diff --git a/config/importmap.rb b/config/importmap.rb index 963d9fbe..2bd82b71 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -27,7 +27,7 @@ under: "mapbox-gl-draw-paint-mode", preload: false # https://github.com/maplibre/maplibre-gl-js -pin "maplibre-gl", preload: false # @5.19.0 +pin "maplibre-gl", preload: false # @5.22.0 # https://github.com/maplibre/maplibre-gl-geocoder pin "maplibre-gl-geocoder", to: "maplibre-gl-geocoder.js", preload: false # https://github.com/GIScience/openrouteservice-js?tab=readme-ov-file diff --git a/vendor/javascript/maplibre-gl.js b/vendor/javascript/maplibre-gl.js index ba58ff32..9019eef3 100644 --- a/vendor/javascript/maplibre-gl.js +++ b/vendor/javascript/maplibre-gl.js @@ -1,6 +1,754 @@ -var e=typeof globalThis!=="undefined"?globalThis:typeof self!=="undefined"?self:global;var c={}; +var e=typeof globalThis<`u`?globalThis:typeof self<`u`?self:global,r={}; /** - * MapLibre GL JS - * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.19.0/LICENSE.txt - */(function(e,u){c=u()})(0,(function(){var c={};var u={};function p(e,p,f){u[e]=f;if(e==="index"){var m="var sharedModule = {}; ("+u.shared+")(sharedModule); ("+u.worker+")(sharedModule);";var g={};u.shared(g);u.index(c,g);typeof window!=="undefined"&&c.setWorkerUrl(window.URL.createObjectURL(new Blob([m],{type:"text/javascript"})));return c}}p("shared",["exports"],(function(c){function u(e,c,u,p){return new(u||(u=Promise))((function(f,m){function g(e){try{x(p.next(e))}catch(e){m(e)}}function y(e){try{x(p.throw(e))}catch(e){m(e)}}function x(e){var c;e.done?f(e.value):(c=e.value,c instanceof u?c:new u((function(e){e(c)}))).then(g,y)}x((p=p.apply(e,c||[])).next())}))}function p(c,u){(this||e).x=c,(this||e).y=u}function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var m,g;"function"==typeof SuppressedError&&SuppressedError,p.prototype={clone(){return new p((this||e).x,(this||e).y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,c){return this.clone()._rotateAround(e,c)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt((this||e).x*(this||e).x+(this||e).y*(this||e).y)},equals(c){return(this||e).x===c.x&&(this||e).y===c.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(c){const u=c.x-(this||e).x,p=c.y-(this||e).y;return u*u+p*p},angle(){return Math.atan2((this||e).y,(this||e).x)},angleTo(c){return Math.atan2((this||e).y-c.y,(this||e).x-c.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(c,u){return Math.atan2((this||e).x*u-(this||e).y*c,(this||e).x*c+(this||e).y*u)},_matMult(c){const u=c[2]*(this||e).x+c[3]*(this||e).y;return(this||e).x=c[0]*(this||e).x+c[1]*(this||e).y,(this||e).y=u,this||e},_add(c){return(this||e).x+=c.x,(this||e).y+=c.y,this||e},_sub(c){return(this||e).x-=c.x,(this||e).y-=c.y,this||e},_mult(c){return(this||e).x*=c,(this||e).y*=c,this||e},_div(c){return(this||e).x/=c,(this||e).y/=c,this||e},_multByPoint(c){return(this||e).x*=c.x,(this||e).y*=c.y,this||e},_divByPoint(c){return(this||e).x/=c.x,(this||e).y/=c.y,this||e},_unit(){return this._div(this.mag()),this||e},_perp(){const c=(this||e).y;return(this||e).y=(this||e).x,(this||e).x=-c,this||e},_rotate(c){const u=Math.cos(c),p=Math.sin(c),f=p*(this||e).x+u*(this||e).y;return(this||e).x=u*(this||e).x-p*(this||e).y,(this||e).y=f,this||e},_rotateAround(c,u){const p=Math.cos(c),f=Math.sin(c),m=u.y+f*((this||e).x-u.x)+p*((this||e).y-u.y);return(this||e).x=u.x+p*((this||e).x-u.x)-f*((this||e).y-u.y),(this||e).y=m,this||e},_round(){return(this||e).x=Math.round((this||e).x),(this||e).y=Math.round((this||e).y),this||e},constructor:p},p.convert=function(e){if(e instanceof p)return e;if(Array.isArray(e))return new p(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new p(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var y=function(){if(g)return m;function c(c,u,p,f){(this||e).cx=3*c,(this||e).bx=3*(p-c)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*u,(this||e).by=3*(f-u)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=c,(this||e).p1y=u,(this||e).p2x=p,(this||e).p2y=f}return g=1,m=c,c.prototype={sampleCurveX:function(c){return(((this||e).ax*c+(this||e).bx)*c+(this||e).cx)*c},sampleCurveY:function(c){return(((this||e).ay*c+(this||e).by)*c+(this||e).cy)*c},sampleCurveDerivativeX:function(c){return(3*(this||e).ax*c+2*(this||e).bx)*c+(this||e).cx},solveCurveX:function(e,c){if(void 0===c&&(c=1e-6),e<0)return 0;if(e>1)return 1;for(var u=e,p=0;p<8;p++){var f=this.sampleCurveX(u)-e;if(Math.abs(f)f?g=u:y=u,u=.5*(y-g)+g;return u},solve:function(e,c){return this.sampleCurveY(this.solveCurveX(e,c))}},m}(),x=f(y);let b,T;function S(){return null==b&&(b="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),b}function P(){if(null==T&&(T=!1,S())){const e=5,c=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(c){for(let u=0;u4&&void 0!==arguments[4]?arguments[4]:"zyx",m=Math.PI/360;c*=m,p*=m,u*=m;var g=Math.sin(c),y=Math.cos(c),x=Math.sin(u),b=Math.cos(u),T=Math.sin(p),S=Math.cos(p);switch(f){case"xyz":e[0]=g*b*S+y*x*T,e[1]=y*x*S-g*b*T,e[2]=y*b*T+g*x*S,e[3]=y*b*S-g*x*T;break;case"xzy":e[0]=g*b*S-y*x*T,e[1]=y*x*S-g*b*T,e[2]=y*b*T+g*x*S,e[3]=y*b*S+g*x*T;break;case"yxz":e[0]=g*b*S+y*x*T,e[1]=y*x*S-g*b*T,e[2]=y*b*T-g*x*S,e[3]=y*b*S+g*x*T;break;case"yzx":e[0]=g*b*S+y*x*T,e[1]=y*x*S+g*b*T,e[2]=y*b*T-g*x*S,e[3]=y*b*S-g*x*T;break;case"zxy":e[0]=g*b*S-y*x*T,e[1]=y*x*S+g*b*T,e[2]=y*b*T+g*x*S,e[3]=y*b*S-g*x*T;break;case"zyx":e[0]=g*b*S-y*x*T,e[1]=y*x*S+g*b*T,e[2]=y*b*T-g*x*S,e[3]=y*b*S+g*x*T;break;default:throw new Error("Unknown angle order "+f)}return e}function Q(){var e=new C(2);return C!=Float32Array&&(e[0]=0,e[1]=0),e}function ee(e,c){var u=new C(2);return u[0]=e,u[1]=c,u}L(),U=new C(4),C!=Float32Array&&(U[0]=0,U[1]=0,U[2]=0,U[3]=0),L(),O(1,0,0),O(0,1,0),W(),W(),R(),Q();const se=8192;function ce(e,c,u){return c*(se/(e.tileSize*Math.pow(2,u-e.tileID.overscaledZ)))}function he(e,c){return(e%c+c)%c}function ue(e,c,u){return e*(1-u)+c*u}function de(e){if(e<=0)return 0;if(e>=1)return 1;const c=e*e,u=c*e;return 4*(e<.5?u:3*(e-c)+u-.75)}function fe(e,c,u,p){const f=new x(e,c,u,p);return e=>f.solve(e)}const me=fe(.25,.1,.25,1);function ge(e,c,u){return Math.min(u,Math.max(c,e))}function ye(e,c,u){const p=u-c,f=((e-c)%p+p)%p+c;return f===c?u:f}function xe(e,...c){for(const u of c)for(const c in u)e[c]=u[c];return e}let ve=1;function be(c,u,p){const f={};for(const p in c)f[p]=u.call(this||e,c[p],p,c);return f}function we(c,u,p){const f={};for(const p in c)u.call(this||e,c[p],p,c)&&(f[p]=c[p]);return f}function Se(e){return Array.isArray(e)?e.map(Se):"object"==typeof e&&e?be(e,Se):e}const Me={};function Ee(e){Me[e]||("undefined"!=typeof console&&console.warn(e),Me[e]=!0)}function Ce(e,c,u){return(u.y-e.y)*(c.x-e.x)>(c.y-e.y)*(u.x-e.x)}function Ae(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}let Ne=null;function Ge(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}const Ue="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function $e(c,p,f,m,g){return u(this||e,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(c,{timestamp:0});try{const u=null==e?void 0:e.format;if(!u||!u.startsWith("BGR")&&!u.startsWith("RGB"))throw new Error(`Unrecognized format ${u}`);const y=u.startsWith("BGR"),x=new Uint8ClampedArray(m*g*4);if(yield e.copyTo(x,function(e,c,u,p,f){const m=4*Math.max(-c,0),g=(Math.max(0,u)-u)*p*4+m,y=4*p,x=Math.max(0,c),b=Math.max(0,u);return{rect:{x:x,y:b,width:Math.min(e.width,c+p)-x,height:Math.min(e.height,u+f)-b},layout:[{offset:g,stride:y}]}}(c,p,f,m,g)),y)for(let e=0;e{e.removeEventListener(c,u,p)}}}function tt(e){return e*Math.PI/180}function it(e){return e/Math.PI*180}const rt={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},nt={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},ot="AbortError";class st extends Error{constructor(e=ot){super(e instanceof Error?e.message:e),this.name=ot,e instanceof Error&&e.stack&&(this.stack=e.stack)}}function at(e){return e.name===ot}const pt={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function ft(e){return pt.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const yt="global-dispatcher";class ct extends Error{constructor(e,c,u,p){super(`AJAXError: ${c} (${e}): ${u}`),this.status=e,this.statusText=c,this.url=u,this.body=p}}const vt=()=>Ae(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,bt=function(c,p){if(/:\/\//.test(c.url)&&!/^https?:|^file:/.test(c.url)){const e=ft(c.url);if(e)return e(c,p);if(Ae(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:c,targetMapId:yt},p)}if(!(/^file:/.test(f=c.url)||/^file:/.test(vt())&&!/^\w+:/.test(f))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(c,p){return u(this||e,void 0,void 0,(function*(){const e=new Request(c.url,{method:c.method||"GET",body:c.body,credentials:c.credentials,headers:c.headers,cache:c.cache,referrer:vt(),signal:p.signal});let u,f;"json"!==c.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{u=yield fetch(e)}catch(e){if(at(e))throw e;throw new ct(0,e.message,c.url,new Blob)}if(!u.ok){const e=yield u.blob();throw new ct(u.status,u.statusText,c.url,e)}f="arrayBuffer"===c.type||"image"===c.type?u.arrayBuffer():"json"===c.type?u.json():u.text();const m=yield f;return p.signal.throwIfAborted(),{data:m,cacheControl:u.headers.get("Cache-Control"),expires:u.headers.get("Expires")}}))}(c,p);if(Ae(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:c,mustQueue:!0,targetMapId:yt},p)}var f;return function(e,c){return new Promise(((u,p)=>{var f;const m=new XMLHttpRequest;m.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(m.responseType="arraybuffer");for(const c in e.headers)m.setRequestHeader(c,e.headers[c]);"json"===e.type&&(m.responseType="text",(null===(f=e.headers)||void 0===f?void 0:f.Accept)||m.setRequestHeader("Accept","application/json")),m.withCredentials="include"===e.credentials,m.onerror=()=>{p(new Error(m.statusText))},m.onload=()=>{if(!c.signal.aborted)if((m.status>=200&&m.status<300||0===m.status)&&null!==m.response){let c=m.response;if("json"===e.type)try{c=JSON.parse(m.response)}catch(e){return void p(e)}u({data:c,cacheControl:m.getResponseHeader("Cache-Control"),expires:m.getResponseHeader("Expires")})}else{const c=new Blob([m.response],{type:m.getResponseHeader("Content-Type")});p(new ct(m.status,m.statusText,e.url,c))}},c.signal.addEventListener("abort",(()=>{m.abort(),p(new st(c.signal.reason))})),m.send(e.body)}))}(c,p)};function wt(e){if(!e||e.indexOf("://")<=0||0===e.indexOf("data:image/")||0===e.indexOf("blob:"))return!0;const c=new URL(e),u=window.location;return c.protocol===u.protocol&&c.host===u.host}function Tt(e,c,u){u[e]&&-1!==u[e].indexOf(c)||(u[e]=u[e]||[],u[e].push(c))}function Pt(e,c,u){if(u&&u[e]){const p=u[e].indexOf(c);-1!==p&&u[e].splice(p,1)}}class mt{constructor(e,c={}){xe(this,c),this.type=e}}class gt extends mt{constructor(e,c={}){super("error",xe({error:e},c))}}class xt{on(e,c){return this._listeners=this._listeners||{},Tt(e,c,this._listeners),{unsubscribe:()=>{this.off(e,c)}}}off(e,c){return Pt(e,c,this._listeners),Pt(e,c,this._oneTimeListeners),this}once(e,c){return c?(this._oneTimeListeners=this._oneTimeListeners||{},Tt(e,c,this._oneTimeListeners),this):new Promise((c=>this.once(e,c)))}fire(e,c){"string"==typeof e&&(e=new mt(e,c||{}));const u=e.type;if(this.listens(u)){e.target=this;const c=this._listeners&&this._listeners[u]?this._listeners[u].slice():[];for(const u of c)u.call(this,e);const p=this._oneTimeListeners&&this._oneTimeListeners[u]?this._oneTimeListeners[u].slice():[];for(const c of p)Pt(u,c,this._oneTimeListeners),c.call(this,e);const f=this._eventedParent;f&&(xe(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),f.fire(e))}else e instanceof gt&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,c){return this._eventedParent=e,this._eventedParentData=c,this}}var Et={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}};const Ct=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function At(e,c){const u={};for(const c in e)"ref"!==c&&(u[c]=e[c]);return Ct.forEach((e=>{e in c&&(u[e]=c[e])})),u}function kt(e,c){if(Array.isArray(e)){if(!Array.isArray(c)||e.length!==c.length)return!1;for(let u=0;u`:"value"===e.itemType.kind?"array":`array<${c}>`}return e.kind}const ki=[li,ci,hi,di,pi,fi,xi,mi,Ii(gi),vi,wi,bi,Ti,Si];function Li(e,c){if("error"===c.kind)return null;if("array"===e.kind){if("array"===c.kind&&(0===c.N&&"value"===c.itemType.kind||!Li(e.itemType,c.itemType))&&("number"!=typeof e.N||e.N===c.N))return null}else{if(e.kind===c.kind)return null;if("value"===e.kind)for(const e of ki)if(!Li(e,c))return null}return`Expected ${Mi(e)} but found ${Mi(c)} instead.`}function Bi(e,c){return c.some((c=>c.kind===e.kind))}function Vi(e,c){return c.some((c=>"null"===c?null===e:"array"===c?Array.isArray(e):"object"===c?e&&!Array.isArray(e)&&"object"==typeof e:c===typeof e))}function ji(e,c){return"array"===e.kind&&"array"===c.kind?e.itemType.kind===c.itemType.kind&&"number"==typeof e.N:e.kind===c.kind}const Ni=.96422,Ui=.82521,qi=4/29,$i=6/29,Zi=3*$i*$i,Wi=$i*$i*$i,Hi=Math.PI/180,Xi=180/Math.PI;function Yi(e){return(e%=360)<0&&(e+=360),e}function Ki([e,c,u,p]){let f,m;const g=Qi((.2225045*(e=Ji(e))+.7168786*(c=Ji(c))+.0606169*(u=Ji(u)))/1);e===c&&c===u?f=m=g:(f=Qi((.4360747*e+.3850649*c+.1430804*u)/Ni),m=Qi((.0139322*e+.0971045*c+.7141733*u)/Ui));const y=116*g-16;return[y<0?0:y,500*(f-g),200*(g-m),p]}function Ji(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Qi(e){return e>Wi?Math.pow(e,1/3):e/Zi+qi}function cr([e,c,u,p]){let f=(e+16)/116,m=isNaN(c)?f:f+c/500,g=isNaN(u)?f:f-u/200;return f=1*ur(f),m=Ni*ur(m),g=Ui*ur(g),[hr(3.1338561*m-1.6168667*f-.4906146*g),hr(-.9787684*m+1.9161415*f+.033454*g),hr(.0719453*m-.2289914*f+1.4052427*g),p]}function hr(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function ur(e){return e>$i?e*e*e:Zi*(e-qi)}const dr=Object.hasOwn||function(e,c){return Object.prototype.hasOwnProperty.call(e,c)};function pr(e,c){return dr(e,c)?e[c]:void 0}function _r(e){return parseInt(e.padEnd(2,e),16)/255}function gr(e,c){return yr(c?e/100:e,0,1)}function yr(e,c,u){return Math.min(Math.max(c,e),u)}function xr(e){return!e.some(Number.isNaN)}const vr={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function br(e,c,u){return e+u*(c-e)}function wr(e,c,u){return e.map(((e,p)=>br(e,c[p],u)))}class Ie{constructor(e,c,u,p=1,f=!0){this.r=e,this.g=c,this.b=u,this.a=p,f||(this.r*=p,this.g*=p,this.b*=p,p||this.overwriteGetter("rgb",[e,c,u,p]))}static parse(e){if(e instanceof Ie)return e;if("string"!=typeof e)return;const c=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const c=pr(vr,e);if(c){const[e,u,p]=c;return[e/255,u/255,p/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const c=e.length<6?1:2;let u=1;return[_r(e.slice(u,u+=c)),_r(e.slice(u,u+=c)),_r(e.slice(u,u+=c)),_r(e.slice(u,u+c)||"ff")]}if(e.startsWith("rgb")){const c=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(c){const[e,u,p,f,m,g,y,x,b,T,S,P]=c,I=[f||" ",y||" ",T].join("");if(" "===I||" /"===I||",,"===I||",,,"===I){const e=[p,g,b].join(""),c="%%%"===e?100:""===e?255:0;if(c){const e=[yr(+u/c,0,1),yr(+m/c,0,1),yr(+x/c,0,1),S?gr(+S,P):1];if(xr(e))return e}}return}}const u=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(u){const[e,c,p,f,m,g,y,x,b]=u,T=[p||" ",m||" ",y].join("");if(" "===T||" /"===T||",,"===T||",,,"===T){const e=[+c,yr(+f,0,100),yr(+g,0,100),x?gr(+x,b):1];if(xr(e))return function([e,c,u,p]){function f(p){const f=(p+e/30)%12,m=c*Math.min(u,1-u);return u-m*Math.max(-1,Math.min(f-3,9-f,1))}return e=Yi(e),c/=100,u/=100,[f(0),f(8),f(4),p]}(e)}}}(e);return c?new Ie(...c,!1):void 0}get rgb(){const{r:e,g:c,b:u,a:p}=this,f=p||1/0;return this.overwriteGetter("rgb",[e/f,c/f,u/f,p])}get hcl(){return this.overwriteGetter("hcl",function(e){const[c,u,p,f]=Ki(e),m=Math.sqrt(u*u+p*p);return[Math.round(1e4*m)?Yi(Math.atan2(p,u)*Xi):NaN,m,c,f]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Ki(this.rgb))}overwriteGetter(e,c){return Object.defineProperty(this,e,{value:c}),c}toString(){const[e,c,u,p]=this.rgb;return`rgba(${[e,c,u].map((e=>Math.round(255*e))).join(",")},${p})`}static interpolate(e,c,u,p="rgb"){switch(p){case"rgb":{const[p,f,m,g]=wr(e.rgb,c.rgb,u);return new Ie(p,f,m,g,!1)}case"hcl":{const[p,f,m,g]=e.hcl,[y,x,b,T]=c.hcl;let S,P;if(isNaN(p)||isNaN(y))isNaN(p)?isNaN(y)?S=NaN:(S=y,1!==m&&0!==m||(P=x)):(S=p,1!==b&&0!==b||(P=f));else{let e=y-p;y>p&&e>180?e-=360:y180&&(e+=360),S=p+u*e}const[I,C,R,F]=function([e,c,u,p]){return e=isNaN(e)?0:e*Hi,cr([u,Math.cos(e)*c,Math.sin(e)*c,p])}([S,null!=P?P:br(f,x,u),br(m,b,u),br(g,T,u)]);return new Ie(I,C,R,F,!1)}case"lab":{const[p,f,m,g]=cr(wr(e.lab,c.lab,u));return new Ie(p,f,m,g,!1)}}}}Ie.black=new Ie(0,0,0,1),Ie.white=new Ie(1,1,1,1),Ie.transparent=new Ie(0,0,0,0),Ie.red=new Ie(1,0,0,1);class Te{constructor(e,c,u){this.sensitivity=e?c?"variant":"case":c?"accent":"base",this.locale=u,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,c){return this.collator.compare(e,c)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const Sr=["bottom","center","top"];class Fe{constructor(e,c,u,p,f,m){this.text=e,this.image=c,this.scale=u,this.fontStack=p,this.textColor=f,this.verticalAlign=m}}class De{constructor(e){this.sections=e}static fromString(e){return new De([new Fe(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((e=>0!==e.text.length||e.image&&0!==e.image.name.length))}static factory(e){return e instanceof De?e:De.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}}class Pe{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Pe)return e;if("number"==typeof e)return new Pe([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const c of e)if("number"!=typeof c)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Pe(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,c,u){return new Pe(wr(e.values,c.values,u))}}class ze{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof ze)return e;if("number"==typeof e)return new ze([e]);if(Array.isArray(e)){for(const c of e)if("number"!=typeof c)return;return new ze(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,c,u){return new ze(wr(e.values,c.values,u))}}class Be{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Be)return e;if("string"==typeof e){const c=Ie.parse(e);if(!c)return;return new Be([c])}if(!Array.isArray(e))return;const c=[];for(const u of e){if("string"!=typeof u)return;const e=Ie.parse(u);if(!e)return;c.push(e)}return new Be(c)}toString(){return JSON.stringify(this.values)}static interpolate(e,c,u,p="rgb"){const f=[];if(e.values.length!=c.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${c.values.length}), cannot interpolate.`);for(let m=0;m=0&&e<=255&&"number"==typeof c&&c>=0&&c<=255&&"number"==typeof u&&u>=0&&u<=255?void 0===p||"number"==typeof p&&p>=0&&p<=1?null:`Invalid rgba value [${[e,c,u,p].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof p?[e,c,u,p]:[e,c,u]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ar(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof Re||e instanceof Ie||e instanceof Te||e instanceof De||e instanceof Pe||e instanceof ze||e instanceof Be||e instanceof Le||e instanceof Oe)return!0;if(Array.isArray(e)){for(const c of e)if(!Ar(c))return!1;return!0}if("object"==typeof e){for(const c in e)if(!Ar(e[c]))return!1;return!0}return!1}function Dr(e){if(null===e)return li;if("string"==typeof e)return hi;if("boolean"==typeof e)return di;if("number"==typeof e)return ci;if(e instanceof Ie)return pi;if(e instanceof Re)return fi;if(e instanceof Te)return yi;if(e instanceof De)return xi;if(e instanceof Pe)return vi;if(e instanceof ze)return wi;if(e instanceof Be)return bi;if(e instanceof Le)return Si;if(e instanceof Oe)return Ti;if(Array.isArray(e)){const c=e.length;let u;for(const c of e){const e=Dr(c);if(u){if(u===e)continue;u=gi;break}u=e}return Ii(u||gi,c)}return mi}function zr(e){const c=typeof e;return null===e?"":"string"===c||"number"===c||"boolean"===c?String(e):e instanceof Ie||e instanceof Re||e instanceof De||e instanceof Pe||e instanceof ze||e instanceof Be||e instanceof Le||e instanceof Oe?e.toString():JSON.stringify(e)}class qe{constructor(e,c){this.type=e,this.value=c}static parse(e,c){if(2!==e.length)return c.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Ar(e[1]))return c.error("invalid value");const u=e[1];let p=Dr(u);const f=c.expectedType;return"array"!==p.kind||0!==p.N||!f||"array"!==f.kind||"number"==typeof f.N&&0!==f.N||(p=f),new qe(p,u)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const kr={string:hi,number:ci,boolean:di,object:mi};class Xe{constructor(e,c){this.type=e,this.args=c}static parse(e,c){if(e.length<2)return c.error("Expected at least one argument.");let u,p=1;const f=e[0];if("array"===f){let f,m;if(e.length>2){const u=e[1];if("string"!=typeof u||!(u in kr)||"object"===u)return c.error('The item type argument of "array" must be one of string, number, boolean',1);f=kr[u],p++}else f=gi;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return c.error('The length argument to "array" must be a positive integer literal',2);m=e[2],p++}u=Ii(f,m)}else{if(!kr[f])throw new Error(`Types doesn't contain name = ${f}`);u=kr[f]}const m=[];for(;pe.outputDefined()))}}const Rr={"to-boolean":di,"to-color":pi,"to-number":ci,"to-string":hi};class Ze{constructor(e,c){this.type=e,this.args=c}static parse(e,c){if(e.length<2)return c.error("Expected at least one argument.");const u=e[0];if(!Rr[u])throw new Error(`Can't parse ${u} as it is not part of the known types`);if(("to-boolean"===u||"to-string"===u)&&2!==e.length)return c.error("Expected one argument.");const p=Rr[u],f=[];for(let u=1;u4?`Invalid rgba value ${JSON.stringify(c)}: expected an array containing either three or four numeric values.`:Cr(c[0],c[1],c[2],c[3]),!u))return new Ie(c[0]/255,c[1]/255,c[2]/255,c[3])}throw new Ve(u||`Could not parse color from value '${"string"==typeof c?c:JSON.stringify(c)}'`)}case"padding":{let c;for(const u of this.args){c=u.evaluate(e);const p=Pe.parse(c);if(p)return p}throw new Ve(`Could not parse padding from value '${"string"==typeof c?c:JSON.stringify(c)}'`)}case"numberArray":{let c;for(const u of this.args){c=u.evaluate(e);const p=ze.parse(c);if(p)return p}throw new Ve(`Could not parse numberArray from value '${"string"==typeof c?c:JSON.stringify(c)}'`)}case"colorArray":{let c;for(const u of this.args){c=u.evaluate(e);const p=Be.parse(c);if(p)return p}throw new Ve(`Could not parse colorArray from value '${"string"==typeof c?c:JSON.stringify(c)}'`)}case"variableAnchorOffsetCollection":{let c;for(const u of this.args){c=u.evaluate(e);const p=Le.parse(c);if(p)return p}throw new Ve(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof c?c:JSON.stringify(c)}'`)}case"number":{let c=null;for(const u of this.args){if(c=u.evaluate(e),null===c)return 0;const p=Number(c);if(!isNaN(p))return p}throw new Ve(`Could not convert ${JSON.stringify(c)} to number.`)}case"formatted":return De.fromString(zr(this.args[0].evaluate(e)));case"resolvedImage":return Oe.fromString(zr(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return zr(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Lr=["Unknown","Point","LineString","Polygon"];class Ke{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Lr[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let c=this._parseColorCache.get(e);return c||(c=Ie.parse(e),this._parseColorCache.set(e,c)),c}}class We{constructor(e,c,u=[],p,f=new Bt,m=[]){this.registry=e,this.path=u,this.key=u.map((e=>`[${e}]`)).join(""),this.scope=f,this.errors=m,this.expectedType=p,this._isConstant=c}parse(e,c,u,p,f={}){return c?this.concat(c,u,p)._parse(e,f):this._parse(e,f)}_parse(e,c){function u(e,c,u){return"assert"===u?new Xe(c,[e]):"coerce"===u?new Ze(c,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const p=e[0];if("string"!=typeof p)return this.error(`Expression name must be a string, but found ${typeof p} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const f=this.registry[p];if(f){let p=f.parse(e,this);if(!p)return null;if(this.expectedType){const e=this.expectedType,f=p.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==f.kind){if("projectionDefinition"===e.kind&&["string","array"].includes(f.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(f.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(f.kind)||"colorArray"===e.kind&&["value","string","array"].includes(f.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(f.kind))p=u(p,e,c.typeAnnotation||"coerce");else if(this.checkSubtype(e,f))return null}else p=u(p,e,c.typeAnnotation||"assert")}if(!(p instanceof qe)&&"resolvedImage"!==p.type.kind&&this._isConstant(p)){const c=new Ke;try{p=new qe(p.type,p.evaluate(c))}catch(e){return this.error(e.message),null}}return p}return this.error(`Unknown expression "${p}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,c,u){const p="number"==typeof e?this.path.concat(e):this.path,f=u?this.scope.concat(u):this.scope;return new We(this.registry,this._isConstant,p,c||null,f,this.errors)}error(e,...c){const u=`${this.key}${c.map((e=>`[${e}]`)).join("")}`;this.errors.push(new zt(u,e))}checkSubtype(e,c){const u=Li(e,c);return u&&this.error(u),u}}class Je{constructor(e,c){this.type=c.type,this.bindings=[].concat(e),this.result=c}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const c of this.bindings)e(c[1]);e(this.result)}static parse(e,c){if(e.length<4)return c.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const u=[];for(let p=1;p=u.length)throw new Ve(`Array index out of bounds: ${c} > ${u.length-1}.`);if(c!==Math.floor(c))throw new Ve(`Array index must be an integer, but found ${c} instead.`);return u[c]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class er{constructor(e,c){this.type=di,this.needle=e,this.haystack=c}static parse(e,c){if(3!==e.length)return c.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const u=c.parse(e[1],1,gi),p=c.parse(e[2],2,gi);return u&&p?Bi(u.type,[di,hi,ci,li,gi])?new er(u,p):c.error(`Expected first argument to be of type boolean, string, number or null, but found ${Mi(u.type)} instead`):null}evaluate(e){const c=this.needle.evaluate(e),u=this.haystack.evaluate(e);if(!u)return!1;if(!Vi(c,["boolean","string","number","null"]))throw new Ve(`Expected first argument to be of type boolean, string, number or null, but found ${Mi(Dr(c))} instead.`);if(!Vi(u,["string","array"]))throw new Ve(`Expected second argument to be of type array or string, but found ${Mi(Dr(u))} instead.`);return u.indexOf(c)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class rr{constructor(e,c,u){this.type=ci,this.needle=e,this.haystack=c,this.fromIndex=u}static parse(e,c){if(e.length<=2||e.length>=5)return c.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const u=c.parse(e[1],1,gi),p=c.parse(e[2],2,gi);if(!u||!p)return null;if(!Bi(u.type,[di,hi,ci,li,gi]))return c.error(`Expected first argument to be of type boolean, string, number or null, but found ${Mi(u.type)} instead`);if(4===e.length){const f=c.parse(e[3],3,ci);return f?new rr(u,p,f):null}return new rr(u,p)}evaluate(e){const c=this.needle.evaluate(e),u=this.haystack.evaluate(e);if(!Vi(c,["boolean","string","number","null"]))throw new Ve(`Expected first argument to be of type boolean, string, number or null, but found ${Mi(Dr(c))} instead.`);let p;if(this.fromIndex&&(p=this.fromIndex.evaluate(e)),Vi(u,["string"])){const e=u.indexOf(c,p);return-1===e?-1:[...u.slice(0,e)].length}if(Vi(u,["array"]))return u.indexOf(c,p);throw new Ve(`Expected second argument to be of type array or string, but found ${Mi(Dr(u))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class nr{constructor(e,c,u,p,f,m){this.inputType=e,this.type=c,this.input=u,this.cases=p,this.outputs=f,this.otherwise=m}static parse(e,c){if(e.length<5)return c.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return c.error("Expected an even number of arguments.");let u,p;c.expectedType&&"value"!==c.expectedType.kind&&(p=c.expectedType);const f={},m=[];for(let g=2;gNumber.MAX_SAFE_INTEGER)return b.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return b.error("Numeric branch labels must be integer values.");if(u){if(b.checkSubtype(u,Dr(e)))return null}else u=Dr(e);if(void 0!==f[String(e)])return b.error("Branch labels must be unique.");f[String(e)]=m.length}const T=c.parse(x,g,p);if(!T)return null;p=p||T.type,m.push(T)}const g=c.parse(e[1],1,gi);if(!g)return null;const y=c.parse(e[e.length-1],e.length-1,p);return y?"value"!==g.type.kind&&c.concat(1).checkSubtype(u,g.type)?null:new nr(u,p,g,f,m,y):null}evaluate(e){const c=this.input.evaluate(e);return(Dr(c)===this.inputType&&this.outputs[this.cases[c]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}}class ir{constructor(e,c,u){this.type=e,this.branches=c,this.otherwise=u}static parse(e,c){if(e.length<4)return c.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return c.error("Expected an odd number of arguments.");let u;c.expectedType&&"value"!==c.expectedType.kind&&(u=c.expectedType);const p=[];for(let f=1;fc.outputDefined()))&&this.otherwise.outputDefined()}}class sr{constructor(e,c,u,p){this.type=e,this.input=c,this.beginIndex=u,this.endIndex=p}static parse(e,c){if(e.length<=2||e.length>=5)return c.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const u=c.parse(e[1],1,gi),p=c.parse(e[2],2,ci);if(!u||!p)return null;if(!Bi(u.type,[Ii(gi),hi,gi]))return c.error(`Expected first argument to be of type array or string, but found ${Mi(u.type)} instead`);if(4===e.length){const f=c.parse(e[3],3,ci);return f?new sr(u.type,u,p,f):null}return new sr(u.type,u,p)}evaluate(e){const c=this.input.evaluate(e),u=this.beginIndex.evaluate(e);let p;if(this.endIndex&&(p=this.endIndex.evaluate(e)),Vi(c,["string"]))return[...c].slice(u,p).join("");if(Vi(c,["array"]))return c.slice(u,p);throw new Ve(`Expected first argument to be of type array or string, but found ${Mi(Dr(c))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function Br(e,c){const u=e.length-1;let p,f,m=0,g=u,y=0;for(;m<=g;)if(y=Math.floor((m+g)/2),p=e[y],f=e[y+1],p<=c){if(y===u||cc))throw new Ve("Input is not a number.");g=y-1}return 0}class or{constructor(e,c,u){this.type=e,this.input=c,this.labels=[],this.outputs=[];for(const[e,c]of u)this.labels.push(e),this.outputs.push(c)}static parse(e,c){if(e.length-1<4)return c.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return c.error("Expected an even number of arguments.");const u=c.parse(e[1],1,ci);if(!u)return null;const p=[];let f=null;c.expectedType&&"value"!==c.expectedType.kind&&(f=c.expectedType);for(let u=1;u=m)return c.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',y);const b=c.parse(g,x,f);if(!b)return null;f=f||b.type,p.push([m,b])}return new or(f,u,p)}evaluate(e){const c=this.labels,u=this.outputs;if(1===c.length)return u[0].evaluate(e);const p=this.input.evaluate(e);if(p<=c[0])return u[0].evaluate(e);const f=c.length;return p>=c[f-1]?u[f-1].evaluate(e):u[Br(c,p)].evaluate(e)}eachChild(e){e(this.input);for(const c of this.outputs)e(c)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Or(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Vr,jr,Nr=function(){if(jr)return Vr;function c(c,u,p,f){(this||e).cx=3*c,(this||e).bx=3*(p-c)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*u,(this||e).by=3*(f-u)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=c,(this||e).p1y=u,(this||e).p2x=p,(this||e).p2y=f}return jr=1,Vr=c,c.prototype={sampleCurveX:function(c){return(((this||e).ax*c+(this||e).bx)*c+(this||e).cx)*c},sampleCurveY:function(c){return(((this||e).ay*c+(this||e).by)*c+(this||e).cy)*c},sampleCurveDerivativeX:function(c){return(3*(this||e).ax*c+2*(this||e).bx)*c+(this||e).cx},solveCurveX:function(e,c){if(void 0===c&&(c=1e-6),e<0)return 0;if(e>1)return 1;for(var u=e,p=0;p<8;p++){var f=this.sampleCurveX(u)-e;if(Math.abs(f)f?g=u:y=u,u=.5*(y-g)+g;return u},solve:function(e,c){return this.sampleCurveY(this.solveCurveX(e,c))}},Vr}(),Gr=Or(Nr);class fr{constructor(e,c,u,p,f){this.type=e,this.operator=c,this.interpolation=u,this.input=p,this.labels=[],this.outputs=[];for(const[e,c]of f)this.labels.push(e),this.outputs.push(c)}static interpolationFactor(e,c,u,p){let f=0;if("exponential"===e.name)f=Ur(c,e.base,u,p);else if("linear"===e.name)f=Ur(c,1,u,p);else if("cubic-bezier"===e.name){const m=e.controlPoints;f=new Gr(m[0],m[1],m[2],m[3]).solve(Ur(c,1,u,p))}return f}static parse(e,c){let[u,p,f,...m]=e;if(!Array.isArray(p)||0===p.length)return c.error("Expected an interpolation type expression.",1);if("linear"===p[0])p={name:"linear"};else if("exponential"===p[0]){const e=p[1];if("number"!=typeof e)return c.error("Exponential interpolation requires a numeric base.",1,1);p={name:"exponential",base:e}}else{if("cubic-bezier"!==p[0])return c.error(`Unknown interpolation type ${String(p[0])}`,1,0);{const e=p.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return c.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);p={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return c.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return c.error("Expected an even number of arguments.");if(f=c.parse(f,2,ci),!f)return null;const g=[];let y=null;"interpolate-hcl"!==u&&"interpolate-lab"!==u||c.expectedType==bi?c.expectedType&&"value"!==c.expectedType.kind&&(y=c.expectedType):y=pi;for(let e=0;e=u)return c.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',f);const b=c.parse(p,x,y);if(!b)return null;y=y||b.type,g.push([u,b])}return ji(y,ci)||ji(y,fi)||ji(y,pi)||ji(y,vi)||ji(y,wi)||ji(y,bi)||ji(y,Si)||ji(y,Ii(ci))?new fr(y,u,p,f,g):c.error(`Type ${Mi(y)} is not interpolatable.`)}evaluate(e){const c=this.labels,u=this.outputs;if(1===c.length)return u[0].evaluate(e);const p=this.input.evaluate(e);if(p<=c[0])return u[0].evaluate(e);const f=c.length;if(p>=c[f-1])return u[f-1].evaluate(e);const m=Br(c,p),g=fr.interpolationFactor(this.interpolation,p,c[m],c[m+1]),y=u[m].evaluate(e),x=u[m+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return br(y,x,g);case"color":return Ie.interpolate(y,x,g);case"padding":return Pe.interpolate(y,x,g);case"colorArray":return Be.interpolate(y,x,g);case"numberArray":return ze.interpolate(y,x,g);case"variableAnchorOffsetCollection":return Le.interpolate(y,x,g);case"array":return wr(y,x,g);case"projectionDefinition":return Re.interpolate(y,x,g)}case"interpolate-hcl":switch(this.type.kind){case"color":return Ie.interpolate(y,x,g,"hcl");case"colorArray":return Be.interpolate(y,x,g,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Ie.interpolate(y,x,g,"lab");case"colorArray":return Be.interpolate(y,x,g,"lab")}}}eachChild(e){e(this.input);for(const c of this.outputs)e(c)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Ur(e,c,u,p){const f=p-u,m=e-u;return 0===f?0:1===c?m/f:(Math.pow(c,m)-1)/(Math.pow(c,f)-1)}const qr={color:Ie.interpolate,number:br,padding:Pe.interpolate,numberArray:ze.interpolate,colorArray:Be.interpolate,variableAnchorOffsetCollection:Le.interpolate,array:wr};class mr{constructor(e,c){this.type=e,this.args=c}static parse(e,c){if(e.length<2)return c.error("Expected at least one argument.");let u=null;const p=c.expectedType;p&&"value"!==p.kind&&(u=p);const f=[];for(const p of e.slice(1)){const e=c.parse(p,1+f.length,u,void 0,{typeAnnotation:"omit"});if(!e)return null;u=u||e.type,f.push(e)}if(!u)throw new Error("No output type");const m=p&&f.some((e=>Li(p,e.type)));return new mr(m?gi:u,f)}evaluate(e){let c,u=null,p=0;for(const f of this.args)if(p++,u=f.evaluate(e),u&&u instanceof Oe&&!u.available&&(c||(c=u.name),u=null,p===this.args.length&&(u=c)),null!==u)break;return u}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function $r(e,c){return"=="===e||"!="===e?"boolean"===c.kind||"string"===c.kind||"number"===c.kind||"null"===c.kind||"value"===c.kind:"string"===c.kind||"number"===c.kind||"value"===c.kind}function Zr(e,c,u,p){return 0===p.compare(c,u)}function Xr(e,c,u){const p="=="!==e&&"!="!==e;return class i{constructor(e,c,u){this.type=di,this.lhs=e,this.rhs=c,this.collator=u,this.hasUntypedArgument="value"===e.type.kind||"value"===c.type.kind}static parse(e,c){if(3!==e.length&&4!==e.length)return c.error("Expected two or three arguments.");const u=e[0];let f=c.parse(e[1],1,gi);if(!f)return null;if(!$r(u,f.type))return c.concat(1).error(`"${u}" comparisons are not supported for type '${Mi(f.type)}'.`);let m=c.parse(e[2],2,gi);if(!m)return null;if(!$r(u,m.type))return c.concat(2).error(`"${u}" comparisons are not supported for type '${Mi(m.type)}'.`);if(f.type.kind!==m.type.kind&&"value"!==f.type.kind&&"value"!==m.type.kind)return c.error(`Cannot compare types '${Mi(f.type)}' and '${Mi(m.type)}'.`);p&&("value"===f.type.kind&&"value"!==m.type.kind?f=new Xe(m.type,[f]):"value"!==f.type.kind&&"value"===m.type.kind&&(m=new Xe(f.type,[m])));let g=null;if(4===e.length){if("string"!==f.type.kind&&"string"!==m.type.kind&&"value"!==f.type.kind&&"value"!==m.type.kind)return c.error("Cannot use collator to compare non-string types.");if(g=c.parse(e[3],3,yi),!g)return null}return new i(f,m,g)}evaluate(f){const m=this.lhs.evaluate(f),g=this.rhs.evaluate(f);if(p&&this.hasUntypedArgument){const c=Dr(m),u=Dr(g);if(c.kind!==u.kind||"string"!==c.kind&&"number"!==c.kind)throw new Ve(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${c.kind}, ${u.kind}) instead.`)}if(this.collator&&!p&&this.hasUntypedArgument){const e=Dr(m),u=Dr(g);if("string"!==e.kind||"string"!==u.kind)return c(f,m,g)}return this.collator?u(f,m,g,this.collator.evaluate(f)):c(f,m,g)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const Yr=Xr("==",(function(e,c,u){return c===u}),Zr),Kr=Xr("!=",(function(e,c,u){return c!==u}),(function(e,c,u,p){return!Zr(0,c,u,p)})),Jr=Xr("<",(function(e,c,u){return c",(function(e,c,u){return c>u}),(function(e,c,u,p){return p.compare(c,u)>0})),en=Xr("<=",(function(e,c,u){return c<=u}),(function(e,c,u,p){return p.compare(c,u)<=0})),tn=Xr(">=",(function(e,c,u){return c>=u}),(function(e,c,u,p){return p.compare(c,u)>=0}));class Mr{constructor(e,c,u){this.type=yi,this.locale=u,this.caseSensitive=e,this.diacriticSensitive=c}static parse(e,c){if(2!==e.length)return c.error("Expected one argument.");const u=e[1];if("object"!=typeof u||Array.isArray(u))return c.error("Collator options argument must be an object.");const p=c.parse(void 0!==u["case-sensitive"]&&u["case-sensitive"],1,di);if(!p)return null;const f=c.parse(void 0!==u["diacritic-sensitive"]&&u["diacritic-sensitive"],1,di);if(!f)return null;let m=null;return u.locale&&(m=c.parse(u.locale,1,hi),!m)?null:new Mr(p,f,m)}evaluate(e){return new Te(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class Ir{constructor(e,c,u,p,f){this.type=hi,this.number=e,this.locale=c,this.currency=u,this.minFractionDigits=p,this.maxFractionDigits=f}static parse(e,c){if(3!==e.length)return c.error("Expected two arguments.");const u=c.parse(e[1],1,ci);if(!u)return null;const p=e[2];if("object"!=typeof p||Array.isArray(p))return c.error("NumberFormat options argument must be an object.");let f=null;if(p.locale&&(f=c.parse(p.locale,1,hi),!f))return null;let m=null;if(p.currency&&(m=c.parse(p.currency,1,hi),!m))return null;let g=null;if(p["min-fraction-digits"]&&(g=c.parse(p["min-fraction-digits"],1,ci),!g))return null;let y=null;return p["max-fraction-digits"]&&(y=c.parse(p["max-fraction-digits"],1,ci),!y)?null:new Ir(u,f,m,g,y)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Tr{constructor(e){this.type=xi,this.sections=e}static parse(e,c){if(e.length<2)return c.error("Expected at least one argument.");const u=e[1];if(!Array.isArray(u)&&"object"==typeof u)return c.error("First argument must be an image or text section.");const p=[];let f=!1;for(let u=1;u<=e.length-1;++u){const m=e[u];if(f&&"object"==typeof m&&!Array.isArray(m)){f=!1;let e=null;if(m["font-scale"]&&(e=c.parse(m["font-scale"],1,ci),!e))return null;let u=null;if(m["text-font"]&&(u=c.parse(m["text-font"],1,Ii(hi)),!u))return null;let g=null;if(m["text-color"]&&(g=c.parse(m["text-color"],1,pi),!g))return null;let y=null;if(m["vertical-align"]){if("string"==typeof m["vertical-align"]&&!Sr.includes(m["vertical-align"]))return c.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${m["vertical-align"]}' instead.`);if(y=c.parse(m["vertical-align"],1,hi),!y)return null}const x=p[p.length-1];x.scale=e,x.font=u,x.textColor=g,x.verticalAlign=y}else{const m=c.parse(e[u],1,gi);if(!m)return null;const g=m.type.kind;if("string"!==g&&"value"!==g&&"null"!==g&&"resolvedImage"!==g)return c.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");f=!0,p.push({content:m,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Tr(p)}evaluate(e){return new De(this.sections.map((c=>{const u=c.content.evaluate(e);return Dr(u)===Ti?new Fe("",u,null,null,null,c.verticalAlign?c.verticalAlign.evaluate(e):null):new Fe(zr(u),null,c.scale?c.scale.evaluate(e):null,c.font?c.font.evaluate(e).join(","):null,c.textColor?c.textColor.evaluate(e):null,c.verticalAlign?c.verticalAlign.evaluate(e):null)})))}eachChild(e){for(const c of this.sections)e(c.content),c.scale&&e(c.scale),c.font&&e(c.font),c.textColor&&e(c.textColor),c.verticalAlign&&e(c.verticalAlign)}outputDefined(){return!1}}class Er{constructor(e){this.type=Ti,this.input=e}static parse(e,c){if(2!==e.length)return c.error("Expected two arguments.");const u=c.parse(e[1],1,hi);return u?new Er(u):c.error("No image name provided.")}evaluate(e){const c=this.input.evaluate(e),u=Oe.fromString(c);return u&&e.availableImages&&(u.available=e.availableImages.indexOf(c)>-1),u}eachChild(e){e(this.input)}outputDefined(){return!1}}class Fr{constructor(e){this.type=ci,this.input=e}static parse(e,c){if(2!==e.length)return c.error(`Expected 1 argument, but found ${e.length-1} instead.`);const u=c.parse(e[1],1);return u?"array"!==u.type.kind&&"string"!==u.type.kind&&"value"!==u.type.kind?c.error(`Expected argument of type string or array, but found ${Mi(u.type)} instead.`):new Fr(u):null}evaluate(e){const c=this.input.evaluate(e);if("string"==typeof c)return[...c].length;if(Array.isArray(c))return c.length;throw new Ve(`Expected value to be of type string or array, but found ${Mi(Dr(c))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const rn=8192;function nn(e,c){const u=(180+e[0])/360,p=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,f=Math.pow(2,c.z);return[Math.round(u*f*rn),Math.round(p*f*rn)]}function sn(e,c){const u=Math.pow(2,c.z);return[(f=(e[0]/rn+c.x)/u,360*f-180),(p=(e[1]/rn+c.y)/u,360/Math.PI*Math.atan(Math.exp((180-360*p)*Math.PI/180))-90)];var p,f}function an(e,c){e[0]=Math.min(e[0],c[0]),e[1]=Math.min(e[1],c[1]),e[2]=Math.max(e[2],c[0]),e[3]=Math.max(e[3],c[1])}function ln(e,c){return!(e[0]<=c[0]||e[2]>=c[2]||e[1]<=c[1]||e[3]>=c[3])}function cn(e,c,u){const p=e[0]-c[0],f=e[1]-c[1],m=e[0]-u[0],g=e[1]-u[1];return p*g-m*f==0&&p*m<=0&&f*g<=0}function hn(e,c,u,p){return 0!=(f=[p[0]-u[0],p[1]-u[1]])[0]*(m=[c[0]-e[0],c[1]-e[1]])[1]-f[1]*m[0]&&!(!_n(e,c,u,p)||!_n(u,p,e,c));var f,m}function un(e,c,u){for(const p of u)for(let u=0;u(f=e)[1]!=(g=y[c+1])[1]>f[1]&&f[0]<(g[0]-m[0])*(f[1]-m[1])/(g[1]-m[1])+m[0]&&(p=!p)}var f,m,g;return p}function pn(e,c){for(const u of c)if(dn(e,u))return!0;return!1}function fn(e,c){for(const u of e)if(!dn(u,c))return!1;for(let u=0;u0&&y<0||g<0&&y>0}function gn(e,c,u){const p=[];for(let f=0;fu[2]){const c=.5*p;let f=e[0]-u[0]>c?-p:u[0]-e[0]>c?p:0;0===f&&(f=e[0]-u[2]>c?-p:u[2]-e[0]>c?p:0),e[0]+=f}an(c,e)}function vn(e,c,u,p){const f=Math.pow(2,p.z)*rn,m=[p.x*rn,p.y*rn],g=[];for(const p of e)for(const e of p){const p=[e.x+m[0],e.y+m[1]];xn(p,c,u,f),g.push(p)}return g}function bn(e,c,u,p){const f=Math.pow(2,p.z)*rn,m=[p.x*rn,p.y*rn],g=[];for(const u of e){const e=[];for(const p of u){const u=[p.x+m[0],p.y+m[1]];an(c,u),e.push(u)}g.push(e)}if(c[2]-c[0]<=f/2){(y=c)[0]=y[1]=1/0,y[2]=y[3]=-1/0;for(const e of g)for(const p of e)xn(p,c,u,f)}var y;return g}class Hr{constructor(e,c){this.type=di,this.geojson=e,this.geometries=c}static parse(e,c){if(2!==e.length)return c.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Ar(e[1])){const c=e[1];if("FeatureCollection"===c.type){const e=[];for(const u of c.features){const{type:c,coordinates:p}=u.geometry;"Polygon"===c&&e.push(p),"MultiPolygon"===c&&e.push(...p)}if(e.length)return new Hr(c,{type:"MultiPolygon",coordinates:e})}else if("Feature"===c.type){const e=c.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Hr(c,c.geometry)}else if("Polygon"===c.type||"MultiPolygon"===c.type)return new Hr(c,c)}return c.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,c){const u=[1/0,1/0,-1/0,-1/0],p=[1/0,1/0,-1/0,-1/0],f=e.canonicalID();if("Polygon"===c.type){const m=gn(c.coordinates,p,f),g=vn(e.geometry(),u,p,f);if(!ln(u,p))return!1;for(const e of g)if(!dn(e,m))return!1}if("MultiPolygon"===c.type){const m=yn(c.coordinates,p,f),g=vn(e.geometry(),u,p,f);if(!ln(u,p))return!1;for(const e of g)if(!pn(e,m))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,c){const u=[1/0,1/0,-1/0,-1/0],p=[1/0,1/0,-1/0,-1/0],f=e.canonicalID();if("Polygon"===c.type){const m=gn(c.coordinates,p,f),g=bn(e.geometry(),u,p,f);if(!ln(u,p))return!1;for(const e of g)if(!fn(e,m))return!1}if("MultiPolygon"===c.type){const m=yn(c.coordinates,p,f),g=bn(e.geometry(),u,p,f);if(!ln(u,p))return!1;for(const e of g)if(!mn(e,m))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let wn=class{constructor(e=[],c=(e,c)=>ec?1:0){if(this.data=e,this.length=this.data.length,this.compare=c,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],c=this.data.pop();return--this.length>0&&(this.data[0]=c,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:c,compare:u}=this,p=c[e];for(;e>0;){const f=e-1>>1,m=c[f];if(u(p,m)>=0)break;c[e]=m,e=f}c[e]=p}_down(e){const{data:c,compare:u}=this,p=this.length>>1,f=c[e];for(;e=0)break;c[e]=c[p],e=p}c[e]=f}};function Tn(e,c,u=0,p=e.length-1,f=In){for(;p>u;){if(p-u>600){const m=p-u+1,g=c-u+1,y=Math.log(m),x=.5*Math.exp(2*y/3),b=.5*Math.sqrt(y*x*(m-x)/m)*(g-m/2<0?-1:1);Tn(e,c,Math.max(u,Math.floor(c-g*x/m+b)),Math.min(p,Math.floor(c+(m-g)*x/m+b)),f)}const m=e[c];let g=u,y=p;for(Sn(e,u,c),f(e[p],m)>0&&Sn(e,u,p);g0;)y--}0===f(e[u],m)?Sn(e,u,y):(y++,Sn(e,y,p)),y<=c&&(u=y+1),c<=y&&(p=y-1)}}function Sn(e,c,u){const p=e[c];e[c]=e[u],e[u]=p}function In(e,c){return ec?1:0}function Mn(e,c){if(e.length<=1)return[e];const u=[];let p,f;for(const c of e){const e=An(c);0!==e&&(c.area=Math.abs(e),void 0===f&&(f=e<0),f===e<0?(p&&u.push(p),p=[c]):p.push(c))}if(p&&u.push(p),c>1)for(let e=0;e1?(x=e[y+1][0],b=e[y+1][1]):P>0&&(x+=T/this.kx*P,b+=S/this.ky*P)),T=this.wrap(c[0]-x)*this.kx,S=(c[1]-b)*this.ky;const I=T*T+S*S;I180;)e-=360;return e}}function Rn(e,c){return c[0]-e[0]}function Ln(e){return e[1]-e[0]+1}function Bn(e,c){return e[1]>=e[0]&&e[1]e[1])return[null,null];const u=Ln(e);if(c){if(2===u)return[e,null];const c=Math.floor(u/2);return[[e[0],e[0]+c],[e[0]+c,e[1]]]}if(1===u)return[e,null];const p=Math.floor(u/2)-1;return[[e[0],e[0]+p],[e[0]+p+1,e[1]]]}function Vn(e,c){if(!Bn(c,e.length))return[1/0,1/0,-1/0,-1/0];const u=[1/0,1/0,-1/0,-1/0];for(let p=c[0];p<=c[1];++p)an(u,e[p]);return u}function jn(e){const c=[1/0,1/0,-1/0,-1/0];for(const u of e)for(const e of u)an(c,e);return c}function Nn(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function Gn(e,c,u){if(!Nn(e)||!Nn(c))return NaN;let p=0,f=0;return e[2]c[2]&&(p=e[0]-c[2]),e[1]>c[3]&&(f=e[1]-c[3]),e[3]=p)return p;if(ln(f,m)){if(Xn(e,c))return 0}else if(Xn(c,e))return 0;let g=1/0;for(const p of e)for(let e=0,f=p.length,m=f-1;e0;){const f=g.pop();if(f[0]>=m)continue;const x=f[1],b=c?50:100;if(Ln(x)<=b){if(!Bn(x,e.length))return NaN;if(c){const c=Hn(e,x,u,p);if(isNaN(c)||0===c)return c;m=Math.min(m,c)}else for(let c=x[0];c<=x[1];++c){const f=Wn(e[c],u,p);if(m=Math.min(m,f),0===m)return 0}}else{const u=On(x,c);Kn(g,m,p,e,y,u[0]),Kn(g,m,p,e,y,u[1])}}return m}function ts(e,c,u,p,f,m=1/0){let g=Math.min(m,f.distance(e[0],u[0]));if(0===g)return g;const y=new wn([[0,[0,e.length-1],[0,u.length-1]]],Rn);for(;y.length>0;){const m=y.pop();if(m[0]>=g)continue;const x=m[1],b=m[2],T=c?50:100,S=p?50:100;if(Ln(x)<=T&&Ln(b)<=S){if(!Bn(x,e.length)&&Bn(b,u.length))return NaN;let m;if(c&&p)m=$n(e,x,u,b,f),g=Math.min(g,m);else if(c&&!p){const c=e.slice(x[0],x[1]+1);for(let e=b[0];e<=b[1];++e)if(m=Un(u[e],c,f),g=Math.min(g,m),0===g)return g}else if(!c&&p){const c=u.slice(b[0],b[1]+1);for(let u=x[0];u<=x[1];++u)if(m=Un(e[u],c,f),g=Math.min(g,m),0===g)return g}else m=Zn(e,x,u,b,f),g=Math.min(g,m)}else{const m=On(x,c),T=On(b,p);Jn(y,g,f,e,u,m[0],T[0]),Jn(y,g,f,e,u,m[0],T[1]),Jn(y,g,f,e,u,m[1],T[0]),Jn(y,g,f,e,u,m[1],T[1])}}return g}function ns(e){return"MultiPolygon"===e.type?e.coordinates.map((e=>({type:"Polygon",coordinates:e}))):"MultiLineString"===e.type?e.coordinates.map((e=>({type:"LineString",coordinates:e}))):"MultiPoint"===e.type?e.coordinates.map((e=>({type:"Point",coordinates:e}))):[e]}class En{constructor(e,c){this.type=ci,this.geojson=e,this.geometries=c}static parse(e,c){if(2!==e.length)return c.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Ar(e[1])){const c=e[1];if("FeatureCollection"===c.type)return new En(c,c.features.map((e=>ns(e.geometry))).flat());if("Feature"===c.type)return new En(c,ns(c.geometry));if("type"in c&&"coordinates"in c)return new En(c,ns(c))}return c.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,c){const u=e.geometry(),p=u.flat().map((c=>sn([c.x,c.y],e.canonical)));if(0===u.length)return NaN;const f=new on(p[0][1]);let m=1/0;for(const e of c){switch(e.type){case"Point":m=Math.min(m,ts(p,!1,[e.coordinates],!1,f,m));break;case"LineString":m=Math.min(m,ts(p,!1,e.coordinates,!0,f,m));break;case"Polygon":m=Math.min(m,Qn(p,!1,e.coordinates,f,m))}if(0===m)return m}return m}(e,this.geometries);if("LineString"===e.geometryType())return function(e,c){const u=e.geometry(),p=u.flat().map((c=>sn([c.x,c.y],e.canonical)));if(0===u.length)return NaN;const f=new on(p[0][1]);let m=1/0;for(const e of c){switch(e.type){case"Point":m=Math.min(m,ts(p,!0,[e.coordinates],!1,f,m));break;case"LineString":m=Math.min(m,ts(p,!0,e.coordinates,!0,f,m));break;case"Polygon":m=Math.min(m,Qn(p,!0,e.coordinates,f,m))}if(0===m)return m}return m}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,c){const u=e.geometry();if(0===u.length||0===u[0].length)return NaN;const p=Mn(u,0).map((c=>c.map((c=>c.map((c=>sn([c.x,c.y],e.canonical))))))),f=new on(p[0][0][0][1]);let m=1/0;for(const e of c)for(const c of p){switch(e.type){case"Point":m=Math.min(m,Qn([e.coordinates],!1,c,f,m));break;case"LineString":m=Math.min(m,Qn(e.coordinates,!0,c,f,m));break;case"Polygon":m=Math.min(m,Yn(c,e.coordinates,f,m))}if(0===m)return m}return m}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Fn{constructor(e){this.type=gi,this.key=e}static parse(e,c){if(2!==e.length)return c.error(`Expected 1 argument, but found ${e.length-1} instead.`);const u=e[1];return null==u?c.error("Global state property must be defined."):"string"!=typeof u?c.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new Fn(u)}evaluate(e){var c;const u=null===(c=e.globals)||void 0===c?void 0:c.globalState;return u&&0!==Object.keys(u).length?pr(u,this.key):null}eachChild(){}outputDefined(){return!1}}const os={"==":Yr,"!=":Kr,">":Qr,"<":Jr,">=":tn,"<=":en,array:Xe,at:tr,boolean:Xe,case:ir,coalesce:mr,collator:Mr,format:Tr,image:Er,in:er,"index-of":rr,interpolate:fr,"interpolate-hcl":fr,"interpolate-lab":fr,length:Fr,let:Je,literal:qe,match:nr,number:Xe,"number-format":Ir,object:Xe,slice:sr,step:or,string:Xe,"to-boolean":Ze,"to-color":Ze,"to-number":Ze,"to-string":Ze,var:Qe,within:Hr,distance:En,"global-state":Fn};class Pn{constructor(e,c,u,p){this.name=e,this.type=c,this._evaluate=u,this.args=p}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,c){const u=e[0],p=Pn.definitions[u];if(!p)return c.error(`Unknown expression "${u}". If you wanted a literal array, use ["literal", [...]].`,0);const f=Array.isArray(p)?p[0]:p.type,m=Array.isArray(p)?[[p[1],p[2]]]:p.overloads,g=m.filter((([c])=>!Array.isArray(c)||c.length===e.length-1));let y=null;for(const[p,m]of g){y=new We(c.registry,ms,c.path,null,c.scope);const g=[];let x=!1;for(let c=1;c{return c=e,Array.isArray(c)?`(${c.map(Mi).join(", ")})`:`(${Mi(c.type)}...)`;var c})).join(" | "),p=[];for(let u=1;u{u=c?u&&ms(e):u&&e instanceof qe})),!!u&&_s(e)&&ys(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function _s(e){if(e instanceof Pn){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof Hr)return!1;if(e instanceof En)return!1;let c=!0;return e.eachChild((e=>{c&&!_s(e)&&(c=!1)})),c}function gs(e){if(e instanceof Pn&&"feature-state"===e.name)return!1;let c=!0;return e.eachChild((e=>{c&&!gs(e)&&(c=!1)})),c}function ys(e,c){if(e instanceof Pn&&c.indexOf(e.name)>=0)return!1;let u=!0;return e.eachChild((e=>{u&&!ys(e,c)&&(u=!1)})),u}function vs(e){return{result:"success",value:e}}function bs(e){return{result:"error",value:e}}function ws(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function Ts(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Ss(e){return!!e.expression&&e.expression.interpolated}function Ps(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Is(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&Dr(e)===mi}function Ms(e){return e}function Es(e,c){const u=e.stops&&"object"==typeof e.stops[0][0],p=u||!(u||void 0!==e.property),f=e.type||(Ss(c)?"exponential":"interval"),m=function(e){switch(e.type){case"color":return Ie.parse;case"padding":return Pe.parse;case"numberArray":return ze.parse;case"colorArray":return Be.parse;default:return null}}(c);if(m&&((e=ai({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],m(e[1])]))),e.default=m(e.default?e.default:c.default)),e.colorSpace&&"rgb"!==(g=e.colorSpace)&&"hcl"!==g&&"lab"!==g)throw new Error(`Unknown color space: "${e.colorSpace}"`);var g;const y=function(e){switch(e){case"exponential":return Fs;case"interval":return ks;case"categorical":return Ds;case"identity":return Bs;default:throw new Error(`Unknown function type "${e}"`)}}(f);let x,b;if("categorical"===f){x=Object.create(null);for(const c of e.stops)x[c[0]]=c[1];b=typeof e.stops[0][0]}if(u){const u={},p=[];for(let c=0;ce[0])),evaluate:({zoom:u},p)=>Fs({stops:f,base:e.base},c,u).evaluate(u,p)}}if(p){const u="exponential"===f?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:u,interpolationFactor:fr.interpolationFactor.bind(void 0,u),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:u})=>y(e,c,u,x,b)}}return{kind:"source",evaluate(u,p){const f=p&&p.properties?p.properties[e.property]:void 0;return void 0===f?As(e.default,c.default):y(e,c,f,x,b)}}}function As(e,c,u){return void 0!==e?e:void 0!==c?c:void 0!==u?u:void 0}function Ds(e,c,u,p,f){return As(typeof u===f?p[u]:void 0,e.default,c.default)}function ks(e,c,u){if("number"!==Ps(u))return As(e.default,c.default);const p=e.stops.length;if(1===p)return e.stops[0][1];if(u<=e.stops[0][0])return e.stops[0][1];if(u>=e.stops[p-1][0])return e.stops[p-1][1];const f=Br(e.stops.map((e=>e[0])),u);return e.stops[f][1]}function Fs(e,c,u){const p=void 0!==e.base?e.base:1;if("number"!==Ps(u))return As(e.default,c.default);const f=e.stops.length;if(1===f)return e.stops[0][1];if(u<=e.stops[0][0])return e.stops[0][1];if(u>=e.stops[f-1][0])return e.stops[f-1][1];const m=Br(e.stops.map((e=>e[0])),u),g=function(e,c,u,p){const f=p-u,m=e-u;return 0===f?0:1===c?m/f:(Math.pow(c,m)-1)/(Math.pow(c,f)-1)}(u,p,e.stops[m][0],e.stops[m+1][0]),y=e.stops[m][1],x=e.stops[m+1][1],b=qr[c.type]||Ms;return"function"==typeof y.evaluate?{evaluate(...c){const u=y.evaluate.apply(void 0,c),p=x.evaluate.apply(void 0,c);if(void 0!==u&&void 0!==p)return b(u,p,g,e.colorSpace)}}:b(y,x,g,e.colorSpace)}function Bs(e,c,u){switch(c.type){case"color":u=Ie.parse(u);break;case"formatted":u=De.fromString(u.toString());break;case"resolvedImage":u=Oe.fromString(u.toString());break;case"padding":u=Pe.parse(u);break;case"colorArray":u=Be.parse(u);break;case"numberArray":u=ze.parse(u);break;default:Ps(u)===c.type||"enum"===c.type&&c.values[u]||(u=void 0)}return As(u,e.default,c.default)}Pn.register(os,{error:[{kind:"error"},[hi],(e,[c])=>{throw new Ve(c.evaluate(e))}],typeof:[hi,[gi],(e,[c])=>Mi(Dr(c.evaluate(e)))],"to-rgba":[Ii(ci,4),[pi],(e,[c])=>{const[u,p,f,m]=c.evaluate(e).rgb;return[255*u,255*p,255*f,m]}],rgb:[pi,[ci,ci,ci],ls],rgba:[pi,[ci,ci,ci,ci],ls],has:{type:di,overloads:[[[hi],(e,[c])=>hs(c.evaluate(e),e.properties())],[[hi,mi],(e,[c,u])=>hs(c.evaluate(e),u.evaluate(e))]]},get:{type:gi,overloads:[[[hi],(e,[c])=>ds(c.evaluate(e),e.properties())],[[hi,mi],(e,[c,u])=>ds(c.evaluate(e),u.evaluate(e))]]},"feature-state":[gi,[hi],(e,[c])=>ds(c.evaluate(e),e.featureState||{})],properties:[mi,[],e=>e.properties()],"geometry-type":[hi,[],e=>e.geometryType()],id:[gi,[],e=>e.id()],zoom:[ci,[],e=>e.globals.zoom],"heatmap-density":[ci,[],e=>e.globals.heatmapDensity||0],elevation:[ci,[],e=>e.globals.elevation||0],"line-progress":[ci,[],e=>e.globals.lineProgress||0],accumulated:[gi,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[ci,ps(ci),(e,c)=>{let u=0;for(const p of c)u+=p.evaluate(e);return u}],"*":[ci,ps(ci),(e,c)=>{let u=1;for(const p of c)u*=p.evaluate(e);return u}],"-":{type:ci,overloads:[[[ci,ci],(e,[c,u])=>c.evaluate(e)-u.evaluate(e)],[[ci],(e,[c])=>-c.evaluate(e)]]},"/":[ci,[ci,ci],(e,[c,u])=>c.evaluate(e)/u.evaluate(e)],"%":[ci,[ci,ci],(e,[c,u])=>c.evaluate(e)%u.evaluate(e)],ln2:[ci,[],()=>Math.LN2],pi:[ci,[],()=>Math.PI],e:[ci,[],()=>Math.E],"^":[ci,[ci,ci],(e,[c,u])=>Math.pow(c.evaluate(e),u.evaluate(e))],sqrt:[ci,[ci],(e,[c])=>Math.sqrt(c.evaluate(e))],log10:[ci,[ci],(e,[c])=>Math.log(c.evaluate(e))/Math.LN10],ln:[ci,[ci],(e,[c])=>Math.log(c.evaluate(e))],log2:[ci,[ci],(e,[c])=>Math.log(c.evaluate(e))/Math.LN2],sin:[ci,[ci],(e,[c])=>Math.sin(c.evaluate(e))],cos:[ci,[ci],(e,[c])=>Math.cos(c.evaluate(e))],tan:[ci,[ci],(e,[c])=>Math.tan(c.evaluate(e))],asin:[ci,[ci],(e,[c])=>Math.asin(c.evaluate(e))],acos:[ci,[ci],(e,[c])=>Math.acos(c.evaluate(e))],atan:[ci,[ci],(e,[c])=>Math.atan(c.evaluate(e))],min:[ci,ps(ci),(e,c)=>Math.min(...c.map((c=>c.evaluate(e))))],max:[ci,ps(ci),(e,c)=>Math.max(...c.map((c=>c.evaluate(e))))],abs:[ci,[ci],(e,[c])=>Math.abs(c.evaluate(e))],round:[ci,[ci],(e,[c])=>{const u=c.evaluate(e);return u<0?-Math.round(-u):Math.round(u)}],floor:[ci,[ci],(e,[c])=>Math.floor(c.evaluate(e))],ceil:[ci,[ci],(e,[c])=>Math.ceil(c.evaluate(e))],"filter-==":[di,[hi,gi],(e,[c,u])=>e.properties()[c.value]===u.value],"filter-id-==":[di,[gi],(e,[c])=>e.id()===c.value],"filter-type-==":[di,[hi],(e,[c])=>e.geometryType()===c.value],"filter-<":[di,[hi,gi],(e,[c,u])=>{const p=e.properties()[c.value],f=u.value;return typeof p==typeof f&&p{const u=e.id(),p=c.value;return typeof u==typeof p&&u":[di,[hi,gi],(e,[c,u])=>{const p=e.properties()[c.value],f=u.value;return typeof p==typeof f&&p>f}],"filter-id->":[di,[gi],(e,[c])=>{const u=e.id(),p=c.value;return typeof u==typeof p&&u>p}],"filter-<=":[di,[hi,gi],(e,[c,u])=>{const p=e.properties()[c.value],f=u.value;return typeof p==typeof f&&p<=f}],"filter-id-<=":[di,[gi],(e,[c])=>{const u=e.id(),p=c.value;return typeof u==typeof p&&u<=p}],"filter->=":[di,[hi,gi],(e,[c,u])=>{const p=e.properties()[c.value],f=u.value;return typeof p==typeof f&&p>=f}],"filter-id->=":[di,[gi],(e,[c])=>{const u=e.id(),p=c.value;return typeof u==typeof p&&u>=p}],"filter-has":[di,[gi],(e,[c])=>c.value in e.properties()],"filter-has-id":[di,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[di,[Ii(hi)],(e,[c])=>c.value.indexOf(e.geometryType())>=0],"filter-id-in":[di,[Ii(gi)],(e,[c])=>c.value.indexOf(e.id())>=0],"filter-in-small":[di,[hi,Ii(gi)],(e,[c,u])=>u.value.indexOf(e.properties()[c.value])>=0],"filter-in-large":[di,[hi,Ii(gi)],(e,[c,u])=>function(e,c,u,p){for(;u<=p;){const f=u+p>>1;if(c[f]===e)return!0;c[f]>e?p=f-1:u=f+1}return!1}(e.properties()[c.value],u.value,0,u.value.length-1)],all:{type:di,overloads:[[[di,di],(e,[c,u])=>c.evaluate(e)&&u.evaluate(e)],[ps(di),(e,c)=>{for(const u of c)if(!u.evaluate(e))return!1;return!0}]]},any:{type:di,overloads:[[[di,di],(e,[c,u])=>c.evaluate(e)||u.evaluate(e)],[ps(di),(e,c)=>{for(const u of c)if(u.evaluate(e))return!0;return!1}]]},"!":[di,[di],(e,[c])=>!c.evaluate(e)],"is-supported-script":[di,[hi],(e,[c])=>{const u=e.globals&&e.globals.isSupportedScript;return!u||u(c.evaluate(e))}],upcase:[hi,[hi],(e,[c])=>c.evaluate(e).toUpperCase()],downcase:[hi,[hi],(e,[c])=>c.evaluate(e).toLowerCase()],concat:[hi,ps(gi),(e,c)=>c.map((c=>zr(c.evaluate(e)))).join("")],"resolved-locale":[hi,[yi],(e,[c])=>c.evaluate(e).resolvedLocale()]});class ei{constructor(e,c,u){this.expression=e,this._warningHistory={},this._evaluator=new Ke,this._defaultValue=c?function(e){if("color"===e.type&&Is(e.default))return new Ie(0,0,0,0);switch(e.type){case"color":return Ie.parse(e.default)||null;case"padding":return Pe.parse(e.default)||null;case"numberArray":return ze.parse(e.default)||null;case"colorArray":return Be.parse(e.default)||null;case"variableAnchorOffsetCollection":return Le.parse(e.default)||null;case"projectionDefinition":return Re.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(c):null,this._enumValues=c&&"enum"===c.type?c.values:null,this._globalState=u}evaluateWithoutErrorHandling(e,c,u,p,f,m){return this._globalState&&(e=xo(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=c,this._evaluator.featureState=u,this._evaluator.canonical=p,this._evaluator.availableImages=f||null,this._evaluator.formattedSection=m,this.expression.evaluate(this._evaluator)}evaluate(e,c,u,p,f,m){this._globalState&&(e=xo(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=c||null,this._evaluator.featureState=u||null,this._evaluator.canonical=p,this._evaluator.availableImages=f||null,this._evaluator.formattedSection=m||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Ve(`Expected value to be one of ${Object.keys(this._enumValues).map((e=>JSON.stringify(e))).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function Vs(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in os}function Ws(e,c,u){const p=new We(os,ms,[],c?function(e){const c={color:pi,string:hi,number:ci,enum:hi,boolean:di,formatted:xi,padding:vi,numberArray:wi,colorArray:bi,projectionDefinition:fi,resolvedImage:Ti,variableAnchorOffsetCollection:Si};return"array"===e.type?Ii(c[e.value]||gi,e.length):c[e.type]}(c):void 0),f=p.parse(e,void 0,void 0,void 0,c&&"string"===c.type?{typeAnnotation:"coerce"}:void 0);return f?vs(new ei(f,c,u)):bs(p.errors)}class ii{constructor(e,c,u){this.kind=e,this._styleExpression=c,this.isStateDependent="constant"!==e&&!gs(c.expression),this.globalStateRefs=uo(c.expression),this._globalState=u}evaluateWithoutErrorHandling(e,c,u,p,f,m){return this._globalState&&(e=xo(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,c,u,p,f,m)}evaluate(e,c,u,p,f,m){return this._globalState&&(e=xo(e,this._globalState)),this._styleExpression.evaluate(e,c,u,p,f,m)}}class si{constructor(e,c,u,p,f){this.kind=e,this.zoomStops=u,this._styleExpression=c,this.isStateDependent="camera"!==e&&!gs(c.expression),this.globalStateRefs=uo(c.expression),this.interpolationType=p,this._globalState=f}evaluateWithoutErrorHandling(e,c,u,p,f,m){return this._globalState&&(e=xo(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,c,u,p,f,m)}evaluate(e,c,u,p,f,m){return this._globalState&&(e=xo(e,this._globalState)),this._styleExpression.evaluate(e,c,u,p,f,m)}interpolationFactor(e,c,u){return this.interpolationType?fr.interpolationFactor(this.interpolationType,e,c,u):0}}function Js(e,c,u){const p=Ws(e,c,u);if("error"===p.result)return p;const f=p.value.expression,m=_s(f);if(!m&&!ws(c))return bs([new zt("","data expressions not supported")]);const g=ys(f,["zoom"]);if(!g&&!Ts(c))return bs([new zt("","zoom expressions not supported")]);const y=ao(f);return y||g?y instanceof zt?bs([y]):y instanceof fr&&!Ss(c)?bs([new zt("",'"interpolate" expressions cannot be used with this property')]):vs(y?new si(m?"camera":"composite",p.value,y.labels,y instanceof fr?y.interpolation:void 0,u):new ii(m?"constant":"source",p.value,u)):bs([new zt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class oi{constructor(e,c){this._parameters=e,this._specification=c,ai(this,Es(this._parameters,this._specification))}static deserialize(e){return new oi(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function ao(e){let c=null;if(e instanceof Je)c=ao(e.result);else if(e instanceof mr){for(const u of e.args)if(c=ao(u),c)break}else(e instanceof or||e instanceof fr)&&e.input instanceof Pn&&"zoom"===e.input.name&&(c=e);return c instanceof zt||e.eachChild((e=>{const u=ao(e);u instanceof zt?c=u:!c&&u?c=new zt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):c&&u&&c!==u&&(c=new zt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),c}function uo(e,c=new Set){return e instanceof Fn&&c.add(e.key),e.eachChild((e=>{uo(e,c)})),c}function xo(e,c){const{zoom:u,heatmapDensity:p,elevation:f,lineProgress:m,isSupportedScript:g,accumulated:y}=null!=e?e:{};return{zoom:u,heatmapDensity:p,elevation:f,lineProgress:m,isSupportedScript:g,accumulated:y,globalState:c}}function vo(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const c of e.slice(1))if(!vo(c)&&"boolean"!=typeof c)return!1;return!0;default:return!0}}const Mo={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function ko(e,c){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};vo(e)||(e=Ho(e));const u=Ws(e,Mo,c);if("error"===u.result)throw new Error(u.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return{filter:(e,c,p)=>u.value.evaluate(e,c,{},p),needGeometry:Wo(e),getGlobalStateRefs:()=>uo(u.value.expression)}}function Ro(e,c){return ec?1:0}function Wo(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let c=1;c"===c||"<="===c||">="===c?Yo(e[1],e[2],c):"any"===c?(u=e.slice(1),["any"].concat(u.map(Ho))):"all"===c?["all"].concat(e.slice(1).map(Ho)):"none"===c?["all"].concat(e.slice(1).map(Ho).map(na)):"in"===c?ta(e[1],e.slice(2)):"!in"===c?na(ta(e[1],e.slice(2))):"has"===c?ia(e[1]):"!has"!==c||na(ia(e[1]));var u}function Yo(e,c,u){switch(e){case"$type":return[`filter-type-${u}`,c];case"$id":return[`filter-id-${u}`,c];default:return[`filter-${u}`,e,c]}}function ta(e,c){if(0===c.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",c]];case"$id":return["filter-id-in",["literal",c]];default:return c.length>200&&!c.some((e=>typeof e!=typeof c[0]))?["filter-in-large",e,["literal",c.sort(Ro)]]:["filter-in-small",e,["literal",c]]}}function ia(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function na(e){return["!",e]}function el(e){const c=typeof e;if("number"===c||"boolean"===c||"string"===c||null==e)return JSON.stringify(e);if(Array.isArray(e)){let c="[";for(const u of e)c+=`${el(u)},`;return`${c}]`}const u=Object.keys(e).sort();let p="{";for(let c=0;cp.maximum?[new Dt(c,u,`${u} is greater than the maximum value ${p.maximum}`)]:[]}function ll(e){const c=e.valueSpec,u=rl(e.value.type);let p,f,m,g={};const y="categorical"!==u&&void 0===e.value.property,x=!y,b="array"===Ps(e.value.stops)&&"array"===Ps(e.value.stops[0])&&"object"===Ps(e.value.stops[0][0]),T=sl({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===u)return[new Dt(e.key,e.value,'identity function may not have a "stops" property')];let c=[];const p=e.value;return c=c.concat(ol({key:e.key,value:p,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:S})),"array"===Ps(p)&&0===p.length&&c.push(new Dt(e.key,p,"array must have at least one stop")),c},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:c,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===u&&y&&T.push(new Dt(e.key,e.value,'missing required property "property"')),"identity"===u||e.value.stops||T.push(new Dt(e.key,e.value,'missing required property "stops"')),"exponential"===u&&e.valueSpec.expression&&!Ss(e.valueSpec)&&T.push(new Dt(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(x&&!ws(e.valueSpec)?T.push(new Dt(e.key,e.value,"property functions not supported")):y&&!Ts(e.valueSpec)&&T.push(new Dt(e.key,e.value,"zoom functions not supported"))),"categorical"!==u&&!b||void 0!==e.value.property||T.push(new Dt(e.key,e.value,'"property" property is required')),T;function S(e){let u=[];const p=e.value,y=e.key;if("array"!==Ps(p))return[new Dt(y,p,`array expected, ${Ps(p)} found`)];if(2!==p.length)return[new Dt(y,p,`array length 2 expected, length ${p.length} found`)];if(b){if("object"!==Ps(p[0]))return[new Dt(y,p,`object expected, ${Ps(p[0])} found`)];if(void 0===p[0].zoom)return[new Dt(y,p,"object stop key must have zoom")];if(void 0===p[0].value)return[new Dt(y,p,"object stop key must have value")];if(m&&m>rl(p[0].zoom))return[new Dt(y,p[0].zoom,"stop zoom values must appear in ascending order")];rl(p[0].zoom)!==m&&(m=rl(p[0].zoom),f=void 0,g={}),u=u.concat(sl({key:`${y}[0]`,value:p[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:al,value:P}}))}else u=u.concat(P({key:`${y}[0]`,value:p[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},p));return Vs(nl(p[1]))?u.concat([new Dt(`${y}[1]`,p[1],"expressions are not allowed in function stops.")]):u.concat(e.validateSpec({key:`${y}[1]`,value:p[1],valueSpec:c,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function P(e,m){const y=Ps(e.value),x=rl(e.value),b=null!==e.value?e.value:m;if(p){if(y!==p)return[new Dt(e.key,b,`${y} stop domain type must match previous stop domain type ${p}`)]}else p=y;if("number"!==y&&"string"!==y&&"boolean"!==y)return[new Dt(e.key,b,"stop domain value must be a number, string, or boolean")];if("number"!==y&&"categorical"!==u){let p=`number expected, ${y} found`;return ws(c)&&void 0===u&&(p+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Dt(e.key,b,p)]}return"categorical"!==u||"number"!==y||isFinite(x)&&Math.floor(x)===x?"categorical"!==u&&"number"===y&&void 0!==f&&xnew Dt(`${e.key}${c.key}`,e.value,c.message)));const u=c.value.expression||c.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!u.outputDefined())return[new Dt(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!gs(u))return[new Dt(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!gs(u))return[new Dt(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!ys(u,["zoom","feature-state"]))return[new Dt(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!_s(u))return[new Dt(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function hl(e){const c=e.key,u=e.value,p=Ps(u);return"string"!==p?[new Dt(c,u,`color expected, ${p} found`)]:Ie.parse(String(u))?[]:[new Dt(c,u,`color expected, "${u}" found`)]}function ul(e){const c=e.key,u=e.value,p=e.valueSpec,f=[];return Array.isArray(p.values)?-1===p.values.indexOf(rl(u))&&f.push(new Dt(c,u,`expected one of [${p.values.join(", ")}], ${JSON.stringify(u)} found`)):-1===Object.keys(p.values).indexOf(rl(u))&&f.push(new Dt(c,u,`expected one of [${Object.keys(p.values).join(", ")}], ${JSON.stringify(u)} found`)),f}function dl(e){return vo(nl(e.value))?cl(ai({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):pl(e)}function pl(e){const c=e.value,u=e.key;if("array"!==Ps(c))return[new Dt(u,c,`array expected, ${Ps(c)} found`)];const p=e.styleSpec;let f,m=[];if(c.length<1)return[new Dt(u,c,"filter array must have at least 1 element")];switch(m=m.concat(ul({key:`${u}[0]`,value:c[0],valueSpec:p.filter_operator,style:e.style,styleSpec:e.styleSpec})),rl(c[0])){case"<":case"<=":case">":case">=":c.length>=2&&"$type"===rl(c[1])&&m.push(new Dt(u,c,`"$type" cannot be use with operator "${c[0]}"`));case"==":case"!=":3!==c.length&&m.push(new Dt(u,c,`filter array for operator "${c[0]}" must have 3 elements`));case"in":case"!in":c.length>=2&&(f=Ps(c[1]),"string"!==f&&m.push(new Dt(`${u}[1]`,c[1],`string expected, ${f} found`)));for(let g=2;g{e in u&&c.push(new Dt(p,u[e],`"${e}" is prohibited for ref layers`))})),f.layers.forEach((c=>{rl(c.id)===y&&(e=c)})),e?e.ref?c.push(new Dt(p,u.ref,"ref cannot reference another ref layer")):g=rl(e.type):c.push(new Dt(p,u.ref,`ref layer "${y}" not found`))}else if("background"!==g)if(u.source){const e=f.sources&&f.sources[u.source],m=e&&rl(e.type);e?"vector"===m&&"raster"===g?c.push(new Dt(p,u.source,`layer "${u.id}" requires a raster source`)):"raster-dem"!==m&&"hillshade"===g||"raster-dem"!==m&&"color-relief"===g?c.push(new Dt(p,u.source,`layer "${u.id}" requires a raster-dem source`)):"raster"===m&&"raster"!==g?c.push(new Dt(p,u.source,`layer "${u.id}" requires a vector source`)):"vector"!==m||u["source-layer"]?"raster-dem"===m&&"hillshade"!==g&&"color-relief"!==g?c.push(new Dt(p,u.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==g||!u.paint||!u.paint["line-gradient"]||"geojson"===m&&e.lineMetrics||c.push(new Dt(p,u,`layer "${u.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):c.push(new Dt(p,u,`layer "${u.id}" must specify a "source-layer"`)):c.push(new Dt(p,u.source,`source "${u.source}" not found`))}else c.push(new Dt(p,u,'missing required property "source"'));return c=c.concat(sl({key:p,value:u,valueSpec:m.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${p}.type`,value:u.type,valueSpec:m.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:u,objectKey:"type"}),filter:dl,layout:e=>sl({layer:u,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>xl(ai({layerType:g},e))}}),paint:e=>sl({layer:u,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>gl(ai({layerType:g},e))}})}})),c}function bl(e){const c=e.value,u=e.key,p=Ps(c);return"string"!==p?[new Dt(u,c,`string expected, ${p} found`)]:[]}const wl={promoteId:function({key:e,value:c}){if("string"===Ps(c))return bl({key:e,value:c});{const u=[];for(const p in c)u.push(...bl({key:`${e}.${p}`,value:c[p]}));return u}}};function Tl(e){const c=e.value,u=e.key,p=e.styleSpec,f=e.style,m=e.validateSpec;if(!c.type)return[new Dt(u,c,'"type" is required')];const g=rl(c.type);let y;switch(g){case"vector":case"raster":return y=sl({key:u,value:c,valueSpec:p[`source_${g.replace("-","_")}`],style:e.style,styleSpec:p,objectElementValidators:wl,validateSpec:m}),y;case"raster-dem":return y=function(e){var c;const u=null!==(c=e.sourceName)&&void 0!==c?c:"",p=e.value,f=e.styleSpec,m=f.source_raster_dem,g=e.style;let y=[];const x=Ps(p);if(void 0===p)return y;if("object"!==x)return y.push(new Dt("source_raster_dem",p,`object expected, ${x} found`)),y;const b="custom"===rl(p.encoding),T=["redFactor","greenFactor","blueFactor","baseShift"],S=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const c in p)!b&&T.includes(c)?y.push(new Dt(c,p[c],`In "${u}": "${c}" is only valid when "encoding" is set to "custom". ${S} encoding found`)):m[c]?y=y.concat(e.validateSpec({key:c,value:p[c],valueSpec:m[c],validateSpec:e.validateSpec,style:g,styleSpec:f})):y.push(new Dt(c,p[c],`unknown property "${c}"`));return y}({sourceName:u,value:c,style:e.style,styleSpec:p,validateSpec:m}),y;case"geojson":if(y=sl({key:u,value:c,valueSpec:p.source_geojson,style:f,styleSpec:p,validateSpec:m,objectElementValidators:wl}),c.cluster)for(const e in c.clusterProperties){const[p,f]=c.clusterProperties[e],m="string"==typeof p?[p,["accumulated"],["get",e]]:p;y.push(...cl({key:`${u}.${e}.map`,value:f,expressionContext:"cluster-map"})),y.push(...cl({key:`${u}.${e}.reduce`,value:m,expressionContext:"cluster-reduce"}))}return y;case"video":return sl({key:u,value:c,valueSpec:p.source_video,style:f,validateSpec:m,styleSpec:p});case"image":return sl({key:u,value:c,valueSpec:p.source_image,style:f,validateSpec:m,styleSpec:p});case"canvas":return[new Dt(u,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ul({key:`${u}.type`,value:c.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Pl(e){const c=e.value,u=e.styleSpec,p=u.light,f=e.style;let m=[];const g=Ps(c);if(void 0===c)return m;if("object"!==g)return m=m.concat([new Dt("light",c,`object expected, ${g} found`)]),m;for(const g in c){const y=g.match(/^(.*)-transition$/);m=m.concat(y&&p[y[1]]&&p[y[1]].transition?e.validateSpec({key:g,value:c[g],valueSpec:u.transition,validateSpec:e.validateSpec,style:f,styleSpec:u}):p[g]?e.validateSpec({key:g,value:c[g],valueSpec:p[g],validateSpec:e.validateSpec,style:f,styleSpec:u}):[new Dt(g,c[g],`unknown property "${g}"`)])}return m}function Ml(e){const c=e.value,u=e.styleSpec,p=u.sky,f=e.style,m=Ps(c);if(void 0===c)return[];if("object"!==m)return[new Dt("sky",c,`object expected, ${m} found`)];let g=[];for(const m in c)g=g.concat(p[m]?e.validateSpec({key:m,value:c[m],valueSpec:p[m],style:f,styleSpec:u}):[new Dt(m,c[m],`unknown property "${m}"`)]);return g}function El(e){const c=e.value,u=e.styleSpec,p=u.terrain,f=e.style;let m=[];const g=Ps(c);if(void 0===c)return m;if("object"!==g)return m=m.concat([new Dt("terrain",c,`object expected, ${g} found`)]),m;for(const g in c)m=m.concat(p[g]?e.validateSpec({key:g,value:c[g],valueSpec:p[g],validateSpec:e.validateSpec,style:f,styleSpec:u}):[new Dt(g,c[g],`unknown property "${g}"`)]);return m}function Cl(e){let c=[];const u=e.value,p=e.key;if(Array.isArray(u)){const f=[],m=[];for(const g in u)u[g].id&&f.includes(u[g].id)&&c.push(new Dt(p,u,`all the sprites' ids must be unique, but ${u[g].id} is duplicated`)),f.push(u[g].id),u[g].url&&m.includes(u[g].url)&&c.push(new Dt(p,u,`all the sprites' URLs must be unique, but ${u[g].url} is duplicated`)),m.push(u[g].url),c=c.concat(sl({key:`${p}[${g}]`,value:u[g],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return c}return bl({key:p,value:u})}function Al(e){return Boolean(e)&&e.constructor===Object}function Dl(e){return Al(e.value)?[]:[new Dt(e.key,e.value,`object expected, ${Ps(e.value)} found`)]}const zl={"*":()=>[],array:ol,boolean:function(e){const c=e.value,u=e.key,p=Ps(c);return"boolean"!==p?[new Dt(u,c,`boolean expected, ${p} found`)]:[]},number:al,color:hl,constants:il,enum:ul,filter:dl,function:ll,layer:vl,object:sl,source:Tl,light:Pl,sky:Ml,terrain:El,projection:function(e){const c=e.value,u=e.styleSpec,p=u.projection,f=e.style,m=Ps(c);if(void 0===c)return[];if("object"!==m)return[new Dt("projection",c,`object expected, ${m} found`)];let g=[];for(const m in c)g=g.concat(p[m]?e.validateSpec({key:m,value:c[m],valueSpec:p[m],style:f,styleSpec:u}):[new Dt(m,c[m],`unknown property "${m}"`)]);return g},projectionDefinition:function(e){const c=e.key;let u=e.value;u=u instanceof String?u.valueOf():u;const p=Ps(u);return"array"!==p||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(u)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(u)?["array","string"].includes(p)?[]:[new Dt(c,u,`projection expected, invalid type "${p}" found`)]:[new Dt(c,u,`projection expected, invalid array ${JSON.stringify(u)} found`)]},string:bl,formatted:function(e){return 0===bl(e).length?[]:cl(e)},resolvedImage:function(e){return 0===bl(e).length?[]:cl(e)},padding:function(e){const c=e.key,u=e.value;if("array"===Ps(u)){if(u.length<1||u.length>4)return[new Dt(c,u,`padding requires 1 to 4 values; ${u.length} values found`)];const p={type:"number"};let f=[];for(let m=0;m[]}})),e.constants&&(u=u.concat(il({key:"constants",value:e.constants}))),Nl(u)}function jl(e){return function(c){return e(Object.assign({},c,{validateSpec:kl}))}}function Nl(e){return[].concat(e).sort(((e,c)=>e.line-c.line))}function Gl(c){return function(...u){return Nl(c.apply(this||e,u))}}Ol.source=Gl(jl(Tl)),Ol.sprite=Gl(jl(Cl)),Ol.glyphs=Gl(jl(Rl)),Ol.light=Gl(jl(Pl)),Ol.sky=Gl(jl(Ml)),Ol.terrain=Gl(jl(El)),Ol.state=Gl(jl(Dl)),Ol.layer=Gl(jl(vl)),Ol.filter=Gl(jl(dl)),Ol.paintProperty=Gl(jl(gl)),Ol.layoutProperty=Gl(jl(xl));const Ul={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};class rs{constructor(e,c){this._globalState=c,this.setValue(e)}evaluate(){var e;return null!==(e=this._literalValue)&&void 0!==e?e:this._compiledValue.evaluate({})}setValue(e){if(null==e||"visible"===e||"none"===e)return this._literalValue="none"===e?"none":"visible",this._compiledValue=void 0,void(this._globalStateRefs=new Set);const c=Ws(e,Ul,this._globalState);if("error"===c.result)throw this._literalValue="visible",this._compiledValue=void 0,new Error(c.value.map((e=>`${e.key}: ${e.message}`)).join(", "));this._literalValue=void 0,this._compiledValue=c.value,this._globalStateRefs=uo(c.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}const ql=Et,$l=Ol,Zl=$l.light,Wl=$l.sky,Hl=$l.paintProperty,Xl=$l.layoutProperty;function Yl(e,c){let u=!1;if(c&&c.length)for(const p of c)e.fire(new gt(new Error(p.message))),u=!0;return u}class cs{constructor(e,c,u){const p=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const f=new Int32Array(this.arrayBuffer);e=f[0],this.d=(c=f[1])+2*(u=f[2]);for(let e=0;e=b[x+0]&&p>=b[x+1])?(g[S]=!0,m.push(f[S])):g[S]=!1}}}}_forEachCell(e,c,u,p,f,m,g,y){const x=this._convertToCellCoord(e),b=this._convertToCellCoord(c),T=this._convertToCellCoord(u),S=this._convertToCellCoord(p);for(let P=x;P<=T;P++)for(let x=b;x<=S;x++){const b=this.d*x+P;if((!y||y(this._convertFromCellCoord(P),this._convertFromCellCoord(x),this._convertFromCellCoord(P+1),this._convertFromCellCoord(x+1)))&&f.call(this,e,c,u,p,b,m,g,y))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,c=3+this.cells.length+1+1;let u=0;for(let e=0;e=0)continue;const m=e[p];f[p]=Kl[u].shallow.indexOf(p)>=0?m:ic(m,c)}e instanceof Error&&(f.message=e.message)}if(f.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==u&&(f.$name=u),f}function nc(e){if(tc(e))return e;if(Array.isArray(e))return e.map(nc);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const c=ec(e)||"Object";if(!Kl[c])throw new Error(`can't deserialize unregistered class ${c}`);const{klass:u}=Kl[c];if(!u)throw new Error(`can't deserialize unregistered class ${c}`);if(u.deserialize)return u.deserialize(e);const p=Object.create(u.prototype);for(const u of Object.keys(e)){if("$name"===u)continue;const f=e[u];p[u]=Kl[c].shallow.indexOf(u)>=0?f:nc(f)}return p}class xs{constructor(){this.first=!0}update(e,c){const u=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=u,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=u,!0):(this.lastFloorZoom>u?(this.lastIntegerZoom=u+1,this.lastIntegerZoomTime=c):this.lastFloorZoom{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}})).filter((e=>e));return new RegExp(c.join("|"),"u")}const pc=dc(["Arab","Dupl","Mong","Ougr","Syrc"]);function fc(e){return!pc.test(String.fromCodePoint(e))}function mc(e){return!(oc(e)||(c=e,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(c))));var c}const _c=dc(["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 gc(e){return _c.test(String.fromCodePoint(e))}function yc(e,c){return!(!c&&gc(e)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e)))}function xc(e){for(const c of e)if(gc(c.codePointAt(0)))return!0;return!1}const vc=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(vc.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(e,c){return u(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;const u=e.pluginURL,p=new Promise((e=>{this.loadScriptResolve=e}));c(u);const f=new Promise((e=>setTimeout((()=>e()),this.TIMEOUT)));if(yield Promise.race([p,f]),this.isParsed()){const e={pluginStatus:"loaded",pluginURL:u};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${u}`)}))}};class zs{constructor(e,c){this.isSupportedScript=bc,this.zoom=e,c?(this.now=c.now||0,this.fadeDuration=c.fadeDuration||0,this.zoomHistory=c.zoomHistory||new xs,this.transition=c.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new xs,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,c=e-Math.floor(e),u=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:c+(1-c)*u}:{fromScale:.5,toScale:1,t:1-(1-u)*c}}}function bc(e){return function(e,c){for(const u of e)if(!yc(u.codePointAt(0),c))return!1;return!0}(e,"loaded"===vc.getRTLTextPluginStatus())}const wc="-transition";class Cs{constructor(e,c,u){this.property=e,this.value=c,this.expression=function(e,c,u){if(Is(e))return new oi(e,c);if(Vs(e)){const p=Js(e,c,u);if("error"===p.result)throw new Error(p.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return p.value}{let u=e;return"color"===c.type&&"string"==typeof e?u=Ie.parse(e):"padding"!==c.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==c.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==c.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===c.type&&Array.isArray(e)?u=Le.parse(e):"projectionDefinition"===c.type&&"string"==typeof e&&(u=Re.parse(e)):u=Be.parse(e):u=ze.parse(e):u=Pe.parse(e),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>u}}}(void 0===c?e.specification.default:c,e.specification,u)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,c,u){return this.property.possiblyEvaluate(this,e,c,u)}}class Ls{constructor(e,c){this.property=e,this.value=new Cs(e,void 0,c)}transitioned(e,c){return new Rs(this.property,this.value,c,xe({},e.transition,this.transition),e.now)}untransitioned(){return new Rs(this.property,this.value,null,{},0)}}class Os{constructor(e,c){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=c}getValue(e){return Se(this._values[e].value.value)}setValue(e,c){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ls(this._values[e].property,this._globalState)),this._values[e].value=new Cs(this._values[e].property,null===c?void 0:Se(c),this._globalState)}getTransition(e){return Se(this._values[e].transition)}setTransition(e,c){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ls(this._values[e].property,this._globalState)),this._values[e].transition=Se(c)||void 0}serialize(){const e={};for(const c of Object.keys(this._values)){const u=this.getValue(c);void 0!==u&&(e[c]=u);const p=this.getTransition(c);void 0!==p&&(e[`${c}${wc}`]=p)}return e}transitioned(e,c){const u=new Ns(this._properties);for(const p of Object.keys(this._values))u._values[p]=this._values[p].transitioned(e,c._values[p]);return u}untransitioned(){const e=new Ns(this._properties);for(const c of Object.keys(this._values))e._values[c]=this._values[c].untransitioned();return e}}class Rs{constructor(e,c,u,p,f){this.property=e,this.value=c,this.begin=f+p.delay||0,this.end=this.begin+p.duration||0,e.specification.transition&&(p.delay||p.duration)&&(this.prior=u)}possiblyEvaluate(e,c,u){const p=e.now||0,f=this.value.possiblyEvaluate(e,c,u),m=this.prior;if(m){if(p>this.end)return this.prior=null,f;if(this.value.isDataDriven())return this.prior=null,f;if(pp.zoomHistory.lastIntegerZoom?{from:e,to:c}:{from:u,to:c}}interpolate(e){return e}}class Ys{constructor(e){this.specification=e}possiblyEvaluate(e,c,u,p){if(void 0!==e.value){if("constant"===e.expression.kind){const f=e.expression.evaluate(c,null,{},u,p);return this._calculate(f,f,f,c)}return this._calculate(e.expression.evaluate(new zs(Math.floor(c.zoom-1),c)),e.expression.evaluate(new zs(Math.floor(c.zoom),c)),e.expression.evaluate(new zs(Math.floor(c.zoom+1),c)),c)}}_calculate(e,c,u,p){return p.zoom>p.zoomHistory.lastIntegerZoom?{from:e,to:c}:{from:u,to:c}}interpolate(e){return e}}class Zs{constructor(e){this.specification=e}possiblyEvaluate(e,c,u,p){return!!e.expression.evaluate(c,null,{},u,p)}interpolate(){return!1}}class Hs{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const c in e){const u=e[c];u.specification.overridable&&this.overridableProperties.push(c);const p=this.defaultPropertyValues[c]=new Cs(u,void 0,void 0),f=this.defaultTransitionablePropertyValues[c]=new Ls(u,void 0);this.defaultTransitioningPropertyValues[c]=f.untransitioned(),this.defaultPossiblyEvaluatedValues[c]=p.possiblyEvaluate({})}}}Jl("DataDrivenProperty",Gs),Jl("DataConstantProperty",qs),Jl("CrossFadedDataDrivenProperty",Xs),Jl("CrossFadedProperty",Ys),Jl("ColorRampProperty",Zs);class Ks extends xt{constructor(e,c,u){if(super(),this.id=e.id,this.type=e.type,this._globalState=u,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=function(e,c){return new rs(e,c)}(this.visibility,u),"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=ko(e.filter,u)),c.layout&&(this._unevaluatedLayout=new $s(c.layout,u)),c.paint)){this._transitionablePaint=new Os(c.paint,u);for(const c in e.paint)this.setPaintProperty(c,e.paint[c],{validate:!1});for(const c in e.layout)this.setLayoutProperty(c,e.layout[c],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new js(c.paint)}}setFilter(e){this.filter=e,this._featureFilter=ko(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;for(const c of this._visibilityExpression.getGlobalStateRefs())e.add(c);if(this._unevaluatedLayout)for(const c in this._unevaluatedLayout._values){const u=this._unevaluatedLayout._values[c];for(const c of u.getGlobalStateRefs())e.add(c)}for(const c of this._featureFilter.getGlobalStateRefs())e.add(c);return e}getPaintAffectingGlobalStateRefs(){var e;const c=new globalThis.Map;if(this._transitionablePaint)for(const u in this._transitionablePaint._values){const p=this._transitionablePaint._values[u].value;for(const f of p.getGlobalStateRefs()){const m=null!==(e=c.get(f))&&void 0!==e?e:[];m.push({name:u,value:p.value}),c.set(f,m)}}return c}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,c,u={}){if(null==c||!this._validate(Xl,`layers.${this.id}.layout.${e}`,e,c,u))return"visibility"===e?(this.visibility=c,this._visibilityExpression.setValue(c),void this.recalculateVisibility()):void this._unevaluatedLayout.setValue(e,c)}getPaintProperty(e){return e.endsWith(wc)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,c,u={}){if(null!=c&&this._validate(Hl,`layers.${this.id}.paint.${e}`,e,c,u))return!1;if(e.endsWith(wc))return this._transitionablePaint.setTransition(e.slice(0,-11),c||void 0),!1;{const u=this._transitionablePaint._values[e],p="cross-faded-data-driven"===u.property.specification["property-type"],f=u.value.isDataDriven(),m=u.value;this._transitionablePaint.setValue(e,c),this._handleSpecialPaintPropertyUpdate(e);const g=this._transitionablePaint._values[e].value;return g.isDataDriven()||f||p||this._handleOverridablePaintPropertyUpdate(e,m,g)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,c,u){return!1}isHidden(e=this.minzoom,c=!1){return!!(this.minzoom&&e<(c?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&e>=this.maxzoom)||"none"===this._evaluatedVisibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(e,c){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,c)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,c)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),we(e,((e,c)=>!(void 0===e||"layout"===c&&!Object.keys(e).length||"paint"===c&&!Object.keys(e).length)))}_validate(e,c,u,p,f={}){return(!f||!1!==f.validate)&&Yl(this,e.call($l,{key:c,layerType:this.type,objectKey:u,value:p,styleSpec:Et,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const c=this.paint.get(e);if(c instanceof Us&&ws(c.property.specification)&&("source"===c.value.kind||"composite"===c.value.kind)&&c.value.isStateDependent)return!0}return!1}}let Tc;var Sc={get paint(){return Tc=Tc||new Hs({"raster-opacity":new qs(Et.paint_raster["raster-opacity"]),"raster-hue-rotate":new qs(Et.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new qs(Et.paint_raster["raster-brightness-min"]),"raster-brightness-max":new qs(Et.paint_raster["raster-brightness-max"]),"raster-saturation":new qs(Et.paint_raster["raster-saturation"]),"raster-contrast":new qs(Et.paint_raster["raster-contrast"]),"raster-resampling":new qs(Et.paint_raster["raster-resampling"]),"raster-fade-duration":new qs(Et.paint_raster["raster-fade-duration"])})}};class Qs extends Ks{constructor(e,c){super(e,Sc,c)}}const Pc={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class ea{constructor(e,c){this._structArray=e,this._pos1=c*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class ra{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,c){return e._trim(),c&&(e.isTransferred=!0,c.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const c=Object.create(this.prototype);return c.arrayBuffer=e.arrayBuffer,c.length=e.length,c.capacity=e.arrayBuffer.byteLength/c.bytesPerElement,c._refreshViews(),c}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const c=this.uint8;this._refreshViews(),c&&this.uint8.set(c)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Ic(e,c=1){let u=0,p=0;return{members:e.map((e=>{const f=Pc[e.type].BYTES_PER_ELEMENT,m=u=Mc(u,Math.max(c,f)),g=e.components||1;return p=Math.max(p,f),u+=f*g,{name:e.name,type:e.type,components:g,offset:m}})),size:Mc(u,Math.max(p,c)),alignment:c}}function Mc(e,c){return Math.ceil(e/c)*c}class sa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,c)}emplace(e,c,u){const p=2*e;return this.int16[p+0]=c,this.int16[p+1]=u,e}}sa.prototype.bytesPerElement=4,Jl("StructArrayLayout2i4",sa);class aa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,c,u)}emplace(e,c,u,p){const f=3*e;return this.int16[f+0]=c,this.int16[f+1]=u,this.int16[f+2]=p,e}}aa.prototype.bytesPerElement=6,Jl("StructArrayLayout3i6",aa);class oa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,c,u,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,c,u,p)}emplace(e,c,u,p,f){const m=4*e;return this.int16[m+0]=c,this.int16[m+1]=u,this.int16[m+2]=p,this.int16[m+3]=f,e}}oa.prototype.bytesPerElement=8,Jl("StructArrayLayout4i8",oa);class la extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,c,u,p,f,m){const g=this.length;return this.resize(g+1),this.emplace(g,e,c,u,p,f,m)}emplace(e,c,u,p,f,m,g){const y=6*e;return this.int16[y+0]=c,this.int16[y+1]=u,this.int16[y+2]=p,this.int16[y+3]=f,this.int16[y+4]=m,this.int16[y+5]=g,e}}la.prototype.bytesPerElement=12,Jl("StructArrayLayout2i4i12",la);class ua extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,c,u,p,f,m){const g=this.length;return this.resize(g+1),this.emplace(g,e,c,u,p,f,m)}emplace(e,c,u,p,f,m,g){const y=4*e,x=8*e;return this.int16[y+0]=c,this.int16[y+1]=u,this.uint8[x+4]=p,this.uint8[x+5]=f,this.uint8[x+6]=m,this.uint8[x+7]=g,e}}ua.prototype.bytesPerElement=8,Jl("StructArrayLayout2i4ub8",ua);class ca extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,c)}emplace(e,c,u){const p=2*e;return this.float32[p+0]=c,this.float32[p+1]=u,e}}ca.prototype.bytesPerElement=8,Jl("StructArrayLayout2f8",ca);class ha extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,c,u,p,f,m,g,y,x,b){const T=this.length;return this.resize(T+1),this.emplace(T,e,c,u,p,f,m,g,y,x,b)}emplace(e,c,u,p,f,m,g,y,x,b,T){const S=10*e;return this.uint16[S+0]=c,this.uint16[S+1]=u,this.uint16[S+2]=p,this.uint16[S+3]=f,this.uint16[S+4]=m,this.uint16[S+5]=g,this.uint16[S+6]=y,this.uint16[S+7]=x,this.uint16[S+8]=b,this.uint16[S+9]=T,e}}ha.prototype.bytesPerElement=20,Jl("StructArrayLayout10ui20",ha);class pa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,c,u,p,f,m,g,y){const x=this.length;return this.resize(x+1),this.emplace(x,e,c,u,p,f,m,g,y)}emplace(e,c,u,p,f,m,g,y,x){const b=8*e;return this.uint16[b+0]=c,this.uint16[b+1]=u,this.uint16[b+2]=p,this.uint16[b+3]=f,this.uint16[b+4]=m,this.uint16[b+5]=g,this.uint16[b+6]=y,this.uint16[b+7]=x,e}}pa.prototype.bytesPerElement=16,Jl("StructArrayLayout8ui16",pa);class fa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,c,u,p,f,m,g,y,x,b,T,S){const P=this.length;return this.resize(P+1),this.emplace(P,e,c,u,p,f,m,g,y,x,b,T,S)}emplace(e,c,u,p,f,m,g,y,x,b,T,S,P){const I=12*e;return this.int16[I+0]=c,this.int16[I+1]=u,this.int16[I+2]=p,this.int16[I+3]=f,this.uint16[I+4]=m,this.uint16[I+5]=g,this.uint16[I+6]=y,this.uint16[I+7]=x,this.int16[I+8]=b,this.int16[I+9]=T,this.int16[I+10]=S,this.int16[I+11]=P,e}}fa.prototype.bytesPerElement=24,Jl("StructArrayLayout4i4ui4i24",fa);class da extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,c,u)}emplace(e,c,u,p){const f=3*e;return this.float32[f+0]=c,this.float32[f+1]=u,this.float32[f+2]=p,e}}da.prototype.bytesPerElement=12,Jl("StructArrayLayout3f12",da);class ya extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const c=this.length;return this.resize(c+1),this.emplace(c,e)}emplace(e,c){return this.uint32[1*e+0]=c,e}}ya.prototype.bytesPerElement=4,Jl("StructArrayLayout1ul4",ya);class ma extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,c,u,p,f,m,g,y,x){const b=this.length;return this.resize(b+1),this.emplace(b,e,c,u,p,f,m,g,y,x)}emplace(e,c,u,p,f,m,g,y,x,b){const T=10*e,S=5*e;return this.int16[T+0]=c,this.int16[T+1]=u,this.int16[T+2]=p,this.int16[T+3]=f,this.int16[T+4]=m,this.int16[T+5]=g,this.uint32[S+3]=y,this.uint16[T+8]=x,this.uint16[T+9]=b,e}}ma.prototype.bytesPerElement=20,Jl("StructArrayLayout6i1ul2ui20",ma);class ga extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,c,u,p,f,m){const g=this.length;return this.resize(g+1),this.emplace(g,e,c,u,p,f,m)}emplace(e,c,u,p,f,m,g){const y=6*e;return this.int16[y+0]=c,this.int16[y+1]=u,this.int16[y+2]=p,this.int16[y+3]=f,this.int16[y+4]=m,this.int16[y+5]=g,e}}ga.prototype.bytesPerElement=12,Jl("StructArrayLayout2i2i2i12",ga);class xa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,c,u,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,e,c,u,p,f)}emplace(e,c,u,p,f,m){const g=4*e,y=8*e;return this.float32[g+0]=c,this.float32[g+1]=u,this.float32[g+2]=p,this.int16[y+6]=f,this.int16[y+7]=m,e}}xa.prototype.bytesPerElement=16,Jl("StructArrayLayout2f1f2i16",xa);class va extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,c,u,p,f,m){const g=this.length;return this.resize(g+1),this.emplace(g,e,c,u,p,f,m)}emplace(e,c,u,p,f,m,g){const y=16*e,x=4*e,b=8*e;return this.uint8[y+0]=c,this.uint8[y+1]=u,this.float32[x+1]=p,this.float32[x+2]=f,this.int16[b+6]=m,this.int16[b+7]=g,e}}va.prototype.bytesPerElement=16,Jl("StructArrayLayout2ub2f2i16",va);class ba extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,c,u)}emplace(e,c,u,p){const f=3*e;return this.uint16[f+0]=c,this.uint16[f+1]=u,this.uint16[f+2]=p,e}}ba.prototype.bytesPerElement=6,Jl("StructArrayLayout3ui6",ba);class wa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,c,u,p,f,m,g,y,x,b,T,S,P,I,C,R,F){const L=this.length;return this.resize(L+1),this.emplace(L,e,c,u,p,f,m,g,y,x,b,T,S,P,I,C,R,F)}emplace(e,c,u,p,f,m,g,y,x,b,T,S,P,I,C,R,F,L){const B=24*e,O=12*e,V=48*e;return this.int16[B+0]=c,this.int16[B+1]=u,this.uint16[B+2]=p,this.uint16[B+3]=f,this.uint32[O+2]=m,this.uint32[O+3]=g,this.uint32[O+4]=y,this.uint16[B+10]=x,this.uint16[B+11]=b,this.uint16[B+12]=T,this.float32[O+7]=S,this.float32[O+8]=P,this.uint8[V+36]=I,this.uint8[V+37]=C,this.uint8[V+38]=R,this.uint32[O+10]=F,this.int16[B+22]=L,e}}wa.prototype.bytesPerElement=48,Jl("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",wa);class _a extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,c,u,p,f,m,g,y,x,b,T,S,P,I,C,R,F,L,B,O,V,j,G,U,q,Z,W,J){const Q=this.length;return this.resize(Q+1),this.emplace(Q,e,c,u,p,f,m,g,y,x,b,T,S,P,I,C,R,F,L,B,O,V,j,G,U,q,Z,W,J)}emplace(e,c,u,p,f,m,g,y,x,b,T,S,P,I,C,R,F,L,B,O,V,j,G,U,q,Z,W,J,Q){const ee=32*e,se=16*e;return this.int16[ee+0]=c,this.int16[ee+1]=u,this.int16[ee+2]=p,this.int16[ee+3]=f,this.int16[ee+4]=m,this.int16[ee+5]=g,this.int16[ee+6]=y,this.int16[ee+7]=x,this.uint16[ee+8]=b,this.uint16[ee+9]=T,this.uint16[ee+10]=S,this.uint16[ee+11]=P,this.uint16[ee+12]=I,this.uint16[ee+13]=C,this.uint16[ee+14]=R,this.uint16[ee+15]=F,this.uint16[ee+16]=L,this.uint16[ee+17]=B,this.uint16[ee+18]=O,this.uint16[ee+19]=V,this.uint16[ee+20]=j,this.uint16[ee+21]=G,this.uint16[ee+22]=U,this.uint32[se+12]=q,this.float32[se+13]=Z,this.float32[se+14]=W,this.uint16[ee+30]=J,this.uint16[ee+31]=Q,e}}_a.prototype.bytesPerElement=64,Jl("StructArrayLayout8i15ui1ul2f2ui64",_a);class Sa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const c=this.length;return this.resize(c+1),this.emplace(c,e)}emplace(e,c){return this.float32[1*e+0]=c,e}}Sa.prototype.bytesPerElement=4,Jl("StructArrayLayout1f4",Sa);class Aa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,c,u)}emplace(e,c,u,p){const f=3*e;return this.uint16[6*e+0]=c,this.float32[f+1]=u,this.float32[f+2]=p,e}}Aa.prototype.bytesPerElement=12,Jl("StructArrayLayout1ui2f12",Aa);class ka extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,c,u)}emplace(e,c,u,p){const f=4*e;return this.uint32[2*e+0]=c,this.uint16[f+2]=u,this.uint16[f+3]=p,e}}ka.prototype.bytesPerElement=8,Jl("StructArrayLayout1ul2ui8",ka);class Ma extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,c)}emplace(e,c,u){const p=2*e;return this.uint16[p+0]=c,this.uint16[p+1]=u,e}}Ma.prototype.bytesPerElement=4,Jl("StructArrayLayout2ui4",Ma);class Ia extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const c=this.length;return this.resize(c+1),this.emplace(c,e)}emplace(e,c){return this.uint16[1*e+0]=c,e}}Ia.prototype.bytesPerElement=2,Jl("StructArrayLayout1ui2",Ia);class Ta extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,c,u,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,c,u,p)}emplace(e,c,u,p,f){const m=4*e;return this.float32[m+0]=c,this.float32[m+1]=u,this.float32[m+2]=p,this.float32[m+3]=f,e}}Ta.prototype.bytesPerElement=16,Jl("StructArrayLayout4f16",Ta);class Ea extends ea{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 p(this.anchorPointX,this.anchorPointY)}}Ea.prototype.size=20;class Fa extends ma{get(e){return new Ea(this,e)}}Jl("CollisionBoxArray",Fa);class Da extends ea{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Da.prototype.size=48;class Pa extends wa{get(e){return new Da(this,e)}}Jl("PlacedSymbolArray",Pa);class za extends ea{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}za.prototype.size=64;class Ba extends _a{get(e){return new za(this,e)}}Jl("SymbolInstanceArray",Ba);class Va extends Sa{getoffsetX(e){return this.float32[1*e+0]}}Jl("GlyphOffsetArray",Va);class Ca extends aa{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}Jl("SymbolLineVertexArray",Ca);class La extends ea{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]}}La.prototype.size=12;class Oa extends Aa{get(e){return new La(this,e)}}Jl("TextAnchorOffsetArray",Oa);class Ra extends ea{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]}}Ra.prototype.size=8;class Na extends ka{get(e){return new Ra(this,e)}}Jl("FeatureIndexArray",Na);class $a extends sa{}class Ua extends sa{}class ja extends sa{}class qa extends la{}class Ga extends ua{}class Xa extends ca{}class Ya extends ha{}class Za extends pa{}class Ha extends fa{}class Ka extends da{}class Wa extends ya{}class Ja extends ga{}class Qa extends va{}class to extends ba{}class eo extends Ma{}const Cc=Ic([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ac}=Cc;class io{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,c,u,p){const f=this.segments[this.segments.length-1];return e>io.MAX_VERTEX_ARRAY_LENGTH&&Ee(`Max vertices per segment is ${io.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${io.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!f||f.vertexLength+e>io.MAX_VERTEX_ARRAY_LENGTH||f.sortKey!==p?this.createNewSegment(c,u,p):f}createNewSegment(e,c,u){const p={vertexOffset:e.length,primitiveOffset:c.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==u&&(p.sortKey=u),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(p),p}getOrCreateLatestSegment(e,c,u){return this.prepareSegment(0,e,c,u)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const e of this.segments)for(const c in e.vaos)e.vaos[c].destroy()}static simpleSegment(e,c,u,p){return new io([{vertexOffset:e,primitiveOffset:c,vertexLength:u,primitiveLength:p,vaos:{},sortKey:0}])}}function Dc(e,c){return 256*(e=ge(Math.floor(e),0,255))+ge(Math.floor(c),0,255)}io.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Jl("SegmentVector",io);const zc=Ic([{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"}]),Rc=Ic([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var Fc,Lc,Bc,Oc={exports:{}},Vc={exports:{}},jc={exports:{}},Nc=function(){if(Bc)return Oc.exports;Bc=1;var e=(Fc||(Fc=1,Vc.exports=function(e,c){var u,p,f,m,g,y,x,b;for(p=e.length-(u=3&e.length),f=c,g=3432918353,y=461845907,b=0;b>>16)*g&65535)<<16)&4294967295)<<15|x>>>17))*y+(((x>>>16)*y&65535)<<16)&4294967295)<<13|f>>>19))+((5*(f>>>16)&65535)<<16)&4294967295))+((58964+(m>>>16)&65535)<<16);switch(x=0,u){case 3:x^=(255&e.charCodeAt(b+2))<<16;case 2:x^=(255&e.charCodeAt(b+1))<<8;case 1:f^=x=(65535&(x=(x=(65535&(x^=255&e.charCodeAt(b)))*g+(((x>>>16)*g&65535)<<16)&4294967295)<<15|x>>>17))*y+(((x>>>16)*y&65535)<<16)&4294967295}return f^=e.length,f=2246822507*(65535&(f^=f>>>16))+((2246822507*(f>>>16)&65535)<<16)&4294967295,f=3266489909*(65535&(f^=f>>>13))+((3266489909*(f>>>16)&65535)<<16)&4294967295,(f^=f>>>16)>>>0}),Vc.exports),c=(Lc||(Lc=1,jc.exports=function(e,c){for(var u,p=e.length,f=c^p,m=0;p>=4;)u=1540483477*(65535&(u=255&e.charCodeAt(m)|(255&e.charCodeAt(++m))<<8|(255&e.charCodeAt(++m))<<16|(255&e.charCodeAt(++m))<<24))+((1540483477*(u>>>16)&65535)<<16),f=1540483477*(65535&f)+((1540483477*(f>>>16)&65535)<<16)^(u=1540483477*(65535&(u^=u>>>24))+((1540483477*(u>>>16)&65535)<<16)),p-=4,++m;switch(p){case 3:f^=(255&e.charCodeAt(m+2))<<16;case 2:f^=(255&e.charCodeAt(m+1))<<8;case 1:f=1540483477*(65535&(f^=255&e.charCodeAt(m)))+((1540483477*(f>>>16)&65535)<<16)}return f=1540483477*(65535&(f^=f>>>13))+((1540483477*(f>>>16)&65535)<<16),(f^=f>>>15)>>>0}),jc.exports);return Oc.exports=e,Oc.exports.murmur3=e,Oc.exports.murmur2=c,Oc.exports}(),Uc=f(Nc);class go{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,c,u,p){this.ids.push(qc(e)),this.positions.push(c,u,p)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const c=qc(e);let u=0,p=this.ids.length-1;for(;u>1;this.ids[e]>=c?p=e:u=e+1}const f=[];for(;this.ids[u]===c;)f.push({index:this.positions[3*u],start:this.positions[3*u+1],end:this.positions[3*u+2]}),u++;return f}static serialize(e,c){const u=new Float64Array(e.ids),p=new Uint32Array(e.positions);return $c(u,p,0,u.length-1),c&&c.push(u.buffer,p.buffer),{ids:u,positions:p}}static deserialize(e){const c=new go;return c.ids=e.ids,c.positions=e.positions,c.indexed=!0,c}}function qc(e){const c=+e;return!isNaN(c)&&c<=Number.MAX_SAFE_INTEGER?c:Uc(String(e))}function $c(e,c,u,p){for(;u>1];let m=u-1,g=p+1;for(;;){do{m++}while(e[m]f);if(m>=g)break;Zc(e,m,g),Zc(c,3*m,3*g),Zc(c,3*m+1,3*g+1),Zc(c,3*m+2,3*g+2)}g-u`u_${e}`)),this.type=u}setUniform(e,c,u){e.set(u.constantOr(this.value))}getBinding(e,c,u){return"color"===this.type?new Ao(e,c):new _o(e,c)}}class To{constructor(e,c){this.uniformNames=c.map((e=>`u_${e}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,c){this.pixelRatioFrom=c.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=c.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,c){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,c.y,c.height,c.width]}setUniform(e,c,u,p){let f=null;"u_pattern_to"===p?f=this.patternTo:"u_pattern_from"===p?f=this.patternFrom:"u_dasharray_to"===p?f=this.dashTo:"u_dasharray_from"===p?f=this.dashFrom:"u_pixel_ratio_to"===p?f=this.pixelRatioTo:"u_pixel_ratio_from"===p&&(f=this.pixelRatioFrom),null!==f&&e.set(f)}getBinding(e,c,u){return u.startsWith("u_pattern")||u.startsWith("u_dasharray_")?new So(e,c):new _o(e,c)}}class Eo{constructor(e,c,u,p){this.expression=e,this.type=u,this.maxValue=0,this.paintVertexAttributes=c.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===u?2:1,offset:0}))),this.paintVertexArray=new p}populatePaintArray(e,c,u){const p=this.paintVertexArray.length,f=this.expression.evaluate(new zs(0,u),c,{},u.canonical,[],u.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(p,e,f)}updatePaintArray(e,c,u,p,f){const m=this.expression.evaluate(new zs(0,f),u,p);this._setPaintValue(e,c,m)}_setPaintValue(e,c,u){if("color"===this.type){const p=Hc(u);for(let u=e;u`u_${e}_t`)),this.type=u,this.useIntegerZoom=p,this.zoom=f,this.maxValue=0,this.paintVertexAttributes=c.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===u?4:2,offset:0}))),this.paintVertexArray=new m}populatePaintArray(e,c,u){const p=this.expression.evaluate(new zs(this.zoom,u),c,{},u.canonical,[],u.formattedSection),f=this.expression.evaluate(new zs(this.zoom+1,u),c,{},u.canonical,[],u.formattedSection),m=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(m,e,p,f)}updatePaintArray(e,c,u,p,f){const m=this.expression.evaluate(new zs(this.zoom,f),u,p),g=this.expression.evaluate(new zs(this.zoom+1,f),u,p);this._setPaintValue(e,c,m,g)}_setPaintValue(e,c,u,p){if("color"===this.type){const f=Hc(u),m=Hc(p);for(let u=e;u`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const c in this.binders){const u=this.binders[c];if(u instanceof Eo||u instanceof Fo)for(let c=0;c!0){this.programConfigurations={};for(const p of e)this.programConfigurations[p.id]=new Bo(p,c,u);this.needsUpload=!1,this._featureMap=new go,this._bufferOffset=0}populatePaintArrays(e,c,u,p){for(const u in this.programConfigurations)this.programConfigurations[u].populatePaintArrays(e,c,p);void 0!==c.id&&this._featureMap.add(c.id,u,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,c,u,p){for(const f of u)this.needsUpload=this.programConfigurations[f.id].updatePaintArrays(e,this._featureMap,c,f,p)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const c in this.programConfigurations)this.programConfigurations[c].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Yc(e,c){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[e]||[e.replace(`${c}-`,"").replace(/-/g,"_")]}function Kc(e,c,u){const p={color:{source:ca,composite:Ta},number:{source:Sa,composite:ca}},f=function(e){return{"line-pattern":{source:Ya,composite:Ya},"fill-pattern":{source:Ya,composite:Ya},"fill-extrusion-pattern":{source:Ya,composite:Ya},"line-dasharray":{source:Za,composite:Za}}[e]}(e);return f&&f[u]||p[c][u]}Jl("ConstantBinder",Io),Jl("CrossFadedConstantBinder",To),Jl("SourceExpressionBinder",Eo),Jl("CrossFadedPatternBinder",Po),Jl("CrossFadedDasharrayBinder",zo),Jl("CompositeExpressionBinder",Fo),Jl("ProgramConfiguration",Bo,{omit:["_buffers"]}),Jl("ProgramConfigurationSet",Vo);const Jc=Math.pow(2,14)-1,Qc=-Jc-1;function eh(e){const c=se/e.extent,u=e.loadGeometry();for(let e=0;eu.x+1||mu.y+1)&&Ee("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return u}function th(e,c){return{type:e.type,id:e.id,properties:e.properties,geometry:c?eh(e):[]}}const ih=-32768;function rh(e,c,u,p,f){e.emplaceBack(ih+8*c+p,ih+8*u+f)}class qo{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Ua,this.indexArray=new to,this.segments=new io,this.programConfigurations=new Vo(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,c,u){const p=this.layers[0],f=[];let m=null,g=!1,y="heatmap"===p.type;if("circle"===p.type){const e=p;m=e.layout.get("circle-sort-key"),g=!m.isConstant(),y=y||"map"===e.paint.get("circle-pitch-alignment")}const x=y?c.subdivisionGranularity.circle:1;for(const{feature:c,id:p,index:y,sourceLayerIndex:x}of e){const e=this.layers[0]._featureFilter.needGeometry,b=th(c,e);if(!this.layers[0]._featureFilter.filter(new zs(this.zoom),b,u))continue;const T=g?m.evaluate(b,{},u):void 0,S={id:p,properties:c.properties,type:c.type,sourceLayerIndex:x,index:y,geometry:e?b.geometry:eh(c),patterns:{},sortKey:T};f.push(S)}g&&f.sort(((e,c)=>e.sortKey-c.sortKey));for(const p of f){const{geometry:f,index:m,sourceLayerIndex:g}=p,y=e[m].feature;this.addFeature(p,f,m,u,x),c.featureIndex.insert(y,f,m,g,this.index)}}update(e,c,u){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,c,this.stateDependentLayers,{imagePositions:u})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ac),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,c,u,p,f=1){let m;switch(f){case 1:m=[0,7];break;case 3:m=[0,2,5,7];break;case 5:m=[0,1,3,4,6,7];break;case 7:m=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${f}; valid values are 1, 3, 5, 7.`)}const g=m.length;for(const u of c)for(const c of u){const u=c.x,p=c.y;if(u<0||u>=se||p<0||p>=se)continue;const f=this.segments.prepareSegment(g*g,this.layoutVertexArray,this.indexArray,e.sortKey),y=f.vertexLength;for(let e=0;e1){if(lh(e,c))return!0;for(let p=0;p1?u:u.sub(c)._mult(f)._add(c))}function ph(e,c){let u,p,f,m=!1;for(let g=0;gc.y!=f.y>c.y&&c.x<(f.x-p.x)*(c.y-p.y)/(f.y-p.y)+p.x&&(m=!m)}return m}function mh(e,c){let u=!1;for(let p=0,f=e.length-1;pc.y!=g.y>c.y&&c.x<(g.x-m.x)*(c.y-m.y)/(g.y-m.y)+m.x&&(u=!u)}return u}function _h(e,c,u){const p=u[0],f=u[2];if(e.xf.x&&c.x>f.x||e.yf.y&&c.y>f.y)return!1;const m=Ce(e,c,u[0]);return m!==Ce(e,c,u[1])||m!==Ce(e,c,u[2])||m!==Ce(e,c,u[3])}function gh(e,c,u){const p=c.paint.get(e).value;return"constant"===p.kind?p.value:u.programConfigurations.get(c.id).getMaxValue(e)}function xh(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function wh(e,c,u,f,m){if(!c[0]&&!c[1])return e;const g=p.convert(c)._mult(m);"viewport"===u&&g._rotate(-f);const y=[];for(let c=0;czh(e,c,u,p)))}(x,f,g,y),I=b),Dh({queryGeometry:P,size:I,transform:f,unwrappedTileID:g,getElevation:y,pitchAlignment:S,pitchScale:T},p)}}class ml extends qo{}let Vh;Jl("HeatmapBucket",ml,{omit:["layers"]});var jh={get paint(){return Vh=Vh||new Hs({"heatmap-radius":new Gs(Et.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Gs(Et.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new qs(Et.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Zs(Et.paint_heatmap["heatmap-color"]),"heatmap-opacity":new qs(Et.paint_heatmap["heatmap-opacity"])})}};function Gh(e,{width:c,height:u},p,f){if(f){if(f instanceof Uint8ClampedArray)f=new Uint8Array(f.buffer);else if(f.length!==c*u*p)throw new RangeError(`mismatched image size. expected: ${f.length} but got: ${c*u*p}`)}else f=new Uint8Array(c*u*p);return e.width=c,e.height=u,e.data=f,e}function Uh(e,{width:c,height:u},p){if(c===e.width&&u===e.height)return;const f=Gh({},{width:c,height:u},p);qh(e,f,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,c),height:Math.min(e.height,u)},p),e.width=c,e.height=u,e.data=f.data}function qh(e,c,u,p,f,m){if(0===f.width||0===f.height)return c;if(f.width>e.width||f.height>e.height||u.x>e.width-f.width||u.y>e.height-f.height)throw new RangeError("out of range source coordinates for image copy");if(f.width>c.width||f.height>c.height||p.x>c.width-f.width||p.y>c.height-f.height)throw new RangeError("out of range destination coordinates for image copy");const g=e.data,y=c.data;if(g===y)throw new Error("srcData equals dstData, so image is already copied");for(let x=0;x{c[e.evaluationKey]=g;const y=e.expression.evaluate(c);f.setPixel(p/4/u,m/4,y)};if(e.clips)for(let c=0,f=0;cthis.max&&(this.max=u),u=this.dim+1||c<-1||c>=this.dim+1)throw new RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${c}, dim: ${this.dim}`);return(c+1)*this.stride+(e+1)}unpack(e,c,u){return e*this.redFactor+c*this.greenFactor+u*this.blueFactor-this.baseShift}pack(e){return lu(e,this.getUnpackVector())}getPixels(){return new Sl({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,c,u){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let p=c*this.dim,f=c*this.dim+this.dim,m=u*this.dim,g=u*this.dim+this.dim;switch(c){case-1:p=f-1;break;case 1:f=p+1}switch(u){case-1:m=g-1;break;case 1:g=m+1}const y=-c*this.dim,x=-u*this.dim;for(let c=m;c0)for(let f=c;f=c;f-=p)m=Uu(f/p|0,e[f],e[f+1],m);return m&&Fu(m,m.next)&&(qu(m),m=m.next),m}function _u(e,c){if(!e)return e;c||(c=e);let u,p=e;do{if(u=!1,p.steiner||!Fu(p,p.next)&&0!==Ru(p.prev,p,p.next))p=p.next;else{if(qu(p),p=c=p.prev,p===p.next)break;u=!0}}while(u||p!==c);return c}function yu(e,c,u,p,f,m,g){if(!e)return;!g&&m&&function(e,c,u,p){let f=e;do{0===f.z&&(f.z=Eu(f.x,f.y,c,u,p)),f.prevZ=f.prev,f.nextZ=f.next,f=f.next}while(f!==e);f.prevZ.nextZ=null,f.prevZ=null,function(e){let c,u=1;do{let p,f=e;e=null;let m=null;for(c=0;f;){c++;let g=f,y=0;for(let e=0;e0||x>0&&g;)0!==y&&(0===x||!g||f.z<=g.z)?(p=f,f=f.nextZ,y--):(p=g,g=g.nextZ,x--),m?m.nextZ=p:e=p,p.prevZ=m,m=p;f=g}m.nextZ=null,u*=2}while(c>1)}(f)}(e,p,f,m);let y=e;for(;e.prev!==e.next;){const x=e.prev,b=e.next;if(m?vu(e,p,f,m):xu(e))c.push(x.i,e.i,b.i),qu(e),e=b.next,y=b.next;else if((e=b)===y){g?1===g?yu(e=bu(_u(e),c),c,u,p,f,m,2):2===g&&wu(e,c,u,p,f,m):yu(_u(e),c,u,p,f,m,1);break}}}function xu(e){const c=e.prev,u=e,p=e.next;if(Ru(c,u,p)>=0)return!1;const f=c.x,m=u.x,g=p.x,y=c.y,x=u.y,b=p.y,T=Math.min(f,m,g),S=Math.min(y,x,b),P=Math.max(f,m,g),I=Math.max(y,x,b);let C=p.next;for(;C!==c;){if(C.x>=T&&C.x<=P&&C.y>=S&&C.y<=I&&zu(f,y,m,x,g,b,C.x,C.y)&&Ru(C.prev,C,C.next)>=0)return!1;C=C.next}return!0}function vu(e,c,u,p){const f=e.prev,m=e,g=e.next;if(Ru(f,m,g)>=0)return!1;const y=f.x,x=m.x,b=g.x,T=f.y,S=m.y,P=g.y,I=Math.min(y,x,b),C=Math.min(T,S,P),R=Math.max(y,x,b),F=Math.max(T,S,P),L=Eu(I,C,c,u,p),B=Eu(R,F,c,u,p);let O=e.prevZ,V=e.nextZ;for(;O&&O.z>=L&&V&&V.z<=B;){if(O.x>=I&&O.x<=R&&O.y>=C&&O.y<=F&&O!==f&&O!==g&&zu(y,T,x,S,b,P,O.x,O.y)&&Ru(O.prev,O,O.next)>=0)return!1;if(O=O.prevZ,V.x>=I&&V.x<=R&&V.y>=C&&V.y<=F&&V!==f&&V!==g&&zu(y,T,x,S,b,P,V.x,V.y)&&Ru(V.prev,V,V.next)>=0)return!1;V=V.nextZ}for(;O&&O.z>=L;){if(O.x>=I&&O.x<=R&&O.y>=C&&O.y<=F&&O!==f&&O!==g&&zu(y,T,x,S,b,P,O.x,O.y)&&Ru(O.prev,O,O.next)>=0)return!1;O=O.prevZ}for(;V&&V.z<=B;){if(V.x>=I&&V.x<=R&&V.y>=C&&V.y<=F&&V!==f&&V!==g&&zu(y,T,x,S,b,P,V.x,V.y)&&Ru(V.prev,V,V.next)>=0)return!1;V=V.nextZ}return!0}function bu(e,c){let u=e;do{const p=u.prev,f=u.next.next;!Fu(p,f)&&Bu(p,u,u.next,f)&&Nu(p,f)&&Nu(f,p)&&(c.push(p.i,u.i,f.i),qu(u),qu(u.next),u=e=f),u=u.next}while(u!==e);return _u(u)}function wu(e,c,u,p,f,m){let g=e;do{let e=g.next.next;for(;e!==g.prev;){if(g.i!==e.i&&ku(g,e)){let y=Gu(g,e);return g=_u(g,g.next),y=_u(y,y.next),yu(g,c,u,p,f,m,0),void yu(y,c,u,p,f,m,0)}e=e.next}g=g.next}while(g!==e)}function Tu(e,c){let u=e.x-c.x;return 0===u&&(u=e.y-c.y,0===u)&&(u=(e.next.y-e.y)/(e.next.x-e.x)-(c.next.y-c.y)/(c.next.x-c.x)),u}function Pu(e,c){const u=function(e,c){let u=c;const p=e.x,f=e.y;let m,g=-1/0;if(Fu(e,u))return u;do{if(Fu(e,u.next))return u.next;if(f<=u.y&&f>=u.next.y&&u.next.y!==u.y){const e=u.x+(f-u.y)*(u.next.x-u.x)/(u.next.y-u.y);if(e<=p&&e>g&&(g=e,m=u.x=u.x&&u.x>=x&&p!==u.x&&Au(fm.x||u.x===m.x&&Mu(m,u)))&&(m=u,T=c)}u=u.next}while(u!==y);return m}(e,c);if(!u)return c;const p=Gu(u,e);return _u(p,p.next),_u(u,u.next)}function Mu(e,c){return Ru(e.prev,e,c.prev)<0&&Ru(c.next,e,e.next)<0}function Eu(e,c,u,p,f){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-u)*f|0)|e<<8))|e<<4))|e<<2))|e<<1))|(c=1431655765&((c=858993459&((c=252645135&((c=16711935&((c=(c-p)*f|0)|c<<8))|c<<4))|c<<2))|c<<1))<<1}function Cu(e){let c=e,u=e;do{(c.x=(e-g)*(m-y)&&(e-g)*(p-y)>=(u-g)*(c-y)&&(u-g)*(m-y)>=(f-g)*(p-y)}function zu(e,c,u,p,f,m,g,y){return!(e===g&&c===y)&&Au(e,c,u,p,f,m,g,y)}function ku(e,c){return e.next.i!==c.i&&e.prev.i!==c.i&&!function(e,c){let u=e;do{if(u.i!==e.i&&u.next.i!==e.i&&u.i!==c.i&&u.next.i!==c.i&&Bu(u,u.next,e,c))return!0;u=u.next}while(u!==e);return!1}(e,c)&&(Nu(e,c)&&Nu(c,e)&&function(e,c){let u=e,p=!1;const f=(e.x+c.x)/2,m=(e.y+c.y)/2;do{u.y>m!=u.next.y>m&&u.next.y!==u.y&&f<(u.next.x-u.x)*(m-u.y)/(u.next.y-u.y)+u.x&&(p=!p),u=u.next}while(u!==e);return p}(e,c)&&(Ru(e.prev,e,c.prev)||Ru(e,c.prev,c))||Fu(e,c)&&Ru(e.prev,e,e.next)>0&&Ru(c.prev,c,c.next)>0)}function Ru(e,c,u){return(c.y-e.y)*(u.x-c.x)-(c.x-e.x)*(u.y-c.y)}function Fu(e,c){return e.x===c.x&&e.y===c.y}function Bu(e,c,u,p){const f=ju(Ru(e,c,u)),m=ju(Ru(e,c,p)),g=ju(Ru(u,p,e)),y=ju(Ru(u,p,c));return f!==m&&g!==y||!(0!==f||!Ou(e,u,c))||!(0!==m||!Ou(e,p,c))||!(0!==g||!Ou(u,e,p))||!(0!==y||!Ou(u,c,p))}function Ou(e,c,u){return c.x<=Math.max(e.x,u.x)&&c.x>=Math.min(e.x,u.x)&&c.y<=Math.max(e.y,u.y)&&c.y>=Math.min(e.y,u.y)}function ju(e){return e>0?1:e<0?-1:0}function Nu(e,c){return Ru(e.prev,e,e.next)<0?Ru(e,c,e.next)>=0&&Ru(e,e.prev,c)>=0:Ru(e,c,e.prev)<0||Ru(e,e.next,c)<0}function Gu(e,c){const u=Zu(e.i,e.x,e.y),p=Zu(c.i,c.x,c.y),f=e.next,m=c.prev;return e.next=c,c.prev=e,u.next=f,f.prev=u,p.next=u,u.prev=p,m.next=p,p.prev=m,p}function Uu(e,c,u,p){const f=Zu(e,c,u);return p?(f.next=p.next,f.prev=p,p.next.prev=f,p.next=f):(f.prev=f,f.next=f),f}function qu(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Zu(e,c,u){return{i:e,x:c,y:u,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class fu{constructor(e,c){if(c>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=c}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||c>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const u=0|Math.round(e),p=0|Math.round(c),f=this._getKey(u,p);if(this._vertexDictionary.has(f))return this._vertexDictionary.get(f);const m=this._vertexBuffer.length/2;return this._vertexDictionary.set(f,m),this._vertexBuffer.push(u,p),m}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,c){const u=[];for(let p=0;p0?(u.push(f),u.push(g),u.push(m)):(u.push(f),u.push(m),u.push(g))}return u}(this._vertexBuffer,e);const c=[],u=e.length;for(let p=0;p=1||O<=0)||R&&(yf)){b>=p&&b<=f&&m.push(u[(e+1)%3]);continue}!R&&B>0&&m.push(this._vertexToIndex(g+P*B,y+I*B));const V=g+P*Math.max(B,0),j=g+P*Math.min(O,1);C||this._generateIntraEdgeVertices(m,g,y,x,b,V,j),!R&&O<1&&m.push(this._vertexToIndex(g+P*O,y+I*O)),(R||b>=p&&b<=f)&&m.push(u[(e+1)%3]),!R&&(b<=p||b>=f)&&this._generateInterEdgeVertices(m,g,y,x,b,T,S,j,p,f)}return m}_generateIntraEdgeVertices(e,c,u,p,f,m,g){const y=p-c,x=f-u,b=0===x,T=b?Math.min(c,p):Math.min(m,g),S=b?Math.max(c,p):Math.max(m,g),P=Math.floor(T/this._granularityCellSize)+1,I=Math.ceil(S/this._granularityCellSize)-1;if(b?c=P;p--){const f=p*this._granularityCellSize;e.push(this._vertexToIndex(f,u+x*(f-c)/y))}}_generateInterEdgeVertices(e,c,u,p,f,m,g,y,x,b){const T=f-u,S=m-p,P=g-f,I=(x-f)/P,C=(b-f)/P,R=Math.min(I,C),F=Math.max(I,C),L=p+S*R;let B=Math.floor(Math.min(L,y)/this._granularityCellSize)+1,O=Math.ceil(Math.max(L,y)/this._granularityCellSize)-1,V=y=1||F<=0){const e=u-g,p=m+(c-m)*Math.min((x-g)/e,(b-g)/e);B=Math.floor(Math.min(p,y)/this._granularityCellSize)+1,O=Math.ceil(Math.max(p,y)/this._granularityCellSize)-1,V=y0?b:x;if(V)for(let c=B;c<=O;c++)e.push(this._vertexToIndex(c*this._granularityCellSize,G));else for(let c=O;c>=B;c--)e.push(this._vertexToIndex(c*this._granularityCellSize,G))}_generateOutline(e){const c=[];for(const u of e){const e=Ku(u,this._granularity,!0),p=this._pointArrayToIndices(e),f=[];for(let e=1;ef!=(m===Wu)?(e.push(c),e.push(u),e.push(this._vertexToIndex(p,m)),e.push(u),e.push(this._vertexToIndex(f,m)),e.push(this._vertexToIndex(p,m))):(e.push(u),e.push(c),e.push(this._vertexToIndex(p,m)),e.push(this._vertexToIndex(f,m)),e.push(u),e.push(this._vertexToIndex(p,m)))}_fillPoles(e,c,u){const p=this._vertexBuffer,f=se,m=e.length;for(let g=2;g80*u){y=e[0],x=e[1];let c=y,p=x;for(let m=u;mc&&(c=u),f>p&&(p=f)}b=Math.max(c-y,p-x),b=0!==b?32767/b:0}return yu(m,g,u,y,x,b,0),g}(u,p),c=this._convertIndices(u,e);f=this._subdivideTrianglesScanline(c)}catch(e){console.error(e)}let m=[];return c&&(m=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(f),{verticesFlattened:this._vertexBuffer,indicesTriangles:f,indicesLineList:m}}_convertIndices(e,c){const u=[];for(let p=0;p0?(Math.floor(B/y)+1)*y:(Math.ceil(B/y)-1)*y,c=R>0?(Math.floor(O/y)+1)*y:(Math.ceil(O/y)-1)*y,u=Math.abs(B-e),f=Math.abs(O-c),m=Math.abs(B-T),g=Math.abs(O-S),b=P?u/F:Number.POSITIVE_INFINITY,V=I?f/L:Number.POSITIVE_INFINITY;if((m<=u||!P)&&(g<=f||!I))break;if(b=0?g-1:m-1,f=(y+1)%m,x=e[2*c[p]],b=e[2*c[f]],T=e[2*c[g]],S=e[2*c[g]+1],P=e[2*c[y]+1];let I=!1;if(xb)I=!1;else{const u=P-S,m=-(e[2*c[y]]-T),g=S((b-T)*u+(e[2*c[f]+1]-S)*m)*g&&(I=!0)}if(I){const e=c[p],f=c[g],x=c[y];e!==f&&e!==x&&f!==x&&u.push(x,f,e),g--,g<0&&(g=m-1)}else{const e=c[f],p=c[g],x=c[y];e!==p&&e!==x&&p!==x&&u.push(x,p,e),y++,y>=m&&(y=0)}if(p===f)break}}function Qu(e,c,u,p,f,m,g,y,x){const b=f.length/2,T=g&&y&&x;if(bio.MAX_VERTEX_ARRAY_LENGTH&&(b=e.createNewSegment(c,u),x=y.count,R=!0,F=!0,L=!0,T=0);const B=ed(g,p,m,y,P,R,b),O=ed(g,p,m,y,I,F,b),V=ed(g,p,m,y,C,L,b);u.emplaceBack(T+B-x,T+O-x,T+V-x),b.primitiveLength++}}(c,u,p,f,m,e),T&&function(e,c,u,p,f,m){const g=[];for(let e=0;eio.MAX_VERTEX_ARRAY_LENGTH&&(b=e.createNewSegment(c,u),x=y.count,C=!0,R=!0,T=0);const F=ed(g,p,m,y,f,C,b),L=ed(g,p,m,y,S,R,b);u.emplaceBack(T+F-x,T+L-x),b.primitiveLength++}}}(g,u,y,f,x,e),c.forceNewSegmentOnNextPrepare(),null==g||g.forceNewSegmentOnNextPrepare()}function ed(e,c,u,p,f,m,g){if(m){const m=p.count;return u(c[2*f],c[2*f+1]),e[f]=p.count,p.count++,g.vertexLength++,m}return e[f]}class Su{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new ja,this.indexArray=new to,this.indexArray2=new eo,this.programConfigurations=new Vo(e.layers,e.zoom),this.segments=new io,this.segments2=new io,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,c,u){this.hasDependencies=uu("fill",this.layers,c);const p=this.layers[0].layout.get("fill-sort-key"),f=!p.isConstant(),m=[];for(const{feature:g,id:y,index:x,sourceLayerIndex:b}of e){const e=this.layers[0]._featureFilter.needGeometry,T=th(g,e);if(!this.layers[0]._featureFilter.filter(new zs(this.zoom),T,u))continue;const S=f?p.evaluate(T,{},u,c.availableImages):void 0,P={id:y,properties:g.properties,type:g.type,sourceLayerIndex:b,index:x,geometry:e?T.geometry:eh(g),patterns:{},sortKey:S};m.push(P)}f&&m.sort(((e,c)=>e.sortKey-c.sortKey));for(const p of m){const{geometry:f,index:m,sourceLayerIndex:g}=p;if(this.hasDependencies){const e=pu("fill",this.layers,p,{zoom:this.zoom},c);this.patternFeatures.push(e)}else this.addFeature(p,f,m,u,{},c.subdivisionGranularity);c.featureIndex.insert(e[m].feature,f,m,g,this.index)}}update(e,c,u){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,c,this.stateDependentLayers,{imagePositions:u})}addFeatures(e,c,u){for(const p of this.patternFeatures)this.addFeature(p,p.geometry,p.index,c,u,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,hu),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,c,u,p,f,m){for(const e of Mn(c,500)){const c=Xu(e,p,m.fill.getGranularityForZoomLevel(p.z)),u=this.layoutVertexArray;Qu(((e,c)=>{u.emplaceBack(e,c)}),this.segments,this.layoutVertexArray,this.indexArray,c.verticesFlattened,c.indicesTriangles,this.segments2,this.indexArray2,c.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,u,{imagePositions:f,canonical:p})}}let td,id;Jl("FillBucket",Su,{omit:["layers","patternFeatures"]});var rd={get paint(){return id=id||new Hs({"fill-antialias":new qs(Et.paint_fill["fill-antialias"]),"fill-opacity":new Gs(Et.paint_fill["fill-opacity"]),"fill-color":new Gs(Et.paint_fill["fill-color"]),"fill-outline-color":new Gs(Et.paint_fill["fill-outline-color"]),"fill-translate":new qs(Et.paint_fill["fill-translate"]),"fill-translate-anchor":new qs(Et.paint_fill["fill-translate-anchor"]),"fill-pattern":new Xs(Et.paint_fill["fill-pattern"])})},get layout(){return td=td||new Hs({"fill-sort-key":new Gs(Et.layout_fill["fill-sort-key"])})}};class Iu extends Ks{constructor(e,c){super(e,rd,c)}recalculate(e,c){super.recalculate(e,c);const u=this.paint._values["fill-outline-color"];"constant"===u.value.kind&&void 0===u.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new Su(e)}queryRadius(){return xh(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:c,transform:u,pixelsToTileUnits:p}){return oh(wh(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-u.bearingInRadians,p),c)}isTileClipped(){return!0}}const nd=Ic([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),sd=Ic([{name:"a_centroid",components:2,type:"Int16"}],4),{members:od}=nd;class Du{constructor(e,c,u,p,f){this.properties={},this.extent=u,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=p,this._values=f,e.readFields(ad,this,c)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const c=e.readVarint()+e.pos,u=[];let f,m=1,g=0,y=0,x=0;for(;e.pos>3}if(g--,1===m||2===m)y+=e.readSVarint(),x+=e.readSVarint(),1===m&&(f&&u.push(f),f=[]),f&&f.push(new p(y,x));else{if(7!==m)throw new Error(`unknown command ${m}`);f&&f.push(f[0].clone())}}return f&&u.push(f),u}bbox(){const e=this._pbf;e.pos=this._geometry;const c=e.readVarint()+e.pos;let u=1,p=0,f=0,m=0,g=1/0,y=-1/0,x=1/0,b=-1/0;for(;e.pos>3}if(p--,1===u||2===u)f+=e.readSVarint(),m+=e.readSVarint(),fy&&(y=f),mb&&(b=m);else if(7!==u)throw new Error(`unknown command ${u}`)}return[g,x,y,b]}toGeoJSON(e,c,u){const p=this.extent*Math.pow(2,u),f=this.extent*e,m=this.extent*c,g=this.loadGeometry();function y(e){return[360*(e.x+f)/p-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+m)/p)*Math.PI))-90]}function x(e){return e.map(y)}let b;if(1===this.type){const e=[];for(const c of g)e.push(c[0]);const c=x(e);b=1===e.length?{type:"Point",coordinates:c[0]}:{type:"MultiPoint",coordinates:c}}else if(2===this.type){const e=g.map(x);b=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw new Error("unknown feature type");{const e=ld(g),c=[];for(const u of e)c.push(u.map(x));b=1===c.length?{type:"Polygon",coordinates:c[0]}:{type:"MultiPolygon",coordinates:c}}}const T={type:"Feature",geometry:b,properties:this.properties};return null!=this.id&&(T.id=this.id),T}}function ad(e,c,u){1===e?c.id=u.readVarint():2===e?function(e,c){const u=e.readVarint()+e.pos;for(;e.pos=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const c=this._pbf.readVarint()+this._pbf.pos;return new Du(this._pbf,c,this.extent,this._keys,this._values)}}function ud(e,c,u){15===e?c.version=u.readVarint():1===e?c.name=u.readString():5===e?c.extent=u.readVarint():2===e?c._features.push(u.pos):3===e?c._keys.push(u.readString()):4===e&&c._values.push(function(e){let c=null;const u=e.readVarint()+e.pos;for(;e.pos>3;c=1===u?e.readString():2===u?e.readFloat():3===u?e.readDouble():4===u?e.readVarint64():5===u?e.readVarint():6===u?e.readSVarint():7===u?e.readBoolean():null}if(null==c)throw new Error("unknown feature value");return c}(u))}class Lu{constructor(e,c){this.layers=e.readFields(dd,{},c)}}function dd(e,c,u){if(3===e){const e=new Vu(u,u.readVarint()+u.pos);e.length&&(c[e.name]=e)}}const fd=Math.pow(2,13);function md(e,c,u,p,f,m,g,y){e.emplaceBack(c,u,2*Math.floor(p*fd)+g,f*fd*2,m*fd*2,Math.round(y))}class $u{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new qa,this.centroidVertexArray=new $a,this.indexArray=new to,this.programConfigurations=new Vo(e.layers,e.zoom),this.segments=new io,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,c,u){this.features=[],this.hasDependencies=uu("fill-extrusion",this.layers,c);for(const{feature:p,id:f,index:m,sourceLayerIndex:g}of e){const e=this.layers[0]._featureFilter.needGeometry,y=th(p,e);if(!this.layers[0]._featureFilter.filter(new zs(this.zoom),y,u))continue;const x={id:f,sourceLayerIndex:g,index:m,geometry:e?y.geometry:eh(p),properties:p.properties,type:p.type,patterns:{}};this.hasDependencies?this.features.push(pu("fill-extrusion",this.layers,x,{zoom:this.zoom},c)):this.addFeature(x,x.geometry,m,u,{},c.subdivisionGranularity),c.featureIndex.insert(p,x.geometry,m,g,this.index,!0)}}addFeatures(e,c,u){for(const p of this.features){const{geometry:f}=p;this.addFeature(p,f,p.index,c,u,e.subdivisionGranularity)}}update(e,c,u){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,c,this.stateDependentLayers,{imagePositions:u})}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,od),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,sd.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,c,u,p,f,m){for(const u of Mn(c,500)){const c={x:0,y:0,sampleCount:0},f=this.layoutVertexArray.length;this.processPolygon(c,p,e,u,m);const g=this.layoutVertexArray.length-f,y=Math.floor(c.x/c.sampleCount),x=Math.floor(c.y/c.sampleCount);for(let e=0;e{md(b,e,c,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,x.verticesFlattened,x.indicesTriangles)}_generateSideFaces(e,c){let u=0;for(let p=1;pio.MAX_VERTEX_ARRAY_LENGTH&&(c.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const g=f.sub(m)._perp()._unit(),y=m.dist(f);u+y>32768&&(u=0),md(this.layoutVertexArray,f.x,f.y,g.x,g.y,0,0,u),md(this.layoutVertexArray,f.x,f.y,g.x,g.y,0,1,u),u+=y,md(this.layoutVertexArray,m.x,m.y,g.x,g.y,0,0,u),md(this.layoutVertexArray,m.x,m.y,g.x,g.y,0,1,u);const x=c.segment.vertexLength;this.indexArray.emplaceBack(x,x+2,x+1),this.indexArray.emplaceBack(x+1,x+2,x+3),c.segment.vertexLength+=4,c.segment.primitiveLength+=2}}}function _d(e,c){for(let u=0;use)||e.y===c.y&&(e.y<0||e.y>se)}function yd(e){return e.every((e=>e.x<0))||e.every((e=>e.x>se))||e.every((e=>e.y<0))||e.every((e=>e.y>se))}let xd;Jl("FillExtrusionBucket",$u,{omit:["layers","features"]});var vd={get paint(){return xd=xd||new Hs({"fill-extrusion-opacity":new qs(Et["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Gs(Et["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new qs(Et["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new qs(Et["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Xs(Et["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Gs(Et["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Gs(Et["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new qs(Et["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Yu extends Ks{constructor(e,c){super(e,vd,c)}createBucket(e){return new $u(e)}queryRadius(){return xh(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:c,featureState:u,geometry:f,transform:m,pixelsToTileUnits:g,pixelPosMatrix:y}){const x=wh(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-m.bearingInRadians,g),b=this.paint.get("fill-extrusion-height").evaluate(c,u),T=this.paint.get("fill-extrusion-base").evaluate(c,u),S=function(e,c){const u=[];for(const f of e){const e=[f.x,f.y,0,1];Z(e,e,c),u.push(new p(e[0]/e[3],e[1]/e[3]))}return u}(x,y),P=function(e,c,u,f){const m=[],g=[],y=f[8]*c,x=f[9]*c,b=f[10]*c,T=f[11]*c,S=f[8]*u,P=f[9]*u,I=f[10]*u,C=f[11]*u;for(const c of e){const e=[],u=[];for(const m of c){const c=m.x,g=m.y,R=f[0]*c+f[4]*g+f[12],F=f[1]*c+f[5]*g+f[13],L=f[2]*c+f[6]*g+f[14],B=f[3]*c+f[7]*g+f[15],O=L+b,V=B+T,j=R+S,G=F+P,U=L+I,q=B+C,Z=new p((R+y)/V,(F+x)/V);Z.z=O/V,e.push(Z);const W=new p(j/q,G/q);W.z=U/q,u.push(W)}m.push(e),g.push(u)}return[m,g]}(f,T,b,y);return function(e,c,u){let p=1/0;oh(u,c)&&(p=wd(u,c[0]));for(let f=0;fe.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={}})),this.layoutVertexArray=new Ga,this.layoutVertexArray2=new Xa,this.indexArray=new to,this.programConfigurations=new Vo(e.layers,e.zoom),this.segments=new io,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,c,u){this.hasDependencies=uu("line",this.layers,c)||this.hasLineDasharray(this.layers);const p=this.layers[0].layout.get("line-sort-key"),f=!p.isConstant(),m=[];for(const{feature:c,id:g,index:y,sourceLayerIndex:x}of e){const e=this.layers[0]._featureFilter.needGeometry,b=th(c,e);if(!this.layers[0]._featureFilter.filter(new zs(this.zoom),b,u))continue;const T=f?p.evaluate(b,{},u):void 0,S={id:g,properties:c.properties,type:c.type,sourceLayerIndex:x,index:y,geometry:e?b.geometry:eh(c),patterns:{},dashes:{},sortKey:T};m.push(S)}f&&m.sort(((e,c)=>e.sortKey-c.sortKey));for(const p of m){const{geometry:f,index:m,sourceLayerIndex:g}=p;this.hasDependencies?(uu("line",this.layers,c)?pu("line",this.layers,p,{zoom:this.zoom},c):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,p,this.zoom,c),this.patternFeatures.push(p)):this.addFeature(p,f,m,u,{},{},c.subdivisionGranularity),c.featureIndex.insert(e[m].feature,f,m,g,this.index)}}update(e,c,u,p){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,c,this.stateDependentLayers,{imagePositions:u,dashPositions:p})}addFeatures(e,c,u,p){for(const f of this.patternFeatures)this.addFeature(f,f.geometry,f.index,c,u,p,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Id)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Sd),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,c,u,p,f,m,g){const y=this.layers[0].layout,x=y.get("line-join").evaluate(e,{}),b=y.get("line-cap"),T=y.get("line-miter-limit"),S=y.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const u of c)this.addLine(u,e,x,b,T,S,p,g);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,u,{imagePositions:f,dashPositions:m,canonical:p})}addLine(e,c,u,p,f,m,g,y){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Ku(e,g?y.line.getGranularityForZoomLevel(g.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let c=0;c=2&&e[b-1].equals(e[b-2]);)b--;let T=0;for(;T0;if(j&&c>T){const e=I.dist(C);if(e>2*S){const c=I.sub(I.sub(C)._mult(S/e)._round());this.updateDistance(C,c),this.addCurrentVertex(c,F,0,0,P),C=c}}const U=C&&R;let q=U?u:x?"butt":p;if(U&&"round"===q&&(Of&&(q="bevel"),"bevel"===q&&(O>2&&(q="flipbevel"),O100)g=L.mult(-1);else{const e=O*F.add(L).mag()/F.sub(L).mag();g._perp()._mult(e*(G?-1:1))}this.addCurrentVertex(I,g,0,0,P),this.addCurrentVertex(I,g.mult(-1),0,0,P)}else if("bevel"===q||"fakeround"===q){const e=-Math.sqrt(O*O-1),c=G?e:0,u=G?0:e;if(C&&this.addCurrentVertex(I,F,c,u,P),"fakeround"===q){const e=Math.round(180*V/Math.PI/20);for(let c=1;c2*S){const c=I.add(R.sub(I)._mult(S/e)._round());this.updateDistance(I,c),this.addCurrentVertex(c,L,0,0,P),I=c}}}}addCurrentVertex(e,c,u,p,f,m=!1){const g=c.y*p-c.x,y=-c.y-c.x*p;this.addHalfVertex(e,c.x+c.y*u,c.y-c.x*u,m,!1,u,f),this.addHalfVertex(e,g,y,m,!0,-p,f),this.distance>Cd/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,c,u,p,f,m))}addHalfVertex({x:e,y:c},u,p,f,m,g,y){const x=.5*(this.lineClips?this.scaledDistance*(Cd-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(f?1:0),(c<<1)+(m?1:0),Math.round(63*u)+128,Math.round(63*p)+128,1+(0===g?0:g<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);const b=y.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,b,this.e2),y.primitiveLength++),m?this.e2=b:this.e1=b}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,c){this.distance+=e.dist(c),this.updateScaledDistance()}hasLineDasharray(e){for(const c of e){const e=c.paint.get("line-dasharray");if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,c,u,p){for(const f of e){const e=f.paint.get("line-dasharray");if(!e||"constant"===e.value.kind)continue;const m="round"===f.layout.get("line-cap"),g={dasharray:e.value.evaluate({zoom:u-1},c,{}),round:m},y={dasharray:e.value.evaluate({zoom:u},c,{}),round:m},x={dasharray:e.value.evaluate({zoom:u+1},c,{}),round:m},b=`${g.dasharray.join(",")},${g.round}`,T=`${y.dasharray.join(",")},${y.round}`,S=`${x.dasharray.join(",")},${x.round}`;p.dashDependencies[b]=g,p.dashDependencies[T]=y,p.dashDependencies[S]=x,c.dashes[f.id]={min:b,mid:T,max:S}}}}let Ad,Dd;Jl("LineBucket",rc,{omit:["layers","patternFeatures"]});var zd={get paint(){return Dd=Dd||new Hs({"line-opacity":new Gs(Et.paint_line["line-opacity"]),"line-color":new Gs(Et.paint_line["line-color"]),"line-translate":new qs(Et.paint_line["line-translate"]),"line-translate-anchor":new qs(Et.paint_line["line-translate-anchor"]),"line-width":new Gs(Et.paint_line["line-width"]),"line-gap-width":new Gs(Et.paint_line["line-gap-width"]),"line-offset":new Gs(Et.paint_line["line-offset"]),"line-blur":new Gs(Et.paint_line["line-blur"]),"line-dasharray":new Xs(Et.paint_line["line-dasharray"]),"line-pattern":new Xs(Et.paint_line["line-pattern"]),"line-gradient":new Zs(Et.paint_line["line-gradient"])})},get layout(){return Ad=Ad||new Hs({"line-cap":new qs(Et.layout_line["line-cap"]),"line-join":new Gs(Et.layout_line["line-join"]),"line-miter-limit":new qs(Et.layout_line["line-miter-limit"]),"line-round-limit":new qs(Et.layout_line["line-round-limit"]),"line-sort-key":new Gs(Et.layout_line["line-sort-key"])})}};class ac extends Gs{possiblyEvaluate(e,c){return c=new zs(Math.floor(c.zoom),{now:c.now,fadeDuration:c.fadeDuration,zoomHistory:c.zoomHistory,transition:c.transition}),super.possiblyEvaluate(e,c)}evaluate(e,c,u,p){return c=xe({},c,{zoom:Math.floor(c.zoom)}),super.evaluate(e,c,u,p)}}let kd;class lc extends Ks{constructor(e,c){super(e,zd,c),this.gradientVersion=0,kd||(kd=new ac(zd.paint.properties["line-width"].specification),kd.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this.gradientExpression();this.stepInterpolant=!!function(e){return void 0!==e._styleExpression}(e)&&e._styleExpression.expression instanceof or,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,c){super.recalculate(e,c),this.paint._values["line-floorwidth"]=kd.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new rc(e)}queryRadius(e){const c=e,u=Rd(gh("line-width",this,c),gh("line-gap-width",this,c)),p=gh("line-offset",this,c);return u/2+Math.abs(p)+xh(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:c,featureState:u,geometry:f,transform:m,pixelsToTileUnits:g}){const y=wh(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-m.bearingInRadians,g),x=g/2*Rd(this.paint.get("line-width").evaluate(c,u),this.paint.get("line-gap-width").evaluate(c,u)),b=this.paint.get("line-offset").evaluate(c,u);return b&&(f=function(e,c){const u=[];for(let f=0;f=3)for(let c=0;c0?c+2*e:e}const Fd=Ic([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Ld=Ic([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ic([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Bd=Ic([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Ic([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Od=Ic([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Vd=Ic([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function jd(e,c,u){return e.sections.forEach((e=>{e.text=function(e,c,u){const p=c.layout.get("text-transform").evaluate(u,{});return"uppercase"===p?e=e.toLocaleUpperCase():"lowercase"===p&&(e=e.toLocaleLowerCase()),vc.applyArabicShaping&&(e=vc.applyArabicShaping(e)),e}(e.text,c,u)})),e}Ic([{name:"triangle",components:3,type:"Uint16"}]),Ic([{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"}]),Ic([{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"}]),Ic([{type:"Float32",name:"offsetX"}]),Ic([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Ic([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var Nd=24;const Gd={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},Ud={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},qd={40:!0};function $d(e,c,u,p,f,m){if("fontStack"in c){const p=u[c.fontStack],m=p&&p[e];return m?m.metrics.advance*c.scale+f:0}{const e=p[c.imageName];return e?e.displaySize[0]*c.scale*Nd/m+f:0}}function Zd(e,c,u,p){const f=Math.pow(e-c,2);return p?eMath.max(e,this.sections[c].scale)),0)}getMaxImageSize(e){let c=0,u=0;for(let p=0;pu)))}addImageSection(e){const c=e.image?e.image.name:"";if(0===c.length)return void Ee("Can't add FormattedSection with an empty image.");const u=this.getNextImageSectionCharCode();u?(this.text+=String.fromCharCode(u),this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName:c}),this.sectionIndex.push(this.sections.length-1)):Ee("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,c,u,p,f){const m=[],g=this.determineAverageLineWidth(e,c,u,p,f),y=this.hasZeroWidthSpaces();let x=0,b=0;const T=this.text[Symbol.iterator]();let S=T.next();const P=this.text[Symbol.iterator]();P.next();let I=P.next();const C=this.text[Symbol.iterator]();C.next(),C.next();let R=C.next();for(;!S.done;){const c=this.getSection(b),F=S.value.codePointAt(0);if(cc(F)||(x+=$d(F,c,u,p,e,f)),!I.done){const e=sc(F),u=I.value.codePointAt(0);(Ud[F]||e||"imageName"in c||!R.done&&qd[u])&&m.push(Hd(b+1,x,g,m,Wd(F,u,e&&y),!1))}b++,S=T.next(),I=P.next(),R=C.next()}return Xd(Hd(this.length(),x,g,m,0,!0))}determineAverageLineWidth(e,c,u,p,f){let m=0,g=0;for(const c of this.text){const y=this.getSection(g);m+=$d(c.codePointAt(0),y,u,p,e,f),g++}return m/Math.max(1,Math.ceil(m/c))}}const Yd=4294967296,Kd=1/Yd,Jd="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class Ec{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,c,u=this.length){for(;this.pos>3,f=this.pos;this.type=7&u,e(p,c,this),this.pos===f&&this.skip(u)}return c}readMessage(e,c){return this.readFields(e,c,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Yd;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Yd;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const c=this.buf;let u,p;return p=c[this.pos++],u=127&p,p<128?u:(p=c[this.pos++],u|=(127&p)<<7,p<128?u:(p=c[this.pos++],u|=(127&p)<<14,p<128?u:(p=c[this.pos++],u|=(127&p)<<21,p<128?u:(p=c[this.pos],u|=(15&p)<<28,function(e,c,u){const p=u.buf;let f,m;if(m=p[u.pos++],f=(112&m)>>4,m<128)return Qd(e,f,c);if(m=p[u.pos++],f|=(127&m)<<3,m<128)return Qd(e,f,c);if(m=p[u.pos++],f|=(127&m)<<10,m<128)return Qd(e,f,c);if(m=p[u.pos++],f|=(127&m)<<17,m<128)return Qd(e,f,c);if(m=p[u.pos++],f|=(127&m)<<24,m<128)return Qd(e,f,c);if(m=p[u.pos++],f|=(1&m)<<31,m<128)return Qd(e,f,c);throw new Error("Expected varint not more than 10 bytes")}(u,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,c=this.pos;return this.pos=e,e-c>=12&&Jd?Jd.decode(this.buf.subarray(c,e)):function(e,c,u){let p="",f=c;for(;f239?4:c>223?3:c>191?2:1;if(f+b>u)break;1===b?c<128&&(x=c):2===b?(m=e[f+1],128==(192&m)&&(x=(31&c)<<6|63&m,x<=127&&(x=null))):3===b?(m=e[f+1],g=e[f+2],128==(192&m)&&128==(192&g)&&(x=(15&c)<<12|(63&m)<<6|63&g,(x<=2047||x>=55296&&x<=57343)&&(x=null))):4===b&&(m=e[f+1],g=e[f+2],y=e[f+3],128==(192&m)&&128==(192&g)&&128==(192&y)&&(x=(15&c)<<18|(63&m)<<12|(63&g)<<6|63&y,(x<=65535||x>=1114112)&&(x=null))),null===x?(x=65533,b=1):x>65535&&(x-=65536,p+=String.fromCharCode(x>>>10&1023|55296),x=56320|1023&x),p+=String.fromCharCode(x),f+=b}return p}(this.buf,c,e)}readBytes(){const e=this.readVarint()+this.pos,c=this.buf.subarray(this.pos,e);return this.pos=e,c}readPackedVarint(e=[],c){const u=this.readPackedEnd();for(;this.pos127;);else if(2===c)this.pos=this.readVarint()+this.pos;else if(5===c)this.pos+=4;else{if(1!==c)throw new Error(`Unimplemented type: ${c}`);this.pos+=8}}writeTag(e,c){this.writeVarint(e<<3|c)}realloc(e){let c=this.length||16;for(;c268435455||e<0?function(e,c){let u,p;if(e>=0?(u=e%4294967296|0,p=e/4294967296|0):(u=~(-e%4294967296),p=~(-e/4294967296),4294967295^u?u=u+1|0:(u=0,p=p+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");c.realloc(10),function(e,c,u){u.buf[u.pos++]=127&e|128,e>>>=7,u.buf[u.pos++]=127&e|128,e>>>=7,u.buf[u.pos++]=127&e|128,e>>>=7,u.buf[u.pos++]=127&e|128,u.buf[u.pos]=127&(e>>>=7)}(u,0,c),function(e,c){const u=(7&e)<<4;c.buf[c.pos++]|=u|((e>>>=3)?128:0),e&&(c.buf[c.pos++]=127&e|((e>>>=7)?128:0),e&&(c.buf[c.pos++]=127&e|((e>>>=7)?128:0),e&&(c.buf[c.pos++]=127&e|((e>>>=7)?128:0),e&&(c.buf[c.pos++]=127&e|((e>>>=7)?128:0),e&&(c.buf[c.pos++]=127&e)))))}(p,c)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const c=this.pos;this.pos=function(e,c,u){for(let p,f,m=0;m55295&&p<57344){if(!f){p>56319||m+1===c.length?(e[u++]=239,e[u++]=191,e[u++]=189):f=p;continue}if(p<56320){e[u++]=239,e[u++]=191,e[u++]=189,f=p;continue}p=f-55296<<10|p-56320|65536,f=null}else f&&(e[u++]=239,e[u++]=191,e[u++]=189,f=null);p<128?e[u++]=p:(p<2048?e[u++]=p>>6|192:(p<65536?e[u++]=p>>12|224:(e[u++]=p>>18|240,e[u++]=p>>12&63|128),e[u++]=p>>6&63|128),e[u++]=63&p|128)}return u}(this.buf,e,this.pos);const u=this.pos-c;u>=128&&ip(c,u,this),this.pos=c-1,this.writeVarint(u),this.pos+=u}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const c=e.length;this.writeVarint(c),this.realloc(c);for(let u=0;u=128&&ip(u,p,this),this.pos=u-1,this.writeVarint(p),this.pos+=p}writeMessage(e,c,u){this.writeTag(e,2),this.writeRawMessage(c,u)}writePackedVarint(e,c){c.length&&this.writeMessage(e,sp,c)}writePackedSVarint(e,c){c.length&&this.writeMessage(e,op,c)}writePackedBoolean(e,c){c.length&&this.writeMessage(e,cp,c)}writePackedFloat(e,c){c.length&&this.writeMessage(e,ap,c)}writePackedDouble(e,c){c.length&&this.writeMessage(e,lp,c)}writePackedFixed32(e,c){c.length&&this.writeMessage(e,hp,c)}writePackedSFixed32(e,c){c.length&&this.writeMessage(e,up,c)}writePackedFixed64(e,c){c.length&&this.writeMessage(e,dp,c)}writePackedSFixed64(e,c){c.length&&this.writeMessage(e,pp,c)}writeBytesField(e,c){this.writeTag(e,2),this.writeBytes(c)}writeFixed32Field(e,c){this.writeTag(e,5),this.writeFixed32(c)}writeSFixed32Field(e,c){this.writeTag(e,5),this.writeSFixed32(c)}writeFixed64Field(e,c){this.writeTag(e,1),this.writeFixed64(c)}writeSFixed64Field(e,c){this.writeTag(e,1),this.writeSFixed64(c)}writeVarintField(e,c){this.writeTag(e,0),this.writeVarint(c)}writeSVarintField(e,c){this.writeTag(e,0),this.writeSVarint(c)}writeStringField(e,c){this.writeTag(e,2),this.writeString(c)}writeFloatField(e,c){this.writeTag(e,5),this.writeFloat(c)}writeDoubleField(e,c){this.writeTag(e,1),this.writeDouble(c)}writeBooleanField(e,c){this.writeVarintField(e,+c)}}function Qd(e,c,u){return u?4294967296*c+(e>>>0):4294967296*(c>>>0)+(e>>>0)}function ip(e,c,u){const p=c<=16383?1:c<=2097151?2:c<=268435455?3:Math.floor(Math.log(c)/(7*Math.LN2));u.realloc(p);for(let c=u.pos-1;c>=e;c--)u.buf[c+p]=u.buf[c]}function sp(e,c){for(let u=0;uc.h-e.h));const p=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(c/.95)),u),h:1/0}];let f=0,m=0;for(const c of e)for(let e=p.length-1;e>=0;e--){const u=p[e];if(!(c.w>u.w||c.h>u.h)){if(c.x=u.x,c.y=u.y,m=Math.max(m,c.y+c.h),f=Math.max(f,c.x+c.w),c.w===u.w&&c.h===u.h){const c=p.pop();c&&eF.toCodeUnitIndex(e)));const e=O(F.toString(),B);for(const c of e){const e=[...c].map((()=>0));L.push(new kc(c,F.sections,e))}}else if(V){L=[],B=B.map((e=>F.toCodeUnitIndex(e)));let e=0;const c=[];for(const u of F.text)c.push(...Array(u.length).fill(F.sectionIndex[e])),e++;const u=V(F.text,c,B);for(const e of u){const c=[];let u="";for(const p of e[0])c.push(e[1][u.length]),u+=p;L.push(new kc(e[0],F.sections,c))}}else L=function(e,c){const u=[];let p=0;for(const f of c)u.push(e.substring(p,f)),p=f;return pb){const e=Math.ceil(m/b);f*=e/g,g=e}return{x1:p,y1:f,x2:p+m,y2:f+g}}function Ap(e,c,u,p,f,m){const g=e.image;let y;if(g.content){const e=g.content,c=g.pixelRatio||1;y=[e[0]/c,e[1]/c,g.displaySize[0]-e[2]/c,g.displaySize[1]-e[3]/c]}const x=c.left*m,b=c.right*m;let T,S,P,I;"width"===u||"both"===u?(I=f[0]+x-p[3],S=f[0]+b+p[1]):(I=f[0]+(x+b-g.displaySize[0])/2,S=I+g.displaySize[0]);const C=c.top*m,R=c.bottom*m;return"height"===u||"both"===u?(T=f[1]+C-p[0],P=f[1]+R+p[2]):(T=f[1]+(C+R-g.displaySize[1])/2,P=T+g.displaySize[1]),{image:g,top:T,right:S,bottom:P,left:I,collisionPadding:y}}Jl("ImagePosition",Gc),Jl("ImageAtlas",Xc),c.az=void 0,(yp=c.az||(c.az={}))[yp.none=0]="none",yp[yp.horizontal=1]="horizontal",yp[yp.vertical=2]="vertical",yp[yp.horizontalOnly=3]="horizontalOnly";const Dp=128,zp=32640;function Fp(e,c){const{expression:u}=c;if("constant"===u.kind)return{kind:"constant",layoutSize:u.evaluate(new zs(e+1))};if("source"===u.kind)return{kind:"source"};{const{zoomStops:c,interpolationType:p}=u;let f=0;for(;fe.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const u=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fp(this.zoom,u["text-size"]),this.iconSizeData=Fp(this.zoom,u["icon-size"]);const p=this.layers[0].layout,f=p.get("symbol-sort-key"),m=p.get("symbol-z-order");this.canOverlap="never"!==Lp(p,"text-overlap","text-allow-overlap")||"never"!==Lp(p,"icon-overlap","icon-allow-overlap")||p.get("text-ignore-placement")||p.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==m&&!f.isConstant(),this.sortFeaturesByY=("viewport-y"===m||"auto"===m&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===p.get("symbol-placement")&&(this.writingModes=p.get("text-writing-mode").map((e=>c.az[e]))),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=e.sourceID}createArrays(){this.text=new fh(new Vo(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new fh(new Vo(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new Va,this.lineVertexArray=new Ca,this.symbolInstances=new Ba,this.textAnchorOffsets=new Oa}calculateGlyphDependencies(e,c,u,p,f){for(const m of e)if(c[m.codePointAt(0)]=!0,(u||p)&&f){const e=Gd[m];e&&(c[e.codePointAt(0)]=!0)}}populate(e,u,p){const f=this.layers[0],m=f.layout,g=m.get("text-font"),y=m.get("text-field"),x=m.get("icon-image"),b=("constant"!==y.value.kind||y.value.value instanceof De&&!y.value.value.isEmpty()||y.value.value.toString().length>0)&&("constant"!==g.value.kind||g.value.value.length>0),T="constant"!==x.value.kind||!!x.value.value||Object.keys(x.parameters).length>0,S=m.get("symbol-sort-key");if(this.features=[],!b&&!T)return;const P=u.iconDependencies,I=u.glyphDependencies,C=u.availableImages,R=new zs(this.zoom);for(const{feature:u,id:y,index:x,sourceLayerIndex:F}of e){const e=f._featureFilter.needGeometry,L=th(u,e);if(!f._featureFilter.filter(R,L,p))continue;let B,O;if(e||(L.geometry=eh(u)),b){const e=f.getValueAndResolveTokens("text-field",L,p,C),c=De.factory(e),u=this.hasRTLText=this.hasRTLText||Up(c);(!u||"unavailable"===vc.getRTLTextPluginStatus()||u&&vc.isParsed())&&(B=jd(c,f,L))}if(T){const e=f.getValueAndResolveTokens("icon-image",L,p,C);O=e instanceof Oe?e:Oe.fromString(e)}if(!B&&!O)continue;const V=this.sortFeaturesByKey?S.evaluate(L,{},p):void 0;if(this.features.push({id:y,text:B,icon:O,index:x,sourceLayerIndex:F,geometry:L.geometry,properties:u.properties,type:Du.types[u.type],sortKey:V}),O&&(P[O.name]=!0),B){const e=g.evaluate(L,{},p).join(","),u="viewport"!==m.get("text-rotation-alignment")&&"point"!==m.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(c.az.vertical)>=0;for(const c of B.sections)if(c.image)P[c.image.name]=!0;else{const p=hc(B.toString()),f=c.fontStack||e,m=I[f]=I[f]||{};this.calculateGlyphDependencies(c.text,m,u,this.allowVerticalPlacement,p)}}}"line"===m.get("symbol-placement")&&(this.features=function(e){const c={},u={},p=[];let f=0;function m(c){p.push(e[c]),f++}function g(e,c,f){const m=u[e];return delete u[e],u[c]=m,p[m].geometry[0].pop(),p[m].geometry[0]=p[m].geometry[0].concat(f[0]),m}function y(e,u,f){const m=c[u];return delete c[u],c[e]=m,p[m].geometry[0].shift(),p[m].geometry[0]=f[0].concat(p[m].geometry[0]),m}function x(e,c,u){const p=u?c[0][c[0].length-1]:c[0][0];return`${e}:${p.x}:${p.y}`}for(let b=0;be.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,c)=>e.sortKey-c.sortKey))}update(e,c,u){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,c,this.layers,{imagePositions:u}),this.icon.programConfigurations.updatePaintArrays(e,c,this.layers,{imagePositions:u}))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,c){const u=this.lineVertexArray.length;if(void 0!==e.segment){let u=e.dist(c[e.segment+1]),p=e.dist(c[e.segment]);const f={};for(let p=e.segment+1;p=0;u--)f[u]={x:c[u].x,y:c[u].y,tileUnitDistanceFromAnchor:p},u>0&&(p+=c[u-1].dist(c[u]));for(let e=0;e0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,c){const u=e.placedSymbolArray.get(c),p=u.vertexStartIndex+4*u.numGlyphs;for(let c=u.vertexStartIndex;cp[e]-p[c]||f[c]-f[e])),m}addToSortKeyRanges(e,c){const u=this.sortKeyRanges[this.sortKeyRanges.length-1];u&&u.sortKey===c?u.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:c,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const c=this.symbolInstances.get(e);this.featureSortOrder.push(c.featureIndex),[c.rightJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.leftJustifiedTextSymbolIndex].forEach(((e,c,u)=>{e>=0&&u.indexOf(e)===c&&this.addIndicesForPlacedSymbol(this.text,e)})),c.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,c.verticalPlacedTextSymbolIndex),c.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,c.placedIconSymbolIndex),c.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,c.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let qp,$p;Jl("SymbolBucket",yh,{omit:["layers","collisionBoxArray","features","compareText"]}),yh.MAX_GLYPHS=65535,yh.addDynamicAttributes=Gp;var Zp={get paint(){return $p=$p||new Hs({"icon-opacity":new Gs(Et.paint_symbol["icon-opacity"]),"icon-color":new Gs(Et.paint_symbol["icon-color"]),"icon-halo-color":new Gs(Et.paint_symbol["icon-halo-color"]),"icon-halo-width":new Gs(Et.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Gs(Et.paint_symbol["icon-halo-blur"]),"icon-translate":new qs(Et.paint_symbol["icon-translate"]),"icon-translate-anchor":new qs(Et.paint_symbol["icon-translate-anchor"]),"text-opacity":new Gs(Et.paint_symbol["text-opacity"]),"text-color":new Gs(Et.paint_symbol["text-color"],{runtimeType:pi,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Gs(Et.paint_symbol["text-halo-color"]),"text-halo-width":new Gs(Et.paint_symbol["text-halo-width"]),"text-halo-blur":new Gs(Et.paint_symbol["text-halo-blur"]),"text-translate":new qs(Et.paint_symbol["text-translate"]),"text-translate-anchor":new qs(Et.paint_symbol["text-translate-anchor"])})},get layout(){return qp=qp||new Hs({"symbol-placement":new qs(Et.layout_symbol["symbol-placement"]),"symbol-spacing":new qs(Et.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new qs(Et.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Gs(Et.layout_symbol["symbol-sort-key"]),"symbol-z-order":new qs(Et.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new qs(Et.layout_symbol["icon-allow-overlap"]),"icon-overlap":new qs(Et.layout_symbol["icon-overlap"]),"icon-ignore-placement":new qs(Et.layout_symbol["icon-ignore-placement"]),"icon-optional":new qs(Et.layout_symbol["icon-optional"]),"icon-rotation-alignment":new qs(Et.layout_symbol["icon-rotation-alignment"]),"icon-size":new Gs(Et.layout_symbol["icon-size"]),"icon-text-fit":new qs(Et.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new qs(Et.layout_symbol["icon-text-fit-padding"]),"icon-image":new Gs(Et.layout_symbol["icon-image"]),"icon-rotate":new Gs(Et.layout_symbol["icon-rotate"]),"icon-padding":new Gs(Et.layout_symbol["icon-padding"]),"icon-keep-upright":new qs(Et.layout_symbol["icon-keep-upright"]),"icon-offset":new Gs(Et.layout_symbol["icon-offset"]),"icon-anchor":new Gs(Et.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new qs(Et.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new qs(Et.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new qs(Et.layout_symbol["text-rotation-alignment"]),"text-field":new Gs(Et.layout_symbol["text-field"]),"text-font":new Gs(Et.layout_symbol["text-font"]),"text-size":new Gs(Et.layout_symbol["text-size"]),"text-max-width":new Gs(Et.layout_symbol["text-max-width"]),"text-line-height":new qs(Et.layout_symbol["text-line-height"]),"text-letter-spacing":new Gs(Et.layout_symbol["text-letter-spacing"]),"text-justify":new Gs(Et.layout_symbol["text-justify"]),"text-radial-offset":new Gs(Et.layout_symbol["text-radial-offset"]),"text-variable-anchor":new qs(Et.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Gs(Et.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Gs(Et.layout_symbol["text-anchor"]),"text-max-angle":new qs(Et.layout_symbol["text-max-angle"]),"text-writing-mode":new qs(Et.layout_symbol["text-writing-mode"]),"text-rotate":new Gs(Et.layout_symbol["text-rotate"]),"text-padding":new qs(Et.layout_symbol["text-padding"]),"text-keep-upright":new qs(Et.layout_symbol["text-keep-upright"]),"text-transform":new Gs(Et.layout_symbol["text-transform"]),"text-offset":new Gs(Et.layout_symbol["text-offset"]),"text-allow-overlap":new qs(Et.layout_symbol["text-allow-overlap"]),"text-overlap":new qs(Et.layout_symbol["text-overlap"]),"text-ignore-placement":new qs(Et.layout_symbol["text-ignore-placement"]),"text-optional":new qs(Et.layout_symbol["text-optional"])})}};class vh{constructor(e){if(void 0===e.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:li,this.defaultValue=e}evaluate(e){if(e.formattedSection){const c=this.defaultValue.property.overrides;if(c&&c.hasOverride(e.formattedSection))return c.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Jl("FormatSectionOverride",vh,{omit:["defaultValue"]});class bh extends Ks{constructor(e,c){super(e,Zp,c)}recalculate(e,c){if(super.recalculate(e,c),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const e=this.layout.get("text-writing-mode");if(e){const c=[];for(const u of e)c.indexOf(u)<0&&c.push(u);this.layout._values["text-writing-mode"]=c}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,c,u,p){const f=this.layout.get(e).evaluate(c,{},u,p),m=this._unevaluatedLayout._values[e];return m.isDataDriven()||Vs(m.value)||!f?f:function(e,c){return c.replace(/{([^{}]+)}/g,((c,u)=>e&&u in e?String(e[u]):""))}(c.properties,f)}createBucket(e){return new yh(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Zp.paint.overridableProperties){if(!bh.hasPaintOverride(this.layout,e))continue;const c=this.paint.get(e),u=new vh(c),p=new ei(u,c.property.specification);let f=null;f="constant"===c.value.kind||"source"===c.value.kind?new ii("source",p):new si("composite",p,c.value.zoomStops),this.paint._values[e]=new Us(c.property,f,c.parameters)}}_handleOverridablePaintPropertyUpdate(e,c,u){return!(!this.layout||c.isDataDriven()||u.isDataDriven())&&bh.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,c){const u=e.get("text-field"),p=Zp.paint.properties[c];let f=!1;const m=e=>{for(const c of e)if(p.overrides&&p.overrides.hasOverride(c))return void(f=!0)};if("constant"===u.value.kind&&u.value.value instanceof De)m(u.value.value.sections);else if("source"===u.value.kind||"composite"===u.value.kind){const e=c=>{f||(c instanceof qe&&Dr(c.value)===xi?m(c.value.sections):c instanceof Tr?m(c.sections):c.eachChild(e))},c=u.value;c._styleExpression&&e(c._styleExpression.expression)}return f}}let Hp;var Xp={get paint(){return Hp=Hp||new Hs({"background-color":new qs(Et.paint_background["background-color"]),"background-pattern":new Ys(Et.paint_background["background-pattern"]),"background-opacity":new qs(Et.paint_background["background-opacity"])})}};class Sh extends Ks{constructor(e,c){super(e,Xp,c)}}class Ah extends Ks{constructor(e,c){super(e,{},c),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class kh{constructor(e){this._methodToThrottle=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle()}),0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Yp={once:!0},Kp=6371008.8;class Th{constructor(e,c){if(isNaN(e)||isNaN(c))throw new Error(`Invalid LngLat object: (${e}, ${c})`);if(this.lng=+e,this.lat=+c,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Th(ye(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const c=Math.PI/180,u=this.lat*c,p=e.lat*c,f=Math.sin(u)*Math.sin(p)+Math.cos(u)*Math.cos(p)*Math.cos((e.lng-this.lng)*c);return Kp*Math.acos(Math.min(f,1))}static convert(e){if(e instanceof Th)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new Th(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new Th(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const ef=2*Math.PI*Kp;function nf(e){return ef*Math.cos(e*Math.PI/180)}function of(e){return(180+e)/360}function af(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function lf(e,c){return e/nf(c)}function df(e){return 360*e-180}function pf(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function ff(e,c){return e*nf(pf(c))}class Lh{constructor(e,c,u=0){this.x=+e,this.y=+c,this.z=+u}static fromLngLat(e,c=0){const u=Th.convert(e);return new Lh(of(u.lng),af(u.lat),lf(c,u.lat))}toLngLat(){return new Th(df(this.x),pf(this.y))}toAltitude(){return ff(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/ef*(e=pf(this.y),1/Math.cos(e*Math.PI/180));var e}}function _f(e,c,u){var p=2*Math.PI*6378137/256/Math.pow(2,u);return[e*p-2*Math.PI*6378137/2,c*p-2*Math.PI*6378137/2]}class Rh{constructor(e,c,u){if(!function(e,c,u){return!(e<0||e>25||u<0||u>=Math.pow(2,e)||c<0||c>=Math.pow(2,e))}(e,c,u))throw new Error(`x=${c}, y=${u}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=c,this.y=u,this.key=vf(0,e,e,c,u)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,c,u){const p=(m=this.y,g=this.z,y=_f(256*(f=this.x),256*(m=Math.pow(2,g)-m-1),g),x=_f(256*(f+1),256*(m+1),g),y[0]+","+y[1]+","+x[0]+","+x[1]);var f,m,g,y,x;const b=function(e,c,u){let p,f="";for(let m=e;m>0;m--)p=1<1?"@2x":"").replace(/{quadkey}/g,b).replace(/{bbox-epsg-3857}/g,p)}isChildOf(e){const c=this.z-e.z;return c>0&&e.x===this.x>>c&&e.y===this.y>>c}getTilePoint(e){const c=Math.pow(2,this.z);return new p((e.x*c-this.x)*se,(e.y*c-this.y)*se)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Nh{constructor(e,c){this.wrap=e,this.canonical=c,this.key=vf(e,c.z,c.z,c.x,c.y)}}class $h{constructor(e,c,u,p,f){if(this.terrainRttPosMatrix32f=null,e= z; overscaledZ = ${e}; z = ${u}`);this.overscaledZ=e,this.wrap=c,this.canonical=new Rh(u,+p,+f),this.key=vf(c,e,u,p,f)}clone(){return new $h(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const c=this.canonical.z-e;return e>this.canonical.z?new $h(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new $h(e,this.wrap,e,this.canonical.x>>c,this.canonical.y>>c)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,c){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const u=this.canonical.z-e;return e>this.canonical.z?vf(this.wrap*+c,e,this.canonical.z,this.canonical.x,this.canonical.y):vf(this.wrap*+c,e,e,this.canonical.x>>u,this.canonical.y>>u)}isChildOf(e){if(e.wrap!==this.wrap)return!1;if(this.overscaledZ-e.overscaledZ<=0)return!1;if(0===e.overscaledZ)return this.overscaledZ>0;const c=this.canonical.z-e.canonical.z;return!(c<0)&&e.canonical.x===this.canonical.x>>c&&e.canonical.y===this.canonical.y>>c}children(e){if(this.overscaledZ>=e)return[new $h(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const c=this.canonical.z+1,u=2*this.canonical.x,p=2*this.canonical.y;return[new $h(c,this.wrap,c,u,p),new $h(c,this.wrap,c,u+1,p),new $h(c,this.wrap,c,u,p+1),new $h(c,this.wrap,c,u+1,p+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.y=0&&e=0&&c=x)return null;let T=this.canonical.x+p,S=this.wrap;return T<0?(S-=Math.ceil(-T/x),T=(T%x+x)%x):T>=x&&(S+=Math.floor(T/x),T%=x),{tileID:new $h(this.overscaledZ,S,y,T,b),x:m,y:g}}}function vf(e,c,u,p,f){(e*=2)<0&&(e=-1*e-1);const m=1<e.key===u));c>-1&&e.addOrUpdateProperties.splice(c,1)}return(e.removeAllProperties||c.removeAllProperties)&&(u.removeAllProperties=!0),(e.removeProperties||c.removeProperties)&&(u.removeProperties=[...e.removeProperties||[],...c.removeProperties||[]]),(e.addOrUpdateProperties||c.addOrUpdateProperties)&&(u.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...c.addOrUpdateProperties||[]]),(e.newGeometry||c.newGeometry)&&(u.newGeometry=c.newGeometry||e.newGeometry),u}function Tf(e){var c,u;if(!e)return{};const p={};return p.removeAll=e.removeAll,p.remove=new Set(e.remove||[]),p.add=new Map(null===(c=e.add)||void 0===c?void 0:c.map((e=>[e.id,e]))),p.update=new Map(null===(u=e.update)||void 0===u?void 0:u.map((e=>[e.id,e]))),p}Jl("CanonicalTileID",Rh),Jl("OverscaledTileID",$h,{omit:["terrainRttPosMatrix32f"]});class Xh{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){const c=new Xh;return c.extend(e(new p(this.minX,this.minY))),c.extend(e(new p(this.maxX,this.minY))),c.extend(e(new p(this.minX,this.maxY))),c.extend(e(new p(this.maxX,this.maxY))),c}static fromPoints(e){const c=new Xh;for(const u of e)c.extend(u);return c}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}class Yh{constructor(e){this._stringToNumber={},this._numberToString=[];for(let c=0;c=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Zh{constructor(e,c,u,p,f){this.type="Feature",this._vectorTileFeature=e,this._x=u,this._y=p,this._z=c,this.properties=e.properties,this.id=f}projectPoint(e,c,u,p){return[360*(e.x+c)/p-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+u)/p)*Math.PI))-90]}projectLine(e,c,u,p){return e.map((e=>this.projectPoint(e,c,u,p)))}get geometry(){if(this._geometry)return this._geometry;const e=this._vectorTileFeature,c=e.extent*Math.pow(2,this._z),u=e.extent*this._x,p=e.extent*this._y,f=e.loadGeometry();switch(e.type){case 1:{const e=[];for(const c of f)e.push(c[0]);const m=this.projectLine(e,u,p,c);this._geometry=1===e.length?{type:"Point",coordinates:m[0]}:{type:"MultiPoint",coordinates:m};break}case 2:{const e=f.map((e=>this.projectLine(e,u,p,c)));this._geometry=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};break}case 3:{const e=ld(f),m=[];for(const f of e)m.push(f.map((e=>this.projectLine(e,u,p,c))));this._geometry=1===m.length?{type:"Polygon",coordinates:m[0]}:{type:"MultiPolygon",coordinates:m};break}default:throw new Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const c in this)"_geometry"!==c&&"_vectorTileFeature"!==c&&"_x"!==c&&"_y"!==c&&"_z"!==c&&(e[c]=this[c]);return e}}class Hh{_name;dataBuffer;nullabilityBuffer;_size;constructor(e,c,u){this._name=e,this.dataBuffer=c,"number"==typeof u?this._size=u:(this.nullabilityBuffer=u,this._size=u.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer&&this.nullabilityBuffer.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class Kh extends Hh{}class Wh extends Kh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Jh extends Kh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Qh extends Hh{delta;constructor(e,c,u,p){super(e,c,p),this.delta=u}}class tp extends Qh{constructor(e,c,u,p){super(e,Int32Array.of(c),u,p)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class ep extends Hh{constructor(e,c,u){super(e,Int32Array.of(c),u)}getValueFromBuffer(e){return this.dataBuffer[0]}}class rp{_name;_geometryVector;_idVector;_propertyVectors;_extent;propertyVectorsMap;constructor(e,c,u,p,f=4096){this._name=e,this._geometryVector=c,this._idVector=u,this._propertyVectors=p,this._extent=f}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map((e=>[e.name,e])))),this.propertyVectorsMap.get(e)}*[Symbol.iterator](){const e=this.geometryVector[Symbol.iterator]();let c=0;for(;c=64)throw new Error("Varint too long")}return c.set(f),u}function Gf(e,c){let u,p;return p=e[c.get()],c.increment(),u=127&p,p<128?u:(p=e[c.get()],c.increment(),u|=(127&p)<<7,p<128?u:(p=e[c.get()],c.increment(),u|=(127&p)<<14,p<128?u:(p=e[c.get()],c.increment(),u|=(127&p)<<21,p<128?u:(p=e[c.get()],u|=(15&p)<<28,function(e,c,u){let p,f;if(f=c[u.get()],u.increment(),p=(112&f)>>4,f<128)return 4294967296*p+(e>>>0);if(f=c[u.get()],u.increment(),p|=(127&f)<<3,f<128)return 4294967296*p+(e>>>0);if(f=c[u.get()],u.increment(),p|=(127&f)<<10,f<128)return 4294967296*p+(e>>>0);if(f=c[u.get()],u.increment(),p|=(127&f)<<17,f<128)return 4294967296*p+(e>>>0);if(f=c[u.get()],u.increment(),p|=(127&f)<<24,f<128)return 4294967296*p+(e>>>0);if(f=c[u.get()],u.increment(),p|=(1&f)<<31,f<128)return 4294967296*p+(e>>>0);throw new Error("Expected varint not more than 10 bytes")}(u,e,c)))))}function Uf(e){return e>>>1^-(1&e)}function qf(e){return e>>1n^-(1n&e)}function $f(e){return e%2==1?(e+1)/-2:e/2}function Zf(e,c,u){if(void 0===u){u=0;for(let p=0;p=4)for(let p=e[0];u>4];let f=null;switch(p){case Mf.DATA:f=new kp(Object.values(Ef)[15&u]);break;case Mf.OFFSET:f=new kp(null,Object.values(Cf)[15&u]);break;case Mf.LENGTH:f=new kp(null,null,Object.values(Af)[15&u])}c.increment();const m=e[c.get()],g=Object.values(Sf)[m>>5],y=Object.values(Sf)[m>>2&7],x=Object.values(If)[3&m];c.increment();const b=Of(e,c,2),T=b[0];return{physicalStreamType:p,logicalStreamType:f,logicalLevelTechnique1:g,logicalLevelTechnique2:y,physicalLevelTechnique:x,numValues:T,byteLength:b[1],decompressedCount:T}}(e,c);return u.logicalLevelTechnique1===Sf.MORTON?function(e,c,u){const p=Of(c,u,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:e.decompressedCount,numBits:p[0],coordinateShift:p[1]}}(u,e,c):Sf.RLE!==u.logicalLevelTechnique1&&Sf.RLE!==u.logicalLevelTechnique2||If.NONE===u.physicalLevelTechnique?u:function(e,c,u){const p=Of(c,u,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:p[1],runs:p[0],numRleValues:p[1]}}(u,e,c)}!function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"}(Ef||(Ef={})),function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"}(Cf||(Cf={})),function(e){e.VAR_BINARY="VAR_BINARY",e.GEOMETRIES="GEOMETRIES",e.PARTS="PARTS",e.RINGS="RINGS",e.TRIANGLES="TRIANGLES",e.SYMBOL="SYMBOL",e.DICTIONARY="DICTIONARY"}(Af||(Af={})),function(e){e[e.FLAT=0]="FLAT",e[e.CONST=1]="CONST",e[e.SEQUENCE=2]="SEQUENCE",e[e.DICTIONARY=3]="DICTIONARY",e[e.FSST_DICTIONARY=4]="FSST_DICTIONARY"}(kf||(kf={}));class Ip{values;_size;constructor(e,c){this.values=e,this._size=c}get(e){const c=Math.floor(e/8);return 1==(this.values[c]>>e%8&1)}set(e,c){const u=Math.floor(e/8);this.values[u]=this.values[u]|(c?1:0)<>e%8&1}size(){return this._size}getBuffer(){return this.values}}function Kf(e,c,u){if(!c)return e;const p=c.size(),f=new(0,e.constructor)(p);let m=0;for(let g=0;g=4)for(;u=4)for(;u=4)for(;u>1,c)-u}}function cm(e,c){let u=0;for(let p=0;p>p;return u}!function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON",e[e.MULTIPOINT=3]="MULTIPOINT",e[e.MULTILINESTRING=4]="MULTILINESTRING",e[e.MULTIPOLYGON=5]="MULTIPOLYGON"}(Rf||(Rf={})),function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"}(Ff||(Ff={})),function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"}(Lf||(Lf={}));class jp{createPoint(e){return[[e]]}createMultiPoint(e){return e.map((e=>[e]))}createLineString(e){return[e]}createMultiLineString(e){return e}createPolygon(e,c){return[e].concat(c)}createMultiPolygon(e){return e.flat()}}function hm(e){const c=new Array(e.numGeometries);let u=1,f=1,m=1,g=0;const y=new jp;let x=0,b=0;const T=e.mortonSettings,S=e.topologyVector,P=S.geometryOffsets,I=S.partOffsets,C=S.ringOffsets,R=e.vertexOffsets,F=e.containsPolygonGeometry(),L=e.vertexBuffer;for(let S=0;S0&&c.push(c[0]),S.push(c)}e[c]=S,m&&b++}break;case Rf.MULTIPOLYGON:{const T=m[b]-m[b-1];b++;const S=[];for(let e=0;e0&&c.push(c[0]),S.push(c)}}e[c]=S}}return e}[Symbol.iterator](){return null}}function gm(e,c,u,p,f,m){return new rf(e,c,u,p,f,m)}class rf extends tf{_numGeometries;_geometryType;constructor(e,c,u,p,f,m){super(u,p,f,m),this._numGeometries=e,this._geometryType=c}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function ym(e,c,u,p,f){return new sf(e,c,u,p,f)}class sf extends tf{_geometryTypes;constructor(e,c,u,p,f){super(c,u,p,f),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function xm(e,c,u,p,f){const m=Yf(e,u);let g=null,y=null,x=null,b=null;if(am(m,p,e,u)===kf.CONST){const f=im(e,u,m,!1);let T=null,S=null,P=null,I=null;for(let p=0;pu?c[m++]:1);return p}function bm(e,c,u,p){const f=new Uint32Array(c[c.length-1]+1);let m=0;f[0]=m;let g=1,y=0;for(let x=0;x=g);){const u=e[p.increment()];if(u<=127){const g=u+3,y=e[p.increment()],x=Math.min(m+g,c);f.fill(y,m,x),m=x}else{const g=256-u;for(let u=0;u=12?Tm.decode(e.subarray(c,u)):function(e,c,u){let p="",f=c;for(;f239?4:c>223?3:c>191?2:1;if(f+b>u)break;1===b?c<128&&(x=c):2===b?(m=e[f+1],128==(192&m)&&(x=(31&c)<<6|63&m,x<=127&&(x=null))):3===b?(m=e[f+1],g=e[f+2],128==(192&m)&&128==(192&g)&&(x=(15&c)<<12|(63&m)<<6|63&g,(x<=2047||x>=55296&&x<=57343)&&(x=null))):4===b&&(m=e[f+1],g=e[f+2],y=e[f+3],128==(192&m)&&128==(192&g)&&128==(192&y)&&(x=(15&c)<<18|(63&m)<<12|(63&g)<<6|63&y,(x<=65535||x>=1114112)&&(x=null))),null===x?(x=65533,b=1):x>65535&&(x-=65536,p+=String.fromCharCode(x>>>10&1023|55296),x=56320|1023&x),p+=String.fromCharCode(x),f+=b}return p}(e,c,u)}class yf extends Hh{offsetBuffer;constructor(e,c,u,p){super(e,u,p),this.offsetBuffer=c}}class mf extends yf{textEncoder;constructor(e,c,u,p){super(e,c,u,p??c.length-1),this.textEncoder=new TextEncoder}getValueFromBuffer(e){return Sm(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class gf extends yf{indexBuffer;textEncoder;constructor(e,c,u,p,f){super(e,u,p,f??c.length),this.indexBuffer=c,this.indexBuffer=c,this.textEncoder=new TextEncoder}getValueFromBuffer(e){const c=this.indexBuffer[e];return Sm(this.dataBuffer,this.offsetBuffer[c],this.offsetBuffer[c+1])}}class xf extends yf{indexBuffer;symbolOffsetBuffer;symbolTableBuffer;textEncoder;symbolLengthBuffer;lengthBuffer;decodedDictionary;constructor(e,c,u,p,f,m,g){super(e,u,p,g),this.indexBuffer=c,this.symbolOffsetBuffer=f,this.symbolTableBuffer=m,this.textEncoder=new TextEncoder}getValueFromBuffer(e){null==this.decodedDictionary&&(null==this.symbolLengthBuffer&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer),this.lengthBuffer=this.offsetToLengthBuffer(this.offsetBuffer)),this.decodedDictionary=function(e,c,u){const p=[],f=new Array(c.length).fill(0);for(let e=1;e1?6:4,u.type="physicalType",c.scalarType=u,c.type="scalarType",c}case 4:{const e={nullable:!1,columnScope:0},c={type:"physicalType",physicalType:0};return e.type="complexType",e.complexType=c,e}case 30:{const e={nullable:!1,columnScope:0},c={type:"physicalType",physicalType:1};return e.type="complexType",e.complexType=c,e}default:return function(e){let c=null;switch(e){case 10:case 11:c=0;break;case 12:case 13:c=1;break;case 14:case 15:c=2;break;case 16:case 17:c=3;break;case 18:case 19:c=4;break;case 20:case 21:c=5;break;case 22:case 23:c=6;break;case 24:case 25:c=7;break;case 26:case 27:c=8;break;case 28:case 29:c=9;break;default:return null}const u={};u.nullable=!!(1&e),u.columnScope=0;const p={type:"physicalType"};return p.physicalType=c,u.type="scalarType",u.scalarType=p,u}(e)}}function Em(e){return e>=10}function Cm(e){return 30===e}function Am(e){if("id"===e.name)return!1;if("scalarType"===e.type){const c=e.scalarType;if("physicalType"===c.type)switch(c.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}else if("logicalType"===c.type)return!1}else if("complexType"===e.type){const c=e.complexType;if("physicalType"===c.type)switch(c.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}const Dm=new TextDecoder;function zm(e,c){const u=Of(e,c,1)[0];if(0===u)return"";const p=c.get(),f=e.subarray(p,p+u);return c.add(u),Dm.decode(f)}function km(e,c){const u=Of(e,c,1)[0]>>>0;if(u<10||u>30)throw new Error(`Unsupported field type code ${u}. Supported: 10-29(scalars), 30(STRUCT)`);const p=Mm(u);if(Em(u)&&(p.name=zm(e,c)),Cm(u)){const u=Of(e,c,1)[0]>>>0;p.complexType.children=new Array(u);for(let f=0;f>>0,p=Mm(u);if(!p)throw new Error(`Unsupported column type code ${u}. Supported: 0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT)`);if(Em(u)?p.name=zm(e,c):u>=0&&u<=3?p.name="id":4===u&&(p.name="geometry"),Cm(u)){const u=Of(e,c,1)[0]>>>0,f=p.complexType;f.children=new Array(u);for(let p=0;p>>0,m=Of(e,c,1)[0]>>>0;p.columns=new Array(m);for(let u=0;u=4)for(;u>>0,m=p.get()+c;if(m>e.length)throw new Error(`Block overruns tile: ${m} > ${e.length}`);if(1!=Of(e,p,1)[0]>>>0){p.set(m);continue}const g=Fm(e,p),y=g[1],x=g[0].featureTables[0];let b=null,T=null;const S=[];let P=0;for(const c of x.columns){const f=c.name;if("id"===f){let m=null;if(c.nullable){const c=Yf(e,p),u=p.get(),f=wm(e,c.numValues,c.byteLength,p);p.set(u+c.byteLength),m=new Ip(f,c.numValues)}const g=Yf(e,p);P=g.decompressedCount,b=Lm(e,c,p,f,g,m??P,u)}else if("geometry"===f){const c=Of(e,p,1)[0];if(0===P){const c=p.get();P=Yf(e,p).decompressedCount,p.set(c)}T=xm(e,c,p,P)}else{const u=Am(c)?Of(e,p,1)[0]:1;if(0===u)continue;const f=Pm(e,p,c,u,P);if(f)if(Array.isArray(f))for(const e of f)S.push(e);else S.push(f)}}const I=new rp(x.name,T,b,S,y);f.push(I),p.set(m)}return f}(new Uint8Array(e));this.layers=c.reduce(((e,c)=>Object.assign(Object.assign({},e),{[c.name]:new Pf(c)})),{})}}class Bf{constructor(e,c){this.feature=e,this.type=e.type,this.properties=e.tags?e.tags:{},this.extent=c,"id"in e&&("string"==typeof e.id?this.id=parseInt(e.id,10):"number"!=typeof e.id||isNaN(e.id)||(this.id=e.id))}loadGeometry(){const e=[],c=1===this.feature.type?[this.feature.geometry]:this.feature.geometry;for(const u of c){const c=[];for(const e of u)c.push(new p(e[0],e[1]));e.push(c)}return e}}const Bm="_geojsonTileLayer";function Om(e,c){c.writeVarintField(15,e.version||1),c.writeStringField(1,e.name||""),c.writeVarintField(5,e.extent||4096);const u={keys:[],values:[],keycache:{},valuecache:{}};for(let p=0;p>31}function Um(e,c){const u=e.loadGeometry(),p=e.type;let f=0,m=0;for(const g of u){let u=1;1===p&&(u=g.length),c.writeVarint(Nm(1,u));const y=3===p?g.length-1:g.length;for(let e=0;e=0&&p[3]>=0&&y.insert(g,p[0],p[1],p[2],p[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers="mlt"!==this.encoding?new Lu(new Ec(this.rawTileData)).layers:new zf(this.rawTileData).layers,this.sourceLayerCoder=new Yh(this.vtLayers?Object.keys(this.vtLayers).sort():[Bm])),this.vtLayers}query(e,c,u,f){this.loadVTLayers();const m=e.params,g=se/e.tileSize/e.scale,y=ko(m.filter,m.globalState),x=e.queryGeometry,b=e.queryPadding*g,T=Xh.fromPoints(x),S=this.grid.query(T.minX-b,T.minY-b,T.maxX+b,T.maxY+b),P=Xh.fromPoints(e.cameraQueryGeometry).expandBy(b),I=this.grid3D.query(P.minX,P.minY,P.maxX,P.maxY,((c,u,f,m)=>function(e,c,u,f,m){for(const p of e)if(c<=p.x&&u<=p.y&&f>=p.x&&m>=p.y)return!0;const g=[new p(c,u),new p(c,m),new p(f,m),new p(f,u)];if(e.length>2)for(const c of g)if(mh(e,c))return!0;for(let c=0;c(P||(P=eh(c)),u.queryIntersectsFeature({queryGeometry:x,feature:c,featureState:p,geometry:P,zoom:this.z,transform:e.transform,pixelsToTileUnits:g,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return C}loadMatchingFeature(e,c,u,p,f,m,g,y,x,b,T){const S=this.bucketLayerIDs[c];if(m&&!S.some((e=>m.has(e))))return;const P=this.sourceLayerCoder.decode(u),I=this.vtLayers[P].feature(p);if(f.needGeometry){const e=th(I,!0);if(!f.filter(new zs(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!f.filter(new zs(this.tileID.overscaledZ),I))return;const C=this.getId(I,P);for(let c=0;c{const g=c instanceof js?c.get(m):null;return g&&g.evaluate?g.evaluate(u,p,f):g}))}function Zm(e,c){return c-e}function Wm(e,c,u,f,m){const g=[];for(let y=0;y=f&&T.x>=f||(y.x>=f?y=new p(f,y.y+(f-y.x)/(T.x-y.x)*(T.y-y.y))._round():T.x>=f&&(T=new p(f,y.y+(f-y.x)/(T.x-y.x)*(T.y-y.y))._round()),y.y>=m&&T.y>=m||(y.y>=m?y=new p(y.x+(m-y.y)/(T.y-y.y)*(T.x-y.x),m)._round():T.y>=m&&(T=new p(y.x+(m-y.y)/(T.y-y.y)*(T.x-y.x),m)._round()),b&&y.equals(b[b.length-1])||(b=[y],g.push(b)),b.push(T)))))}}return g}function Hm(e,c,u,p,f){switch(c){case 1:return function(e,c,u,p){const f=[];for(const m of e)for(const e of m){const m=0===p?e.x:e.y;m>=c&&m<=u&&f.push([e])}return f}(e,u,p,f);case 2:return Ym(e,u,p,f,!1);case 3:return Ym(e,u,p,f,!0)}return[]}function Xm(e,c,u,f,m){const g=0===f?Km:Jm;let y=[];const x=[];for(let p=0;pc&&y.push(g(b,T,c)):S>u?P=c&&(y.push(g(b,T,c)),I=!0),P>u&&S<=u&&(y.push(g(b,T,u)),I=!0),!m&&I&&(x.push(y),y=[])}const b=e.length-1,T=0===f?e[b].x:e[b].y;return T>=c&&T<=u&&y.push(e[b]),m&&y.length>0&&!y[0].equals(y[y.length-1])&&y.push(new p(y[0].x,y[0].y)),y.length>0&&x.push(y),x}function Ym(e,c,u,p,f){const m=[];for(const g of e){const e=Xm(g,c,u,p,f);e.length>0&&m.push(...e)}return m}function Km(e,c,u){return new p(u,e.y+(u-e.x)/(c.x-e.x)*(c.y-e.y))}function Jm(e,c,u){return new p(e.x+(u-e.y)/(c.y-e.y)*(c.x-e.x),u)}Jl("FeatureIndex",jf,{omit:["rawTileData","sourceLayerCoder"]});class Jf extends p{constructor(e,c,u,p){super(e,c),this.angle=u,void 0!==p&&(this.segment=p)}clone(){return new Jf(this.x,this.y,this.angle,this.segment)}}function Qm(e,c,u,p,f){if(void 0===c.segment||0===u)return!0;let m=c,g=c.segment+1,y=0;for(;y>-u/2;){if(g--,g<0)return!1;y-=e[g].dist(m),m=e[g]}y+=e[g].dist(e[g+1]),g++;const x=[];let b=0;for(;yp;)b-=x.shift().angleDelta;if(b>f)return!1;g++,y+=c.dist(u)}return!0}function e_(e){let c=0;for(let u=0;ub){const T=(b-x)/m,S=qr.number(p.x,f.x,T),P=qr.number(p.y,f.y,T),I=new Jf(S,P,f.angleTo(p),u);return I._round(),!g||Qm(e,I,y,g,c)?I:void 0}x+=m}}function n_(e,c,u,p,f,m,g,y,x){const b=t_(p,m,g),T=i_(p,f),S=T*g,P=0===e[0].x||e[0].x===x||0===e[0].y||e[0].y===x;return c-S=0&&L=0&&B=0&&P+b<=T){const u=new Jf(L,B,R,c);u._round(),p&&!Qm(e,u,m,p,f)||I.push(u)}}S+=C}return y||I.length||g||(I=s_(e,S/2,u,p,f,m,g,!0,x)),I}function o_(e,c,u,f){const m=[],g=e.image,y=g.pixelRatio,x=g.paddedRect.w-2,b=g.paddedRect.h-2;let T={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const S=g.stretchX||[[0,x]],P=g.stretchY||[[0,b]],I=(e,c)=>e+c[1]-c[0],C=S.reduce(I,0),R=P.reduce(I,0),F=x-C,L=b-R;let B=0,O=C,V=0,j=R,G=0,U=F,q=0,Z=L;if(g.content&&f){const c=g.content,u=c[2]-c[0],p=c[3]-c[1];(g.textFitWidth||g.textFitHeight)&&(T=Cp(e)),B=a_(S,0,c[0]),V=a_(P,0,c[1]),O=a_(S,c[0],c[2]),j=a_(P,c[1],c[3]),G=c[0]-B,q=c[1]-V,U=u-O,Z=p-j}const W=T.x1,J=T.y1,Q=T.x2-W,ee=T.y2-J,se=(e,f,m,x)=>{const b=c_(e.stretch-B,O,Q,W),T=h_(e.fixed-G,U,e.stretch,C),S=c_(f.stretch-V,j,ee,J),P=h_(f.fixed-q,Z,f.stretch,R),I=c_(m.stretch-B,O,Q,W),F=h_(m.fixed-G,U,m.stretch,C),L=c_(x.stretch-V,j,ee,J),se=h_(x.fixed-q,Z,x.stretch,R),ce=new p(b,S),he=new p(I,S),ue=new p(I,L),de=new p(b,L),fe=new p(T/y,P/y),me=new p(F/y,se/y),ge=c*Math.PI/180;if(ge){const e=Math.sin(ge),c=Math.cos(ge),u=[c,-e,e,c];ce._matMult(u),he._matMult(u),de._matMult(u),ue._matMult(u)}const ye=e.stretch+e.fixed,xe=f.stretch+f.fixed;return{tl:ce,tr:he,bl:de,br:ue,tex:{x:g.paddedRect.x+1+ye,y:g.paddedRect.y+1+xe,w:m.stretch+m.fixed-ye,h:x.stretch+x.fixed-xe},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:fe,pixelOffsetBR:me,minFontScaleX:U/y/Q,minFontScaleY:Z/y/ee,isSDF:u}};if(f&&(g.stretchX||g.stretchY)){const e=l_(S,F,C),c=l_(P,L,R);for(let u=0;u0&&(p=Math.max(10,p),this.circleDiameter=p)}else{const b=(null===(S=g.image)||void 0===S?void 0:S.content)&&(g.image.textFitWidth||g.image.textFitHeight)?Cp(g):{x1:g.left,y1:g.top,x2:g.right,y2:g.bottom};b.y1=b.y1*y-x[0],b.y2=b.y2*y+x[2],b.x1=b.x1*y-x[3],b.x2=b.x2*y+x[1];const P=g.collisionPadding;if(P&&(b.x1-=P[0]*y,b.y1-=P[1]*y,b.x2+=P[2]*y,b.y2+=P[3]*y),T){const e=new p(b.x1,b.y1),c=new p(b.x2,b.y1),u=new p(b.x1,b.y2),f=new p(b.x2,b.y2),m=T*Math.PI/180;e._rotate(m),c._rotate(m),u._rotate(m),f._rotate(m),b.x1=Math.min(e.x,c.x,u.x,f.x),b.x2=Math.max(e.x,c.x,u.x,f.x),b.y1=Math.min(e.y,c.y,u.y,f.y),b.y2=Math.max(e.y,c.y,u.y,f.y)}e.emplaceBack(c.x,c.y,b.x1,b.y1,b.x2,b.y2,u,f,m)}this.boxEndIndex=e.length}}class pd{constructor(e=[],c=(e,c)=>ec?1:0){if(this.data=e,this.length=this.data.length,this.compare=c,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],c=this.data.pop();return--this.length>0&&(this.data[0]=c,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:c,compare:u}=this,p=c[e];for(;e>0;){const f=e-1>>1,m=c[f];if(u(p,m)>=0)break;c[e]=m,e=f}c[e]=p}_down(e){const{data:c,compare:u}=this,p=this.length>>1,f=c[e];for(;e=0)break;c[e]=c[p],e=p}c[e]=f}}function u_(e,c=1,u=!1){const f=Xh.fromPoints(e[0]),m=Math.min(f.width(),f.height());let g=m/2;const y=new pd([],d_),{minX:x,minY:b,maxX:T,maxY:S}=f;if(0===m)return new p(x,b);for(let c=x;cP.d||!P.d)&&(P=p,u&&console.log("found best %d after %d probes",Math.round(1e4*p.d)/1e4,I)),p.max-P.d<=c||(g=p.h/2,y.push(new p_(p.p.x-g,p.p.y-g,g,e)),y.push(new p_(p.p.x+g,p.p.y-g,g,e)),y.push(new p_(p.p.x-g,p.p.y+g,g,e)),y.push(new p_(p.p.x+g,p.p.y+g,g,e)),I+=4)}return u&&(console.log(`num probes: ${I}`),console.log(`best distance: ${P.d}`)),P.p}function d_(e,c){return c.max-e.max}function p_(c,u,f,m){(this||e).p=new p(c,u),(this||e).h=f,(this||e).d=function(e,c){let u=!1,p=1/0;for(let f=0;fe.y!=y.y>e.y&&e.x<(y.x-f.x)*(e.y-f.y)/(y.y-f.y)+f.x&&(u=!u),p=Math.min(p,uh(e,f,y))}}return(u?1:-1)*Math.sqrt(p)}((this||e).p,m),(this||e).max=(this||e).d+(this||e).h*Math.SQRT2}var f_;c.aP=void 0,(f_=c.aP||(c.aP={}))[f_.center=1]="center",f_[f_.left=2]="left",f_[f_.right=3]="right",f_[f_.top=4]="top",f_[f_.bottom=5]="bottom",f_[f_["top-left"]=6]="top-left",f_[f_["top-right"]=7]="top-right",f_[f_["bottom-left"]=8]="bottom-left",f_[f_["bottom-right"]=9]="bottom-right";const m_=Number.POSITIVE_INFINITY;function __(e,c){return c[1]!==m_?function(e,c,u){let p=0,f=0;switch(c=Math.abs(c),u=Math.abs(u),e){case"top-right":case"top-left":case"top":f=u-7;break;case"bottom-right":case"bottom-left":case"bottom":f=7-u}switch(e){case"top-right":case"bottom-right":case"right":p=-c;break;case"top-left":case"bottom-left":case"left":p=c}return[p,f]}(e,c[0],c[1]):function(e,c){let u=0,p=0;c<0&&(c=0);const f=c/Math.SQRT2;switch(e){case"top-right":case"top-left":p=f-7;break;case"bottom-right":case"bottom-left":p=7-f;break;case"bottom":p=7-c;break;case"top":p=c-7}switch(e){case"top-right":case"bottom-right":u=-f;break;case"top-left":case"bottom-left":u=f;break;case"left":u=c;break;case"right":u=-c}return[u,p]}(e,c[0])}function g_(e,c,u){var p;const f=e.layout,m=null===(p=f.get("text-variable-anchor-offset"))||void 0===p?void 0:p.evaluate(c,{},u);if(m){const e=m.values,c=[];for(let u=0;ue*Nd));p.startsWith("top")?f[1]-=7:p.startsWith("bottom")&&(f[1]+=7),c[u+1]=f}return new Le(c)}const g=f.get("text-variable-anchor");if(g){let p;p=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[f.get("text-radial-offset").evaluate(c,{},u)*Nd,m_]:f.get("text-offset").evaluate(c,{},u).map((e=>e*Nd));const m=[];for(const e of g)m.push(e,__(e,p));return new Le(m)}return null}function y_(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function x_(e,u,p,f,m,g,y,x,b,T,S,P){let I=g.textMaxSize.evaluate(u,{});void 0===I&&(I=y);const C=e.layers[0].layout,R=C.get("icon-offset").evaluate(u,{},S),F=b_(p.horizontal),L=y/24,B=e.tilePixelRatio*L,O=e.tilePixelRatio*I/24,V=e.tilePixelRatio*x,j=e.tilePixelRatio*C.get("symbol-spacing"),G=C.get("text-padding")*e.tilePixelRatio,U=function(e,c,u,p=1){const f=e.get("icon-padding").evaluate(c,{},u),m=f&&f.values;return[m[0]*p,m[1]*p,m[2]*p,m[3]*p]}(C,u,S,e.tilePixelRatio),q=C.get("text-max-angle")/180*Math.PI,Z="viewport"!==C.get("text-rotation-alignment")&&"point"!==C.get("symbol-placement"),W="map"===C.get("icon-rotation-alignment")&&"point"!==C.get("symbol-placement"),J=C.get("symbol-placement"),Q=j/2,ee=C.get("icon-text-fit");let ce;f&&"none"!==ee&&(e.allowVerticalPlacement&&p.vertical&&(ce=Ap(f,p.vertical,ee,C.get("icon-text-fit-padding"),R,L)),F&&(f=Ap(f,F,ee,C.get("icon-text-fit-padding"),R,L)));const he=S?P.line.getGranularityForZoomLevel(S.z):1,ue=(x,P)=>{P.x<0||P.x>=se||P.y<0||P.y>=se||function(e,u,p,f,m,g,y,x,b,T,S,P,I,C,R,F,L,B,O,V,j,G,U,q,Z){const W=e.addToLineVertexArray(u,p);let J,Q,ee,se,ce=0,he=0,ue=0,de=0,fe=-1,me=-1;const ge={};let ye=Uc("");if(e.allowVerticalPlacement&&f.vertical){const e=x.layout.get("text-rotate").evaluate(j,{},q)+90;ee=new hd(b,u,T,S,P,f.vertical,I,C,R,e),y&&(se=new hd(b,u,T,S,P,y,L,B,R,e))}if(m){const p=x.layout.get("icon-rotate").evaluate(j,{}),f="none"!==x.layout.get("icon-text-fit"),g=o_(m,p,U,f),I=y?o_(y,p,U,f):void 0;Q=new hd(b,u,T,S,P,m,L,B,!1,p),ce=4*g.length;const C=e.iconSizeData;let R=null;"source"===C.kind?(R=[Dp*x.layout.get("icon-size").evaluate(j,{})],R[0]>zp&&Ee(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===C.kind&&(R=[Dp*G.compositeIconSizes[0].evaluate(j,{},q),Dp*G.compositeIconSizes[1].evaluate(j,{},q)],(R[0]>zp||R[1]>zp)&&Ee(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,g,R,V,O,j,c.az.none,u,W.lineStartIndex,W.lineLength,-1,q),fe=e.icon.placedSymbolArray.length-1,I&&(he=4*I.length,e.addSymbols(e.icon,I,R,V,O,j,c.az.vertical,u,W.lineStartIndex,W.lineLength,-1,q),me=e.icon.placedSymbolArray.length-1)}const xe=Object.keys(f.horizontal);for(const p of xe){const m=f.horizontal[p];if(!J){ye=Uc(m.text);const e=x.layout.get("text-rotate").evaluate(j,{},q);J=new hd(b,u,T,S,P,m,I,C,R,e)}const y=1===m.positionedLines.length;if(ue+=v_(e,u,m,g,x,R,j,F,W,f.vertical?c.az.horizontal:c.az.horizontalOnly,y?xe:[p],ge,fe,G,q),y)break}f.vertical&&(de+=v_(e,u,f.vertical,g,x,R,j,F,W,c.az.vertical,["vertical"],ge,me,G,q));const ve=J?J.boxStartIndex:e.collisionBoxArray.length,be=J?J.boxEndIndex:e.collisionBoxArray.length,we=ee?ee.boxStartIndex:e.collisionBoxArray.length,Se=ee?ee.boxEndIndex:e.collisionBoxArray.length,Me=Q?Q.boxStartIndex:e.collisionBoxArray.length,Ce=Q?Q.boxEndIndex:e.collisionBoxArray.length,Ae=se?se.boxStartIndex:e.collisionBoxArray.length,Ne=se?se.boxEndIndex:e.collisionBoxArray.length;let Ge=-1;const Ue=(e,c)=>e&&e.circleDiameter?Math.max(e.circleDiameter,c):c;Ge=Ue(J,Ge),Ge=Ue(ee,Ge),Ge=Ue(Q,Ge),Ge=Ue(se,Ge);const $e=Ge>-1?1:0;$e&&(Ge*=Z/Nd),e.glyphOffsetArray.length>=yh.MAX_GLYPHS&&Ee("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==j.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,j.sortKey);const He=g_(x,j,q),[Ye,et]=function(e,u){const p=e.length,f=null==u?void 0:u.values;if((null==f?void 0:f.length)>0)for(let u=0;u=0?ge.right:-1,ge.center>=0?ge.center:-1,ge.left>=0?ge.left:-1,ge.vertical||-1,fe,me,ye,ve,be,we,Se,Me,Ce,Ae,Ne,T,ue,de,ce,he,$e,0,I,Ge,Ye,et)}(e,P,x,p,f,m,ce,e.layers[0],e.collisionBoxArray,u.index,u.sourceLayerIndex,e.index,B,[G,G,G,G],Z,b,V,U,W,R,u,g,T,S,y)};if("line"===J)for(const c of Wm(u.geometry,0,0,se,se)){const u=Ku(c,he),m=n_(u,j,q,p.vertical||F,f,24,O,e.overscaling,se);for(const c of m)F&&w_(e,F.text,Q,c)||ue(u,c)}else if("line-center"===J){for(const e of u.geometry)if(e.length>1){const c=Ku(e,he),u=r_(c,q,p.vertical||F,f,24,O);u&&ue(c,u)}}else if("Polygon"===u.type)for(const e of Mn(u.geometry,0)){const c=u_(e,16);ue(Ku(e[0],he,!0),new Jf(c.x,c.y,0))}else if("LineString"===u.type)for(const e of u.geometry){const c=Ku(e,he);ue(c,new Jf(c[0].x,c[0].y,0))}else if("Point"===u.type)for(const e of u.geometry)for(const c of e)ue([c],new Jf(c.x,c.y,0))}function v_(e,c,u,f,m,g,y,x,b,T,S,P,I,C,R){const F=function(e,c,u,f,m,g,y,x){const b=f.layout.get("text-rotate").evaluate(g,{})*Math.PI/180,T=[];for(const e of c.positionedLines)for(const f of e.positionedGlyphs){if(!f.rect)continue;const g=f.rect||{};let S=4,P=!0,I=1,C=0;const R=(m||x)&&f.vertical,F=f.metrics.advance*f.scale/2;if(x&&c.verticalizable&&(C=e.lineOffset/2-(f.imageName?-(Nd-f.metrics.width*f.scale)/2:(f.scale-1)*Nd)),f.imageName){const e=y[f.imageName];P=e.sdf,I=e.pixelRatio,S=1/I}const L=m?[f.x+F,f.y]:[0,0];let B=m?[0,0]:[f.x+F+u[0],f.y+u[1]-C],O=[0,0];R&&(O=B,B=[0,0]);const V=f.metrics.isDoubleResolution?2:1,j=(f.metrics.left-S)*f.scale-F+B[0],G=(-f.metrics.top-S)*f.scale+B[1],U=j+g.w/V*f.scale/I,q=G+g.h/V*f.scale/I,Z=new p(j,G),W=new p(U,G),J=new p(j,q),Q=new p(U,q);if(R){const e=new p(-F,F- -17),c=-Math.PI/2,u=12-F,m=new p(22-u,-(f.imageName?u:0)),g=new p(...O);Z._rotateAround(c,e)._add(m)._add(g),W._rotateAround(c,e)._add(m)._add(g),J._rotateAround(c,e)._add(m)._add(g),Q._rotateAround(c,e)._add(m)._add(g)}if(b){const e=Math.sin(b),c=Math.cos(b),u=[c,-e,e,c];Z._matMult(u),W._matMult(u),J._matMult(u),Q._matMult(u)}const ee=new p(0,0),se=new p(0,0);T.push({tl:Z,tr:W,bl:J,br:Q,tex:g,writingMode:c.writingMode,glyphOffset:L,sectionIndex:f.sectionIndex,isSDF:P,pixelOffsetTL:ee,pixelOffsetBR:se,minFontScaleX:0,minFontScaleY:0})}return T}(0,u,x,m,g,y,f,e.allowVerticalPlacement),L=e.textSizeData;let B=null;"source"===L.kind?(B=[Dp*m.layout.get("text-size").evaluate(y,{})],B[0]>zp&&Ee(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===L.kind&&(B=[Dp*C.compositeTextSizes[0].evaluate(y,{},R),Dp*C.compositeTextSizes[1].evaluate(y,{},R)],(B[0]>zp||B[1]>zp)&&Ee(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,F,B,x,g,y,T,c,b.lineStartIndex,b.lineLength,I,R);for(const c of S)P[c]=e.text.placedSymbolArray.length-1;return 4*F.length}function b_(e){for(const c in e)return e[c];return null}function w_(e,c,u,p){const f=e.compareText;if(c in f){const e=f[c];for(let c=e.length-1;c>=0;c--)if(p.dist(e[c])>4;if(1!==p)throw new Error(`Got v${p} data when expected v1.`);const f=T_[15&u];if(!f)throw new Error("Unrecognized array type.");const[m]=new Uint16Array(e,2,1),[g]=new Uint32Array(e,4,1);return new Md(g,m,f,e)}constructor(e,c=64,u=Float64Array,p){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+c,2),65535),this.ArrayType=u,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const f=T_.indexOf(this.ArrayType),m=2*e*this.ArrayType.BYTES_PER_ELEMENT,g=e*this.IndexArrayType.BYTES_PER_ELEMENT,y=(8-g%8)%8;if(f<0)throw new Error(`Unexpected typed array class: ${u}.`);p&&p instanceof ArrayBuffer?(this.data=p,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+g+y,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+m+g+y),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+g+y,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+f]),new Uint16Array(this.data,2,1)[0]=c,new Uint32Array(this.data,4,1)[0]=e)}add(e,c){const u=this._pos>>1;return this.ids[u]=u,this.coords[this._pos++]=e,this.coords[this._pos++]=c,u}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return S_(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,c,u,p){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:f,coords:m,nodeSize:g}=this,y=[0,f.length-1,0],x=[];for(;y.length;){const b=y.pop()||0,T=y.pop()||0,S=y.pop()||0;if(T-S<=g){for(let g=S;g<=T;g++){const y=m[2*g],b=m[2*g+1];y>=e&&y<=u&&b>=c&&b<=p&&x.push(f[g])}continue}const P=S+T>>1,I=m[2*P],C=m[2*P+1];I>=e&&I<=u&&C>=c&&C<=p&&x.push(f[P]),(0===b?e<=I:c<=C)&&(y.push(S),y.push(P-1),y.push(1-b)),(0===b?u>=I:p>=C)&&(y.push(P+1),y.push(T),y.push(1-b))}return x}within(e,c,u){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:p,coords:f,nodeSize:m}=this,g=[0,p.length-1,0],y=[],x=u*u;for(;g.length;){const b=g.pop()||0,T=g.pop()||0,S=g.pop()||0;if(T-S<=m){for(let u=S;u<=T;u++)E_(f[2*u],f[2*u+1],e,c)<=x&&y.push(p[u]);continue}const P=S+T>>1,I=f[2*P],C=f[2*P+1];E_(I,C,e,c)<=x&&y.push(p[P]),(0===b?e-u<=I:c-u<=C)&&(g.push(S),g.push(P-1),g.push(1-b)),(0===b?e+u>=I:c+u>=C)&&(g.push(P+1),g.push(T),g.push(1-b))}return y}}function S_(e,c,u,p,f,m){if(f-p<=u)return;const g=p+f>>1;P_(e,c,g,p,f,m),S_(e,c,u,p,g-1,1-m),S_(e,c,u,g+1,f,1-m)}function P_(e,c,u,p,f,m){for(;f>p;){if(f-p>600){const g=f-p+1,y=u-p+1,x=Math.log(g),b=.5*Math.exp(2*x/3),T=.5*Math.sqrt(x*b*(g-b)/g)*(y-g/2<0?-1:1);P_(e,c,u,Math.max(p,Math.floor(u-y*b/g+T)),Math.min(f,Math.floor(u+(g-y)*b/g+T)),m)}const g=c[2*u+m];let y=p,x=f;for(I_(e,c,p,u),c[2*f+m]>g&&I_(e,c,p,f);yg;)x--}c[2*p+m]===g?I_(e,c,p,x):(x++,I_(e,c,x,f)),x<=u&&(p=x+1),u<=x&&(f=x-1)}}function I_(e,c,u,p){M_(e,u,p),M_(c,2*u,2*p),M_(c,2*u+1,2*p+1)}function M_(e,c,u){const p=e[c];e[c]=e[u],e[u]=p}function E_(e,c,u,p){const f=e-u,m=c-p;return f*f+m*m}var C_;c.cI=void 0,(C_=c.cI||(c.cI={})).create="create",C_.load="load",C_.fullLoad="fullLoad";let A_=null,D_=[];const z_=1e3/60,k_="loadTime",R_="fullLoadTime",F_={mark(e){performance.mark(e)},recordStartOfFrameAt(e){null!=A_&&D_.push(e-A_),A_=e},resetRuntimeMetrics(){A_=null,D_=[]},clearInitializationMetrics(){performance.clearMeasures(k_),performance.clearMeasures(R_);for(const e in c.cI)performance.clearMarks(c.cI[e])},remove(){this.resetRuntimeMetrics(),this.clearInitializationMetrics()},getPerformanceMetrics(){performance.measure(k_,c.cI.create,c.cI.load),performance.measure(R_,c.cI.create,c.cI.fullLoad);const e=performance.getEntriesByName(k_)[0].duration,u=performance.getEntriesByName(R_)[0].duration,p=D_.length;return{loadTimeMs:e,fullLoadTimeMs:u,averageFramesPerSecond:1/(D_.reduce(((e,c)=>e+c),0)/p/1e3),virtualDroppedFramesCount:D_.filter((e=>e>z_)).reduce(((e,c)=>e+(c-z_)/z_),0),totalFramesCount:p}}};c.$=S,c.A=C,c.B=Yl,c.C=$l,c.D=qs,c.E=xt,c.F=function([e,c,u]){return c+=90,c*=Math.PI/180,u*=Math.PI/180,{x:e*Math.cos(c)*Math.sin(u),y:e*Math.sin(c)*Math.sin(u),z:e*Math.cos(u)}},c.G=qr,c.H=zs,c.I=Gc,c.J=Wl,c.K=function(e){if(null==Ne){const c=e.navigator?e.navigator.userAgent:null;Ne=!!e.safari||!(!c||!(/\b(iPad|iPhone|iPod)\b/.test(c)||c.match("Safari")&&!c.match("Chrome")))}return Ne},c.L=class{constructor(e,c){this.target=e,this.mapId=c,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new kh((()=>this.process())),this.subscription=et(this.target,"message",(e=>this.receive(e)),!1),this.globalScope=Ae(self)?e:window}registerMessageHandler(e,c){this.messageHandlers[e]=c}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,c){return new Promise(((u,p)=>{const f=Math.round(1e18*Math.random()).toString(36).substring(0,10),m=c?et(c.signal,"abort",(()=>{null==m||m.unsubscribe(),delete this.resolveRejects[f];const c={id:f,type:"",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(c)}),Yp):null;this.resolveRejects[f]={resolve:e=>{null==m||m.unsubscribe(),u(e)},reject:e=>{null==m||m.unsubscribe(),p(e)}};const g=[],y=Object.assign(Object.assign({},e),{id:f,sourceMapId:this.mapId,origin:location.origin,data:ic(e.data,g)});this.target.postMessage(y,{transfer:g})}))}receive(e){const c=e.data,u=c.id;if(!("file://"!==c.origin&&"file://"!==location.origin&&"resource://android"!==c.origin&&"resource://android"!==location.origin&&c.origin!==location.origin||c.targetMapId&&this.mapId!==c.targetMapId)){if(""===c.type){delete this.tasks[u];const e=this.abortControllers[u];return delete this.abortControllers[u],void(e&&e.abort())}if(Ae(self)||c.mustQueue)return this.tasks[u]=c,this.taskQueue.push(u),void this.invoker.trigger();this.processTask(u,c)}}process(){if(0===this.taskQueue.length)return;const e=this.taskQueue.shift(),c=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),c&&this.processTask(e,c)}processTask(e,c){return u(this,void 0,void 0,(function*(){if(""===c.type){const u=this.resolveRejects[e];if(delete this.resolveRejects[e],!u)return;return void(c.error?u.reject(nc(c.error)):u.resolve(nc(c.data)))}if(!this.messageHandlers[c.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${c.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const u=nc(c.data),p=new AbortController;this.abortControllers[e]=p;try{const f=yield this.messageHandlers[c.type](c.sourceMapId,u,p);this.completeTask(e,null,f)}catch(u){this.completeTask(e,u)}}))}completeTask(e,c,u){const p=[];delete this.abortControllers[e];const f={id:e,type:"",sourceMapId:this.mapId,origin:location.origin,error:c?ic(c):null,data:ic(u,p)};this.target.postMessage(f,{transfer:p})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},c.M=yt,c.N=function(){var e=new C(16);return C!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},c.O=function(e,c,u){var p,f,m,g,y,x,b,T,S,P,I,C,R=u[0],F=u[1],L=u[2];return c===e?(e[12]=c[0]*R+c[4]*F+c[8]*L+c[12],e[13]=c[1]*R+c[5]*F+c[9]*L+c[13],e[14]=c[2]*R+c[6]*F+c[10]*L+c[14],e[15]=c[3]*R+c[7]*F+c[11]*L+c[15]):(f=c[1],m=c[2],g=c[3],y=c[4],x=c[5],b=c[6],T=c[7],S=c[8],P=c[9],I=c[10],C=c[11],e[0]=p=c[0],e[1]=f,e[2]=m,e[3]=g,e[4]=y,e[5]=x,e[6]=b,e[7]=T,e[8]=S,e[9]=P,e[10]=I,e[11]=C,e[12]=p*R+y*F+S*L+c[12],e[13]=f*R+x*F+P*L+c[13],e[14]=m*R+b*F+I*L+c[14],e[15]=g*R+T*F+C*L+c[15]),e},c.P=p,c.Q=function(e,c,u){var p=u[0],f=u[1],m=u[2];return e[0]=c[0]*p,e[1]=c[1]*p,e[2]=c[2]*p,e[3]=c[3]*p,e[4]=c[4]*f,e[5]=c[5]*f,e[6]=c[6]*f,e[7]=c[7]*f,e[8]=c[8]*m,e[9]=c[9]*m,e[10]=c[10]*m,e[11]=c[11]*m,e[12]=c[12],e[13]=c[13],e[14]=c[14],e[15]=c[15],e},c.R=Sl,c.S=function(e,c,u){var p=c[0],f=c[1],m=c[2],g=c[3],y=c[4],x=c[5],b=c[6],T=c[7],S=c[8],P=c[9],I=c[10],C=c[11],R=c[12],F=c[13],L=c[14],B=c[15],O=u[0],V=u[1],j=u[2],G=u[3];return e[0]=O*p+V*y+j*S+G*R,e[1]=O*f+V*x+j*P+G*F,e[2]=O*m+V*b+j*I+G*L,e[3]=O*g+V*T+j*C+G*B,e[4]=(O=u[4])*p+(V=u[5])*y+(j=u[6])*S+(G=u[7])*R,e[5]=O*f+V*x+j*P+G*F,e[6]=O*m+V*b+j*I+G*L,e[7]=O*g+V*T+j*C+G*B,e[8]=(O=u[8])*p+(V=u[9])*y+(j=u[10])*S+(G=u[11])*R,e[9]=O*f+V*x+j*P+G*F,e[10]=O*m+V*b+j*I+G*L,e[11]=O*g+V*T+j*C+G*B,e[12]=(O=u[12])*p+(V=u[13])*y+(j=u[14])*S+(G=u[15])*R,e[13]=O*f+V*x+j*P+G*F,e[14]=O*m+V*b+j*I+G*L,e[15]=O*g+V*T+j*C+G*B,e},c.T=Bl,c.U=function(e,c){const u={};for(let p=0;p0||(null===(f=u.addOrUpdateProperties)||void 0===f?void 0:f.length)>0;if(!g&&!y)continue;m.push(c.geometry);const x=Object.assign({},c);if(e.set(u.id,x),g&&(m.push(u.newGeometry),x.geometry=u.newGeometry),y){if(x.properties=u.removeAllProperties?{}:Object.assign({},x.properties||{}),u.removeProperties)for(const e of u.removeProperties)delete x.properties[e];if(u.addOrUpdateProperties)for(const{key:e,value:c}of u.addOrUpdateProperties)x.properties[e]=c}}return m},c.a9=Lh,c.aA=function(e,{uSize:c,uSizeT:u},{lowerSize:p,upperSize:f}){return"source"===e.kind?p/Dp:"composite"===e.kind?qr.number(p/Dp,f/Dp,u):c},c.aB=function(e,c){var u=c[0],p=c[1],f=c[2],m=c[3],g=c[4],y=c[5],x=c[6],b=c[7],T=c[8],S=c[9],P=c[10],I=c[11],C=c[12],R=c[13],F=c[14],L=c[15],B=u*y-p*g,O=u*x-f*g,V=u*b-m*g,j=p*x-f*y,G=p*b-m*y,U=f*b-m*x,q=T*R-S*C,Z=T*F-P*C,W=T*L-I*C,J=S*F-P*R,Q=S*L-I*R,ee=P*L-I*F,se=B*ee-O*Q+V*J+j*W-G*Z+U*q;return se?(e[0]=(y*ee-x*Q+b*J)*(se=1/se),e[1]=(f*Q-p*ee-m*J)*se,e[2]=(R*U-F*G+L*j)*se,e[3]=(P*G-S*U-I*j)*se,e[4]=(x*W-g*ee-b*Z)*se,e[5]=(u*ee-f*W+m*Z)*se,e[6]=(F*V-C*U-L*O)*se,e[7]=(T*U-P*V+I*O)*se,e[8]=(g*Q-y*W+b*q)*se,e[9]=(p*W-u*Q-m*q)*se,e[10]=(C*G-R*V+L*B)*se,e[11]=(S*V-T*G-I*B)*se,e[12]=(y*Z-g*J-x*q)*se,e[13]=(u*J-p*Z+f*q)*se,e[14]=(R*O-C*j-F*B)*se,e[15]=(T*j-S*O+P*B)*se,e):null},c.aC=Q,c.aD=function(e){var c=e[0],u=e[1];return Math.sqrt(c*c+u*u)},c.aE=function(e){return e[0]=0,e[1]=0,e},c.aF=function(e,c,u){return e[0]=c[0]*u,e[1]=c[1]*u,e},c.aG=Gp,c.aH=Z,c.aI=function(e,c,u,f){const m=c.y-e.y,g=c.x-e.x,y=f.y-u.y,x=f.x-u.x,b=y*g-x*m;if(0===b)return null;const T=(x*(e.y-u.y)-y*(e.x-u.x))/b;return new p(e.x+T*g,e.y+T*m)},c.aJ=Wm,c.aK=nh,c.aL=function(e){let c=1/0,u=1/0,p=-1/0,f=-1/0;for(const m of e)c=Math.min(c,m.x),u=Math.min(u,m.y),p=Math.max(p,m.x),f=Math.max(f,m.y);return[c,u,p,f]},c.aM=Nd,c.aN=ce,c.aO=function(e,c,u,p,f=!1){if(!u[0]&&!u[1])return[0,0];const m=f?"map"===p?-e.bearingInRadians:0:"viewport"===p?e.bearingInRadians:0;if(m){const e=Math.sin(m),c=Math.cos(m);u=[u[0]*c-u[1]*e,u[0]*e+u[1]*c]}return[f?u[0]:ce(c,u[0],e.zoom),f?u[1]:ce(c,u[1],e.zoom)]},c.aQ=Lp,c.aR=y_,c.aS=vp,c.aT=Md,c.aU=Ic,c.aV=du,c.aW=$a,c.aX=io,c.aY=to,c.aZ=it,c.a_=ff,c.aa=Xh,c.ab=25,c.ac=Rh,c.ad=e=>{const c=window.document.createElement("video");return c.muted=!0,new Promise((u=>{c.onloadstart=()=>{u(c)};for(const u of e){const e=window.document.createElement("source");wt(u)||(c.crossOrigin="Anonymous"),e.src=u,c.appendChild(e)}}))},c.ae=Dt,c.af=function(){return ve++},c.ag=Fa,c.ah=yh,c.ai=Bm,c.aj=ko,c.ak=th,c.al=Zh,c.am=function(e){const c={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,u,p,f)=>{const m=p||f;return c[u]=!m||m.toLowerCase(),""})),c["max-age"]){const e=parseInt(c["max-age"],10);isNaN(e)?delete c["max-age"]:c["max-age"]=e}return c},c.an=ge,c.ao=85.051129,c.ap=tt,c.aq=function(e){return Math.pow(2,e)},c.ar=F,c.as=lf,c.at=function(e){return Math.log(e)/Math.LN2},c.au=function(e){var c=e[0],u=e[1];return c*c+u*u},c.av=function(e){if(!e.length)return new Set;const c=Math.max(...e.map((e=>e.canonical.z)));let u=1/0,p=-1/0,f=1/0,m=-1/0;const g=[];for(const y of e){const{x:e,y:x,z:b}=y.canonical,T=Math.pow(2,c-b),S=e*T,P=x*T;g.push({id:y,x:S,y:P}),Sp&&(p=S),Pm&&(m=P)}const y=new Set;for(const e of g)e.x!==u&&e.x!==p&&e.y!==f&&e.y!==m||y.add(e.id);return y},c.aw=function(e,c){const u=Math.abs(2*e.wrap)-+(e.wrap<0),p=Math.abs(2*c.wrap)-+(c.wrap<0);return e.overscaledZ-c.overscaledZ||p-u||c.canonical.y-e.canonical.y||c.canonical.x-e.canonical.x},c.ax=class{constructor(e,c){this.max=e,this.onRemove=c,this.reset()}reset(){for(const e in this.data)for(const c of this.data[e])c.timeout&&clearTimeout(c.timeout),this.onRemove(c.value);return this.data={},this.order=[],this}add(e,c,u){const p=e.wrapped().key;void 0===this.data[p]&&(this.data[p]=[]);const f={value:c,timeout:void 0};if(void 0!==u&&(f.timeout=setTimeout((()=>{this.remove(e,f)}),u)),this.data[p].push(f),this.order.push(p),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const c=this.data[e].shift();return c.timeout&&clearTimeout(c.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),c.value}getByKey(e){const c=this.data[e];return c?c[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,c){if(!this.has(e))return this;const u=e.wrapped().key,p=void 0===c?0:this.data[u].indexOf(c),f=this.data[u][p];return this.data[u].splice(p,1),f.timeout&&clearTimeout(f.timeout),0===this.data[u].length&&delete this.data[u],this.onRemove(f.value),this.order.splice(this.order.indexOf(u),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const c=[];for(const u in this.data)for(const p of this.data[u])e(p.value)||c.push(p);for(const e of c)this.remove(e.value.tileID,e)}},c.ay=function(e,c){let u=0,p=0;if("constant"===e.kind)p=e.layoutSize;else if("source"!==e.kind){const{interpolationType:f,minZoom:m,maxZoom:g}=e,y=f?ge(fr.interpolationFactor(f,c,m,g),0,1):0;"camera"===e.kind?p=qr.number(e.minSize,e.maxSize,y):u=y}return{uSizeT:u,uSize:p}},c.b=Ge,c.b$=Ao,c.b0=V,c.b1=function(e){var c=new C(3);return c[0]=e[0],c[1]=e[1],c[2]=e[2],c},c.b2=function(e,c,u){return e[0]=c[0]-u[0],e[1]=c[1]-u[1],e[2]=c[2]-u[2],e},c.b3=function(e,c){var u=c[0],p=c[1],f=c[2],m=u*u+p*p+f*f;return m>0&&(m=1/Math.sqrt(m)),e[0]=c[0]*m,e[1]=c[1]*m,e[2]=c[2]*m,e},c.b4=G,c.b5=function(e,c){return e[0]*c[0]+e[1]*c[1]+e[2]*c[2]},c.b6=function(e,c,u){return e[0]=c[0]*u[0],e[1]=c[1]*u[1],e[2]=c[2]*u[2],e[3]=c[3]*u[3],e},c.b7=B,c.b8=function(e,c,u){const p=c[0]*u[0]+c[1]*u[1]+c[2]*u[2];return 0===p?null:(-(e[0]*u[0]+e[1]*u[1]+e[2]*u[2])-u[3])/p},c.b9=q,c.bA=function(){return new Float64Array(3)},c.bB=J,c.bC=function(e,c,u){var p=u[0],f=u[1],m=u[2],g=u[3],y=c[0],x=c[1],b=c[2],T=f*b-m*x,S=m*y-p*b,P=p*x-f*y;return e[0]=y+g*(T+=T)+f*(P+=P)-m*(S+=S),e[1]=x+g*S+m*T-p*P,e[2]=b+g*P+p*S-f*T,e},c.bD=function(e,c,u){const p=(f=[e[0],e[1],e[2],c[0],c[1],c[2],u[0],u[1],u[2]])[0]*((T=f[8])*(g=f[4])-(y=f[5])*(b=f[7]))+f[1]*(-T*(m=f[3])+y*(x=f[6]))+f[2]*(b*m-g*x);var f,m,g,y,x,b,T;if(0===p)return null;const S=G([],[c[0],c[1],c[2]],[u[0],u[1],u[2]]),P=G([],[u[0],u[1],u[2]],[e[0],e[1],e[2]]),I=G([],[e[0],e[1],e[2]],[c[0],c[1],c[2]]),C=j([],S,-e[3]);return V(C,C,j([],P,-c[3])),V(C,C,j([],I,-u[3])),j(C,C,1/p),C},c.bE=Kp,c.bF=function(){return new Float64Array(4)},c.bG=function(e,c,u,p){var f=[],m=[];return f[0]=c[0]-u[0],f[1]=c[1]-u[1],f[2]=c[2]-u[2],m[0]=f[0]*Math.cos(p)-f[1]*Math.sin(p),m[1]=f[0]*Math.sin(p)+f[1]*Math.cos(p),m[2]=f[2],e[0]=m[0]+u[0],e[1]=m[1]+u[1],e[2]=m[2]+u[2],e},c.bH=function(e,c,u,p){var f=[],m=[];return f[0]=c[0]-u[0],f[1]=c[1]-u[1],f[2]=c[2]-u[2],m[0]=f[0],m[1]=f[1]*Math.cos(p)-f[2]*Math.sin(p),m[2]=f[1]*Math.sin(p)+f[2]*Math.cos(p),e[0]=m[0]+u[0],e[1]=m[1]+u[1],e[2]=m[2]+u[2],e},c.bI=function(e,c,u,p){var f=[],m=[];return f[0]=c[0]-u[0],f[1]=c[1]-u[1],f[2]=c[2]-u[2],m[0]=f[2]*Math.sin(p)+f[0]*Math.cos(p),m[1]=f[1],m[2]=f[2]*Math.cos(p)-f[0]*Math.sin(p),e[0]=m[0]+u[0],e[1]=m[1]+u[1],e[2]=m[2]+u[2],e},c.bJ=function(e,c,u){var p=Math.sin(u),f=Math.cos(u),m=c[0],g=c[1],y=c[2],x=c[3],b=c[8],T=c[9],S=c[10],P=c[11];return c!==e&&(e[4]=c[4],e[5]=c[5],e[6]=c[6],e[7]=c[7],e[12]=c[12],e[13]=c[13],e[14]=c[14],e[15]=c[15]),e[0]=m*f-b*p,e[1]=g*f-T*p,e[2]=y*f-S*p,e[3]=x*f-P*p,e[8]=m*p+b*f,e[9]=g*p+T*f,e[10]=y*p+S*f,e[11]=x*p+P*f,e},c.bK=function(e,c){const u=he(e,360),p=he(c,360),f=p-u,m=p>u?f-360:f+360;return Math.abs(f)0?g:-g},c.bN=function(e,c){const u=he(e,2*Math.PI),p=he(c,2*Math.PI);return Math.min(Math.abs(u-p),Math.abs(u-p+2*Math.PI),Math.abs(u-p-2*Math.PI))},c.bO=function(){const e={},c=Et.$version;for(const u in Et.$root){const p=Et.$root[u];if(p.required){let f=null;f="version"===u?c:"array"===p.type?[]:{},null!=f&&(e[u]=f)}}return e},c.bP=vt,c.bQ=xs,c.bR=function e(c,u){if(Array.isArray(c)){if(!Array.isArray(u)||c.length!==u.length)return!1;for(let p=0;p"raster"===e.type,c.bV=Se,c.bW=function(e,c){if(!e)return[{command:"setStyle",args:[c]}];let u=[];try{if(!kt(e.version,c.version))return[{command:"setStyle",args:[c]}];kt(e.center,c.center)||u.push({command:"setCenter",args:[c.center]}),kt(e.state,c.state)||u.push({command:"setGlobalState",args:[c.state]}),kt(e.centerAltitude,c.centerAltitude)||u.push({command:"setCenterAltitude",args:[c.centerAltitude]}),kt(e.zoom,c.zoom)||u.push({command:"setZoom",args:[c.zoom]}),kt(e.bearing,c.bearing)||u.push({command:"setBearing",args:[c.bearing]}),kt(e.pitch,c.pitch)||u.push({command:"setPitch",args:[c.pitch]}),kt(e.roll,c.roll)||u.push({command:"setRoll",args:[c.roll]}),kt(e.sprite,c.sprite)||u.push({command:"setSprite",args:[c.sprite]}),kt(e.glyphs,c.glyphs)||u.push({command:"setGlyphs",args:[c.glyphs]}),kt(e.transition,c.transition)||u.push({command:"setTransition",args:[c.transition]}),kt(e.light,c.light)||u.push({command:"setLight",args:[c.light]}),kt(e.terrain,c.terrain)||u.push({command:"setTerrain",args:[c.terrain]}),kt(e.sky,c.sky)||u.push({command:"setSky",args:[c.sky]}),kt(e.projection,c.projection)||u.push({command:"setProjection",args:[c.projection]});const p={},f=[];!function(e,c,u,p){let f;for(f in c=c||{},e=e||{})Object.prototype.hasOwnProperty.call(e,f)&&(Object.prototype.hasOwnProperty.call(c,f)||jt(f,u,p));for(f in c)Object.prototype.hasOwnProperty.call(c,f)&&(Object.prototype.hasOwnProperty.call(e,f)?kt(e[f],c[f])||("geojson"===e[f].type&&"geojson"===c[f].type&&Ut(e,c,f)?Lt(u,{command:"setGeoJSONSourceData",args:[f,c[f].data]}):Gt(f,c,u,p)):Ot(f,c,u))}(e.sources,c.sources,f,p);const m=[];e.layers&&e.layers.forEach((e=>{"source"in e&&p[e.source]?u.push({command:"removeLayer",args:[e.id]}):m.push(e)})),u=u.concat(f),function(e,c,u){c=c||[];const p=(e=e||[]).map(Yt),f=c.map(Yt),m=e.reduce(Kt,{}),g=c.reduce(Kt,{}),y=p.slice(),x=Object.create(null);let b,T,S,P,I;for(let e=0,c=0;eI?(f=Math.acos(m),g=Math.sin(f),y=Math.sin((1-p)*f)/g,x=Math.sin(p*f)/g):(y=1-p,x=p),e[0]=y*b+x*C,e[1]=y*T+x*R,e[2]=y*S+x*F,e[3]=y*P+x*L,e},c.bn=function(e){const c=new Float64Array(9);var u,p,f,m,g,y,x,b,T,S,P,I,C,R,F,L,B,O;S=(f=(p=e)[0])*(x=f+f),P=(m=p[1])*x,C=(g=p[2])*x,R=g*(b=m+m),L=(y=p[3])*x,B=y*b,O=y*(T=g+g),(u=c)[0]=1-(I=m*b)-(F=g*T),u[3]=P-O,u[6]=C+B,u[1]=P+O,u[4]=1-S-F,u[7]=R-L,u[2]=C-B,u[5]=R+L,u[8]=1-S-I;const V=it(-Math.asin(ge(c[2],-1,1)));let j,G;return Math.hypot(c[5],c[8])<.001?(j=0,G=-it(Math.atan2(c[3],c[4]))):(j=it(0===c[5]&&0===c[8]?0:Math.atan2(c[5],c[8])),G=it(0===c[1]&&0===c[0]?0:Math.atan2(c[1],c[0]))),{roll:j,pitch:V+90,bearing:G}},c.bo=function(e,c){return e.roll==c.roll&&e.pitch==c.pitch&&e.bearing==c.bearing},c.bp=Ie,c.bq=_o,c.br=Wu,c.bs=Hu,c.bt=fu,c.bu=ue,c.bv=de,c.bw=Re,c.bx=function(e,c,u,p,f){return ue(p,f,ge((e-c)/(u-c),0,1))},c.by=function(e,c,u,p){return e[0]=c[0]+u[0]*p,e[1]=c[1]+u[1]*p,e[2]=c[2]+u[2]*p,e},c.bz=he,c.c=pt,c.c$=class{constructor(e){this.start=`${e}#start`,this.end=`${e}#end`,this.measure=e,performance.mark(this.start)}finish(){performance.mark(this.end);let e=performance.getEntriesByName(this.measure);return 0===e.length&&(performance.measure(this.measure,this.start,this.end),e=performance.getEntriesByName(this.measure),performance.clearMarks(this.start),performance.clearMarks(this.end),performance.clearMeasures(this.measure)),e}},c.c0=class extends wo{constructor(e,c){super(e,c),this.current=Wc}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let c=1;c<16;c++)if(e[c]!==this.current[c]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},c.c1=So,c.c2=class extends wo{constructor(e,c){super(e,c),this.current=[0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]||(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},c.c3=class extends wo{constructor(e,c){super(e,c),this.current=[0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]||(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},c.c4=R,c.c5=function(e,c){var u=Math.sin(c),p=Math.cos(c);return e[0]=p,e[1]=u,e[2]=0,e[3]=-u,e[4]=p,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},c.c6=function(e,c,u){var p=c[0],f=c[1],m=c[2];return e[0]=p*u[0]+f*u[3]+m*u[6],e[1]=p*u[1]+f*u[4]+m*u[7],e[2]=p*u[2]+f*u[5]+m*u[8],e},c.c7=function(e,c,u,p,f,m,g){var y=1/(c-u),x=1/(p-f),b=1/(m-g);return e[0]=-2*y,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*x,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*b,e[11]=0,e[12]=(c+u)*y,e[13]=(f+p)*x,e[14]=(g+m)*b,e[15]=1,e},c.c8=class extends wo{constructor(e,c){super(e,c),this.current=new Array}set(e){if(e!=this.current){this.current=e;const c=new Float32Array(4*e.length);for(let u=0;u25||p<0||p>=1||u<0||u>=1)},c.cF=function(e,c){return e[0]=c[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=c[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},c.cG=class extends aa{},c.cH=F_,c.cJ=ct,c.cK=function(e,c){pt.REGISTERED_PROTOCOLS[e]=c},c.cL=function(e){delete pt.REGISTERED_PROTOCOLS[e]},c.cM=function(e,c){const u={};for(let p=0;pe*Nd))}let O=x?"center":f.get("text-justify").evaluate(m,{},e.canonical);const V="point"===f.get("symbol-placement")?f.get("text-max-width").evaluate(m,{},e.canonical)*Nd:1/0,j=()=>{e.bucket.allowVerticalPlacement&&hc(u)&&(R.vertical=xp(F,e.glyphMap,e.glyphPositions,e.imagePositions,S,V,y,C,"left",T,B,c.az.vertical,!0,I,P))};if(!x&&L){const u=new Set;if("auto"===O)for(let e=0;e=this.maxEntries){const e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,c)}clear(){this.map.clear()}},c.cY=Lu,c.cZ=Ec,c.c_=zf,c.ca=class extends xa{},c.cb=Vd,c.cc=class extends ba{},c.cd=iu,c.ce=function(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},c.cf=tu,c.cg=function(e,c,u){var p=c[0],f=c[1],m=c[2],g=u[3]*p+u[7]*f+u[11]*m+u[15];return e[0]=(u[0]*p+u[4]*f+u[8]*m+u[12])/(g=g||1),e[1]=(u[1]*p+u[5]*f+u[9]*m+u[13])/g,e[2]=(u[2]*p+u[6]*f+u[10]*m+u[14])/g,e},c.ch=class extends oa{},c.ci=class extends Ia{},c.cj=function(e,c){return e[0]===c[0]&&e[1]===c[1]&&e[2]===c[2]&&e[3]===c[3]&&e[4]===c[4]&&e[5]===c[5]&&e[6]===c[6]&&e[7]===c[7]&&e[8]===c[8]&&e[9]===c[9]&&e[10]===c[10]&&e[11]===c[11]&&e[12]===c[12]&&e[13]===c[13]&&e[14]===c[14]&&e[15]===c[15]},c.ck=function(e,c){var u=e[0],p=e[1],f=e[2],m=e[3],g=e[4],y=e[5],x=e[6],b=e[7],T=e[8],S=e[9],P=e[10],C=e[11],R=e[12],F=e[13],L=e[14],B=e[15],O=c[0],V=c[1],j=c[2],G=c[3],U=c[4],q=c[5],Z=c[6],W=c[7],J=c[8],Q=c[9],ee=c[10],se=c[11],ce=c[12],he=c[13],ue=c[14],de=c[15];return Math.abs(u-O)<=I*Math.max(1,Math.abs(u),Math.abs(O))&&Math.abs(p-V)<=I*Math.max(1,Math.abs(p),Math.abs(V))&&Math.abs(f-j)<=I*Math.max(1,Math.abs(f),Math.abs(j))&&Math.abs(m-G)<=I*Math.max(1,Math.abs(m),Math.abs(G))&&Math.abs(g-U)<=I*Math.max(1,Math.abs(g),Math.abs(U))&&Math.abs(y-q)<=I*Math.max(1,Math.abs(y),Math.abs(q))&&Math.abs(x-Z)<=I*Math.max(1,Math.abs(x),Math.abs(Z))&&Math.abs(b-W)<=I*Math.max(1,Math.abs(b),Math.abs(W))&&Math.abs(T-J)<=I*Math.max(1,Math.abs(T),Math.abs(J))&&Math.abs(S-Q)<=I*Math.max(1,Math.abs(S),Math.abs(Q))&&Math.abs(P-ee)<=I*Math.max(1,Math.abs(P),Math.abs(ee))&&Math.abs(C-se)<=I*Math.max(1,Math.abs(C),Math.abs(se))&&Math.abs(R-ce)<=I*Math.max(1,Math.abs(R),Math.abs(ce))&&Math.abs(F-he)<=I*Math.max(1,Math.abs(F),Math.abs(he))&&Math.abs(L-ue)<=I*Math.max(1,Math.abs(L),Math.abs(ue))&&Math.abs(B-de)<=I*Math.max(1,Math.abs(B),Math.abs(de))},c.cl=function(e,c){return e[0]=c[0],e[1]=c[1],e[2]=c[2],e[3]=c[3],e[4]=c[4],e[5]=c[5],e[6]=c[6],e[7]=c[7],e[8]=c[8],e[9]=c[9],e[10]=c[10],e[11]=c[11],e[12]=c[12],e[13]=c[13],e[14]=c[14],e[15]=c[15],e},c.cm=e=>"symbol"===e.type,c.cn=e=>"circle"===e.type,c.co=e=>"heatmap"===e.type,c.cp=e=>"line"===e.type,c.cq=e=>"fill"===e.type,c.cr=e=>"fill-extrusion"===e.type,c.cs=e=>"hillshade"===e.type,c.ct=e=>"color-relief"===e.type,c.cu=e=>"background"===e.type,c.cv=e=>"custom"===e.type,c.cw=fe,c.cx=function(e,c,u){if(c<=0)return e;const p=1/c;return void 0===u||Math.abs(u)<1e-10?Math.round(e*p)/p:(u>0?Math.ceil(e*p-1e-9):Math.floor(e*p+1e-10))/p},c.cy=function(e,c,u){const p=ee(c.x-u.x,c.y-u.y),f=ee(e.x-u.x,e.y-u.y);var m,g;return it(Math.atan2(p[0]*f[1]-p[1]*f[0],(m=p)[0]*(g=f)[0]+m[1]*g[1]))},c.cz=me,c.d=wt,c.d0=function(c,p,f,m,g){return u(this||e,void 0,void 0,(function*(){if(P())try{return yield $e(c,p,f,m,g)}catch(e){}return function(e,c,u,p,f){const m=e.width,g=e.height;He&&Ye||(He=new OffscreenCanvas(m,g),Ye=He.getContext("2d",{willReadFrequently:!0})),He.width=m,He.height=g,Ye.drawImage(e,0,0,m,g);const y=Ye.getImageData(c,u,p,f);return Ye.clearRect(0,0,m,g),y.data}(c,p,f,m,g)}))},c.d1=Vl,c.d2=f,c.d3=class{constructor(e,c){this.layers={[Bm]:this},this.name=Bm,this.version=c?c.version:1,this.extent=c?c.extent:4096,this.length=e.length,this.features=e}feature(e){return new Bf(this.features[e],this.extent)}},c.d4=Ws,c.d5=vc,c.e=xe,c.f=e=>u(void 0,void 0,void 0,(function*(){if(0===e.byteLength)return createImageBitmap(new ImageData(1,1));const c=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(c)}catch(e){throw new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),c.g=ft,c.h=e=>new Promise(((c,u)=>{const p=new Image;p.onload=()=>{c(p),URL.revokeObjectURL(p.src),p.onload=null,window.requestAnimationFrame((()=>{p.src=Ue}))},p.onerror=()=>u(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const f=new Blob([new Uint8Array(e)],{type:"image/png"});p.src=e.byteLength?URL.createObjectURL(f):Ue})),c.i=Ae,c.j=(e,c)=>bt(xe(e,{type:"json"}),c),c.k=gt,c.l=mt,c.m=bt,c.n=(e,c)=>bt(xe(e,{type:"arrayBuffer"}),c),c.o=function(e){return new Ec(e).readFields(fp,[])},c.p=gp,c.q=function(e){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))},c.r=_l,c.s=et,c.t=Hs,c.u=Et,c.v=ql,c.w=Ee,c.x=Os,c.y=Zl,c.z=wc}));p("worker",["./shared"],(function(e){class t{constructor(e,c){this.keyCache={},e&&this.replace(e,c)}replace(e,c){this._layerConfigs={},this._layers={},this.update(e,[],c)}update(c,u,p){for(const u of c){this._layerConfigs[u.id]=u;const c=this._layers[u.id]=e.bT(u,p);c._featureFilter=e.aj(c.filter,p),this.keyCache[u.id]&&delete this.keyCache[u.id]}for(const e of u)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const f=e.cM(Object.values(this._layerConfigs),this.keyCache);for(const c of f){const u=c.map((e=>this._layers[e.id])),p=u[0];if(p.isHidden())continue;const f=p.source||"";let m=this.familiesBySource[f];m||(m=this.familiesBySource[f]={});const g=p.sourceLayer||e.ai;let y=m[g];y||(y=m[g]=[]),y.push(u)}}}class o{constructor(c){const u={},p=[];for(const e in c){const f=c[e],m=u[e]={};for(const e in f){const c=f[+e];if(!c||0===c.bitmap.width||0===c.bitmap.height)continue;const u={x:0,y:0,w:c.bitmap.width+2,h:c.bitmap.height+2};p.push(u),m[e]={rect:u,metrics:c.metrics}}}const{w:f,h:m}=e.p(p),g=new e.r({width:f||1,height:m||1});for(const p in c){const f=c[p];for(const c in f){const m=f[+c];if(!m||0===m.bitmap.width||0===m.bitmap.height)continue;const y=u[p][c].rect;e.r.copy(m.bitmap,g,{x:0,y:0},{x:y.x+1,y:y.y+1},m.bitmap)}}this.image=g,this.positions=u}}e.cN("GlyphAtlas",o);class s{constructor(c){this.tileID=new e.a2(c.tileID.overscaledZ,c.tileID.wrap,c.tileID.canonical.z,c.tileID.canonical.x,c.tileID.canonical.y),this.uid=c.uid,this.zoom=c.zoom,this.pixelRatio=c.pixelRatio,this.tileSize=c.tileSize,this.source=c.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=c.showCollisionBoxes,this.collectResourceTiming=!!c.collectResourceTiming,this.returnDependencies=!!c.returnDependencies,this.promoteId=c.promoteId,this.inFlightDependencies=[]}parse(u,p,f,m,g){return e._(this,void 0,void 0,(function*(){this.status="parsing",this.data=u,this.collisionBoxArray=new e.ag;const y=new e.cO(Object.keys(u.layers).sort()),x=new e.cP(this.tileID,this.promoteId);x.bucketLayerIDs=[];const b={},T={featureIndex:x,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:f,subdivisionGranularity:g},S=p.familiesBySource[this.source];for(const p in S){const m=u.layers[p];if(!m)continue;1===m.version&&e.w(`Vector tile source "${this.source}" layer "${p}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const g=y.encode(p),P=[];for(let e=0;ee.id))))}}const P=e.bY(T.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.abort())),this.inFlightDependencies=[];let I=Promise.resolve({});if(Object.keys(P).length){const e=new AbortController;this.inFlightDependencies.push(e),I=m.sendAsync({type:"GG",data:{stacks:P,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const C=Object.keys(T.iconDependencies);let R=Promise.resolve({});if(C.length){const e=new AbortController;this.inFlightDependencies.push(e),R=m.sendAsync({type:"GI",data:{icons:C,source:this.source,tileID:this.tileID,type:"icons"}},e)}const F=Object.keys(T.patternDependencies);let L=Promise.resolve({});if(F.length){const e=new AbortController;this.inFlightDependencies.push(e),L=m.sendAsync({type:"GI",data:{icons:F,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const B=T.dashDependencies;let O=Promise.resolve({});if(Object.keys(B).length){const e=new AbortController;this.inFlightDependencies.push(e),O=m.sendAsync({type:"GDA",data:{dashes:B}},e)}const[V,j,G,U]=yield Promise.all([I,R,L,O]),q=new o(V),Z=new e.cQ(j,G);for(const u in b){const p=b[u];p instanceof e.ah?(c(p.layers,this.zoom,f),e.cR({bucket:p,glyphMap:V,glyphPositions:q.positions,imageMap:j,imagePositions:Z.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:T.subdivisionGranularity})):p.hasDependencies&&(p instanceof e.cS||p instanceof e.cT||p instanceof e.cU)&&(c(p.layers,this.zoom,f),p.addFeatures(T,this.tileID.canonical,Z.patternPositions,U))}return this.status="done",{buckets:Object.values(b).filter((e=>!e.isEmpty())),featureIndex:x,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:q.image,imageAtlas:Z,dashPositions:U,glyphMap:this.returnDependencies?V:null,iconMap:this.returnDependencies?j:null,glyphPositions:this.returnDependencies?q.positions:null}}))}}function c(c,u,p){const f=new e.H(u);for(const e of c)e.recalculate(f,p)}class r{constructor(){this.loading={},this.loaded={},this.parsing={}}startLoading(e,c){this.loading[e]=c}finishLoading(e){delete this.loading[e]}abort(e){const c=this.loading[e];(null==c?void 0:c.abort)&&(c.abort.abort(),delete this.loading[e])}setParsing(e,c){this.parsing[e]=c}consumeParsing(e){const c=this.parsing[e];if(c)return delete this.parsing[e],c}clearParsing(e){delete this.parsing[e]}markLoaded(e,c){this.loaded[e]=c}getLoaded(e){const c=this.loaded[e];if(c)return c}removeLoaded(e){delete this.loaded[e]}clearLoaded(){this.loaded={}}}class n{constructor(e,c,u,p,f){this.type=e,this.properties=u||{},this.extent=f,this.pointsArray=c,this.id=p}loadGeometry(){return this.pointsArray.map((c=>c.map((c=>new e.P(c.x,c.y)))))}}class a{constructor(e,c,u){this.version=2,this._myFeatures=e,this.name=c,this.length=e.length,this.extent=u}feature(e){return this._myFeatures[e]}}class l{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}}function u(c){let u=e.cV(c);return 0===u.byteOffset&&u.byteLength===u.buffer.byteLength||(u=new Uint8Array(u)),{vectorTile:c,rawData:u.buffer}}function p(c,u,p){const{extent:f}=c,m=Math.pow(2,p.z-u.z),g=(p.x-u.x*m)*f,y=(p.y-u.y*m)*f,x=[];for(let u=0;u0&&T.addLayer(m)}const P=u(T);return this.overzoomedTileResultCache.set(x,P),P}reloadTile(c){return e._(this,void 0,void 0,(function*(){const e=c.uid,u=this.tileState.getLoaded(e);if(!u)throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");if(u.showCollisionBoxes=c.showCollisionBoxes,"parsing"===u.status){const p=this.tileState.consumeParsing(e);return yield this._parseWorkerTile(u,c,p)}if("done"===u.status&&u.vectorTile)return yield this._parseWorkerTile(u,c)}))}abortTile(c){return e._(this,void 0,void 0,(function*(){this.tileState.abort(c.uid)}))}removeTile(c){return e._(this,void 0,void 0,(function*(){this.tileState.removeLoaded(c.uid)}))}}class d{constructor(){this.loaded={}}loadTile(c){return e._(this,void 0,void 0,(function*(){const{uid:u,encoding:p,rawImageData:f,redFactor:m,greenFactor:g,blueFactor:y,baseShift:x}=c,b=f.width+2,T=f.height+2,S=e.b(f)?new e.R({width:b,height:T},yield e.d0(f,-1,-1,b,T)):f,P=new e.d1(u,S,p,m,g,y,x);return this.loaded=this.loaded||{},this.loaded[u]=P,P}))}removeTile(e){const c=this.loaded,u=e.uid;c&&c[u]&&delete c[u]}}var f,m,g=function(){if(m)return f;function e(e,u){if(0!==e.length){c(e[0],u);for(var p=1;p=Math.abs(y)?u-x+y:y-x+u,u=x}u+p>=0!=!!c&&e.reverse()}return m=1,f=function c(u,p){var f,m=u&&u.type;if("FeatureCollection"===m)for(f=0;fe},b=Math.fround||(T=new Float32Array(1),e=>(T[0]=+e,T[0]));var T;class _{constructor(e){this.options=Object.assign(Object.create(x),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:c,minZoom:u,maxZoom:p}=this.options;c&&console.time("total time");const f=`prepare ${e.length} points`;c&&console.time(f),this.points=e;const m=[];for(let c=0;c=u;e--){const u=+Date.now();g=this.trees[e]=this._createTree(this._cluster(g,e)),c&&console.log("z%d: %d clusters in %dms",e,g.numItems,+Date.now()-u)}return c&&console.timeEnd("total time"),this}getClusters(e,c){let u=((e[0]+180)%360+360)%360-180;const p=Math.max(-90,Math.min(90,e[1]));let f=180===e[2]?180:((e[2]+180)%360+360)%360-180;const m=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)u=-180,f=180;else if(u>f){const e=this.getClusters([u,p,180,m],c),g=this.getClusters([-180,p,f,m],c);return e.concat(g)}const g=this.trees[this._limitZoom(c)],y=g.range(I(u),C(m),I(f),C(p)),x=g.data,b=[];for(const e of y){const c=this.stride*e;b.push(x[c+5]>1?S(x,c,this.clusterProps):this.points[x[c+3]])}return b}getChildren(e){const c=this._getOriginId(e),u=this._getOriginZoom(e),p="No cluster with the specified id.",f=this.trees[u];if(!f)throw new Error(p);const m=f.data;if(c*this.stride>=m.length)throw new Error(p);const g=this.options.radius/(this.options.extent*Math.pow(2,u-1)),y=f.within(m[c*this.stride],m[c*this.stride+1],g),x=[];for(const c of y){const u=c*this.stride;m[u+4]===e&&x.push(m[u+5]>1?S(m,u,this.clusterProps):this.points[m[u+3]])}if(0===x.length)throw new Error(p);return x}getLeaves(e,c,u){const p=[];return this._appendLeaves(p,e,c=c||10,u=u||0,0),p}getTile(e,c,u){const p=this.trees[this._limitZoom(e)],f=Math.pow(2,e),{extent:m,radius:g}=this.options,y=g/m,x=(u-y)/f,b=(u+1+y)/f,T={features:[]};return this._addTileFeatures(p.range((c-y)/f,x,(c+1+y)/f,b),p.data,c,u,f,T),0===c&&this._addTileFeatures(p.range(1-y/f,x,1,b),p.data,f,u,f,T),c===f-1&&this._addTileFeatures(p.range(0,x,y/f,b),p.data,-1,u,f,T),T.features.length?T:null}getClusterExpansionZoom(e){let c=this._getOriginZoom(e)-1;for(;c<=this.options.maxZoom;){const u=this.getChildren(e);if(c++,1!==u.length)break;e=u[0].properties.cluster_id}return c}_appendLeaves(e,c,u,p,f){const m=this.getChildren(c);for(const c of m){const m=c.properties;if(m&&m.cluster?f+m.point_count<=p?f+=m.point_count:f=this._appendLeaves(e,m.cluster_id,u,p,f):f1;let x,b,T;if(y)x=P(c,e,this.clusterProps),b=c[e],T=c[e+1];else{const u=this.points[c[e+3]];x=u.properties;const[p,f]=u.geometry.coordinates;b=I(p),T=C(f)}const S={type:1,geometry:[[Math.round(this.options.extent*(b*f-u)),Math.round(this.options.extent*(T*f-p))]],tags:x};let R;R=y||this.options.generateId?c[e+3]:this.points[c[e+3]].id,void 0!==R&&(S.id=R),m.features.push(S)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,c){const{radius:u,extent:p,reduce:f,minPoints:m}=this.options,g=u/(p*Math.pow(2,c)),y=e.data,x=[],b=this.stride;for(let u=0;uc&&(I+=y[u+5])}if(I>P&&I>=m){let e,m=p*P,g=T*P,C=-1;const R=(u/b<<5)+(c+1)+this.points.length;for(const p of S){const x=p*b;if(y[x+2]<=c)continue;y[x+2]=c;const T=y[x+5];m+=y[x]*T,g+=y[x+1]*T,y[x+4]=R,f&&(e||(e=this._map(y,u,!0),C=this.clusterProps.length,this.clusterProps.push(e)),f(e,this._map(y,x)))}y[u+4]=R,x.push(m/I,g/I,1/0,R,-1,I),f&&x.push(C)}else{for(let e=0;e1)for(const e of S){const u=e*b;if(!(y[u+2]<=c)){y[u+2]=c;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,c,u){if(e[c+5]>1){const p=this.clusterProps[e[c+6]];return u?Object.assign({},p):p}const p=this.points[e[c+3]].properties,f=this.options.map(p);return u&&f===p?Object.assign({},f):f}}function S(e,c,u){return{type:"Feature",id:e[c+3],properties:P(e,c,u),geometry:{type:"Point",coordinates:[(p=e[c],360*(p-.5)),R(e[c+1])]}};var p}function P(e,c,u){const p=e[c+5],f=p>=1e4?`${Math.round(p/1e3)}k`:p>=1e3?Math.round(p/100)/10+"k":p,m=e[c+6],g=-1===m?{}:Object.assign({},u[m]);return Object.assign(g,{cluster:!0,cluster_id:e[c+3],point_count:p,point_count_abbreviated:f})}function I(e){return e/360+.5}function C(e){const c=Math.sin(e*Math.PI/180),u=.5-.25*Math.log((1+c)/(1-c))/Math.PI;return u<0?0:u>1?1:u}function R(e){const c=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(c))/Math.PI-90}function F(e,c,u,p){let f=p;const m=c+(u-c>>1);let g,y=u-c;const x=e[c],b=e[c+1],T=e[u],S=e[u+1];for(let p=c+3;pf)g=p,f=c;else if(c===f){const e=Math.abs(p-m);ep&&(g-c>3&&F(e,c,g,p),e[g+2]=f,u-g>3&&F(e,g,u,p))}function L(e,c,u,p,f,m){let g=f-u,y=m-p;if(0!==g||0!==y){const x=((e-u)*g+(c-p)*y)/(g*g+y*y);x>1?(u=f,p=m):x>0&&(u+=g*x,p+=y*x)}return g=e-u,y=c-p,g*g+y*y}function B(e,c,u,p){const f={type:c,geom:u},m={id:null==e?null:e,type:f.type,geometry:f.geom,tags:p,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};switch(f.type){case"Point":case"MultiPoint":case"LineString":O(m,f.geom);break;case"Polygon":O(m,f.geom[0]);break;case"MultiLineString":for(const e of f.geom)O(m,e);break;case"MultiPolygon":for(const e of f.geom)O(m,e[0])}return m}function O(e,c){for(let u=0;u0&&(g+=p?(f*x-y*m)/2:Math.sqrt(Math.pow(y-f,2)+Math.pow(x-m,2))),f=y,m=x}const y=c.length-3;c[2]=1,u>0&&F(c,0,y,u),c[y+2]=1,c.size=Math.abs(g),c.start=0,c.end=c.size}function q(e,c,u,p){for(let f=0;f1?1:u}function J(e,c,u,p,f,m,g,y){if(p/=c,m>=(u/=c)&&g=p)return null;const x=[];for(const c of e){const e=0===f?c.minX:c.minY,m=0===f?c.maxX:c.maxY;if(e>=u&&m=p))switch(c.type){case"Point":case"MultiPoint":{const e=[];if(Q(c.geometry,e,u,p,f),!e.length)continue;x.push(B(c.id,3===e.length?"Point":"MultiPoint",e,c.tags));continue}case"LineString":{const e=[];if(ee(c.geometry,e,u,p,f,!1,y.lineMetrics),!e.length)continue;if(y.lineMetrics){for(const u of e)x.push(B(c.id,c.type,u,c.tags));continue}if(e.length>1){x.push(B(c.id,"MultiLineString",e,c.tags));continue}x.push(B(c.id,c.type,e[0],c.tags));continue}case"MultiLineString":{const e=[];if(ce(c.geometry,e,u,p,f,!1),!e.length)continue;if(1===e.length){x.push(B(c.id,"LineString",e[0],c.tags));continue}x.push(B(c.id,c.type,e,c.tags));continue}case"Polygon":{const e=[];if(ce(c.geometry,e,u,p,f,!0),!e.length)continue;x.push(B(c.id,c.type,e,c.tags));continue}case"MultiPolygon":{const e=[];for(const m of c.geometry){const c=[];ce(m,c,u,p,f,!0),c.length&&e.push(c)}if(!e.length)continue;x.push(B(c.id,c.type,e,c.tags));continue}}}return x.length?x:null}function Q(e,c,u,p,f){for(let m=0;m=u&&g<=p&&he(c,e[m],e[m+1],e[m+2])}}function ee(e,c,u,p,f,m,g){let y=se(e);const x=0===f?ue:de;let b,T,S=e.start;for(let P=0;Pu&&(T=x(y,I,C,F,L,u),g&&(y.start=S+b*T)):B>p?O=u&&(T=x(y,I,C,F,L,u),V=!0),O>p&&B<=p&&(T=x(y,I,C,F,L,p),V=!0),!m&&V&&(g&&(y.end=S+b*T),c.push(y),y=se(e)),g&&(S+=b)}let P=e.length-3;const I=e[P],C=e[P+1],R=0===f?I:C;R>=u&&R<=p&&he(y,I,C,e[P+2]),P=y.length-3,m&&P>=3&&(y[P]!==y[0]||y[P+1]!==y[1])&&he(y,y[0],y[1],y[2]),y.length&&c.push(y)}function se(e){const c=[];return c.size=e.size,c.start=e.start,c.end=e.end,c}function ce(e,c,u,p,f,m){for(const g of e)ee(g,c,u,p,f,m,!1)}function he(e,c,u,p){e.push(c,u,p)}function ue(e,c,u,p,f,m){const g=(m-c)/(p-c);return he(e,m,u+(f-u)*g,1),g}function de(e,c,u,p,f,m){const g=(m-u)/(f-u);return he(e,c+(p-c)*g,m,1),g}function fe(e,c){const u=c.buffer/c.extent;let p=e;const f=J(e,1,-1-u,u,0,-1,2,c),m=J(e,1,1-u,2+u,0,-1,2,c);return f||m?(p=J(e,1,-u,1+u,0,-1,2,c)||[],f&&(p=me(f,1).concat(p)),m&&(p=p.concat(me(m,-1))),p):p}function me(e,c){const u=[];for(const p of e)switch(p.type){case"Point":case"MultiPoint":case"LineString":{const e=ge(p.geometry,c);u.push(B(p.id,p.type,e,p.tags));continue}case"MultiLineString":case"Polygon":{const e=[];for(const u of p.geometry)e.push(ge(u,c));u.push(B(p.id,p.type,e,p.tags));continue}case"MultiPolygon":{const e=[];for(const u of p.geometry){const p=[];for(const e of u)p.push(ge(e,c));e.push(p)}u.push(B(p.id,p.type,e,p.tags));continue}}return u}function ge(e,c){const u=[];u.size=e.size,void 0!==e.start&&(u.start=e.start,u.end=e.end);for(let p=0;p0&&c.size<(f?g:p))return void(u.numPoints+=c.length/3);const y=[];for(let e=0;eg)&&(u.numSimplified++,y.push(c[e],c[e+1])),u.numPoints++;f&&function(e,c){let u=0;for(let c=0,p=e.length,f=p-2;c0===c)for(let c=0,u=e.length;c0||c.addOrUpdateProperties?.length>0;if(p){let p=V({type:"FeatureCollection",features:[{type:"Feature",id:e.id,geometry:c.newGeometry,properties:f?Me(e.tags,c):e.tags}]},u);return p=fe(p,u),p[0]}if(f){const u={...e};return u.tags=Me(u.tags,c),u}return null}function Me(e,c){if(c.removeAllProperties)return{};const u={...e||{}};if(c.removeProperties)for(const e of c.removeProperties)delete u[e];if(c.addOrUpdateProperties)for(const{key:e,value:p}of c.addOrUpdateProperties)u[e]=p;return u}const Ee={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,updateable:!1,debug:0};class oe{options;tiles;tileCoords;stats={};total=0;source;constructor(e,c){const u=(c=this.options=Object.assign({},Ee,c)).debug;if(u&&console.time("preprocess data"),c.maxZoom<0||c.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(c.promoteId&&c.generateId)throw new Error("promoteId and generateId cannot be used together.");let p=V(e,c);this.tiles={},this.tileCoords=[],u&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",c.indexMaxZoom,c.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),p=fe(p,c),p.length&&this.splitTile(p,0,0,0),c.updateable&&(this.source=p),u&&(p.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(e,c,u,p,f,m,g){const y=[e,c,u,p],x=this.options,b=x.debug;for(;y.length;){p=y.pop(),u=y.pop(),c=y.pop(),e=y.pop();const T=1<1&&console.time("creation"),P=this.tiles[S]=ve(e,c,u,p,x),this.tileCoords.push({z:c,x:u,y:p,id:S}),b)){b>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",c,u,p,P.numFeatures,P.numPoints,P.numSimplified),console.timeEnd("creation"));const e=`z${c}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(P.source=e,null==f){if(c===x.indexMaxZoom||P.numPoints<=x.indexMaxPoints)continue}else{if(c===x.maxZoom||c===f)continue;if(null!=f){const e=f-c;if(u!==m>>e||p!==g>>e)continue}}if(P.source=null,!e.length)continue;b>1&&console.time("clipping");const I=.5*x.buffer/x.extent,C=.5-I,R=.5+I,F=1+I;let L=null,B=null,O=null,V=null;const j=J(e,T,u-I,u+R,0,P.minX,P.maxX,x),G=J(e,T,u+C,u+F,0,P.minX,P.maxX,x);j&&(L=J(j,T,p-I,p+R,1,P.minY,P.maxY,x),B=J(j,T,p+C,p+F,1,P.minY,P.maxY,x)),G&&(O=J(G,T,p-I,p+R,1,P.minY,P.maxY,x),V=J(G,T,p+C,p+F,1,P.minY,P.maxY,x)),b>1&&console.timeEnd("clipping"),y.push(L||[],c+1,2*u,2*p),y.push(B||[],c+1,2*u,2*p+1),y.push(O||[],c+1,2*u+1,2*p),y.push(V||[],c+1,2*u+1,2*p+1)}}getTile(e,c,u){e=+e,c=+c,u=+u;const p=this.options,{extent:f,debug:m}=p;if(e<0||e>24)return null;const g=1<1&&console.log("drilling down to z%d-%d-%d",e,c,u);let x,b=e,T=c,S=u;for(;!x&&b>0;)b--,T>>=1,S>>=1,x=this.tiles[Ce(b,T,S)];return x?.source?(m>1&&(console.log("found parent tile z%d-%d-%d",b,T,S),console.time("drilling down")),this.splitTile(x.source,b,T,S,e,c,u),m>1&&console.timeEnd("drilling down"),this.tiles[y]?ye(this.tiles[y],f):null):null}invalidateTiles(e){const c=this.options,{debug:u}=c;let p=1/0,f=-1/0,m=1/0,g=-1/0;for(const c of e)p=Math.min(p,c.minX),f=Math.max(f,c.maxX),m=Math.min(m,c.minY),g=Math.max(g,c.maxY);const y=c.buffer/c.extent,x=new Set;for(const c in this.tiles){const b=this.tiles[c],T=1<=P||g=C)continue;let R=!1;for(const c of e)if(c.maxX>=S&&c.minX=I&&c.minY1&&console.log("invalidate tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",b.z,b.x,b.y,b.numFeatures,b.numPoints,b.numSimplified);const e=`z${b.z}`;this.stats[e]=(this.stats[e]||0)-1,this.total--}delete this.tiles[c],x.add(c)}}x.size&&(this.tileCoords=this.tileCoords.filter((e=>!x.has(e.id))))}updateData(e){const c=this.options,u=c.debug;if(!c.updateable)throw new Error("to update tile geojson `updateable` option must be set to true");const{affected:p,source:f}=function(e,c,u){const p=function(e){return e?{removeAll:e.removeAll,remove:new Set(e.remove||[]),add:new Map(e.add?.map((e=>[e.id,e]))),update:new Map(e.update?.map((e=>[e.id,e])))}:{remove:new Set,add:new Map,update:new Map}}(c);let f=[];if(p.removeAll&&(f=e,e=[]),p.remove.size||p.add.size){const c=[];for(const u of e){const{id:e}=u;(p.remove.has(e)||p.add.has(e))&&c.push(u)}if(c.length){f.push(...c);const u=new Set(c.map((e=>e.id)));e=e.filter((e=>!u.has(e.id)))}if(p.add.size){let c=V({type:"FeatureCollection",features:Array.from(p.add.values())},u);c=fe(c,u),f.push(...c),e.push(...c)}}if(p.update.size)for(const[c,m]of p.update){const p=e.findIndex((e=>e.id===c));if(-1===p)continue;const g=e[p],y=Se(g,m,u);y&&(f.push(g,y),e[p]=y)}return{affected:f,source:e}}(this.source,e,c);if(!p.length)return;this.source=f,u>1&&(console.log("invalidating tiles"),console.time("invalidating")),this.invalidateTiles(p),u>1&&console.timeEnd("invalidating");const[m,g,y]=[0,0,0],x=ve(this.source,m,g,y,this.options);x.source=this.source;const b=Ce(m,g,y);if(this.tiles[b]=x,this.tileCoords.push({z:m,x:g,y:y,id:b}),u){const e=`z${m}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}}}function Ce(e,c,u){return 32*((1<`${e.key}: ${e.message}`)).join(", "));const f=c.features.filter((e=>p.value.evaluate({zoom:0},e)));return this._toFeatureCollection(f)}_toFeatureCollection(e){return{type:"FeatureCollection",features:e}}removeSource(c){return e._(this,void 0,void 0,(function*(){var e;null===(e=this._pendingRequest)||void 0===e||e.abort()}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}function Ae(c,u){return u.cluster?new _(function({superclusterOptions:c,clusterProperties:u}){if(!u||!c)return c;const p={},f={},m={accumulated:null,zoom:0},g={properties:null},y=Object.keys(u);for(const c of y){const[m,g]=u[c],y=e.d4(g),x=e.d4("string"==typeof m?[m,["accumulated"],["get",c]]:m);p[c]=y.value,f[c]=x.value}return c.map=e=>{g.properties=e;const c={};for(const e of y)c[e]=p[e].evaluate(m,g);return c},c.reduce=(e,c)=>{g.properties=c;for(const c of y)m.accumulated=e[c],e[c]=f[c].evaluate(m,g)},c}(u)).load(c.features):function(e,c){return new oe(e,c)}(c,u.geojsonVtOptions)}class ne{constructor(c){this.self=c,this.actor=new e.L(c),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,c)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=c},this.self.addProtocol=e.cK,this.self.removeProtocol=e.cL,this.self.registerRTLTextPlugin=c=>{e.d5.setMethods(c)},this.actor.registerMessageHandler("LDT",((e,c)=>this._getDEMWorkerSource(e,c.source).loadTile(c))),this.actor.registerMessageHandler("RDT",((c,u)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(c,u.source).removeTile(u)})))),this.actor.registerMessageHandler("GCEZ",((c,u)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(c,u.type,u.source).getClusterExpansionZoom(u)})))),this.actor.registerMessageHandler("GCC",((c,u)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(c,u.type,u.source).getClusterChildren(u)})))),this.actor.registerMessageHandler("GCL",((c,u)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(c,u.type,u.source).getClusterLeaves(u)})))),this.actor.registerMessageHandler("LD",((e,c)=>this._getWorkerSource(e,c.type,c.source).loadData(c))),this.actor.registerMessageHandler("GD",((e,c)=>this._getWorkerSource(e,c.type,c.source).getData())),this.actor.registerMessageHandler("LT",((e,c)=>this._getWorkerSource(e,c.type,c.source).loadTile(c))),this.actor.registerMessageHandler("RT",((e,c)=>this._getWorkerSource(e,c.type,c.source).reloadTile(c))),this.actor.registerMessageHandler("AT",((e,c)=>this._getWorkerSource(e,c.type,c.source).abortTile(c))),this.actor.registerMessageHandler("RMT",((e,c)=>this._getWorkerSource(e,c.type,c.source).removeTile(c))),this.actor.registerMessageHandler("RS",((c,u)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[c]||!this.workerSources[c][u.type]||!this.workerSources[c][u.type][u.source])return;const e=this.workerSources[c][u.type][u.source];delete this.workerSources[c][u.type][u.source],void 0!==e.removeSource&&e.removeSource(u)})))),this.actor.registerMessageHandler("RM",(c=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[c],delete this.availableImages[c],delete this.workerSources[c],delete this.demWorkerSources[c],this.globalStates.delete(c)})))),this.actor.registerMessageHandler("SR",((c,u)=>e._(this,void 0,void 0,(function*(){this.referrer=u})))),this.actor.registerMessageHandler("SRPS",((e,c)=>this._syncRTLPluginState(e,c))),this.actor.registerMessageHandler("IS",((c,u)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(u)})))),this.actor.registerMessageHandler("SI",((e,c)=>this._setImages(e,c))),this.actor.registerMessageHandler("UL",((c,u)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(c).update(u.layers,u.removedIds,this._getGlobalState(c))})))),this.actor.registerMessageHandler("UGS",((c,u)=>e._(this,void 0,void 0,(function*(){const e=this._getGlobalState(c);for(const c in u)e[c]=u[c]})))),this.actor.registerMessageHandler("SL",((c,u)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(c).replace(u,this._getGlobalState(c))}))))}_getGlobalState(e){let c=this.globalStates.get(e);return c||(c={},this.globalStates.set(e,c)),c}_setImages(c,u){return e._(this,void 0,void 0,(function*(){this.availableImages[c]=u;for(const e in this.workerSources[c]){const p=this.workerSources[c][e];for(const e in p)p[e].availableImages=u}}))}_syncRTLPluginState(c,u){return e._(this,void 0,void 0,(function*(){return yield e.d5.syncState(u,this.self.importScripts)}))}_getAvailableImages(e){let c=this.availableImages[e];return c||(c=[]),c}_getLayerIndex(e){let c=this.layerIndexes[e];return c||(c=this.layerIndexes[e]=new t),c}_getWorkerSource(e,c,u){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][c]||(this.workerSources[e][c]={}),!this.workerSources[e][c][u]){const p={sendAsync:(c,u)=>(c.targetMapId=e,this.actor.sendAsync(c,u))};switch(c){case"vector":this.workerSources[e][c][u]=new h(p,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][c][u]=new ie(p,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][c][u]=new this.externalWorkerSourceTypes[c](p,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][c][u]}_getDEMWorkerSource(e,c){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][c]||(this.demWorkerSources[e][c]=new d),this.demWorkerSources[e][c]}}return e.i(self)&&(self.worker=new ne(self)),ne}));p("index",["exports","./shared"],(function(c,u){var p="5.19.0";function f(){var e=new u.A(4);return u.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let m,g,y;const x={frame(e,c,p,f){const m=f||window,g=m.requestAnimationFrame((e=>{y(),c(e)})),{unsubscribe:y}=u.s(e.signal,"abort",(()=>{y(),m.cancelAnimationFrame(g),p(new u.a(e.signal.reason))}),!1)},frameAsync(e,c){return new Promise(((u,p)=>{this.frame(e,u,p,c)}))},getImageData(e,c=0){return this.getImageCanvasContext(e).getImageData(-c,-c,e.width+2*c,e.height+2*c)},getImageCanvasContext(e){const c=window.document.createElement("canvas"),u=c.getContext("2d",{willReadFrequently:!0});if(!u)throw new Error("failed to create canvas 2d context");return c.width=e.width,c.height=e.height,u.drawImage(e,0,0,e.width,e.height),u},resolveURL:e=>(m||(m=document.createElement("a")),m.href=e,m.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return void 0!==y?y:!!matchMedia&&(null==g&&(g=matchMedia("(prefers-reduced-motion: reduce)")),g.matches)},set prefersReducedMotion(e){y=e}},b=new class{constructor(){this._realTime="undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),this._frozenAt=null}getCurrentTime(){return null!==this._frozenAt?this._frozenAt:this._realTime()}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function T(){return b.getCurrentTime()}class h{static testProp(e){if(!h.docStyle)return e[0];for(let c=0;c{window.removeEventListener("click",h.suppressClickInternal,!0)}),0)}static getScale(e){const c=e.getBoundingClientRect();return{x:c.width/e.offsetWidth||1,y:c.height/e.offsetHeight||1,boundingClientRect:c}}static getPoint(e,c,p){const f=c.boundingClientRect;return new u.P((p.clientX-f.left)/c.x-e.clientLeft,(p.clientY-f.top)/c.y-e.clientTop)}static mousePos(e,c){const u=h.getScale(e);return h.getPoint(e,u,c)}static touchPos(e,c){const u=[],p=h.getScale(e);for(let f=0;f{P&&F(P),P=null,R=!0},I.onerror=()=>{C=!0,P=null},I.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(c){let p,f,m,g;c.resetRequestQueue=()=>{p=[],f=0,m=0,g={}},c.addThrottleControl=e=>{const c=m++;return g[c]=e,c},c.removeThrottleControl=e=>{delete g[e],x()},c.getImage=(e,c,f=!0)=>new Promise(((m,g)=>{S.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),u.e(e,{type:"image"}),p.push({abortController:c,requestParameters:e,supportImageRefresh:f,state:"queued",onError:e=>{g(e)},onSuccess:e=>{m(e)}}),x()}));const y=c=>u._(this||e,void 0,void 0,(function*(){c.state="running";const{requestParameters:e,supportImageRefresh:p,onError:m,onSuccess:g,abortController:y}=c,T=!1===p&&!u.i(self)&&!u.g(e.url)&&(!e.headers||Object.keys(e.headers).reduce(((e,c)=>e&&"accept"===c),!0));f++;const S=T?b(e,y):u.m(e,y);try{const e=yield S;delete c.abortController,c.state="completed",e.data instanceof HTMLImageElement||u.b(e.data)?g(e):e.data&&g({data:yield(P=e.data,"function"==typeof createImageBitmap?u.f(P):u.h(P)),cacheControl:e.cacheControl,expires:e.expires})}catch(e){delete c.abortController,m(e)}finally{f--,x()}var P})),x=()=>{const e=(()=>{for(const e of Object.keys(g))if(g[e]())return!0;return!1})()?u.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:u.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let c=f;c0;c++){const e=p.shift();e.abortController.signal.aborted?c--:y(e)}},b=(e,c)=>new Promise(((p,f)=>{const m=new Image,g=e.url,y=e.credentials;y&&"include"===y?m.crossOrigin="use-credentials":(y&&"same-origin"===y||!u.d(g))&&(m.crossOrigin="anonymous"),c.signal.addEventListener("abort",(()=>{m.src="",f(new u.a(c.signal.reason))})),m.fetchPriority="high",m.onload=()=>{m.onerror=m.onload=null,p({data:m})},m.onerror=()=>{m.onerror=m.onload=null,c.signal.aborted||f(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},m.src=g}))}(L||(L={})),L.resetRequestQueue();class v{constructor(e){this._transformRequestFn=null!=e?e:null}transformRequest(e,c){return this._transformRequestFn&&this._transformRequestFn(e,c)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function B(e){const c=[];if("string"==typeof e)c.push({id:"default",url:e});else if(e&&e.length>0){const u=[];for(const{id:p,url:f}of e){const e=`${p}${f}`;-1===u.indexOf(e)&&(u.push(e),c.push({id:p,url:f}))}}return c}function O(e,c,u){try{const p=new URL(e);return p.pathname+=`${c}${u}`,p.toString()}catch(c){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function V(e){const{userImage:c}=e;return!!(c&&c.render&&c.render())&&(e.data.replace(new Uint8Array(c.data.buffer)),!0)}class w extends u.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new u.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const e of Object.keys(this.images))this.removeImage(e);this.patterns={},this.atlasImage=new u.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:c}of this.requestors)c(this._getImagesForIds(e));this.requestors=[]}}getImage(e){const c=this.images[e];if(c&&!c.data&&c.spriteData){const e=c.spriteData;c.data=new u.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),c.spriteData=null}return c}addImage(e,c){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,c)&&(this.images[e]=c)}_validate(e,c){let p=!0;const f=c.data||c.spriteData;return this._validateStretch(c.stretchX,f&&f.width)||(this.fire(new u.k(new Error(`Image "${e}" has invalid "stretchX" value`))),p=!1),this._validateStretch(c.stretchY,f&&f.height)||(this.fire(new u.k(new Error(`Image "${e}" has invalid "stretchY" value`))),p=!1),this._validateContent(c.content,c)||(this.fire(new u.k(new Error(`Image "${e}" has invalid "content" value`))),p=!1),p}_validateStretch(e,c){if(!e)return!0;let u=0;for(const p of e){if(p[0]{let p=!0;if(!this.isLoaded())for(const c of e)this.images[c]||(p=!1);this.isLoaded()||p?c(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:c})}))}_getImagesForIds(e){const c={};for(const p of e){let e=this.getImage(p);e||(this.fire(new u.l("styleimagemissing",{id:p})),e=this.getImage(p)),e?c[p]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:u.w(`Image "${p}" 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 c}getPixelSize(){const{width:e,height:c}=this.atlasImage;return{width:e,height:c}}getPattern(e){const c=this.patterns[e],p=this.getImage(e);if(!p)return null;if(c&&c.position.version===p.version)return c.position;if(c)c.position.version=p.version;else{const c={w:p.data.width+2,h:p.data.height+2,x:0,y:0},f=new u.I(c,p);this.patterns[e]={bin:c,position:f}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const c=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new u.T(e,this.atlasImage,c.RGBA),this.atlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const c in this.patterns)e.push(this.patterns[c].bin);const{w:c,h:p}=u.p(e),f=this.atlasImage;f.resize({width:c||1,height:p||1});for(const e in this.patterns){const{bin:c}=this.patterns[e],p=c.x+1,m=c.y+1,g=this.getImage(e).data,y=g.width,x=g.height;u.R.copy(g,f,{x:0,y:0},{x:p,y:m},{width:y,height:x}),u.R.copy(g,f,{x:0,y:x-1},{x:p,y:m-1},{width:y,height:1}),u.R.copy(g,f,{x:0,y:0},{x:p,y:m+x},{width:y,height:1}),u.R.copy(g,f,{x:y-1,y:0},{x:p-1,y:m},{width:1,height:x}),u.R.copy(g,f,{x:0,y:0},{x:p+y,y:m},{width:1,height:x})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const c of e){if(this.callbackDispatchedThisFrame[c])continue;this.callbackDispatchedThisFrame[c]=!0;const e=this.getImage(c);e||u.w(`Image with ID: "${c}" was not found`),V(e)&&this.updateImage(c,e)}}cloneImages(){const e={};for(const c in this.images){const u=this.images[c];e[c]=Object.assign(Object.assign({},u),{data:u.data?u.data.clone():null})}return e}}const j=1e20;function G(e,c,u,p,f,m,g,y,x){for(let b=c;b-1);x++,m[x]=y,g[x]=b,g[x+1]=j}for(let y=0,x=0;y/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`)).join(",");return new M.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:u,fontWeight:this._fontWeight(c[0]),fontStyle:this._fontStyle(c[0]),lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){const c={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};let u;for(const[p,f]of Object.entries(c))new RegExp(`\\b${p}\\b`,"i").test(e)&&(u=`${f}`);return u}destroy(){for(const e in this.entries){const c=this.entries[e];c.tinySDF&&(c.tinySDF=null),c.ideographTinySDF&&(c.ideographTinySDF=null),c.glyphs={},c.requests={},c.ranges={}}this.entries={}}}M.loadGlyphRange=function(c,p,f,m){return u._(this||e,void 0,void 0,(function*(){const e=256*p,g=e+255,y=m.transformRequest(f.replace("{fontstack}",c).replace("{range}",`${e}-${g}`),"Glyphs"),x=yield u.n(y,new AbortController);if(!x||!x.data)throw new Error(`Could not load glyph range. range: ${p}, ${e}-${g}`);const b={};for(const e of u.o(x.data))b[e.id]=e;return b}))},M.TinySDF=class{constructor({fontSize:e=24,buffer:c=3,radius:u=8,cutoff:p=.25,fontFamily:f="sans-serif",fontWeight:m="normal",fontStyle:g="normal",lang:y=null}={}){this.buffer=c,this.cutoff=p,this.radius=u,this.lang=y;const x=this.size=e+4*c,b=this._createCanvas(x),T=this.ctx=b.getContext("2d",{willReadFrequently:!0});T.font=`${g} ${m} ${e}px ${f}`,T.textBaseline="alphabetic",T.textAlign="left",T.fillStyle="black",this.gridOuter=new Float64Array(x*x),this.gridInner=new Float64Array(x*x),this.f=new Float64Array(x),this.z=new Float64Array(x+1),this.v=new Uint16Array(x)}_createCanvas(e){const c=document.createElement("canvas");return c.width=c.height=e,c}draw(e){const{width:c,actualBoundingBoxAscent:u,actualBoundingBoxDescent:p,actualBoundingBoxLeft:f,actualBoundingBoxRight:m}=this.ctx.measureText(e),g=Math.ceil(u),y=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(m-f))),x=Math.min(this.size-this.buffer,g+Math.ceil(p)),b=y+2*this.buffer,T=x+2*this.buffer,S=Math.max(b*T,0),P=new Uint8ClampedArray(S),I={data:P,width:b,height:T,glyphWidth:y,glyphHeight:x,glyphTop:g,glyphLeft:0,glyphAdvance:c};if(0===y||0===x)return I;const{ctx:C,buffer:R,gridInner:F,gridOuter:L}=this;this.lang&&(C.lang=this.lang),C.clearRect(R,R,y,x),C.fillText(e,R,R+g);const B=C.getImageData(R,R,y,x);L.fill(j,0,S),F.fill(0,0,S);for(let e=0;e0?e*e:0,F[p]=e<0?e*e:0}}G(L,0,0,b,T,b,this.f,this.v,this.z),G(F,R,R,y,x,b,this.f,this.v,this.z);for(let e=0;e1&&(g=e[++m]);const x=Math.abs(y-g.left),b=Math.abs(y-g.right),T=Math.min(x,b);let S;const P=c/u*(p+1);if(g.isDash){const e=p-Math.abs(P);S=Math.sqrt(T*T+e*e)}else S=p-Math.sqrt(T*T+P*P);this.data[f+y]=Math.max(0,Math.min(255,S+128))}}}addRegularDash(e){for(let c=e.length-1;c>=0;--c){const u=e[c],p=e[c+1];u.zeroLength?e.splice(c,1):p&&p.isDash===u.isDash&&(p.left=u.left,e.splice(c,1))}const c=e[0],u=e[e.length-1];c.isDash===u.isDash&&(c.left=u.left-this.width,u.right=c.right+this.width);const p=this.width*this.nextRow;let f=0,m=e[f];for(let c=0;c1&&(m=e[++f]);const u=Math.abs(c-m.left),g=Math.abs(c-m.right),y=Math.min(u,g);this.data[p+c]=Math.max(0,Math.min(255,(m.isDash?y:-y)+128))}}addDash(e,c){const p=c?7:0,f=2*p+1;if(this.nextRow+f>this.height)return u.w("LineAtlas out of space"),null;let m=0;for(let c=0;c{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[J]}numActive(){return Object.keys(this.active).length}}const Q=Math.floor(x.hardwareConcurrency/2);let ee,se;function ce(){return ee||(ee=new k),ee}k.workerCount=u.K(globalThis)?Math.max(Math.min(Q,3),1):1;class N{constructor(e,c){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=c;const p=this.workerPool.acquire(c);for(let e=0;e{e.remove()})),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,c){for(const u of this.actors)u.registerMessageHandler(e,c)}unregisterMessageHandler(e){for(const c of this.actors)c.unregisterMessageHandler(e)}}function he(){return se||(se=new N(ce(),u.M),se.registerMessageHandler("GR",((e,c,p)=>u.m(c,p)))),se}function ue(e,c){const p=u.N();return u.O(p,p,[1,1,0]),u.Q(p,p,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?u.S(p,p,e.calculatePosMatrix(c.toUnwrapped())):p}function de(e,c,u,p,f,m,g){var y;const x=function(e,c,u){if(e)for(const p of e){const e=c[p];if(e&&e.source===u&&"fill-extrusion"===e.type)return!0}else for(const e in c){const p=c[e];if(p.source===u&&"fill-extrusion"===p.type)return!0}return!1}(null!==(y=null==f?void 0:f.layers)&&void 0!==y?y:null,c,e.id),b=m.maxPitchScaleFactor(),T=e.tilesIn(p,b,x);T.sort(fe);const S=[];for(const p of T)S.push({wrappedTileID:p.tileID.wrapped().key,queryResults:p.tile.queryRenderedFeatures(c,u,e.getState(),p.queryGeometry,p.cameraQueryGeometry,p.scale,f,m,b,ue(m,p.tileID),g?(e,c)=>g(p.tileID,e,c):void 0)});return function(e,c){for(const u in e)for(const p of e[u])me(p,c);return e}(function(e){const c={},u={};for(const p of e){const e=p.queryResults,f=p.wrappedTileID,m=u[f]=u[f]||{};for(const u in e){const p=e[u],f=m[u]=m[u]||{},g=c[u]=c[u]||[];for(const e of p)f[e.featureIndex]||(f[e.featureIndex]=!0,g.push(e))}}return c}(S),e)}function fe(e,c){const u=e.tileID,p=c.tileID;return u.overscaledZ-p.overscaledZ||u.canonical.y-p.canonical.y||u.wrap-p.wrap||u.canonical.x-p.canonical.x}function me(e,c){const u=e.feature,p=c.getFeatureState(u.layer["source-layer"],u.id);u.source=u.layer.source,u.layer["source-layer"]&&(u.sourceLayer=u.layer["source-layer"]),u.state=p}function ge(c,p,f,m){return u._(this||e,void 0,void 0,(function*(){let e=c;if(c.url?e=(yield u.j(p.transformRequest(c.url,"Source"),f)).data:yield x.frameAsync(f,m),!e)return null;const g=u.U(u.e(e,c),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in e&&e.vector_layers&&(g.vectorLayerIds=e.vector_layers.map((e=>e.id))),g}))}class ${constructor(e,c){e&&(c?this.setSouthWest(e).setNorthEast(c):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])))}setNorthEast(e){return this._ne=e instanceof u.V?new u.V(e.lng,e.lat):u.V.convert(e),this}setSouthWest(e){return this._sw=e instanceof u.V?new u.V(e.lng,e.lat):u.V.convert(e),this}extend(e){const c=this._sw,p=this._ne;let f,m;if(e instanceof u.V)f=e,m=e;else{if(!(e instanceof $))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend($.convert(e)):this.extend(u.V.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(u.V.convert(e)):this;if(f=e._sw,m=e._ne,!f||!m)return this}return c||p?(c.lng=Math.min(f.lng,c.lng),c.lat=Math.min(f.lat,c.lat),p.lng=Math.max(m.lng,p.lng),p.lat=Math.max(m.lat,p.lat)):(this._sw=new u.V(f.lng,f.lat),this._ne=new u.V(m.lng,m.lat)),this}getCenter(){return new u.V((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new u.V(this.getWest(),this.getNorth())}getSouthEast(){return new u.V(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:c,lat:p}=u.V.convert(e);let f=this._sw.lng<=c&&c<=this._ne.lng;return this._sw.lng>this._ne.lng&&(f=this._sw.lng>=c&&c>=this._ne.lng),this._sw.lat<=p&&p<=this._ne.lat&&f}intersects(e){if(!((e=$.convert(e)).getNorth()>=this.getSouth()&&e.getSouth()<=this.getNorth()))return!1;const c=Math.abs(this.getEast()-this.getWest()),p=Math.abs(e.getEast()-e.getWest());if(c>=360||p>=360)return!0;const f=u.W(this.getWest(),-180,180),m=u.W(this.getEast(),-180,180),g=u.W(e.getWest(),-180,180),y=u.W(e.getEast(),-180,180),x=f>m,b=g>y;return!(!x||!b)||(x?y>=f||g<=m:b?m>=g||f<=y:g<=m&&y>=f)}static convert(e){return e instanceof $?e:e?new $(e):e}static fromLngLat(e,c=0){const p=360*c/40075017,f=p/Math.cos(Math.PI/180*e.lat);return new $(new u.V(e.lng-f,e.lat-p),new u.V(e.lng+f,e.lat+p))}adjustAntiMeridian(){const e=new u.V(this._sw.lng,this._sw.lat),c=new u.V(this._ne.lng,this._ne.lat);return new $(e,e.lng>c.lng?new u.V(c.lng+360,c.lat):c)}}class H{constructor(e,c,u){this.bounds=$.convert(this.validateBounds(e)),this.minzoom=c||0,this.maxzoom=u||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const c=Math.pow(2,e.z),p=Math.floor(u.Y(this.bounds.getWest())*c),f=Math.floor(u.X(this.bounds.getNorth())*c),m=Math.ceil(u.Y(this.bounds.getEast())*c),g=Math.ceil(u.X(this.bounds.getSouth())*c);return e.x>=p&&e.x=f&&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 u.e({},this._options)}loadTile(e){return u._(this,void 0,void 0,(function*(){const c=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),u={request:this.map._requestManager.transformRequest(c,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:this._getOverzoomParameters(e)};u.request.collectResourceTiming=this._collectResourceTiming;let p="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise(((c,u)=>{e.reloadPromise={resolve:c,reject:u}}))}else e.actor=this.dispatcher.getActor(),p="LT";e.abortController=new AbortController;try{const c=yield e.actor.sendAsync({type:p,data:u},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,c)}catch(c){if(delete e.abortController,e.aborted)return;if(c&&404!==c.status)throw c;this._afterTileLoadWorkerResponse(e,null)}}))}_getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom)return;if(void 0===this.map._zoomLevelsToOverscale)return;const c=e.tileID.scaledTo(this.maxzoom).canonical,u=c.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:c,overzoomRequest:this.map._requestManager.transformRequest(u,"Tile")}}_afterTileLoadWorkerResponse(e,c){if(c&&c.resourceTiming&&(e.resourceTiming=c.resourceTiming),c&&this.map._refreshExpiredTiles&&e.setExpiryData(c),e.loadVectorData(c,this.map.painter),e.reloadPromise){const c=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(c.resolve).catch(c.reject)}}abortTile(e){return u._(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 u._(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class K extends u.E{constructor(e,c,p,f){super(),this.id=e,this.dispatcher=p,this.setEventedParent(f),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=u.e({type:"raster"},c),u.e(this,u.U(c,["url","scheme","tileSize"]))}load(){return u._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new u.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const c=yield ge(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,c&&(u.e(this,c),c.bounds&&(this.tileBounds=new H(c.bounds,this.minzoom,this.maxzoom)),this.fire(new u.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new u.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,u.Z(e)||this.fire(new u.k(e))}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}serialize(){return u.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return u._(this,void 0,void 0,(function*(){const c=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const p=yield L.getImage(this.map._requestManager.transformRequest(c,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(p&&p.data){this.map._refreshExpiredTiles&&(p.cacheControl||p.expires)&&e.setExpiryData({cacheControl:p.cacheControl,expires:p.expires});const c=this.map.painter.context,f=c.gl,m=p.data;e.texture=this.map.painter.getTileTexture(m.width),e.texture?e.texture.update(m,{useMipmap:!0}):(e.texture=new u.T(c,m,f.RGBA,{useMipmap:!0}),e.texture.bind(f.LINEAR,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(c){if(delete e.abortController,e.aborted)e.state="unloaded";else if(c)throw e.state="errored",c}}))}abortTile(e){return u._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)}))}unloadTile(e){return u._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)}))}hasTransition(){return!1}}class Y extends K{constructor(e,c,p,f){super(e,c,p,f),this.type="raster-dem",this.maxzoom=22,this._options=u.e({type:"raster-dem"},c),this.encoding=c.encoding||"mapbox",this.redFactor=c.redFactor,this.greenFactor=c.greenFactor,this.blueFactor=c.blueFactor,this.baseShift=c.baseShift}loadTile(e){return u._(this,void 0,void 0,(function*(){const c=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),p=this.map._requestManager.transformRequest(c,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const c=yield L.getImage(p,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(c&&c.data){const p=c.data;this.map._refreshExpiredTiles&&(c.cacheControl||c.expires)&&e.setExpiryData({cacheControl:c.cacheControl,expires:c.expires});const f=u.b(p)&&u.$()?p:yield this.readImageNow(p),m={type:this.type,uid:e.uid,source:this.id,rawImageData:f,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const c=yield e.actor.sendAsync({type:"LDT",data:m});e.dem=c,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(c){if(delete e.abortController,e.aborted)e.state="unloaded";else if(c)throw e.state="errored",c}}))}readImageNow(e){return u._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&u.a0()){const c=e.width+2,p=e.height+2;try{return new u.R({width:c,height:p},yield u.a1(e,-1,-1,c,p))}catch(e){}}return x.getImageData(e,1)}))}_getNeighboringTiles(e){const c=e.canonical,p=Math.pow(2,c.z),f=(c.x-1+p)%p,m=0===c.x?e.wrap-1:e.wrap,g=(c.x+1+p)%p,y=c.x+1===p?e.wrap+1:e.wrap,x={};return x[new u.a2(e.overscaledZ,m,c.z,f,c.y).key]={backfilled:!1},x[new u.a2(e.overscaledZ,y,c.z,g,c.y).key]={backfilled:!1},c.y>0&&(x[new u.a2(e.overscaledZ,m,c.z,f,c.y-1).key]={backfilled:!1},x[new u.a2(e.overscaledZ,e.wrap,c.z,c.x,c.y-1).key]={backfilled:!1},x[new u.a2(e.overscaledZ,y,c.z,g,c.y-1).key]={backfilled:!1}),c.y+1ye(e))):[]}function xe(e){return"GeometryCollection"===e.type?e.geometries.flatMap((e=>xe(e))):ye(e.coordinates)}function ve(e){const c=new $;let u;switch(e.type){case"FeatureCollection":u=e.features.flatMap((e=>xe(e.geometry)));break;case"Feature":u=xe(e.geometry);break;default:u=xe(e)}if(0===u.length)return c;for(let e=0;eve(e)))}}shouldReloadTile(e,{affectedBounds:c}){if("loading"===e.state)return!0;if("unloaded"===e.state)return!1;const{buffer:p,extent:f}=this.workerOptions.geojsonVtOptions,m=function({x:e,y:c,z:p},f=0){const m=u.a3((e-f)/Math.pow(2,p)),g=u.a4((c+1+f)/Math.pow(2,p)),y=u.a3((e+1+f)/Math.pow(2,p)),x=u.a4((c-f)/Math.pow(2,p));return new $([m,g],[y,x])}(e.tileID.canonical,p/f);for(const e of c)if(m.intersects(e))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(e){return u._(this,void 0,void 0,(function*(){const c=e.actor?"RT":"LT";e.actor=this.actor;const u={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;const p=yield this.actor.sendAsync({type:c,data:u},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(p,this.map.painter,"RT"===c)}))}abortTile(e){return u._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}))}unloadTile(e){return u._(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 u.e({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}}class ie extends u.E{constructor(e,c,u,p){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=u,this.coordinates=c.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(p),this.options=c}load(e){return u._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new u.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const c=yield L.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,c&&c.data&&(this.image=c.data,e&&(this.coordinates=e),this._finishLoading())}catch(e){this._request=null,this._loaded=!0,u.Z(e)||this.fire(new u.k(e))}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally((()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new u.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const c=e.map(u.a9.fromLngLat);var p;return this.tileID=function(e){const c=u.aa.fromPoints(e),p=c.width(),f=c.height(),m=Math.max(p,f),g=Math.max(0,Math.floor(-Math.log(m)/Math.LN2)),y=Math.pow(2,g);return new u.ac(g,Math.floor((c.minX+c.maxX)/2*y),Math.floor((c.minY+c.maxY)/2*y))}(c),this.terrainTileRanges=this._getOverlappingTileRanges(c),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=c.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((p=this.tileCoords)[1].x-p[0].x)*(p[2].y-p[0].y)-(p[1].y-p[0].y)*(p[2].x-p[0].x)<0,this.fire(new u.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,c=e.gl;this.texture||(this.texture=new u.T(e,this.image,c.RGBA),this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE));let p=!1;for(const e in this.tiles){const c=this.tiles[e];"loaded"!==c.state&&(c.state="loaded",c.texture=this.texture,p=!0)}p&&this.fire(new u.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return u._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:c,minY:p,maxX:f,maxY:m}=u.aa.fromPoints(e),g={};for(let e=0;e<=u.ab;e++){const u=Math.pow(2,e),y=Math.floor(c*u),x=Math.floor(p*u),b=Math.floor(f*u),T=Math.floor(m*u),S=(y%u+u)%u,P=b%u,I=Math.floor(y/u),C=Math.floor(b/u);g[e]={minWrap:I,maxWrap:C,minTileXWrapped:S,maxTileXWrapped:P,minTileY:x,maxTileY:T}}return g}}class ae extends ie{constructor(e,c,u,p){super(e,c,u,p),this.roundZoom=!0,this.type="video",this.options=c}load(){return u._(this,void 0,void 0,(function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const c of e.urls)this.urls.push(this.map._requestManager.transformRequest(c,"Source").url);try{const e=yield u.ad(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new u.k(e))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const c=this.video.seekable;ec.end(0)?this.fire(new u.k(new u.ae(`sources.${this.id}`,null,`Playback for this video can be set only between the ${c.start(0)} and ${c.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,c=e.gl;this.texture?this.video.paused||(this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE),c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,this.video)):(this.texture=new u.T(e,this.video,c.RGBA),this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE));let p=!1;for(const e in this.tiles){const c=this.tiles[e];"loaded"!==c.state&&(c.state="loaded",c.texture=this.texture,p=!0)}p&&this.fire(new u.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class re extends ie{constructor(e,c,p,f){super(e,c,p,f),c.coordinates?Array.isArray(c.coordinates)&&4===c.coordinates.length&&!c.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new u.k(new u.ae(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new u.k(new u.ae(`sources.${e}`,null,'missing required property "coordinates"'))),c.animate&&"boolean"!=typeof c.animate&&this.fire(new u.k(new u.ae(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),c.canvas?"string"==typeof c.canvas||c.canvas instanceof HTMLCanvasElement||this.fire(new u.k(new u.ae(`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 u.k(new u.ae(`sources.${e}`,null,'missing required property "canvas"'))),this.options=c,this.animate=void 0===c.animate||c.animate}load(){return u._(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 u.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const c=this.map.painter.context,p=c.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new u.T(c,this.canvas,p.RGBA,{premultiply:!0}),this.texture.bind(p.LINEAR,p.CLAMP_TO_EDGE));let f=!1;for(const e in this.tiles){const c=this.tiles[e];"loaded"!==c.state&&(c.state="loaded",c.texture=this.texture,f=!0)}f&&this.fire(new u.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}const be={},we=e=>{switch(e){case"geojson":return te;case"image":return ie;case"raster":return K;case"raster-dem":return Y;case"vector":return X;case"video":return ae;case"canvas":return re}return be[e]},Se="RTLPluginLoaded";class le extends u.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=he()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch((e=>{throw this.status="error",e}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return u._(this,arguments,void 0,(function*(e,c=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=x.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!c)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return u._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new u.l(Se))}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let Me=null;function Ee(){return Me||(Me=new le),Me}var Ce,Ae;!function(e){e[e.Base=0]="Base",e[e.Parent=1]="Parent"}(Ce||(Ce={})),function(e){e[e.Departing=0]="Departing",e[e.Incoming=1]="Incoming"}(Ae||(Ae={}));class _e{constructor(e,c){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=u.af(),this.uses=0,this.tileSize=c,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading"}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:c,fadingParentID:u,fadeEndTime:p}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=c,this.fadingParentID=u,this.fadeEndTime=p}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=T(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,c,p){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,c){const u={};if(!c)return u;for(const p of e){const e=p.layerIds.map((e=>c.getLayer(e))).filter(Boolean);if(0!==e.length){p.layers=e,p.stateDependentLayerIds&&(p.stateDependentLayers=p.stateDependentLayerIds.map((c=>e.filter((e=>e.id===c))[0])));for(const c of e)u[c.id]=p}}return u}(e.buckets,null==c?void 0:c.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const c=this.buckets[e];if(c instanceof u.ah){if(this.hasSymbolBuckets=!0,!p)break;c.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const c=this.buckets[e];if(c instanceof u.ah&&c.hasRTLText){this.hasRTLText=!0,Ee().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const u=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,c.style.getLayer(e).queryRadius(u))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new u.ag}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.dashPositions&&(this.dashPositions=null),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const c in this.buckets){const u=this.buckets[c];u.uploadPending()&&u.upload(e)}const c=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new u.T(e,this.imageAtlas.image,c.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new u.T(e,this.glyphAtlasImage,c.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,c,u,p,f,m,g,y,x,b,T){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:p,cameraQueryGeometry:f,scale:m,tileSize:this.tileSize,pixelPosMatrix:b,transform:y,params:g,queryPadding:this.queryPadding*x,getElevation:T},e,c,u):{}}querySourceFeatures(e,c){const p=this.latestFeatureIndex;if(!p||!p.rawTileData)return;const f=p.loadVTLayers(),m=c&&c.sourceLayer?c.sourceLayer:"",g=f[u.ai]||f[m];if(!g)return;const y=u.aj(null==c?void 0:c.filter,null==c?void 0:c.globalState),{z:x,x:b,y:T}=this.tileID.canonical,S={z:x,x:b,y:T};for(let c=0;ce)u=!1;else if(c)if(this.expirationTime({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),V=[],j=[];if(e.renderWorldCopies&&y.allowWorldCopies())for(let e=1;e<=3;e++)V.push(O(-e)),V.push(O(e));for(V.push(O(0));V.length>0;){const I=V.pop(),F=I.x,O=I.y;let G=I.fullyVisible;const U={x:F,y:O,z:I.zoom},q=y.getTileBoundingVolume(U,I.wrap,e.elevation,c);if(!G){const e=tt(p,q,f);if(0===e)continue;G=2===e}const Z=y.distanceToTile2d(m.x,m.y,U,q);let W=b;x&&(W=(c.calculateTileZoom||nt)(e.zoom+u.at(e.tileSize/c.tileSize),Z,L,B,e.fov)),W=(c.roundZoom?Math.round:Math.floor)(W),W=Math.max(0,W);const J=Math.min(W,S);if(I.wrap=y.getWrap(g,U,I.wrap),I.zoom>=J){if(I.zoom>1),wrap:I.wrap,fullyVisible:G})}return j.sort(((e,c)=>e.distanceSq-c.distanceSq)).map((e=>e.tileID))}const pt=u.aa.fromPoints([new u.P(0,0),new u.P(u.a5,u.a5)]);function ft(e){return"raster"===e||"image"===e||"video"===e}function yt(e,c,u,p,f,m,g){if(!c.hasData())return!1;const{tileID:y,fadingRole:x,fadingDirection:b,fadingParentID:T}=c;if(x===Ce.Base&&b===Ae.Incoming&&T)return u[T.key]=T,!0;const S=Math.max(y.overscaledZ-f,m);for(let f=y.overscaledZ-1;f>=S;f--){const m=y.scaledTo(f),x=e.getLoadedTile(m);if(x)return c.setCrossFadeLogic({fadingRole:Ce.Base,fadingDirection:Ae.Incoming,fadingParentID:x.tileID,fadeEndTime:p+g}),x.setCrossFadeLogic({fadingRole:Ce.Parent,fadingDirection:Ae.Departing,fadeEndTime:p+g}),u[m.key]=m,!0}return!1}function vt(e,c,u,p,f,m){if(!c.hasData())return!1;const g=c.tileID.children(f);let y=bt(e,c,g,u,p,f,m);if(y)return!0;for(const x of g)bt(e,c,x.children(f),u,p,f,m)&&(y=!0);return y}function bt(e,c,u,p,f,m,g){if(u[0].overscaledZ>=m)return!1;let y=!1;for(const m of u){const u=e.getLoadedTile(m);if(!u)continue;const{fadingRole:x,fadingDirection:b,fadingParentID:T}=u;x===Ce.Base&&b===Ae.Departing&&T||(u.setCrossFadeLogic({fadingRole:Ce.Base,fadingDirection:Ae.Departing,fadingParentID:c.tileID,fadeEndTime:f+g}),c.setCrossFadeLogic({fadingRole:Ce.Parent,fadingDirection:Ae.Incoming,fadeEndTime:f+g})),p[m.key]=m,y=!0}return y}function wt(e,c,u,p){const f=e.tileID;return!!e.selfFading||!e.hasData()&&!!c.has(f)&&(e.setSelfFadeLogic(u+p),!0)}function Tt(e,c){var u;e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0;let p=c.tileID.canonical.x-e.tileID.canonical.x;const f=c.tileID.canonical.y-e.tileID.canonical.y,m=Math.pow(2,e.tileID.canonical.z),g=c.tileID.key;0===p&&0===f||Math.abs(f)>1||(Math.abs(p)>1&&(1===Math.abs(p+m)?p+=m:1===Math.abs(p-m)&&(p-=m)),c.dem&&e.dem&&(e.dem.backfillBorder(c.dem,p,f),(null===(u=e.neighboringTiles)||void 0===u?void 0:u[g])&&(e.neighboringTiles[g].backfilled=!0)))}class ke{constructor(){this._tiles={}}handleWrapJump(e){const c={};for(const u in this._tiles){const p=this._tiles[u];p.tileID=p.tileID.unwrapTo(p.tileID.wrap+e),c[p.tileID.key]=p}this._tiles=c}setFeatureState(e,c){for(const u in this._tiles)this._tiles[u].setFeatureState(e,c)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map((e=>e.tileID)).sort(u.aw).map((e=>e.key)):Object.keys(this._tiles)}getTileById(e){return this._tiles[e]}setTile(e,c){this._tiles[e]=c}deleteTileById(e){delete this._tiles[e]}getLoadedTile(e){const c=this.getTileById(e.key);return(null==c?void 0:c.hasData())?c:null}isIdRenderable(e,c=!1){var u;return null===(u=this.getTileById(e))||void 0===u?void 0:u.isRenderable(c)}getRenderableIds(e=0,c){const p=[];for(const e of this.getAllIds())this.isIdRenderable(e,c)&&p.push(this.getTileById(e));return c?p.sort(((c,p)=>{const f=c.tileID,m=p.tileID,g=new u.P(f.canonical.x,f.canonical.y)._rotate(-e),y=new u.P(m.canonical.x,m.canonical.y)._rotate(-e);return f.overscaledZ-m.overscaledZ||y.y-g.y||y.x-g.x})).map((e=>e.tileID.key)):p.map((e=>e.tileID)).sort(u.aw).map((e=>e.key))}}class Fe extends u.E{constructor(e,c,p){super(),this.id=e,this.dispatcher=p,this.on("data",(e=>this._dataHandler(e))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((e,c,u,p)=>{const f=new(we(c.type))(e,c,u,p);if(f.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${f.id}`);return f})(e,c,p,this),this._inViewTiles=new ke,this._outOfViewCache=new u.ax(0,(e=>this._unloadTile(e))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new pe,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){for(const e of this._inViewTiles.getAllTiles())e.unloadVectorData();this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e),this._inViewTiles=new ke}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,c,p){return u._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,c,p)}catch(c){e.state="errored",404!==c.status?this._source.fire(new u.k(c,{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 u.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(const c of this._inViewTiles.getAllTiles())c.upload(e),c.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(e){var c;return this._inViewTiles.getRenderableIds(null===(c=this.transform)||void 0===c?void 0:c.bearingInRadians,e)}hasRenderableParent(e){const c=e.overscaledZ-1;if(c>=this._source.minzoom){const u=this.getLoadedTile(e.scaledTo(c));if(u)return this._inViewTiles.isIdRenderable(u.tileID.key)}return!1}reload(e,c=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(const u of this._inViewTiles.getAllIds()){const p=this._inViewTiles.getTileById(u);c&&!this._source.shouldReloadTile(p,c)||(e?this._reloadTile(u,"expired"):"errored"!==p.state&&this._reloadTile(u,"reloading"))}}}_reloadTile(e,c){return u._(this,void 0,void 0,(function*(){const u=this._inViewTiles.getTileById(e);u&&("loading"!==u.state&&(u.state=c),yield this._loadTile(u,e,c))}))}_tileLoaded(e,c,p){e.timeAdded=T(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),"expired"===p&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(c,e),"raster-dem"===this.getSource().type&&e.dem&&function(e,c){var u,p;const f=c.getRenderableIds();for(const m of f){if(!e.neighboringTiles||!e.neighboringTiles[m])continue;const f=c.getTileById(m);e.neighboringTiles[m].backfilled||Tt(e,f),(null===(p=null===(u=f.neighboringTiles)||void 0===u?void 0:u[e.tileID.key])||void 0===p?void 0:p.backfilled)||Tt(f,e)}}(e,this._inViewTiles),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new u.l("data",{dataType:"source",tile:e,coord:e.tileID}))}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._inViewTiles.getTileById(e)}_retainLoadedChildren(e,c){const u=this._getLoadedDescendents(c),p=new Set;for(const f of c){const c=u[f.key];if(!(null==c?void 0:c.length)){p.add(f);continue}const m=f.overscaledZ+Fe.maxOverzooming,g=c.filter((e=>e.tileID.overscaledZ<=m));if(!g.length){p.add(f);continue}const y=Math.min(...g.map((e=>e.tileID.overscaledZ))),x=g.filter((e=>e.tileID.overscaledZ===y)).map((e=>e.tileID));for(const c of x)e[c.key]=c;this._areDescendentsComplete(x,y,f.overscaledZ)||p.add(f)}return p}_getLoadedDescendents(e){var c;const u={};for(const p of this._inViewTiles.getAllTiles().filter((e=>e.hasData())))for(const f of e)p.tileID.isChildOf(f)&&(u[c=f.key]||(u[c]=[])).push(p);return u}_areDescendentsComplete(e,c,u){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===c:Math.pow(4,c-u)===e.length}getLoadedTile(e){return this._inViewTiles.getLoadedTile(e)}updateCacheSize(e){const c=Math.ceil(e.width/this._source.tileSize)+1,p=Math.ceil(e.height/this._source.tileSize)+1,f=Math.floor(c*p*(null===this._maxTileCacheZoomLevels?u.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),m="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,f):f;this._outOfViewCache.setMaxSize(m)}handleWrapJump(e){const c=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);this._prevLng=e,c&&(this._inViewTiles.handleWrapJump(c),this._resetTileReloadTimers())}update(e,c){if(!this._sourceLoaded||this._paused)return;let p;this.transform=e,this.terrain=c,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?p=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new u.a2(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(p=at(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?e.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:c,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(p=p.filter((e=>this._source.hasTile(e))))):p=[],this.usedForTerrain&&(p=this._addTerrainIdealTiles(p));const f=0===p.length&&!this._updated&&this._didEmitContent;this._updated=!0,f&&this.fire(new u.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const m=ot(e,this._source),g=this._updateRetainedTiles(p,m),y=ft(this._source.type);y&&this._rasterFadeDuration>0&&!c&&function(e,c,p,f,m,g,y){const x=T(),b=u.av(c);for(const u of c){const c=e.getTileById(u.key);c.fadingDirection!==Ae.Departing&&0!==c.fadeOpacity||c.resetFadeLogic(),yt(e,c,p,x,f,m,y)||vt(e,c,p,x,g,y)||wt(c,b,x,y)||c.resetFadeLogic()}}(this._inViewTiles,p,g,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),y?this._cleanUpRasterTiles(g):this._cleanUpVectorTiles(g)}_cleanUpRasterTiles(e){for(const c of this._inViewTiles.getAllIds())e[c]||this._removeTile(c)}_cleanUpVectorTiles(e){for(const c of this._inViewTiles.getAllIds()){const u=this._inViewTiles.getTileById(c);e[c]?u.clearSymbolFadeHold():u.hasSymbolBuckets?u.holdingForSymbolFade()?u.symbolFadeFinished()&&this._removeTile(c):u.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(c)}}_addTerrainIdealTiles(e){const c=[];for(const u of e)if(u.canonical.z>this._source.minzoom){const e=u.scaledTo(u.canonical.z-1);c.push(e);const p=u.scaledTo(Math.max(this._source.minzoom,Math.min(u.canonical.z,5)));c.push(p)}return e.concat(c)}releaseSymbolFadeTiles(){for(const e of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(e).holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,c){var u;const p=new Set;for(const c of e)this._addTile(c).hasData()||p.add(c);const f=e.reduce(((e,c)=>(e[c.key]=c,e)),{}),m=this._retainLoadedChildren(f,p),g={},y=Math.max(c-Fe.maxUnderzooming,this._source.minzoom);for(const e of m){let c=this._inViewTiles.getTileById(e.key),p=null==c?void 0:c.wasRequested();for(let m=e.overscaledZ-1;m>=y;--m){const y=e.scaledTo(m);if(g[y.key])break;if(g[y.key]=!0,c=this.getTile(y),!c&&p&&(c=this._addTile(y)),c){const e=c.hasData();if((e||!(null===(u=this.map)||void 0===u?void 0:u.cancelPendingTileRequestsWhileZooming)||p)&&(f[y.key]=y),p=c.wasRequested(),e)break}}}return f}_addTile(e){let c=this._inViewTiles.getTileById(e.key);if(c)return c;c=this._outOfViewCache.getAndRemove(e),c&&(c.resetFadeLogic(),this._setTileReloadTimer(e.key,c),c.tileID=e,this._state.initializeTileState(c,this.map?this.map.painter:null));const p=c;return c||(c=new _e(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(c,e.key,c.state)),c.uses++,this._inViewTiles.setTile(e.key,c),p||this._source.fire(new u.l("dataloading",{tile:c,coord:c.tileID,dataType:"source"})),c}_setTileReloadTimer(e,c){this._clearTileReloadTimer(e);const u=c.getExpiryTimeout();u&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),u))}_clearTileReloadTimer(e){const c=this._timers[e];c&&(clearTimeout(c),delete this._timers[e])}_resetTileReloadTimers(){for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e of this._inViewTiles.getAllIds()){const c=this._inViewTiles.getTileById(e);this._setTileReloadTimer(e,c)}}refreshTiles(e){for(const c of this._inViewTiles.getAllIds()){const u=this._inViewTiles.getTileById(c);(this._inViewTiles.isIdRenderable(c)||"errored"==u.state)&&e.some((e=>e.equals(u.tileID.canonical)))&&this._reloadTile(c,"expired")}}_removeTile(e){const c=this._inViewTiles.getTileById(e);c&&(c.uses--,this._inViewTiles.deleteTileById(e),this._clearTileReloadTimer(e),c.uses>0||(c.hasData()&&"reloading"!==c.state?this._outOfViewCache.add(c.tileID,c,c.getExpiryTimeout()):(c.aborted=!0,this._abortTile(c),this._unloadTile(c))))}_dataHandler(e){"source"===e.dataType&&("metadata"!==e.sourceDataType?"content"===e.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e of this._inViewTiles.getAllIds())this._removeTile(e);this._outOfViewCache.reset()}tilesIn(e,c,p){const f=[],m=this.transform;if(!m)return f;const g=m.getCoveringTilesDetailsProvider().allowWorldCopies(),y=p?m.getCameraQueryGeometry(e):e,x=e=>m.screenPointToMercatorCoordinate(e,this.terrain),b=this.transformBbox(e,x,!g),T=this.transformBbox(y,x,!g),S=this.getIds(),P=u.aa.fromPoints(T);for(let e=0;ee.getTilePoint(new u.a9(c.x,c.y))));if(c.expandBy(I),c.intersects(pt)){const c=b.map((c=>e.getTilePoint(c))),u=T.map((c=>e.getTilePoint(c)));f.push({tile:p,tileID:g?e:e.unwrapTo(0),queryGeometry:c,cameraQueryGeometry:u,scale:x})}}}return f}transformBbox(e,c,p){let f=e.map(c);if(p){const p=u.aa.fromPoints(e);p.shrinkBy(.001*Math.min(p.width(),p.height()));const m=p.map(c);u.aa.fromPoints(f).covers(m)||(f=f.map((e=>e.x>.5?new u.a9(e.x-1,e.y,e.z):e)))}return f}getVisibleCoordinates(e){const c=this.getRenderableIds(e).map((e=>this._inViewTiles.getTileById(e).tileID));return this.transform&&this.transform.populateCache(c),c}hasTransition(){return!!this._source.hasTransition()||!(!ft(this._source.type)||!function(e,c){if(c<=0)return!1;const u=T();for(const c of e.getAllTiles())if(c.fadeEndTime>=u)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration))}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,c,p){this._state.updateState(e=e||u.ai,c,p)}removeFeatureState(e,c,p){this._state.removeFeatureState(e=e||u.ai,c,p)}getFeatureState(e,c){return this._state.getState(e=e||u.ai,c)}setDependencies(e,c,u){const p=this._inViewTiles.getTileById(e);p&&p.setDependencies(c,u)}reloadTilesForDependencies(e,c){for(const u of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(u).hasDependency(e,c)&&this._reloadTile(u,"reloading");this._outOfViewCache.filter((u=>!u.hasDependency(e,c)))}areTilesLoaded(){for(const e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return!1;return!0}}Fe.maxUnderzooming=10,Fe.maxOverzooming=3;class Be{constructor(e,c){this.reset(e,c)}reset(e,c){this.points=e||[],this._distances=[0];for(let e=1;e0?(f-g)/y:0;return this.points[m].mult(1-x).add(this.points[c].mult(x))}}function Pt(e,c){let u=!0;return"always"===e||"never"!==e&&"never"!==c||(u=!1),u}class je{constructor(e,c,u){const p=this.boxCells=[],f=this.circleCells=[];this.xCellCount=Math.ceil(e/u),this.yCellCount=Math.ceil(c/u);for(let e=0;ethis.width||p<0||c>this.height)return[];const y=[];if(e<=0&&c<=0&&this.width<=u&&this.height<=p){if(f)return[{key:null,x1:e,y1:c,x2:u,y2:p}];for(let e=0;e0}hitTestCircle(e,c,u,p,f){const m=e-u,g=e+u,y=c-u,x=c+u;if(g<0||m>this.width||x<0||y>this.height)return!1;const b=[];return this._forEachCell(m,y,g,x,this._queryCellCircle,b,{hitTest:!0,overlapMode:p,circle:{x:e,y:c,radius:u},seenUids:{box:{},circle:{}}},f),b.length>0}_queryCell(e,c,u,p,f,m,g,y){const{seenUids:x,hitTest:b,overlapMode:T}=g,S=this.boxCells[f];if(null!==S){const f=this.bboxes;for(const g of S)if(!x.box[g]){x.box[g]=!0;const S=4*g,P=this.boxKeys[g];if(e<=f[S+2]&&c<=f[S+3]&&u>=f[S+0]&&p>=f[S+1]&&(!y||y(P))&&(!b||!Pt(T,P.overlapMode))&&(m.push({key:P,x1:f[S],y1:f[S+1],x2:f[S+2],y2:f[S+3]}),b))return!0}}const P=this.circleCells[f];if(null!==P){const f=this.circles;for(const g of P)if(!x.circle[g]){x.circle[g]=!0;const S=3*g,P=this.circleKeys[g];if(this._circleAndRectCollide(f[S],f[S+1],f[S+2],e,c,u,p)&&(!y||y(P))&&(!b||!Pt(T,P.overlapMode))){const e=f[S],c=f[S+1],u=f[S+2];if(m.push({key:P,x1:e-u,y1:c-u,x2:e+u,y2:c+u}),b)return!0}}}return!1}_queryCellCircle(e,c,u,p,f,m,g,y){const{circle:x,seenUids:b,overlapMode:T}=g,S=this.boxCells[f];if(null!==S){const e=this.bboxes;for(const c of S)if(!b.box[c]){b.box[c]=!0;const u=4*c,p=this.boxKeys[c];if(this._circleAndRectCollide(x.x,x.y,x.radius,e[u+0],e[u+1],e[u+2],e[u+3])&&(!y||y(p))&&!Pt(T,p.overlapMode))return m.push(!0),!0}}const P=this.circleCells[f];if(null!==P){const e=this.circles;for(const c of P)if(!b.circle[c]){b.circle[c]=!0;const u=3*c,p=this.circleKeys[c];if(this._circlesCollide(e[u],e[u+1],e[u+2],x.x,x.y,x.radius)&&(!y||y(p))&&!Pt(T,p.overlapMode))return m.push(!0),!0}}}_forEachCell(e,c,u,p,f,m,g,y){const x=this._convertToXCellCoord(e),b=this._convertToYCellCoord(c),T=this._convertToXCellCoord(u),S=this._convertToYCellCoord(p);for(let P=x;P<=T;P++)for(let x=b;x<=S;x++)if(f.call(this,e,c,u,p,this.xCellCount*x+P,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,c,u,p,f,m){const g=p-e,y=f-c,x=u+m;return x*x>g*g+y*y}_circleAndRectCollide(e,c,u,p,f,m,g){const y=(m-p)/2,x=Math.abs(e-(p+y));if(x>y+u)return!1;const b=(g-f)/2,T=Math.abs(c-(f+b));if(T>b+u)return!1;if(x<=y||T<=b)return!0;const S=x-y,P=T-b;return S*S+P*P<=u*u}}function Et(e,c,p){const m=u.N();if(!e){const{vecSouth:e,vecEast:u}=At(c),p=f();p[0]=u[0],p[1]=u[1],p[2]=e[0],p[3]=e[1],g=p,(P=(x=(y=p)[0])*(S=y[3])-(T=y[2])*(b=y[1]))&&(g[0]=S*(P=1/P),g[1]=-b*P,g[2]=-T*P,g[3]=x*P),m[0]=p[0],m[1]=p[1],m[4]=p[2],m[5]=p[3]}var g,y,x,b,T,S,P;return u.Q(m,m,[1/p,1/p,1]),m}function Ct(e,c,p,f){if(e){const e=u.N();if(!c){const{vecSouth:c,vecEast:u}=At(p);e[0]=u[0],e[1]=u[1],e[4]=c[0],e[5]=c[1]}return u.Q(e,e,[f,f,1]),e}return p.pixelsToClipSpaceMatrix}function At(e){const c=Math.cos(e.rollInRadians),p=Math.sin(e.rollInRadians),f=Math.cos(e.pitchInRadians),m=Math.cos(e.bearingInRadians),g=Math.sin(e.bearingInRadians),y=u.aC();y[0]=-m*f*p-g*c,y[1]=-g*f*p+m*c;const x=u.aD(y);x<1e-9?u.aE(y):u.aF(y,y,1/x);const b=u.aC();b[0]=m*f*c-g*p,b[1]=g*f*c+m*p;const T=u.aD(b);return T<1e-9?u.aE(b):u.aF(b,b,1/T),{vecEast:b,vecSouth:y}}function kt(e,c,p,f){let m;f?(m=[e,c,f(e,c),1],u.aH(m,m,p)):(m=[e,c,0,1],gi(m,m,p));const g=m[3];return{point:new u.P(m[0]/g,m[1]/g),signedDistanceFromCamera:g,isOccluded:!1}}function Lt(e,c){return.5+e/c*.5}function Ot(e,c){return e.x>=-c[0]&&e.x<=c[0]&&e.y>=-c[1]&&e.y<=c[1]}function jt(e,c,p,f,m,g,y,x,b,T,S,P,I){const C=p?e.textSizeData:e.iconSizeData,R=u.ay(C,c.transform.zoom),F=[256/c.width*2+1,256/c.height*2+1],L=p?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;L.clear();const B=e.lineVertexArray,O=p?e.text.placedSymbolArray:e.icon.placedSymbolArray,V=c.transform.width/c.transform.height;let j=!1;for(let p=0;pMath.abs(p.x-c.x)*f?{useVertical:!0}:(e===u.az.vertical?c.yp.x)?{needsFlipping:!0}:null}function Xt(e){const{projectionContext:c,pitchedLabelPlaneMatrixInverse:p,symbol:f,fontSize:m,flip:g,keepUpright:y,glyphOffsetArray:x,dynamicLayoutVertexArray:b,aspectRatio:T,rotateToLine:S}=e,P=m/24,I=f.lineOffsetX*P,C=f.lineOffsetY*P;let R;if(f.numGlyphs>1){const e=f.glyphStartIndex+f.numGlyphs,u=f.lineStartIndex,m=f.lineStartIndex+f.lineLength,b=Gt(P,x,I,C,g,f,S,c);if(!b)return{notEnoughRoom:!0};const F=li(b.first.point.x,b.first.point.y,c,p),L=li(b.last.point.x,b.last.point.y,c,p);if(y&&!g){const e=Ut(f.writingMode,F,L,T);if(e)return e}R=[b.first];for(let p=f.glyphStartIndex+1;p0?y.point:Yt(c.tileAnchorPoint,g,e,1,c),b=li(e.x,e.y,c,p),S=li(x.x,x.y,c,p),P=Ut(f.writingMode,b,S,T);if(P)return P}const e=pi(P*x.getoffsetX(f.glyphStartIndex),I,C,g,f.segment,f.lineStartIndex,f.lineStartIndex+f.lineLength,c,S);if(!e||c.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};R=[e]}for(const e of R)u.aG(b,e.point,e.angle);return{}}function Yt(e,c,u,p,f){const m=e.add(e.sub(c)._unit()),g=ai(m.x,m.y,f).point,y=u.sub(g);return u.add(y._mult(p/y.mag()))}function Kt(e,c,p){const f=c.projectionCache;if(f.projections[e])return f.projections[e];const m=new u.P(c.lineVertexArray.getx(e),c.lineVertexArray.gety(e)),g=ai(m.x,m.y,c);if(g.signedDistanceFromCamera>0)return f.projections[e]=g.point,f.anyProjectionOccluded=f.anyProjectionOccluded||g.isOccluded,g.point;const y=e-p.direction;return Yt(0===p.distanceFromAnchor?c.tileAnchorPoint:new u.P(c.lineVertexArray.getx(y),c.lineVertexArray.gety(y)),m,p.previousVertex,p.absOffsetX-p.distanceFromAnchor+1,c)}function ai(e,c,u){const p=e+u.translation[0],f=c+u.translation[1];let m;return u.pitchWithMap?(m=kt(p,f,u.pitchedLabelPlaneMatrix,u.getElevation),m.isOccluded=!1):(m=u.transform.projectTileCoordinates(p,f,u.unwrappedTileID,u.getElevation),m.point.x=(.5*m.point.x+.5)*u.width,m.point.y=(.5*-m.point.y+.5)*u.height),m}function li(e,c,p,f){if(p.pitchWithMap){const m=[e,c,0,1];return u.aH(m,m,f),p.transform.projectTileCoordinates(m[0]/m[3],m[1]/m[3],p.unwrappedTileID,p.getElevation).point}return{x:e/p.width*2-1,y:1-c/p.height*2}}function ci(e,c,u){return u.transform.projectTileCoordinates(e,c,u.unwrappedTileID,u.getElevation)}function hi(e,c,u){return e._unit()._perp()._mult(c*u)}function di(e,c,p,f,m,g,y,x,b){if(x.projectionCache.offsets[e])return x.projectionCache.offsets[e];const T=p.add(c);if(e+b.direction=m)return x.projectionCache.offsets[e]=T,T;const S=Kt(e+b.direction,x,b),P=hi(S.sub(p),y,b.direction),I=p.add(P),C=S.add(P);return x.projectionCache.offsets[e]=u.aI(g,T,I,C)||T,x.projectionCache.offsets[e]}function pi(e,c,u,p,f,m,g,y,x){const b=p?e-c:e+c;let T=b>0?1:-1,S=0;p&&(T*=-1,S=Math.PI),T<0&&(S+=Math.PI);let P,I=T>0?m+f:m+f+1;y.projectionCache.cachedAnchorPoint?P=y.projectionCache.cachedAnchorPoint:(P=ai(y.tileAnchorPoint.x,y.tileAnchorPoint.y,y).point,y.projectionCache.cachedAnchorPoint=P);let C,R,F=P,L=P,B=0,O=0;const V=Math.abs(b),j=[];let G;for(;B+O<=V;){if(I+=T,I=g)return null;B+=O,L=F,R=C;const e={absOffsetX:V,direction:T,distanceFromAnchor:B,previousVertex:L};if(F=Kt(I,y,e),0===u)j.push(L),G=F.sub(L);else{let c;const p=F.sub(L);c=0===p.mag()?hi(Kt(I+T,y,e).sub(F),u,T):hi(p,u,T),R||(R=L.add(c)),C=di(I,c,F,m,g,R,u,y,e),j.push(R),G=C.sub(R)}O=G.mag()}const U=G._mult((V-B)/O)._add(R||L),q=S+Math.atan2(F.y-L.y,F.x-L.x);return j.push(U),{point:U,angle:x?q:0,path:j}}const fi=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function mi(e,c){for(let u=0;u=1;e--)I.push(g.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let F=[];if(I.length>0){const e=I[0].clone(),c=I[0].clone();for(let u=1;u=p.x&&c.x<=f.x&&e.y>=p.y&&c.y<=f.y?[I]:c.xf.x||c.yf.y?[]:u.aJ([I],p.x,p.y,f.x,f.y)}for(const u of F){m.reset(u,.25*c);let p=0;p=m.length<=.5*c?1:Math.ceil(m.paddedLength/C)+1;for(let u=0;u{const u=kt(e.x,e.y,p,c.getElevation),f=c.transform.projectTileCoordinates(u.point.x,u.point.y,c.unwrappedTileID,c.getElevation);return f.point.x=(.5*f.point.x+.5)*c.width,f.point.y=(.5*-f.point.y+.5)*c.height,f}))}(e,c);return function(e){let c=0,u=0,p=0,f=0;for(let m=0;mu&&(u=f,c=p));return e.slice(c,c+u)}(p)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const c=[],p=new u.aa;for(const f of e){const e=new u.P(f.x+yi,f.y+yi);p.extend(e),c.push(e)}const{minX:f,minY:m,maxX:g,maxY:y}=p,x=this.grid.query(f,m,g,y).concat(this.ignoredGrid.query(f,m,g,y)),b={},T={};for(const e of x){const p=e.key;if(void 0===b[p.bucketInstanceId]&&(b[p.bucketInstanceId]={}),b[p.bucketInstanceId][p.featureIndex])continue;const f=[new u.P(e.x1,e.y1),new u.P(e.x2,e.y1),new u.P(e.x2,e.y2),new u.P(e.x1,e.y2)];u.aK(c,f)&&(b[p.bucketInstanceId][p.featureIndex]=!0,void 0===T[p.bucketInstanceId]&&(T[p.bucketInstanceId]=[]),T[p.bucketInstanceId].push(p.featureIndex))}return T}insertCollisionBox(e,c,u,p,f,m){(u?this.ignoredGrid:this.grid).insert({bucketInstanceId:p,featureIndex:f,collisionGroupID:m,overlapMode:c},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,c,u,p,f,m){const g=u?this.ignoredGrid:this.grid,y={bucketInstanceId:p,featureIndex:f,collisionGroupID:m,overlapMode:c};for(let c=0;c=this.screenRightBoundary||pthis.screenBottomBoundary}isInsideGrid(e,c,u,p){return u>=0&&e=0&&cthis.projectAndGetPerspectiveRatio(e.x,e.y,f,b,S)));ee=e.some((e=>!e.isOccluded)),Q=e.map((e=>new u.P(e.x,e.y)))}else ee=!0;return{box:u.aL(Q),allPointsOccluded:!ee}}}class ct{constructor(e,c,u,p){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?c:-c))):p&&u?1:0,this.placed=u}isHidden(){return 0===this.opacity&&!this.placed}}class ht{constructor(e,c,u,p,f){this.text=new ct(e?e.text:null,c,u,f),this.icon=new ct(e?e.icon:null,c,p,f)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class ut{constructor(e,c,u){this.text=e,this.icon=c,this.skipFade=u}}class dt{constructor(e,c,u,p,f){this.bucketInstanceId=e,this.featureIndex=c,this.sourceLayerIndex=u,this.bucketIndex=p,this.tileID=f}}class _t{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const c=++this.maxGroupID;this.collisionGroups[e]={ID:c,predicate:e=>e.collisionGroupID===c}}return this.collisionGroups[e]}}function xi(e,c,p,f,m){const{horizontalAlign:g,verticalAlign:y}=u.aS(e);return new u.P(-(g-.5)*c+f[0]*m,-(y-.5)*p+f[1]*m)}class mt{constructor(e,c,u,p,f){this.transform=e.clone(),this.terrain=c,this.collisionIndex=new lt(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=u,this.retainedQueryData={},this.collisionGroups=new _t(p),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=f,f&&(f.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const c=this.terrain;return c?(u,p)=>c.getElevation(e,u,p):null}getBucketParts(e,c,p,f){const m=p.getBucket(c),g=p.latestFeatureIndex;if(!m||!g||c.id!==m.layerIds[0])return;const y=p.collisionBoxArray,x=m.layers[0].layout,b=m.layers[0].paint,T=Math.pow(2,this.transform.zoom-p.tileID.overscaledZ),S=p.tileSize/u.a5,P=p.tileID.toUnwrapped(),I="map"===x.get("text-rotation-alignment"),C=u.aN(p,1,this.transform.zoom),R=u.aO(this.collisionIndex.transform,p,b.get("text-translate"),b.get("text-translate-anchor")),F=u.aO(this.collisionIndex.transform,p,b.get("icon-translate"),b.get("icon-translate-anchor")),L=Et(I,this.transform,C);this.retainedQueryData[m.bucketInstanceId]=new dt(m.bucketInstanceId,g,m.sourceLayerIndex,m.index,p.tileID);const B={bucket:m,layout:x,translationText:R,translationIcon:F,unwrappedTileID:P,pitchedLabelPlaneMatrix:L,scale:T,textPixelRatio:S,holdingForFade:p.holdingForSymbolFade(),collisionBoxArray:y,partiallyEvaluatedTextSize:u.ay(m.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(m.sourceID)};if(f)for(const c of m.sortKeyRanges){const{sortKey:u,symbolInstanceStart:p,symbolInstanceEnd:f}=c;e.push({sortKey:u,symbolInstanceStart:p,symbolInstanceEnd:f,parameters:B})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:m.symbolInstances.length,parameters:B})}attemptAnchorPlacement(e,c,p,f,m,g,y,x,b,T,S,P,I,C,R,F,L,B,O,V){const j=u.aP[e.textAnchor],G=[e.textOffset0,e.textOffset1],U=xi(j,p,f,G,m),q=this.collisionIndex.placeCollisionBox(c,P,x,b,T,y,g,F,S.predicate,O,U,V);if((!B||this.collisionIndex.placeCollisionBox(B,P,x,b,T,y,g,L,S.predicate,O,U,V).placeable)&&q.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[I.crossTileID]&&this.prevPlacement.placements[I.crossTileID]&&this.prevPlacement.placements[I.crossTileID].text&&(e=this.prevPlacement.variableOffsets[I.crossTileID].anchor),0===I.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[I.crossTileID]={textOffset:G,width:p,height:f,anchor:j,textBoxScale:m,prevAnchor:e},this.markUsedJustification(C,j,I,R),C.allowVerticalPlacement&&(this.markUsedOrientation(C,R,I),this.placedOrientations[I.crossTileID]=R),{shift:U,placedGlyphBoxes:q}}}placeLayerBucketPart(e,c,p){const{bucket:f,layout:m,translationText:g,translationIcon:y,unwrappedTileID:x,pitchedLabelPlaneMatrix:b,textPixelRatio:T,holdingForFade:S,collisionBoxArray:P,partiallyEvaluatedTextSize:I,collisionGroup:C}=e.parameters,R=m.get("text-optional"),F=m.get("icon-optional"),L=u.aQ(m,"text-overlap","text-allow-overlap"),B="always"===L,O=u.aQ(m,"icon-overlap","icon-allow-overlap"),V="always"===O,j="map"===m.get("text-rotation-alignment"),G="map"===m.get("text-pitch-alignment"),U="none"!==m.get("icon-text-fit"),q="viewport-y"===m.get("symbol-z-order"),Z=B&&(V||!f.hasIconData()||F),W=V&&(B||!f.hasTextData()||R);!f.collisionArrays&&P&&f.deserializeCollisionBoxes(P);const J=this.retainedQueryData[f.bucketInstanceId].tileID,Q=this._getTerrainElevationFunc(J),ee=this.transform.getFastPathSimpleProjectionMatrix(J),se=(e,P,V)=>{var q,se;if(c[e.crossTileID])return;if(S)return void(this.placements[e.crossTileID]=new ut(!1,!1,!1));let ce=!1,he=!1,ue=!0,de=null,fe={box:null,placeable:!1,offscreen:null,occluded:!1},me={placeable:!1},ge=null,ye=null,xe=null,ve=0,be=0,we=0;P.textFeatureIndex?ve=P.textFeatureIndex:e.useRuntimeCollisionCircles&&(ve=e.featureIndex),P.verticalTextFeatureIndex&&(be=P.verticalTextFeatureIndex);const Se=P.textBox;if(Se){const c=c=>{let p=u.az.horizontal;if(f.allowVerticalPlacement&&!c&&this.prevPlacement){const c=this.prevPlacement.placedOrientations[e.crossTileID];c&&(this.placedOrientations[e.crossTileID]=c,p=c,this.markUsedOrientation(f,p,e))}return p},m=(c,p)=>{if(f.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&P.verticalTextBox){for(const e of f.writingModes)if(e===u.az.vertical?(fe=p(),me=fe):fe=c(),fe&&fe.placeable)break}else fe=c()},b=e.textAnchorOffsetStartIndex,S=e.textAnchorOffsetEndIndex;if(S===b){const p=(c,u)=>{const p=this.collisionIndex.placeCollisionBox(c,L,T,J,x,G,j,g,C.predicate,Q,void 0,ee);return p&&p.placeable&&(this.markUsedOrientation(f,u,e),this.placedOrientations[e.crossTileID]=u),p};m((()=>p(Se,u.az.horizontal)),(()=>{const c=P.verticalTextBox;return f.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&c?p(c,u.az.vertical):{box:null,offscreen:null}})),c(fe&&fe.placeable)}else{let I=u.aP[null===(se=null===(q=this.prevPlacement)||void 0===q?void 0:q.variableOffsets[e.crossTileID])||void 0===se?void 0:se.anchor];const R=(c,u,m)=>{const P=c.x2-c.x1,R=c.y2-c.y1,F=e.textBoxScale,B=U&&"never"===O?u:null;let V=null,q="never"===L?1:2,Z="never";I&&q++;for(let u=0;uR(Se,P.iconBox,u.az.horizontal)),(()=>{const c=P.verticalTextBox;return f.allowVerticalPlacement&&(!fe||!fe.placeable)&&e.numVerticalGlyphVertices>0&&c?R(c,P.verticalIconBox,u.az.vertical):{box:null,occluded:!0,offscreen:null}})),fe&&(ce=fe.placeable,ue=fe.offscreen);const F=c(fe&&fe.placeable);if(!ce&&this.prevPlacement){const c=this.prevPlacement.variableOffsets[e.crossTileID];c&&(this.variableOffsets[e.crossTileID]=c,this.markUsedJustification(f,c.anchor,e,F))}}}if(ge=fe,ce=ge&&ge.placeable,ue=ge&&ge.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){const c=f.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),y=u.aA(f.textSizeData,I,c),T=m.get("text-padding");ye=this.collisionIndex.placeCollisionCircles(L,c,f.lineVertexArray,f.glyphOffsetArray,y,x,b,p,G,C.predicate,e.collisionCircleDiameter,T,g,Q),ye.circles.length&&ye.collisionDetected&&!p&&u.w("Collisions detected, but collision boxes are not shown"),ce=B||ye.circles.length>0&&!ye.collisionDetected,ue=ue&&ye.offscreen}if(P.iconFeatureIndex&&(we=P.iconFeatureIndex),P.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,O,T,J,x,G,j,y,C.predicate,Q,U&&de?de:void 0,ee);me&&me.placeable&&P.verticalIconBox?(xe=e(P.verticalIconBox),he=xe.placeable):(xe=e(P.iconBox),he=xe.placeable),ue=ue&&xe.offscreen}const Me=R||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,Ee=F||0===e.numIconVertices;Me||Ee?Ee?Me||(he=he&&ce):ce=he&&ce:he=ce=he&&ce;const Ce=he&&xe.placeable;if(ce&&ge.placeable&&this.collisionIndex.insertCollisionBox(ge.box,L,m.get("text-ignore-placement"),f.bucketInstanceId,me&&me.placeable&&be?be:ve,C.ID),Ce&&this.collisionIndex.insertCollisionBox(xe.box,O,m.get("icon-ignore-placement"),f.bucketInstanceId,we,C.ID),ye&&ce&&this.collisionIndex.insertCollisionCircles(ye.circles,L,m.get("text-ignore-placement"),f.bucketInstanceId,ve,C.ID),p&&this.storeCollisionData(f.bucketInstanceId,V,P,ge,xe,ye),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===f.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new ut((ce||Z)&&!(null==ge?void 0:ge.occluded),(he||W)&&!(null==xe?void 0:xe.occluded),ue||f.justReloaded),c[e.crossTileID]=!0};if(q){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const c=f.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=c.length-1;e>=0;--e){const u=c[e];se(f.symbolInstances.get(u),f.collisionArrays[u],u)}}else for(let c=e.symbolInstanceStart;c=0&&(e.text.placedSymbolArray.get(c).crossTileID=m>=0&&c!==m?0:p.crossTileID)}markUsedOrientation(e,c,p){const f=c===u.az.horizontal||c===u.az.horizontalOnly?c:0,m=c===u.az.vertical?c:0,g=[p.leftJustifiedTextSymbolIndex,p.centerJustifiedTextSymbolIndex,p.rightJustifiedTextSymbolIndex];for(const c of g)e.text.placedSymbolArray.get(c).placedOrientation=f;p.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(p.verticalPlacedTextSymbolIndex).placedOrientation=m)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const c=this.prevPlacement;let u=!1;this.prevZoomAdjustment=c?c.zoomAdjustment(this.transform.zoom):0;const p=c?c.symbolFadeChange(e):1,f=c?c.opacities:{},m=c?c.variableOffsets:{},g=c?c.placedOrientations:{};for(const e in this.placements){const c=this.placements[e],m=f[e];m?(this.opacities[e]=new ht(m,p,c.text,c.icon),u=u||c.text!==m.text.placed||c.icon!==m.icon.placed):(this.opacities[e]=new ht(null,p,c.text,c.icon,c.skipFade),u=u||c.text||c.icon)}for(const e in f){const c=f[e];if(!this.opacities[e]){const f=new ht(c,p,!1,!1);f.isHidden()||(this.opacities[e]=f,u=u||c.text.placed||c.icon.placed)}}for(const e in m)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=m[e]);for(const e in g)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=g[e]);if(c&&void 0===c.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");u?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=c?c.lastPlacementChangeTime:e)}updateLayerOpacities(e,c){const u={};for(const p of c){const c=p.getBucket(e);c&&p.latestFeatureIndex&&e.id===c.layerIds[0]&&this.updateBucketOpacities(c,p.tileID,u,p.collisionBoxArray)}}updateBucketOpacities(e,c,p,f){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const m=e.layers[0],g=m.layout,y=new ht(null,0,!1,!1,!0),x=g.get("text-allow-overlap"),b=g.get("icon-allow-overlap"),T=m._unevaluatedLayout.hasValue("text-variable-anchor")||m._unevaluatedLayout.hasValue("text-variable-anchor-offset"),S="map"===g.get("text-rotation-alignment"),P="map"===g.get("text-pitch-alignment"),I="none"!==g.get("icon-text-fit"),C=new ht(null,0,x&&(b||!e.hasIconData()||g.get("icon-optional")),b&&(x||!e.hasTextData()||g.get("text-optional")),!0);!e.collisionArrays&&f&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(f);const R=(e,c,u)=>{for(let p=0;p0,B=this.placedOrientations[f.crossTileID],O=B===u.az.vertical,V=B===u.az.horizontal||B===u.az.horizontalOnly;if(m>0||g>0){const c=Li(b.text);R(e.text,m,O?Bi:c),R(e.text,g,V?Bi:c);const u=b.text.isHidden();[f.rightJustifiedTextSymbolIndex,f.centerJustifiedTextSymbolIndex,f.leftJustifiedTextSymbolIndex].forEach((c=>{c>=0&&(e.text.placedSymbolArray.get(c).hidden=u||O?1:0)})),f.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(f.verticalPlacedTextSymbolIndex).hidden=u||V?1:0);const p=this.variableOffsets[f.crossTileID];p&&this.markUsedJustification(e,p.anchor,f,B);const y=this.placedOrientations[f.crossTileID];y&&(this.markUsedJustification(e,"left",f,y),this.markUsedOrientation(e,y,f))}if(L){const c=Li(b.icon),u=!(I&&f.verticalPlacedIconSymbolIndex&&O);f.placedIconSymbolIndex>=0&&(R(e.icon,f.numIconVertices,u?c:Bi),e.icon.placedSymbolArray.get(f.placedIconSymbolIndex).hidden=b.icon.isHidden()),f.verticalPlacedIconSymbolIndex>=0&&(R(e.icon,f.numVerticalIconVertices,u?Bi:c),e.icon.placedSymbolArray.get(f.verticalPlacedIconSymbolIndex).hidden=b.icon.isHidden())}const j=F&&F.has(c)?F.get(c):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const p=e.collisionArrays[c];if(p){let c=new u.P(0,0);if(p.textBox||p.verticalTextBox){let u=!0;if(T){const e=this.variableOffsets[x];e?(c=xi(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),S&&c._rotate(P?-this.transform.bearingInRadians:this.transform.bearingInRadians)):u=!1}if(p.textBox||p.verticalTextBox){let f;p.textBox&&(f=O),p.verticalTextBox&&(f=V),vi(e.textCollisionBox.collisionVertexArray,b.text.placed,!u||f,j.text,c.x,c.y)}}if(p.iconBox||p.verticalIconBox){const u=Boolean(!V&&p.verticalIconBox);let f;p.iconBox&&(f=u),p.verticalIconBox&&(f=!u),vi(e.iconCollisionBox.collisionVertexArray,b.icon.placed,f,j.icon,I?c.x:0,I?c.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}}function vi(e,c,u,p,f,m){p&&0!==p.length||(p=[0,0,0,0]);const g=p[0]-yi,y=p[1]-yi,x=p[2]-yi,b=p[3]-yi;e.emplaceBack(c?1:0,u?1:0,f||0,m||0,g,y),e.emplaceBack(c?1:0,u?1:0,f||0,m||0,x,y),e.emplaceBack(c?1:0,u?1:0,f||0,m||0,x,b),e.emplaceBack(c?1:0,u?1:0,f||0,m||0,g,b)}const bi=Math.pow(2,25),wi=Math.pow(2,24),Ti=Math.pow(2,17),Si=Math.pow(2,16),Ii=Math.pow(2,9),Mi=Math.pow(2,8),ki=Math.pow(2,1);function Li(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const c=e.placed?1:0,u=Math.floor(127*e.opacity);return u*bi+c*wi+u*Ti+c*Si+u*Ii+c*Mi+u*ki+c}const Bi=0;class It{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,c,u,p,f){const m=this._bucketParts;for(;this._currentTileIndexe.sortKey-c.sortKey)));this._currentPartIndex!this._forceFullPlacement&&T()-p>2;for(;this._currentPlacementIndex>=0;){const p=c[e[this._currentPlacementIndex]],m=this.placement.collisionIndex.transform.zoom;if("symbol"===p.type&&(!p.minzoom||p.minzoom<=m)&&(!p.maxzoom||p.maxzoom>m)){if(this._inProgressLayer||(this._inProgressLayer=new It(p)),this._inProgressLayer.continuePlacement(u[p.source],this.placement,this._showCollisionBoxes,p,f))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Vi=512/u.a5/2;class St{constructor(e,c,p){this.tileID=e,this.bucketInstanceId=p,this._symbolsByKey={};const f=new Map;for(let e=0;e({x:Math.floor(e.anchorX*Vi),y:Math.floor(e.anchorY*Vi)}))),crossTileIDs:c.map((e=>e.crossTileID))};if(p.positions.length>128){const e=new u.aT(p.positions.length,16,Uint16Array);for(const{x:c,y:u}of p.positions)e.add(c,u);e.finish(),delete p.positions,p.index=e}this._symbolsByKey[e]=p}}getScaledCoordinates(e,c){const{x:p,y:f,z:m}=this.tileID.canonical,{x:g,y:y,z:x}=c.canonical,b=Vi/Math.pow(2,x-m),T=(y*u.a5+e.anchorY)*b,S=f*u.a5*Vi;return{x:Math.floor((g*u.a5+e.anchorX)*b-p*u.a5*Vi),y:Math.floor(T-S)}}findMatches(e,c,u){const p=this.tileID.canonical.ze))}}class zt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Rt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const c=Math.round((e-this.lng)/360);if(0!==c)for(const e in this.indexes){const u=this.indexes[e],p={};for(const e in u){const f=u[e];f.tileID=f.tileID.unwrapTo(f.tileID.wrap+c),p[f.tileID.key]=f}this.indexes[e]=p}this.lng=e}addBucket(e,c,u){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===c.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;ee.overscaledZ)for(const u in f){const m=f[u];m.tileID.isChildOf(e)&&m.findMatches(c.symbolInstances,e,p)}else{const m=f[e.scaledTo(Number(u)).key];m&&m.findMatches(c.symbolInstances,e,p)}}for(let e=0;e{c[e]=!0}));for(const e in this.layerIndexes)c[e]||delete this.layerIndexes[e]}}var ji="void main() {fragColor=vec4(1.0);}";const Ni={prelude:Ui("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:Ui("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:Ui("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:Ui("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:Ui("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:Ui("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:Ui(ji,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:Ui("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:Ui("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:Ui("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:Ui("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:Ui("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:Ui("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:Ui(ji,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:Ui("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:Ui("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:Ui("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:Ui("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:Ui("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:Ui("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:Ui("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Ui("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:Ui("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:Ui("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:Ui("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:Ui("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:Ui("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),raster:Ui("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:Ui("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:Ui("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset)*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:Ui("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:Ui("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:Ui("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:Ui("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:Ui("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:Ui("#ifdef GL_ES\nprecision highp float;\n#endif\nin vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:Ui("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function Ui(e,c){const u=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,p=c.match(/in ([\w]+) ([\w]+)/g),f=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),m=c.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),g=m?m.concat(f):f,y={};return{fragmentSource:e=e.replace(u,((e,c,u,p,f)=>(y[f]=!0,"define"===c?`\n#ifndef HAS_UNIFORM_u_${f}\nin ${u} ${p} ${f};\n#else\nuniform ${u} ${p} u_${f};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${f}\n ${u} ${p} ${f} = u_${f};\n#endif\n`))),vertexSource:c=c.replace(u,((e,c,u,p,f)=>{const m="float"===p?"vec2":"vec4",g=f.match(/color/)?"color":m;return y[f]?"define"===c?`\n#ifndef HAS_UNIFORM_u_${f}\nuniform lowp float u_${f}_t;\nin ${u} ${m} a_${f};\nout ${u} ${p} ${f};\n#else\nuniform ${u} ${p} u_${f};\n#endif\n`:"vec4"===g?`\n#ifndef HAS_UNIFORM_u_${f}\n ${f} = a_${f};\n#else\n ${u} ${p} ${f} = u_${f};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${f}\n ${f} = unpack_mix_${g}(a_${f}, u_${f}_t);\n#else\n ${u} ${p} ${f} = u_${f};\n#endif\n`:"define"===c?`\n#ifndef HAS_UNIFORM_u_${f}\nuniform lowp float u_${f}_t;\nin ${u} ${m} a_${f};\n#else\nuniform ${u} ${p} u_${f};\n#endif\n`:"vec4"===g?`\n#ifndef HAS_UNIFORM_u_${f}\n ${u} ${p} ${f} = a_${f};\n#else\n ${u} ${p} ${f} = u_${f};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${f}\n ${u} ${p} ${f} = unpack_mix_${g}(a_${f}, u_${f}_t);\n#else\n ${u} ${p} ${f} = u_${f};\n#endif\n`})),staticAttributes:p,staticUniforms:g}}class Ft{constructor(e,c,u){this.vertexBuffer=e,this.indexBuffer=c,this.segments=u}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var qi=u.aU([{name:"a_pos",type:"Int16",components:2}]);const $i="#define PROJECTION_MERCATOR",Zi="mercator";class Nt{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Zi}get shaderDefine(){return $i}get shaderPreludeCode(){return Ni.projectionMercator}get vertexShaderPreludeCode(){return Ni.projectionMercator.vertexSource}get subdivisionGranularity(){return u.aV.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,c,p,f,m){if(this._cachedMesh)return this._cachedMesh;const g=new u.aW;g.emplaceBack(0,0),g.emplaceBack(u.a5,0),g.emplaceBack(0,u.a5),g.emplaceBack(u.a5,u.a5);const y=e.createVertexBuffer(g,qi.members),x=u.aX.simpleSegment(0,0,4,2),b=new u.aY;b.emplaceBack(1,0,2),b.emplaceBack(1,2,3);const T=e.createIndexBuffer(b);return this._cachedMesh=new Ft(y,T,x),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class Zt{constructor(e=0,c=0,u=0,p=0){if(isNaN(e)||e<0||isNaN(c)||c<0||isNaN(u)||u<0||isNaN(p)||p<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=c,this.left=u,this.right=p}interpolate(e,c,p){return null!=c.top&&null!=e.top&&(this.top=u.G.number(e.top,c.top,p)),null!=c.bottom&&null!=e.bottom&&(this.bottom=u.G.number(e.bottom,c.bottom,p)),null!=c.left&&null!=e.left&&(this.left=u.G.number(e.left,c.left,p)),null!=c.right&&null!=e.right&&(this.right=u.G.number(e.right,c.right,p)),this}getCenter(e,c){const p=u.an((this.left+e-this.right)/2,0,e),f=u.an((this.top+c-this.bottom)/2,0,c);return new u.P(p,f)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Zt(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Wi(e,c){if(!e.renderWorldCopies||e.lngRange)return;const u=c.lng-e.center.lng;c.lng+=u>180?-360:u<-180?360:0}function Hi(e){return Math.max(0,Math.floor(e))}class Vt{constructor(e,c){var p;this.applyConstrain=(e,c)=>null!==this._constrainOverride?this._constrainOverride(e,c):this._callbacks.defaultConstrain(e,c),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===(null==c?void 0:c.renderWorldCopies)||!!(null==c?void 0:c.renderWorldCopies),this._minZoom=(null==c?void 0:c.minZoom)||0,this._maxZoom=(null==c?void 0:c.maxZoom)||22,this._minPitch=null==(null==c?void 0:c.minPitch)?0:null==c?void 0:c.minPitch,this._maxPitch=null==(null==c?void 0:c.maxPitch)?60:null==c?void 0:c.maxPitch,this._constrainOverride=null!==(p=null==c?void 0:c.constrainOverride)&&void 0!==p?p:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new u.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Hi(this._zoom),this._scale=u.aq(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Zt,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,c,p){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=Hi(this._zoom),this._scale=u.aq(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Zt(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!p&&e.autoCalculateNearFarZ,c&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){void 0===e&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new u.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const c=u.W(e,-180,180)*Math.PI/180;var p,m,g,y,x,b,T,S,P;this._bearingInRadians!==c&&(this._unmodified=!1,this._bearingInRadians=c,this._calcMatrices(),this._rotationMatrix=f(),p=this._rotationMatrix,g=-this._bearingInRadians,y=(m=this._rotationMatrix)[0],x=m[1],b=m[2],T=m[3],S=Math.sin(g),P=Math.cos(g),p[0]=y*P+b*S,p[1]=x*P+T*S,p[2]=y*-S+b*P,p[3]=x*-S+T*P)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const c=u.an(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==c&&(this._unmodified=!1,this._pitchInRadians=c,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const c=e/180*Math.PI;this._rollInRadians!==c&&(this._unmodified=!1,this._rollInRadians=c,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return u.aZ(this._fovInRadians)}setFov(e){e=u.an(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=u.ap(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const c=this.applyConstrain(this._center,e).zoom;this._zoom!==c&&(this._unmodified=!1,this._zoom=c,this._tileZoom=Math.max(0,Math.floor(c)),this._scale=u.aq(c),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,c){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=c,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,c,u){this._unmodified=!1,this._edgeInsets.interpolate(e,c,u),this.constrainInternal(),this._calcMatrices()}resize(e,c,u=!0){this._width=e,this._height=c,u&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new $([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-u.ao,u.ao])}getCameraQueryGeometry(e,c){if(1===c.length)return[c[0],e];{const{minX:p,minY:f,maxX:m,maxY:g}=u.aa.fromPoints(c).extend(e);return[new u.P(p,f),new u.P(m,f),new u.P(m,g),new u.P(p,g),new u.P(p,f)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:c,zoom:u}=this.applyConstrain(this.center,this.zoom);this.setCenter(c),this.setZoom(u),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=u.ar(new Float64Array(16));u.Q(e,e,[this._width/2,-this._height/2,1]),u.O(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=u.ar(new Float64Array(16)),u.Q(e,e,[1,-1,1]),u.O(e,e,[-1,-1,0]),u.Q(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,c,p,f){const m=void 0!==p?p:this.bearing,g=f=void 0!==f?f:this.pitch,{distanceToCenter:y,clampedElevation:x}=this._distanceToCenterFromAltElevationPitch(c,this.elevation,g),{x:b,y:T}=et(g,m),S=u.a9.fromLngLat(e,c);let P,I,C=u.a_(1,S.y),R=0;do{if(R+=1,R>10)break;I=y/C,P=new u.a9(S.x+b*I,S.y+T*I),C=1/P.meterInMercatorCoordinateUnits()}while(Math.abs(y-I*C)>1e-12);return{center:P.toLngLat(),elevation:x,zoom:u.at(this.height/2/Math.tan(this.fovInRadians/2)/I/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const c=1/this.worldSize,p=u.as(1,this.center.lat)*this.worldSize,f=u.a9.fromLngLat(this.center,this.elevation),m=f.x/c,g=f.y/c,y=f.z/c,x=this.pitch,b=this.bearing,{x:T,y:S,z:P}=et(x,b),I=this.cameraToCenterDistance,C=m+I*-T,R=g+I*-S,F=y+I*P,{distanceToCenter:L,clampedElevation:B}=this._distanceToCenterFromAltElevationPitch(F/p,e,x),O=L*p,V=new u.a9((C+T*O)*c,(R+S*O)*c,0).toLngLat(),j=u.as(1,V.lat),G=u.at(this.height/2/Math.tan(this.fovInRadians/2)/L/j/this.tileSize);this._elevation=B,this._center=V,this.setZoom(G)}_distanceToCenterFromAltElevationPitch(e,c,p){const f=-Math.cos(u.ap(p)),m=e-c;let g,y=c;return f*m>=0||Math.abs(f)<.1?(g=1e4,y=e+g*f):g=-m/f,{distanceToCenter:g,clampedElevation:y}}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new u.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=u.as(1,this.center.lat)*this.worldSize;return Ye(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const c=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(c+=e[p]*this.min[p],u+=e[p]*this.max[p]):(u+=e[p]*this.min[p],c+=e[p]*this.max[p]);return c>=0?2:u<0?0:1}}class Wt{distanceToTile2d(e,c,u,p){const f=p.distanceX([e,c]),m=p.distanceY([e,c]);return Math.hypot(f,m)}getWrap(e,c,u){return u}getTileBoundingVolume(e,c,p,f){var m,g;let y=0,x=0;if(null==f?void 0:f.terrain){const b=new u.a2(e.z,c,e.z,e.x,e.y),T=f.terrain.getMinMaxElevation(b);y=null!==(m=T.minElevation)&&void 0!==m?m:Math.min(0,p),x=null!==(g=T.maxElevation)&&void 0!==g?g:Math.max(0,p)}const b=1<f}allowWorldCopies(){return!0}prepareNextFrame(){}}class $t{constructor(e,c,u){this.points=e,this.planes=c,this.aabb=u}static fromInvProjectionMatrix(e,c=1,p=0,f,m){const g=m?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],y=Math.pow(2,p),x=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((p=>function(e,c,p,f){const m=u.aH([],e,c),g=1/m[3]/p*f;return u.b6(m,m,[g,g,1/m[3],g])}(p,e,c,y)));f&&function(e,c,p,f){const m=f?4:0,g=f?0:4;let y=0;const x=[],b=[];for(let c=0;c<4;c++){const p=u.b2([],e[c+g],e[c+m]),f=u.b7(p);u.a$(p,p,1/f),x.push(f),b.push(p)}for(let c=0;c<4;c++){const f=u.b8(e[c+m],b[c],p);y=null!==f&&f>=0?Math.max(y,f):Math.max(y,x[c])}const T=function(e,c){const p=u.b2([],e[c[0]],e[c[1]]),f=u.b2([],e[c[2]],e[c[1]]),m=[0,0,0,0];return u.b3(m,u.b4([],p,f)),m[3]=-u.b5(m,e[c[0]]),m}(e,c),S=function(e,c){const p=u.b9(e),f=u.ba([],e,1/p),m=u.b2([],c,u.a$([],f,u.b5(c,f))),g=u.b9(m);if(g>0){const e=Math.sqrt(1-f[3]*f[3]),p=u.a$([],f,-f[3]),y=u.b0([],p,u.a$([],m,e/g));return u.bb(c,y)}return null}(p,T);if(null!==S){const e=S/u.b5(b[0],T);y=Math.min(y,e)}for(let c=0;c<4;c++){const u=Math.min(y,x[c]);e[c+g]=[e[c+m][0]+b[c][0]*u,e[c+m][1]+b[c][1]*u,e[c+m][2]+b[c][2]*u,1]}}(x,g[0],f,m);const b=g.map((e=>{const c=u.b2([],x[e[0]],x[e[1]]),p=u.b2([],x[e[2]],x[e[1]]),f=u.b3([],u.b4([],c,p)),m=-u.b5(f,x[e[1]]);return f.concat(m)})),T=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],S=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of x)for(let c=0;c<3;c++)T[c]=Math.min(T[c],e[c]),S[c]=Math.max(S[c],e[c]);return new $t(x,b,new qt(T,S))}}class Ht{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,c,u){return this._helper.interpolatePadding(e,c,u)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,c,u=!0){this._helper.resize(e,c,u)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,c){this._helper.overrideNearFarZ(e,c)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,c){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,c)=>{c=u.an(+c,this.minZoom,this.maxZoom);const p={center:new u.V(e.lng,e.lat),zoom:c};let f=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===f){const e=180-1e-10;f=[-e,e]}const m=this.tileSize*u.aq(p.zoom);let g=0,y=m,x=0,b=m,T=0,S=0;const{x:P,y:I}=this.size;if(this._helper._latRange){const e=this._helper._latRange;g=u.X(e[1])*m,y=u.X(e[0])*m,y-gy&&(L=y-e)}if(f){const e=(x+b)/2;let c=C;this._helper._renderWorldCopies&&(c=u.W(C,e-m/2,e+m/2));const p=P/2;c-pb&&(F=b-p)}if(void 0!==F||void 0!==L){const e=new u.P(null!=F?F:C,null!=L?L:R);p.center=Ue(m,e).wrap()}return p},this.applyConstrain=(e,c)=>this._helper.applyConstrain(e,c),this._helper=new Vt({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,c)=>this.defaultConstrain(e,c)},e),this._coveringTilesDetailsProvider=new Wt}clone(){const e=new Ht;return e.apply(this,!1),e}apply(e,c,u){this._helper.apply(e,c,u)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const c=[new u.bc(0,e)];if(this._helper._renderWorldCopies){const p=this.screenPointToMercatorCoordinate(new u.P(0,0)),f=this.screenPointToMercatorCoordinate(new u.P(this._helper._width,0)),m=this.screenPointToMercatorCoordinate(new u.P(this._helper._width,this._helper._height)),g=this.screenPointToMercatorCoordinate(new u.P(0,this._helper._height)),y=Math.floor(Math.min(p.x,f.x,m.x,g.x)),x=Math.floor(Math.max(p.x,f.x,m.x,g.x)),b=1;for(let p=y-b;p<=x+b;p++)0!==p&&c.push(new u.bc(p,e))}return c}getCameraFrustum(){return $t.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const c=this.screenPointToLocation(this.centerPoint,e),u=e?e.getElevationForLngLatZoom(c,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(u)}setLocationAtPoint(e,c){const p=u.as(this.elevation,this.center.lat),f=this.screenPointToMercatorCoordinateAtZ(c,p),m=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,p),g=u.a9.fromLngLat(e),y=new u.a9(g.x-(f.x-m.x),g.y-(f.y-m.y));this.setCenter(null==y?void 0:y.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,c){return c?this.coordinatePoint(u.a9.fromLngLat(e),c.getElevationForLngLat(e,this),this._pixelMatrix3D):this.coordinatePoint(u.a9.fromLngLat(e))}screenPointToLocation(e,c){var u;return null===(u=this.screenPointToMercatorCoordinate(e,c))||void 0===u?void 0:u.toLngLat()}screenPointToMercatorCoordinate(e,c){if(c){const u=c.pointCoordinate(e);if(null!=u)return u}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,c){const p=c||0,f=[e.x,e.y,0,1],m=[e.x,e.y,1,1];u.aH(f,f,this._pixelMatrixInverse),u.aH(m,m,this._pixelMatrixInverse);const g=f[3],y=m[3],x=f[1]/g,b=m[1]/y,T=f[2]/g,S=m[2]/y,P=T===S?0:(p-T)/(S-T);return new u.a9(u.G.number(f[0]/g,m[0]/y,P)/this.worldSize,u.G.number(x,b,P)/this.worldSize,p)}coordinatePoint(e,c=0,p=this._pixelMatrix){const f=[e.x*this.worldSize,e.y*this.worldSize,c,1];return u.aH(f,f,p),new u.P(f[0]/f[3],f[1]/f[3])}getBounds(){const e=Math.max(0,this._helper._height/2-$e(this));return(new $).extend(this.screenPointToLocation(new u.P(0,e))).extend(this.screenPointToLocation(new u.P(this._helper._width,e))).extend(this.screenPointToLocation(new u.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new u.P(0,this._helper._height)))}isPointOnMapSurface(e,c){return c?null!=c.pointCoordinate(e):e.y>this.height/2-$e(this)}calculatePosMatrix(e,c=!1,p){var f;const m=null!==(f=e.key)&&void 0!==f?f:u.bd(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),g=c?this._alignedPosMatrixCache:this._posMatrixCache;if(g.has(m)){const e=g.get(m);return p?e.f32:e.f64}const y=He(e,this.worldSize);u.S(y,c?this._alignedProjMatrix:this._viewProjMatrix,y);const x={f64:y,f32:new Float32Array(y)};return g.set(m,x),p?x.f32:x.f64}calculateFogMatrix(e){const c=e.key,p=this._fogMatrixCacheF32;if(p.has(c))return p.get(c);const f=He(e,this.worldSize);return u.S(f,this._fogMatrix,f),p.set(c,new Float32Array(f)),p.get(c)}calculateCenterFromCameraLngLatAlt(e,c,u,p){return this._helper.calculateCenterFromCameraLngLatAlt(e,c,u,p)}_calculateNearFarZIfNeeded(e,c,p){if(!this._helper.autoCalculateNearFarZ)return;const f=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),m=e-f*this._helper._pixelPerMeter/Math.cos(c),g=f<0?m:e,y=Math.PI/2+this.pitchInRadians,x=u.ap(this.fov)*(Math.abs(Math.cos(u.ap(this.roll)))*this.height+Math.abs(Math.sin(u.ap(this.roll)))*this.width)/this.height*(.5+p.y/this.height),b=Math.sin(x)*g/Math.sin(u.an(Math.PI-y-x,.01,Math.PI-.01)),T=$e(this),S=Math.atan(T/this._helper.cameraToCenterDistance),P=u.ap(.75),I=S>P?2*S*(.5+p.y/(2*T)):P,C=Math.sin(I)*g/Math.sin(u.an(Math.PI-y-I,.01,Math.PI-.01)),R=Math.min(b,C);this._helper._farZ=1.01*(Math.cos(Math.PI/2-c)*R+g),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,c=Ge(this.worldSize,this.center),p=c.x,f=c.y;this._helper._pixelPerMeter=u.as(1,this.center.lat)*this.worldSize;const m=u.ap(Math.min(this.pitch,Ne)),g=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(m));let y;this._calculateNearFarZIfNeeded(g,m,e),y=new Float64Array(16),u.be(y,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),u.aB(this._invProjMatrix,y),y[8]=2*-e.x/this._helper._width,y[9]=2*e.y/this._helper._height,this._projectionMatrix=u.bf(y),u.Q(y,y,[1,-1,1]),u.O(y,y,[0,0,-this._helper.cameraToCenterDistance]),u.bg(y,y,-this.rollInRadians),u.bh(y,y,this.pitchInRadians),u.bg(y,y,-this.bearingInRadians),u.O(y,y,[-p,-f,0]),this._mercatorMatrix=u.Q([],y,[this.worldSize,this.worldSize,this.worldSize]),u.Q(y,y,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=u.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,y),u.O(y,y,[0,0,-this.elevation]),this._viewProjMatrix=y,this._invViewProjMatrix=u.aB([],y);const x=[0,0,-1,1];u.aH(x,x,this._invViewProjMatrix),this._cameraPosition=[x[0]/x[3],x[1]/x[3],x[2]/x[3]],this._fogMatrix=new Float64Array(16),u.be(this._fogMatrix,this.fovInRadians,this.width/this.height,g,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,u.Q(this._fogMatrix,this._fogMatrix,[1,-1,1]),u.O(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),u.bg(this._fogMatrix,this._fogMatrix,-this.rollInRadians),u.bh(this._fogMatrix,this._fogMatrix,this.pitchInRadians),u.bg(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),u.O(this._fogMatrix,this._fogMatrix,[-p,-f,0]),u.Q(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),u.O(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=u.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,y);const b=this._helper._width%2/2,T=this._helper._height%2/2,S=Math.cos(this.bearingInRadians),P=Math.sin(-this.bearingInRadians),I=p-Math.round(p)+S*b+P*T,C=f-Math.round(f)+S*T+P*b,R=new Float64Array(y);if(u.O(R,R,[I>.5?I-1:I,C>.5?C-1:C,0]),this._alignedProjMatrix=R,y=u.aB(new Float64Array(16),this._pixelMatrix),!y)throw new Error("failed to invert matrix");this._pixelMatrixInverse=y,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new u.P(0,0)),c=[e.x*this.worldSize,e.y*this.worldSize,0,1];return u.aH(c,c,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=u.as(1,this.center.lat)*this.worldSize;return Ye(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,c){const p=u.a9.fromLngLat(e),f=[p.x*this.worldSize,p.y*this.worldSize,c,1];return u.aH(f,f,this._viewProjMatrix),f[2]/f[3]}getProjectionData(e){const{overscaledTileID:c,aligned:p,applyTerrainMatrix:f}=e,m=this._helper.getMercatorTileCoordinates(c),g=c?this.calculatePosMatrix(c,p,!0):null;let y;return y=c&&c.terrainRttPosMatrix32f&&f?c.terrainRttPosMatrix32f:g||u.bi(),{mainMatrix:y,tileMercatorCoords:m,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:y}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,c,u){return 1}transformLightDirection(e){return u.b1(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,c,p,f){const m=this.calculatePosMatrix(p);let g;f?(g=[e,c,f(e,c),1],u.aH(g,g,m)):(g=[e,c,0,1],gi(g,g,m));const y=g[3];return{point:new u.P(g[0]/y,g[1]/y),signedDistanceFromCamera:y,isOccluded:!1}}populateCache(e){for(const c of e)this.calculatePosMatrix(c)}getMatrixForModel(e,c){const p=u.a9.fromLngLat(e,c),f=p.meterInMercatorCoordinateUnits(),m=u.bj();return u.O(m,m,[p.x,p.y,p.z]),u.bg(m,m,Math.PI),u.bh(m,m,Math.PI/2),u.Q(m,m,[-f,f,f]),m}getProjectionDataForCustomLayer(e=!0){const c=new u.a2(0,0,0,0,0),p=this.getProjectionData({overscaledTileID:c,applyGlobeMatrix:e}),f=He(c,this.worldSize);u.S(f,this._viewProjMatrix,f),p.tileMercatorCoords=[0,0,1,1];const m=[u.a5,u.a5,this.worldSize/this._helper.pixelsPerMeter],g=u.bk();return u.Q(g,f,m),p.fallbackMatrix=g,p.mainMatrix=g,p}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function Xi(){u.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Yi(e){if(e.useSlerp)if(e.k<1){const c=u.bl(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),p=u.bl(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),f=new Float64Array(4);u.bm(f,c,p,e.k);const m=u.bn(f);e.tr.setRoll(m.roll),e.tr.setPitch(m.pitch),e.tr.setBearing(m.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(u.G.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(u.G.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(u.G.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Ki(e,c,p,f,m){const g=m.padding,y=Ge(m.worldSize,p.getNorthWest()),x=Ge(m.worldSize,p.getNorthEast()),b=Ge(m.worldSize,p.getSouthEast()),T=Ge(m.worldSize,p.getSouthWest()),S=u.ap(-f),P=y.rotate(S),I=x.rotate(S),C=b.rotate(S),R=T.rotate(S),F=new u.P(Math.max(P.x,I.x,R.x,C.x),Math.max(P.y,I.y,R.y,C.y)),L=new u.P(Math.min(P.x,I.x,R.x,C.x),Math.min(P.y,I.y,R.y,C.y)),B=F.sub(L),O=(m.width-(g.left+g.right+c.left+c.right))/B.x,V=(m.height-(g.top+g.bottom+c.top+c.bottom))/B.y;if(V<0||O<0)return void Xi();const j=Math.min(u.at(m.scale*Math.min(O,V)),e.maxZoom),G=u.P.convert(e.offset),U=new u.P((c.left-c.right)/2,(c.top-c.bottom)/2).rotate(u.ap(f)),q=G.add(U).mult(m.scale/u.aq(j));return{center:Ue(m.worldSize,y.add(b).div(2).sub(q)),zoom:j,bearing:f}}class Qt{get useGlobeControls(){return!1}handlePanInertia(e,c){const u=e.mag(),p=Math.abs($e(c));return{easingOffset:e.mult(Math.min(.75*p/u,1)),easingCenter:c.center}}handleMapControlsRollPitchBearingZoom(e,c){e.bearingDelta&&c.setBearing(c.bearing+e.bearingDelta),e.pitchDelta&&c.setPitch(c.pitch+e.pitchDelta),e.rollDelta&&c.setRoll(c.roll+e.rollDelta),e.zoomDelta&&c.setZoom(c.zoom+e.zoomDelta)}handleMapControlsPan(e,c,u){e.around.distSqr(c.centerPoint)<.01||c.setLocationAtPoint(u,e.around)}cameraForBoxAndBearing(e,c,u,p,f){return Ki(e,c,u,p,f)}handleJumpToCenterZoom(e,c){e.zoom!==(void 0!==c.zoom?+c.zoom:e.zoom)&&e.setZoom(+c.zoom),void 0!==c.center&&e.setCenter(u.V.convert(c.center))}handleEaseTo(e,c){const p=e.zoom,f=e.padding,m={roll:e.roll,pitch:e.pitch,bearing:e.bearing},g={roll:void 0===c.roll?e.roll:c.roll,pitch:void 0===c.pitch?e.pitch:c.pitch,bearing:void 0===c.bearing?e.bearing:c.bearing},y=void 0!==c.zoom,x=!e.isPaddingEqual(c.padding);let b=!1;const T=y?+c.zoom:e.zoom;let S=e.centerPoint.add(c.offsetAsPoint);const P=e.screenPointToLocation(S),{center:I,zoom:C}=e.applyConstrain(u.V.convert(c.center||P),null!=T?T:p);Wi(e,I);const R=Ge(e.worldSize,P),F=Ge(e.worldSize,I).sub(R),L=u.aq(C-p);return b=C!==p,{easeFunc:y=>{if(b&&e.setZoom(u.G.number(p,C,y)),u.bo(m,g)||Yi({startEulerAngles:m,endEulerAngles:g,tr:e,k:y,useSlerp:m.roll!=g.roll}),x&&(e.interpolatePadding(f,c.padding,y),S=e.centerPoint.add(c.offsetAsPoint)),c.around)e.setLocationAtPoint(c.around,c.aroundPoint);else{const c=u.aq(e.zoom-p),f=C>p?Math.min(2,L):Math.max(.5,L),m=Math.pow(f,1-y),g=Ue(e.worldSize,R.add(F.mult(y*m)).mult(c));e.setLocationAtPoint(e.renderWorldCopies?g.wrap():g,S)}},isZooming:b,elevationCenter:I}}handleFlyTo(e,c){const p=void 0!==c.zoom,f=e.zoom,m=e.applyConstrain(u.V.convert(c.center||c.locationAtOffset),p?+c.zoom:f),g=m.center,y=m.zoom;Wi(e,g);const x=Ge(e.worldSize,c.locationAtOffset),b=Ge(e.worldSize,g).sub(x),T=b.mag(),S=u.aq(y-f);let P;if(void 0!==c.minZoom){const p=Math.min(+c.minZoom,f,y),m=e.applyConstrain(g,p).zoom;P=u.aq(m-f)}return{easeFunc:(c,p,m,T)=>{e.setZoom(1===c?y:f+u.at(p));const S=1===c?g:Ue(e.worldSize,x.add(b.mult(m)).mult(p));e.setLocationAtPoint(e.renderWorldCopies?S.wrap():S,T)},scaleOfZoom:S,targetCenter:g,scaleOfMinZoom:P,pixelPathLength:T}}}class Jt{constructor(e,c,u){this.blendFunction=e,this.blendColor=c,this.mask=u}}Jt.Replace=[1,0],Jt.disabled=new Jt(Jt.Replace,u.bp.transparent,[!1,!1,!1,!1]),Jt.unblended=new Jt(Jt.Replace,u.bp.transparent,[!0,!0,!0,!0]),Jt.alphaBlended=new Jt([1,771],u.bp.transparent,[!0,!0,!0,!0]);const Ji=2305;class ti{constructor(e,c,u){this.enable=e,this.mode=c,this.frontFace=u}}ti.disabled=new ti(!1,1029,Ji),ti.backCCW=new ti(!0,1029,Ji),ti.frontCCW=new ti(!0,1028,Ji);class ii{constructor(e,c,u){this.func=e,this.mask=c,this.range=u}}ii.ReadOnly=!1,ii.ReadWrite=!0,ii.disabled=new ii(519,ii.ReadOnly,[0,1]);const Qi=7680;class ri{constructor(e,c,u,p,f,m){this.test=e,this.ref=c,this.mask=u,this.fail=p,this.depthFail=f,this.pass=m}}ri.disabled=new ri({func:519,mask:0},0,0,Qi,Qi,Qi);const cr=new WeakMap;function hr(e){var c;if(cr.has(e))return cr.get(e);{const u=null===(c=e.getParameter(e.VERSION))||void 0===c?void 0:c.startsWith("WebGL 2.0");return cr.set(e,u),u}}class ni{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const c=e.context,p=c.gl;this._texFormat=p.RGBA,this._texType=p.UNSIGNED_BYTE;const f=new u.aW;f.emplaceBack(-1,-1),f.emplaceBack(2,-1),f.emplaceBack(-1,2);const m=new u.aY;m.emplaceBack(0,1,2),this._fullscreenTriangle=new Ft(c.createVertexBuffer(f,qi.members),c.createIndexBuffer(m),u.aX.simpleSegment(0,0,f.length,m.length)),this._resultBuffer=new Uint8Array(4),c.activeTexture.set(p.TEXTURE1);const g=p.createTexture();p.bindTexture(p.TEXTURE_2D,g),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texImage2D(p.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=c.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(g),hr(p)&&(this._pbo=p.createBuffer(),p.bindBuffer(p.PIXEL_PACK_BUFFER,this._pbo),p.bufferData(p.PIXEL_PACK_BUFFER,4,p.STREAM_READ),p.bindBuffer(p.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,c){const u=this._updateCount;return this._readbackQueue?u>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():u>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,c),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,c=e.gl;e.activeTexture.set(c.TEXTURE1),c.bindTexture(c.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,c){const p=this._cachedRenderContext.context,f=p.gl;if(this._bindFramebuffer(),p.viewport.set([0,0,this._texWidth,this._texHeight]),p.clear({color:u.bp.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(p,f.TRIANGLES,ii.disabled,ri.disabled,Jt.unblended,ti.disabled,((e,c)=>({u_input:e,u_output_expected:c}))(e,c),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&hr(f)){f.bindBuffer(f.PIXEL_PACK_BUFFER,this._pbo),f.readBuffer(f.COLOR_ATTACHMENT0),f.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),f.bindBuffer(f.PIXEL_PACK_BUFFER,null);const e=f.fenceSync(f.SYNC_GPU_COMMANDS_COMPLETE,0);f.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&hr(e)){const c=e.clientWaitSync(this._readbackQueue.sync,0,0);if(c===e.WAIT_FAILED)return u.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(c===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=ni._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let c=0;return c+=e[0]/256,c+=e[1]/65536,c+=e[2]/16777216,e[3]<127&&(c=-c),c/128}}const ur=u.a5/128;function dr(e,c){const p=void 0!==e.granularity?Math.max(e.granularity,1):1,f=p+(e.generateBorders?2:0),m=p+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),g=f+1,y=m+1,x=e.generateBorders?-1:0,b=e.generateBorders||e.extendToNorthPole?-1:0,T=p+(e.generateBorders?1:0),S=p+(e.generateBorders||e.extendToSouthPole?1:0),P=g*y,I=f*m*6,C=g*y>65536;if(C&&"16bit"===c)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const R=C||"32bit"===c,F=new Int16Array(2*P);let L=0;for(let c=b;c<=S;c++)for(let f=x;f<=T;f++){let m=f/p*u.a5;-1===f&&(m=-ur),f===p+1&&(m=u.a5+ur);let g=c/p*u.a5;-1===c&&(g=e.extendToNorthPole?u.br:-ur),c===p+1&&(g=e.extendToSouthPole?u.bs:u.a5+ur),F[L++]=m,F[L++]=g}const B=R?new Uint32Array(I):new Uint16Array(I);let O=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,c,u,p,f){return this.currentProjection.getMeshFromTileID(e,c,u,p,f)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function gr(e){const c=vr(e.worldSize,e.center.lat);return 2*Math.PI*c}function yr(e,c,p,f,m){const g=1/(1<1e-6){const f=e[0]/p,m=Math.acos(e[2]/p),g=(f>0?m:-m)/Math.PI*180;return new u.V(u.W(g,-180,180),c)}return new u.V(0,c)}function wr(e){return Math.cos(e*Math.PI/180)}function Sr(e,c){const p=wr(e),f=wr(c);return u.at(f/p)}function Pr(e,c){const p=e.rotate(c.bearingInRadians),f=c.zoom+Sr(c.center.lat,0),m=u.bu(1/wr(c.center.lat),1/wr(Math.min(Math.abs(c.center.lat),60)),u.bx(f,7,3,0,1)),g=360/gr({worldSize:c.worldSize,center:{lat:c.center.lat}});return new u.V(c.center.lng-p.x*g*m,u.an(c.center.lat+p.y*g,-u.ao,u.ao))}function Cr(e){const c=.5*e,u=Math.sin(c),p=Math.cos(c);return Math.log(u+p)-Math.log(p-u)}function Ar(e,c,p,f){const m=e.lat+p*f;if(Math.abs(p)>1){const g=(Math.sign(e.lat+p)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,y=Math.abs(e.lat+p)*Math.PI/180,x=Cr(g+f*(y-g)),b=Cr(g),T=Cr(y);return new u.V(e.lng+c*((x-b)/(T-b)),m)}return new u.V(e.lng+c*f,m)}class Pi{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,c,u,p){const f=`${e.z}_${e.x}_${e.y}_${(null==p?void 0:p.terrain)?"t":""}`,m=this._cache.get(f);if(m)return m;const g=this._cachePrevious.get(f);if(g)return this._cache.set(f,g),g;const y=this._boundingVolumeFactory(e,c,u,p);return this._cache.set(f,y),this._hadAnyChanges=!0,y}}class Ci{constructor(e,c,u,p){this.min=u,this.max=p,this.points=e,this.planes=c}static fromAabb(e,c){const u=[];for(let p=0;p<8;p++)u.push([1&~p?e[0]:c[0],1==(p>>1&1)?c[1]:e[1],1==(p>>2&1)?c[2]:e[2]]);return new Ci(u,[[-1,0,0,c[0]],[1,0,0,-e[0]],[0,-1,0,c[1]],[0,1,0,-e[1]],[0,0,-1,c[2]],[0,0,1,-e[2]]],e,c)}static fromCenterSizeAngles(e,c,p){const f=u.bB([],p[0],p[1],p[2]),m=u.bC([],[c[0],0,0],f),g=u.bC([],[0,c[1],0],f),y=u.bC([],[0,0,c[2]],f),x=[...e],b=[...e];for(let c=0;c<8;c++)for(let u=0;u<3;u++){const p=e[u]+m[u]*(1&~c?-1:1)+g[u]*(1==(c>>1&1)?1:-1)+y[u]*(1==(c>>2&1)?1:-1);x[u]=Math.min(x[u],p),b[u]=Math.max(b[u],p)}const T=[];for(let c=0;c<8;c++){const p=[...e];u.b0(p,p,u.a$([],m,1&~c?-1:1)),u.b0(p,p,u.a$([],g,1==(c>>1&1)?1:-1)),u.b0(p,p,u.a$([],y,1==(c>>2&1)?1:-1)),T.push(p)}return new Ci(T,[[...m,-u.b5(m,T[0])],[...g,-u.b5(g,T[0])],[...y,-u.b5(y,T[0])],[-m[0],-m[1],-m[2],-u.b5(m,T[7])],[-g[0],-g[1],-g[2],-u.b5(g,T[7])],[-y[0],-y[1],-y[2],-u.b5(y,T[7])]],x,b)}intersectsFrustum(e){let c=!0;const u=this.points.length,p=this.planes.length,f=e.planes.length,m=e.points.length;for(let p=0;p=0&&m++}if(0===m)return 0;m=0&&p++}if(0===p)return 0}return 1}intersectsPlane(e){const c=this.points.length;let u=0;for(let p=0;p=0&&u++}return u===c?2:0===u?0:1}}function Dr(e,c,u){const p=e-c;return p<0?-p:Math.max(0,p-u)}function zr(e,c,u,p,f){const m=e-u;let g;return g=m<0?Math.min(-m,1+m-f):m>1?Math.min(Math.max(m-f,0),1-m):0,Math.max(g,Dr(c,p,f))}class Ei{constructor(){this._boundingVolumeCache=new Pi(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,c,u,p){const f=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(e,c,u,p){return this._boundingVolumeCache.getTileBoundingVolume(e,c,u,p)}_computeTileBoundingVolume(e,c,p,f){var m,g;let y=0,x=0;if(null==f?void 0:f.terrain){const b=new u.a2(e.z,c,e.z,e.x,e.y),T=f.terrain.getMinMaxElevation(b);y=null!==(m=T.minElevation)&&void 0!==m?m:Math.min(0,p),x=null!==(g=T.maxElevation)&&void 0!==g?g:Math.max(0,p)}if(y/=u.bE,x/=u.bE,y+=1,x+=1,e.z<=0)return Ci.fromAabb([-x,-x,-x],[x,x,x]);if(1===e.z)return Ci.fromAabb([0===e.x?-x:0,0===e.y?0:-x,-x],[0===e.x?0:x,0===e.y?x:0,x]);{const c=[yr(0,0,e.x,e.y,e.z),yr(u.a5,0,e.x,e.y,e.z),yr(u.a5,u.a5,e.x,e.y,e.z),yr(0,u.a5,e.x,e.y,e.z)],p=[];for(const e of c)p.push(u.a$([],e,x));if(x!==y)for(const e of c)p.push(u.a$([],e,y));0===e.y&&p.push([0,1,0]),e.y===(1<=(1<{const p=u.an(e.lat,-u.ao,u.ao),f=u.an(+c,this.minZoom+Sr(0,p),this.maxZoom);return{center:new u.V(e.lng,p),zoom:f}},this.applyConstrain=(e,c)=>this._helper.applyConstrain(e,c),this._helper=new Vt({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,c)=>this.defaultConstrain(e,c)},e),this._coveringTilesDetailsProvider=new Ei}clone(){const e=new zi;return e.apply(this,!1),e}apply(e,c,u){this._globeLatitudeErrorCorrectionRadians=u||0,this._helper.apply(e,c)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=u.bA();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:c,applyGlobeMatrix:u}=e,p=this._helper.getMercatorTileCoordinates(c);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:p,clippingPlane:this._cachedClippingPlane,projectionTransition:u?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const c=this.pitchInRadians,p=this.cameraToCenterDistance/e,f=Math.sin(c)*p,m=Math.cos(c)*p+1,g=1/Math.sqrt(f*f+m*m)*1;let y=-f,x=m;const b=Math.sqrt(y*y+x*x);y/=b,x/=b;const T=[0,y,x];u.bG(T,T,[0,0,0],-this.bearingInRadians),u.bH(T,T,[0,0,0],-1*this.center.lat*Math.PI/180),u.bI(T,T,[0,0,0],this.center.lng*Math.PI/180);const S=1/u.b7(T);return u.a$(T,T,S),[...T,-g*S]}isLocationOccluded(e){return!this.isSurfacePointVisible(xr(e))}transformLightDirection(e){const c=this._helper._center.lng*Math.PI/180,p=this._helper._center.lat*Math.PI/180,f=Math.cos(p),m=[Math.sin(c)*f,Math.sin(p),Math.cos(c)*f],g=[m[2],0,-m[0]],y=[0,0,0];u.b4(y,g,m),u.b3(g,g),u.b3(y,y);const x=[0,0,0];return u.b3(x,[g[0]*e[0]+y[0]*e[1]+m[0]*e[2],g[1]*e[0]+y[1]*e[1]+m[1]*e[2],g[2]*e[0]+y[2]*e[1]+m[2]*e[2]]),x}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,c,p){const f=function(e,c,p){const f=1/(1<m&&(m=c),py&&(y=p)}const T=[b.lng+g,b.lat+x,b.lng+m,b.lat+y];return this.isSurfacePointOnScreen([0,1,0])&&(T[3]=90,T[0]=-180,T[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(T[1]=-90,T[0]=-180,T[2]=180),new $(T)}calculateCenterFromCameraLngLatAlt(e,c,u,p){return this._helper.calculateCenterFromCameraLngLatAlt(e,c,u,p)}setLocationAtPoint(e,c){const p=xr(this.unprojectScreenPoint(c)),f=xr(e),m=u.bA();u.bL(m);const g=u.bA();u.bI(g,p,m,-this.center.lng*Math.PI/180),u.bH(g,g,m,this.center.lat*Math.PI/180);const y=f[0]*f[0]+f[2]*f[2],x=g[0]*g[0];if(y=-L&&C<=L,O=F>=-L&&F<=L;let V,j;if(B&&O){const e=this.center.lng*Math.PI/180,c=this.center.lat*Math.PI/180;u.bN(S,e)+u.bN(C,c)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const c=u.bF();return u.aH(c,[...e,1],this._globeViewProjMatrixNoCorrection),c[0]/=c[3],c[1]/=c[3],c[2]/=c[3],c[0]>-1&&c[0]<1&&c[1]>-1&&c[1]<1&&c[2]>-1&&c[2]<1}rayPlanetIntersection(e,c){const p=u.b5(e,c),f=u.bA(),m=u.bA();u.a$(m,c,p),u.b2(f,e,m);const g=1-u.b5(f,f);if(g<0)return null;const y=u.b5(e,e)-1,x=-p+(p<0?1:-1)*Math.sqrt(g),b=y/x,T=x;return{tMin:Math.min(b,T),tMax:Math.max(b,T)}}unprojectScreenPoint(e){const c=this._cameraPosition,p=this.getRayDirectionFromPixel(e),f=this.rayPlanetIntersection(c,p);if(f){const e=u.bA();u.b0(e,c,[p[0]*f.tMin,p[1]*f.tMin,p[2]*f.tMin]);const m=u.bA();return u.b3(m,e),br(m)}const m=this._cachedClippingPlane,g=m[0]*p[0]+m[1]*p[1]+m[2]*p[2],y=-u.bb(m,c)/g,x=u.bA();if(y>0)u.b0(x,c,[p[0]*y,p[1]*y,p[2]*y]);else{const e=u.bA();u.b0(e,c,[2*p[0],2*p[1],2*p[2]]);const f=u.bb(this._cachedClippingPlane,e);u.b2(x,e,[this._cachedClippingPlane[0]*f,this._cachedClippingPlane[1]*f,this._cachedClippingPlane[2]*f])}const b=function(e){const c=u.bA();return c[0]=e[0]*-e[3],c[1]=e[1]*-e[3],c[2]=e[2]*-e[3],{center:c,radius:Math.sqrt(1-e[3]*e[3])}}(m);return br(function(e,c,p){const f=u.bA();u.b2(f,p,e);const m=u.bA();return u.by(m,e,f,c/u.b9(f)),m}(b.center,b.radius,x))}getMatrixForModel(e,c){const p=u.V.convert(e),f=1/u.bE,m=u.bj();return u.bJ(m,m,p.lng/180*Math.PI),u.bh(m,m,-p.lat/180*Math.PI),u.O(m,m,[0,0,1+c/u.bE]),u.bh(m,m,.5*Math.PI),u.Q(m,m,[f,f,f]),m}getProjectionDataForCustomLayer(e=!0){const c=this.getProjectionData({overscaledTileID:new u.a2(0,0,0,0,0),applyGlobeMatrix:e});return c.tileMercatorCoords=[0,0,1,1],c}getFastPathSimpleProjectionMatrix(e){}}class Ri{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,c,u){return this._helper.interpolatePadding(e,c,u)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,c,u=!0){this._helper.resize(e,c,u)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,c){this._helper.overrideNearFarZ(e,c)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,c){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=c,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(e,c)=>this.currentTransform.defaultConstrain(e,c),this.applyConstrain=(e,c)=>this._helper.applyConstrain(e,c),this._helper=new Vt({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,c)=>this.defaultConstrain(e,c)},e),this._globeness=1,this._mercatorTransform=new Ht,this._verticalPerspectiveTransform=new zi}clone(){const e=new Ri;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this,!1),e}apply(e,c){this._helper.apply(e,c),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const c=this._mercatorTransform.getProjectionData(e),u=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?u.mainMatrix:c.mainMatrix,clippingPlane:u.clippingPlane,tileMercatorCoords:u.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:c.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return u.bu(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return u.bu(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,c,p){const f=this._mercatorTransform.getPitchedTextCorrection(e,c,p),m=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,c,p);return u.bu(f,m,this._globeness)}projectTileCoordinates(e,c,u,p){return this.currentTransform.projectTileCoordinates(e,c,u,p)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,c){return this.currentTransform.lngLatToCameraDepth(e,c)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,c,u,p){return this._helper.calculateCenterFromCameraLngLatAlt(e,c,u,p)}setLocationAtPoint(e,c){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,c),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(e,c),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(e,c){return this.currentTransform.locationToScreenPoint(e,c)}screenPointToMercatorCoordinate(e,c){return this.currentTransform.screenPointToMercatorCoordinate(e,c)}screenPointToLocation(e,c){return this.currentTransform.screenPointToLocation(e,c)}isPointOnMapSurface(e,c){return this.currentTransform.isPointOnMapSurface(e,c)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,c){return this.currentTransform.getMatrixForModel(e,c)}getProjectionDataForCustomLayer(e=!0){const c=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return c;const u=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return u.fallbackMatrix=c.mainMatrix,u}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Di{get useGlobeControls(){return!0}handlePanInertia(e,c){const p=Pr(e,c);return Math.abs(p.lng-c.center.lng)>180&&(p.lng=c.center.lng+179.5*Math.sign(p.lng-c.center.lng)),{easingCenter:p,easingOffset:new u.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,c){const p=e.around,f=c.screenPointToLocation(p);e.bearingDelta&&c.setBearing(c.bearing+e.bearingDelta),e.pitchDelta&&c.setPitch(c.pitch+e.pitchDelta),e.rollDelta&&c.setRoll(c.roll+e.rollDelta);const m=c.zoom;e.zoomDelta&&c.setZoom(c.zoom+e.zoomDelta);const g=c.zoom-m;if(0===g)return;const y=u.bK(c.center.lng,f.lng),x=y/(Math.abs(y/180)+1),b=u.bK(c.center.lat,f.lat),T=c.getRayDirectionFromPixel(p),S=c.cameraPosition,P=-1*u.b5(S,T),I=u.bA();u.b0(I,S,[T[0]*P,T[1]*P,T[2]*P]);const C=u.b7(I)-1,R=Math.exp(.5*-Math.max(C-.3,0)),F=vr(c.worldSize,c.center.lat)/Math.min(c.width,c.height),L=u.bx(F,.9,.5,1,.25),B=(1-u.aq(-g))*Math.min(R,L),O=c.center.lat,V=c.zoom,j=new u.V(c.center.lng+x*B,u.an(c.center.lat+b*B,-u.ao,u.ao));c.setLocationAtPoint(f,p);const G=c.center,U=u.bx(Math.abs(y),45,85,0,1),q=u.bx(F,.75,.35,0,1),Z=Math.pow(Math.max(U,q),.25),W=u.bK(G.lng,j.lng),J=u.bK(G.lat,j.lat);c.setCenter(new u.V(G.lng+W*Z,G.lat+J*Z).wrap()),c.setZoom(V+Sr(O,c.center.lat))}handleMapControlsPan(e,c,u){if(!e.panDelta)return;const p=c.center.lat,f=c.zoom;c.setCenter(Pr(e.panDelta,c).wrap()),c.setZoom(f+Sr(p,c.center.lat))}cameraForBoxAndBearing(e,c,p,f,m){const g=Ki(e,c,p,f,m),y=c.left/m.width*2-1,x=(m.width-c.right)/m.width*2-1,b=c.top/m.height*-2+1,T=(m.height-c.bottom)/m.height*-2+1,S=u.bK(p.getWest(),p.getEast())<0,P=S?p.getEast():p.getWest(),I=S?p.getWest():p.getEast(),C=Math.max(p.getNorth(),p.getSouth()),R=Math.min(p.getNorth(),p.getSouth()),F=P+.5*u.bK(P,I),L=C+.5*u.bK(C,R),B=m.clone();B.setCenter(g.center),B.setBearing(g.bearing),B.setPitch(0),B.setRoll(0),B.setZoom(g.zoom);const O=B.modelViewProjectionMatrix,V=[xr(p.getNorthWest()),xr(p.getNorthEast()),xr(p.getSouthWest()),xr(p.getSouthEast()),xr(new u.V(I,L)),xr(new u.V(P,L)),xr(new u.V(F,C)),xr(new u.V(F,R))],j=xr(g.center);let G=Number.POSITIVE_INFINITY;for(const e of V)y<0&&(G=Di.getLesserNonNegativeNonNull(G,Di.solveVectorScale(e,j,O,"x",y))),x>0&&(G=Di.getLesserNonNegativeNonNull(G,Di.solveVectorScale(e,j,O,"x",x))),b>0&&(G=Di.getLesserNonNegativeNonNull(G,Di.solveVectorScale(e,j,O,"y",b))),T<0&&(G=Di.getLesserNonNegativeNonNull(G,Di.solveVectorScale(e,j,O,"y",T)));if(Number.isFinite(G)&&0!==G)return g.zoom=B.zoom+u.at(G),g;Xi()}handleJumpToCenterZoom(e,c){const p=e.center.lat,f=e.applyConstrain(c.center?u.V.convert(c.center):e.center,e.zoom).center;e.setCenter(f.wrap());const m=void 0!==c.zoom?+c.zoom:e.zoom+Sr(p,f.lat);e.zoom!==m&&e.setZoom(m)}handleEaseTo(e,c){const p=e.zoom,f=e.center,m=e.padding,g={roll:e.roll,pitch:e.pitch,bearing:e.bearing},y={roll:void 0===c.roll?e.roll:c.roll,pitch:void 0===c.pitch?e.pitch:c.pitch,bearing:void 0===c.bearing?e.bearing:c.bearing},x=void 0!==c.zoom,b=!e.isPaddingEqual(c.padding);let T=!1;const S=c.center?u.V.convert(c.center):f,P=e.applyConstrain(S,p).center;Wi(e,P);const I=e.clone();I.setCenter(P),I.setZoom(x?+c.zoom:p+Sr(f.lat,S.lat)),I.setBearing(c.bearing);const C=new u.P(u.an(e.centerPoint.x+c.offsetAsPoint.x,0,e.width),u.an(e.centerPoint.y+c.offsetAsPoint.y,0,e.height));I.setLocationAtPoint(P,C);const R=(c.offset&&c.offsetAsPoint.mag())>0?I.center:P,F=x?+c.zoom:p+Sr(f.lat,R.lat),L=p+Sr(f.lat,0),B=F+Sr(R.lat,0),O=u.bK(f.lng,R.lng),V=u.bK(f.lat,R.lat),j=u.aq(B-L);return T=F!==p,{easeFunc:p=>{if(u.bo(g,y)||Yi({startEulerAngles:g,endEulerAngles:y,tr:e,k:p,useSlerp:g.roll!=y.roll}),b&&e.interpolatePadding(m,c.padding,p),c.around)u.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(c.around,c.aroundPoint);else{const c=B>L?Math.min(2,j):Math.max(.5,j),u=Math.pow(c,1-p),m=Ar(f,O,V,p*u);e.setCenter(m.wrap())}if(T){const c=u.G.number(L,B,p)+Sr(0,e.center.lat);e.setZoom(c)}},isZooming:T,elevationCenter:R}}handleFlyTo(e,c){const p=void 0!==c.zoom,f=e.center,m=e.zoom,g=e.padding,y=!e.isPaddingEqual(c.padding),x=e.applyConstrain(u.V.convert(c.center||c.locationAtOffset),m).center,b=p?+c.zoom:e.zoom+Sr(e.center.lat,x.lat),T=e.clone();T.setCenter(x),T.setZoom(b),T.setBearing(c.bearing);const S=new u.P(u.an(e.centerPoint.x+c.offsetAsPoint.x,0,e.width),u.an(e.centerPoint.y+c.offsetAsPoint.y,0,e.height));T.setLocationAtPoint(x,S);const P=T.center;Wi(e,P);const I=function(e,c,p){const f=xr(c),m=xr(p),g=u.b5(f,m),y=Math.acos(g),x=gr(e);return y/(2*Math.PI)*x}(e,f,P),C=m+Sr(f.lat,0),R=b+Sr(P.lat,0),F=u.aq(R-C);let L;if("number"==typeof c.minZoom){const p=+c.minZoom+Sr(P.lat,0),f=Math.min(p,C,R)+Sr(0,P.lat),m=e.applyConstrain(P,f).zoom+Sr(P.lat,0);L=u.aq(m-C)}const B=u.bK(f.lng,P.lng),O=u.bK(f.lat,P.lat);return{easeFunc:(p,m,x,T)=>{const S=Ar(f,B,O,x);y&&e.interpolatePadding(g,c.padding,p);const I=1===p?P:S;e.setCenter(I.wrap());const R=C+u.at(m);e.setZoom(1===p?b:R+Sr(0,I.lat))},scaleOfZoom:F,targetCenter:P,scaleOfMinZoom:L,pixelPathLength:I}}static solveVectorScale(e,c,u,p,f){const m="x"===p?[u[0],u[4],u[8],u[12]]:[u[1],u[5],u[9],u[13]],g=[u[3],u[7],u[11],u[15]],y=e[0]*m[0]+e[1]*m[1]+e[2]*m[2],x=e[0]*g[0]+e[1]*g[1]+e[2]*g[2],b=c[0]*m[0]+c[1]*m[1]+c[2]*m[2],T=c[0]*g[0]+c[1]*g[1]+c[2]*g[2];return b+f*x===y+f*T||g[3]*(y-b)+m[3]*(T-x)+y*T==b*x?null:(b+m[3]-f*T-f*g[3])/(b-y-f*T+f*x)}static getLesserNonNegativeNonNull(e,c){return null!==c&&c>=0&&cu.B(e,c&&c.filter((e=>"source.canvas"!==e.identifier))),Lr=u.bO();class Fi extends u.E{constructor(e,c={}){var p,f;super(),this._rtlPluginLoaded=()=>{for(const e in this.tileManagers){const c=this.tileManagers[e].getSource().type;"vector"!==c&&"geojson"!==c||this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new N(ce(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((e,c)=>this.getGlyphs(e,c))),this.dispatcher.registerMessageHandler("GI",((e,c)=>this.getImages(e,c))),this.dispatcher.registerMessageHandler("GDA",((e,c)=>this.getDashes(e,c))),this.imageManager=new w,this.imageManager.setEventedParent(this);const m=(null===(p=e._container)||void 0===p?void 0:p.lang)||"undefined"!=typeof document&&(null===(f=document.documentElement)||void 0===f?void 0:f.lang)||void 0;this.glyphManager=new M(e._requestManager,c.localIdeographFontFamily,m),this.lineAtlas=new A(256,512),this.crossTileSymbolIndex=new Dt,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",u.bP()),Ee().on(Se,this._rtlPluginLoaded),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const c=this.tileManagers[e.sourceId];if(!c)return;const u=c.getSource();if(u&&u.vectorLayerIds)for(const e in this._layers){const c=this._layers[e];c.source===u.id&&this._validateLayer(c)}}))}_setInitialValues(){var e;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new u.bQ,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new((null===(e=this.crossTileSymbolIndex)||void 0===e?void 0:e.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,c){var p,f,m;this._checkLoaded();const g=null===c?null!==(m=null===(f=null===(p=this.stylesheet.state)||void 0===p?void 0:p[e])||void 0===f?void 0:f.default)&&void 0!==m?m:null:c;if(u.bR(g,this._globalState[e]))return this;this._globalState[e]=g,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const c=[];for(const p in e)!u.bR(this._globalState[p],e[p].default)&&(c.push(p),this._globalState[p]=e[p].default);this._applyGlobalStateChanges(c)}_applyGlobalStateChanges(e){if(0===e.length)return;const c=new Set,u={};for(const p of e){u[p]=this._globalState[p];for(const e in this._layers){const u=this._layers[e],f=u.getLayoutAffectingGlobalStateRefs(),m=u.getPaintAffectingGlobalStateRefs(),g=u.getVisibilityAffectingGlobalStateRefs();if(f.has(p)&&c.add(u.source),m.has(p))for(const{name:e,value:c}of m.get(p))this._updatePaintProperty(u,e,c);(null==g?void 0:g.has(p))&&(u.recalculateVisibility(),this._updateLayer(u))}}this.dispatcher.broadcast("UGS",u);for(const e in this.tileManagers)c.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e,c={},p){this.fire(new u.l("dataloading",{dataType:"style"})),c.validate="boolean"!=typeof c.validate||c.validate;const f=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const m=this._loadStyleRequest;u.j(f,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,c,p)})).catch((e=>{this._loadStyleRequest=null,e&&!m.signal.aborted&&this.fire(new u.k(e))}))}loadJSON(e,c={},p){this.fire(new u.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,x.frameAsync(this._frameRequest,this.map._ownerWindow).then((()=>{this._frameRequest=null,c.validate=!1!==c.validate,this._load(e,c,p)})).catch((()=>{}))}loadEmpty(){this.fire(new u.l("dataloading",{dataType:"style"})),this._load(Lr,{validate:!1})}_load(e,c,p){var f,m;let g=c.transformStyle?c.transformStyle(p,e):e;if(!c.validate||!Rr(this,u.C(g))){g=Object.assign({},g),this._loaded=!0,this.stylesheet=g;for(const e in g.sources)this.addSource(e,g.sources[e],{validate:!1});g.sprite?this._loadSprite(g.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(g.glyphs),this._createLayers(),this.light=new z(this.stylesheet.light),this._setProjectionInternal((null===(f=this.stylesheet.projection)||void 0===f?void 0:f.type)||"mercator"),this.sky=new D(this.stylesheet.sky),this.map.setTerrain(null!==(m=this.stylesheet.terrain)&&void 0!==m?m:null),this.fire(new u.l("data",{dataType:"style"})),this.fire(new u.l("style.load"))}}_createLayers(){var e,c,p;const f=u.bS(this.stylesheet.layers);this.setGlobalState(null!==(e=this.stylesheet.state)&&void 0!==e?e:null),this.dispatcher.broadcast("SL",f),this._order=f.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const e of f){const f=u.bT(e,this._globalState);if(f.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=f,u.bU(f)&&this.tileManagers[f.source]){const u=null!==(p=null===(c=e.paint)||void 0===c?void 0:c["raster-fade-duration"])&&void 0!==p?p:f.paint.get("raster-fade-duration");this.tileManagers[f.source].setRasterFadeDuration(u)}}}_loadSprite(e,c=!1,p=void 0){this.imageManager.setLoaded(!1);const f=new AbortController;let m;this._spriteRequest=f,function(e,c,p,f){return u._(this,void 0,void 0,(function*(){const m=B(e),g=p>1?"@2x":"",y={},b={};for(const{id:e,url:p}of m){const m=c.transformRequest(O(p,g,".json"),"SpriteJSON");y[e]=u.j(m,f);const x=c.transformRequest(O(p,g,".png"),"SpriteImage");b[e]=L.getImage(x,f)}return yield Promise.all([...Object.values(y),...Object.values(b)]),function(e,c){return u._(this,void 0,void 0,(function*(){const u={};for(const p in e){u[p]={};const f=x.getImageCanvasContext((yield c[p]).data),m=(yield e[p]).data;for(const e in m){const{width:c,height:g,x:y,y:x,sdf:b,pixelRatio:T,stretchX:S,stretchY:P,content:I,textFitWidth:C,textFitHeight:R}=m[e];u[p][e]={data:null,pixelRatio:T,sdf:b,stretchX:S,stretchY:P,content:I,textFitWidth:C,textFitHeight:R,spriteData:{width:c,height:g,x:y,y:x,context:f}}}}return u}))}(y,b)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(const u in e){this._spritesImagesIds[u]=[];const p=this._spritesImagesIds[u]?this._spritesImagesIds[u].filter((c=>!(c in e))):[];for(const e of p)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const p in e[u]){const f="default"===u?p:`${u}:${p}`;this._spritesImagesIds[u].push(f),f in this.imageManager.images?this.imageManager.updateImage(f,e[u][p],!1):this.imageManager.addImage(f,e[u][p]),c&&(this._changedImages[f]=!0)}}})).catch((e=>{this._spriteRequest=null,m=e,f.signal.aborted||this.fire(new u.k(m))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),c&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new u.l("data",{dataType:"style"})),p&&p(m)}))}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new u.l("data",{dataType:"style"}))}_validateLayer(e){const c=this.tileManagers[e.source];if(!c)return;const p=e.sourceLayer;if(!p)return;const f=c.getSource();("geojson"===f.type||f.vectorLayerIds&&-1===f.vectorLayerIds.indexOf(p))&&this.fire(new u.k(new Error(`Source layer "${p}" does not exist on source "${f.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,c=!1){const p=this._serializedAllLayers();if(!e||0===e.length)return Object.values(c?u.bV(p):p);const f=[];for(const m of e)if(p[m]){const e=c?u.bV(p[m]):p[m];f.push(e)}return f}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const c=Object.keys(this._layers);for(const u of c){const c=this._layers[u];"custom"!==c.type&&(e[u]=c.serialize())}return e}hasTransitions(){var e,c,u;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return!0;if(null===(c=this.sky)||void 0===c?void 0:c.hasTransition())return!0;if(null===(u=this.projection)||void 0===u?void 0:u.hasTransition())return!0;for(const e in this.tileManagers)if(this.tileManagers[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const c=this._changed;if(c){const c=Object.keys(this._updatedLayers),u=Object.keys(this._removedLayers);(c.length||u.length)&&this._updateWorkerLayers(c,u);for(const e in this._updatedSources){const c=this._updatedSources[e];if("reload"===c)this._reloadSource(e);else{if("clear"!==c)throw new Error(`Invalid action ${c}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const c in this._updatedPaintProps)this._layers[c].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const p={};for(const e in this.tileManagers){const c=this.tileManagers[e];p[e]=c.used,c.used=!1}for(const c of this._order){const u=this._layers[c];u.recalculate(e,this._availableImages),!u.isHidden(e.zoom)&&u.source&&(this.tileManagers[u.source].used=!0)}for(const e in p){const c=this.tileManagers[e];!!p[e]!=!!c.used&&c.fire(new u.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,c&&this.fire(new u.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const c in this.tileManagers)this.tileManagers[c].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,c){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:c})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,c={}){var p;this._checkLoaded();const f=this.serialize();if(e=c.transformStyle?c.transformStyle(f,e):e,(null===(p=c.validate)||void 0===p||p)&&Rr(this,u.C(e)))return!1;(e=u.bV(e)).layers=u.bS(e.layers);const m=u.bW(f,e),g=this._getOperationsToPerform(m);if(g.unimplemented.length>0)throw new Error(`Unimplemented: ${g.unimplemented.join(", ")}.`);if(0===g.operations.length)return!1;for(const e of g.operations)e();return this.stylesheet=e,this._serializedLayers=null,this.fire(new u.l("style.load",{style:this})),!0}_getOperationsToPerform(e){const c=[],u=[];for(const p of e)switch(p.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":c.push((()=>this.addLayer.apply(this,p.args)));break;case"removeLayer":c.push((()=>this.removeLayer.apply(this,p.args)));break;case"setPaintProperty":c.push((()=>this.setPaintProperty.apply(this,p.args)));break;case"setLayoutProperty":c.push((()=>this.setLayoutProperty.apply(this,p.args)));break;case"setFilter":c.push((()=>this.setFilter.apply(this,p.args)));break;case"addSource":c.push((()=>this.addSource.apply(this,p.args)));break;case"removeSource":c.push((()=>this.removeSource.apply(this,p.args)));break;case"setLayerZoomRange":c.push((()=>this.setLayerZoomRange.apply(this,p.args)));break;case"setLight":c.push((()=>this.setLight.apply(this,p.args)));break;case"setGeoJSONSourceData":c.push((()=>this.setGeoJSONSourceData.apply(this,p.args)));break;case"setGlyphs":c.push((()=>this.setGlyphs.apply(this,p.args)));break;case"setSprite":c.push((()=>this.setSprite.apply(this,p.args)));break;case"setTerrain":c.push((()=>this.map.setTerrain.apply(this,p.args)));break;case"setSky":c.push((()=>this.setSky.apply(this,p.args)));break;case"setProjection":this.setProjection.apply(this,p.args);break;case"setGlobalState":c.push((()=>this.setGlobalState.apply(this,p.args)));break;case"setTransition":c.push((()=>{}));break;default:u.push(p.command)}return{operations:c,unimplemented:u}}addImage(e,c){if(this.getImage(e))return this.fire(new u.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,c),this._afterImageUpdated(e)}updateImage(e,c){this.imageManager.updateImage(e,c)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new u.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new u.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,c,p={}){if(this._checkLoaded(),void 0!==this.tileManagers[e])throw new Error(`Source "${e}" already exists.`);if(!c.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(c).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(c.type)>=0&&this._validate(u.C.source,`sources.${e}`,c,null,p))return;this.map&&this.map._collectResourceTiming&&(c.collectResourceTiming=!0);const f=this.tileManagers[e]=new Fe(e,c,this.dispatcher);f.style=this,f.setEventedParent(this,(()=>({isSourceLoaded:f.loaded(),source:f.serialize(),sourceId:e}))),f.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);for(const c in this._layers)if(this._layers[c].source===e)return this.fire(new u.k(new Error(`Source "${e}" cannot be removed while layer "${c}" is using it.`)));const c=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],c.fire(new u.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),c.setEventedParent(null),c.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,c){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);const u=this.tileManagers[e].getSource();if("geojson"!==u.type)throw new Error(`geojsonSource.type is ${u.type}, which is !== 'geojson`);u.setData(c),this._changed=!0}getSource(e){return this.tileManagers[e]&&this.tileManagers[e].getSource()}addLayer(e,c,p={}){this._checkLoaded();const f=e.id;if(this.getLayer(f))return void this.fire(new u.k(new Error(`Layer "${f}" already exists on this map.`)));let m;if("custom"===e.type){if(Rr(this,u.bX(e)))return;m=u.bT(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(f,e.source),e=u.bV(e),e=u.e(e,{source:f})),this._validate(u.C.layer,`layers.${f}`,e,{arrayIndex:-1},p))return;m=u.bT(e,this._globalState),this._validateLayer(m),m.setEventedParent(this,{layer:{id:f}})}const g=c?this._order.indexOf(c):this._order.length;if(c&&-1===g)this.fire(new u.k(new Error(`Cannot add layer "${f}" before non-existing layer "${c}".`)));else{if(this._order.splice(g,0,f),this._layerOrderChanged=!0,this._layers[f]=m,this._removedLayers[f]&&m.source&&"custom"!==m.type){const e=this._removedLayers[f];delete this._removedLayers[f],e.type!==m.type?this._updatedSources[m.source]="clear":(this._updatedSources[m.source]="reload",this.tileManagers[m.source].pause())}this._updateLayer(m),m.onAdd&&m.onAdd(this.map)}}moveLayer(e,c){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new u.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===c)return;const p=this._order.indexOf(e);this._order.splice(p,1);const f=c?this._order.indexOf(c):this._order.length;c&&-1===f?this.fire(new u.k(new Error(`Cannot move layer "${e}" before non-existing layer "${c}".`))):(this._order.splice(f,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const c=this._layers[e];if(!c)return void this.fire(new u.k(new Error(`Cannot remove non-existing layer "${e}".`)));c.setEventedParent(null);const p=this._order.indexOf(e);this._order.splice(p,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=c,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],c.onRemove&&c.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,c,p){this._checkLoaded();const f=this.getLayer(e);f?f.minzoom===c&&f.maxzoom===p||(null!=c&&(f.minzoom=c),null!=p&&(f.maxzoom=p),this._updateLayer(f)):this.fire(new u.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,c,p={}){this._checkLoaded();const f=this.getLayer(e);if(f){if(!u.bR(f.filter,c))return null==c?(f.setFilter(void 0),void this._updateLayer(f)):void(this._validate(u.C.filter,`layers.${f.id}.filter`,c,null,p)||(f.setFilter(u.bV(c)),this._updateLayer(f)))}else this.fire(new u.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return u.bV(this.getLayer(e).filter)}setLayoutProperty(e,c,p,f={}){this._checkLoaded();const m=this.getLayer(e);m?u.bR(m.getLayoutProperty(c),p)||(m.setLayoutProperty(c,p,f),this._updateLayer(m)):this.fire(new u.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,c){const p=this.getLayer(e);if(p)return p.getLayoutProperty(c);this.fire(new u.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,c,p,f={}){this._checkLoaded();const m=this.getLayer(e);m?u.bR(m.getPaintProperty(c),p)||this._updatePaintProperty(m,c,p,f):this.fire(new u.k(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,c,p,f={}){e.setPaintProperty(c,p,f)&&this._updateLayer(e),u.bU(e)&&"raster-fade-duration"===c&&this.tileManagers[e.source].setRasterFadeDuration(p),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,c){return this.getLayer(e).getPaintProperty(c)}setFeatureState(e,c){this._checkLoaded();const p=e.source,f=e.sourceLayer,m=this.tileManagers[p];if(void 0===m)return void this.fire(new u.k(new Error(`The source '${p}' does not exist in the map's style.`)));const g=m.getSource().type;"geojson"===g&&f?this.fire(new u.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==g||f?(void 0===e.id&&this.fire(new u.k(new Error("The feature id parameter must be provided."))),m.setFeatureState(f,e.id,c)):this.fire(new u.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,c){this._checkLoaded();const p=e.source,f=this.tileManagers[p];if(void 0===f)return void this.fire(new u.k(new Error(`The source '${p}' does not exist in the map's style.`)));const m=f.getSource().type,g="vector"===m?e.sourceLayer:void 0;"vector"!==m||g?c&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new u.k(new Error("A feature id is required to remove its specific state property."))):f.removeFeatureState(g,e.id,c):this.fire(new u.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const c=e.source,p=e.sourceLayer,f=this.tileManagers[c];if(void 0!==f)return"vector"!==f.getSource().type||p?(void 0===e.id&&this.fire(new u.k(new Error("The feature id parameter must be provided."))),f.getFeatureState(p,e.id)):void this.fire(new u.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new u.k(new Error(`The source '${c}' does not exist in the map's style.`)))}getTransition(){return u.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=u.bY(this.tileManagers,(e=>e.serialize())),c=this._serializeByIds(this._order,!0),p=this.map.getTerrain()||void 0,f=this.stylesheet;return u.bZ({version:f.version,name:f.name,metadata:f.metadata,light:f.light,sky:f.sky,center:f.center,zoom:f.zoom,bearing:f.bearing,pitch:f.pitch,sprite:f.sprite,glyphs:f.glyphs,transition:f.transition,projection:f.projection,sources:e,layers:c,terrain:p},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.tileManagers[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const c=e=>"fill-extrusion"===this._layers[e].type,u={},p=[];for(let f=this._order.length-1;f>=0;f--){const m=this._order[f];if(c(m)){u[m]=f;for(const c of e){const e=c[m];if(e)for(const c of e)p.push(c)}}}p.sort(((e,c)=>c.intersectionZ-e.intersectionZ));const f=[];for(let m=this._order.length-1;m>=0;m--){const g=this._order[m];if(c(g))for(let e=p.length-1;e>=0;e--){const c=p[e].feature;if(u[c.layer.id]this.map.terrain.getElevation(e,c,u):void 0));return this.placement&&m.push(function(e,c,u,p,f,m,g){const y={},x=m.queryRenderedSymbols(p),b=[];for(const e of Object.keys(x).map(Number))b.push(g[e]);b.sort(fe);for(const u of b){const p=u.featureIndex.lookupSymbolFeatures(x[u.bucketInstanceId],c,u.bucketIndex,u.sourceLayerIndex,{filterSpec:f.filter,globalState:f.globalState},f.layers,f.availableImages,e);for(const e in p){const c=y[e]=y[e]||[],f=p[e];f.sort(((e,c)=>{const p=u.featureSortOrder;if(p){const u=p.indexOf(e.featureIndex);return p.indexOf(c.featureIndex)-u}return c.featureIndex-e.featureIndex}));for(const e of f)c.push(e)}}return function(e,c,u){for(const p in e)for(const f of e[p])me(f,u[c[p].source]);return e}(y,e,u)}(this._layers,g,this.tileManagers,e,x,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(m)}querySourceFeatures(e,c){(null==c?void 0:c.filter)&&this._validate(u.C.filter,"querySourceFeatures.filter",c.filter,null,c);const p=this.tileManagers[e];return p?function(e,c){const u=e.getRenderableIds().map((c=>e.getTileByID(c))),p=[],f={};for(let e=0;ee.getTileByID(c))).sort(((e,c)=>c.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(c.tileID)?-1:1)))}const p=this.crossTileSymbolIndex.addLayer(u,y[u.source],e.center.lng);m=m||p}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((f=f||this._layerOrderChanged||0===u)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(T(),e.zoom))&&(this.pauseablePlacement=new Mt(e,this.map.terrain,this._order,f,c,u,p,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(T()),g=!0),m&&this.pauseablePlacement.placement.setStale()),g||m)for(const e of this._order){const c=this._layers[e];"symbol"===c.type&&this.placement.updateLayerOpacities(c,y[c.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(T())}_releaseSymbolFadeTiles(){for(const e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}getImages(e,c){return u._(this,void 0,void 0,(function*(){const e=yield this.imageManager.getImages(c.icons);this._updateTilesForChangedImages();const u=this.tileManagers[c.source];return u&&u.setDependencies(c.tileID.key,c.type,c.icons),e}))}getGlyphs(e,c){return u._(this,void 0,void 0,(function*(){const e=yield this.glyphManager.getGlyphs(c.stacks),u=this.tileManagers[c.source];return u&&u.setDependencies(c.tileID.key,c.type,[""]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,c={}){this._checkLoaded(),e&&this._validate(u.C.glyphs,"glyphs",e,null,c)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getDashes(e,c){return u._(this,void 0,void 0,(function*(){const e={};for(const[u,p]of Object.entries(c.dashes))e[u]=this.lineAtlas.getDash(p.dasharray,p.round);return e}))}addSprite(e,c,p={},f){this._checkLoaded();const m=[{id:e,url:c}],g=[...B(this.stylesheet.sprite),...m];this._validate(u.C.sprite,"sprite",g,null,p)||(this.stylesheet.sprite=g,this._loadSprite(m,!0,f))}removeSprite(e){this._checkLoaded();const c=B(this.stylesheet.sprite);if(c.find((c=>c.id===e))){if(this._spritesImagesIds[e])for(const c of this._spritesImagesIds[e])this.imageManager.removeImage(c),this._changedImages[c]=!0;c.splice(c.findIndex((c=>c.id===e)),1),this.stylesheet.sprite=c.length>0?c:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new u.l("data",{dataType:"style"}))}else this.fire(new u.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return B(this.stylesheet.sprite)}setSprite(e,c={},p){this._checkLoaded(),e&&this._validate(u.C.sprite,"sprite",e,null,c)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,p):(this._unloadSprite(),p&&p(null)))}destroy(){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null);for(const e in this.tileManagers){const c=this.tileManagers[e];c.setEventedParent(null),c.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(const e in this._layers){const c=this._layers[e];c.setEventedParent(null),c.onRemove&&c.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}}var Br=u.aU([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Oi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,c,u,p,f,m,g,y,x){this.context=e;let b=this.boundPaintVertexBuffers.length!==p.length;for(let e=0;!b&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:c,u_fog_color:p?p.properties.get("fog-color"):u.bp.white,u_fog_ground_blend:p?p.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:m?0:p?p.calculateFogBlendOpacity(f):0,u_horizon_color:p?p.properties.get("horizon-color"):u.bp.white,u_horizon_fog_blend:p?p.properties.get("horizon-fog-blend"):1,u_is_globe_mode:m?1:0}),Vr={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function jr(e){const c=[];for(let u=0;u({u_depth:new u.b_(e,c.u_depth),u_terrain:new u.b_(e,c.u_terrain),u_terrain_dim:new u.bq(e,c.u_terrain_dim),u_terrain_matrix:new u.c0(e,c.u_terrain_matrix),u_terrain_unpack:new u.c1(e,c.u_terrain_unpack),u_terrain_exaggeration:new u.bq(e,c.u_terrain_exaggeration)}))(e,Z),this.projectionUniforms=((e,c)=>({u_projection_matrix:new u.c0(e,c.u_projection_matrix),u_projection_tile_mercator_coords:new u.c1(e,c.u_projection_tile_mercator_coords),u_projection_clipping_plane:new u.c1(e,c.u_projection_clipping_plane),u_projection_transition:new u.bq(e,c.u_projection_transition),u_projection_fallback_matrix:new u.c0(e,c.u_projection_fallback_matrix)}))(e,Z),this.binderUniforms=p?p.getUniforms(e,Z):[]}draw(e,c,u,p,f,m,g,y,x,b,T,S,P,I,C,R,F,L,B){const O=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(u),e.setStencilMode(p),e.setColorMode(f),e.setCullFace(m),y){e.activeTexture.set(O.TEXTURE2),O.bindTexture(O.TEXTURE_2D,y.depthTexture),e.activeTexture.set(O.TEXTURE3),O.bindTexture(O.TEXTURE_2D,y.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(y[e])}if(x)for(const e in x)this.projectionUniforms[Vr[e]].set(x[e]);if(g)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(g[e]);R&&R.setUniforms(e,this.binderUniforms,I,{zoom:C});let V=0;switch(c){case O.LINES:V=2;break;case O.TRIANGLES:V=3;break;case O.LINE_STRIP:V=1}for(const u of P.get()){const p=u.vaos||(u.vaos={});(p[b]||(p[b]=new Oi)).bind(e,this,T,R?R.getPaintVertexBuffers():[],S,u.vertexOffset,F,L,B),O.drawElements(c,u.primitiveLength*V,O.UNSIGNED_SHORT,u.primitiveOffset*V*2)}}}function Nr(e,c,p){const f=1/u.aN(p,1,c.transform.tileZoom),m=Math.pow(2,p.tileID.overscaledZ),g=p.tileSize*Math.pow(2,c.transform.tileZoom)/m,y=g*(p.tileID.canonical.x+p.tileID.wrap*m),x=g*p.tileID.canonical.y;return{u_image:0,u_texsize:p.imageAtlasTexture.size,u_scale:[f,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[y>>16,x>>16],u_pixel_coord_lower:[65535&y,65535&x]}}const Gr=(e,c,p,f)=>{const m=e.style.light,g=m.properties.get("position"),y=[g.x,g.y,g.z],x=u.c4();"viewport"===m.properties.get("anchor")&&u.c5(x,e.transform.bearingInRadians),u.c6(y,y,x);const b=e.transform.transformLightDirection(y),T=m.properties.get("color");return{u_lightpos:y,u_lightpos_globe:b,u_lightintensity:m.properties.get("intensity"),u_lightcolor:[T.r,T.g,T.b],u_vertical_gradient:+c,u_opacity:p,u_fill_translate:f}},Ur=(e,c,p,f,m,g,y)=>u.e(Gr(e,c,p,f),Nr(g,e,y),{u_height_factor:-Math.pow(2,m.overscaledZ)/y.tileSize/8}),qr=(e,c,p,f)=>u.e(Nr(c,e,p),{u_fill_translate:f}),$r=(e,c)=>({u_world:e,u_fill_translate:c}),Zr=(e,c,p,f,m)=>u.e(qr(e,c,p,m),{u_world:f}),Xr=(e,c,p,f,m)=>{const g=e.transform;let y,x,b=0;if("map"===p.paint.get("circle-pitch-alignment")){const e=u.aN(c,1,g.zoom);y=!0,x=[e,e],b=e/(u.a5*Math.pow(2,c.tileID.overscaledZ))*2*Math.PI*m}else y=!1,x=g.pixelsToGLUnits;return{u_camera_to_center_distance:g.cameraToCenterDistance,u_scale_with_map:+("map"===p.paint.get("circle-pitch-scale")),u_pitch_with_map:+y,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:x,u_globe_extrude_scale:b,u_translate:f}},Yr=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Kr=e=>({u_viewport_size:[e.width,e.height]}),Jr=(e,c=1)=>({u_color:e,u_overlay:0,u_overlay_scale:c}),Qr=(e,c,p,f)=>{const m=u.aN(e,1,c)/(u.a5*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*f;return{u_extrude_scale:u.aN(e,1,c),u_intensity:p,u_globe_extrude_scale:m}},en=(e,c,p,f)=>{const m=u.N();u.c7(m,0,e.width,e.height,0,0,1);const g=e.context.gl;return{u_matrix:m,u_world:[g.drawingBufferWidth,g.drawingBufferHeight],u_image:p,u_color_ramp:f,u_opacity:c.paint.get("heatmap-opacity")}},tn=(e,c,u)=>{const p=u.paint.get("hillshade-accent-color");let f;switch(u.paint.get("hillshade-method")){case"basic":f=4;break;case"combined":f=1;break;case"igor":f=2;break;case"multidirectional":f=3;break;default:f=0}const m=u.getIlluminationProperties();for(let c=0;c{const p=c.stride,f=u.N();return u.c7(f,0,u.a5,-u.a5,0,0,1),u.O(f,f,[0,-u.a5,0]),{u_matrix:f,u_image:1,u_dimension:[p,p],u_zoom:e.overscaledZ,u_unpack:c.getUnpackVector()}};function nn(e,c){const p=Math.pow(2,c.canonical.z),f=c.canonical.y;return[new u.a9(0,f/p).toLngLat().lat,new u.a9(0,(f+1)/p).toLngLat().lat]}const sn=(e,c,u=0)=>({u_image:0,u_unpack:c.getUnpackVector(),u_dimension:[c.stride,c.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:u,u_opacity:e.paint.get("color-relief-opacity")}),an=(e,c,p,f)=>{const m=e.transform;return{u_translation:pn(e,c,p),u_ratio:f/u.aN(c,1,m.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/m.pixelsToGLUnits[0],1/m.pixelsToGLUnits[1]]}},ln=(e,c,p,f,m)=>u.e(an(e,c,p,f),{u_image:0,u_image_height:m}),cn=(e,c,p,f,m)=>{const g=e.transform,y=dn(c,g);return{u_translation:pn(e,c,p),u_texsize:c.imageAtlasTexture.size,u_ratio:f/u.aN(c,1,g.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[y,m.fromScale,m.toScale],u_fade:m.t,u_units_to_pixels:[1/g.pixelsToGLUnits[0],1/g.pixelsToGLUnits[1]]}},hn=(e,c,p,f,m)=>{const g=dn(c,e.transform);return u.e(an(e,c,p,f),{u_tileratio:g,u_crossfade_from:m.fromScale,u_crossfade_to:m.toScale,u_image:0,u_mix:m.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},un=(e,c,p,f,m,g)=>{const y=dn(c,e.transform);return u.e(an(e,c,p,f),{u_image:0,u_image_height:g,u_tileratio:y,u_crossfade_from:m.fromScale,u_crossfade_to:m.toScale,u_image_dash:1,u_mix:m.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function dn(e,c){return 1/u.aN(e,1,c.tileZoom)}function pn(e,c,p){return u.aO(e.transform,c,p.paint.get("line-translate"),p.paint.get("line-translate-anchor"))}const fn=(e,c,u,p,f)=>{return{u_tl_parent:e,u_scale_parent:c,u_buffer_scale:1,u_fade_t:u.mix,u_opacity:u.opacity*p.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:p.paint.get("raster-brightness-min"),u_brightness_high:p.paint.get("raster-brightness-max"),u_saturation_factor:(g=p.paint.get("raster-saturation"),g>0?1-1/(1.001-g):-g),u_contrast_factor:(m=p.paint.get("raster-contrast"),m>0?1/(1-m):1+m),u_spin_weights:mn(p.paint.get("raster-hue-rotate")),u_coords_top:[f[0].x,f[0].y,f[1].x,f[1].y],u_coords_bottom:[f[3].x,f[3].y,f[2].x,f[2].y]};var m,g};function mn(e){e*=Math.PI/180;const c=Math.sin(e),u=Math.cos(e);return[(2*u+1)/3,(-Math.sqrt(3)*c-u+1)/3,(Math.sqrt(3)*c-u+1)/3]}const _n=(e,c,u,p,f,m,g,y,x,b,T,S,P)=>{const I=g.transform;return{u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:c?c.uSizeT:0,u_size:c?c.uSize:0,u_camera_to_center_distance:I.cameraToCenterDistance,u_pitch:I.pitch/360*2*Math.PI,u_rotate_symbol:+u,u_aspect_ratio:I.width/I.height,u_fade_change:g.options.fadeDuration?g.symbolFadeChange:1,u_label_plane_matrix:y,u_coord_matrix:x,u_is_text:+T,u_pitch_with_map:+p,u_is_along_line:f,u_is_variable_anchor:m,u_texsize:S,u_texture:0,u_translation:b,u_pitched_scale:P}},gn=(e,c,p,f,m,g,y,x,b,T,S,P,I,C)=>{const R=y.transform;return u.e(_n(e,c,p,f,m,g,y,x,b,T,S,P,C),{u_gamma_scale:f?Math.cos(R.pitch*Math.PI/180)*R.cameraToCenterDistance:1,u_device_pixel_ratio:y.pixelRatio,u_is_halo:1})},yn=(e,c,p,f,m,g,y,x,b,T,S,P,I)=>u.e(gn(e,c,p,f,m,g,y,x,b,T,!0,S,0,I),{u_texsize_icon:P,u_texture_icon:1}),xn=(e,c)=>({u_opacity:e,u_color:c}),vn=(e,c,p,f,m)=>u.e(function(e,c,p,f){const m=p.imageManager.getPattern(e.from.toString()),g=p.imageManager.getPattern(e.to.toString()),{width:y,height:x}=p.imageManager.getPixelSize(),b=Math.pow(2,f.tileID.overscaledZ),T=f.tileSize*Math.pow(2,p.transform.tileZoom)/b,S=T*(f.tileID.canonical.x+f.tileID.wrap*b),P=T*f.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:m.tl,u_pattern_br_a:m.br,u_pattern_tl_b:g.tl,u_pattern_br_b:g.br,u_texsize:[y,x],u_mix:c.t,u_pattern_size_a:m.displaySize,u_pattern_size_b:g.displaySize,u_scale_a:c.fromScale,u_scale_b:c.toScale,u_tile_units_to_pixels:1/u.aN(f,1,p.transform.tileZoom),u_pixel_coord_upper:[S>>16,P>>16],u_pixel_coord_lower:[65535&S,65535&P]}}(p,m,c,f),{u_opacity:e}),bn=(e,c)=>{},wn={fillExtrusion:(e,c)=>({u_lightpos:new u.c2(e,c.u_lightpos),u_lightpos_globe:new u.c2(e,c.u_lightpos_globe),u_lightintensity:new u.bq(e,c.u_lightintensity),u_lightcolor:new u.c2(e,c.u_lightcolor),u_vertical_gradient:new u.bq(e,c.u_vertical_gradient),u_opacity:new u.bq(e,c.u_opacity),u_fill_translate:new u.c3(e,c.u_fill_translate)}),fillExtrusionPattern:(e,c)=>({u_lightpos:new u.c2(e,c.u_lightpos),u_lightpos_globe:new u.c2(e,c.u_lightpos_globe),u_lightintensity:new u.bq(e,c.u_lightintensity),u_lightcolor:new u.c2(e,c.u_lightcolor),u_vertical_gradient:new u.bq(e,c.u_vertical_gradient),u_height_factor:new u.bq(e,c.u_height_factor),u_opacity:new u.bq(e,c.u_opacity),u_fill_translate:new u.c3(e,c.u_fill_translate),u_image:new u.b_(e,c.u_image),u_texsize:new u.c3(e,c.u_texsize),u_pixel_coord_upper:new u.c3(e,c.u_pixel_coord_upper),u_pixel_coord_lower:new u.c3(e,c.u_pixel_coord_lower),u_scale:new u.c2(e,c.u_scale),u_fade:new u.bq(e,c.u_fade)}),fill:(e,c)=>({u_fill_translate:new u.c3(e,c.u_fill_translate)}),fillPattern:(e,c)=>({u_image:new u.b_(e,c.u_image),u_texsize:new u.c3(e,c.u_texsize),u_pixel_coord_upper:new u.c3(e,c.u_pixel_coord_upper),u_pixel_coord_lower:new u.c3(e,c.u_pixel_coord_lower),u_scale:new u.c2(e,c.u_scale),u_fade:new u.bq(e,c.u_fade),u_fill_translate:new u.c3(e,c.u_fill_translate)}),fillOutline:(e,c)=>({u_world:new u.c3(e,c.u_world),u_fill_translate:new u.c3(e,c.u_fill_translate)}),fillOutlinePattern:(e,c)=>({u_world:new u.c3(e,c.u_world),u_image:new u.b_(e,c.u_image),u_texsize:new u.c3(e,c.u_texsize),u_pixel_coord_upper:new u.c3(e,c.u_pixel_coord_upper),u_pixel_coord_lower:new u.c3(e,c.u_pixel_coord_lower),u_scale:new u.c2(e,c.u_scale),u_fade:new u.bq(e,c.u_fade),u_fill_translate:new u.c3(e,c.u_fill_translate)}),circle:(e,c)=>({u_camera_to_center_distance:new u.bq(e,c.u_camera_to_center_distance),u_scale_with_map:new u.b_(e,c.u_scale_with_map),u_pitch_with_map:new u.b_(e,c.u_pitch_with_map),u_extrude_scale:new u.c3(e,c.u_extrude_scale),u_device_pixel_ratio:new u.bq(e,c.u_device_pixel_ratio),u_globe_extrude_scale:new u.bq(e,c.u_globe_extrude_scale),u_translate:new u.c3(e,c.u_translate)}),collisionBox:(e,c)=>({u_pixel_extrude_scale:new u.c3(e,c.u_pixel_extrude_scale)}),collisionCircle:(e,c)=>({u_viewport_size:new u.c3(e,c.u_viewport_size)}),debug:(e,c)=>({u_color:new u.b$(e,c.u_color),u_overlay:new u.b_(e,c.u_overlay),u_overlay_scale:new u.bq(e,c.u_overlay_scale)}),depth:bn,clippingMask:bn,heatmap:(e,c)=>({u_extrude_scale:new u.bq(e,c.u_extrude_scale),u_intensity:new u.bq(e,c.u_intensity),u_globe_extrude_scale:new u.bq(e,c.u_globe_extrude_scale)}),heatmapTexture:(e,c)=>({u_matrix:new u.c0(e,c.u_matrix),u_world:new u.c3(e,c.u_world),u_image:new u.b_(e,c.u_image),u_color_ramp:new u.b_(e,c.u_color_ramp),u_opacity:new u.bq(e,c.u_opacity)}),hillshade:(e,c)=>({u_image:new u.b_(e,c.u_image),u_latrange:new u.c3(e,c.u_latrange),u_exaggeration:new u.bq(e,c.u_exaggeration),u_altitudes:new u.c9(e,c.u_altitudes),u_azimuths:new u.c9(e,c.u_azimuths),u_accent:new u.b$(e,c.u_accent),u_method:new u.b_(e,c.u_method),u_shadows:new u.c8(e,c.u_shadows),u_highlights:new u.c8(e,c.u_highlights)}),hillshadePrepare:(e,c)=>({u_matrix:new u.c0(e,c.u_matrix),u_image:new u.b_(e,c.u_image),u_dimension:new u.c3(e,c.u_dimension),u_zoom:new u.bq(e,c.u_zoom),u_unpack:new u.c1(e,c.u_unpack)}),colorRelief:(e,c)=>({u_image:new u.b_(e,c.u_image),u_unpack:new u.c1(e,c.u_unpack),u_dimension:new u.c3(e,c.u_dimension),u_elevation_stops:new u.b_(e,c.u_elevation_stops),u_color_stops:new u.b_(e,c.u_color_stops),u_color_ramp_size:new u.b_(e,c.u_color_ramp_size),u_opacity:new u.bq(e,c.u_opacity)}),line:(e,c)=>({u_translation:new u.c3(e,c.u_translation),u_ratio:new u.bq(e,c.u_ratio),u_device_pixel_ratio:new u.bq(e,c.u_device_pixel_ratio),u_units_to_pixels:new u.c3(e,c.u_units_to_pixels)}),lineGradient:(e,c)=>({u_translation:new u.c3(e,c.u_translation),u_ratio:new u.bq(e,c.u_ratio),u_device_pixel_ratio:new u.bq(e,c.u_device_pixel_ratio),u_units_to_pixels:new u.c3(e,c.u_units_to_pixels),u_image:new u.b_(e,c.u_image),u_image_height:new u.bq(e,c.u_image_height)}),linePattern:(e,c)=>({u_translation:new u.c3(e,c.u_translation),u_texsize:new u.c3(e,c.u_texsize),u_ratio:new u.bq(e,c.u_ratio),u_device_pixel_ratio:new u.bq(e,c.u_device_pixel_ratio),u_image:new u.b_(e,c.u_image),u_units_to_pixels:new u.c3(e,c.u_units_to_pixels),u_scale:new u.c2(e,c.u_scale),u_fade:new u.bq(e,c.u_fade)}),lineSDF:(e,c)=>({u_translation:new u.c3(e,c.u_translation),u_ratio:new u.bq(e,c.u_ratio),u_device_pixel_ratio:new u.bq(e,c.u_device_pixel_ratio),u_units_to_pixels:new u.c3(e,c.u_units_to_pixels),u_image:new u.b_(e,c.u_image),u_mix:new u.bq(e,c.u_mix),u_tileratio:new u.bq(e,c.u_tileratio),u_crossfade_from:new u.bq(e,c.u_crossfade_from),u_crossfade_to:new u.bq(e,c.u_crossfade_to),u_lineatlas_width:new u.bq(e,c.u_lineatlas_width),u_lineatlas_height:new u.bq(e,c.u_lineatlas_height)}),lineGradientSDF:(e,c)=>({u_translation:new u.c3(e,c.u_translation),u_ratio:new u.bq(e,c.u_ratio),u_device_pixel_ratio:new u.bq(e,c.u_device_pixel_ratio),u_units_to_pixels:new u.c3(e,c.u_units_to_pixels),u_image:new u.b_(e,c.u_image),u_image_height:new u.bq(e,c.u_image_height),u_tileratio:new u.bq(e,c.u_tileratio),u_crossfade_from:new u.bq(e,c.u_crossfade_from),u_crossfade_to:new u.bq(e,c.u_crossfade_to),u_image_dash:new u.b_(e,c.u_image_dash),u_mix:new u.bq(e,c.u_mix),u_lineatlas_width:new u.bq(e,c.u_lineatlas_width),u_lineatlas_height:new u.bq(e,c.u_lineatlas_height)}),raster:(e,c)=>({u_tl_parent:new u.c3(e,c.u_tl_parent),u_scale_parent:new u.bq(e,c.u_scale_parent),u_buffer_scale:new u.bq(e,c.u_buffer_scale),u_fade_t:new u.bq(e,c.u_fade_t),u_opacity:new u.bq(e,c.u_opacity),u_image0:new u.b_(e,c.u_image0),u_image1:new u.b_(e,c.u_image1),u_brightness_low:new u.bq(e,c.u_brightness_low),u_brightness_high:new u.bq(e,c.u_brightness_high),u_saturation_factor:new u.bq(e,c.u_saturation_factor),u_contrast_factor:new u.bq(e,c.u_contrast_factor),u_spin_weights:new u.c2(e,c.u_spin_weights),u_coords_top:new u.c1(e,c.u_coords_top),u_coords_bottom:new u.c1(e,c.u_coords_bottom)}),symbolIcon:(e,c)=>({u_is_size_zoom_constant:new u.b_(e,c.u_is_size_zoom_constant),u_is_size_feature_constant:new u.b_(e,c.u_is_size_feature_constant),u_size_t:new u.bq(e,c.u_size_t),u_size:new u.bq(e,c.u_size),u_camera_to_center_distance:new u.bq(e,c.u_camera_to_center_distance),u_pitch:new u.bq(e,c.u_pitch),u_rotate_symbol:new u.b_(e,c.u_rotate_symbol),u_aspect_ratio:new u.bq(e,c.u_aspect_ratio),u_fade_change:new u.bq(e,c.u_fade_change),u_label_plane_matrix:new u.c0(e,c.u_label_plane_matrix),u_coord_matrix:new u.c0(e,c.u_coord_matrix),u_is_text:new u.b_(e,c.u_is_text),u_pitch_with_map:new u.b_(e,c.u_pitch_with_map),u_is_along_line:new u.b_(e,c.u_is_along_line),u_is_variable_anchor:new u.b_(e,c.u_is_variable_anchor),u_texsize:new u.c3(e,c.u_texsize),u_texture:new u.b_(e,c.u_texture),u_translation:new u.c3(e,c.u_translation),u_pitched_scale:new u.bq(e,c.u_pitched_scale)}),symbolSDF:(e,c)=>({u_is_size_zoom_constant:new u.b_(e,c.u_is_size_zoom_constant),u_is_size_feature_constant:new u.b_(e,c.u_is_size_feature_constant),u_size_t:new u.bq(e,c.u_size_t),u_size:new u.bq(e,c.u_size),u_camera_to_center_distance:new u.bq(e,c.u_camera_to_center_distance),u_pitch:new u.bq(e,c.u_pitch),u_rotate_symbol:new u.b_(e,c.u_rotate_symbol),u_aspect_ratio:new u.bq(e,c.u_aspect_ratio),u_fade_change:new u.bq(e,c.u_fade_change),u_label_plane_matrix:new u.c0(e,c.u_label_plane_matrix),u_coord_matrix:new u.c0(e,c.u_coord_matrix),u_is_text:new u.b_(e,c.u_is_text),u_pitch_with_map:new u.b_(e,c.u_pitch_with_map),u_is_along_line:new u.b_(e,c.u_is_along_line),u_is_variable_anchor:new u.b_(e,c.u_is_variable_anchor),u_texsize:new u.c3(e,c.u_texsize),u_texture:new u.b_(e,c.u_texture),u_gamma_scale:new u.bq(e,c.u_gamma_scale),u_device_pixel_ratio:new u.bq(e,c.u_device_pixel_ratio),u_is_halo:new u.b_(e,c.u_is_halo),u_translation:new u.c3(e,c.u_translation),u_pitched_scale:new u.bq(e,c.u_pitched_scale)}),symbolTextAndIcon:(e,c)=>({u_is_size_zoom_constant:new u.b_(e,c.u_is_size_zoom_constant),u_is_size_feature_constant:new u.b_(e,c.u_is_size_feature_constant),u_size_t:new u.bq(e,c.u_size_t),u_size:new u.bq(e,c.u_size),u_camera_to_center_distance:new u.bq(e,c.u_camera_to_center_distance),u_pitch:new u.bq(e,c.u_pitch),u_rotate_symbol:new u.b_(e,c.u_rotate_symbol),u_aspect_ratio:new u.bq(e,c.u_aspect_ratio),u_fade_change:new u.bq(e,c.u_fade_change),u_label_plane_matrix:new u.c0(e,c.u_label_plane_matrix),u_coord_matrix:new u.c0(e,c.u_coord_matrix),u_is_text:new u.b_(e,c.u_is_text),u_pitch_with_map:new u.b_(e,c.u_pitch_with_map),u_is_along_line:new u.b_(e,c.u_is_along_line),u_is_variable_anchor:new u.b_(e,c.u_is_variable_anchor),u_texsize:new u.c3(e,c.u_texsize),u_texsize_icon:new u.c3(e,c.u_texsize_icon),u_texture:new u.b_(e,c.u_texture),u_texture_icon:new u.b_(e,c.u_texture_icon),u_gamma_scale:new u.bq(e,c.u_gamma_scale),u_device_pixel_ratio:new u.bq(e,c.u_device_pixel_ratio),u_is_halo:new u.b_(e,c.u_is_halo),u_translation:new u.c3(e,c.u_translation),u_pitched_scale:new u.bq(e,c.u_pitched_scale)}),background:(e,c)=>({u_opacity:new u.bq(e,c.u_opacity),u_color:new u.b$(e,c.u_color)}),backgroundPattern:(e,c)=>({u_opacity:new u.bq(e,c.u_opacity),u_image:new u.b_(e,c.u_image),u_pattern_tl_a:new u.c3(e,c.u_pattern_tl_a),u_pattern_br_a:new u.c3(e,c.u_pattern_br_a),u_pattern_tl_b:new u.c3(e,c.u_pattern_tl_b),u_pattern_br_b:new u.c3(e,c.u_pattern_br_b),u_texsize:new u.c3(e,c.u_texsize),u_mix:new u.bq(e,c.u_mix),u_pattern_size_a:new u.c3(e,c.u_pattern_size_a),u_pattern_size_b:new u.c3(e,c.u_pattern_size_b),u_scale_a:new u.bq(e,c.u_scale_a),u_scale_b:new u.bq(e,c.u_scale_b),u_pixel_coord_upper:new u.c3(e,c.u_pixel_coord_upper),u_pixel_coord_lower:new u.c3(e,c.u_pixel_coord_lower),u_tile_units_to_pixels:new u.bq(e,c.u_tile_units_to_pixels)}),terrain:(e,c)=>({u_texture:new u.b_(e,c.u_texture),u_ele_delta:new u.bq(e,c.u_ele_delta),u_fog_matrix:new u.c0(e,c.u_fog_matrix),u_fog_color:new u.b$(e,c.u_fog_color),u_fog_ground_blend:new u.bq(e,c.u_fog_ground_blend),u_fog_ground_blend_opacity:new u.bq(e,c.u_fog_ground_blend_opacity),u_horizon_color:new u.b$(e,c.u_horizon_color),u_horizon_fog_blend:new u.bq(e,c.u_horizon_fog_blend),u_is_globe_mode:new u.bq(e,c.u_is_globe_mode)}),terrainDepth:(e,c)=>({u_ele_delta:new u.bq(e,c.u_ele_delta)}),terrainCoords:(e,c)=>({u_texture:new u.b_(e,c.u_texture),u_terrain_coords_id:new u.bq(e,c.u_terrain_coords_id),u_ele_delta:new u.bq(e,c.u_ele_delta)}),projectionErrorMeasurement:(e,c)=>({u_input:new u.bq(e,c.u_input),u_output_expected:new u.bq(e,c.u_output_expected)}),atmosphere:(e,c)=>({u_sun_pos:new u.c2(e,c.u_sun_pos),u_atmosphere_blend:new u.bq(e,c.u_atmosphere_blend),u_globe_position:new u.c2(e,c.u_globe_position),u_globe_radius:new u.bq(e,c.u_globe_radius),u_inv_proj_matrix:new u.c0(e,c.u_inv_proj_matrix)}),sky:(e,c)=>({u_sky_color:new u.b$(e,c.u_sky_color),u_horizon_color:new u.b$(e,c.u_horizon_color),u_horizon:new u.c3(e,c.u_horizon),u_horizon_normal:new u.c3(e,c.u_horizon_normal),u_sky_horizon_blend:new u.bq(e,c.u_sky_horizon_blend),u_sky_blend:new u.bq(e,c.u_sky_blend)})};class ya{constructor(e,c,u){this.context=e;const p=e.gl;this.buffer=p.createBuffer(),this.dynamicDraw=Boolean(u),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),p.bufferData(p.ELEMENT_ARRAY_BUFFER,c.arrayBuffer,this.dynamicDraw?p.DYNAMIC_DRAW:p.STATIC_DRAW),this.dynamicDraw||delete c.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const c=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),c.bufferSubData(c.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Tn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Ta{constructor(e,c,u,p){this.length=c.length,this.attributes=u,this.itemSize=c.bytesPerElement,this.dynamicDraw=p,this.context=e;const f=e.gl;this.buffer=f.createBuffer(),e.bindVertexBuffer.set(this.buffer),f.bufferData(f.ARRAY_BUFFER,c.arrayBuffer,this.dynamicDraw?f.DYNAMIC_DRAW:f.STATIC_DRAW),this.dynamicDraw||delete c.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const c=this.context.gl;this.bind(),c.bufferSubData(c.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,c){for(let u=0;u0&&(T.push({circleArray:F,circleOffset:P,coord:I}),S+=F.length/4,P=S),R&&b.draw(g,x.LINES,ii.disabled,ri.disabled,e.colorModeForRenderPass(),ti.disabled,Yr(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(I),y.getProjectionData({overscaledTileID:I,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),p.id,R.layoutVertexBuffer,R.indexBuffer,R.segments,null,e.transform.zoom,null,null,R.collisionVertexBuffer)}if(!m||!T.length)return;const I=e.useProgram("collisionCircle"),C=new u.ca;C.resize(4*S),C._trim();let R=0;for(const e of T)for(let c=0;c=0&&(F[L.associatedIconIndex]={shiftedAnchor:Q,angle:ee})}else mi(L.numGlyphs,C)}if(b){R.clear();const c=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(x,c,u):null,u="map"===p.layout.get("text-rotation-alignment");jt(b,e,m,ye,xe,B,T,u,x.toUnwrapped(),F.width,F.height,be,c)}const Ee=m&&q||Me,Ce=O||Ee?Cn:B?ye:e.transform.clipSpaceToPixelsMatrix,Ae=C&&0!==p.paint.get(m?"text-halo-width":"icon-halo-width").constantOr(1);let Ne;Ne=C?b.iconsInText?yn(U.kind,ee,V,B,O,Ee,e,Ce,ve,be,ce,fe,W):gn(U.kind,ee,V,B,O,Ee,e,Ce,ve,be,m,ce,0,W):_n(U.kind,ee,V,B,O,Ee,e,Ce,ve,be,m,ce,W);const Ge={program:Q,buffers:S,uniformValues:Ne,projectionData:we,atlasTexture:he,atlasTextureIcon:me,atlasInterpolation:ue,atlasInterpolationIcon:de,isSDF:C,hasHalo:Ae};if(j&&b.canOverlap){G=!0;const e=S.segments.get();for(const c of e)Z.push({segments:new u.aX([c]),sortKey:c.sortKey,state:Ge,terrainData:se})}else Z.push({segments:S.segments,sortKey:0,state:Ge,terrainData:se})}G&&Z.sort(((e,c)=>e.sortKey-c.sortKey));for(const c of Z){const u=c.state;if(C.activeTexture.set(R.TEXTURE0),u.atlasTexture.bind(u.atlasInterpolation,R.CLAMP_TO_EDGE),u.atlasTextureIcon&&(C.activeTexture.set(R.TEXTURE1),u.atlasTextureIcon&&u.atlasTextureIcon.bind(u.atlasInterpolationIcon,R.CLAMP_TO_EDGE)),u.isSDF){const f=u.uniformValues;u.hasHalo&&(f.u_is_halo=1,Ln(u.buffers,c.segments,p,e,u.program,U,S,P,f,u.projectionData,c.terrainData)),f.u_is_halo=0}Ln(u.buffers,c.segments,p,e,u.program,U,S,P,u.uniformValues,u.projectionData,c.terrainData)}}function Ln(e,c,u,p,f,m,g,y,x,b,T){const S=p.context;f.draw(S,S.gl.TRIANGLES,m,g,y,ti.backCCW,x,T,b,u.id,e.layoutVertexBuffer,e.indexBuffer,c,u.paint,p.transform.zoom,e.programConfigurations.get(u.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function Bn(e,c,p,f,m){const g=e.context,y=g.gl,x=ri.disabled,b=new Jt([y.ONE,y.ONE],u.bp.transparent,[!0,!0,!0,!0]),T=c.getBucket(p);if(!T)return;const S=f.key;let P=p.heatmapFbos.get(S);P||(P=Vn(g,c.tileSize,c.tileSize),p.heatmapFbos.set(S,P)),g.bindFramebuffer.set(P.framebuffer),g.viewport.set([0,0,c.tileSize,c.tileSize]),g.clear({color:u.bp.transparent});const I=T.programConfigurations.get(p.id),C=e.useProgram("heatmap",I,!m),R=e.transform.getProjectionData({overscaledTileID:c.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),F=e.style.map.terrain.getTerrainData(f);C.draw(g,y.TRIANGLES,ii.disabled,x,b,ti.disabled,Qr(c,e.transform.zoom,p.paint.get("heatmap-intensity"),1),F,R,p.id,T.layoutVertexBuffer,T.indexBuffer,T.segments,p.paint,e.transform.zoom,I)}function On(e,c,u,p,f){const m=e.context,g=m.gl,y=e.transform;m.setColorMode(e.colorModeForRenderPass());const x=jn(m,c),b=u.key,T=c.heatmapFbos.get(b);if(!T)return;m.activeTexture.set(g.TEXTURE0),g.bindTexture(g.TEXTURE_2D,T.colorAttachment.get()),m.activeTexture.set(g.TEXTURE1),x.bind(g.LINEAR,g.CLAMP_TO_EDGE);const S=y.getProjectionData({overscaledTileID:u,applyTerrainMatrix:f,applyGlobeMatrix:!p});e.useProgram("heatmapTexture").draw(m,g.TRIANGLES,ii.disabled,ri.disabled,e.colorModeForRenderPass(),ti.disabled,en(e,c,0,1),null,S,c.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,c.paint,y.zoom),T.destroy(),c.heatmapFbos.delete(b)}function Vn(e,c,u){var p,f;const m=e.gl,g=m.createTexture();m.bindTexture(m.TEXTURE_2D,g),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MIN_FILTER,m.LINEAR),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MAG_FILTER,m.LINEAR);const y=null!==(p=e.HALF_FLOAT)&&void 0!==p?p:m.UNSIGNED_BYTE,x=null!==(f=e.RGBA16F)&&void 0!==f?f:m.RGBA;m.texImage2D(m.TEXTURE_2D,0,x,c,u,0,m.RGBA,y,null);const b=e.createFramebuffer(c,u,!1,!1);return b.colorAttachment.set(g),b}function jn(e,c){return c.colorRampTexture||(c.colorRampTexture=new u.T(e,c.colorRamp,e.gl.RGBA)),c.colorRampTexture}function Nn(e,c,p,f,m,g,y,x){let b=256;if(m.stepInterpolant){const f=c.getSource().maxzoom,m=y.canonical.z===f?Math.ceil(1<e.options.anisotropicFilterPitch&&P.texParameterf(P.TEXTURE_2D,S.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,S.extTextureFilterAnisotropicMax);const ee=e.style.map.terrain&&e.style.map.terrain.getTerrainData(G),se=C.getProjectionData({overscaledTileID:G,aligned:L,applyGlobeMatrix:!b,applyTerrainMatrix:!0}),ce=fn(J,W,Q.fadeMix,u,y),he=R.getMeshFromTileID(S,G.canonical,m,g,"raster");I.draw(S,P.TRIANGLES,p,f?f[G.overscaledZ]:ri.disabled,F,x?ti.frontCCW:ti.backCCW,ce,ee,se,u.id,he.vertexBuffer,he.indexBuffer,he.segments)}}function Qn(e,c,p,f){const m={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===p||f)return m;if(e.fadingParentID){const f=c.getLoadedTile(e.fadingParentID);if(!f)return m;const g=Math.pow(2,f.tileID.overscaledZ-e.tileID.overscaledZ),y=[e.tileID.canonical.x*g%1,e.tileID.canonical.y*g%1],x=function(e,c,p){const f=T(),m=(f-c.timeAdded)/p,g=e.fadingDirection===Ae.Incoming,y=u.an((f-e.timeAdded)/p,0,1),x=u.an(1-m,0,1),b=g?y:x;return{tileOpacity:b,parentTileOpacity:g?x:y,fadeMix:{opacity:1,mix:1-b}}}(e,f,p);return{parentTile:f,parentScaleBy:g,parentTopLeft:y,fadeValues:x}}if(e.selfFading){const c=function(e,c){const p=(T()-e.timeAdded)/c,f=u.an(p,0,1);return{tileOpacity:f,fadeMix:{opacity:f,mix:0}}}(e,p);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:c}}return m}const ts=new u.bp(1,0,0,1),ns=new u.bp(0,1,0,1),os=new u.bp(0,0,1,1),ls=new u.bp(1,0,1,1),hs=new u.bp(0,1,1,1);function ds(e,c,u,p){ms(e,0,c+u/2,e.transform.width,u,p)}function ps(e,c,u,p){ms(e,c-u/2,0,u,e.transform.height,p)}function ms(e,c,u,p,f,m){const g=e.context,y=g.gl;y.enable(y.SCISSOR_TEST),y.scissor(c*e.pixelRatio,u*e.pixelRatio,p*e.pixelRatio,f*e.pixelRatio),g.clear({color:m}),y.disable(y.SCISSOR_TEST)}function _s(e,c,p){const f=e.context,m=f.gl,g=e.useProgram("debug"),y=ii.disabled,x=ri.disabled,b=e.colorModeForRenderPass(),T="$debug",S=e.style.map.terrain&&e.style.map.terrain.getTerrainData(p);f.activeTexture.set(m.TEXTURE0);const P=c.getTileByID(p.key).latestRawTileData,I=Math.floor((P&&P.byteLength||0)/1024),C=c.getTile(p).tileSize,R=512/Math.min(C,512)*(p.overscaledZ/e.transform.zoom)*.5;let F=p.canonical.toString();p.overscaledZ!==p.canonical.z&&(F+=` => ${p.overscaledZ}`),function(e,c){e.initDebugOverlayCanvas();const u=e.debugOverlayCanvas,p=e.context.gl,f=e.debugOverlayCanvas.getContext("2d");f.clearRect(0,0,u.width,u.height),f.shadowColor="white",f.shadowBlur=2,f.lineWidth=1.5,f.strokeStyle="white",f.textBaseline="top",f.font="bold 36px Open Sans, sans-serif",f.fillText(c,5,5),f.strokeText(c,5,5),e.debugOverlayTexture.update(u),e.debugOverlayTexture.bind(p.LINEAR,p.CLAMP_TO_EDGE)}(e,`${F} ${I}kB`);const L=e.transform.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!0,applyTerrainMatrix:!0});g.draw(f,m.TRIANGLES,y,x,Jt.alphaBlended,ti.disabled,Jr(u.bp.transparent,R),null,L,T,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),g.draw(f,m.LINE_STRIP,y,x,b,ti.disabled,Jr(u.bp.red),S,L,T,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function gs(e,c,u,p){const{isRenderingGlobe:f}=p,m=e.context,g=m.gl,y=e.transform,x=e.colorModeForRenderPass(),b=e.getDepthModeFor3D(),T=e.useProgram("terrain");m.bindFramebuffer.set(null),m.viewport.set([0,0,e.width,e.height]);for(const p of u){const u=c.getTerrainMesh(p.tileID),S=e.renderToTexture.getTexture(p),P=c.getTerrainData(p.tileID);m.activeTexture.set(g.TEXTURE0),g.bindTexture(g.TEXTURE_2D,S.texture);const I=c.getMeshFrameDelta(y.zoom),C=y.calculateFogMatrix(p.tileID.toUnwrapped()),R=Or(I,C,e.style.sky,y.pitch,f),F=y.getProjectionData({overscaledTileID:p.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});T.draw(m,g.TRIANGLES,b,ri.disabled,x,ti.backCCW,R,P,F,"terrain",u.vertexBuffer,u.indexBuffer,u.segments)}}function ys(e,c){if(!c.mesh){const p=new u.aW;p.emplaceBack(-1,-1),p.emplaceBack(1,-1),p.emplaceBack(1,1),p.emplaceBack(-1,1);const f=new u.aY;f.emplaceBack(0,1,2),f.emplaceBack(0,2,3),c.mesh=new Ft(e.createVertexBuffer(p,qi.members),e.createIndexBuffer(f),u.aX.simpleSegment(0,0,p.length,f.length))}return c.mesh}class Wr{constructor(e,c){this.context=new lr(e),this.transform=c,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:u.ar(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Fe.maxOverzooming+Fe.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Dt}resize(e,c,u){if(this.width=Math.floor(e*u),this.height=Math.floor(c*u),this.pixelRatio=u,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize()}setup(){const e=this.context,c=new u.aW;c.emplaceBack(0,0),c.emplaceBack(u.a5,0),c.emplaceBack(0,u.a5),c.emplaceBack(u.a5,u.a5),this.tileExtentBuffer=e.createVertexBuffer(c,qi.members),this.tileExtentSegments=u.aX.simpleSegment(0,0,4,2);const p=new u.aW;p.emplaceBack(0,0),p.emplaceBack(u.a5,0),p.emplaceBack(0,u.a5),p.emplaceBack(u.a5,u.a5),this.debugBuffer=e.createVertexBuffer(p,qi.members),this.debugSegments=u.aX.simpleSegment(0,0,4,5);const f=new u.ch;f.emplaceBack(0,0,0,0),f.emplaceBack(u.a5,0,u.a5,0),f.emplaceBack(0,u.a5,0,u.a5),f.emplaceBack(u.a5,u.a5,u.a5,u.a5),this.rasterBoundsBuffer=e.createVertexBuffer(f,Br.members),this.rasterBoundsSegments=u.aX.simpleSegment(0,0,4,2);const m=new u.aW;m.emplaceBack(0,0),m.emplaceBack(u.a5,0),m.emplaceBack(0,u.a5),m.emplaceBack(u.a5,u.a5),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(m,qi.members),this.rasterBoundsSegmentsPosOnly=u.aX.simpleSegment(0,0,4,5);const g=new u.aW;g.emplaceBack(0,0),g.emplaceBack(1,0),g.emplaceBack(0,1),g.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(g,qi.members),this.viewportSegments=u.aX.simpleSegment(0,0,4,2);const y=new u.ci;y.emplaceBack(0),y.emplaceBack(1),y.emplaceBack(3),y.emplaceBack(2),y.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(y);const x=new u.aY;x.emplaceBack(1,0,2),x.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(x);const b=this.context.gl;this.stencilClearMode=new ri({func:b.ALWAYS,mask:0},0,255,b.ZERO,b.ZERO,b.ZERO),this.tileExtentMesh=new Ft(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,c=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const p=u.N();u.c7(p,0,this.width,this.height,0,0,1),u.Q(p,p,[c.drawingBufferWidth,c.drawingBufferHeight,0]);const f={mainMatrix:p,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:p};this.useProgram("clippingMask",null,!0).draw(e,c.TRIANGLES,ii.disabled,this.stencilClearMode,Jt.disabled,ti.disabled,null,null,f,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,c,u){if(this.currentStencilSource===e.source||!e.isTileClipped()||!c||!c.length)return;this.currentStencilSource=e.source,this.nextStencilID+c.length>256&&this.clearStencil();const p=this.context;p.setColorMode(Jt.disabled),p.setDepthMode(ii.disabled);const f={};for(const e of c)f[e.key]=this.nextStencilID++;this._renderTileMasks(f,c,u,!0),this._renderTileMasks(f,c,u,!1),this._tileClippingMaskIDs=f}_renderTileMasks(e,c,u,p){const f=this.context,m=f.gl,g=this.style.projection,y=this.transform,x=this.useProgram("clippingMask");for(const b of c){const c=e[b.key],T=this.style.map.terrain&&this.style.map.terrain.getTerrainData(b),S=g.getMeshFromTileID(this.context,b.canonical,p,!0,"stencil"),P=y.getProjectionData({overscaledTileID:b,applyGlobeMatrix:!u,applyTerrainMatrix:!0});x.draw(f,m.TRIANGLES,ii.disabled,new ri({func:m.ALWAYS,mask:0},c,255,m.KEEP,m.KEEP,m.REPLACE),Jt.disabled,u?ti.disabled:ti.backCCW,null,T,P,"$clipping",S.vertexBuffer,S.indexBuffer,S.segments)}}_renderTilesDepthBuffer(){const e=this.context,c=e.gl,u=this.style.projection,p=this.transform,f=this.useProgram("depth"),m=this.getDepthModeFor3D(),g=at(p,{tileSize:p.tileSize});for(const y of g){const g=this.style.map.terrain&&this.style.map.terrain.getTerrainData(y),x=u.getMeshFromTileID(this.context,y.canonical,!0,!0,"raster"),b=p.getProjectionData({overscaledTileID:y,applyGlobeMatrix:!0,applyTerrainMatrix:!0});f.draw(e,c.TRIANGLES,m,ri.disabled,Jt.disabled,ti.backCCW,null,g,b,"$clipping",x.vertexBuffer,x.indexBuffer,x.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,c=this.context.gl;return new ri({func:c.NOTEQUAL,mask:255},e,255,c.KEEP,c.KEEP,c.REPLACE)}stencilModeForClipping(e){const c=this.context.gl;return new ri({func:c.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,c.KEEP,c.KEEP,c.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const c=this.context.gl,u=e.sort(((e,c)=>c.overscaledZ-e.overscaledZ)),p=u[u.length-1].overscaledZ,f=u[0].overscaledZ-p+1;if(f>1){this.currentStencilSource=void 0,this.nextStencilID+f>256&&this.clearStencil();const e={};for(let u=0;uc.overscaledZ-e.overscaledZ)),p=u[u.length-1].overscaledZ,f=u[0].overscaledZ-p+1;if(this.clearStencil(),f>1){const e={},m={};for(let u=0;u0};for(const e in g){const c=g[e];c.used&&c.prepare(this.context),y[e]=c.getVisibleCoordinates(!1),x[e]=y[e].slice().reverse(),b[e]=c.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:c.showOverdrawInspector?u.bp.black:u.bp.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,c){const u=e.context,p=u.gl,f=((e,c,u)=>{const p=Math.cos(c.rollInRadians),f=Math.sin(c.rollInRadians),m=$e(c),g=c.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(c.width/2-m*f)*u,(c.height/2+m*p)*u],u_horizon_normal:[-f,p],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*c.height/2*u,u_sky_blend:g}})(c,e.style.map.transform,e.pixelRatio),m=new ii(p.LEQUAL,ii.ReadWrite,[0,1]),g=ri.disabled,y=e.colorModeForRenderPass(),x=e.useProgram("sky"),b=ys(u,c);x.draw(u,p.TRIANGLES,m,g,y,ti.disabled,f,null,void 0,"sky",b.vertexBuffer,b.indexBuffer,b.segments)}(this,this.style.sky),this._showOverdrawInspector=c.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=m.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[m[this.currentLayer]],c=g[e.source],u=y[e.source];this._renderTileClippingMasks(e,u,!1),this.renderLayer(this,c,e,u,S)}this.renderPass="translucent";let P=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:c,u_globe_position:u,u_globe_radius:p,u_inv_proj_matrix:f}))(b,S,[C[0],C[1],C[2]],P,I),F=ys(f,c);g.draw(f,m.TRIANGLES,y,ri.disabled,Jt.alphaBlended,ti.disabled,R,null,null,"atmosphere",F.vertexBuffer,F.indexBuffer,F.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,c){let u=null;const p=Object.values(e._layers).flatMap((u=>u.source&&!u.isHidden(c)?[e.tileManagers[u.source]]:[])),f=p.filter((e=>"vector"===e.getSource().type)),m=p.filter((e=>"vector"!==e.getSource().type)),g=e=>{(!u||u.getSource().maxzoomg(e))),u||m.forEach((e=>g(e))),u}(this.style,this.transform.zoom);e&&function(e,c,u){for(let p=0;pS.getElevation(m,e,c):null;zn(g,P,I,b,T,F,c,C,L,u.aO(T,e,y,x),m.toUnwrapped(),p)}}}(f,e,p,c,p.layout.get("text-rotation-alignment"),p.layout.get("text-pitch-alignment"),p.paint.get("text-translate"),p.paint.get("text-translate-anchor"),m),0!==p.paint.get("icon-opacity").constantOr(1)&&Rn(e,c,p,f,!1,p.paint.get("icon-translate"),p.paint.get("icon-translate-anchor"),p.layout.get("icon-rotation-alignment"),p.layout.get("icon-pitch-alignment"),p.layout.get("icon-keep-upright"),x,b,y),0!==p.paint.get("text-opacity").constantOr(1)&&Rn(e,c,p,f,!0,p.paint.get("text-translate"),p.paint.get("text-translate-anchor"),p.layout.get("text-rotation-alignment"),p.layout.get("text-pitch-alignment"),p.layout.get("text-keep-upright"),x,b,y),c.map.showCollisionBoxes&&(Mn(e,c,p,f,!0),Mn(e,c,p,f,!1))}(e,c,p,f,this.style.placement.variableOffsets,m):u.cn(p)?function(e,c,p,f,m){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:g}=m,y=p.paint.get("circle-opacity"),x=p.paint.get("circle-stroke-width"),b=p.paint.get("circle-stroke-opacity"),T=!p.layout.get("circle-sort-key").isConstant();if(0===y.constantOr(1)&&(0===x.constantOr(1)||0===b.constantOr(1)))return;const S=e.context,P=S.gl,I=e.transform,C=e.getDepthModeForSublayer(0,ii.ReadOnly),R=ri.disabled,F=e.colorModeForRenderPass(),L=[],B=I.getCircleRadiusCorrection();for(let m=0;me.sortKey-c.sortKey));for(const c of L){const{programConfiguration:u,program:f,layoutVertexBuffer:m,indexBuffer:g,uniformValues:y,terrainData:x,projectionData:b}=c.state;f.draw(S,P.TRIANGLES,C,R,F,ti.backCCW,y,x,b,p.id,m,g,c.segments,p.paint,e.transform.zoom,u)}}(e,c,p,f,m):u.co(p)?function(e,c,p,f,m){if(0===p.paint.get("heatmap-opacity"))return;const g=e.context,{isRenderingToTexture:y,isRenderingGlobe:x}=m;if(e.style.map.terrain){for(const u of f){const f=c.getTile(u);c.hasRenderableParent(u)||("offscreen"===e.renderPass?Bn(e,f,p,u,x):"translucent"===e.renderPass&&On(e,p,u,y,x))}g.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,c,p,f){const m=e.context,g=m.gl,y=e.transform,x=ri.disabled,b=new Jt([g.ONE,g.ONE],u.bp.transparent,[!0,!0,!0,!0]);(function(e,c,p){const f=e.gl;e.activeTexture.set(f.TEXTURE1),e.viewport.set([0,0,c.width/4,c.height/4]);let m=p.heatmapFbos.get(u.cd);m?(f.bindTexture(f.TEXTURE_2D,m.colorAttachment.get()),e.bindFramebuffer.set(m.framebuffer)):(m=Vn(e,c.width/4,c.height/4),p.heatmapFbos.set(u.cd,m))})(m,e,p),m.clear({color:u.bp.transparent});for(let u=0;u0?c.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const c=this.imageManager.getPattern(e.from.toString()),u=this.imageManager.getPattern(e.to.toString());return!c||!u}useProgram(e,c,u=!1,p=[]){this.cache=this.cache||{};const f=!!this.style.map.terrain,m=this.style.projection,g=u?Ni.projectionMercator:m.shaderPreludeCode,y=u?$i:m.shaderDefine,x=e+(c?c.cacheKey:"")+`/${u?Zi:m.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(f?"/terrain":"")+(p?`/${p.join("/")}`:"");return this.cache[x]||(this.cache[x]=new Gi(this.context,Ni[e],c,wn[e],this._showOverdrawInspector,f,g,y,p)),this.cache[x]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new u.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var e,c;if(this._tileTextures){for(const e in this._tileTextures){const c=this._tileTextures[e];if(c)for(const e of c)e.destroy()}this._tileTextures={}}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&(null===(e=this.tileExtentMesh.vertexBuffer)||void 0===e||e.destroy()),this.tileExtentMesh&&(null===(c=this.tileExtentMesh.indexBuffer)||void 0===c||c.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const e in this.cache){const c=this.cache[e];c&&c.program&&this.context.gl.deleteProgram(c.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:c}=this.context.gl;return this.width!==e||this.height!==c}}function vs(c,u){let p,f=!1,m=null,g=null;const y=()=>{m=null,f&&(c.apply(g,p),m=setTimeout(y,u),f=!1)};return(...c)=>(f=!0,g=this||e,p=c,m||y(),m)}class Hr{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let c;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(c=e)})),(c&&c[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return!1;const c=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:c,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const c=e.join("/");let u=c;u.split("&").length>0&&(u=u.split("&")[0]),this._hashName&&(u=`${this._hashName}=${c}`);let p=window.location.hash.replace(u,"");p.startsWith("#&")?p=p.slice(0,1)+p.slice(2):"#"===p&&(p="");let f=window.location.href.replace(/(#.+)?$/,p);f=f.replace("&&","&"),window.history.replaceState(window.history.state,null,f)},this._updateHash=vs(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const c=this._map.getCenter(),u=Math.round(100*this._map.getZoom())/100,p=Math.ceil((u*Math.LN2+Math.log(512/360/.5))/Math.LN10),f=Math.pow(10,p),m=Math.round(c.lng*f)/f,g=Math.round(c.lat*f)/f,y=this._map.getBearing(),x=this._map.getPitch();let b="";if(b+=e?`/${m}/${g}/${u}`:`${u}/${g}/${m}`,(y||x)&&(b+="/"+Math.round(10*y)/10),x&&(b+=`/${Math.round(x)}`),this._hashName){const e=this._hashName;let c=!1;const u=window.location.hash.slice(1).split("&").map((u=>{const p=u.split("=")[0];return p===e?(c=!0,`${p}=${b}`):u})).filter((e=>e));return c||u.push(`${e}=${b}`),`#${u.join("&")}`}return`#${b}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new u.V(+e[2],+e[1])}catch(e){return!1}const c=+e[0],p=+(e[3]||0),f=+(e[4]||0);return c>=this._map.getMinZoom()&&c<=this._map.getMaxZoom()&&p>=-180&&p<=180&&f>=this._map.getMinPitch()&&f<=this._map.getMaxPitch()}}const bs={linearity:.3,easing:u.cw(0,0,.3,1)},ws=u.e({deceleration:2500,maxSpeed:1400},bs),Ts=u.e({deceleration:20,maxSpeed:1400},bs),Ss=u.e({deceleration:1e3,maxSpeed:360},bs),Ps=u.e({deceleration:1e3,maxSpeed:90},bs),Is=u.e({deceleration:1e3,maxSpeed:360},bs);class to{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:T(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,c=T();for(;e.length>0&&c-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const c={zoom:0,bearing:0,pitch:0,roll:0,pan:new u.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)c.zoom+=e.zoomDelta||0,c.bearing+=e.bearingDelta||0,c.pitch+=e.pitchDelta||0,c.roll+=e.rollDelta||0,e.panDelta&&c.pan._add(e.panDelta),e.around&&(c.around=e.around),e.pinchAround&&(c.pinchAround=e.pinchAround);const p=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,f={};if(c.pan.mag()){const m=Es(c.pan.mag(),p,u.e({},ws,e||{})),g=c.pan.mult(m.amount/c.pan.mag()),y=this._map.cameraHelper.handlePanInertia(g,this._map.transform);f.center=y.easingCenter,f.offset=y.easingOffset,Ms(f,m)}if(c.zoom){const e=Es(c.zoom,p,Ts),m=u.cx(this._map.transform.zoom+e.amount,this._map.getZoomSnap(),e.amount);f.zoom=m,Ms(f,e)}if(c.bearing){const e=Es(c.bearing,p,Ss);f.bearing=this._map.transform.bearing+u.an(e.amount,-179,179),Ms(f,e)}if(c.pitch){const e=Es(c.pitch,p,Ps);f.pitch=this._map.transform.pitch+e.amount,Ms(f,e)}if(c.roll){const e=Es(c.roll,p,Is);f.roll=this._map.transform.roll+u.an(e.amount,-179,179),Ms(f,e)}if(f.zoom||f.bearing){const e=void 0===c.pinchAround?c.around:c.pinchAround;f.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),u.e(f,{noMoveStart:!0})}}function Ms(e,c){(!e.duration||e.durationc.unproject(e))),y=m.reduce(((e,c,u,p)=>e.add(c.div(p.length))),new u.P(0,0));super(e,{points:m,point:y,lngLats:g,lngLat:c.unproject(y),originalEvent:p}),this._defaultPrevented=!1}}class so extends u.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,c,u){super(e,{originalEvent:u}),this._defaultPrevented=!1}}class no{constructor(e,c){this._map=e,this._clickTolerance=c.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new so(e.type,this._map,e))}mousedown(e,c){return this._mousedownPos=c,this._firePreventable(new ro(e.type,this._map,e))}mouseup(e){this._map.fire(new ro(e.type,this._map,e))}click(e,c){this._mousedownPos&&this._mousedownPos.dist(c)>=this._clickTolerance||this._map.fire(new ro(e.type,this._map,e))}dblclick(e){return this._firePreventable(new ro(e.type,this._map,e))}mouseover(e){this._map.fire(new ro(e.type,this._map,e))}mouseout(e){this._map.fire(new ro(e.type,this._map,e))}touchstart(e){return this._firePreventable(new oo(e.type,this._map,e))}touchmove(e){this._map.fire(new oo(e.type,this._map,e))}touchend(e){this._map.fire(new oo(e.type,this._map,e))}touchcancel(e){this._map.fire(new oo(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class lo{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new ro(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ro("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ro(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class co{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(u.P.convert(e),this._map.terrain)}}class ho{constructor(e,c){this._map=e,this._tr=new co(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=c.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,c){this.isEnabled()&&e.shiftKey&&0===e.button&&(h.disableDrag(),this._startPos=this._lastPos=c,this._active=!0)}mousemoveWindow(e,c){if(!this._active)return;const u=c;if(this._lastPos.equals(u)||!this._box&&u.dist(this._startPos)e.fitScreenCoordinates(p,f,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(h.remove(this._box),this._box=null),h.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,c){return this._map.fire(new u.l(e,{originalEvent:c}))}}function As(e,c){if(e.length!==c.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${c.length}`);const u={};for(let p=0;pthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),p.length===this.numTouches&&(this.centroid=function(e){const c=new u.P(0,0);for(const u of e)c._add(u);return c.div(e.length)}(c),this.touches=As(p,c)))}touchmove(e,c,u){if(this.aborted||!this.centroid)return;const p=As(u,c);for(const e in this.touches){const c=p[e];(!c||c.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,c,u){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===u.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class po{constructor(e){this.singleTap=new _o(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,c,u){this.singleTap.touchstart(e,c,u)}touchmove(e,c,u){this.singleTap.touchmove(e,c,u)}touchend(e,c,u){const p=this.singleTap.touchend(e,c,u);if(p){const c=e.timeStamp-this.lastTime<500,u=!this.lastTap||this.lastTap.dist(p)<30;if(c&&u||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=p,this.count===this.numTaps)return this.reset(),p}}}class mo{constructor(e){this._tr=new co(e),this._zoomIn=new po({numTouches:1,numTaps:2}),this._zoomOut=new po({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,c,u){this._zoomIn.touchstart(e,c,u),this._zoomOut.touchstart(e,c,u)}touchmove(e,c,u){this._zoomIn.touchmove(e,c,u),this._zoomOut.touchmove(e,c,u)}touchend(e,c,p){const f=this._zoomIn.touchend(e,c,p),m=this._zoomOut.touchend(e,c,p),g=this._tr;return f?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:c=>c.easeTo({duration:300,zoom:u.cx(g.zoom+1,c.getZoomSnap()),around:g.unproject(f)},{originalEvent:e})}):m?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:c=>c.easeTo({duration:300,zoom:u.cx(g.zoom-1,c.getZoomSnap()),around:g.unproject(m)},{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 fo{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const c=this._moveFunction(...e);if(c.bearingDelta||c.pitchDelta||c.rollDelta||c.around||c.panDelta)return this._active=!0,c}dragStart(e,c){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(c)?c[0]:c,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,c){if(!this.isEnabled())return;const u=this._lastPoint;if(!u)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const p=Array.isArray(c)?c[0]:c;return!this._moved&&p.dist(u)!0}),c=new yo){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=c}_executeRelevantHandler(e,c,u){return e instanceof MouseEvent?c(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?u(e):void 0}startMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.startMove(e)),(e=>this.oneFingerTouchMoveStateManager.startMove(e)))}endMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.endMove(e)),(e=>this.oneFingerTouchMoveStateManager.endMove(e)))}isValidStartEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidStartEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e)))}isValidMoveEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidMoveEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e)))}isValidEndEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidEndEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e)))}}const Bs=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class Po{constructor(e,c){this._clickTolerance=e.clickTolerance||1,this._map=c,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new u.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,c,u){return this._calculateTransform(e,c,u)}touchmove(e,c,u){if(this._active){if(!this._shouldBePrevented(u.length))return e.preventDefault(),this._calculateTransform(e,c,u);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,c,u){this._calculateTransform(e,c,u),this._active&&this._shouldBePrevented(u.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,c,p){p.length>0&&(this._active=!0);const f=As(p,c),m=new u.P(0,0),g=new u.P(0,0);let y=0;for(const e in f){const c=f[e],u=this._touches[e];u&&(m._add(c),g._add(c.sub(u)),y++,f[e]=c)}if(this._touches=f,this._shouldBePrevented(y)||!g.mag())return;const x=g.div(y);return this._sum._add(x),this._sum.mag()Math.abs(e.x)}class Do extends Co{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,c,u){super.touchstart(e,c,u),this._currentTouchCount=u.length}_start(e){this._lastPoints=e,ao(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,c,u){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const p=e[0].sub(this._lastPoints[0]),f=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(p,f,u.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(p.y+f.y)/2*-.5}):void 0}gestureBeginsVertically(e,c,u){if(void 0!==this._valid)return this._valid;const p=e.mag()>=2,f=c.mag()>=2;if(!p&&!f)return;if(!p||!f)return void 0===this._firstMove&&(this._firstMove=u),u-this._firstMove<100&&void 0;const m=e.y>0==c.y>0;return ao(e)&&ao(c)&&m}}const uo={panStep:100,bearingStep:15,pitchStep:10};class Lo{constructor(e){this._tr=new co(e);const c=uo;this._panStep=c.panStep,this._bearingStep=c.bearingStep,this._pitchStep=c.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let c=0,p=0,f=0,m=0,g=0;switch(e.keyCode){case 61:case 107:case 171:case 187:c=1;break;case 189:case 109:case 173:c=-1;break;case 37:e.shiftKey?p=-1:(e.preventDefault(),m=-1);break;case 39:e.shiftKey?p=1:(e.preventDefault(),m=1);break;case 38:e.shiftKey?f=1:(e.preventDefault(),g=-1);break;case 40:e.shiftKey?f=-1:(e.preventDefault(),g=1);break;default:return}return this._rotationDisabled&&(p=0,f=0),{cameraAnimation:y=>{const x=this._tr;y.easeTo({duration:300,easeId:"keyboardHandler",easing:xo,zoom:c?u.cx(x.zoom+c*(e.shiftKey?2:1),y.getZoomSnap()):x.zoom,bearing:x.bearing+p*this._bearingStep,pitch:x.pitch+f*this._pitchStep,offset:[-m*this._panStep,-g*this._panStep],center:x.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 xo(e){return e*(2-e)}const vo=4.000244140625,Mo=1/450;class Oo{constructor(e,c){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new co(e),this._triggerRenderFrame=c,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Mo}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let c=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const u=T(),p=u-(this._lastWheelEventTime||0);this._lastWheelEventTime=u,0!==c&&c%vo==0?this._type="wheel":0!==c&&Math.abs(c)<4?this._type="trackpad":p>400?(this._type=null,this._lastValue=c,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(p*c)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,c+=this._lastValue)),e.shiftKey&&c&&(c/=4),this._type&&(this._lastWheelEvent=e,this._delta-=c,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const c=h.mousePos(this._map.getCanvas(),e),p=this._tr;this._aroundPoint=this._aroundCenter?p.transform.locationToScreenPoint(u.V.convert(p.center)):c,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const c=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=c),"number"==typeof this._targetZoom&&(this._targetZoom+=c)}if(0!==this._delta){const c="wheel"===this._type&&Math.abs(this._delta)>vo?this._wheelZoomRate:this._defaultZoomRate;let p=2/(1+Math.exp(-Math.abs(this._delta*c)));this._delta<0&&0!==p&&(p=1/p);const f="number"!=typeof this._targetZoom?e.scale:u.aq(this._targetZoom),m=e.applyConstrain(e.getCameraLngLat(),u.at(f*p)).zoom,g=this._map.getZoomSnap();if("wheel"===this._type&&g>0){const c=u.cx(e.zoom,g);this._targetZoom=u.cx(m,g,m-c)}else this._targetZoom=m;"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const c="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,p=this._startZoom,f=this._easing;let m,g=!1;if("wheel"===this._type&&p&&f){const e=T()-this._lastWheelEventTime,y=Math.min((e+5)/200,1),x=f(y);m=u.G.number(p,c,x),y<1?this._frameId||(this._frameId=!0):g=!0}else m=c,g=!0;return this._active=!0,g&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=m,{noInertia:!0,needsRenderFrame:!g,zoomDelta:m-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let c=u.cz;if(this._prevEase){const e=this._prevEase,p=(T()-e.start)/e.duration,f=e.easing(p+.01)-e.easing(p),m=.27/Math.sqrt(f*f+1e-4)*.01,g=Math.sqrt(.0729-m*m);c=u.cw(m,g,.25,1)}return this._prevEase={start:T(),duration:e,easing:c},c}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class jo{constructor(e,c){this._clickZoom=e,this._tapZoom=c}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 No{constructor(e){this._tr=new co(e),this.reset()}reset(){this._active=!1}dblclick(e,c){return e.preventDefault(),{cameraAnimation:p=>{p.easeTo({duration:300,zoom:u.cx(this._tr.zoom+(e.shiftKey?-1:1),p.getZoomSnap()),around:this._tr.unproject(c)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Zo{constructor(){this._tap=new po({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,c,u){if(!this._swipePoint)if(this._tapTime){const p=c[0],f=e.timeStamp-this._tapTime<500,m=this._tapPoint.dist(p)<30;f&&m?u.length>0&&(this._swipePoint=p,this._swipeTouch=u[0].identifier):this.reset()}else this._tap.touchstart(e,c,u)}touchmove(e,c,u){if(this._tapTime){if(this._swipePoint){if(u[0].identifier!==this._swipeTouch)return;const p=c[0],f=p.y-this._swipePoint.y;return this._swipePoint=p,e.preventDefault(),this._active=!0,{zoomDelta:f/128}}}else this._tap.touchmove(e,c,u)}touchend(e,c,u){if(this._tapTime)this._swipePoint&&0===u.length&&this.reset();else{const p=this._tap.touchend(e,c,u);p&&(this._tapTime=e.timeStamp,this._tapPoint=p)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Go{constructor(e,c,u){this._el=e,this._mousePan=c,this._touchPan=u}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 Uo{constructor(e,c,u,p){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=c,this._mousePitch=u,this._mouseRoll=p}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class Vo{constructor(e,c,u,p){this._el=e,this._touchZoom=c,this._touchRotate=u,this._tapDragZoom=p,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 qo{constructor(e,c){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=c,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=h.create("div","maplibregl-cooperative-gesture-screen",e);let c=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(c=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const u=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),p=document.createElement("div");p.className="maplibregl-desktop-message",p.textContent=c,this._container.appendChild(p);const f=document.createElement("div");f.className="maplibregl-mobile-message",f.textContent=u,this._container.appendChild(f),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(h.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,c){this._enabled&&(this._map.fire(new u.l("cooperativegestureprevented",{gestureType:e,originalEvent:c})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const ko=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class $o extends u.l{}function Ro(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Xo{get _ownerDocument(){var e;return(null===(e=this._el)||void 0===e?void 0:e.ownerDocument)||document}get _ownerWindow(){var e,c;return(null===(c=null===(e=this._el)||void 0===e?void 0:e.ownerDocument)||void 0===c?void 0:c.defaultView)||window}constructor(e,c){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,c)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const p="renderFrame"===e.type?void 0:e,f={needsRenderFrame:!1},m={},g={};for(const{handlerName:y,handler:x,allowed:b}of this._handlers){if(!x.isEnabled())continue;let T;if(this._blockedByActive(g,b,y))x.reset();else if(x[c||e.type]){if(u.cA(e,c||e.type)){const u=h.mousePos(this._map.getCanvas(),e);T=x[c||e.type](e,u)}else if(u.cB(e,c||e.type)){const u=this._getMapTouches(e.touches),p=h.touchPos(this._map.getCanvas(),u);T=x[c||e.type](e,p,u)}else u.cC(c||e.type)||(T=x[c||e.type](e));this.mergeHandlerResult(f,m,T,y,p),T&&T.needsRenderFrame&&this._triggerRenderFrame()}(T||x.isActive())&&(g[y]=x)}const y={};for(const e in this._previousActiveHandlers)g[e]||(y[e]=p);this._previousActiveHandlers=g,(Object.keys(y).length||Ro(f))&&(this._changes.push([f,m,y]),this._triggerRenderFrame()),(Object.keys(g).length||Ro(f))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:x}=f;x&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],x(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new to(e),this._bearingSnap=c.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(c);const p=this._el;this._listeners=[[p,"touchstart",{passive:!0}],[p,"touchmove",{passive:!1}],[p,"touchend",void 0],[p,"touchcancel",void 0],[p,"mousedown",void 0],[p,"mousemove",void 0],[p,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[p,"mouseover",void 0],[p,"mouseout",void 0],[p,"dblclick",void 0],[p,"click",void 0],[p,"keydown",{capture:!1}],[p,"keyup",void 0],[p,"wheel",{passive:!1}],[p,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(const[e,c,u]of this._listeners)h.addEventListener(e,c,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,u)}destroy(){for(const[e,c,u]of this._listeners)h.removeEventListener(e,c,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,u)}_addDefaultHandlers(e){const c=this._map,p=c.getCanvasContainer();this._add("mapEvent",new no(c,e));const f=c.boxZoom=new ho(c,e);this._add("boxZoom",f),e.interactive&&e.boxZoom&&f.enable();const m=c.cooperativeGestures=new qo(c,e.cooperativeGestures);this._add("cooperativeGestures",m),e.cooperativeGestures&&m.enable();const g=new mo(c),y=new No(c);c.doubleClickZoom=new jo(y,g),this._add("tapZoom",g),this._add("clickZoom",y),e.interactive&&e.doubleClickZoom&&c.doubleClickZoom.enable();const x=new Zo;this._add("tapDragZoom",x);const b=c.touchPitch=new Do(c);this._add("touchPitch",b),e.interactive&&e.touchPitch&&c.touchPitch.enable(e.touchPitch);const T=()=>c.project(c.getCenter()),S=function({enable:e,clickTolerance:c,aroundCenter:p=!0,minPixelCenterThreshold:f=100,rotateDegreesPerPixelMoved:m=.8},g){const y=new bo({checkCorrectEvent:e=>0===h.mouseButton(e)&&e.ctrlKey||2===h.mouseButton(e)&&!e.ctrlKey});return new fo({clickTolerance:c,move:(e,c)=>{const y=g();if(p&&Math.abs(y.y-e.y)>f)return{bearingDelta:u.cy(new u.P(e.x,c.y),c,y)};let x=(c.x-e.x)*m;return p&&c.y0===h.mouseButton(e)&&e.ctrlKey||2===h.mouseButton(e)});return new fo({clickTolerance:c,move:(e,c)=>({pitchDelta:(c.y-e.y)*u}),moveStateManager:p,enable:e,assignEvents:Bs})}(e),I=function({enable:e,clickTolerance:c,rollDegreesPerPixelMoved:u=.3},p){const f=new bo({checkCorrectEvent:e=>2===h.mouseButton(e)&&e.ctrlKey});return new fo({clickTolerance:c,move:(e,c)=>{const f=p();let m=(c.x-e.x)*u;return c.y0===h.mouseButton(e)&&!e.ctrlKey});return new fo({clickTolerance:c,move:(e,c)=>({around:c,panDelta:c.sub(e)}),activateOnStart:!0,moveStateManager:u,enable:e,assignEvents:Bs})}(e),R=new Po(e,c);c.dragPan=new Go(p,C,R),this._add("mousePan",C),this._add("touchPan",R,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&c.dragPan.enable(e.dragPan);const F=new zo,L=new Eo;c.touchZoomRotate=new Vo(p,L,F,x),this._add("touchRotate",F,["touchPan","touchZoom"]),this._add("touchZoom",L,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&c.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new lo(c));const B=c.scrollZoom=new Oo(c,(()=>this._triggerRenderFrame()));this._add("scrollZoom",B,["mousePan"]),e.interactive&&e.scrollZoom&&c.scrollZoom.enable(e.scrollZoom);const O=c.keyboard=new Lo(c);this._add("keyboard",O),e.interactive&&e.keyboard&&c.keyboard.enable()}_add(e,c,u){this._handlers.push({handlerName:e,handler:c,allowed:u}),this._handlersById[e]=c}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(ko(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,c,u){for(const p in e)if(p!==u&&(!c||c.indexOf(p)<0))return!0;return!1}_getMapTouches(e){const c=[];for(const u of e)this._el.contains(u.target)&&c.push(u);return c}mergeHandlerResult(e,c,p,f,m){if(!p)return;u.e(e,p);const g={handlerName:f,originalEvent:p.originalEvent||m};void 0!==p.zoomDelta&&(c.zoom=g),void 0!==p.panDelta&&(c.drag=g),void 0!==p.rollDelta&&(c.roll=g),void 0!==p.pitchDelta&&(c.pitch=g),void 0!==p.bearingDelta&&(c.rotate=g)}_applyChanges(){const e={},c={},p={};for(const[f,m,g]of this._changes)f.panDelta&&(e.panDelta=(e.panDelta||new u.P(0,0))._add(f.panDelta)),f.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+f.zoomDelta),f.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+f.bearingDelta),f.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+f.pitchDelta),f.rollDelta&&(e.rollDelta=(e.rollDelta||0)+f.rollDelta),void 0!==f.around&&(e.around=f.around),void 0!==f.pinchAround&&(e.pinchAround=f.pinchAround),f.noInertia&&(e.noInertia=f.noInertia),u.e(c,m),u.e(p,g);this._updateMapTransform(e,c,p),this._changes=[]}_updateMapTransform(e,c,u){const p=this._map,f=p._getTransformForUpdate(),m=p.terrain;if(!(Ro(e)||m&&this._terrainMovement))return this._fireEvents(c,u,!0);p._stop(!0);let{panDelta:g,zoomDelta:y,bearingDelta:x,pitchDelta:b,rollDelta:T,around:S,pinchAround:P}=e;void 0!==P&&(S=P),S=S||p.transform.centerPoint,m&&!f.isPointOnMapSurface(S)&&(S=f.centerPoint);const I={panDelta:g,zoomDelta:y,rollDelta:T,pitchDelta:b,bearingDelta:x,around:S};this._map.cameraHelper.useGlobeControls&&!f.isPointOnMapSurface(S)&&(S=f.centerPoint);const C=S.distSqr(f.centerPoint)<.01?f.center:f.screenPointToLocation(g?S.sub(g):S);this._handleMapControls({terrain:m,tr:f,deltasForHelper:I,preZoomAroundLoc:C,combinedEventsInProgress:c,panDelta:g}),p._applyUpdatedTransform(f),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(c,u,!0)}_handleMapControls({terrain:e,tr:c,deltasForHelper:u,preZoomAroundLoc:p,combinedEventsInProgress:f,panDelta:m}){const g=this._map.cameraHelper;if(g.handleMapControlsRollPitchBearingZoom(u,c),e)return g.useGlobeControls?(this._terrainMovement||!f.drag&&!f.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void g.handleMapControlsPan(u,c,p)):this._terrainMovement||!f.drag&&!f.zoom?void(f.drag&&this._terrainMovement&&m?c.setCenter(c.screenPointToLocation(c.centerPoint.sub(m))):g.handleMapControlsPan(u,c,p)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void g.handleMapControlsPan(u,c,p));g.handleMapControlsPan(u,c,p)}_fireEvents(e,c,p){const f=ko(this._eventsInProgress),m=ko(e),g={};for(const c in e){const{originalEvent:u}=e[c];this._eventsInProgress[c]||(g[`${c}start`]=u),this._eventsInProgress[c]=e[c]}!f&&m&&this._fireEvent("movestart",m.originalEvent);for(const e in g)this._fireEvent(e,g[e]);m&&this._fireEvent("move",m.originalEvent);for(const c in e){const{originalEvent:u}=e[c];this._fireEvent(c,u)}const y={};let b;for(const e in this._eventsInProgress){const{handlerName:u,originalEvent:p}=this._eventsInProgress[e];this._handlersById[u].isActive()||(delete this._eventsInProgress[e],b=c[u]||p,y[`${e}end`]=b)}for(const e in y)this._fireEvent(e,y[e]);const T=ko(this._eventsInProgress),S=(f||m)&&!T;if(S&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(p&&S){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),c=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new $o("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Ko extends u.E{constructor(e,c,u){super(),this._renderFrameCallback=()=>{const e=Math.min((T()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=u.bearingSnap,this._zoomSnap=u.zoomSnap,this.cameraHelper=c,this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(e,c){e.apply(this.transform,!0),this.transform=e,this.cameraHelper=c}getCenter(){return new u.V(this.transform.center.lng,this.transform.center.lat)}setCenter(e,c){return this.jumpTo({center:e},c)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,c){return this.jumpTo({elevation:e},c),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,c,p){return e=u.P.convert(e).mult(-1),this.panTo(this.transform.center,u.e({offset:e},c),p)}panTo(e,c,p){return this.easeTo(u.e({center:e},c),p)}getZoom(){return this.transform.zoom}setZoom(e,c){return this.jumpTo({zoom:e},c),this}zoomTo(e,c,p){return this.easeTo(u.e({zoom:e},c),p)}zoomIn(e,c){return this.zoomTo(u.cx(this.getZoom()+1,this._zoomSnap),e,c),this}zoomOut(e,c){return this.zoomTo(u.cx(this.getZoom()-1,this._zoomSnap),e,c),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,c){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new u.l("movestart",c)).fire(new u.l("move",c)).fire(new u.l("moveend",c))),this}getBearing(){return this.transform.bearing}setZoomSnap(e){return this._zoomSnap=e,this}getZoomSnap(){return this._zoomSnap}setBearing(e,c){return this.jumpTo({bearing:e},c),this}getPadding(){return this.transform.padding}setPadding(e,c){return this.jumpTo({padding:e},c),this}rotateTo(e,c,p){return this.easeTo(u.e({bearing:e},c),p)}resetNorth(e,c){return this.rotateTo(0,u.e({duration:1e3},e),c),this}resetNorthPitch(e,c){return this.easeTo(u.e({bearing:0,pitch:0,roll:0,duration:1e3},e),c),this}snapToNorth(e,c){return Math.abs(this.getBearing()){F.easeFunc(u),this.terrain&&!e.freezeElevation&&this._updateElevation(u),this._applyUpdatedTransform(p),this._fireMoveEvents(c)}),(u=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(c,u)}),e),this}_prepareEase(e,c,p={}){this._moving=!0,c||p.moving||this.fire(new u.l("movestart",e)),this._zooming&&!p.zooming&&this.fire(new u.l("zoomstart",e)),this._rotating&&!p.rotating&&this.fire(new u.l("rotatestart",e)),this._pitching&&!p.pitching&&this.fire(new u.l("pitchstart",e)),this._rolling&&!p.rolling&&this.fire(new u.l("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){void 0!==this._elevationStart&&void 0!==this._elevationCenter||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const c=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&c!==this._elevationTarget){const u=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(u-(c-(u*e+this._elevationStart))/(1-e)),this._elevationTarget=c}this.transform.setElevation(u.G.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const c=e.getCameraLngLat(),u=e.getCameraAltitude(),p=this.terrain?this.terrain.getElevationForLngLatZoom(c,e.zoom):0;if(uthis._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&c.push((e=>this.transformCameraUpdate(e))),!c.length)return;const u=e.clone();for(const e of c){const c=u.clone(),{center:p,zoom:f,roll:m,pitch:g,bearing:y,elevation:x}=e(c);p&&c.setCenter(p),void 0!==x&&c.setElevation(x),void 0!==f&&c.setZoom(f),void 0!==m&&c.setRoll(m),void 0!==g&&c.setPitch(g),void 0!==y&&c.setBearing(y),u.apply(c,!1)}this.transform.apply(u,!1)}_fireMoveEvents(e){this.fire(new u.l("move",e)),this._zooming&&this.fire(new u.l("zoom",e)),this._rotating&&this.fire(new u.l("rotate",e)),this._pitching&&this.fire(new u.l("pitch",e)),this._rolling&&this.fire(new u.l("roll",e))}_afterEase(e,c){if(this._easeId&&c&&this._easeId===c)return;delete this._easeId;const p=this._zooming,f=this._rotating,m=this._pitching,g=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,p&&this.fire(new u.l("zoomend",e)),f&&this.fire(new u.l("rotateend",e)),m&&this.fire(new u.l("pitchend",e)),g&&this.fire(new u.l("rollend",e)),this.fire(new u.l("moveend",e))}flyTo(e,c){if(!e.essential&&x.prefersReducedMotion){const p=u.U(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(p,c)}this.stop(),e=u.e({offset:[0,0],speed:1.2,curve:1.42,easing:u.cz},e);const p=this._getTransformForUpdate(),f=p.bearing,m=p.pitch,g=p.roll,y=p.padding,b="bearing"in e?this._normalizeBearing(e.bearing,f):f,T="pitch"in e?+e.pitch:m,S="roll"in e?this._normalizeBearing(e.roll,g):g,P="padding"in e?e.padding:p.padding,I=u.P.convert(e.offset);let C=p.centerPoint.add(I);const R=p.screenPointToLocation(C),F=this.cameraHelper.handleFlyTo(p,{bearing:b,pitch:T,roll:S,padding:P,locationAtOffset:R,offsetAsPoint:I,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let L=e.curve;const B=Math.max(p.width,p.height),O=B/F.scaleOfZoom,V=F.pixelPathLength;"number"==typeof F.scaleOfMinZoom&&(L=Math.sqrt(B/F.scaleOfMinZoom/V*2));const j=L*L;function G(e){const c=(O*O-B*B+(e?-1:1)*j*j*V*V)/(2*(e?O:B)*j*V);return Math.log(Math.sqrt(c*c+1)-c)}function U(e){return(Math.exp(e)-Math.exp(-e))/2}function q(e){return(Math.exp(e)+Math.exp(-e))/2}const Z=G(!1);let W=function(e){return q(Z)/q(Z+L*e)},J=function(e){return B*((q(Z)*(U(c=Z+L*e)/q(c))-U(Z))/j)/V;var c},Q=(G(!0)-Z)/L;if(Math.abs(V)<2e-6||!isFinite(Q)){if(Math.abs(B-O)<1e-6)return this.easeTo(e,c);const u=O0,W=e=>Math.exp(u*L*e)}return e.duration="duration"in e?+e.duration:1e3*Q/("screenSpeed"in e?+e.screenSpeed/L:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=f!==b,this._pitching=T!==m,this._rolling=S!==g,this._padding=!p.isPaddingEqual(P),this._prepareEase(c,!1),this.terrain&&this._prepareElevation(F.targetCenter),this._ease((x=>{const R=x*Q,L=1/W(R),B=J(R);this._rotating&&p.setBearing(u.G.number(f,b,x)),this._pitching&&p.setPitch(u.G.number(m,T,x)),this._rolling&&p.setRoll(u.G.number(g,S,x)),this._padding&&(p.interpolatePadding(y,P,x),C=p.centerPoint.add(I)),F.easeFunc(x,L,B,C),this.terrain&&!e.freezeElevation&&this._updateElevation(x),this._applyUpdatedTransform(p),this._fireMoveEvents(c)}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(c)}),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,c){var u;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,c)}return e||null===(u=this.handlers)||void 0===u||u.stop(!1),this}_ease(e,c,u){!1===u.animate||0===u.duration?(e(1),c()):(this._easeStart=T(),this._easeOptions=u,this._onEaseFrame=e,this._onEaseEnd=c,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,c){e=u.W(e,-180,180);const p=Math.abs(e-c);return Math.abs(e-360-c)MapLibre'};class Qo{constructor(e=Wo){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=h.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=h.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=h.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){h.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,c){const u=this._map._getUIString(`AttributionControl.${c}`);e.title=u,e.setAttribute("aria-label",u)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((e=>"string"!=typeof e?"":e))):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const c=this._map.style.tileManagers;for(const u in c){const p=c[u];if(p.used||p.usedForTerrain){const c=p.getSource();c.attribution&&e.indexOf(c.attribution)<0&&e.push(c.attribution)}}e=e.filter((e=>String(e).trim())),e.sort(((e,c)=>e.length-c.length)),e=e.filter(((c,u)=>{for(let p=u+1;p=0)return!1;return!0}));const u=e.join(" | ");u!==this._attribHTML&&(this._attribHTML=u,e.length?(this._innerContainer.innerHTML=h.sanitize(u),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Jo{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const c=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&c.classList.add("maplibregl-compact"):c.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=h.create("div","maplibregl-ctrl");const c=h.create("a","maplibregl-ctrl-logo");return c.target="_blank",c.rel="noopener nofollow",c.href="https://maplibre.org/",c.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),c.setAttribute("rel","noopener nofollow"),this._container.appendChild(c),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){h.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class es{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const c=++this._id;return this._queue.push({callback:e,id:c,cancelled:!1}),c}remove(e){const c=this._currentlyRunning,u=c?this._queue.concat(c):this._queue;for(const c of u)if(c.id===e)return void(c.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const c=this._currentlyRunning=this._queue;this._queue=[];for(const u of c)if(!u.cancelled&&(u.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Ho=u.aU([{name:"a_pos3d",type:"Int16",components:3}]);class is extends u.E{constructor(e){super(),this._lastTilesetChange=T(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(e,c){this.tileManager.update(e,c),this._renderableTilesKeys=[];const p={};for(const f of at(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:c,calculateTileZoom:this.tileManager._source.calculateTileZoom}))p[f.key]=!0,this._renderableTilesKeys.push(f.key),this._tiles[f.key]||(f.terrainRttPosMatrix32f=new Float64Array(16),u.c7(f.terrainRttPosMatrix32f,0,u.a5,u.a5,0,0,1),this._tiles[f.key]=new _e(f,this.tileSize),this._lastTilesetChange=T());for(const e in this._tiles)p[e]||delete this._tiles[e]}freeRtt(e){for(const c in this._tiles){const u=this._tiles[c];(!e||u.tileID.equals(e)||u.tileID.isChildOf(e)||e.isChildOf(u.tileID))&&(u.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,c){return c?this._getTerrainCoordsForTileRanges(e,c):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const c={};for(const p of this._renderableTilesKeys){const f=this._tiles[p].tileID,m=e.clone(),g=u.bk();if(f.canonical.equals(e.canonical))u.c7(g,0,u.a5,u.a5,0,0,1);else if(f.canonical.isChildOf(e.canonical)){const c=f.canonical.z-e.canonical.z,p=f.canonical.x-(f.canonical.x>>c<>c<>c;u.c7(g,0,y,y,0,0,1),u.O(g,g,[-p*y,-m*y,0])}else{if(!e.canonical.isChildOf(f.canonical))continue;{const c=e.canonical.z-f.canonical.z,p=e.canonical.x-(e.canonical.x>>c<>c<>c;u.c7(g,0,u.a5,u.a5,0,0,1),u.O(g,g,[p*y,m*y,0]),u.Q(g,g,[1/2**c,1/2**c,0])}}m.terrainRttPosMatrix32f=new Float32Array(g),c[p]=m}return c}_getTerrainCoordsForTileRanges(e,c){const p={};for(const f of this._renderableTilesKeys){const m=this._tiles[f].tileID;if(!this._isWithinTileRanges(m,c))continue;const g=e.clone(),y=u.bk();if(m.canonical.z===e.canonical.z){const c=e.canonical.x-m.canonical.x+e.wrap*(1<e.canonical.z){const c=m.canonical.z-e.canonical.z,p=m.canonical.x-(m.canonical.x>>c<>c<>c),x=e.canonical.y-(m.canonical.y>>c),b=u.a5>>c;u.c7(y,0,b,b,0,0,1),u.O(y,y,[-p*b+g*u.a5,-f*b+x*u.a5,0])}else{const c=e.canonical.z-m.canonical.z,p=e.canonical.x-(e.canonical.x>>c<>c<>c)-m.canonical.x,x=(e.canonical.y>>c)-m.canonical.y,b=u.a5<u.maxzoom&&(p=u.maxzoom),p=u.minzoom&&!(null==f?void 0:f.dem);)f=this.findTileInCaches(e.scaledTo(p--).key);return f}findTileInCaches(e){let c=this.tileManager.getTileByID(e);return c||(c=this.tileManager._outOfViewCache.getByKey(e),c)}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,c){const u=c[e.canonical.z];return!!u&&(e.wrap>u.minWrap||e.wrap=u.minTileXWrapped&&e.canonical.x<=u.maxTileXWrapped&&e.canonical.y>=u.minTileY&&e.canonical.y<=u.maxTileY)}}class as{constructor(e,c,u){this._meshCache={},this.painter=e,this.tileManager=new is(c),this.options=u,this.exaggeration="number"==typeof u.exaggeration?u.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,c,p,f=u.a5){var m;const g=e.normalizeCoordinates(c,p,f);if(!g)return 0;const y=this.getTerrainData(g.tileID),x=null===(m=y.tile)||void 0===m?void 0:m.dem;if(!x)return 0;const b=u.cD([],[g.x/f*u.a5,g.y/f*u.a5],y.u_terrain_matrix),T=[b[0]*x.dim,b[1]*x.dim],S=Math.floor(T[0]),P=Math.floor(T[1]),I=T[0]-S,C=T[1]-P;return x.get(S,P)*(1-I)*(1-C)+x.get(S+1,P)*I*(1-C)+x.get(S,P+1)*(1-I)*C+x.get(S+1,P+1)*I*C}getElevationForLngLatZoom(e,c){if(!u.cE(c,e.wrap()))return 0;const{tileID:p,mercatorX:f,mercatorY:m}=this._getOverscaledTileIDFromLngLatZoom(e,c);return this.getElevation(p,f%u.a5,m%u.a5,u.a5)}getElevationForLngLat(e,c){const u=at(c,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this});let p=0;for(const e of u)e.canonical.z>p&&(p=Math.min(e.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,p)}getElevation(e,c,p,f=u.a5){return this.getDEMElevation(e,c,p,f)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){const e=this.painter.context,c=new u.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new u.T(e,c,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new u.T(e,new u.R({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=u.ar([])}const c=this.tileManager.getSourceTile(e,!0);if(c&&c.dem&&(!c.demTexture||c.needsTerrainPrepare)){const e=this.painter.context;c.demTexture=this.painter.getTileTexture(c.dem.stride),c.demTexture?c.demTexture.update(c.dem.getPixels(),{premultiply:!1}):c.demTexture=new u.T(e,c.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),c.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),c.needsTerrainPrepare=!1}const p=c&&c.toString()+c.tileID.key+e.key;if(p&&!this._demMatrixCache[p]){const p=this.tileManager.getSource().maxzoom;let f=e.canonical.z-c.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=p?f=e.canonical.z-p:u.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const m=e.canonical.x-(e.canonical.x>>f<>f<>8<<4|e>>8,c[u+3]=0;const p=new u.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(c.buffer)),f=new u.T(e,p,e.gl.RGBA,{premultiply:!1});return f.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=f,f}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const c=new Uint8Array(4),p=this.painter.context,f=p.gl,m=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),g=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),y=Math.round(this.painter.height/devicePixelRatio);p.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),f.readPixels(m,y-g-1,1,1,f.RGBA,f.UNSIGNED_BYTE,c),p.bindFramebuffer.set(null);const x=c[0]+(c[2]>>4<<8),b=c[1]+((15&c[2])<<8),T=this.coordsIndex[255-c[3]],S=T&&this.tileManager.getTileByID(T);if(!S)return null;const P=this._coordsTextureSize,I=(1<0,f=p&&0===e.canonical.y,m=p&&e.canonical.y===(1<e.id!==c)),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length!e.inUse))}}const Yo={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class ss{constructor(e,c){this.painter=e,this.terrain=c,this.pool=new rs(e.context,30,c.tileManager.tileSize*c.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,c){var u,p;this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter((u=>!e._layers[u].isHidden(c))),this._coordsAscending={};for(const c in e.tileManagers){this._coordsAscending[c]={};const u=e.tileManagers[c].getVisibleCoordinates(),p=e.tileManagers[c].getSource(),f=p instanceof ie?p.terrainTileRanges:null;for(const e of u){const u=this.terrain.tileManager.getTerrainCoords(e,f);for(const e in u)this._coordsAscending[c][e]||(this._coordsAscending[c][e]=[]),this._coordsAscending[c][e].push(u[e])}}this._rttFingerprints={};for(const c of e._order){const f=e._layers[c],m=f.source;if(Yo[f.type]&&!this._rttFingerprints[m]){this._rttFingerprints[m]={};const c=null!==(p=null===(u=e.tileManagers[m])||void 0===u?void 0:u.getState().revision)&&void 0!==p?p:0;for(const e in this._coordsAscending[m])this._rttFingerprints[m][e]=`${this._coordsAscending[m][e].map((e=>e.key)).sort().join()}#${c}`}}for(const e of this._renderableTiles)for(const c in this._rttFingerprints){const u=this._rttFingerprints[c][e.tileID.key];u&&u!==e.rttFingerprint[c]&&(e.rtt=[])}}renderLayer(e,c){if(e.isHidden(this.painter.transform.zoom))return!1;const p=Object.assign(Object.assign({},c),{isRenderingToTexture:!0}),f=e.type,m=this.painter,g=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Yo[f]&&(this._prevType&&Yo[this._prevType]||this._stacks.push([]),this._prevType=f,this._stacks[this._stacks.length-1].push(e.id),!g))return!0;if(Yo[this._prevType]||Yo[f]&&g){this._prevType=f;const e=this._stacks.length-1,c=this._stacks[e]||[];for(const f of this._renderableTiles){if(this.pool.isFull()&&(gs(this.painter,this.terrain,this._rttTiles,p),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(f),f.rtt[e]){const c=this.pool.getObjectForId(f.rtt[e].id);if(c.stamp===f.rtt[e].stamp){this.pool.useObject(c);continue}}const g=this.pool.getOrCreateFreeObject();this.pool.useObject(g),this.pool.stampObject(g),f.rtt[e]={id:g.id,stamp:g.stamp},m.context.bindFramebuffer.set(g.fbo.framebuffer),m.context.clear({color:u.bp.transparent,stencil:0}),m.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,h.mousePos(this.element,e)),h.addEventListener(window,"mousemove",this.mousemove),h.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,h.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=h.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),h.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.addEventListener(window,"touchend",this.touchend))},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=h.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos))},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=c;const f=new wo;this._rotatePitchHandler=new fo({clickTolerance:3,move:(e,f)=>{const m=c.getBoundingClientRect(),g=new u.P((m.bottom-m.top)/2,(m.right-m.left)/2);return{bearingDelta:u.cy(new u.P(e.x,f.y),f,g),pitchDelta:p?-.5*(f.y-e.y):void 0}},moveStateManager:f,enable:!0,assignEvents:()=>{}}),this.map=e,h.addEventListener(c,"mousedown",this.mousedown),h.addEventListener(c,"touchstart",this.touchstart,{passive:!1}),h.addEventListener(c,"touchcancel",this.reset)}startMove(e,c){this._rotatePitchHandler.dragStart(e,c),h.disableDrag()}move(e,c){const u=this.map,{bearingDelta:p,pitchDelta:f}=this._rotatePitchHandler.dragMove(e,c)||{};p&&u.setBearing(u.getBearing()+p),f&&u.setPitch(u.getPitch()+f)}off(){const e=this.element;h.removeEventListener(e,"mousedown",this.mousedown),h.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),h.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.removeEventListener(window,"touchend",this.touchend),h.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){h.enableDrag(),h.removeEventListener(window,"mousemove",this.mousemove),h.removeEventListener(window,"mouseup",this.mouseup),h.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.removeEventListener(window,"touchend",this.touchend)}}let tl;function il(e,c,p,f=!1){if(f||!p.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const m=new u.V(e.lng,e.lat);if(e=new u.V(e.lng,e.lat),c){const f=new u.V(e.lng-360,e.lat),m=new u.V(e.lng+360,e.lat),g=p.locationToScreenPoint(e).distSqr(c);p.locationToScreenPoint(f).distSqr(c)180;){const c=p.locationToScreenPoint(e);if(c.x>=0&&c.y>=0&&c.x<=p.width&&c.y<=p.height)break;e.lng>p.center.lng?e.lng-=360:e.lng+=360}return e.lng!==m.lng&&p.isPointOnMapSurface(p.locationToScreenPoint(e))?e:m}const rl={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 nl(e,c,u){const p=e.classList;for(const e in rl)p.remove(`maplibregl-${u}-anchor-${e}`);p.add(`maplibregl-${u}-anchor-${c}`)}class fs extends u.E{constructor(e){if(super(),this._onClick=e=>{this.fire(new u.l("click",{originalEvent:e}))},this._onKeyPress=e=>{const c=e.code,u=e.charCode||e.keyCode;"Space"!==c&&"Enter"!==c&&32!==u&&13!==u||this.togglePopup()},this._onMapClick=e=>{const c=e.originalEvent.target,u=this._element;this._popup&&(c===u||u.contains(c))&&this.togglePopup()},this._update=e=>{if(!this._map)return;const c=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!c)&&this._map.once("render",this._update),this._lngLat=il(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let u="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?u=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(u=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let p="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?p="rotateX(0deg)":"map"===this._pitchAlignment&&(p=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),h.setTransform(this._element,`${rl[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${p} ${u}`),x.frameAsync(new AbortController,this._map._ownerWindow).then((()=>{this._updateOpacity(e&&"moveend"===e.type)})).catch((()=>{}))},this._onMove=e=>{if(!this._isDragging){const c=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=c}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new u.l("dragstart"))),this.fire(new u.l("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new u.l("dragend")),this._state="inactive"},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=u.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=h.create("div");const c=h.createNS("http://www.w3.org/2000/svg","svg"),p=41,f=27;c.setAttributeNS(null,"display","block"),c.setAttributeNS(null,"height",`${p}px`),c.setAttributeNS(null,"width",`${f}px`),c.setAttributeNS(null,"viewBox",`0 0 ${f} ${p}`);const m=h.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"stroke","none"),m.setAttributeNS(null,"stroke-width","1"),m.setAttributeNS(null,"fill","none"),m.setAttributeNS(null,"fill-rule","evenodd");const g=h.createNS("http://www.w3.org/2000/svg","g");g.setAttributeNS(null,"fill-rule","nonzero");const y=h.createNS("http://www.w3.org/2000/svg","g");y.setAttributeNS(null,"transform","translate(3.0, 29.0)"),y.setAttributeNS(null,"fill","#000000");const x=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of x){const c=h.createNS("http://www.w3.org/2000/svg","ellipse");c.setAttributeNS(null,"opacity","0.04"),c.setAttributeNS(null,"cx","10.5"),c.setAttributeNS(null,"cy","5.80029008"),c.setAttributeNS(null,"rx",e.rx),c.setAttributeNS(null,"ry",e.ry),y.appendChild(c)}const b=h.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill",this._color);const T=h.createNS("http://www.w3.org/2000/svg","path");T.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),b.appendChild(T);const S=h.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"opacity","0.25"),S.setAttributeNS(null,"fill","#000000");const P=h.createNS("http://www.w3.org/2000/svg","path");P.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),S.appendChild(P);const I=h.createNS("http://www.w3.org/2000/svg","g");I.setAttributeNS(null,"transform","translate(6.0, 7.0)"),I.setAttributeNS(null,"fill","#FFFFFF");const C=h.createNS("http://www.w3.org/2000/svg","g");C.setAttributeNS(null,"transform","translate(8.0, 8.0)");const R=h.createNS("http://www.w3.org/2000/svg","circle");R.setAttributeNS(null,"fill","#000000"),R.setAttributeNS(null,"opacity","0.25"),R.setAttributeNS(null,"cx","5.5"),R.setAttributeNS(null,"cy","5.5"),R.setAttributeNS(null,"r","5.4999962");const F=h.createNS("http://www.w3.org/2000/svg","circle");F.setAttributeNS(null,"fill","#FFFFFF"),F.setAttributeNS(null,"cx","5.5"),F.setAttributeNS(null,"cy","5.5"),F.setAttributeNS(null,"r","5.4999962"),C.appendChild(R),C.appendChild(F),g.appendChild(y),g.appendChild(b),g.appendChild(S),g.appendChild(I),g.appendChild(C),c.appendChild(g),c.setAttributeNS(null,"height",p*this._scale+"px"),c.setAttributeNS(null,"width",f*this._scale+"px"),this._element.appendChild(c),this._offset=u.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault()})),this._element.addEventListener("mousedown",(e=>{e.preventDefault()})),nl(this._element,this._anchor,"marker"),this._element.addEventListener("click",this._onClick),e&&e.className)for(const c of e.className.split(" "))this._element.classList.add(c);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),h.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=u.V.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const c=38.1,u=13.5,p=Math.abs(u)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-c],"bottom-left":[p,-1*(c-u+p)],"bottom-right":[-p,-1*(c-u+p)],left:[u,-1*(c-u)],right:[-u,-1*(c-u)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var c,p;const f=null===(c=this._map)||void 0===c?void 0:c.terrain,m=this._map.transform.isLocationOccluded(this._lngLat);if(!f||m){const e=m?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}const g=this._map,y=g.terrain.depthAtPoint(this._pos),x=g.terrain.getElevationForLngLat(this._lngLat,g.transform);if(g.transform.lngLatToCameraDepth(this._lngLat,x)-y<.006)return void(this._element.style.opacity=this._opacity);const b=-this._offset.y/g.transform.pixelsPerMeter,T=Math.sin(g.getPitch()*Math.PI/180)*b,S=g.terrain.depthAtPoint(new u.P(this._pos.x,this._pos.y-this._offset.y)),P=g.transform.lngLatToCameraDepth(this._lngLat,x+T)-S>.006;(null===(p=this._popup)||void 0===p?void 0:p.isOpen())&&P&&this._popup.remove(),this._element.style.opacity=P?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=u.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,c){return(void 0===this._opacity||void 0===e&&void 0===c)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==c&&(this._opacityWhenCovered=c),this._map&&this._updateOpacity(!0),this}}const sl={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let ol=0,al=!1;const ll={maxWidth:100,unit:"metric"};function cl(e,c,u){const p=u&&u.maxWidth||100,f=e._container.clientHeight/2,m=e._container.clientWidth/2,g=e.unproject([m-p/2,f]),y=e.unproject([m+p/2,f]),x=Math.round(e.project(y).x-e.project(g).x),b=Math.min(p,x,e._container.clientWidth),T=g.distanceTo(y);if(u&&"imperial"===u.unit){const u=3.2808*T;u>5280?hl(c,b,u/5280,e._getUIString("ScaleControl.Miles")):hl(c,b,u,e._getUIString("ScaleControl.Feet"))}else u&&"nautical"===u.unit?hl(c,b,T/1852,e._getUIString("ScaleControl.NauticalMiles")):T>=1e3?hl(c,b,T/1e3,e._getUIString("ScaleControl.Kilometers")):hl(c,b,T,e._getUIString("ScaleControl.Meters"))}function hl(e,c,u,p){const f=function(e){const c=Math.pow(10,`${Math.floor(e)}`.length-1);let u=e/c;return u=u>=10?10:u>=5?5:u>=3?3:u>=2?2:u>=1?1:function(e){const c=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*c)/c}(u),c*u}(u);e.style.width=c*(f/u)+"px",e.innerHTML=`${f} ${p}`}const ul={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},dl=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function pl(e){if(e){if("number"==typeof e){const c=Math.round(Math.abs(e)/Math.SQRT2);return{center:new u.P(0,0),top:new u.P(0,e),"top-left":new u.P(c,c),"top-right":new u.P(-c,c),bottom:new u.P(0,-e),"bottom-left":new u.P(c,-c),"bottom-right":new u.P(-c,-c),left:new u.P(e,0),right:new u.P(-e,0)}}if(e instanceof u.P||Array.isArray(e)){const c=u.P.convert(e);return{center:c,top:c,"top-left":c,"top-right":c,bottom:c,"bottom-left":c,"bottom-right":c,left:c,right:c}}return{center:u.P.convert(e.center||[0,0]),top:u.P.convert(e.top||[0,0]),"top-left":u.P.convert(e["top-left"]||[0,0]),"top-right":u.P.convert(e["top-right"]||[0,0]),bottom:u.P.convert(e.bottom||[0,0]),"bottom-left":u.P.convert(e["bottom-left"]||[0,0]),"bottom-right":u.P.convert(e["bottom-right"]||[0,0]),left:u.P.convert(e.left||[0,0]),right:u.P.convert(e.right||[0,0])}}return pl(new u.P(0,0))}const fl=p;c.AJAXError=u.cJ,c.EXTENT=u.a5,c.Event=u.l,c.Evented=u.E,c.LngLat=u.V,c.MercatorCoordinate=u.a9,c.Point=u.P,c.addProtocol=u.cK,c.config=u.c,c.removeProtocol=u.cL,c.AttributionControl=Qo,c.BoxZoomHandler=ho,c.CanvasSource=re,c.CooperativeGesturesHandler=qo,c.DoubleClickZoomHandler=jo,c.DragPanHandler=Go,c.DragRotateHandler=Uo,c.EdgeInsets=Zt,c.FullscreenControl=class extends u.E{constructor(e={}){var c;super(),this._onFullscreenChange=()=>{var e;let c=window.document.fullscreenElement||window.document.webkitFullscreenElement;for(;null===(e=null==c?void 0:c.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)c=c.shadowRoot.fullscreenElement;c===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,this._pseudo=null!==(c=e.pseudo)&&void 0!==c&&c,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:u.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){h.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const e=this._fullscreenButton=h.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);h.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new u.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new u.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){this._pseudo?this._togglePseudoFullScreen():window.document.exitFullscreen?window.document.exitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._pseudo?this._togglePseudoFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},c.GeoJSONSource=te,c.GeolocateControl=class extends u.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new u.l("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new u.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const c=new u.V(e.coords.longitude,e.coords.latitude),p=e.coords.accuracy,f=this._map.getBearing(),m=u.e({bearing:f},this.options.fitBoundsOptions),g=$.fromLngLat(c,p);this._map.fitBounds(g,m,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const c=new u.V(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(c).addTo(this._map),this._userLocationDotMarker.setLngLat(c).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&al)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new u.l("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=h.create("button","maplibregl-ctrl-geolocate",this._container),h.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){u.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=h.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new fs({element:this._dotElement}),this._circleElement=h.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new fs({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{const c=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||c||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new u.l("trackuserlocationend")),this.fire(new u.l("userlocationlostfocus")))}))}},this.options=u.e({},sl,e)}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return u._(this,arguments,void 0,(function*(e=!1){if(void 0!==tl&&!e)return tl;if(void 0===window.navigator.permissions)return tl=!!window.navigator.geolocation,tl;try{const e=yield window.navigator.permissions.query({name:"geolocation"});tl="denied"!==e.state}catch(e){tl=!!window.navigator.geolocation}return tl}))}().then((e=>this._finishSetupUI(e))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),h.remove(this._container),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,ol=0,al=!1}_isOutOfMapMaxBounds(e){const c=this._map.getMaxBounds(),u=e.coords;return c&&(u.longitudec.getEast()||u.latitudec.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const e=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&e))return;const c=this._map.project(e),u=this._map.unproject([c.x+100,c.y]),p=e.distanceTo(u)/100,f=2*this._accuracy/p;this._circleElement.style.width=`${f.toFixed(2)}px`,this._circleElement.style.height=`${f.toFixed(2)}px`}trigger(){if(!this._setup)return u.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 u.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":ol--,al=!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 u.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new u.l("trackuserlocationstart")),this.fire(new u.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),ol++,ol>1?(e={maximumAge:6e5,timeout:0},al=!0):(e=this.options.positionOptions,al=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},c.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const c=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==c&&c?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=h.create("button","maplibregl-ctrl-globe",this._container),h.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._map.on("projectiontransition",this._updateGlobeIcon),this._container}onRemove(){h.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._map.off("projectiontransition",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},c.Hash=Hr,c.ImageSource=ie,c.KeyboardHandler=Lo,c.LngLatBounds=$,c.LogoControl=Jo,c.Map=class extends Ko{get _ownerWindow(){var e,c;return(null===(c=null===(e=this._container)||void 0===e?void 0:e.ownerDocument)||void 0===c?void 0:c.defaultView)||window}constructor(e){var c,p;u.cH.mark(u.cI.create);const f=Object.assign(Object.assign(Object.assign({},na),e),{canvasContextAttributes:Object.assign(Object.assign({},na.canvasContextAttributes),e.canvasContextAttributes)});if(null!=f.minZoom&&null!=f.maxZoom&&f.minZoom>f.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=f.minPitch&&null!=f.maxPitch&&f.minPitch>f.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=f.minPitch&&f.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=f.maxPitch&&f.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const m=new Ht,g=new Qt;void 0!==f.minZoom&&m.setMinZoom(f.minZoom),void 0!==f.maxZoom&&m.setMaxZoom(f.maxZoom),void 0!==f.minPitch&&m.setMinPitch(f.minPitch),void 0!==f.maxPitch&&m.setMaxPitch(f.maxPitch),void 0!==f.renderWorldCopies&&m.setRenderWorldCopies(f.renderWorldCopies),null!==f.transformConstrain&&m.setConstrainOverride(f.transformConstrain),super(m,g,{bearingSnap:f.bearingSnap,zoomSnap:f.zoomSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new es,this._controls=[],this._mapId=u.af(),this._lostContextStyle={style:null,images:null},this._contextLost=e=>{if(e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),this.style){for(const e of Object.values(this.style._layers))if("custom"===e.type&&console.warn(`Custom layer with id '${e.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),e._listeners)for(const[c]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${c}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.destroy(),this.style=null,this.fire(new u.l("webglcontextlost",{originalEvent:e}))}else this.fire(new u.l("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.resize(),this._update(),this._resizeInternal(),this.fire(new u.l("webglcontextrestored",{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=f.interactive,this._maxTileCacheSize=f.maxTileCacheSize,this._maxTileCacheZoomLevels=f.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},f.canvasContextAttributes),this._trackResize=!0===f.trackResize,this._bearingSnap=f.bearingSnap,this._zoomSnap=f.zoomSnap,this._centerClampedToGround=f.centerClampedToGround,this._refreshExpiredTiles=!0===f.refreshExpiredTiles,this._fadeDuration=f.fadeDuration,this._crossSourceCollisions=!0===f.crossSourceCollisions,this._collectResourceTiming=!0===f.collectResourceTiming,this._locale=Object.assign(Object.assign({},ta),f.locale),this._clickTolerance=f.clickTolerance,this._overridePixelRatio=f.pixelRatio,this._maxCanvasSize=f.maxCanvasSize,this._zoomLevelsToOverscale=f.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=f.transformCameraUpdate,this.transformConstrain=f.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===f.cancelPendingTileRequestsWhileZooming,this.setAnisotropicFilterPitch(f.anisotropicFilterPitch),void 0!==f.reduceMotion&&(x.prefersReducedMotion=f.reduceMotion),this._imageQueueHandle=L.addThrottleControl((()=>this.isMoving())),this._requestManager=new v(f.transformRequest),this._container=this._resolveContainer(f.container),f.maxBounds&&this.setMaxBounds(f.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})),this.once("idle",(()=>{this._idleTriggered=!0})),"undefined"!=typeof window&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver()),this.handlers=new Xo(this,f),this._hash=f.hash&&new Hr("string"==typeof f.hash&&f.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:f.center,elevation:f.elevation,zoom:f.zoom,bearing:f.bearing,pitch:f.pitch,roll:f.roll}),f.bounds&&(this.resize(),this.fitBounds(f.bounds,u.e({},f.fitBoundsOptions,{duration:0}))));const y="string"==typeof f.style||!("globe"===(null===(p=null===(c=f.style)||void 0===c?void 0:c.projection)||void 0===p?void 0:p.type));this.resize(null,y),this._localIdeographFontFamily=f.localIdeographFontFamily,this._validateStyle=f.validateStyle,f.style&&this.setStyle(f.style,{localIdeographFontFamily:f.localIdeographFontFamily}),f.attributionControl&&this.addControl(new Qo("boolean"==typeof f.attributionControl?void 0:f.attributionControl)),f.maplibreLogo&&this.addControl(new Jo,f.logoPosition),this.on("style.load",(()=>{if(y||this._resizeTransform(),this.transform.unmodified){const e=u.U(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new u.l(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new u.l(`${e.dataType}dataloading`,e))})),this.on("dataabort",(e=>{this.fire(new u.l("sourcedataabort",e))}))}_getMapId(){return this._mapId}setGlobalStateProperty(e,c){return this.style.setGlobalStateProperty(e,c),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,c){if(void 0===c&&(c=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new u.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const p=e.onAdd(this);this._controls.push(e);const f=this._controlPositions[c];return-1!==c.indexOf("bottom")?f.insertBefore(p,f.firstChild):f.appendChild(p),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new u.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const c=this._controls.indexOf(e);return c>-1&&this._controls.splice(c,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}coveringTiles(e){return at(this.transform,e)}calculateCameraOptionsFromTo(e,c,u,p){return null==p&&this.terrain&&(p=this.terrain.getElevationForLngLat(u,this.transform)),super.calculateCameraOptionsFromTo(e,c,u,p)}resize(e,c=!0){if(null!==this._lostContextStyle.style)return this;this._resizeInternal(c);const p=!this._moving;return p&&(this.stop(),this.fire(new u.l("movestart",e)).fire(new u.l("move",e))),this.fire(new u.l("resize",e)),p&&this.fire(new u.l("moveend",e)),this}_resizeInternal(e=!0){const[c,u]=this._containerDimensions(),p=this._getClampedPixelRatio(c,u);if(this._resizeCanvas(c,u,p),this.painter.resize(c,u,p),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const p=this._getClampedPixelRatio(c,u);this._resizeCanvas(c,u,p),this.painter.resize(c,u,p)}this._resizeTransform(e)}_resizeTransform(e=!0){var c;const[u,p]=this._containerDimensions();this.transform.resize(u,p,e),null===(c=this._requestedCameraState)||void 0===c||c.resize(u,p,e)}_getClampedPixelRatio(e,c){const{0:u,1:p}=this._maxCanvasSize,f=this.getPixelRatio(),m=e*f,g=c*f;return Math.min(m>u?u/m:1,g>p?p/g:1)*f}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds($.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom){const c=this.transform.zoom,p=this._getTransformForUpdate();return p.setMinZoom(e),this._applyUpdatedTransform(p),this._update(),c!==this.transform.zoom&&this.fire(new u.l("zoomstart")).fire(new u.l("zoom")).fire(new u.l("zoomend")).fire(new u.l("movestart")).fire(new u.l("move")).fire(new u.l("moveend")),this}throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e=null==e?22:e)>=this.transform.minZoom){const c=this.transform.zoom,p=this._getTransformForUpdate();return p.setMaxZoom(e),this._applyUpdatedTransform(p),this._update(),c!==this.transform.zoom&&this.fire(new u.l("zoomstart")).fire(new u.l("zoom")).fire(new u.l("zoomend")).fire(new u.l("movestart")).fire(new u.l("move")).fire(new u.l("moveend")),this}throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch){const c=this.transform.pitch,p=this._getTransformForUpdate();return p.setMinPitch(e),this._applyUpdatedTransform(p),this._update(),c!==this.transform.pitch&&this.fire(new u.l("pitchstart")).fire(new u.l("pitch")).fire(new u.l("pitchend")).fire(new u.l("movestart")).fire(new u.l("move")).fire(new u.l("moveend")),this}throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e=null==e?60:e)>180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch){const c=this.transform.pitch,p=this._getTransformForUpdate();return p.setMaxPitch(e),this._applyUpdatedTransform(p),this._update(),c!==this.transform.pitch&&this.fire(new u.l("pitchstart")).fire(new u.l("pitch")).fire(new u.l("pitchend")).fire(new u.l("movestart")).fire(new u.l("move")).fire(new u.l("moveend")),this}throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(e){if((e=null==e?20:e)>180)throw new Error("anisotropicFilterPitch must be less than or equal to 180");if(e<0)throw new Error("anisotropicFilterPitch must be greater than or equal to 0");return this._anisotropicFilterPitch=e,this._update()}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this.transform.setConstrainOverride(e),this._update()}project(e){return this.transform.locationToScreenPoint(u.V.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(u.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,c,u){if("mouseenter"===e||"mouseover"===e){let p=!1;const f=f=>{const m=c.filter((e=>this.getLayer(e))),g=0!==m.length?this.queryRenderedFeatures(f.point,{layers:m}):[];g.length?p||(p=!0,u.call(this,new ro(e,this,f.originalEvent,{features:g}))):p=!1};return{layers:c,listener:u,delegates:{mousemove:f,mouseout:()=>{p=!1}}}}if("mouseleave"===e||"mouseout"===e){let p=!1;const f=f=>{const m=c.filter((e=>this.getLayer(e)));(0!==m.length?this.queryRenderedFeatures(f.point,{layers:m}):[]).length?p=!0:p&&(p=!1,u.call(this,new ro(e,this,f.originalEvent)))},m=c=>{p&&(p=!1,u.call(this,new ro(e,this,c.originalEvent)))};return{layers:c,listener:u,delegates:{mousemove:f,mouseout:m}}}{const p=e=>{const p=c.filter((e=>this.getLayer(e))),f=0!==p.length?this.queryRenderedFeatures(e.point,{layers:p}):[];f.length&&(e.features=f,u.call(this,e),delete e.features)};return{layers:c,listener:u,delegates:{[e]:p}}}}_saveDelegatedListener(e,c){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(c)}_removeDelegatedListener(e,c,u){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const p=this._delegatedListeners[e];for(let e=0;ec.includes(e)))){for(const e in f.delegates)this.off(e,f.delegates[e]);return void p.splice(e,1)}}}on(e,c,u){if(void 0===u)return super.on(e,c);const p="string"==typeof c?[c]:c,f=this._createDelegatedListener(e,p,u);this._saveDelegatedListener(e,f);for(const e in f.delegates)this.on(e,f.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,p,u)}}}once(e,c,u){if(void 0===u)return super.once(e,c);const p="string"==typeof c?[c]:c,f=this._createDelegatedListener(e,p,u);for(const c in f.delegates){const m=f.delegates[c];f.delegates[c]=(...c)=>{this._removeDelegatedListener(e,p,u),m(...c)}}this._saveDelegatedListener(e,f);for(const e in f.delegates)this.once(e,f.delegates[e]);return this}off(e,c,u){return void 0===u?super.off(e,c):(this._removeDelegatedListener(e,"string"==typeof c?[c]:c,u),this)}queryRenderedFeatures(e,c){if(!this.style)return[];let p;const f=e instanceof u.P||Array.isArray(e),m=f?e:[[0,0],[this.transform.width,this.transform.height]];if(c=c||(f?{}:e)||{},m instanceof u.P||"number"==typeof m[0])p=[u.P.convert(m)];else{const e=u.P.convert(m[0]),c=u.P.convert(m[1]);p=[e,new u.P(c.x,e.y),c,new u.P(e.x,c.y),e]}return this.style.queryRenderedFeatures(p,c,this.transform)}querySourceFeatures(e,c){return this.style.querySourceFeatures(e,c)}setStyle(e,c){return!1!==(c=u.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},c)).diff&&c.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,c),this):(this._localIdeographFontFamily=c.localIdeographFontFamily,this._updateStyle(e,c))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const c=this._locale[e];if(null==c)throw new Error(`Missing UI string '${e}'`);return c}_updateStyle(e,c){var u,p;if(c.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(e,c)));const f=this.style&&c.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new Fi(this,c||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,c,f):this.style.loadJSON(e,c,f),this):(null===(p=null===(u=this.style)||void 0===u?void 0:u.projection)||void 0===p||p.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Fi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,c){if("string"==typeof e){const p=this._requestManager.transformRequest(e,"Style");u.j(p,new AbortController).then((e=>{this._updateDiff(e.data,c)})).catch((e=>{e&&this.fire(new u.k(e))}))}else"object"==typeof e&&this._updateDiff(e,c)}_updateDiff(e,c){try{this.style.setState(e,c)&&this._update(!0)}catch(p){u.w(`Unable to perform style diff: ${p.message||p.error||p}. Rebuilding the style from scratch.`),this._updateStyle(e,c)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){return this.style?this.style.loaded():u.w("There is no style added to the map.")}addSource(e,c){return this._lazyInitEmptyStyle(),this.style.addSource(e,c),this._update(!0)}isSourceLoaded(e){const c=this.style&&this.style.tileManagers[e];if(void 0!==c)return c.loaded();this.fire(new u.k(new Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const c=this.style.tileManagers[e.source];if(!c)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&c.reload();for(const c in this.style._layers){const p=this.style._layers[c];"hillshade"===p.type&&p.source===e.source&&u.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===p.type&&p.source===e.source&&u.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new as(this.painter,c,e),this.painter.renderToTexture=new ss(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=c=>{var u;"style"===c.dataType?this.terrain.tileManager.freeRtt():"source"===c.dataType&&c.tile&&(c.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(u=c.source)||void 0===u?void 0:u.type)?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(c.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.tileManager.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new u.l("terrain",{terrain:e})),this}getTerrain(){var e,c;return null!==(c=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==c?c:null}areTilesLoaded(){const e=this.style&&this.style.tileManagers;for(const c of Object.values(e))if(!c.areTilesLoaded())return!1;return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,c,u){if(u){const p=this.getSource(u);if(!p)throw new Error(`There is no source with ID "${u}", cannot set LOD parameters`);p.calculateTileZoom=rt(Math.max(1,e),Math.max(1,c))}else for(const u in this.style.tileManagers)this.style.tileManagers[u].getSource().calculateTileZoom=rt(Math.max(1,e),Math.max(1,c));return this._update(!0),this}refreshTiles(e,c){const p=this.style.tileManagers[e];if(!p)throw new Error(`There is no tile manager with ID "${e}", cannot refresh tile`);void 0===c?p.reload(!0):p.refreshTiles(c.map((e=>new u.ac(e.z,e.x,e.y))))}addImage(e,c,p={}){const{pixelRatio:f=1,sdf:m=!1,stretchX:g,stretchY:y,content:b,textFitWidth:T,textFitHeight:S}=p;if(this._lazyInitEmptyStyle(),!(c instanceof HTMLImageElement||u.b(c))){if(void 0===c.width||void 0===c.height)return this.fire(new u.k(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:p,height:x,data:P}=c,I=c;return this.style.addImage(e,{data:new u.R({width:p,height:x},new Uint8Array(P)),pixelRatio:f,stretchX:g,stretchY:y,content:b,textFitWidth:T,textFitHeight:S,sdf:m,version:0,userImage:I}),I.onAdd&&I.onAdd(this,e),this}}{const{width:p,height:P,data:I}=x.getImageData(c);this.style.addImage(e,{data:new u.R({width:p,height:P},I),pixelRatio:f,stretchX:g,stretchY:y,content:b,textFitWidth:T,textFitHeight:S,sdf:m,version:0})}}updateImage(e,c){const p=this.style.getImage(e);if(!p)return this.fire(new u.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const f=c instanceof HTMLImageElement||u.b(c)?x.getImageData(c):c,{width:m,height:g,data:y}=f;if(void 0===m||void 0===g)return this.fire(new u.k(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(m!==p.data.width||g!==p.data.height)return this.fire(new u.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const b=!(c instanceof HTMLImageElement||u.b(c));return p.data.replace(y,b),this.style.updateImage(e,p),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new u.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return L.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,c){return this._lazyInitEmptyStyle(),this.style.addLayer(e,c),this._update(!0)}moveLayer(e,c){return this.style.moveLayer(e,c),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,c,u){return this.style.setLayerZoomRange(e,c,u),this._update(!0)}setFilter(e,c,u={}){return this.style.setFilter(e,c,u),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,c,u,p={}){return this.style.setPaintProperty(e,c,u,p),this._update(!0)}getPaintProperty(e,c){return this.style.getPaintProperty(e,c)}setLayoutProperty(e,c,u,p={}){return this.style.setLayoutProperty(e,c,u,p),this._update(!0)}getLayoutProperty(e,c){return this.style.getLayoutProperty(e,c)}setGlyphs(e,c={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,c),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,c,u={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,c,u,(e=>{e||this._update(!0)})),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,c={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,c,(e=>{e||this._update(!0)})),this}setLight(e,c={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,c),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,c={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,c),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,c){return this.style.setFeatureState(e,c),this._update()}removeFeatureState(e,c){return this.style.removeFeatureState(e,c),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,c=0;return this._container&&(e=this._container.clientWidth||400,c=this._container.clientHeight||300),[e,c]}_setupResizeObserver(){var e;let c=!1;const u=vs((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())}),50),p=null!==(e=this._ownerWindow.ResizeObserver)&&void 0!==e?e:ResizeObserver;this._resizeObserver=new p((e=>{c?u(e):c=!0})),this._resizeObserver.observe(this._container)}_resolveContainer(e){if("string"==typeof e){const c=document.getElementById(e);if(!c)throw new Error(`Container '${e}' not found.`);return c}if(e instanceof HTMLElement)return e;if(e&&"object"==typeof e&&1===e.nodeType)return e;throw new Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const c=this._canvasContainer=h.create("div","maplibregl-canvas-container",e);this._interactive&&c.classList.add("maplibregl-interactive"),this._canvas=h.create("canvas","maplibregl-canvas",c),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const u=this._containerDimensions(),p=this._getClampedPixelRatio(u[0],u[1]);this._resizeCanvas(u[0],u[1],p);const f=this._controlContainer=h.create("div","maplibregl-control-container",e),m=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{m[e]=h.create("div",`maplibregl-ctrl-${e} `,f)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,c,u){this._canvas.width=Math.floor(u*e),this._canvas.height=Math.floor(u*c),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${c}px`}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let c=null;this._canvas.addEventListener("webglcontextcreationerror",(u=>{c={requestedAttributes:e},u&&(c.statusMessage=u.statusMessage,c.type=u.type)}),{once:!0});let u=null;if(u=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!u){const e="Failed to initialize WebGL";throw c?(c.message=e,new Error(JSON.stringify(c))):new Error(e)}this.painter=new Wr(u,this.transform),S.testSupport(u)}migrateProjection(e,c){super.migrateProjection(e,c),this.painter.transform=e,this.fire(new u.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){var c,p,f,m,g;const y=this._idleTriggered?this._fadeDuration:0,x=(null===(c=this.style.projection)||void 0===c?void 0:c.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let b=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,c=T();this.style.zoomHistory.update(e,c);const p=new u.H(e,{now:c,fadeDuration:y,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),f=p.crossFadingFactor();1===f&&f===this._crossFadingFactor||(b=!0,this._crossFadingFactor=f),this.style.update(p)}const S=(null===(p=this.style.projection)||void 0===p?void 0:p.transitionState)>0!==x;null===(f=this.style.projection)||void 0===f||f.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(m=this.style.projection)||void 0===m?void 0:m.transitionState,null===(g=this.style.projection)||void 0===g?void 0:g.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||S)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,y,this._crossSourceCollisions,S),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:y,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new u.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,u.cH.mark(u.cI.load),this.fire(new u.l("load"))),this.style&&(this.style.hasTransitions()||b)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const P=this._sourcesDirty||this._styleDirty||this._placementDirty;return P||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new u.l("idle")),!this._loaded||this._fullyLoaded||P||(this._fullyLoaded=!0,u.cH.mark(u.cI.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),L.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const c=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==c?void 0:c.loseContext)&&c.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),h.remove(this._canvasContainer),h.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),u.cH.remove(),this._removed=!0,this.fire(new u.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,x.frame(this._frameRequest,(e=>{u.cH.recordStartOfFrameAt(e),this._frameRequest=null;try{this._render(e)}catch(e){if(!u.Z(e)&&!function(e){return e.message===Sn}(e))throw e}}),(()=>{}),this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get version(){return ia}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},c.MapMouseEvent=ro,c.MapTouchEvent=oo,c.MapWheelEvent=so,c.Marker=fs,c.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),c=e===this._map.getMaxZoom(),u=e===this._map.getMinZoom();this._zoomInButton.disabled=c,this._zoomOutButton.disabled=u,this._zoomInButton.setAttribute("aria-disabled",c.toString()),this._zoomOutButton.setAttribute("aria-disabled",u.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,c)=>{const u=this._map._getUIString(`NavigationControl.${c}`);e.title=u,e.setAttribute("aria-label",u)},this.options=u.e({},el,e),this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(e=>this._map.zoomIn({},{originalEvent:e}))),h.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(e=>this._map.zoomOut({},{originalEvent:e}))),h.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})})),this._compassIcon=h.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new us(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){h.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,c){const u=h.create("button",e,this._container);return u.type="button",u.addEventListener("click",c),u}},c.Popup=class extends u.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&h.remove(this._content),this._container&&(h.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new u.l("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=h.create("div","maplibregl-popup",this._map.getContainer()),this._tip=h.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=il(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const c=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let u=this.options.anchor;const p=pl(this.options.offset);if(!u){const e=this._container.offsetWidth,f=this._container.offsetHeight,m=function(e){var c,u,p,f;return e?{top:null!==(c=e.top)&&void 0!==c?c:0,right:null!==(u=e.right)&&void 0!==u?u:0,bottom:null!==(p=e.bottom)&&void 0!==p?p:0,left:null!==(f=e.left)&&void 0!==f?f:0}:{top:0,right:0,bottom:0,left:0}}(this.options.padding);let g;g=c.y+p.bottom.ythis._map.transform.height-f-m.bottom?["bottom"]:[],c.xthis._map.transform.width-e/2-m.right&&g.push("right"),u=0===g.length?"bottom":g.join("-")}let f=c.add(p[u]);this.options.subpixelPositioning||(f=f.round()),h.setTransform(this._container,`${rl[u]} translate(${f.x}px,${f.y}px)`),nl(this._container,u,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=u.e(Object.create(ul),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new u.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=u.V.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const c=document.createDocumentFragment(),u=document.createElement("body");let p;for(u.innerHTML=e;p=u.firstChild,p;)c.appendChild(p);return this.setDOMContent(c)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=h.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}setPadding(e){this.options.padding=e,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=h.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(dl);e&&e.focus()}},c.RasterDEMTileSource=Y,c.RasterTileSource=K,c.ScaleControl=class{constructor(e){this._onMove=()=>{cl(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,cl(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},ll),e)}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){h.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},c.ScrollZoomHandler=Oo,c.Style=Fi,c.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=e}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=h.create("button","maplibregl-ctrl-terrain",this._container),h.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){h.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},c.TwoFingersTouchPitchHandler=Do,c.TwoFingersTouchRotateHandler=zo,c.TwoFingersTouchZoomHandler=Eo,c.TwoFingersTouchZoomRotateHandler=Vo,c.VectorTileSource=X,c.VideoSource=ae,c.addSourceType=(e,c)=>u._(void 0,void 0,void 0,(function*(){if(we(e))throw new Error(`A source type called "${e}" already exists.`);((e,c)=>{be[e]=c})(e,c)})),c.clearPrewarmedResources=function(){const e=ee;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(J),ee=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()"))},c.createTileMesh=dr,c.getMaxParallelImageRequests=function(){return u.c.MAX_PARALLEL_IMAGE_REQUESTS},c.getRTLTextPluginStatus=function(){return Ee().getRTLTextPluginStatus()},c.getVersion=function(){return fl},c.getWorkerCount=function(){return k.workerCount},c.getWorkerUrl=function(){return u.c.WORKER_URL},c.importScriptInWorkers=function(e){return he().broadcast("IS",e)},c.isTimeFrozen=function(){return b.isFrozen()},c.now=T,c.prewarm=function(){ce().acquire(J)},c.restoreNow=function(){b.restoreNow()},c.setMaxParallelImageRequests=function(e){u.c.MAX_PARALLEL_IMAGE_REQUESTS=e},c.setNow=function(e){b.setNow(e)},c.setRTLTextPlugin=function(e,c){return Ee().setRTLTextPlugin(e,c)},c.setWorkerCount=function(e){k.workerCount=e},c.setWorkerUrl=function(e){u.c.WORKER_URL=e}}));var f=c;return f}));var u=c;export{u as default}; +* MapLibre GL JS +* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.22.0/LICENSE.txt +*/ +(function(e,_){r=_()})(r,function(){var r={},_={};function v(e,v,b){if(_[e]=b,e===`index`){var x=`var sharedModule = {}; (`+_.shared+`)(sharedModule); (`+_.worker+`)(sharedModule);`,C={};return _.shared(C),_.index(r,C),typeof window<`u`&&r.setWorkerUrl(window.URL.createObjectURL(new Blob([x],{type:`text/javascript`}))),r}}return v(`shared`,[`exports`],function(r){function _(e,r,_,v){return new(_||=Promise)(function(b,x){function C(e){try{E(v.next(e))}catch(e){x(e)}}function T(e){try{E(v.throw(e))}catch(e){x(e)}}function E(e){var r;e.done?b(e.value):(r=e.value,r instanceof _?r:new _(function(e){e(r)})).then(C,T)}E((v=v.apply(e,r||[])).next())})}function v(r,_){(this||e).x=r,(this||e).y=_}function b(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var x,C;v.prototype={clone(){return new v((this||e).x,(this||e).y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,r){return this.clone()._rotateAround(e,r)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt((this||e).x*(this||e).x+(this||e).y*(this||e).y)},equals(r){return(this||e).x===r.x&&(this||e).y===r.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(r){let _=r.x-(this||e).x,v=r.y-(this||e).y;return _*_+v*v},angle(){return Math.atan2((this||e).y,(this||e).x)},angleTo(r){return Math.atan2((this||e).y-r.y,(this||e).x-r.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(r,_){return Math.atan2((this||e).x*_-(this||e).y*r,(this||e).x*r+(this||e).y*_)},_matMult(r){let _=r[2]*(this||e).x+r[3]*(this||e).y;return(this||e).x=r[0]*(this||e).x+r[1]*(this||e).y,(this||e).y=_,this||e},_add(r){return(this||e).x+=r.x,(this||e).y+=r.y,this||e},_sub(r){return(this||e).x-=r.x,(this||e).y-=r.y,this||e},_mult(r){return(this||e).x*=r,(this||e).y*=r,this||e},_div(r){return(this||e).x/=r,(this||e).y/=r,this||e},_multByPoint(r){return(this||e).x*=r.x,(this||e).y*=r.y,this||e},_divByPoint(r){return(this||e).x/=r.x,(this||e).y/=r.y,this||e},_unit(){return this._div(this.mag()),this||e},_perp(){let r=(this||e).y;return(this||e).y=(this||e).x,(this||e).x=-r,this||e},_rotate(r){let _=Math.cos(r),v=Math.sin(r),b=v*(this||e).x+_*(this||e).y;return(this||e).x=_*(this||e).x-v*(this||e).y,(this||e).y=b,this||e},_rotateAround(r,_){let v=Math.cos(r),b=Math.sin(r),x=_.y+b*((this||e).x-_.x)+v*((this||e).y-_.y);return(this||e).x=_.x+v*((this||e).x-_.x)-b*((this||e).y-_.y),(this||e).y=x,this||e},_round(){return(this||e).x=Math.round((this||e).x),(this||e).y=Math.round((this||e).y),this||e},constructor:v},v.convert=function(e){if(e instanceof v)return e;if(Array.isArray(e))return new v(+e[0],+e[1]);if(e.x!==void 0&&e.y!==void 0)return new v(+e.x,+e.y);throw Error(`Expected [x, y] or {x, y} point format`)};var T=b(function(){if(C)return x;function r(r,_,v,b){(this||e).cx=3*r,(this||e).bx=3*(v-r)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*_,(this||e).by=3*(b-_)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=r,(this||e).p1y=_,(this||e).p2x=v,(this||e).p2y=b}return C=1,x=r,r.prototype={sampleCurveX:function(r){return(((this||e).ax*r+(this||e).bx)*r+(this||e).cx)*r},sampleCurveY:function(r){return(((this||e).ay*r+(this||e).by)*r+(this||e).cy)*r},sampleCurveDerivativeX:function(r){return(3*(this||e).ax*r+2*(this||e).bx)*r+(this||e).cx},solveCurveX:function(e,r){if(r===void 0&&(r=1e-6),e<0)return 0;if(e>1)return 1;for(var _=e,v=0;v<8;v++){var b=this.sampleCurveX(_)-e;if(Math.abs(b)b?C=_:T=_,_=.5*(T-C)+C;return _},solve:function(e,r){return this.sampleCurveY(this.solveCurveX(e,r))}},x}());let E,D;function O(){return E??=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)&&typeof createImageBitmap==`function`,E}function k(){if(D==null&&(D=!1,O())){let e=5,r=new OffscreenCanvas(5,5).getContext(`2d`,{willReadFrequently:!0});if(r){for(let e=0;e<25;e++){let _=4*e;r.fillStyle=`rgb(${_},${_+1},${_+2})`,r.fillRect(e%5,Math.floor(e/5),1,1)}let e=r.getImageData(0,0,5,5).data;for(let r=0;r<100;r++)if(r%4!=3&&e[r]!==r){D=!0;break}}}return D||!1}var A=1e-6,j=typeof Float32Array<`u`?Float32Array:Array;function F(){var e=new j(9);return j!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function R(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function z(){var e=new j(3);return j!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function B(e){var r=e[0],_=e[1],v=e[2];return Math.sqrt(r*r+_*_+v*v)}function H(e,r,_){var v=new j(3);return v[0]=e,v[1]=r,v[2]=_,v}function K(e,r,_){return e[0]=r[0]+_[0],e[1]=r[1]+_[1],e[2]=r[2]+_[2],e}function q(e,r,_){return e[0]=r[0]*_,e[1]=r[1]*_,e[2]=r[2]*_,e}function Y(e,r,_){var v=r[0],b=r[1],x=r[2],C=_[0],T=_[1],E=_[2];return e[0]=b*E-x*T,e[1]=x*C-v*E,e[2]=v*T-b*C,e}var X,ne=B;function Z(e,r,_){var v=r[0],b=r[1],x=r[2],C=r[3];return e[0]=_[0]*v+_[4]*b+_[8]*x+_[12]*C,e[1]=_[1]*v+_[5]*b+_[9]*x+_[13]*C,e[2]=_[2]*v+_[6]*b+_[10]*x+_[14]*C,e[3]=_[3]*v+_[7]*b+_[11]*x+_[15]*C,e}function ie(){var e=new j(4);return j!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function ae(e,r,_,v){var b=arguments.length>4&&arguments[4]!==void 0?arguments[4]:`zyx`,x=Math.PI/360;r*=x,v*=x,_*=x;var C=Math.sin(r),T=Math.cos(r),E=Math.sin(_),D=Math.cos(_),O=Math.sin(v),k=Math.cos(v);switch(b){case`xyz`:e[0]=C*D*k+T*E*O,e[1]=T*E*k-C*D*O,e[2]=T*D*O+C*E*k,e[3]=T*D*k-C*E*O;break;case`xzy`:e[0]=C*D*k-T*E*O,e[1]=T*E*k-C*D*O,e[2]=T*D*O+C*E*k,e[3]=T*D*k+C*E*O;break;case`yxz`:e[0]=C*D*k+T*E*O,e[1]=T*E*k-C*D*O,e[2]=T*D*O-C*E*k,e[3]=T*D*k+C*E*O;break;case`yzx`:e[0]=C*D*k+T*E*O,e[1]=T*E*k+C*D*O,e[2]=T*D*O-C*E*k,e[3]=T*D*k-C*E*O;break;case`zxy`:e[0]=C*D*k-T*E*O,e[1]=T*E*k+C*D*O,e[2]=T*D*O+C*E*k,e[3]=T*D*k-C*E*O;break;case`zyx`:e[0]=C*D*k-T*E*O,e[1]=T*E*k+C*D*O,e[2]=T*D*O-C*E*k,e[3]=T*D*k+C*E*O;break;default:throw Error(`Unknown angle order `+b)}return e}function oe(){var e=new j(2);return j!=Float32Array&&(e[0]=0,e[1]=0),e}function se(e,r){var _=new j(2);return _[0]=e,_[1]=r,_}z(),X=new j(4),j!=Float32Array&&(X[0]=0,X[1]=0,X[2]=0,X[3]=0),z(),H(1,0,0),H(0,1,0),ie(),ie(),F(),oe();let ce=8192;function le(e,r,_){return r*(ce/(e.tileSize*2**(_-e.tileID.overscaledZ)))}function de(e,r){return(e%r+r)%r}function fe(e,r,_){return e*(1-_)+r*_}function pe(e){if(e<=0)return 0;if(e>=1)return 1;let r=e*e,_=r*e;return 4*(e<.5?_:3*(e-r)+_-.75)}function me(e,r,_,v){let b=new T(e,r,_,v);return e=>b.solve(e)}let ge=me(.25,.1,.25,1);function _e(e,r,_){return Math.min(_,Math.max(r,e))}function ve(e,r,_){let v=_-r,b=((e-r)%v+v)%v+r;return b===r?_:b}function ye(e,...r){for(let _ of r)for(let r in _)e[r]=_[r];return e}let be=1;function xe(r,_,v){let b={};for(let v in r)b[v]=_.call(this||e,r[v],v,r);return b}function Se(r,_,v){let b={};for(let v in r)_.call(this||e,r[v],v,r)&&(b[v]=r[v]);return b}function we(e){return Array.isArray(e)?e.map(we):typeof e==`object`&&e?xe(e,we):e}let ke={};function je(e){ke[e]||(typeof console<`u`&&console.warn(e),ke[e]=!0)}function Me(e,r,_){return(_.y-e.y)*(r.x-e.x)>(r.y-e.y)*(_.x-e.x)}function Ne(e){return typeof WorkerGlobalScope<`u`&&e!==void 0&&e instanceof WorkerGlobalScope}let Ie=null;function Ue(e){return typeof ImageBitmap<`u`&&e instanceof ImageBitmap}let We=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=`;function qe(r,v,b,x,C){return _(this||e,void 0,void 0,function*(){if(typeof VideoFrame>`u`)throw Error(`VideoFrame not supported`);let e=new VideoFrame(r,{timestamp:0});try{let _=e?.format;if(!_||!_.startsWith(`BGR`)&&!_.startsWith(`RGB`))throw Error(`Unrecognized format ${_}`);let T=_.startsWith(`BGR`),E=new Uint8ClampedArray(x*C*4);if(yield e.copyTo(E,function(e,r,_,v,b){let x=4*Math.max(-r,0),C=(Math.max(0,_)-_)*v*4+x,T=4*v,E=Math.max(0,r),D=Math.max(0,_);return{rect:{x:E,y:D,width:Math.min(e.width,r+v)-E,height:Math.min(e.height,_+b)-D},layout:[{offset:C,stride:T}]}}(r,v,b,x,C)),T)for(let e=0;e{e.removeEventListener(r,_,v)}}}function tt(e){return e*Math.PI/180}function it(e){return e/Math.PI*180}let at={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},ot={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},ut=`AbortError`;class st extends Error{constructor(e=ut){super(e instanceof Error?e.message:e),this.name=ut,e instanceof Error&&e.stack&&(this.stack=e.stack)}}function ft(e){return e.name===ut}function pt(e){if(e.aborted)throw new st(e.reason)}let mt={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:``};function _t(e){return mt.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf(`://`))]}let yt=`global-dispatcher`;class ht extends Error{constructor(e,r,_,v){super(`AJAXError: ${r} (${e}): ${_}`),this.status=e,this.statusText=r,this.url=_,this.body=v}}let bt=()=>Ne(self)?self.worker&&self.worker.referrer:(window.location.protocol===`blob:`?window.parent:window).location.href,wt=function(r,v){if(/:\/\//.test(r.url)&&!/^https?:|^file:/.test(r.url)){let e=_t(r.url);if(e)return e(r,v);if(Ne(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:`GR`,data:r,targetMapId:yt},v)}if(!(/^file:/.test(b=r.url)||/^file:/.test(bt())&&!/^\w+:/.test(b))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,`signal`))return function(r,v){return _(this||e,void 0,void 0,function*(){let e=new Request(r.url,{method:r.method||`GET`,body:r.body,credentials:r.credentials,headers:r.headers,cache:r.cache,referrer:bt(),referrerPolicy:r.referrerPolicy,signal:v.signal}),_,b;r.type!==`json`||e.headers.has(`Accept`)||e.headers.set(`Accept`,`application/json`);try{_=yield fetch(e)}catch(e){throw ft(e)?e:new ht(0,e.message,r.url,new Blob)}if(!_.ok){let e=yield _.blob();throw new ht(_.status,_.statusText,r.url,e)}b=r.type===`arrayBuffer`||r.type===`image`?_.arrayBuffer():r.type===`json`?_.json():_.text();let x=yield b;return pt(v.signal),{data:x,cacheControl:_.headers.get(`Cache-Control`),expires:_.headers.get(`Expires`),etag:_.headers.get(`ETag`)}})}(r,v);if(Ne(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:`GR`,data:r,mustQueue:!0,targetMapId:yt},v)}var b;return function(e,r){return new Promise((_,v)=>{var b;let x=new XMLHttpRequest;x.open(e.method||`GET`,e.url,!0),e.type!==`arrayBuffer`&&e.type!==`image`||(x.responseType=`arraybuffer`);for(let r in e.headers)x.setRequestHeader(r,e.headers[r]);e.type===`json`&&(x.responseType=`text`,(b=e.headers)?.Accept||x.setRequestHeader(`Accept`,`application/json`)),x.withCredentials=e.credentials===`include`,x.onerror=()=>{v(Error(x.statusText))},x.onload=()=>{if(!r.signal.aborted)if((x.status>=200&&x.status<300||x.status===0)&&x.response!==null){let r=x.response;if(e.type===`json`)try{r=JSON.parse(x.response)}catch(e){v(e);return}_({data:r,cacheControl:x.getResponseHeader(`Cache-Control`),expires:x.getResponseHeader(`Expires`),etag:x.getResponseHeader(`ETag`)})}else{let r=new Blob([x.response],{type:x.getResponseHeader(`Content-Type`)});v(new ht(x.status,x.statusText,e.url,r))}},r.signal.addEventListener(`abort`,()=>{x.abort(),v(new st(r.signal.reason))}),x.send(e.body)})}(r,v)};function kt(e){if(!e||e.indexOf(`://`)<=0||e.indexOf(`data:image/`)===0||e.indexOf(`blob:`)===0)return!0;let r=new URL(e),_=window.location;return r.protocol===_.protocol&&r.host===_.host}function jt(e,r,_){_[e]&&_[e].indexOf(r)!==-1||(_[e]=_[e]||[],_[e].push(r))}function Ft(e,r,_){if(_&&_[e]){let v=_[e].indexOf(r);v!==-1&&_[e].splice(v,1)}}class gt{constructor(e,r={}){ye(this,r),this.type=e}}class xt extends gt{constructor(e,r={}){super(`error`,ye({error:e},r))}}class vt{on(e,r){return this._listeners=this._listeners||{},jt(e,r,this._listeners),{unsubscribe:()=>{this.off(e,r)}}}off(e,r){return Ft(e,r,this._listeners),Ft(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},jt(e,r,this._oneTimeListeners),this):new Promise(r=>this.once(e,r))}fire(e,r){typeof e==`string`&&(e=new gt(e,r||{}));let _=e.type;if(this.listens(_)){e.target=this;let r=this._listeners&&this._listeners[_]?this._listeners[_].slice():[];for(let _ of r)_.call(this,e);let v=this._oneTimeListeners&&this._oneTimeListeners[_]?this._oneTimeListeners[_].slice():[];for(let r of v)Ft(_,r,this._oneTimeListeners),r.call(this,e);let b=this._eventedParent;b&&(ye(e,typeof this._eventedParentData==`function`?this._eventedParentData():this._eventedParentData),b.fire(e))}else e instanceof xt&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,r){return this._eventedParent=e,this._eventedParentData=r,this}}var $={$version:8,$root:{version:{required:!0,type:`enum`,values:[8]},name:{type:`string`},metadata:{type:`*`},center:{type:`array`,value:`number`,length:2},centerAltitude:{type:`number`},zoom:{type:`number`},bearing:{type:`number`,default:0,period:360,units:`degrees`},pitch:{type:`number`,default:0,units:`degrees`},roll:{type:`number`,default:0,units:`degrees`},state:{type:`state`,default:{}},light:{type:`light`},sky:{type:`sky`},projection:{type:`projection`},terrain:{type:`terrain`},sources:{required:!0,type:`sources`},sprite:{type:`sprite`},glyphs:{type:`string`},"font-faces":{type:`fontFaces`},transition:{type:`transition`},layers:{required:!0,type:`array`,value:`layer`}},sources:{"*":{type:`source`}},source:[`source_vector`,`source_raster`,`source_raster_dem`,`source_geojson`,`source_video`,`source_image`],source_vector:{type:{required:!0,type:`enum`,values:{vector:{}}},url:{type:`string`},tiles:{type:`array`,value:`string`},bounds:{type:`array`,value:`number`,length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:`enum`,values:{xyz:{},tms:{}},default:`xyz`},minzoom:{type:`number`,default:0},maxzoom:{type:`number`,default:22},attribution:{type:`string`},promoteId:{type:`promoteId`},volatile:{type:`boolean`,default:!1},encoding:{type:`enum`,values:{mvt:{},mlt:{}},default:`mvt`},"*":{type:`*`}},source_raster:{type:{required:!0,type:`enum`,values:{raster:{}}},url:{type:`string`},tiles:{type:`array`,value:`string`},bounds:{type:`array`,value:`number`,length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:`number`,default:0},maxzoom:{type:`number`,default:22},tileSize:{type:`number`,default:512,units:`pixels`},scheme:{type:`enum`,values:{xyz:{},tms:{}},default:`xyz`},attribution:{type:`string`},volatile:{type:`boolean`,default:!1},"*":{type:`*`}},source_raster_dem:{type:{required:!0,type:`enum`,values:{"raster-dem":{}}},url:{type:`string`},tiles:{type:`array`,value:`string`},bounds:{type:`array`,value:`number`,length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:`number`,default:0},maxzoom:{type:`number`,default:22},tileSize:{type:`number`,default:512,units:`pixels`},attribution:{type:`string`},encoding:{type:`enum`,values:{terrarium:{},mapbox:{},custom:{}},default:`mapbox`},redFactor:{type:`number`,default:1},blueFactor:{type:`number`,default:1},greenFactor:{type:`number`,default:1},baseShift:{type:`number`,default:0},volatile:{type:`boolean`,default:!1},"*":{type:`*`}},source_geojson:{type:{required:!0,type:`enum`,values:{geojson:{}}},data:{required:!0,type:`*`},maxzoom:{type:`number`,default:18},attribution:{type:`string`},buffer:{type:`number`,default:128,maximum:512,minimum:0},filter:{type:`filter`},tolerance:{type:`number`,default:.375},cluster:{type:`boolean`,default:!1},clusterRadius:{type:`number`,default:50,minimum:0},clusterMaxZoom:{type:`number`},clusterMinPoints:{type:`number`},clusterProperties:{type:`*`},lineMetrics:{type:`boolean`,default:!1},generateId:{type:`boolean`,default:!1},promoteId:{type:`promoteId`}},source_video:{type:{required:!0,type:`enum`,values:{video:{}}},urls:{required:!0,type:`array`,value:`string`},coordinates:{required:!0,type:`array`,length:4,value:{type:`array`,length:2,value:`number`}}},source_image:{type:{required:!0,type:`enum`,values:{image:{}}},url:{required:!0,type:`string`},coordinates:{required:!0,type:`array`,length:4,value:{type:`array`,length:2,value:`number`}}},layer:{id:{type:`string`,required:!0},type:{type:`enum`,values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:`*`},source:{type:`string`},"source-layer":{type:`string`},minzoom:{type:`number`,minimum:0,maximum:24},maxzoom:{type:`number`,minimum:0,maximum:24},filter:{type:`filter`},layout:{type:`layout`},paint:{type:`paint`}},layout:[`layout_fill`,`layout_line`,`layout_circle`,`layout_heatmap`,`layout_fill-extrusion`,`layout_symbol`,`layout_raster`,`layout_hillshade`,`layout_color-relief`,`layout_background`],layout_background:{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},layout_fill:{"fill-sort-key":{type:`number`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},layout_circle:{"circle-sort-key":{type:`number`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},layout_heatmap:{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},"layout_fill-extrusion":{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},layout_line:{"line-cap":{type:`enum`,values:{butt:{},round:{},square:{}},default:`butt`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"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`,`feature`]},"property-type":`data-driven`},"line-round-limit":{type:`number`,default:1.05,requires:[{"line-join":`round`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"line-sort-key":{type:`number`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},layout_symbol:{"symbol-placement":{type:`enum`,values:{point:{},line:{},"line-center":{}},default:`point`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"symbol-spacing":{type:`number`,default:250,minimum:1,units:`pixels`,requires:[{"symbol-placement":`line`}],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"symbol-avoid-edges":{type:`boolean`,default:!1,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"symbol-sort-key":{type:`number`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"symbol-z-order":{type:`enum`,values:{auto:{},"viewport-y":{},source:{}},default:`auto`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-allow-overlap":{type:`boolean`,default:!1,requires:[`icon-image`,{"!":`icon-overlap`}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-overlap":{type:`enum`,values:{never:{},always:{},cooperative:{}},requires:[`icon-image`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-ignore-placement":{type:`boolean`,default:!1,requires:[`icon-image`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-optional":{type:`boolean`,default:!1,requires:[`icon-image`,`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-rotation-alignment":{type:`enum`,values:{map:{},viewport:{},auto:{}},default:`auto`,requires:[`icon-image`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-size":{type:`number`,default:1,minimum:0,units:`factor of the original icon size`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-text-fit":{type:`enum`,values:{none:{},width:{},height:{},both:{}},default:`none`,requires:[`icon-image`,`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-text-fit-padding":{type:`array`,value:`number`,length:4,default:[0,0,0,0],units:`pixels`,requires:[`icon-image`,`text-field`,{"icon-text-fit":[`both`,`width`,`height`]}],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"icon-image":{type:`resolvedImage`,tokens:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-rotate":{type:`number`,default:0,period:360,units:`degrees`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-padding":{type:`padding`,default:[2],units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-keep-upright":{type:`boolean`,default:!1,requires:[`icon-image`,{"icon-rotation-alignment":`map`},{"symbol-placement":[`line`,`line-center`]}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-offset":{type:`array`,value:`number`,length:2,default:[0,0],requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-anchor":{type:`enum`,values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:`center`,requires:[`icon-image`],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-pitch-alignment":{type:`enum`,values:{map:{},viewport:{},auto:{}},default:`auto`,requires:[`icon-image`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-pitch-alignment":{type:`enum`,values:{map:{},viewport:{},auto:{}},default:`auto`,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-rotation-alignment":{type:`enum`,values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:`auto`,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-field":{type:`formatted`,default:``,tokens:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-font":{type:`array`,value:`string`,default:[`Open Sans Regular`,`Arial Unicode MS Regular`],requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-size":{type:`number`,default:16,minimum:0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-max-width":{type:`number`,default:10,minimum:0,units:`ems`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-line-height":{type:`number`,default:1.2,units:`ems`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"text-letter-spacing":{type:`number`,default:0,units:`ems`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-justify":{type:`enum`,values:{auto:{},left:{},center:{},right:{}},default:`center`,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-radial-offset":{type:`number`,units:`ems`,default:0,requires:[`text-field`],"property-type":`data-driven`,expression:{interpolated:!0,parameters:[`zoom`,`feature`]}},"text-variable-anchor":{type:`array`,value:`enum`,values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:[`text-field`,{"symbol-placement":[`point`]}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-variable-anchor-offset":{type:`variableAnchorOffsetCollection`,requires:[`text-field`,{"symbol-placement":[`point`]}],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-anchor":{type:`enum`,values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:`center`,requires:[`text-field`,{"!":`text-variable-anchor`}],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-max-angle":{type:`number`,default:45,units:`degrees`,requires:[`text-field`,{"symbol-placement":[`line`,`line-center`]}],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"text-writing-mode":{type:`array`,value:`enum`,values:{horizontal:{},vertical:{}},requires:[`text-field`,{"symbol-placement":[`point`]}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-rotate":{type:`number`,default:0,period:360,units:`degrees`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-padding":{type:`number`,default:2,minimum:0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"text-keep-upright":{type:`boolean`,default:!0,requires:[`text-field`,{"text-rotation-alignment":`map`},{"symbol-placement":[`line`,`line-center`]}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-transform":{type:`enum`,values:{none:{},uppercase:{},lowercase:{}},default:`none`,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-offset":{type:`array`,value:`number`,units:`ems`,length:2,default:[0,0],requires:[`text-field`,{"!":`text-radial-offset`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-allow-overlap":{type:`boolean`,default:!1,requires:[`text-field`,{"!":`text-overlap`}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-overlap":{type:`enum`,values:{never:{},always:{},cooperative:{}},requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-ignore-placement":{type:`boolean`,default:!1,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-optional":{type:`boolean`,default:!1,requires:[`text-field`,`icon-image`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},layout_raster:{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},layout_hillshade:{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},"layout_color-relief":{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,expression:{interpolated:!1,parameters:[`global-state`]},"property-type":`data-constant`}},filter:{type:`boolean`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},filter_operator:{type:`enum`,values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:`enum`,values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:`expression`},stops:{type:`array`,value:`function_stop`},base:{type:`number`,default:1,minimum:0},property:{type:`string`,default:`$zoom`},type:{type:`enum`,values:{identity:{},exponential:{},interval:{},categorical:{}},default:`exponential`},colorSpace:{type:`enum`,values:{rgb:{},lab:{},hcl:{}},default:`rgb`},default:{type:`*`,required:!1}},function_stop:{type:`array`,minimum:0,maximum:24,value:[`number`,`color`],length:2},expression:{type:`array`,value:`expression_name`,minimum:1},light:{anchor:{type:`enum`,default:`viewport`,values:{map:{},viewport:{}},"property-type":`data-constant`,transition:!1,expression:{interpolated:!1,parameters:[`zoom`]}},position:{type:`array`,default:[1.15,210,30],length:3,value:`number`,"property-type":`data-constant`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]}},color:{type:`color`,"property-type":`data-constant`,default:`#ffffff`,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},intensity:{type:`number`,"property-type":`data-constant`,default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0}},sky:{"sky-color":{type:`color`,"property-type":`data-constant`,default:`#88C6FC`,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"horizon-color":{type:`color`,"property-type":`data-constant`,default:`#ffffff`,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"fog-color":{type:`color`,"property-type":`data-constant`,default:`#ffffff`,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"fog-ground-blend":{type:`number`,"property-type":`data-constant`,default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"horizon-fog-blend":{type:`number`,"property-type":`data-constant`,default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"sky-horizon-blend":{type:`number`,"property-type":`data-constant`,default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"atmosphere-blend":{type:`number`,"property-type":`data-constant`,default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0}},terrain:{source:{type:`string`,required:!0},exaggeration:{type:`number`,minimum:0,default:1}},projection:{type:{type:`projectionDefinition`,default:`mercator`,"property-type":`data-constant`,transition:!1,expression:{interpolated:!0,parameters:[`zoom`]}}},paint:[`paint_fill`,`paint_line`,`paint_circle`,`paint_heatmap`,`paint_fill-extrusion`,`paint_symbol`,`paint_raster`,`paint_hillshade`,`paint_color-relief`,`paint_background`],paint_fill:{"fill-antialias":{type:`boolean`,default:!0,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"fill-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-color":{type:`color`,default:`#000000`,transition:!0,requires:[{"!":`fill-pattern`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-outline-color":{type:`color`,transition:!0,requires:[{"!":`fill-pattern`},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"fill-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`fill-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"fill-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"fill-extrusion-color":{type:`color`,default:`#000000`,transition:!0,requires:[{"!":`fill-extrusion-pattern`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-extrusion-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"fill-extrusion-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`fill-extrusion-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"fill-extrusion-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`},"fill-extrusion-height":{type:`number`,default:0,minimum:0,units:`meters`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-extrusion-base":{type:`number`,default:0,minimum:0,units:`meters`,transition:!0,requires:[`fill-extrusion-height`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-extrusion-vertical-gradient":{type:`boolean`,default:!0,transition:!1,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`}},paint_line:{"line-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-color":{type:`color`,default:`#000000`,transition:!0,requires:[{"!":`line-pattern`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"line-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`line-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"line-width":{type:`number`,default:1,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-gap-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-offset":{type:`number`,default:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-blur":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-dasharray":{type:`array`,value:`number`,minimum:0,transition:!0,units:`line widths`,requires:[{"!":`line-pattern`}],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`},"line-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`},"line-gradient":{type:`color`,transition:!1,requires:[{"!":`line-dasharray`},{"!":`line-pattern`},{source:`geojson`,has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:[`line-progress`]},"property-type":`color-ramp`}},paint_circle:{"circle-radius":{type:`number`,default:5,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-color":{type:`color`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-blur":{type:`number`,default:0,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"circle-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`circle-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"circle-pitch-scale":{type:`enum`,values:{map:{},viewport:{}},default:`map`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"circle-pitch-alignment":{type:`enum`,values:{map:{},viewport:{}},default:`viewport`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"circle-stroke-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-stroke-color":{type:`color`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-stroke-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`}},paint_heatmap:{"heatmap-radius":{type:`number`,default:30,minimum:1,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"heatmap-weight":{type:`number`,default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"heatmap-intensity":{type:`number`,default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"heatmap-color":{type:`color`,default:[`interpolate`,[`linear`],[`heatmap-density`],0,`rgba(0, 0, 255, 0)`,.1,`royalblue`,.3,`cyan`,.5,`lime`,.7,`yellow`,1,`red`],transition:!1,expression:{interpolated:!0,parameters:[`heatmap-density`]},"property-type":`color-ramp`},"heatmap-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`}},paint_symbol:{"icon-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-color":{type:`color`,default:`#000000`,transition:!0,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-halo-color":{type:`color`,default:`rgba(0, 0, 0, 0)`,transition:!0,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-halo-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-halo-blur":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"icon-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`icon-image`,`icon-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-color":{type:`color`,default:`#000000`,transition:!0,overridable:!0,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-halo-color":{type:`color`,default:`rgba(0, 0, 0, 0)`,transition:!0,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-halo-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-halo-blur":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"text-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`text-field`,`text-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`}},paint_raster:{"raster-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-hue-rotate":{type:`number`,default:0,period:360,transition:!0,units:`degrees`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-brightness-min":{type:`number`,default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-brightness-max":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-saturation":{type:`number`,default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-contrast":{type:`number`,default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},resampling:{type:`enum`,values:{linear:{},nearest:{}},default:`linear`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"raster-resampling":{type:`enum`,values:{linear:{},nearest:{}},default:`linear`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"raster-fade-duration":{type:`number`,default:300,minimum:0,transition:!1,units:`milliseconds`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`}},paint_hillshade:{"hillshade-illumination-direction":{type:`numberArray`,default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-illumination-altitude":{type:`numberArray`,default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-illumination-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`viewport`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-exaggeration":{type:`number`,default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-shadow-color":{type:`colorArray`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-highlight-color":{type:`colorArray`,default:`#FFFFFF`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-accent-color":{type:`color`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-method":{type:`enum`,values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:`standard`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},resampling:{type:`enum`,values:{linear:{},nearest:{}},default:`linear`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`}},"paint_color-relief":{"color-relief-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"color-relief-color":{type:`color`,transition:!1,expression:{interpolated:!0,parameters:[`elevation`]},"property-type":`color-ramp`},resampling:{type:`enum`,values:{linear:{},nearest:{}},default:`linear`,expression:{interpolated:!1,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`}},interpolation:{type:`array`,value:`interpolation_name`,minimum:1},interpolation_name:{type:`enum`,values:{linear:{syntax:{overloads:[{parameters:[],"output-type":`interpolation`}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:[`base`],"output-type":`interpolation`}],parameters:[{name:`base`,type:`number literal`}]}},"cubic-bezier":{syntax:{overloads:[{parameters:[`x1`,`y1`,`x2`,`y2`],"output-type":`interpolation`}],parameters:[{name:`x1`,type:`number literal`},{name:`y1`,type:`number literal`},{name:`x2`,type:`number literal`},{name:`y2`,type:`number literal`}]}}}}};let Lt=[`type`,`source`,`source-layer`,`minzoom`,`maxzoom`,`filter`,`layout`];function Rt(e,r){let _={};for(let r in e)r!==`ref`&&(_[r]=e[r]);return Lt.forEach(e=>{e in r&&(_[e]=r[e])}),_}function zt(e,r){if(Array.isArray(e)){if(!Array.isArray(r)||e.length!==r.length)return!1;for(let _=0;_`:e.itemType.kind===`value`?`array`:`array<${r}>`}return e.kind}let Ln=[pn,mn,hn,gn,_n,vn,wn,bn,Nn(Sn),On,An,kn,jn,Mn];function Rn(e,r){if(r.kind===`error`)return null;if(e.kind===`array`){if(r.kind===`array`&&(r.N===0&&r.itemType.kind===`value`||!Rn(e.itemType,r.itemType))&&(typeof e.N!=`number`||e.N===r.N))return null}else{if(e.kind===r.kind)return null;if(e.kind===`value`){for(let e of Ln)if(!Rn(e,r))return null}}return`Expected ${In(e)} but found ${In(r)} instead.`}function zn(e,r){return r.some(r=>r.kind===e.kind)}function Bn(e,r){return r.some(r=>r===`null`?e===null:r===`array`?Array.isArray(e):r===`object`?e&&!Array.isArray(e)&&typeof e==`object`:r===typeof e)}function Vn(e,r){return e.kind===`array`&&r.kind===`array`?e.itemType.kind===r.itemType.kind&&typeof e.N==`number`:e.kind===r.kind}let Hn=.96422,Un=.82521,Wn=4/29,Gn=6/29,qn=3*Gn*Gn,Yn=Gn*Gn*Gn,Xn=Math.PI/180,Zn=180/Math.PI;function Qn(e){return(e%=360)<0&&(e+=360),e}function $n([e,r,_,v]){let b,x,C=tr((.2225045*(e=er(e))+.7168786*(r=er(r))+.0606169*(_=er(_)))/1);e===r&&r===_?b=x=C:(b=tr((.4360747*e+.3850649*r+.1430804*_)/Hn),x=tr((.0139322*e+.0971045*r+.7141733*_)/Un));let T=116*C-16;return[T<0?0:T,500*(b-C),200*(C-x),v]}function er(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function tr(e){return e>.008856451679035631?e**(1/3):e/qn+Wn}function cr([e,r,_,v]){let b=(e+16)/116,x=isNaN(r)?b:b+r/500,C=isNaN(_)?b:b-_/200;return b=1*pr(b),x=Hn*pr(x),C=Un*pr(C),[fr(3.1338561*x-1.6168667*b-.4906146*C),fr(-.9787684*x+1.9161415*b+.033454*C),fr(.0719453*x-.2289914*b+1.4052427*C),v]}function fr(e){return(e=e<=.00304?12.92*e:1.055*e**(1/2.4)-.055)<0?0:e>1?1:e}function pr(e){return e>Gn?e*e*e:qn*(e-Wn)}let mr=Object.hasOwn||function(e,r){return Object.prototype.hasOwnProperty.call(e,r)};function br(e,r){return mr(e,r)?e[r]:void 0}function Tr(e){return parseInt(e.padEnd(2,e),16)/255}function Er(e,r){return Dr(r?e/100:e,0,1)}function Dr(e,r,_){return Math.min(Math.max(r,e),_)}function Ar(e){return!e.some(Number.isNaN)}let Ir={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Lr(e,r,_){return e+_*(r-e)}function Rr(e,r,_){return e.map((e,v)=>Lr(e,r[v],_))}class Ee{constructor(e,r,_,v=1,b=!0){this.r=e,this.g=r,this.b=_,this.a=v,b||(this.r*=v,this.g*=v,this.b*=v,v||this.overwriteGetter(`rgb`,[e,r,_,v]))}static parse(e){if(e instanceof Ee)return e;if(typeof e!=`string`)return;let r=function(e){if((e=e.toLowerCase().trim())===`transparent`)return[0,0,0,0];let r=br(Ir,e);if(r){let[e,_,v]=r;return[e/255,_/255,v/255,1]}if(e.startsWith(`#`)&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){let r=e.length<6?1:2,_=1;return[Tr(e.slice(_,_+=r)),Tr(e.slice(_,_+=r)),Tr(e.slice(_,_+=r)),Tr(e.slice(_,_+r)||`ff`)]}if(e.startsWith(`rgb`)){let r=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){let[e,_,v,b,x,C,T,E,D,O,k,A]=r,j=[b||` `,T||` `,O].join(``);if(j===` `||j===` /`||j===`,,`||j===`,,,`){let e=[v,C,D].join(``),r=e===`%%%`?100:e===``?255:0;if(r){let e=[Dr(+_/r,0,1),Dr(+x/r,0,1),Dr(+E/r,0,1),k?Er(+k,A):1];if(Ar(e))return e}}return}}let _=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(_){let[e,r,v,b,x,C,T,E,D]=_,O=[v||` `,x||` `,T].join(``);if(O===` `||O===` /`||O===`,,`||O===`,,,`){let e=[+r,Dr(+b,0,100),Dr(+C,0,100),E?Er(+E,D):1];if(Ar(e))return function([e,r,_,v]){function b(v){let b=(v+e/30)%12,x=r*Math.min(_,1-_);return _-x*Math.max(-1,Math.min(b-3,9-b,1))}return e=Qn(e),r/=100,_/=100,[b(0),b(8),b(4),v]}(e)}}}(e);return r?new Ee(...r,!1):void 0}get rgb(){let{r:e,g:r,b:_,a:v}=this,b=v||1/0;return this.overwriteGetter(`rgb`,[e/b,r/b,_/b,v])}get hcl(){return this.overwriteGetter(`hcl`,function(e){let[r,_,v,b]=$n(e),x=Math.sqrt(_*_+v*v);return[Math.round(1e4*x)?Qn(Math.atan2(v,_)*Zn):NaN,x,r,b]}(this.rgb))}get lab(){return this.overwriteGetter(`lab`,$n(this.rgb))}overwriteGetter(e,r){return Object.defineProperty(this,e,{value:r}),r}toString(){let[e,r,_,v]=this.rgb;return`rgba(${[e,r,_].map(e=>Math.round(255*e)).join(`,`)},${v})`}static interpolate(e,r,_,v=`rgb`){switch(v){case`rgb`:{let[v,b,x,C]=Rr(e.rgb,r.rgb,_);return new Ee(v,b,x,C,!1)}case`hcl`:{let[v,b,x,C]=e.hcl,[T,E,D,O]=r.hcl,k,A;if(isNaN(v)||isNaN(T))isNaN(v)?isNaN(T)?k=NaN:(k=T,x!==1&&x!==0||(A=E)):(k=v,D!==1&&D!==0||(A=b));else{let e=T-v;T>v&&e>180?e-=360:T180&&(e+=360),k=v+_*e}let[j,F,R,z]=function([e,r,_,v]){return e=isNaN(e)?0:e*Xn,cr([_,Math.cos(e)*r,Math.sin(e)*r,v])}([k,A??Lr(b,E,_),Lr(x,D,_),Lr(C,O,_)]);return new Ee(j,F,R,z,!1)}case`lab`:{let[v,b,x,C]=cr(Rr(e.lab,r.lab,_));return new Ee(v,b,x,C,!1)}}}}Ee.black=new Ee(0,0,0,1),Ee.white=new Ee(1,1,1,1),Ee.transparent=new Ee(0,0,0,0),Ee.red=new Ee(1,0,0,1);class Te{constructor(e,r,_){this.sensitivity=e?r?`variant`:`case`:r?`accent`:`base`,this.locale=_,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:`search`})}compare(e,r){return this.collator.compare(e,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}let Hr=[`bottom`,`center`,`top`];class Pe{constructor(e,r,_,v,b,x){this.text=e,this.image=r,this.scale=_,this.fontStack=v,this.textColor=b,this.verticalAlign=x}}class De{constructor(e){this.sections=e}static fromString(e){return new De([new Pe(e,null,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||e.image&&e.image.name.length!==0)}static factory(e){return e instanceof De?e:De.fromString(e)}toString(){return this.sections.length===0?``:this.sections.map(e=>e.text).join(``)}}class ze{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof ze)return e;if(typeof e==`number`)return new ze([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(let r of e)if(typeof r!=`number`)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new ze(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,r,_){return new ze(Rr(e.values,r.values,_))}}class Be{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Be)return e;if(typeof e==`number`)return new Be([e]);if(Array.isArray(e)){for(let r of e)if(typeof r!=`number`)return;return new Be(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,r,_){return new Be(Rr(e.values,r.values,_))}}class Ce{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Ce)return e;if(typeof e==`string`){let r=Ee.parse(e);return r?new Ce([r]):void 0}if(!Array.isArray(e))return;let r=[];for(let _ of e){if(typeof _!=`string`)return;let e=Ee.parse(_);if(!e)return;r.push(e)}return new Ce(r)}toString(){return JSON.stringify(this.values)}static interpolate(e,r,_,v=`rgb`){let b=[];if(e.values.length!=r.values.length)throw Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${r.values.length}), cannot interpolate.`);for(let x=0;x=0&&e<=255&&typeof r==`number`&&r>=0&&r<=255&&typeof _==`number`&&_>=0&&_<=255?v===void 0||typeof v==`number`&&v>=0&&v<=1?null:`Invalid rgba value [${[e,r,_,v].join(`, `)}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof v==`number`?[e,r,_,v]:[e,r,_]).join(`, `)}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Qr(e){if(e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`||e instanceof Re||e instanceof Ee||e instanceof Te||e instanceof De||e instanceof ze||e instanceof Be||e instanceof Ce||e instanceof Oe||e instanceof $e)return!0;if(Array.isArray(e)){for(let r of e)if(!Qr(r))return!1;return!0}if(typeof e==`object`){for(let r in e)if(!Qr(e[r]))return!1;return!0}return!1}function ei(e){if(e===null)return pn;if(typeof e==`string`)return hn;if(typeof e==`boolean`)return gn;if(typeof e==`number`)return mn;if(e instanceof Ee)return _n;if(e instanceof Re)return vn;if(e instanceof Te)return Cn;if(e instanceof De)return wn;if(e instanceof ze)return On;if(e instanceof Be)return An;if(e instanceof Ce)return kn;if(e instanceof Oe)return Mn;if(e instanceof $e)return jn;if(Array.isArray(e)){let r=e.length,_;for(let r of e){let e=ei(r);if(_){if(_===e)continue;_=Sn;break}_=e}return Nn(_||Sn,r)}return bn}function ri(e){let r=typeof e;return e===null?``:r===`string`||r===`number`||r===`boolean`?String(e):e instanceof Ee||e instanceof Re||e instanceof De||e instanceof ze||e instanceof Be||e instanceof Ce||e instanceof Oe||e instanceof $e?e.toString():JSON.stringify(e)}class Ge{constructor(e,r){this.type=e,this.value=r}static parse(e,r){if(e.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Qr(e[1]))return r.error(`invalid value`);let _=e[1],v=ei(_),b=r.expectedType;return v.kind!==`array`||v.N!==0||!b||b.kind!==`array`||typeof b.N==`number`&&b.N!==0||(v=b),new Ge(v,_)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}let ii={string:hn,number:mn,boolean:gn,object:bn};class Ye{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error(`Expected at least one argument.`);let _,v=1,b=e[0];if(b===`array`){let b,x;if(e.length>2){let _=e[1];if(typeof _!=`string`||!(_ in ii)||_===`object`)return r.error(`The item type argument of "array" must be one of string, number, boolean`,1);b=ii[_],v++}else b=Sn;if(e.length>3){if(e[2]!==null&&(typeof e[2]!=`number`||e[2]<0||e[2]!==Math.floor(e[2])))return r.error(`The length argument to "array" must be a positive integer literal`,2);x=e[2],v++}_=Nn(b,x)}else{if(!ii[b])throw Error(`Types doesn't contain name = ${b}`);_=ii[b]}let x=[];for(;ve.outputDefined())}}let ci={"to-boolean":gn,"to-color":_n,"to-number":mn,"to-string":hn};class He{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error(`Expected at least one argument.`);let _=e[0];if(!ci[_])throw Error(`Can't parse ${_} as it is not part of the known types`);if((_===`to-boolean`||_===`to-string`)&&e.length!==2)return r.error(`Expected one argument.`);let v=ci[_],b=[];for(let _=1;_4?`Invalid rgba value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:Gr(r[0],r[1],r[2],r[3]),!_))return new Ee(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new Ve(_||`Could not parse color from value '${typeof r==`string`?r:JSON.stringify(r)}'`)}case`padding`:{let r;for(let _ of this.args){r=_.evaluate(e);let v=ze.parse(r);if(v)return v}throw new Ve(`Could not parse padding from value '${typeof r==`string`?r:JSON.stringify(r)}'`)}case`numberArray`:{let r;for(let _ of this.args){r=_.evaluate(e);let v=Be.parse(r);if(v)return v}throw new Ve(`Could not parse numberArray from value '${typeof r==`string`?r:JSON.stringify(r)}'`)}case`colorArray`:{let r;for(let _ of this.args){r=_.evaluate(e);let v=Ce.parse(r);if(v)return v}throw new Ve(`Could not parse colorArray from value '${typeof r==`string`?r:JSON.stringify(r)}'`)}case`variableAnchorOffsetCollection`:{let r;for(let _ of this.args){r=_.evaluate(e);let v=Oe.parse(r);if(v)return v}throw new Ve(`Could not parse variableAnchorOffsetCollection from value '${typeof r==`string`?r:JSON.stringify(r)}'`)}case`number`:{let r=null;for(let _ of this.args){if(r=_.evaluate(e),r===null)return 0;let v=Number(r);if(!isNaN(v))return v}throw new Ve(`Could not convert ${JSON.stringify(r)} to number.`)}case`formatted`:return De.fromString(ri(this.args[0].evaluate(e)));case`resolvedImage`:return $e.fromString(ri(this.args[0].evaluate(e)));case`projectionDefinition`:return this.args[0].evaluate(e);default:return ri(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}let ui=[`Unknown`,`Point`,`LineString`,`Polygon`];class Ke{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=/* @__PURE__ */ new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&`id`in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type==`number`?ui[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&`geometry`in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let r=this._parseColorCache.get(e);return r||(r=Ee.parse(e),this._parseColorCache.set(e,r)),r}}class Je{constructor(e,r,_=[],v,b=new Ct,x=[]){this.registry=e,this.path=_,this.key=_.map(e=>`[${e}]`).join(``),this.scope=b,this.errors=x,this.expectedType=v,this._isConstant=r}parse(e,r,_,v,b={}){return r?this.concat(r,_,v)._parse(e,b):this._parse(e,b)}_parse(e,r){function _(e,r,_){return _===`assert`?new Ye(r,[e]):_===`coerce`?new He(r,[e]):e}if(e!==null&&typeof e!=`string`&&typeof e!=`boolean`&&typeof e!=`number`||(e=[`literal`,e]),Array.isArray(e)){if(e.length===0)return this.error(`Expected an array with at least one element. If you wanted a literal array, use ["literal", []].`);let v=e[0];if(typeof v!=`string`)return this.error(`Expression name must be a string, but found ${typeof v} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let b=this.registry[v];if(b){let v=b.parse(e,this);if(!v)return null;if(this.expectedType){let e=this.expectedType,b=v.type;if(e.kind!==`string`&&e.kind!==`number`&&e.kind!==`boolean`&&e.kind!==`object`&&e.kind!==`array`||b.kind!==`value`){if(e.kind===`projectionDefinition`&&[`string`,`array`].includes(b.kind)||[`color`,`formatted`,`resolvedImage`].includes(e.kind)&&[`value`,`string`].includes(b.kind)||[`padding`,`numberArray`].includes(e.kind)&&[`value`,`number`,`array`].includes(b.kind)||e.kind===`colorArray`&&[`value`,`string`,`array`].includes(b.kind)||e.kind===`variableAnchorOffsetCollection`&&[`value`,`array`].includes(b.kind))v=_(v,e,r.typeAnnotation||`coerce`);else if(this.checkSubtype(e,b))return null}else v=_(v,e,r.typeAnnotation||`assert`)}if(!(v instanceof Ge)&&v.type.kind!==`resolvedImage`&&this._isConstant(v)){let e=new Ke;try{v=new Ge(v.type,v.evaluate(e))}catch(e){return this.error(e.message),null}}return v}return this.error(`Unknown expression "${v}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?`'undefined' value invalid. Use null instead.`:typeof e==`object`?`Bare objects invalid. Use ["literal", {...}] instead.`:`Expected an array, but found ${typeof e} instead.`)}concat(e,r,_){let v=typeof e==`number`?this.path.concat(e):this.path,b=_?this.scope.concat(_):this.scope;return new Je(this.registry,this._isConstant,v,r||null,b,this.errors)}error(e,...r){let _=`${this.key}${r.map(e=>`[${e}]`).join(``)}`;this.errors.push(new Bt(_,e))}checkSubtype(e,r){let _=Rn(e,r);return _&&this.error(_),_}}class Qe{constructor(e,r){this.type=r.type,this.bindings=[].concat(e),this.result=r}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(let r of this.bindings)e(r[1]);e(this.result)}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);let _=[];for(let v=1;v=_.length)throw new Ve(`Array index out of bounds: ${r} > ${_.length-1}.`);if(r!==Math.floor(r))throw new Ve(`Array index must be an integer, but found ${r} instead.`);return _[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class nn{constructor(e,r){this.type=gn,this.needle=e,this.haystack=r}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let _=r.parse(e[1],1,Sn),v=r.parse(e[2],2,Sn);return _&&v?zn(_.type,[gn,hn,mn,pn,Sn])?new nn(_,v):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${In(_.type)} instead`):null}evaluate(e){let r=this.needle.evaluate(e),_=this.haystack.evaluate(e);if(!_)return!1;if(!Bn(r,[`boolean`,`string`,`number`,`null`]))throw new Ve(`Expected first argument to be of type boolean, string, number or null, but found ${In(ei(r))} instead.`);if(!Bn(_,[`string`,`array`]))throw new Ve(`Expected second argument to be of type array or string, but found ${In(ei(_))} instead.`);return _.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class rn{constructor(e,r,_){this.type=mn,this.needle=e,this.haystack=r,this.fromIndex=_}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);let _=r.parse(e[1],1,Sn),v=r.parse(e[2],2,Sn);if(!_||!v)return null;if(!zn(_.type,[gn,hn,mn,pn,Sn]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${In(_.type)} instead`);if(e.length===4){let b=r.parse(e[3],3,mn);return b?new rn(_,v,b):null}return new rn(_,v)}evaluate(e){let r=this.needle.evaluate(e),_=this.haystack.evaluate(e);if(!Bn(r,[`boolean`,`string`,`number`,`null`]))throw new Ve(`Expected first argument to be of type boolean, string, number or null, but found ${In(ei(r))} instead.`);let v;if(this.fromIndex&&(v=this.fromIndex.evaluate(e)),Bn(_,[`string`])){let e=_.indexOf(r,v);return e===-1?-1:[..._.slice(0,e)].length}if(Bn(_,[`array`]))return _.indexOf(r,v);throw new Ve(`Expected second argument to be of type array or string, but found ${In(ei(_))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class sn{constructor(e,r,_,v,b,x){this.inputType=e,this.type=r,this.input=_,this.cases=v,this.outputs=b,this.otherwise=x}static parse(e,r){if(e.length<5)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return r.error(`Expected an even number of arguments.`);let _,v;r.expectedType&&r.expectedType.kind!==`value`&&(v=r.expectedType);let b={},x=[];for(let C=2;C2**53-1)return D.error(`Branch labels must be integers no larger than ${2**53-1}.`);if(typeof e==`number`&&Math.floor(e)!==e)return D.error(`Numeric branch labels must be integer values.`);if(_){if(D.checkSubtype(_,ei(e)))return null}else _=ei(e);if(b[String(e)]!==void 0)return D.error(`Branch labels must be unique.`);b[String(e)]=x.length}let O=r.parse(E,C,v);if(!O)return null;v||=O.type,x.push(O)}let C=r.parse(e[1],1,Sn);if(!C)return null;let T=r.parse(e[e.length-1],e.length-1,v);return T?C.type.kind!==`value`&&r.concat(1).checkSubtype(_,C.type)?null:new sn(_,v,C,b,x,T):null}evaluate(e){let r=this.input.evaluate(e);return(ei(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}}class on{constructor(e,r,_){this.type=e,this.branches=r,this.otherwise=_}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error(`Expected an odd number of arguments.`);let _;r.expectedType&&r.expectedType.kind!==`value`&&(_=r.expectedType);let v=[];for(let b=1;br.outputDefined())&&this.otherwise.outputDefined()}}class an{constructor(e,r,_,v){this.type=e,this.input=r,this.beginIndex=_,this.endIndex=v}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);let _=r.parse(e[1],1,Sn),v=r.parse(e[2],2,mn);if(!_||!v)return null;if(!zn(_.type,[Nn(Sn),hn,Sn]))return r.error(`Expected first argument to be of type array or string, but found ${In(_.type)} instead`);if(e.length===4){let b=r.parse(e[3],3,mn);return b?new an(_.type,_,v,b):null}return new an(_.type,_,v)}evaluate(e){let r=this.input.evaluate(e),_=this.beginIndex.evaluate(e),v;if(this.endIndex&&(v=this.endIndex.evaluate(e)),Bn(r,[`string`]))return[...r].slice(_,v).join(``);if(Bn(r,[`array`]))return r.slice(_,v);throw new Ve(`Expected first argument to be of type array or string, but found ${In(ei(r))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function di(e,r){let _=e.length-1,v,b,x=0,C=_,T=0;for(;x<=C;)if(T=Math.floor((x+C)/2),v=e[T],b=e[T+1],v<=r){if(T===_||rr))throw new Ve(`Input is not a number.`);C=T-1}return 0}class un{constructor(e,r,_){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(let[e,r]of _)this.labels.push(e),this.outputs.push(r)}static parse(e,r){if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error(`Expected an even number of arguments.`);let _=r.parse(e[1],1,mn);if(!_)return null;let v=[],b=null;r.expectedType&&r.expectedType.kind!==`value`&&(b=r.expectedType);for(let _=1;_=x)return r.error(`Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.`,T);let D=r.parse(C,E,b);if(!D)return null;b||=D.type,v.push([x,D])}return new un(b,_,v)}evaluate(e){let r=this.labels,_=this.outputs;if(r.length===1)return _[0].evaluate(e);let v=this.input.evaluate(e);if(v<=r[0])return _[0].evaluate(e);let b=r.length;return v>=r[b-1]?_[b-1].evaluate(e):_[di(r,v)].evaluate(e)}eachChild(e){e(this.input);for(let r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function fi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var pi,mi,gi=fi(function(){if(mi)return pi;function r(r,_,v,b){(this||e).cx=3*r,(this||e).bx=3*(v-r)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*_,(this||e).by=3*(b-_)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=r,(this||e).p1y=_,(this||e).p2x=v,(this||e).p2y=b}return mi=1,pi=r,r.prototype={sampleCurveX:function(r){return(((this||e).ax*r+(this||e).bx)*r+(this||e).cx)*r},sampleCurveY:function(r){return(((this||e).ay*r+(this||e).by)*r+(this||e).cy)*r},sampleCurveDerivativeX:function(r){return(3*(this||e).ax*r+2*(this||e).bx)*r+(this||e).cx},solveCurveX:function(e,r){if(r===void 0&&(r=1e-6),e<0)return 0;if(e>1)return 1;for(var _=e,v=0;v<8;v++){var b=this.sampleCurveX(_)-e;if(Math.abs(b)b?C=_:T=_,_=.5*(T-C)+C;return _},solve:function(e,r){return this.sampleCurveY(this.solveCurveX(e,r))}},pi}());class yn{constructor(e,r,_,v,b){this.type=e,this.operator=r,this.interpolation=_,this.input=v,this.labels=[],this.outputs=[];for(let[e,r]of b)this.labels.push(e),this.outputs.push(r)}static interpolationFactor(e,r,_,v){let b=0;if(e.name===`exponential`)b=_i(r,e.base,_,v);else if(e.name===`linear`)b=_i(r,1,_,v);else if(e.name===`cubic-bezier`){let x=e.controlPoints;b=new gi(x[0],x[1],x[2],x[3]).solve(_i(r,1,_,v))}return b}static parse(e,r){let[_,v,b,...x]=e;if(!Array.isArray(v)||v.length===0)return r.error(`Expected an interpolation type expression.`,1);if(v[0]===`linear`)v={name:`linear`};else if(v[0]===`exponential`){let e=v[1];if(typeof e!=`number`)return r.error(`Exponential interpolation requires a numeric base.`,1,1);v={name:`exponential`,base:e}}else{if(v[0]!==`cubic-bezier`)return r.error(`Unknown interpolation type ${String(v[0])}`,1,0);{let e=v.slice(1);if(e.length!==4||e.some(e=>typeof e!=`number`||e<0||e>1))return r.error(`Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.`,1);v={name:`cubic-bezier`,controlPoints:e}}}if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error(`Expected an even number of arguments.`);if(b=r.parse(b,2,mn),!b)return null;let C=[],T=null;_!==`interpolate-hcl`&&_!==`interpolate-lab`||r.expectedType==kn?r.expectedType&&r.expectedType.kind!==`value`&&(T=r.expectedType):T=_n;for(let e=0;e=_)return r.error(`Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.`,b);let D=r.parse(v,E,T);if(!D)return null;T||=D.type,C.push([_,D])}return Vn(T,mn)||Vn(T,vn)||Vn(T,_n)||Vn(T,On)||Vn(T,An)||Vn(T,kn)||Vn(T,Mn)||Vn(T,Nn(mn))?new yn(T,_,v,b,C):r.error(`Type ${In(T)} is not interpolatable.`)}evaluate(e){let r=this.labels,_=this.outputs;if(r.length===1)return _[0].evaluate(e);let v=this.input.evaluate(e);if(v<=r[0])return _[0].evaluate(e);let b=r.length;if(v>=r[b-1])return _[b-1].evaluate(e);let x=di(r,v),C=yn.interpolationFactor(this.interpolation,v,r[x],r[x+1]),T=_[x].evaluate(e),E=_[x+1].evaluate(e);switch(this.operator){case`interpolate`:switch(this.type.kind){case`number`:return Lr(T,E,C);case`color`:return Ee.interpolate(T,E,C);case`padding`:return ze.interpolate(T,E,C);case`colorArray`:return Ce.interpolate(T,E,C);case`numberArray`:return Be.interpolate(T,E,C);case`variableAnchorOffsetCollection`:return Oe.interpolate(T,E,C);case`array`:return Rr(T,E,C);case`projectionDefinition`:return Re.interpolate(T,E,C)}case`interpolate-hcl`:switch(this.type.kind){case`color`:return Ee.interpolate(T,E,C,`hcl`);case`colorArray`:return Ce.interpolate(T,E,C,`hcl`)}case`interpolate-lab`:switch(this.type.kind){case`color`:return Ee.interpolate(T,E,C,`lab`);case`colorArray`:return Ce.interpolate(T,E,C,`lab`)}}}eachChild(e){e(this.input);for(let r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function _i(e,r,_,v){let b=v-_,x=e-_;return b===0?0:r===1?x/b:(r**+x-1)/(r**+b-1)}let vi={color:Ee.interpolate,number:Lr,padding:ze.interpolate,numberArray:Be.interpolate,colorArray:Ce.interpolate,variableAnchorOffsetCollection:Oe.interpolate,array:Rr};class xn{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error(`Expected at least one argument.`);let _=null,v=r.expectedType;v&&v.kind!==`value`&&(_=v);let b=[];for(let v of e.slice(1)){let e=r.parse(v,1+b.length,_,void 0,{typeAnnotation:`omit`});if(!e)return null;_||=e.type,b.push(e)}if(!_)throw Error(`No output type`);return new xn(v&&b.some(e=>Rn(v,e.type))?Sn:_,b)}evaluate(e){let r,_=null,v=0;for(let b of this.args)if(v++,_=b.evaluate(e),_&&_ instanceof $e&&!_.available&&(r||=_.name,_=null,v===this.args.length&&(_=r)),_!==null)break;return _}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}function bi(e,r){return e===`==`||e===`!=`?r.kind===`boolean`||r.kind===`string`||r.kind===`number`||r.kind===`null`||r.kind===`value`:r.kind===`string`||r.kind===`number`||r.kind===`value`}function xi(e,r,_,v){return v.compare(r,_)===0}function Ti(e,r,_){let v=e!==`==`&&e!==`!=`;return class i{constructor(e,r,_){this.type=gn,this.lhs=e,this.rhs=r,this.collator=_,this.hasUntypedArgument=e.type.kind===`value`||r.type.kind===`value`}static parse(e,r){if(e.length!==3&&e.length!==4)return r.error(`Expected two or three arguments.`);let _=e[0],b=r.parse(e[1],1,Sn);if(!b)return null;if(!bi(_,b.type))return r.concat(1).error(`"${_}" comparisons are not supported for type '${In(b.type)}'.`);let x=r.parse(e[2],2,Sn);if(!x)return null;if(!bi(_,x.type))return r.concat(2).error(`"${_}" comparisons are not supported for type '${In(x.type)}'.`);if(b.type.kind!==x.type.kind&&b.type.kind!==`value`&&x.type.kind!==`value`)return r.error(`Cannot compare types '${In(b.type)}' and '${In(x.type)}'.`);v&&(b.type.kind===`value`&&x.type.kind!==`value`?b=new Ye(x.type,[b]):b.type.kind!==`value`&&x.type.kind===`value`&&(x=new Ye(b.type,[x])));let C=null;if(e.length===4){if(b.type.kind!==`string`&&x.type.kind!==`string`&&b.type.kind!==`value`&&x.type.kind!==`value`)return r.error(`Cannot use collator to compare non-string types.`);if(C=r.parse(e[3],3,Cn),!C)return null}return new i(b,x,C)}evaluate(b){let x=this.lhs.evaluate(b),C=this.rhs.evaluate(b);if(v&&this.hasUntypedArgument){let r=ei(x),_=ei(C);if(r.kind!==_.kind||r.kind!==`string`&&r.kind!==`number`)throw new Ve(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${r.kind}, ${_.kind}) instead.`)}if(this.collator&&!v&&this.hasUntypedArgument){let e=ei(x),_=ei(C);if(e.kind!==`string`||_.kind!==`string`)return r(b,x,C)}return this.collator?_(b,x,C,this.collator.evaluate(b)):r(b,x,C)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}let Di=Ti(`==`,function(e,r,_){return r===_},xi),Oi=Ti(`!=`,function(e,r,_){return r!==_},function(e,r,_,v){return!xi(0,r,_,v)}),Ni=Ti(`<`,function(e,r,_){return r<_},function(e,r,_,v){return v.compare(r,_)<0}),Pi=Ti(`>`,function(e,r,_){return r>_},function(e,r,_,v){return v.compare(r,_)>0}),Fi=Ti(`<=`,function(e,r,_){return r<=_},function(e,r,_,v){return v.compare(r,_)<=0}),Ii=Ti(`>=`,function(e,r,_){return r>=_},function(e,r,_,v){return v.compare(r,_)>=0});class En{constructor(e,r,_){this.type=Cn,this.locale=_,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error(`Expected one argument.`);let _=e[1];if(typeof _!=`object`||Array.isArray(_))return r.error(`Collator options argument must be an object.`);let v=r.parse(_[`case-sensitive`]!==void 0&&_[`case-sensitive`],1,gn);if(!v)return null;let b=r.parse(_[`diacritic-sensitive`]!==void 0&&_[`diacritic-sensitive`],1,gn);if(!b)return null;let x=null;return _.locale&&(x=r.parse(_.locale,1,hn),!x)?null:new En(v,b,x)}evaluate(e){return new Te(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class Tn{constructor(e,r,_,v,b,x){this.type=hn,this.number=e,this.locale=r,this.currency=_,this.unit=v,this.minFractionDigits=b,this.maxFractionDigits=x}static parse(e,r){if(e.length!==3)return r.error(`Expected two arguments.`);let _=r.parse(e[1],1,mn);if(!_)return null;let v=e[2];if(typeof v!=`object`||Array.isArray(v))return r.error(`NumberFormat options argument must be an object.`);let b=null;if(v.locale&&(b=r.parse(v.locale,1,hn),!b))return null;let x=null;if(v.currency&&(x=r.parse(v.currency,1,hn),!x))return null;let C=null;if(v.unit&&(C=r.parse(v.unit,1,hn),!C))return null;if(x&&C)return r.error("NumberFormat options `currency` and `unit` are mutually exclusive");let T=null;if(v[`min-fraction-digits`]&&(T=r.parse(v[`min-fraction-digits`],1,mn),!T))return null;let E=null;return v[`max-fraction-digits`]&&(E=r.parse(v[`max-fraction-digits`],1,mn),!E)?null:new Tn(_,b,x,C,T,E)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?`currency`:this.unit?`unit`:`decimal`,currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Fn{constructor(e){this.type=wn,this.sections=e}static parse(e,r){if(e.length<2)return r.error(`Expected at least one argument.`);let _=e[1];if(!Array.isArray(_)&&typeof _==`object`)return r.error(`First argument must be an image or text section.`);let v=[],b=!1;for(let _=1;_<=e.length-1;++_){let x=e[_];if(b&&typeof x==`object`&&!Array.isArray(x)){b=!1;let e=null;if(x[`font-scale`]&&(e=r.parse(x[`font-scale`],1,mn),!e))return null;let _=null;if(x[`text-font`]&&(_=r.parse(x[`text-font`],1,Nn(hn)),!_))return null;let C=null;if(x[`text-color`]&&(C=r.parse(x[`text-color`],1,_n),!C))return null;let T=null;if(x[`vertical-align`]){if(typeof x[`vertical-align`]==`string`&&!Hr.includes(x[`vertical-align`]))return r.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${x[`vertical-align`]}' instead.`);if(T=r.parse(x[`vertical-align`],1,hn),!T)return null}let E=v[v.length-1];E.scale=e,E.font=_,E.textColor=C,E.verticalAlign=T}else{let x=r.parse(e[_],1,Sn);if(!x)return null;let C=x.type.kind;if(C!==`string`&&C!==`value`&&C!==`null`&&C!==`resolvedImage`)return r.error(`Formatted text type must be 'string', 'value', 'image' or 'null'.`);b=!0,v.push({content:x,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Fn(v)}evaluate(e){return new De(this.sections.map(r=>{let _=r.content.evaluate(e);return ei(_)===jn?new Pe(``,_,null,null,null,r.verticalAlign?r.verticalAlign.evaluate(e):null):new Pe(ri(_),null,r.scale?r.scale.evaluate(e):null,r.font?r.font.evaluate(e).join(`,`):null,r.textColor?r.textColor.evaluate(e):null,r.verticalAlign?r.verticalAlign.evaluate(e):null)}))}eachChild(e){for(let r of this.sections)e(r.content),r.scale&&e(r.scale),r.font&&e(r.font),r.textColor&&e(r.textColor),r.verticalAlign&&e(r.verticalAlign)}outputDefined(){return!1}}class Pn{constructor(e){this.type=jn,this.input=e}static parse(e,r){if(e.length!==2)return r.error(`Expected two arguments.`);let _=r.parse(e[1],1,hn);return _?new Pn(_):r.error(`No image name provided.`)}evaluate(e){let r=this.input.evaluate(e),_=$e.fromString(r);return _&&e.availableImages&&(_.available=e.availableImages.indexOf(r)>-1),_}eachChild(e){e(this.input)}outputDefined(){return!1}}class Dn{constructor(e){this.type=mn,this.input=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);let _=r.parse(e[1],1);return _?_.type.kind!==`array`&&_.type.kind!==`string`&&_.type.kind!==`value`?r.error(`Expected argument of type string or array, but found ${In(_.type)} instead.`):new Dn(_):null}evaluate(e){let r=this.input.evaluate(e);if(typeof r==`string`)return[...r].length;if(Array.isArray(r))return r.length;throw new Ve(`Expected value to be of type string or array, but found ${In(ei(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}let Li=8192;function zi(e,r){let _=(180+e[0])/360,v=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,b=2**r.z;return[Math.round(_*b*Li),Math.round(v*b*Li)]}function Bi(e,r){let _=2**r.z;return[(b=(e[0]/Li+r.x)/_,360*b-180),(v=(e[1]/Li+r.y)/_,360/Math.PI*Math.atan(Math.exp((180-360*v)*Math.PI/180))-90)];var v,b}function Vi(e,r){e[0]=Math.min(e[0],r[0]),e[1]=Math.min(e[1],r[1]),e[2]=Math.max(e[2],r[0]),e[3]=Math.max(e[3],r[1])}function Hi(e,r){return!(e[0]<=r[0]||e[2]>=r[2]||e[1]<=r[1]||e[3]>=r[3])}function Ui(e,r,_){let v=e[0]-r[0],b=e[1]-r[1],x=e[0]-_[0],C=e[1]-_[1];return v*C-x*b==0&&v*x<=0&&b*C<=0}function Wi(e,r,_,v){return(b=[v[0]-_[0],v[1]-_[1]])[0]*(x=[r[0]-e[0],r[1]-e[1]])[1]-b[1]*x[0]!=0&&!(!Xi(e,r,_,v)||!Xi(_,v,e,r));var b,x}function Gi(e,r,_){for(let v of _)for(let _=0;_(b=e)[1]!=(C=T[r+1])[1]>b[1]&&b[0]<(C[0]-x[0])*(b[1]-x[1])/(C[1]-x[1])+x[0]&&(v=!v)}var b,x,C;return v}function qi(e,r){for(let _ of r)if(Ki(e,_))return!0;return!1}function Ji(e,r){for(let _ of e)if(!Ki(_,r))return!1;for(let _=0;_0&&T<0||C<0&&T>0}function Zi(e,r,_){let v=[];for(let b=0;b_[2]){let r=.5*v,b=e[0]-_[0]>r?-v:_[0]-e[0]>r?v:0;b===0&&(b=e[0]-_[2]>r?-v:_[2]-e[0]>r?v:0),e[0]+=b}Vi(r,e)}function aa(e,r,_,v){let b=2**v.z*Li,x=[v.x*Li,v.y*Li],C=[];for(let v of e)for(let e of v){let v=[e.x+x[0],e.y+x[1]];$i(v,r,_,b),C.push(v)}return C}function ca(e,r,_,v){let b=2**v.z*Li,x=[v.x*Li,v.y*Li],C=[];for(let _ of e){let e=[];for(let v of _){let _=[v.x+x[0],v.y+x[1]];Vi(r,_),e.push(_)}C.push(e)}if(r[2]-r[0]<=b/2){(T=r)[0]=T[1]=1/0,T[2]=T[3]=-1/0;for(let e of C)for(let v of e)$i(v,r,_,b)}var T;return C}class Kn{constructor(e,r){this.type=gn,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Qr(e[1])){let r=e[1];if(r.type===`FeatureCollection`){let e=[];for(let _ of r.features){let{type:r,coordinates:v}=_.geometry;r===`Polygon`&&e.push(v),r===`MultiPolygon`&&e.push(...v)}if(e.length)return new Kn(r,{type:`MultiPolygon`,coordinates:e})}else if(r.type===`Feature`){let e=r.geometry.type;if(e===`Polygon`||e===`MultiPolygon`)return new Kn(r,r.geometry)}else if(r.type===`Polygon`||r.type===`MultiPolygon`)return new Kn(r,r)}return r.error(`'within' expression requires valid geojson object that contains polygon geometry type.`)}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()===`Point`)return function(e,r){let _=[1/0,1/0,-1/0,-1/0],v=[1/0,1/0,-1/0,-1/0],b=e.canonicalID();if(r.type===`Polygon`){let x=Zi(r.coordinates,v,b),C=aa(e.geometry(),_,v,b);if(!Hi(_,v))return!1;for(let e of C)if(!Ki(e,x))return!1}if(r.type===`MultiPolygon`){let x=Qi(r.coordinates,v,b),C=aa(e.geometry(),_,v,b);if(!Hi(_,v))return!1;for(let e of C)if(!qi(e,x))return!1}return!0}(e,this.geometries);if(e.geometryType()===`LineString`)return function(e,r){let _=[1/0,1/0,-1/0,-1/0],v=[1/0,1/0,-1/0,-1/0],b=e.canonicalID();if(r.type===`Polygon`){let x=Zi(r.coordinates,v,b),C=ca(e.geometry(),_,v,b);if(!Hi(_,v))return!1;for(let e of C)if(!Ji(e,x))return!1}if(r.type===`MultiPolygon`){let x=Qi(r.coordinates,v,b),C=ca(e.geometry(),_,v,b);if(!Hi(_,v))return!1;for(let e of C)if(!Yi(e,x))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Jn=class{constructor(e=[],r=(e,r)=>er?1:0){if(this.data=e,this.length=this.data.length,this.compare=r,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:r,compare:_}=this,v=r[e];for(;e>0;){let b=e-1>>1,x=r[b];if(_(v,x)>=0)break;r[e]=x,e=b}r[e]=v}_down(e){let{data:r,compare:_}=this,v=this.length>>1,b=r[e];for(;e=0)break;r[e]=r[v],e=v}r[e]=b}};function ua(e,r,_=0,v=e.length-1,b=fa){for(;v>_;){if(v-_>600){let x=v-_+1,C=r-_+1,T=Math.log(x),E=.5*Math.exp(2*T/3),D=.5*Math.sqrt(T*E*(x-E)/x)*(C-x/2<0?-1:1);ua(e,r,Math.max(_,Math.floor(r-C*E/x+D)),Math.min(v,Math.floor(r+(x-C)*E/x+D)),b)}let x=e[r],C=_,T=v;for(da(e,_,r),b(e[v],x)>0&&da(e,_,v);C0;)T--}b(e[_],x)===0?da(e,_,T):(T++,da(e,T,v)),T<=r&&(_=T+1),r<=T&&(v=T-1)}}function da(e,r,_){let v=e[r];e[r]=e[_],e[_]=v}function fa(e,r){return er?1:0}function pa(e,r){if(e.length<=1)return[e];let _=[],v,b;for(let r of e){let e=ha(r);e!==0&&(r.area=Math.abs(e),b===void 0&&(b=e<0),b===e<0?(v&&_.push(v),v=[r]):v.push(r))}if(v&&_.push(v),r>1)for(let e=0;e<_.length;e++)_[e].length<=r||(ua(_[e],r,1,_[e].length-1,ma),_[e]=_[e].slice(0,r));return _}function ma(e,r){return r.area-e.area}function ha(e){let r=0;for(let _,v,b=0,x=e.length,C=x-1;b1?(E=e[T+1][0],D=e[T+1][1]):A>0&&(E+=O/this.kx*A,D+=k/this.ky*A)),O=this.wrap(r[0]-E)*this.kx,k=(r[1]-D)*this.ky;let j=O*O+k*k;j180;)e-=360;return e}}function ya(e,r){return r[0]-e[0]}function xa(e){return e[1]-e[0]+1}function Sa(e,r){return e[1]>=e[0]&&e[1]e[1])return[null,null];let _=xa(e);if(r){if(_===2)return[e,null];let r=Math.floor(_/2);return[[e[0],e[0]+r],[e[0]+r,e[1]]]}if(_===1)return[e,null];let v=Math.floor(_/2)-1;return[[e[0],e[0]+v],[e[0]+v+1,e[1]]]}function Ta(e,r){if(!Sa(r,e.length))return[1/0,1/0,-1/0,-1/0];let _=[1/0,1/0,-1/0,-1/0];for(let v=r[0];v<=r[1];++v)Vi(_,e[v]);return _}function Ea(e){let r=[1/0,1/0,-1/0,-1/0];for(let _ of e)for(let e of _)Vi(r,e);return r}function ja(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function Na(e,r,_){if(!ja(e)||!ja(r))return NaN;let v=0,b=0;return e[2]r[2]&&(v=e[0]-r[2]),e[1]>r[3]&&(b=e[1]-r[3]),e[3]=v)return v;if(Hi(b,x)){if(Xa(e,r))return 0}else if(Xa(r,e))return 0;let C=1/0;for(let v of e)for(let e=0,b=v.length,x=b-1;e0;){let b=C.pop();if(b[0]>=x)continue;let E=b[1],D=r?50:100;if(xa(E)<=D){if(!Sa(E,e.length))return NaN;if(r){let r=Ka(e,E,_,v);if(isNaN(r)||r===0)return r;x=Math.min(x,r)}else for(let r=E[0];r<=E[1];++r){let b=Ga(e[r],_,v);if(x=Math.min(x,b),x===0)return 0}}else{let _=wa(E,r);Qa(C,x,v,e,T,_[0]),Qa(C,x,v,e,T,_[1])}}return x}function to(e,r,_,v,b,x=1/0){let C=Math.min(x,b.distance(e[0],_[0]));if(C===0)return C;let T=new Jn([[0,[0,e.length-1],[0,_.length-1]]],ya);for(;T.length>0;){let x=T.pop();if(x[0]>=C)continue;let E=x[1],D=x[2],O=r?50:100,k=v?50:100;if(xa(E)<=O&&xa(D)<=k){if(!Sa(E,e.length)&&Sa(D,_.length))return NaN;let x;if(r&&v)x=Ua(e,E,_,D,b),C=Math.min(C,x);else if(r&&!v){let r=e.slice(E[0],E[1]+1);for(let e=D[0];e<=D[1];++e)if(x=Ra(_[e],r,b),C=Math.min(C,x),C===0)return C}else if(!r&&v){let r=_.slice(D[0],D[1]+1);for(let _=E[0];_<=E[1];++_)if(x=Ra(e[_],r,b),C=Math.min(C,x),C===0)return C}else x=Wa(e,E,_,D,b),C=Math.min(C,x)}else{let x=wa(E,r),O=wa(D,v);$a(T,C,b,e,_,x[0],O[0]),$a(T,C,b,e,_,x[0],O[1]),$a(T,C,b,e,_,x[1],O[0]),$a(T,C,b,e,_,x[1],O[1])}}return C}function ro(e){return e.type===`MultiPolygon`?e.coordinates.map(e=>({type:`Polygon`,coordinates:e})):e.type===`MultiLineString`?e.coordinates.map(e=>({type:`LineString`,coordinates:e})):e.type===`MultiPoint`?e.coordinates.map(e=>({type:`Point`,coordinates:e})):[e]}class Fr{constructor(e,r){this.type=mn,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Qr(e[1])){let r=e[1];if(r.type===`FeatureCollection`)return new Fr(r,r.features.map(e=>ro(e.geometry)).flat());if(r.type===`Feature`)return new Fr(r,ro(r.geometry));if(`type`in r&&`coordinates`in r)return new Fr(r,ro(r))}return r.error(`'distance' expression requires valid geojson object that contains polygon geometry type.`)}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()===`Point`)return function(e,r){let _=e.geometry(),v=_.flat().map(r=>Bi([r.x,r.y],e.canonical));if(_.length===0)return NaN;let b=new lr(v[0][1]),x=1/0;for(let e of r){switch(e.type){case`Point`:x=Math.min(x,to(v,!1,[e.coordinates],!1,b,x));break;case`LineString`:x=Math.min(x,to(v,!1,e.coordinates,!0,b,x));break;case`Polygon`:x=Math.min(x,eo(v,!1,e.coordinates,b,x))}if(x===0)return x}return x}(e,this.geometries);if(e.geometryType()===`LineString`)return function(e,r){let _=e.geometry(),v=_.flat().map(r=>Bi([r.x,r.y],e.canonical));if(_.length===0)return NaN;let b=new lr(v[0][1]),x=1/0;for(let e of r){switch(e.type){case`Point`:x=Math.min(x,to(v,!0,[e.coordinates],!1,b,x));break;case`LineString`:x=Math.min(x,to(v,!0,e.coordinates,!0,b,x));break;case`Polygon`:x=Math.min(x,eo(v,!0,e.coordinates,b,x))}if(x===0)return x}return x}(e,this.geometries);if(e.geometryType()===`Polygon`)return function(e,r){let _=e.geometry();if(_.length===0||_[0].length===0)return NaN;let v=pa(_,0).map(r=>r.map(r=>r.map(r=>Bi([r.x,r.y],e.canonical)))),b=new lr(v[0][0][0][1]),x=1/0;for(let e of r)for(let r of v){switch(e.type){case`Point`:x=Math.min(x,eo([e.coordinates],!1,r,b,x));break;case`LineString`:x=Math.min(x,eo(e.coordinates,!0,r,b,x));break;case`Polygon`:x=Math.min(x,Za(r,e.coordinates,b,x))}if(x===0)return x}return x}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Pr{constructor(e){this.type=Sn,this.key=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);let _=e[1];return _==null?r.error(`Global state property must be defined.`):typeof _==`string`?new Pr(_):r.error(`Global state property must be string, but found ${typeof e[1]} instead.`)}evaluate(e){var r;let _=(r=e.globals)?.globalState;return _&&Object.keys(_).length!==0?br(_,this.key):null}eachChild(){}outputDefined(){return!1}}let ao={"==":Di,"!=":Oi,">":Pi,"<":Ni,">=":Ii,"<=":Fi,array:Ye,at:en,boolean:Ye,case:on,coalesce:xn,collator:En,format:Fn,image:Pn,in:nn,"index-of":rn,interpolate:yn,"interpolate-hcl":yn,"interpolate-lab":yn,length:Dn,let:Qe,literal:Ge,match:sn,number:Ye,"number-format":Tn,object:Ye,slice:an,step:un,string:Ye,"to-boolean":He,"to-color":He,"to-number":He,"to-string":He,var:tn,within:Kn,distance:Fr,"global-state":Pr};class zr{constructor(e,r,_,v){this.name=e,this.type=r,this._evaluate=_,this.args=v}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,r){let _=e[0],v=zr.definitions[_];if(!v)return r.error(`Unknown expression "${_}". If you wanted a literal array, use ["literal", [...]].`,0);let b=Array.isArray(v)?v[0]:v.type,x=Array.isArray(v)?[[v[1],v[2]]]:v.overloads,C=x.filter(([r])=>!Array.isArray(r)||r.length===e.length-1),T=null;for(let[v,x]of C){T=new Je(r.registry,ls,r.path,null,r.scope);let C=[],E=!1;for(let r=1;r{return r=e,Array.isArray(r)?`(${r.map(In).join(`, `)})`:`(${In(r.type)}...)`;var r}).join(` | `),v=[];for(let _=1;_{_=r?_&&ls(e):_&&e instanceof Ge}),!!_&&us(e)&&fs(e,[`zoom`,`heatmap-density`,`elevation`,`line-progress`,`accumulated`,`is-supported-script`])}function us(e){if(e instanceof zr&&(e.name===`get`&&e.args.length===1||e.name===`feature-state`||e.name===`has`&&e.args.length===1||e.name===`properties`||e.name===`geometry-type`||e.name===`id`||/^filter-/.test(e.name))||e instanceof Kn||e instanceof Fr)return!1;let r=!0;return e.eachChild(e=>{r&&!us(e)&&(r=!1)}),r}function ds(e){if(e instanceof zr&&e.name===`feature-state`)return!1;let r=!0;return e.eachChild(e=>{r&&!ds(e)&&(r=!1)}),r}function fs(e,r){if(e instanceof zr&&r.indexOf(e.name)>=0)return!1;let _=!0;return e.eachChild(e=>{_&&!fs(e,r)&&(_=!1)}),_}function ms(e){return{result:`success`,value:e}}function gs(e){return{result:`error`,value:e}}function _s(e){return e[`property-type`]===`data-driven`||e[`property-type`]===`cross-faded-data-driven`}function ys(e){return!!e.expression&&e.expression.parameters.indexOf(`zoom`)>-1}function bs(e){return!!e.expression&&e.expression.interpolated}function xs(e){return e instanceof Number?`number`:e instanceof String?`string`:e instanceof Boolean?`boolean`:Array.isArray(e)?`array`:e===null?`null`:typeof e}function Ss(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&ei(e)===bn}function Cs(e){return e}function ws(e,r){let _=e.stops&&typeof e.stops[0][0]==`object`,v=_||!(_||e.property!==void 0),b=e.type||(bs(r)?`exponential`:`interval`),x=function(e){switch(e.type){case`color`:return Ee.parse;case`padding`:return ze.parse;case`numberArray`:return Be.parse;case`colorArray`:return Ce.parse;default:return null}}(r);if(x&&((e=fn({},e)).stops&&(e.stops=e.stops.map(e=>[e[0],x(e[1])])),e.default=x(e.default?e.default:r.default)),e.colorSpace&&(C=e.colorSpace)!==`rgb`&&C!==`hcl`&&C!==`lab`)throw Error(`Unknown color space: "${e.colorSpace}"`);var C;let T=function(e){switch(e){case`exponential`:return ks;case`interval`:return Ds;case`categorical`:return Es;case`identity`:return As;default:throw Error(`Unknown function type "${e}"`)}}(b),E,D;if(b===`categorical`){E=Object.create(null);for(let r of e.stops)E[r[0]]=r[1];D=typeof e.stops[0][0]}if(_){let _={},v=[];for(let r=0;re[0]),evaluate:({zoom:_},v)=>ks({stops:b,base:e.base},r,_).evaluate(_,v)}}if(v){let _=b===`exponential`?{name:`exponential`,base:e.base===void 0?1:e.base}:null;return{kind:`camera`,interpolationType:_,interpolationFactor:yn.interpolationFactor.bind(void 0,_),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:_})=>T(e,r,_,E,D)}}return{kind:`source`,evaluate(_,v){let b=v&&v.properties?v.properties[e.property]:void 0;return b===void 0?Ts(e.default,r.default):T(e,r,b,E,D)}}}function Ts(e,r,_){return e===void 0?r===void 0?_===void 0?void 0:_:r:e}function Es(e,r,_,v,b){return Ts(typeof _===b?v[_]:void 0,e.default,r.default)}function Ds(e,r,_){if(xs(_)!==`number`)return Ts(e.default,r.default);let v=e.stops.length;if(v===1||_<=e.stops[0][0])return e.stops[0][1];if(_>=e.stops[v-1][0])return e.stops[v-1][1];let b=di(e.stops.map(e=>e[0]),_);return e.stops[b][1]}function ks(e,r,_){let v=e.base===void 0?1:e.base;if(xs(_)!==`number`)return Ts(e.default,r.default);let b=e.stops.length;if(b===1||_<=e.stops[0][0])return e.stops[0][1];if(_>=e.stops[b-1][0])return e.stops[b-1][1];let x=di(e.stops.map(e=>e[0]),_),C=function(e,r,_,v){let b=v-_,x=e-_;return b===0?0:r===1?x/b:(r**+x-1)/(r**+b-1)}(_,v,e.stops[x][0],e.stops[x+1][0]),T=e.stops[x][1],E=e.stops[x+1][1],D=vi[r.type]||Cs;return typeof T.evaluate==`function`?{evaluate(...r){let _=T.evaluate.apply(void 0,r),v=E.evaluate.apply(void 0,r);if(_!==void 0&&v!==void 0)return D(_,v,C,e.colorSpace)}}:D(T,E,C,e.colorSpace)}function As(e,r,_){switch(r.type){case`color`:_=Ee.parse(_);break;case`formatted`:_=De.fromString(_.toString());break;case`resolvedImage`:_=$e.fromString(_.toString());break;case`padding`:_=ze.parse(_);break;case`colorArray`:_=Ce.parse(_);break;case`numberArray`:_=Be.parse(_);break;default:xs(_)===r.type||r.type===`enum`&&r.values[_]||(_=void 0)}return Ts(_,e.default,r.default)}zr.register(ao,{error:[{kind:`error`},[hn],(e,[r])=>{throw new Ve(r.evaluate(e))}],typeof:[hn,[Sn],(e,[r])=>In(ei(r.evaluate(e)))],"to-rgba":[Nn(mn,4),[_n],(e,[r])=>{let[_,v,b,x]=r.evaluate(e).rgb;return[255*_,255*v,255*b,x]}],rgb:[_n,[mn,mn,mn],oo],rgba:[_n,[mn,mn,mn,mn],oo],has:{type:gn,overloads:[[[hn],(e,[r])=>is(r.evaluate(e),e.properties())],[[hn,bn],(e,[r,_])=>is(r.evaluate(e),_.evaluate(e))]]},get:{type:Sn,overloads:[[[hn],(e,[r])=>as(r.evaluate(e),e.properties())],[[hn,bn],(e,[r,_])=>as(r.evaluate(e),_.evaluate(e))]]},"feature-state":[Sn,[hn],(e,[r])=>as(r.evaluate(e),e.featureState||{})],properties:[bn,[],e=>e.properties()],"geometry-type":[hn,[],e=>e.geometryType()],id:[Sn,[],e=>e.id()],zoom:[mn,[],e=>e.globals.zoom],"heatmap-density":[mn,[],e=>e.globals.heatmapDensity||0],elevation:[mn,[],e=>e.globals.elevation||0],"line-progress":[mn,[],e=>e.globals.lineProgress||0],accumulated:[Sn,[],e=>e.globals.accumulated===void 0?null:e.globals.accumulated],"+":[mn,ss(mn),(e,r)=>{let _=0;for(let v of r)_+=v.evaluate(e);return _}],"*":[mn,ss(mn),(e,r)=>{let _=1;for(let v of r)_*=v.evaluate(e);return _}],"-":{type:mn,overloads:[[[mn,mn],(e,[r,_])=>r.evaluate(e)-_.evaluate(e)],[[mn],(e,[r])=>-r.evaluate(e)]]},"/":[mn,[mn,mn],(e,[r,_])=>r.evaluate(e)/_.evaluate(e)],"%":[mn,[mn,mn],(e,[r,_])=>r.evaluate(e)%_.evaluate(e)],ln2:[mn,[],()=>Math.LN2],pi:[mn,[],()=>Math.PI],e:[mn,[],()=>Math.E],"^":[mn,[mn,mn],(e,[r,_])=>r.evaluate(e)**+_.evaluate(e)],sqrt:[mn,[mn],(e,[r])=>Math.sqrt(r.evaluate(e))],log10:[mn,[mn],(e,[r])=>Math.log(r.evaluate(e))/Math.LN10],ln:[mn,[mn],(e,[r])=>Math.log(r.evaluate(e))],log2:[mn,[mn],(e,[r])=>Math.log(r.evaluate(e))/Math.LN2],sin:[mn,[mn],(e,[r])=>Math.sin(r.evaluate(e))],cos:[mn,[mn],(e,[r])=>Math.cos(r.evaluate(e))],tan:[mn,[mn],(e,[r])=>Math.tan(r.evaluate(e))],asin:[mn,[mn],(e,[r])=>Math.asin(r.evaluate(e))],acos:[mn,[mn],(e,[r])=>Math.acos(r.evaluate(e))],atan:[mn,[mn],(e,[r])=>Math.atan(r.evaluate(e))],min:[mn,ss(mn),(e,r)=>Math.min(...r.map(r=>r.evaluate(e)))],max:[mn,ss(mn),(e,r)=>Math.max(...r.map(r=>r.evaluate(e)))],abs:[mn,[mn],(e,[r])=>Math.abs(r.evaluate(e))],round:[mn,[mn],(e,[r])=>{let _=r.evaluate(e);return _<0?-Math.round(-_):Math.round(_)}],floor:[mn,[mn],(e,[r])=>Math.floor(r.evaluate(e))],ceil:[mn,[mn],(e,[r])=>Math.ceil(r.evaluate(e))],"filter-==":[gn,[hn,Sn],(e,[r,_])=>e.properties()[r.value]===_.value],"filter-id-==":[gn,[Sn],(e,[r])=>e.id()===r.value],"filter-type-==":[gn,[hn],(e,[r])=>e.geometryType()===r.value],"filter-<":[gn,[hn,Sn],(e,[r,_])=>{let v=e.properties()[r.value],b=_.value;return typeof v==typeof b&&v{let _=e.id(),v=r.value;return typeof _==typeof v&&_":[gn,[hn,Sn],(e,[r,_])=>{let v=e.properties()[r.value],b=_.value;return typeof v==typeof b&&v>b}],"filter-id->":[gn,[Sn],(e,[r])=>{let _=e.id(),v=r.value;return typeof _==typeof v&&_>v}],"filter-<=":[gn,[hn,Sn],(e,[r,_])=>{let v=e.properties()[r.value],b=_.value;return typeof v==typeof b&&v<=b}],"filter-id-<=":[gn,[Sn],(e,[r])=>{let _=e.id(),v=r.value;return typeof _==typeof v&&_<=v}],"filter->=":[gn,[hn,Sn],(e,[r,_])=>{let v=e.properties()[r.value],b=_.value;return typeof v==typeof b&&v>=b}],"filter-id->=":[gn,[Sn],(e,[r])=>{let _=e.id(),v=r.value;return typeof _==typeof v&&_>=v}],"filter-has":[gn,[Sn],(e,[r])=>r.value in e.properties()],"filter-has-id":[gn,[],e=>e.id()!==null&&e.id()!==void 0],"filter-type-in":[gn,[Nn(hn)],(e,[r])=>r.value.indexOf(e.geometryType())>=0],"filter-id-in":[gn,[Nn(Sn)],(e,[r])=>r.value.indexOf(e.id())>=0],"filter-in-small":[gn,[hn,Nn(Sn)],(e,[r,_])=>_.value.indexOf(e.properties()[r.value])>=0],"filter-in-large":[gn,[hn,Nn(Sn)],(e,[r,_])=>function(e,r,_,v){for(;_<=v;){let b=_+v>>1;if(r[b]===e)return!0;r[b]>e?v=b-1:_=b+1}return!1}(e.properties()[r.value],_.value,0,_.value.length-1)],all:{type:gn,overloads:[[[gn,gn],(e,[r,_])=>r.evaluate(e)&&_.evaluate(e)],[ss(gn),(e,r)=>{for(let _ of r)if(!_.evaluate(e))return!1;return!0}]]},any:{type:gn,overloads:[[[gn,gn],(e,[r,_])=>r.evaluate(e)||_.evaluate(e)],[ss(gn),(e,r)=>{for(let _ of r)if(_.evaluate(e))return!0;return!1}]]},"!":[gn,[gn],(e,[r])=>!r.evaluate(e)],"is-supported-script":[gn,[hn],(e,[r])=>{let _=e.globals&&e.globals.isSupportedScript;return!_||_(r.evaluate(e))}],upcase:[hn,[hn],(e,[r])=>r.evaluate(e).toUpperCase()],downcase:[hn,[hn],(e,[r])=>r.evaluate(e).toLowerCase()],concat:[hn,ss(Sn),(e,r)=>r.map(r=>ri(r.evaluate(e))).join(``)],split:[Nn(hn),[hn,hn],(e,[r,_])=>r.evaluate(e).split(_.evaluate(e))],join:[hn,[Nn(hn),hn],(e,[r,_])=>r.evaluate(e).join(_.evaluate(e))],"resolved-locale":[hn,[Cn],(e,[r])=>r.evaluate(e).resolvedLocale()]});class ni{constructor(e,r,_){this.expression=e,this._warningHistory={},this._evaluator=new Ke,this._defaultValue=r?function(e){if(e.type===`color`&&Ss(e.default))return new Ee(0,0,0,0);switch(e.type){case`color`:return Ee.parse(e.default)||null;case`padding`:return ze.parse(e.default)||null;case`numberArray`:return Be.parse(e.default)||null;case`colorArray`:return Ce.parse(e.default)||null;case`variableAnchorOffsetCollection`:return Oe.parse(e.default)||null;case`projectionDefinition`:return Re.parse(e.default)||null;default:return e.default===void 0?null:e.default}}(r):null,this._enumValues=r&&r.type===`enum`?r.values:null,this._globalState=_}evaluateWithoutErrorHandling(e,r,_,v,b,x){return this._globalState&&(e=Vs(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=_,this._evaluator.canonical=v,this._evaluator.availableImages=b||null,this._evaluator.formattedSection=x,this.expression.evaluate(this._evaluator)}evaluate(e,r,_,v,b,x){this._globalState&&(e=Vs(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=_||null,this._evaluator.canonical=v,this._evaluator.availableImages=b||null,this._evaluator.formattedSection=x||null;try{let e=this.expression.evaluate(this._evaluator);if(e==null||typeof e==`number`&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Ve(`Expected value to be one of ${Object.keys(this._enumValues).map(e=>JSON.stringify(e)).join(`, `)}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,typeof console<`u`&&console.warn(e.message)),this._defaultValue}}}function Ms(e){return Array.isArray(e)&&e.length>0&&typeof e[0]==`string`&&e[0]in ao}function Ps(e,r,_){let v=new Je(ao,ls,[],r?function(e){let r={color:_n,string:hn,number:mn,enum:hn,boolean:gn,formatted:wn,padding:On,numberArray:An,colorArray:kn,projectionDefinition:vn,resolvedImage:jn,variableAnchorOffsetCollection:Mn};return e.type===`array`?Nn(r[e.value]||Sn,e.length):r[e.type]}(r):void 0),b=v.parse(e,void 0,void 0,void 0,r&&r.type===`string`?{typeAnnotation:`coerce`}:void 0);return b?ms(new ni(b,r,_)):gs(v.errors)}class si{constructor(e,r,_){this.kind=e,this._styleExpression=r,this.isStateDependent=e!==`constant`&&!ds(r.expression),this.globalStateRefs=zs(r.expression),this._globalState=_}evaluateWithoutErrorHandling(e,r,_,v,b,x){return this._globalState&&(e=Vs(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,r,_,v,b,x)}evaluate(e,r,_,v,b,x){return this._globalState&&(e=Vs(e,this._globalState)),this._styleExpression.evaluate(e,r,_,v,b,x)}}class oi{constructor(e,r,_,v,b){this.kind=e,this.zoomStops=_,this._styleExpression=r,this.isStateDependent=e!==`camera`&&!ds(r.expression),this.globalStateRefs=zs(r.expression),this.interpolationType=v,this._globalState=b}evaluateWithoutErrorHandling(e,r,_,v,b,x){return this._globalState&&(e=Vs(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,r,_,v,b,x)}evaluate(e,r,_,v,b,x){return this._globalState&&(e=Vs(e,this._globalState)),this._styleExpression.evaluate(e,r,_,v,b,x)}interpolationFactor(e,r,_){return this.interpolationType?yn.interpolationFactor(this.interpolationType,e,r,_):0}}function Fs(e,r,_){let v=Ps(e,r,_);if(v.result===`error`)return v;let b=v.value.expression,x=us(b);if(!x&&!_s(r))return gs([new Bt(``,`data expressions not supported`)]);let C=fs(b,[`zoom`]);if(!C&&!ys(r))return gs([new Bt(``,`zoom expressions not supported`)]);let T=Is(b);return T||C?T instanceof Bt?gs([T]):T instanceof yn&&!bs(r)?gs([new Bt(``,`"interpolate" expressions cannot be used with this property`)]):ms(T?new oi(x?`camera`:`composite`,v.value,T.labels,T instanceof yn?T.interpolation:void 0,_):new si(x?`constant`:`source`,v.value,_)):gs([new Bt(``,`"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.`)])}class li{constructor(e,r){this._parameters=e,this._specification=r,fn(this,ws(this._parameters,this._specification))}static deserialize(e){return new li(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Is(e){let r=null;if(e instanceof Qe)r=Is(e.result);else if(e instanceof xn){for(let _ of e.args)if(r=Is(_),r)break}else (e instanceof un||e instanceof yn)&&e.input instanceof zr&&e.input.name===`zoom`&&(r=e);return r instanceof Bt||e.eachChild(e=>{let _=Is(e);_ instanceof Bt?r=_:!r&&_?r=new Bt(``,`"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.`):r&&_&&r!==_&&(r=new Bt(``,`Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.`))}),r}function zs(e,r=/* @__PURE__ */ new Set){return e instanceof Pr&&r.add(e.key),e.eachChild(e=>{zs(e,r)}),r}function Vs(e,r){let{zoom:_,heatmapDensity:v,elevation:b,lineProgress:x,isSupportedScript:C,accumulated:T}=e??{};return{zoom:_,heatmapDensity:v,elevation:b,lineProgress:x,isSupportedScript:C,accumulated:T,globalState:r}}function Ks(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||e.length===0)return!1;switch(e[0]){case`has`:return e.length>=2&&e[1]!==`$id`&&e[1]!==`$type`;case`in`:return e.length>=3&&(typeof e[1]!=`string`||Array.isArray(e[2]));case`!in`:case`!has`:case`none`:return!1;case`==`:case`!=`:case`>`:case`>=`:case`<`:case`<=`:return e.length!==3||Array.isArray(e[1])||Array.isArray(e[2]);case`any`:case`all`:for(let r of e.slice(1))if(!Ks(r)&&typeof r!=`boolean`)return!1;return!0;default:return!0}}let Js={type:`boolean`,default:!1,transition:!1,"property-type":`data-driven`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]}};function ec(e,r){if(e==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>/* @__PURE__ */ new Set};Ks(e)||(e=ic(e));let _=Ps(e,Js,r);if(_.result===`error`)throw Error(_.value.map(e=>`${e.key}: ${e.message}`).join(`, `));return{filter:(e,r,v)=>_.value.evaluate(e,r,{},v),needGeometry:rc(e),getGlobalStateRefs:()=>zs(_.value.expression)}}function nc(e,r){return er?1:0}function rc(e){if(!Array.isArray(e))return!1;if(e[0]===`within`||e[0]===`distance`)return!0;for(let r=1;r`||r===`<=`||r===`>=`?ac(e[1],e[2],r):r===`any`?(_=e.slice(1),[`any`].concat(_.map(ic))):r===`all`?[`all`].concat(e.slice(1).map(ic)):r===`none`?[`all`].concat(e.slice(1).map(ic).map(cc)):r===`in`?oc(e[1],e.slice(2)):r===`!in`?cc(oc(e[1],e.slice(2))):r===`has`?sc(e[1]):r!==`!has`||cc(sc(e[1]));var _}function ac(e,r,_){switch(e){case`$type`:return[`filter-type-${_}`,r];case`$id`:return[`filter-id-${_}`,r];default:return[`filter-${_}`,e,r]}}function oc(e,r){if(r.length===0)return!1;switch(e){case`$type`:return[`filter-type-in`,[`literal`,r]];case`$id`:return[`filter-id-in`,[`literal`,r]];default:return r.length>200&&!r.some(e=>typeof e!=typeof r[0])?[`filter-in-large`,e,[`literal`,r.sort(nc)]]:[`filter-in-small`,e,[`literal`,r]]}}function sc(e){switch(e){case`$type`:return!0;case`$id`:return[`filter-has-id`];default:return[`filter-has`,e]}}function cc(e){return[`!`,e]}function lc(e){let r=typeof e;if(r===`number`||r===`boolean`||r===`string`||e==null)return JSON.stringify(e);if(Array.isArray(e)){let r=`[`;for(let _ of e)r+=`${lc(_)},`;return`${r}]`}let _=Object.keys(e).sort(),v=`{`;for(let r=0;r<_.length;r++)v+=`${JSON.stringify(_[r])}:${lc(e[_[r]])},`;return`${v}}`}function uc(e){let r=``;for(let _ of Lt)r+=`/${lc(e[_])}`;return r}function dc(e){let r=e.value;return r?[new Dt(e.key,r,`constants have been deprecated as of v8`)]:[]}function fc(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function pc(e){if(Array.isArray(e))return e.map(pc);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){let r={};for(let _ in e)r[_]=pc(e[_]);return r}return fc(e)}function mc(e){let r=e.key,_=e.value,v=e.valueSpec||{},b=e.objectElementValidators||{},x=e.style,C=e.styleSpec,T=e.validateSpec,E=[],D=xs(_);if(D!==`object`)return[new Dt(r,_,`object expected, ${D} found`)];for(let e in _){let D=e.split(`.`)[0],O=br(v,D)||v[`*`],k;if(br(b,D))k=b[D];else if(br(v,D)){if(_[e]===void 0)continue;k=T}else if(b[`*`])k=b[`*`];else{if(!v[`*`]){E.push(new Dt(r,_[e],`unknown property "${e}"`));continue}k=T}E=E.concat(k({key:(r&&`${r}.`)+e,value:_[e],valueSpec:O,style:x,styleSpec:C,object:_,objectKey:e,validateSpec:T},_))}for(let e in v)b[e]||v[e].required&&v[e].default===void 0&&_[e]===void 0&&E.push(new Dt(r,_,`missing required property "${e}"`));return E}function hc(e){let r=e.value,_=e.valueSpec,v=e.style,b=e.styleSpec,x=e.key,C=e.arrayElementValidator||e.validateSpec;if(xs(r)!==`array`)return[new Dt(x,r,`array expected, ${xs(r)} found`)];if(_.length&&r.length!==_.length)return[new Dt(x,r,`array length ${_.length} expected, length ${r.length} found`)];let T={type:_.value,values:_.values};b.$version<7&&(T.function=_.function),xs(_.value)===`object`&&(T=_.value);let E=[];for(let _=0;_v.maximum?[new Dt(r,_,`${_} is greater than the maximum value ${v.maximum}`)]:[]:[new Dt(r,_,`number expected, ${b} found`)]}function _c(e){let r=e.valueSpec,_=fc(e.value.type),v,b,x,C={},T=_!==`categorical`&&e.value.property===void 0,E=!T,D=xs(e.value.stops)===`array`&&xs(e.value.stops[0])===`array`&&xs(e.value.stops[0][0])===`object`,O=mc({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if(_===`identity`)return[new Dt(e.key,e.value,`identity function may not have a "stops" property`)];let r=[],v=e.value;return r=r.concat(hc({key:e.key,value:v,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:k})),xs(v)===`array`&&v.length===0&&r.push(new Dt(e.key,v,`array must have at least one stop`)),r},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:r,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return _===`identity`&&T&&O.push(new Dt(e.key,e.value,`missing required property "property"`)),_===`identity`||e.value.stops||O.push(new Dt(e.key,e.value,`missing required property "stops"`)),_===`exponential`&&e.valueSpec.expression&&!bs(e.valueSpec)&&O.push(new Dt(e.key,e.value,`exponential functions not supported`)),e.styleSpec.$version>=8&&(E&&!_s(e.valueSpec)?O.push(new Dt(e.key,e.value,`property functions not supported`)):T&&!ys(e.valueSpec)&&O.push(new Dt(e.key,e.value,`zoom functions not supported`))),_!==`categorical`&&!D||e.value.property!==void 0||O.push(new Dt(e.key,e.value,`"property" property is required`)),O;function k(e){let _=[],v=e.value,T=e.key;if(xs(v)!==`array`)return[new Dt(T,v,`array expected, ${xs(v)} found`)];if(v.length!==2)return[new Dt(T,v,`array length 2 expected, length ${v.length} found`)];if(D){if(xs(v[0])!==`object`)return[new Dt(T,v,`object expected, ${xs(v[0])} found`)];if(v[0].zoom===void 0)return[new Dt(T,v,`object stop key must have zoom`)];if(v[0].value===void 0)return[new Dt(T,v,`object stop key must have value`)];if(x&&x>fc(v[0].zoom))return[new Dt(T,v[0].zoom,`stop zoom values must appear in ascending order`)];fc(v[0].zoom)!==x&&(x=fc(v[0].zoom),b=void 0,C={}),_=_.concat(mc({key:`${T}[0]`,value:v[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:gc,value:A}}))}else _=_.concat(A({key:`${T}[0]`,value:v[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},v));return Ms(pc(v[1]))?_.concat([new Dt(`${T}[1]`,v[1],`expressions are not allowed in function stops.`)]):_.concat(e.validateSpec({key:`${T}[1]`,value:v[1],valueSpec:r,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function A(e,x){let T=xs(e.value),E=fc(e.value),D=e.value===null?x:e.value;if(v){if(T!==v)return[new Dt(e.key,D,`${T} stop domain type must match previous stop domain type ${v}`)]}else v=T;if(T!==`number`&&T!==`string`&&T!==`boolean`)return[new Dt(e.key,D,`stop domain value must be a number, string, or boolean`)];if(T!==`number`&&_!==`categorical`){let v=`number expected, ${T} found`;return _s(r)&&_===void 0&&(v+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Dt(e.key,D,v)]}return _!==`categorical`||T!==`number`||isFinite(E)&&Math.floor(E)===E?_!==`categorical`&&T===`number`&&b!==void 0&&Enew Dt(`${e.key}${r.key}`,e.value,r.message));let _=r.value.expression||r.value._styleExpression.expression;if(e.expressionContext===`property`&&e.propertyKey===`text-font`&&!_.outputDefined())return[new Dt(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if(e.expressionContext===`property`&&e.propertyType===`layout`&&!ds(_))return[new Dt(e.key,e.value,`"feature-state" data expressions are not supported with layout properties.`)];if(e.expressionContext===`filter`&&!ds(_))return[new Dt(e.key,e.value,`"feature-state" data expressions are not supported with filters.`)];if(e.expressionContext&&e.expressionContext.indexOf(`cluster`)===0){if(!fs(_,[`zoom`,`feature-state`]))return[new Dt(e.key,e.value,`"zoom" and "feature-state" expressions are not supported with cluster properties.`)];if(e.expressionContext===`cluster-initial`&&!us(_))return[new Dt(e.key,e.value,`Feature data expressions are not supported with initial expression part of cluster properties.`)]}return[]}function yc(e){let r=e.key,_=e.value,v=xs(_);return v===`string`?Ee.parse(String(_))?[]:[new Dt(r,_,`color expected, "${_}" found`)]:[new Dt(r,_,`color expected, ${v} found`)]}function bc(e){let r=e.key,_=e.value,v=e.valueSpec,b=[];return Array.isArray(v.values)?v.values.indexOf(fc(_))===-1&&b.push(new Dt(r,_,`expected one of [${v.values.join(`, `)}], ${JSON.stringify(_)} found`)):Object.keys(v.values).indexOf(fc(_))===-1&&b.push(new Dt(r,_,`expected one of [${Object.keys(v.values).join(`, `)}], ${JSON.stringify(_)} found`)),b}function xc(e){return Ks(pc(e.value))?vc(fn({},e,{expressionContext:`filter`,valueSpec:{value:`boolean`}})):Sc(e)}function Sc(e){let r=e.value,_=e.key;if(xs(r)!==`array`)return[new Dt(_,r,`array expected, ${xs(r)} found`)];let v=e.styleSpec,b,x=[];if(r.length<1)return[new Dt(_,r,`filter array must have at least 1 element`)];switch(x=x.concat(bc({key:`${_}[0]`,value:r[0],valueSpec:v.filter_operator,style:e.style,styleSpec:e.styleSpec})),fc(r[0])){case`<`:case`<=`:case`>`:case`>=`:r.length>=2&&fc(r[1])===`$type`&&x.push(new Dt(_,r,`"$type" cannot be use with operator "${r[0]}"`));case`==`:case`!=`:r.length!==3&&x.push(new Dt(_,r,`filter array for operator "${r[0]}" must have 3 elements`));case`in`:case`!in`:r.length>=2&&(b=xs(r[1]),b!==`string`&&x.push(new Dt(`${_}[1]`,r[1],`string expected, ${b} found`)));for(let C=2;C{e in b&&v.push(new Dt(x,b[e],`"${e}" is prohibited for ref layers`))}),C.layers.forEach(r=>{fc(r.id)===D&&(e=r)}),e?e.ref?v.push(new Dt(x,b.ref,`ref cannot reference another ref layer`)):E=fc(e.type):v.push(new Dt(x,b.ref,`ref layer "${D}" not found`))}else if(E!==`background`)if(b.source){let e=C.sources&&C.sources[b.source],r=e&&fc(e.type);e?r===`vector`&&E===`raster`?v.push(new Dt(x,b.source,`layer "${b.id}" requires a raster source`)):r!==`raster-dem`&&E===`hillshade`||r!==`raster-dem`&&E===`color-relief`?v.push(new Dt(x,b.source,`layer "${b.id}" requires a raster-dem source`)):r===`raster`&&E!==`raster`?v.push(new Dt(x,b.source,`layer "${b.id}" requires a vector source`)):r!==`vector`||b[`source-layer`]?r===`raster-dem`&&E!==`hillshade`&&E!==`color-relief`?v.push(new Dt(x,b.source,`raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.`)):E!==`line`||!b.paint||!b.paint[`line-gradient`]||r===`geojson`&&e.lineMetrics||v.push(new Dt(x,b,`layer "${b.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):v.push(new Dt(x,b,`layer "${b.id}" must specify a "source-layer"`)):v.push(new Dt(x,b.source,`source "${b.source}" not found`))}else v.push(new Dt(x,b,`missing required property "source"`));return E===`raster`&&(r=b.paint)?.resampling&&(_=b.paint)?.[`raster-resampling`]&&v.push(new Dt(x,b.paint,`layer "${b.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),v=v.concat(mc({key:x,value:b,valueSpec:T.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${x}.type`,value:b.type,valueSpec:T.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:b,objectKey:`type`}),filter:xc,layout:e=>mc({layer:b,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Tc(fn({layerType:E},e))}}),paint:e=>mc({layer:b,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>wc(fn({layerType:E},e))}})}})),v}function Dc(e){let r=e.value,_=e.key,v=xs(r);return v===`string`?[]:[new Dt(_,r,`string expected, ${v} found`)]}let Oc={promoteId:function({key:e,value:r}){if(xs(r)===`string`)return Dc({key:e,value:r});{let _=[];for(let v in r)_.push(...Dc({key:`${e}.${v}`,value:r[v]}));return _}}};function kc(e){let r=e.value,_=e.key,v=e.styleSpec,b=e.style,x=e.validateSpec;if(!r.type)return[new Dt(_,r,`"type" is required`)];let C=fc(r.type),T;switch(C){case`vector`:case`raster`:return T=mc({key:_,value:r,valueSpec:v[`source_${C.replace(`-`,`_`)}`],style:e.style,styleSpec:v,objectElementValidators:Oc,validateSpec:x}),T;case`raster-dem`:return T=function(e){var r;let _=(r=e.sourceName)??``,v=e.value,b=e.styleSpec,x=b.source_raster_dem,C=e.style,T=[],E=xs(v);if(v===void 0)return T;if(E!==`object`)return T.push(new Dt(`source_raster_dem`,v,`object expected, ${E} found`)),T;let D=fc(v.encoding)===`custom`,O=[`redFactor`,`greenFactor`,`blueFactor`,`baseShift`],k=e.value.encoding?`"${e.value.encoding}"`:`Default`;for(let r in v)!D&&O.includes(r)?T.push(new Dt(r,v[r],`In "${_}": "${r}" is only valid when "encoding" is set to "custom". ${k} encoding found`)):x[r]?T=T.concat(e.validateSpec({key:r,value:v[r],valueSpec:x[r],validateSpec:e.validateSpec,style:C,styleSpec:b})):T.push(new Dt(r,v[r],`unknown property "${r}"`));return T}({sourceName:_,value:r,style:e.style,styleSpec:v,validateSpec:x}),T;case`geojson`:if(T=mc({key:_,value:r,valueSpec:v.source_geojson,style:b,styleSpec:v,validateSpec:x,objectElementValidators:Oc}),r.cluster)for(let e in r.clusterProperties){let[v,b]=r.clusterProperties[e],x=typeof v==`string`?[v,[`accumulated`],[`get`,e]]:v;T.push(...vc({key:`${_}.${e}.map`,value:b,expressionContext:`cluster-map`})),T.push(...vc({key:`${_}.${e}.reduce`,value:x,expressionContext:`cluster-reduce`}))}return T;case`video`:return mc({key:_,value:r,valueSpec:v.source_video,style:b,validateSpec:x,styleSpec:v});case`image`:return mc({key:_,value:r,valueSpec:v.source_image,style:b,validateSpec:x,styleSpec:v});case`canvas`:return[new Dt(_,null,`Please use runtime APIs to add canvas sources, rather than including them in stylesheets.`,`source.canvas`)];default:return bc({key:`${_}.type`,value:r.type,valueSpec:{values:[`vector`,`raster`,`raster-dem`,`geojson`,`video`,`image`]}})}}function Ac(e){let r=e.value,_=e.styleSpec,v=_.light,b=e.style,x=[],C=xs(r);if(r===void 0)return x;if(C!==`object`)return x=x.concat([new Dt(`light`,r,`object expected, ${C} found`)]),x;for(let C in r){let T=C.match(/^(.*)-transition$/);x=x.concat(T&&v[T[1]]&&v[T[1]].transition?e.validateSpec({key:C,value:r[C],valueSpec:_.transition,validateSpec:e.validateSpec,style:b,styleSpec:_}):v[C]?e.validateSpec({key:C,value:r[C],valueSpec:v[C],validateSpec:e.validateSpec,style:b,styleSpec:_}):[new Dt(C,r[C],`unknown property "${C}"`)])}return x}function jc(e){let r=e.value,_=e.styleSpec,v=_.sky,b=e.style,x=xs(r);if(r===void 0)return[];if(x!==`object`)return[new Dt(`sky`,r,`object expected, ${x} found`)];let C=[];for(let x in r)C=C.concat(v[x]?e.validateSpec({key:x,value:r[x],valueSpec:v[x],style:b,styleSpec:_}):[new Dt(x,r[x],`unknown property "${x}"`)]);return C}function Mc(e){let r=e.value,_=e.styleSpec,v=_.terrain,b=e.style,x=[],C=xs(r);if(r===void 0)return x;if(C!==`object`)return x=x.concat([new Dt(`terrain`,r,`object expected, ${C} found`)]),x;for(let C in r)x=x.concat(v[C]?e.validateSpec({key:C,value:r[C],valueSpec:v[C],validateSpec:e.validateSpec,style:b,styleSpec:_}):[new Dt(C,r[C],`unknown property "${C}"`)]);return x}function Pc(e){let r=[],_=e.value,v=e.key;if(Array.isArray(_)){let b=[],x=[];for(let C in _)_[C].id&&b.includes(_[C].id)&&r.push(new Dt(v,_,`all the sprites' ids must be unique, but ${_[C].id} is duplicated`)),b.push(_[C].id),_[C].url&&x.includes(_[C].url)&&r.push(new Dt(v,_,`all the sprites' URLs must be unique, but ${_[C].url} is duplicated`)),x.push(_[C].url),r=r.concat(mc({key:`${v}[${C}]`,value:_[C],valueSpec:{id:{type:`string`,required:!0},url:{type:`string`,required:!0}},validateSpec:e.validateSpec}));return r}return Dc({key:v,value:_})}function Fc(e){return!!e&&e.constructor===Object}function Ic(e){return Fc(e.value)?[]:[new Dt(e.key,e.value,`object expected, ${xs(e.value)} found`)]}let Lc={"*":()=>[],array:hc,boolean:function(e){let r=e.value,_=e.key,v=xs(r);return v===`boolean`?[]:[new Dt(_,r,`boolean expected, ${v} found`)]},number:gc,color:yc,constants:dc,enum:bc,filter:xc,function:_c,layer:Ec,object:mc,source:kc,light:Ac,sky:jc,terrain:Mc,projection:function(e){let r=e.value,_=e.styleSpec,v=_.projection,b=e.style,x=xs(r);if(r===void 0)return[];if(x!==`object`)return[new Dt(`projection`,r,`object expected, ${x} found`)];let C=[];for(let x in r)C=C.concat(v[x]?e.validateSpec({key:x,value:r[x],valueSpec:v[x],style:b,styleSpec:_}):[new Dt(x,r[x],`unknown property "${x}"`)]);return C},projectionDefinition:function(e){let r=e.key,_=e.value;_=_ instanceof String?_.valueOf():_;let v=xs(_);return v!==`array`||function(e){return Array.isArray(e)&&e.length===3&&typeof e[0]==`string`&&typeof e[1]==`string`&&typeof e[2]==`number`}(_)||function(e){return!![`interpolate`,`step`,`literal`].includes(e[0])}(_)?[`array`,`string`].includes(v)?[]:[new Dt(r,_,`projection expected, invalid type "${v}" found`)]:[new Dt(r,_,`projection expected, invalid array ${JSON.stringify(_)} found`)]},string:Dc,formatted:function(e){return Dc(e).length===0?[]:vc(e)},resolvedImage:function(e){return Dc(e).length===0?[]:vc(e)},padding:function(e){let r=e.key,_=e.value;if(xs(_)===`array`){if(_.length<1||_.length>4)return[new Dt(r,_,`padding requires 1 to 4 values; ${_.length} values found`)];let v={type:`number`},b=[];for(let x=0;x<_.length;x++)b=b.concat(e.validateSpec({key:`${r}[${x}]`,value:_[x],validateSpec:e.validateSpec,valueSpec:v}));return b}return gc({key:r,value:_,valueSpec:{}})},numberArray:function(e){let r=e.key,_=e.value;if(xs(_)===`array`){let v={type:`number`};if(_.length<1)return[new Dt(r,_,`array length at least 1 expected, length 0 found`)];let b=[];for(let x=0;x<_.length;x++)b=b.concat(e.validateSpec({key:`${r}[${x}]`,value:_[x],validateSpec:e.validateSpec,valueSpec:v}));return b}return gc({key:r,value:_,valueSpec:{}})},colorArray:function(e){let r=e.key,_=e.value;if(xs(_)===`array`){if(_.length<1)return[new Dt(r,_,`array length at least 1 expected, length 0 found`)];let e=[];for(let v=0;v<_.length;v++)e=e.concat(yc({key:`${r}[${v}]`,value:_[v]}));return e}return yc({key:r,value:_})},variableAnchorOffsetCollection:function(e){let r=e.key,_=e.value,v=xs(_),b=e.styleSpec;if(v!==`array`||_.length<1||_.length%2!=0)return[new Dt(r,_,`variableAnchorOffsetCollection requires a non-empty array of even length`)];let x=[];for(let v=0;v<_.length;v+=2)x=x.concat(bc({key:`${r}[${v}]`,value:_[v],valueSpec:b.layout_symbol[`text-anchor`]})),x=x.concat(hc({key:`${r}[${v+1}]`,value:_[v+1],valueSpec:{length:2,value:`number`},validateSpec:e.validateSpec,style:e.style,styleSpec:b}));return x},sprite:Pc,state:Ic,fontFaces:function(e){let r=e.key,_=e.value,v=e.validateSpec,b=e.styleSpec,x=e.style;if(!Fc(_))return[new Dt(r,_,`object expected, ${xs(_)} found`)];let C=[];for(let e in _){let T=_[e],E=xs(T);if(E===`string`)C.push(...Dc({key:`${r}.${e}`,value:T}));else if(E===`array`){let _={url:{type:`string`,required:!0},"unicode-range":{type:`array`,value:`string`}};for(let[E,D]of T.entries())C.push(...mc({key:`${r}.${e}[${E}]`,value:D,valueSpec:_,styleSpec:b,style:x,validateSpec:v}))}else C.push(new Dt(`${r}.${e}`,T,`string or array expected, ${E} found`))}return C}};function Rc(e){let r=e.value,_=e.valueSpec,v=e.styleSpec;return e.validateSpec=Rc,_.expression&&Ss(fc(r))?_c(e):_.expression&&Ms(pc(r))?vc(e):_.type&&Lc[_.type]?Lc[_.type](e):mc(fn({},e,{valueSpec:_.type?v[_.type]:_}))}function zc(e){let r=e.value,_=e.key,v=Dc(e);return v.length||(r.indexOf(`{fontstack}`)===-1&&v.push(new Dt(_,r,`"glyphs" url must include a "{fontstack}" token`)),r.indexOf(`{range}`)===-1&&v.push(new Dt(_,r,`"glyphs" url must include a "{range}" token`))),v}function Bc(e,r=$){let _=[];return _=_.concat(Rc({key:``,value:e,valueSpec:r.$root,styleSpec:r,style:e,validateSpec:Rc,objectElementValidators:{glyphs:zc,"*":()=>[]}})),e.constants&&(_=_.concat(dc({key:`constants`,value:e.constants}))),Hc(_)}function Vc(e){return function(r){return e(Object.assign({},r,{validateSpec:Rc}))}}function Hc(e){return[].concat(e).sort((e,r)=>e.line-r.line)}function Uc(r){return function(..._){return Hc(r.apply(this||e,_))}}Bc.source=Uc(Vc(kc)),Bc.sprite=Uc(Vc(Pc)),Bc.glyphs=Uc(Vc(zc)),Bc.light=Uc(Vc(Ac)),Bc.sky=Uc(Vc(jc)),Bc.terrain=Uc(Vc(Mc)),Bc.state=Uc(Vc(Ic)),Bc.layer=Uc(Vc(Ec)),Bc.filter=Uc(Vc(xc)),Bc.paintProperty=Uc(Vc(wc)),Bc.layoutProperty=Uc(Vc(Tc));let Wc={type:`enum`,"property-type":`data-constant`,expression:{interpolated:!1,parameters:[`global-state`]},values:{visible:{},none:{}},transition:!1,default:`visible`};class rs{constructor(e,r){this._globalState=r,this.setValue(e)}evaluate(){var e;return(e=this._literalValue)??this._compiledValue.evaluate({})}setValue(e){if(e==null||e===`visible`||e===`none`)return this._literalValue=e===`none`?`none`:`visible`,this._compiledValue=void 0,void(this._globalStateRefs=/* @__PURE__ */ new Set);let r=Ps(e,Wc,this._globalState);if(r.result===`error`)throw this._literalValue=`visible`,this._compiledValue=void 0,Error(r.value.map(e=>`${e.key}: ${e.message}`).join(`, `));this._literalValue=void 0,this._compiledValue=r.value,this._globalStateRefs=zs(r.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}let Gc=$,Kc=Bc,qc=Kc.light,Jc=Kc.sky,Yc=Kc.paintProperty,Xc=Kc.layoutProperty;function Zc(e,r){let _=!1;if(r&&r.length)for(let v of r)e.fire(new xt(Error(v.message))),_=!0;return _}class hs{constructor(e,r,_){let v=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;let b=new Int32Array(this.arrayBuffer);e=b[0],this.d=(r=b[1])+2*(_=b[2]);for(let e=0;e=D[E+0]&&v>=D[E+1])?(C[k]=!0,x.push(b[k])):C[k]=!1}}}}_forEachCell(e,r,_,v,b,x,C,T){let E=this._convertToCellCoord(e),D=this._convertToCellCoord(r),O=this._convertToCellCoord(_),k=this._convertToCellCoord(v);for(let A=E;A<=O;A++)for(let E=D;E<=k;E++){let D=this.d*E+A;if((!T||T(this._convertFromCellCoord(A),this._convertFromCellCoord(E),this._convertFromCellCoord(A+1),this._convertFromCellCoord(E+1)))&&b.call(this,e,r,_,v,D,x,C,T))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;let e=this.cells,r=3+this.cells.length+1+1,_=0;for(let e=0;e=0)continue;let x=e[v];b[v]=Qc[_].shallow.indexOf(v)>=0?x:rl(x,r)}e instanceof Error&&(b.message=e.message)}if(b.$name)throw Error(`$name property is reserved for worker serialization logic.`);return _!==`Object`&&(b.$name=_),b}function il(e){if(nl(e))return e;if(Array.isArray(e))return e.map(il);if(typeof e!=`object`)throw Error(`can't deserialize object of type `+typeof e);let r=tl(e)||`Object`;if(!Qc[r])throw Error(`can't deserialize unregistered class ${r}`);let{klass:_}=Qc[r];if(!_)throw Error(`can't deserialize unregistered class ${r}`);if(_.deserialize)return _.deserialize(e);let v=Object.create(_.prototype);for(let _ of Object.keys(e)){if(_===`$name`)continue;let b=e[_];v[_]=Qc[r].shallow.indexOf(_)>=0?b:il(b)}return v}class vs{constructor(){this.first=!0}update(e,r){let _=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=_,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=_,!0):(this.lastFloorZoom>_?(this.lastIntegerZoom=_+1,this.lastIntegerZoomTime=r):this.lastFloorZoom<_&&(this.lastIntegerZoom=_,this.lastIntegerZoomTime=r),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=_,!0))}}function al(e){return/[\u02EA\u02EB\u2E80-\u2FDF\u2FF0-\u303F\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FD-\u30FF\u3105-\u312F\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function ol(e){return/[\u02EA\u02EB\u1100-\u11FF\u1400-\u167F\u18B0-\u18F5\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303F\u3041-\u3096\u309D-\u30FB\u30FD-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD83D\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD30-\uDEFB]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83C[\uDC00-\uDE00\uDF00-\uDFFF]|\uD83E[\uDD00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function sl(e){return/\s/u.test(String.fromCodePoint(e))}function cl(e){for(let r of e)if(ol(r.codePointAt(0)))return!0;return!1}function ll(e){for(let r of e)if(!fl(r.codePointAt(0)))return!1;return!0}function ul(e){let r=e.map(e=>{try{return RegExp(`\\p{sc=${e}}`,`u`).source}catch{return null}}).filter(e=>e);return new RegExp(r.join(`|`),`u`)}let dl=ul([`Arab`,`Dupl`,`Mong`,`Ougr`,`Syrc`]);function fl(e){return!dl.test(String.fromCodePoint(e))}function pl(e){return!(ol(e)||(r=e,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(r))));var r}let ml=ul(/* @__PURE__ */ `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`.split(`.`));function hl(e){return ml.test(String.fromCodePoint(e))}function gl(e,r){return!(!r&&hl(e)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e)))}function _l(e){for(let r of e)if(hl(r.codePointAt(0)))return!0;return!1}let yl=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus=`unavailable`,this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(yl.isParsed())throw Error(`RTL text plugin already registered.`);this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}syncState(e,r){return _(this,void 0,void 0,function*(){if(this.isParsed())return this.getState();if(e.pluginStatus!==`loading`)return this.setState(e),e;let _=e.pluginURL,v=new Promise(e=>{this.loadScriptResolve=e});r(_);let b=new Promise(e=>setTimeout(()=>e(),this.TIMEOUT));if(yield Promise.race([v,b]),this.isParsed()){let e={pluginStatus:`loaded`,pluginURL:_};return this.setState(e),e}throw this.setState({pluginStatus:`error`,pluginURL:``}),/* @__PURE__ */ Error(`RTL Text Plugin failed to import scripts from ${_}`)})}};class Bs{constructor(e,r){this.isSupportedScript=bl,this.zoom=e,r?(this.now=r.now||0,this.fadeDuration=r.fadeDuration||0,this.zoomHistory=r.zoomHistory||new vs,this.transition=r.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new vs,this.transition={})}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let e=this.zoom,r=e-Math.floor(e),_=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*_}:{fromScale:.5,toScale:1,t:1-(1-_)*r}}}function bl(e){return function(e,r){for(let _ of e)if(!gl(_.codePointAt(0),r))return!1;return!0}(e,yl.getRTLTextPluginStatus()===`loaded`)}let Sl=`-transition`;class Ls{constructor(e,r,_){this.property=e,this.value=r,this.expression=function(e,r,_){if(Ss(e))return new li(e,r);if(Ms(e)){let v=Fs(e,r,_);if(v.result===`error`)throw Error(v.value.map(e=>`${e.key}: ${e.message}`).join(`, `));return v.value}{let _=e;return r.type===`color`&&typeof e==`string`?_=Ee.parse(e):r.type!==`padding`||typeof e!=`number`&&!Array.isArray(e)?r.type!==`numberArray`||typeof e!=`number`&&!Array.isArray(e)?r.type!==`colorArray`||typeof e!=`string`&&!Array.isArray(e)?r.type===`variableAnchorOffsetCollection`&&Array.isArray(e)?_=Oe.parse(e):r.type===`projectionDefinition`&&typeof e==`string`&&(_=Re.parse(e)):_=Ce.parse(e):_=Be.parse(e):_=ze.parse(e),{globalStateRefs:/* @__PURE__ */ new Set,_globalState:null,kind:`constant`,evaluate:()=>_}}}(r===void 0?e.specification.default:r,e.specification,_)}isDataDriven(){return this.expression.kind===`source`||this.expression.kind===`composite`}getGlobalStateRefs(){return this.expression.globalStateRefs||/* @__PURE__ */ new Set}possiblyEvaluate(e,r,_){return this.property.possiblyEvaluate(this,e,r,_)}}class Os{constructor(e,r){this.property=e,this.value=new Ls(e,void 0,r)}transitioned(e,r){return new Rs(this.property,this.value,r,ye({},e.transition,this.transition),e.now)}untransitioned(){return new Rs(this.property,this.value,null,{},0)}}class $s{constructor(e,r){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=r}hasProperty(e){return e in this._properties.defaultTransitionablePropertyValues}getValue(e){return we(this._values[e].value.value)}setValue(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Os(this._values[e].property,this._globalState)),this._values[e].value=new Ls(this._values[e].property,r===null?void 0:we(r),this._globalState)}getTransition(e){return we(this._values[e].transition)}setTransition(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Os(this._values[e].property,this._globalState)),this._values[e].transition=we(r)||void 0}serialize(){let e={};for(let r of Object.keys(this._values)){let _=this.getValue(r);_!==void 0&&(e[r]=_);let v=this.getTransition(r);v!==void 0&&(e[`${r}${Sl}`]=v)}return e}transitioned(e,r){let _=new Ns(this._properties);for(let v of Object.keys(this._values))_._values[v]=this._values[v].transitioned(e,r._values[v]);return _}untransitioned(){let e=new Ns(this._properties);for(let r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class Rs{constructor(e,r,_,v,b){this.property=e,this.value=r,this.begin=b+v.delay||0,this.end=this.begin+v.duration||0,e.specification.transition&&(v.delay||v.duration)&&(this.prior=_)}possiblyEvaluate(e,r,_){let v=e.now||0,b=this.value.possiblyEvaluate(e,r,_),x=this.prior;if(x){if(v>this.end||this.value.isDataDriven())return this.prior=null,b;if(vv.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:_,to:r}}interpolate(e){return e}}class Zs{constructor(e){this.specification=e}possiblyEvaluate(e,r,_,v){if(e.value!==void 0){if(e.expression.kind===`constant`){let b=e.expression.evaluate(r,null,{},_,v);return this._calculate(b,b,b,r)}return this._calculate(e.expression.evaluate(new Bs(Math.floor(r.zoom-1),r)),e.expression.evaluate(new Bs(Math.floor(r.zoom),r)),e.expression.evaluate(new Bs(Math.floor(r.zoom+1),r)),r)}}_calculate(e,r,_,v){return v.zoom>v.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:_,to:r}}interpolate(e){return e}}class Hs{constructor(e){this.specification=e}possiblyEvaluate(e,r,_,v){return!!e.expression.evaluate(r,null,{},_,v)}interpolate(){return!1}}class Ws{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let r in e){let _=e[r];_.specification.overridable&&this.overridableProperties.push(r);let v=this.defaultPropertyValues[r]=new Ls(_,void 0,void 0),b=this.defaultTransitionablePropertyValues[r]=new Os(_,void 0);this.defaultTransitioningPropertyValues[r]=b.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=v.possiblyEvaluate({})}}}$c(`DataDrivenProperty`,Xs),$c(`DataConstantProperty`,Gs),$c(`CrossFadedDataDrivenProperty`,Ys),$c(`CrossFadedProperty`,Zs),$c(`ColorRampProperty`,Hs);let Cl=` is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?`,wl=` is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?`;class Qs extends vt{constructor(e,r,_){if(super(),this.id=e.id,this.type=e.type,this._globalState=_,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>/* @__PURE__ */ new Set},this._visibilityExpression=function(e,r){return new rs(e,r)}(this.visibility,_),e.type!==`custom`&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!==`background`&&(this.source=e.source,this.sourceLayer=e[`source-layer`],this.filter=e.filter,this._featureFilter=ec(e.filter,_)),r.layout&&(this._unevaluatedLayout=new Us(r.layout,_)),r.paint)){this._transitionablePaint=new $s(r.paint,_);for(let r in e.paint)this.setPaintProperty(r,e.paint[r],{validate:!1});for(let r in e.layout)this.setLayoutProperty(r,e.layout[r],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new qs(r.paint)}}setFilter(e){this.filter=e,this._featureFilter=ec(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){var r;if(e===`visibility`)return this.visibility;if((r=this._transitionablePaint)?.hasProperty(e))throw Error(e+Cl);if(!this._unevaluatedLayout)throw Error(`Cannot get layout property "${e}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){let e=/* @__PURE__ */ new Set;for(let r of this._visibilityExpression.getGlobalStateRefs())e.add(r);if(this._unevaluatedLayout)for(let r in this._unevaluatedLayout._values){let _=this._unevaluatedLayout._values[r];for(let r of _.getGlobalStateRefs())e.add(r)}for(let r of this._featureFilter.getGlobalStateRefs())e.add(r);return e}getPaintAffectingGlobalStateRefs(){var e;let r=new globalThis.Map;if(this._transitionablePaint)for(let _ in this._transitionablePaint._values){let v=this._transitionablePaint._values[_].value;for(let b of v.getGlobalStateRefs()){let x=(e=r.get(b))??[];x.push({name:_,value:v.value}),r.set(b,x)}}return r}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,r,_={}){var v;if(e===`visibility`)return this.visibility=r,this._visibilityExpression.setValue(r),void this.recalculateVisibility();(v=this._transitionablePaint)?.hasProperty(e)?this.fire(new xt(Error(e+Cl))):r!=null&&this._validate(Xc,`layers.${this.id}.layout.${e}`,e,r,_)||this._unevaluatedLayout.setValue(e,r)}getPaintProperty(e){var r,_;if(e.endsWith(Sl)){let _=e.slice(0,-11);if(_===`visibility`||(r=this._unevaluatedLayout)?.hasProperty(_))throw Error(e+wl);return this._transitionablePaint.getTransition(_)}if(e===`visibility`||(_=this._unevaluatedLayout)?.hasProperty(e))throw Error(e+wl);return this._transitionablePaint.getValue(e)}setPaintProperty(e,r,_={}){var v;if(e===`visibility`||(v=this._unevaluatedLayout)?.hasProperty(e))return this.fire(new xt(Error(e+wl))),!1;if(r!=null&&this._validate(Yc,`layers.${this.id}.paint.${e}`,e,r,_))return!1;if(e.endsWith(Sl))return this._transitionablePaint.setTransition(e.slice(0,-11),r||void 0),!1;{let _=this._transitionablePaint._values[e],v=_.property.specification[`property-type`]===`cross-faded-data-driven`,b=_.value.isDataDriven(),x=_.value;this._transitionablePaint.setValue(e,r),this._handleSpecialPaintPropertyUpdate(e);let C=this._transitionablePaint._values[e].value;return C.isDataDriven()||b||v||this._handleOverridablePaintPropertyUpdate(e,x,C)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,r,_){return!1}isHidden(e=this.minzoom,r=!1){return!!(this.minzoom&&e<(r?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&e>=this.maxzoom)||this._evaluatedVisibility===`none`}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(e,r){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,r)}serialize(){var e,r;let _={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:(e=this._unevaluatedLayout)?.serialize(),paint:(r=this._transitionablePaint)?.serialize()};return this.visibility&&(_.layout=_.layout||{},_.layout.visibility=this.visibility),Se(_,(e,r)=>!(e===void 0||r===`layout`&&!Object.keys(e).length||r===`paint`&&!Object.keys(e).length))}_validate(e,r,_,v,b={}){return!1!==b?.validate&&Zc(this,e.call(Kc,{key:r,layerType:this.type,objectKey:_,value:v,styleSpec:$,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let e in this.paint._values){let r=this.paint.get(e);if(r instanceof js&&_s(r.property.specification)&&(r.value.kind===`source`||r.value.kind===`composite`)&&r.value.isStateDependent)return!0}return!1}}let Tl;var El={get paint(){return Tl||=new Ws({"raster-opacity":new Gs($.paint_raster[`raster-opacity`]),"raster-hue-rotate":new Gs($.paint_raster[`raster-hue-rotate`]),"raster-brightness-min":new Gs($.paint_raster[`raster-brightness-min`]),"raster-brightness-max":new Gs($.paint_raster[`raster-brightness-max`]),"raster-saturation":new Gs($.paint_raster[`raster-saturation`]),"raster-contrast":new Gs($.paint_raster[`raster-contrast`]),resampling:new Gs($.paint_raster.resampling),"raster-resampling":new Gs($.paint_raster[`raster-resampling`]),"raster-fade-duration":new Gs($.paint_raster[`raster-fade-duration`])})}};class no extends Qs{constructor(e,r){super(e,El,r)}}let Dl={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class io{constructor(e,r){this._structArray=e,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class so{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,r){return e._trim(),r&&(e.isTransferred=!0,r.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){let r=Object.create(this.prototype);return r.arrayBuffer=e.arrayBuffer,r.length=e.length,r.capacity=e.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(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw Error(`_refreshViews() must be implemented by each concrete StructArray layout`)}freeBufferAfterUpload(){this.arrayBuffer=/* @__PURE__ */ new ArrayBuffer(0),this._refreshViews()}}function Al(e,r=1){let _=0,v=0;return{members:e.map(e=>{let b=Dl[e.type].BYTES_PER_ELEMENT,x=_=jl(_,Math.max(r,b)),C=e.components||1;return v=Math.max(v,b),_+=b*C,{name:e.name,type:e.type,components:C,offset:x}}),size:jl(_,Math.max(v,r)),alignment:r}}function jl(e,r){return Math.ceil(e/r)*r}class lo extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r){let _=this.length;return this.resize(_+1),this.emplace(_,e,r)}emplace(e,r,_){let v=2*e;return this.int16[v+0]=r,this.int16[v+1]=_,e}}lo.prototype.bytesPerElement=4,$c(`StructArrayLayout2i4`,lo);class uo extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,_){let v=this.length;return this.resize(v+1),this.emplace(v,e,r,_)}emplace(e,r,_,v){let b=3*e;return this.int16[b+0]=r,this.int16[b+1]=_,this.int16[b+2]=v,e}}uo.prototype.bytesPerElement=6,$c(`StructArrayLayout3i6`,uo);class co extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,_,v){let b=this.length;return this.resize(b+1),this.emplace(b,e,r,_,v)}emplace(e,r,_,v,b){let x=4*e;return this.int16[x+0]=r,this.int16[x+1]=_,this.int16[x+2]=v,this.int16[x+3]=b,e}}co.prototype.bytesPerElement=8,$c(`StructArrayLayout4i8`,co);class ho extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,_,v,b,x){let C=this.length;return this.resize(C+1),this.emplace(C,e,r,_,v,b,x)}emplace(e,r,_,v,b,x,C){let T=6*e;return this.int16[T+0]=r,this.int16[T+1]=_,this.int16[T+2]=v,this.int16[T+3]=b,this.int16[T+4]=x,this.int16[T+5]=C,e}}ho.prototype.bytesPerElement=12,$c(`StructArrayLayout2i4i12`,ho);class po extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,_,v,b,x){let C=this.length;return this.resize(C+1),this.emplace(C,e,r,_,v,b,x)}emplace(e,r,_,v,b,x,C){let T=4*e,E=8*e;return this.int16[T+0]=r,this.int16[T+1]=_,this.uint8[E+4]=v,this.uint8[E+5]=b,this.uint8[E+6]=x,this.uint8[E+7]=C,e}}po.prototype.bytesPerElement=8,$c(`StructArrayLayout2i4ub8`,po);class fo extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r){let _=this.length;return this.resize(_+1),this.emplace(_,e,r)}emplace(e,r,_){let v=2*e;return this.float32[v+0]=r,this.float32[v+1]=_,e}}fo.prototype.bytesPerElement=8,$c(`StructArrayLayout2f8`,fo);class yo extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,_,v,b,x,C,T,E,D){let O=this.length;return this.resize(O+1),this.emplace(O,e,r,_,v,b,x,C,T,E,D)}emplace(e,r,_,v,b,x,C,T,E,D,O){let k=10*e;return this.uint16[k+0]=r,this.uint16[k+1]=_,this.uint16[k+2]=v,this.uint16[k+3]=b,this.uint16[k+4]=x,this.uint16[k+5]=C,this.uint16[k+6]=T,this.uint16[k+7]=E,this.uint16[k+8]=D,this.uint16[k+9]=O,e}}yo.prototype.bytesPerElement=20,$c(`StructArrayLayout10ui20`,yo);class mo extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,_,v,b,x,C,T){let E=this.length;return this.resize(E+1),this.emplace(E,e,r,_,v,b,x,C,T)}emplace(e,r,_,v,b,x,C,T,E){let D=8*e;return this.uint16[D+0]=r,this.uint16[D+1]=_,this.uint16[D+2]=v,this.uint16[D+3]=b,this.uint16[D+4]=x,this.uint16[D+5]=C,this.uint16[D+6]=T,this.uint16[D+7]=E,e}}mo.prototype.bytesPerElement=16,$c(`StructArrayLayout8ui16`,mo);class go extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,_,v,b,x,C,T,E,D,O,k){let A=this.length;return this.resize(A+1),this.emplace(A,e,r,_,v,b,x,C,T,E,D,O,k)}emplace(e,r,_,v,b,x,C,T,E,D,O,k,A){let j=12*e;return this.int16[j+0]=r,this.int16[j+1]=_,this.int16[j+2]=v,this.int16[j+3]=b,this.uint16[j+4]=x,this.uint16[j+5]=C,this.uint16[j+6]=T,this.uint16[j+7]=E,this.int16[j+8]=D,this.int16[j+9]=O,this.int16[j+10]=k,this.int16[j+11]=A,e}}go.prototype.bytesPerElement=24,$c(`StructArrayLayout4i4ui4i24`,go);class xo extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,_){let v=this.length;return this.resize(v+1),this.emplace(v,e,r,_)}emplace(e,r,_,v){let b=3*e;return this.float32[b+0]=r,this.float32[b+1]=_,this.float32[b+2]=v,e}}xo.prototype.bytesPerElement=12,$c(`StructArrayLayout3f12`,xo);class vo extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){let r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint32[1*e+0]=r,e}}vo.prototype.bytesPerElement=4,$c(`StructArrayLayout1ul4`,vo);class bo extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,_,v,b,x,C,T,E){let D=this.length;return this.resize(D+1),this.emplace(D,e,r,_,v,b,x,C,T,E)}emplace(e,r,_,v,b,x,C,T,E,D){let O=10*e,k=5*e;return this.int16[O+0]=r,this.int16[O+1]=_,this.int16[O+2]=v,this.int16[O+3]=b,this.int16[O+4]=x,this.int16[O+5]=C,this.uint32[k+3]=T,this.uint16[O+8]=E,this.uint16[O+9]=D,e}}bo.prototype.bytesPerElement=20,$c(`StructArrayLayout6i1ul2ui20`,bo);class wo extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,_,v,b,x){let C=this.length;return this.resize(C+1),this.emplace(C,e,r,_,v,b,x)}emplace(e,r,_,v,b,x,C){let T=6*e;return this.int16[T+0]=r,this.int16[T+1]=_,this.int16[T+2]=v,this.int16[T+3]=b,this.int16[T+4]=x,this.int16[T+5]=C,e}}wo.prototype.bytesPerElement=12,$c(`StructArrayLayout2i2i2i12`,wo);class _o extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,_,v,b){let x=this.length;return this.resize(x+1),this.emplace(x,e,r,_,v,b)}emplace(e,r,_,v,b,x){let C=4*e,T=8*e;return this.float32[C+0]=r,this.float32[C+1]=_,this.float32[C+2]=v,this.int16[T+6]=b,this.int16[T+7]=x,e}}_o.prototype.bytesPerElement=16,$c(`StructArrayLayout2f1f2i16`,_o);class So extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,_,v,b,x){let C=this.length;return this.resize(C+1),this.emplace(C,e,r,_,v,b,x)}emplace(e,r,_,v,b,x,C){let T=16*e,E=4*e,D=8*e;return this.uint8[T+0]=r,this.uint8[T+1]=_,this.float32[E+1]=v,this.float32[E+2]=b,this.int16[D+6]=x,this.int16[D+7]=C,e}}So.prototype.bytesPerElement=16,$c(`StructArrayLayout2ub2f2i16`,So);class Ao extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,_){let v=this.length;return this.resize(v+1),this.emplace(v,e,r,_)}emplace(e,r,_,v){let b=3*e;return this.uint16[b+0]=r,this.uint16[b+1]=_,this.uint16[b+2]=v,e}}Ao.prototype.bytesPerElement=6,$c(`StructArrayLayout3ui6`,Ao);class Mo extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,_,v,b,x,C,T,E,D,O,k,A,j,F,R,z){let B=this.length;return this.resize(B+1),this.emplace(B,e,r,_,v,b,x,C,T,E,D,O,k,A,j,F,R,z)}emplace(e,r,_,v,b,x,C,T,E,D,O,k,A,j,F,R,z,B){let H=24*e,K=12*e,q=48*e;return this.int16[H+0]=r,this.int16[H+1]=_,this.uint16[H+2]=v,this.uint16[H+3]=b,this.uint32[K+2]=x,this.uint32[K+3]=C,this.uint32[K+4]=T,this.uint16[H+10]=E,this.uint16[H+11]=D,this.uint16[H+12]=O,this.float32[K+7]=k,this.float32[K+8]=A,this.uint8[q+36]=j,this.uint8[q+37]=F,this.uint8[q+38]=R,this.uint32[K+10]=z,this.int16[H+22]=B,e}}Mo.prototype.bytesPerElement=48,$c(`StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48`,Mo);class ko extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,_,v,b,x,C,T,E,D,O,k,A,j,F,R,z,B,H,K,q,Y,X,ne,Z,ie,ae,oe){let se=this.length;return this.resize(se+1),this.emplace(se,e,r,_,v,b,x,C,T,E,D,O,k,A,j,F,R,z,B,H,K,q,Y,X,ne,Z,ie,ae,oe)}emplace(e,r,_,v,b,x,C,T,E,D,O,k,A,j,F,R,z,B,H,K,q,Y,X,ne,Z,ie,ae,oe,se){let ce=32*e,le=16*e;return this.int16[ce+0]=r,this.int16[ce+1]=_,this.int16[ce+2]=v,this.int16[ce+3]=b,this.int16[ce+4]=x,this.int16[ce+5]=C,this.int16[ce+6]=T,this.int16[ce+7]=E,this.uint16[ce+8]=D,this.uint16[ce+9]=O,this.uint16[ce+10]=k,this.uint16[ce+11]=A,this.uint16[ce+12]=j,this.uint16[ce+13]=F,this.uint16[ce+14]=R,this.uint16[ce+15]=z,this.uint16[ce+16]=B,this.uint16[ce+17]=H,this.uint16[ce+18]=K,this.uint16[ce+19]=q,this.uint16[ce+20]=Y,this.uint16[ce+21]=X,this.uint16[ce+22]=ne,this.uint32[le+12]=Z,this.float32[le+13]=ie,this.float32[le+14]=ae,this.uint16[ce+30]=oe,this.uint16[ce+31]=se,e}}ko.prototype.bytesPerElement=64,$c(`StructArrayLayout8i15ui1ul2f2ui64`,ko);class Io extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){let r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.float32[1*e+0]=r,e}}Io.prototype.bytesPerElement=4,$c(`StructArrayLayout1f4`,Io);class Eo extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,_){let v=this.length;return this.resize(v+1),this.emplace(v,e,r,_)}emplace(e,r,_,v){let b=3*e;return this.uint16[6*e+0]=r,this.float32[b+1]=_,this.float32[b+2]=v,e}}Eo.prototype.bytesPerElement=12,$c(`StructArrayLayout1ui2f12`,Eo);class To extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,_){let v=this.length;return this.resize(v+1),this.emplace(v,e,r,_)}emplace(e,r,_,v){let b=4*e;return this.uint32[2*e+0]=r,this.uint16[b+2]=_,this.uint16[b+3]=v,e}}To.prototype.bytesPerElement=8,$c(`StructArrayLayout1ul2ui8`,To);class Fo extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r){let _=this.length;return this.resize(_+1),this.emplace(_,e,r)}emplace(e,r,_){let v=2*e;return this.uint16[v+0]=r,this.uint16[v+1]=_,e}}Fo.prototype.bytesPerElement=4,$c(`StructArrayLayout2ui4`,Fo);class Po extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){let r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint16[1*e+0]=r,e}}Po.prototype.bytesPerElement=2,$c(`StructArrayLayout1ui2`,Po);class Do extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,_,v){let b=this.length;return this.resize(b+1),this.emplace(b,e,r,_,v)}emplace(e,r,_,v,b){let x=4*e;return this.float32[x+0]=r,this.float32[x+1]=_,this.float32[x+2]=v,this.float32[x+3]=b,e}}Do.prototype.bytesPerElement=16,$c(`StructArrayLayout4f16`,Do);class zo extends io{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 v(this.anchorPointX,this.anchorPointY)}}zo.prototype.size=20;class Bo extends bo{get(e){return new zo(this,e)}}$c(`CollisionBoxArray`,Bo);class Co extends io{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Co.prototype.size=48;class Vo extends Mo{get(e){return new Co(this,e)}}$c(`PlacedSymbolArray`,Vo);class Lo extends io{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Lo.prototype.size=64;class Oo extends ko{get(e){return new Lo(this,e)}}$c(`SymbolInstanceArray`,Oo);class $o extends Io{getoffsetX(e){return this.float32[1*e+0]}}$c(`GlyphOffsetArray`,$o);class Ro extends uo{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}$c(`SymbolLineVertexArray`,Ro);class No extends io{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]}}No.prototype.size=12;class Uo extends Eo{get(e){return new No(this,e)}}$c(`TextAnchorOffsetArray`,Uo);class jo extends io{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]}}jo.prototype.size=8;class qo extends To{get(e){return new jo(this,e)}}$c(`FeatureIndexArray`,qo);class Go extends lo{}class Xo extends lo{}class Yo extends lo{}class Zo extends ho{}class Ho extends po{}class Wo extends fo{}class Ko extends yo{}class Jo extends mo{}class Qo extends go{}class ta extends xo{}class ea extends vo{}class na extends wo{}class ra extends So{}class ia extends Ao{}class sa extends Fo{}let{members:Nl}=Al([{name:`a_pos`,components:2,type:`Int16`}],4);class la{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,r,_,v){let b=this.segments[this.segments.length-1];return e>la.MAX_VERTEX_ARRAY_LENGTH&&je(`Max vertices per segment is ${la.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${la.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!b||b.vertexLength+e>la.MAX_VERTEX_ARRAY_LENGTH||b.sortKey!==v?this.createNewSegment(r,_,v):b}createNewSegment(e,r,_){let v={vertexOffset:e.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0,vaos:{}};return _!==void 0&&(v.sortKey=_),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(v),v}getOrCreateLatestSegment(e,r,_){return this.prepareSegment(0,e,r,_)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(let e of this.segments)for(let r in e.vaos)e.vaos[r].destroy()}static simpleSegment(e,r,_,v){return new la([{vertexOffset:e,primitiveOffset:r,vertexLength:_,primitiveLength:v,vaos:{},sortKey:0}])}}function Pl(e,r){return 256*(e=_e(Math.floor(e),0,255))+_e(Math.floor(r),0,255)}la.MAX_VERTEX_ARRAY_LENGTH=2**16-1,$c(`SegmentVector`,la);let Il=Al([{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`}]),Bl=Al([{name:`a_dasharray_from`,components:4,type:`Uint16`},{name:`a_dasharray_to`,components:4,type:`Uint16`}]);var Vl,Hl,Ul,Wl={exports:{}},Gl={exports:{}},Kl={exports:{}},ql=b(function(){if(Ul)return Wl.exports;Ul=1;var e=(Vl||(Vl=1,Gl.exports=function(e,r){var _,v,b,x,C,T,E,D;for(v=e.length-(_=3&e.length),b=r,C=3432918353,T=461845907,D=0;D>>16)*C&65535)<<16)&4294967295)<<15|E>>>17))*T+(((E>>>16)*T&65535)<<16)&4294967295)<<13|b>>>19))+((5*(b>>>16)&65535)<<16)&4294967295))+((58964+(x>>>16)&65535)<<16);switch(E=0,_){case 3:E^=(255&e.charCodeAt(D+2))<<16;case 2:E^=(255&e.charCodeAt(D+1))<<8;case 1:b^=E=(65535&(E=(E=(65535&(E^=255&e.charCodeAt(D)))*C+(((E>>>16)*C&65535)<<16)&4294967295)<<15|E>>>17))*T+(((E>>>16)*T&65535)<<16)&4294967295}return b^=e.length,b=2246822507*(65535&(b^=b>>>16))+((2246822507*(b>>>16)&65535)<<16)&4294967295,b=3266489909*(65535&(b^=b>>>13))+((3266489909*(b>>>16)&65535)<<16)&4294967295,(b^=b>>>16)>>>0}),Gl.exports),r=(Hl||(Hl=1,Kl.exports=function(e,r){for(var _,v=e.length,b=r^v,x=0;v>=4;)_=1540483477*(65535&(_=255&e.charCodeAt(x)|(255&e.charCodeAt(++x))<<8|(255&e.charCodeAt(++x))<<16|(255&e.charCodeAt(++x))<<24))+((1540483477*(_>>>16)&65535)<<16),b=1540483477*(65535&b)+((1540483477*(b>>>16)&65535)<<16)^(_=1540483477*(65535&(_^=_>>>24))+((1540483477*(_>>>16)&65535)<<16)),v-=4,++x;switch(v){case 3:b^=(255&e.charCodeAt(x+2))<<16;case 2:b^=(255&e.charCodeAt(x+1))<<8;case 1:b=1540483477*(65535&(b^=255&e.charCodeAt(x)))+((1540483477*(b>>>16)&65535)<<16)}return b=1540483477*(65535&(b^=b>>>13))+((1540483477*(b>>>16)&65535)<<16),(b^=b>>>15)>>>0}),Kl.exports);return Wl.exports=e,Wl.exports.murmur3=e,Wl.exports.murmur2=r,Wl.exports}());class ba{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,r,_,v){this.ids.push(Jl(e)),this.positions.push(r,_,v)}getPositions(e){if(!this.indexed)throw Error(`Trying to get index, but feature positions are not indexed`);let r=Jl(e),_=0,v=this.ids.length-1;for(;_>1;this.ids[e]>=r?v=e:_=e+1}let b=[];for(;this.ids[_]===r;)b.push({index:this.positions[3*_],start:this.positions[3*_+1],end:this.positions[3*_+2]}),_++;return b}static serialize(e,r){let _=new Float64Array(e.ids),v=new Uint32Array(e.positions);return Yl(_,v,0,_.length-1),r&&r.push(_.buffer,v.buffer),{ids:_,positions:v}}static deserialize(e){let r=new ba;return r.ids=e.ids,r.positions=e.positions,r.indexed=!0,r}}function Jl(e){let r=+e;return!isNaN(r)&&r<=2**53-1?r:ql(String(e))}function Yl(e,r,_,v){for(;_>1],x=_-1,C=v+1;for(;;){do x++;while(e[x]b);if(x>=C)break;Xl(e,x,C),Xl(r,3*x,3*C),Xl(r,3*x+1,3*C+1),Xl(r,3*x+2,3*C+2)}C-_`u_${e}`),this.type=_}setUniform(e,r,_){e.set(_.constantOr(this.value))}getBinding(e,r,_){return this.type===`color`?new Ia(e,r):new Ma(e,r)}}class Pa{constructor(e,r){this.uniformNames=r.map(e=>`u_${e}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,r){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,r.y,r.height,r.width]}setUniform(e,r,_,v){let b=null;v===`u_pattern_to`?b=this.patternTo:v===`u_pattern_from`?b=this.patternFrom:v===`u_dasharray_to`?b=this.dashTo:v===`u_dasharray_from`?b=this.dashFrom:v===`u_pixel_ratio_to`?b=this.pixelRatioTo:v===`u_pixel_ratio_from`&&(b=this.pixelRatioFrom),b!==null&&e.set(b)}getBinding(e,r,_){return _.startsWith(`u_pattern`)||_.startsWith(`u_dasharray_`)?new ka(e,r):new Ma(e,r)}}class Da{constructor(e,r,_,v){this.expression=e,this.type=_,this.maxValue=0,this.paintVertexAttributes=r.map(e=>({name:`a_${e}`,type:`Float32`,components:_===`color`?2:1,offset:0})),this.paintVertexArray=new v}populatePaintArray(e,r,_){let v=this.paintVertexArray.length,b=this.expression.evaluate(new Bs(0,_),r,{},_.canonical,[],_.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(v,e,b)}updatePaintArray(e,r,_,v,b){let x=this.expression.evaluate(new Bs(0,b),_,v);this._setPaintValue(e,r,x)}_setPaintValue(e,r,_){if(this.type===`color`){let v=Ql(_);for(let _=e;_`u_${e}_t`),this.type=_,this.useIntegerZoom=v,this.zoom=b,this.maxValue=0,this.paintVertexAttributes=r.map(e=>({name:`a_${e}`,type:`Float32`,components:_===`color`?4:2,offset:0})),this.paintVertexArray=new x}populatePaintArray(e,r,_){let v=this.expression.evaluate(new Bs(this.zoom,_),r,{},_.canonical,[],_.formattedSection),b=this.expression.evaluate(new Bs(this.zoom+1,_),r,{},_.canonical,[],_.formattedSection),x=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(x,e,v,b)}updatePaintArray(e,r,_,v,b){let x=this.expression.evaluate(new Bs(this.zoom,b),_,v),C=this.expression.evaluate(new Bs(this.zoom+1,b),_,v);this._setPaintValue(e,r,x,C)}_setPaintValue(e,r,_,v){if(this.type===`color`){let b=Ql(_),x=Ql(v);for(let _=e;_`#define HAS_UNIFORM_${e}`))}return e}getBinderAttributes(){let e=[];for(let r in this.binders){let _=this.binders[r];if(_ instanceof Da||_ instanceof za)for(let r=0;r<_.paintVertexAttributes.length;r++)e.push(_.paintVertexAttributes[r].name);else if(_ instanceof Ba){let r=_.getVertexAttributes();for(let _ of r)e.push(_.name)}}return e}getBinderUniforms(){let e=[];for(let r in this.binders){let _=this.binders[r];if(_ instanceof Fa||_ instanceof Pa||_ instanceof za)for(let r of _.uniformNames)e.push(r)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,r){let _=[];for(let v in this.binders){let b=this.binders[v];if(b instanceof Fa||b instanceof Pa||b instanceof za){for(let x of b.uniformNames)if(r[x]){let C=b.getBinding(e,r[x],x);_.push({name:x,property:v,binding:C})}}}return _}setUniforms(e,r,_,v){for(let{name:e,property:b,binding:x}of r)this.binders[b].setUniform(x,v,_.get(b),e)}updatePaintBuffers(e){this._buffers=[];for(let r in this.binders){let _=this.binders[r];if(e&&_ instanceof Ba){let r=e.fromScale===2?_.zoomInPaintVertexBuffer:_.zoomOutPaintVertexBuffer;r&&this._buffers.push(r)}else (_ instanceof Da||_ instanceof za)&&_.paintVertexBuffer&&this._buffers.push(_.paintVertexBuffer)}}upload(e){for(let r in this.binders){let _=this.binders[r];(_ instanceof Da||_ instanceof za||_ instanceof Ba)&&_.upload(e)}this.updatePaintBuffers()}destroy(){for(let e in this.binders){let r=this.binders[e];(r instanceof Da||r instanceof za||r instanceof Ba)&&r.destroy()}}}class Oa{constructor(e,r,_=()=>!0){this.programConfigurations={};for(let v of e)this.programConfigurations[v.id]=new La(v,r,_);this.needsUpload=!1,this._featureMap=new ba,this._bufferOffset=0}populatePaintArrays(e,r,_,v){for(let _ in this.programConfigurations)this.programConfigurations[_].populatePaintArrays(e,r,v);r.id!==void 0&&this._featureMap.add(r.id,_,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,r,_,v){for(let b of _)this.needsUpload=this.programConfigurations[b.id].updatePaintArrays(e,this._featureMap,r,b,v)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(let r in this.programConfigurations)this.programConfigurations[r].upload(e);this.needsUpload=!1}}destroy(){for(let e in this.programConfigurations)this.programConfigurations[e].destroy()}}function $l(e,r){return{"text-opacity":[`opacity`],"icon-opacity":[`opacity`],"text-color":[`fill_color`],"icon-color":[`fill_color`],"text-halo-color":[`halo_color`],"icon-halo-color":[`halo_color`],"text-halo-blur":[`halo_blur`],"icon-halo-blur":[`halo_blur`],"text-halo-width":[`halo_width`],"icon-halo-width":[`halo_width`],"line-gap-width":[`gapwidth`],"line-dasharray":[`dasharray_to`,`dasharray_from`],"line-pattern":[`pattern_to`,`pattern_from`,`pixel_ratio_to`,`pixel_ratio_from`],"fill-pattern":[`pattern_to`,`pattern_from`,`pixel_ratio_to`,`pixel_ratio_from`],"fill-extrusion-pattern":[`pattern_to`,`pattern_from`,`pixel_ratio_to`,`pixel_ratio_from`]}[e]||[e.replace(`${r}-`,``).replace(/-/g,`_`)]}function eu(e,r,_){let v={color:{source:fo,composite:Do},number:{source:Io,composite:fo}},b=function(e){return{"line-pattern":{source:Ko,composite:Ko},"fill-pattern":{source:Ko,composite:Ko},"fill-extrusion-pattern":{source:Ko,composite:Ko},"line-dasharray":{source:Jo,composite:Jo}}[e]}(e);return b&&b[_]||v[r][_]}$c(`ConstantBinder`,Fa),$c(`CrossFadedConstantBinder`,Pa),$c(`SourceExpressionBinder`,Da),$c(`CrossFadedPatternBinder`,Ca),$c(`CrossFadedDasharrayBinder`,Va),$c(`CompositeExpressionBinder`,za),$c(`ProgramConfiguration`,La,{omit:[`_buffers`]}),$c(`ProgramConfigurationSet`,Oa);let tu=2**14-1,nu=-tu-1;function ru(e){let r=ce/e.extent,_=e.loadGeometry();for(let e=0;e<_.length;e++){let v=_[e];for(let e=0;e_.x+1||x<_.y||x>_.y+1)&&je(`Geometry exceeds allowed extent, reduce your vector tile buffer size`)}}return _}function iu(e,r){return{type:e.type,id:e.id,properties:e.properties,geometry:r?ru(e):[]}}let au=-32768;function ou(e,r,_,v,b){e.emplaceBack(au+8*r+v,au+8*_+b)}class Ya{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Xo,this.indexArray=new ia,this.segments=new la,this.programConfigurations=new Oa(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,r,_){let v=this.layers[0],b=[],x=null,C=!1,T=v.type===`heatmap`;if(v.type===`circle`){let e=v;x=e.layout.get(`circle-sort-key`),C=!x.isConstant(),T||=e.paint.get(`circle-pitch-alignment`)===`map`}let E=T?r.subdivisionGranularity.circle:1;for(let{feature:r,id:v,index:T,sourceLayerIndex:E}of e){let e=this.layers[0]._featureFilter.needGeometry,D=iu(r,e);if(!this.layers[0]._featureFilter.filter(new Bs(this.zoom),D,_))continue;let O=C?x.evaluate(D,{},_):void 0,k={id:v,properties:r.properties,type:r.type,sourceLayerIndex:E,index:T,geometry:e?D.geometry:ru(r),patterns:{},sortKey:O};b.push(k)}C&&b.sort((e,r)=>e.sortKey-r.sortKey);for(let v of b){let{geometry:b,index:x,sourceLayerIndex:C}=v,T=e[x].feature;this.addFeature(v,b,x,_,E),r.featureIndex.insert(T,b,x,C,this.index)}}update(e,r,_){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,{imagePositions:_})}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Nl),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,r,_,v,b=1){let x;switch(b){case 1:x=[0,7];break;case 3:x=[0,2,5,7];break;case 5:x=[0,1,3,4,6,7];break;case 7:x=[0,1,2,3,4,5,6,7];break;default:throw Error(`Invalid circle bucket granularity: ${b}; valid values are 1, 3, 5, 7.`)}let C=x.length;for(let _ of r)for(let r of _){let _=r.x,v=r.y;if(_<0||_>=ce||v<0||v>=ce)continue;let b=this.segments.prepareSegment(C*C,this.layoutVertexArray,this.indexArray,e.sortKey),T=b.vertexLength;for(let e=0;e1){if(du(e,r))return!0;for(let v=0;v1?_:_.sub(r)._mult(b)._add(r))}function _u(e,r){let _,v,b,x=!1;for(let C=0;Cr.y!=b.y>r.y&&r.x<(b.x-v.x)*(r.y-v.y)/(b.y-v.y)+v.x&&(x=!x)}return x}function vu(e,r){let _=!1;for(let v=0,b=e.length-1;vr.y!=C.y>r.y&&r.x<(C.x-x.x)*(r.y-x.y)/(C.y-x.y)+x.x&&(_=!_)}return _}function yu(e,r,_){let v=_[0],b=_[2];if(e.xb.x&&r.x>b.x||e.yb.y&&r.y>b.y)return!1;let x=Me(e,r,_[0]);return x!==Me(e,r,_[1])||x!==Me(e,r,_[2])||x!==Me(e,r,_[3])}function xu(e,r,_){let v=r.paint.get(e).value;return v.kind===`constant`?v.value:_.programConfigurations.get(r.id).getMaxValue(e)}function Su(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Cu(e,r,_,b,x){if(!r[0]&&!r[1])return e;let C=v.convert(r)._mult(x);_===`viewport`&&C._rotate(-b);let T=[];for(let r=0;rMu(e,r,_,v))}(E,b,C,T),j=D),ju({queryGeometry:A,size:j,transform:b,unwrappedTileID:C,getElevation:T,pitchAlignment:k,pitchScale:O},v)}}class vl extends Ya{}let Lu;$c(`HeatmapBucket`,vl,{omit:[`layers`]});var zu={get paint(){return Lu||=new Ws({"heatmap-radius":new Xs($.paint_heatmap[`heatmap-radius`]),"heatmap-weight":new Xs($.paint_heatmap[`heatmap-weight`]),"heatmap-intensity":new Gs($.paint_heatmap[`heatmap-intensity`]),"heatmap-color":new Hs($.paint_heatmap[`heatmap-color`]),"heatmap-opacity":new Gs($.paint_heatmap[`heatmap-opacity`])})}};function Vu(e,{width:r,height:_},v,b){if(b){if(b instanceof Uint8ClampedArray)b=new Uint8Array(b.buffer);else if(b.length!==r*_*v)throw RangeError(`mismatched image size. expected: ${b.length} but got: ${r*_*v}`)}else b=new Uint8Array(r*_*v);return e.width=r,e.height=_,e.data=b,e}function Hu(e,{width:r,height:_},v){if(r===e.width&&_===e.height)return;let b=Vu({},{width:r,height:_},v);Uu(e,b,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,r),height:Math.min(e.height,_)},v),e.width=r,e.height=_,e.data=b.data}function Uu(e,r,_,v,b,x){if(b.width===0||b.height===0)return r;if(b.width>e.width||b.height>e.height||_.x>e.width-b.width||_.y>e.height-b.height)throw RangeError(`out of range source coordinates for image copy`);if(b.width>r.width||b.height>r.height||v.x>r.width-b.width||v.y>r.height-b.height)throw RangeError(`out of range destination coordinates for image copy`);let C=e.data,T=r.data;if(C===T)throw Error(`srcData equals dstData, so image is already copied`);for(let E=0;E{r[e.evaluationKey]=C;let T=e.expression.evaluate(r);b.setPixel(v/4/_,x/4,T)};if(e.clips)for(let r=0,b=0;rthis.max&&(this.max=_),_=this.dim+1||r<-1||r>=this.dim+1)throw RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${r}, dim: ${this.dim}`);return(r+1)*this.stride+(e+1)}unpack(e,r,_){return e*this.redFactor+r*this.greenFactor+_*this.blueFactor-this.baseShift}pack(e){return ed(e,this.getUnpackVector())}getPixels(){return new kl({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,r,_){if(this.dim!==e.dim)throw Error(`dem dimension mismatch`);let v=r*this.dim,b=r*this.dim+this.dim,x=_*this.dim,C=_*this.dim+this.dim;switch(r){case-1:v=b-1;break;case 1:b=v+1}switch(_){case-1:x=C-1;break;case 1:C=x+1}let T=-r*this.dim,E=-_*this.dim;for(let r=x;r0)for(let b=r;b<_;b+=v)x=Vd(b/v|0,e[b],e[b+1],x);else for(let b=_-v;b>=r;b-=v)x=Vd(b/v|0,e[b],e[b+1],x);return x&&Nd(x,x.next)&&(Hd(x),x=x.next),x}function od(e,r){if(!e)return e;r||=e;let _,v=e;do if(_=!1,v.steiner||!Nd(v,v.next)&&Md(v.prev,v,v.next)!==0)v=v.next;else{if(Hd(v),v=r=v.prev,v===v.next)break;_=!0}while(_||v!==r);return r}function ld(e,r,_,v,b,x,C){if(!e)return;!C&&x&&function(e,r,_,v){let b=e;do b.z===0&&(b.z=Dd(b.x,b.y,r,_,v)),b.prevZ=b.prev,b.nextZ=b.next,b=b.next;while(b!==e);b.prevZ.nextZ=null,b.prevZ=null,function(e){let r,_=1;do{let v,b=e;e=null;let x=null;for(r=0;b;){r++;let C=b,T=0;for(let e=0;e<_&&(T++,C=C.nextZ,C);e++);let E=_;for(;T>0||E>0&&C;)T!==0&&(E===0||!C||b.z<=C.z)?(v=b,b=b.nextZ,T--):(v=C,C=C.nextZ,E--),x?x.nextZ=v:e=v,v.prevZ=x,x=v;b=C}x.nextZ=null,_*=2}while(r>1)}(b)}(e,v,b,x);let T=e;for(;e.prev!==e.next;){let E=e.prev,D=e.next;if(x?dd(e,v,b,x):ud(e))r.push(E.i,e.i,D.i),Hd(e),e=D.next,T=D.next;else if((e=D)===T){C?C===1?ld(e=md(od(e),r),r,_,v,b,x,2):C===2&&vd(e,r,_,v,b,x):ld(od(e),r,_,v,b,x,1);break}}}function ud(e){let r=e.prev,_=e,v=e.next;if(Md(r,_,v)>=0)return!1;let b=r.x,x=_.x,C=v.x,T=r.y,E=_.y,D=v.y,O=Math.min(b,x,C),k=Math.min(T,E,D),A=Math.max(b,x,C),j=Math.max(T,E,D),F=v.next;for(;F!==r;){if(F.x>=O&&F.x<=A&&F.y>=k&&F.y<=j&&Ad(b,T,x,E,C,D,F.x,F.y)&&Md(F.prev,F,F.next)>=0)return!1;F=F.next}return!0}function dd(e,r,_,v){let b=e.prev,x=e,C=e.next;if(Md(b,x,C)>=0)return!1;let T=b.x,E=x.x,D=C.x,O=b.y,k=x.y,A=C.y,j=Math.min(T,E,D),F=Math.min(O,k,A),R=Math.max(T,E,D),z=Math.max(O,k,A),B=Dd(j,F,r,_,v),H=Dd(R,z,r,_,v),K=e.prevZ,q=e.nextZ;for(;K&&K.z>=B&&q&&q.z<=H;){if(K.x>=j&&K.x<=R&&K.y>=F&&K.y<=z&&K!==b&&K!==C&&Ad(T,O,E,k,D,A,K.x,K.y)&&Md(K.prev,K,K.next)>=0||(K=K.prevZ,q.x>=j&&q.x<=R&&q.y>=F&&q.y<=z&&q!==b&&q!==C&&Ad(T,O,E,k,D,A,q.x,q.y)&&Md(q.prev,q,q.next)>=0))return!1;q=q.nextZ}for(;K&&K.z>=B;){if(K.x>=j&&K.x<=R&&K.y>=F&&K.y<=z&&K!==b&&K!==C&&Ad(T,O,E,k,D,A,K.x,K.y)&&Md(K.prev,K,K.next)>=0)return!1;K=K.prevZ}for(;q&&q.z<=H;){if(q.x>=j&&q.x<=R&&q.y>=F&&q.y<=z&&q!==b&&q!==C&&Ad(T,O,E,k,D,A,q.x,q.y)&&Md(q.prev,q,q.next)>=0)return!1;q=q.nextZ}return!0}function md(e,r){let _=e;do{let v=_.prev,b=_.next.next;!Nd(v,b)&&Pd(v,_,_.next,b)&&zd(v,b)&&zd(b,v)&&(r.push(v.i,_.i,b.i),Hd(_),Hd(_.next),_=e=b),_=_.next}while(_!==e);return od(_)}function vd(e,r,_,v,b,x){let C=e;do{let e=C.next.next;for(;e!==C.prev;){if(C.i!==e.i&&jd(C,e)){let T=Bd(C,e);C=od(C,C.next),T=od(T,T.next),ld(C,r,_,v,b,x,0),ld(T,r,_,v,b,x,0);return}e=e.next}C=C.next}while(C!==e)}function bd(e,r){let _=e.x-r.x;return _===0&&(_=e.y-r.y,_===0)&&(_=(e.next.y-e.y)/(e.next.x-e.x)-(r.next.y-r.y)/(r.next.x-r.x)),_}function xd(e,r){let _=function(e,r){let _=r,v=e.x,b=e.y,x,C=-1/0;if(Nd(e,_))return _;do{if(Nd(e,_.next))return _.next;if(b<=_.y&&b>=_.next.y&&_.next.y!==_.y){let e=_.x+(b-_.y)*(_.next.x-_.x)/(_.next.y-_.y);if(e<=v&&e>C&&(C=e,x=_.x<_.next.x?_:_.next,e===v))return x}_=_.next}while(_!==r);if(!x)return null;let T=x,E=x.x,D=x.y,O=1/0;_=x;do{if(v>=_.x&&_.x>=E&&v!==_.x&&kd(bx.x||_.x===x.x&&Cd(x,_)))&&(x=_,O=r)}_=_.next}while(_!==T);return x}(e,r);if(!_)return r;let v=Bd(_,e);return od(v,v.next),od(_,_.next)}function Cd(e,r){return Md(e.prev,e,r.prev)<0&&Md(r.next,e,e.next)<0}function Dd(e,r,_,v,b){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-_)*b|0)|e<<8))|e<<4))|e<<2))|e<<1))|(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=(r-v)*b|0)|r<<8))|r<<4))|r<<2))|r<<1))<<1}function Od(e){let r=e,_=e;do(r.x<_.x||r.x===_.x&&r.y<_.y)&&(_=r),r=r.next;while(r!==e);return _}function kd(e,r,_,v,b,x,C,T){return(b-C)*(r-T)>=(e-C)*(x-T)&&(e-C)*(v-T)>=(_-C)*(r-T)&&(_-C)*(x-T)>=(b-C)*(v-T)}function Ad(e,r,_,v,b,x,C,T){return!(e===C&&r===T)&&kd(e,r,_,v,b,x,C,T)}function jd(e,r){return e.next.i!==r.i&&e.prev.i!==r.i&&!function(e,r){let _=e;do{if(_.i!==e.i&&_.next.i!==e.i&&_.i!==r.i&&_.next.i!==r.i&&Pd(_,_.next,e,r))return!0;_=_.next}while(_!==e);return!1}(e,r)&&(zd(e,r)&&zd(r,e)&&function(e,r){let _=e,v=!1,b=(e.x+r.x)/2,x=(e.y+r.y)/2;do _.y>x!=_.next.y>x&&_.next.y!==_.y&&b<(_.next.x-_.x)*(x-_.y)/(_.next.y-_.y)+_.x&&(v=!v),_=_.next;while(_!==e);return v}(e,r)&&(Md(e.prev,e,r.prev)||Md(e,r.prev,r))||Nd(e,r)&&Md(e.prev,e,e.next)>0&&Md(r.prev,r,r.next)>0)}function Md(e,r,_){return(r.y-e.y)*(_.x-r.x)-(r.x-e.x)*(_.y-r.y)}function Nd(e,r){return e.x===r.x&&e.y===r.y}function Pd(e,r,_,v){let b=Rd(Md(e,r,_)),x=Rd(Md(e,r,v)),C=Rd(Md(_,v,e)),T=Rd(Md(_,v,r));return b!==x&&C!==T||!(b!==0||!Ld(e,_,r))||!(x!==0||!Ld(e,v,r))||!(C!==0||!Ld(_,e,v))||!(T!==0||!Ld(_,r,v))}function Ld(e,r,_){return r.x<=Math.max(e.x,_.x)&&r.x>=Math.min(e.x,_.x)&&r.y<=Math.max(e.y,_.y)&&r.y>=Math.min(e.y,_.y)}function Rd(e){return e>0?1:e<0?-1:0}function zd(e,r){return Md(e.prev,e,e.next)<0?Md(e,r,e.next)>=0&&Md(e,e.prev,r)>=0:Md(e,r,e.prev)<0||Md(e,e.next,r)<0}function Bd(e,r){let _=Ud(e.i,e.x,e.y),v=Ud(r.i,r.x,r.y),b=e.next,x=r.prev;return e.next=r,r.prev=e,_.next=b,b.prev=_,v.next=_,_.prev=v,x.next=v,v.prev=x,v}function Vd(e,r,_,v){let b=Ud(e,r,_);return v?(b.next=v.next,b.prev=v,v.next.prev=b,v.next=b):(b.prev=b,b.next=b),b}function Hd(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Ud(e,r,_){return{i:e,x:r,y:_,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class mu{constructor(e,r){if(r>e)throw Error(`Min granularity must not be greater than base granularity.`);this._baseZoomGranularity=e,this._minGranularity=r}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||r>32767)throw Error(`Vertex coordinates are out of signed 16 bit integer range.`);let _=0|Math.round(e),v=0|Math.round(r),b=this._getKey(_,v);if(this._vertexDictionary.has(b))return this._vertexDictionary.get(b);let x=this._vertexBuffer.length/2;return this._vertexDictionary.set(b,x),this._vertexBuffer.push(_,v),x}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,r){let _=[];for(let v=0;v0?(_.push(b),_.push(C),_.push(x)):(_.push(b),_.push(x),_.push(C))}return _}(this._vertexBuffer,e);let r=[],_=e.length;for(let v=0;v<_;v+=3){let _=[e[v+0],e[v+1],e[v+2]],b=[this._vertexBuffer[2*e[v+0]+0],this._vertexBuffer[2*e[v+0]+1],this._vertexBuffer[2*e[v+1]+0],this._vertexBuffer[2*e[v+1]+1],this._vertexBuffer[2*e[v+2]+0],this._vertexBuffer[2*e[v+2]+1]],x=1/0,C=1/0,T=-1/0,E=-1/0;for(let e=0;e<3;e++){let r=b[2*e],_=b[2*e+1];x=Math.min(x,r),T=Math.max(T,r),C=Math.min(C,_),E=Math.max(E,_)}if(x===T||C===E)continue;let D=Math.floor(x/this._granularityCellSize),O=Math.ceil(T/this._granularityCellSize),k=Math.floor(C/this._granularityCellSize),A=Math.ceil(E/this._granularityCellSize);if(D!==O||k!==A)for(let e=k;e=1||K<=0)||R&&(Tb)){D>=v&&D<=b&&x.push(_[(e+1)%3]);continue}!R&&H>0&&x.push(this._vertexToIndex(C+A*H,T+j*H));let q=C+A*Math.max(H,0),Y=C+A*Math.min(K,1);F||this._generateIntraEdgeVertices(x,C,T,E,D,q,Y),!R&&K<1&&x.push(this._vertexToIndex(C+A*K,T+j*K)),(R||D>=v&&D<=b)&&x.push(_[(e+1)%3]),!R&&(D<=v||D>=b)&&this._generateInterEdgeVertices(x,C,T,E,D,O,k,Y,v,b)}return x}_generateIntraEdgeVertices(e,r,_,v,b,x,C){let T=v-r,E=b-_,D=E===0,O=D?Math.min(r,v):Math.min(x,C),k=D?Math.max(r,v):Math.max(x,C),A=Math.floor(O/this._granularityCellSize)+1,j=Math.ceil(k/this._granularityCellSize)-1;if(D?r=A;v--){let b=v*this._granularityCellSize;e.push(this._vertexToIndex(b,_+E*(b-r)/T))}}_generateInterEdgeVertices(e,r,_,v,b,x,C,T,E,D){let O=b-_,k=x-v,A=C-b,j=(E-b)/A,F=(D-b)/A,R=Math.min(j,F),z=Math.max(j,F),B=v+k*R,H=Math.floor(Math.min(B,T)/this._granularityCellSize)+1,K=Math.ceil(Math.max(B,T)/this._granularityCellSize)-1,q=T=1||z<=0){let e=_-C,v=x+(r-x)*Math.min((E-C)/e,(D-C)/e);H=Math.floor(Math.min(v,T)/this._granularityCellSize)+1,K=Math.ceil(Math.max(v,T)/this._granularityCellSize)-1,q=T0?D:E;if(q)for(let r=H;r<=K;r++)e.push(this._vertexToIndex(r*this._granularityCellSize,X));else for(let r=K;r>=H;r--)e.push(this._vertexToIndex(r*this._granularityCellSize,X))}_generateOutline(e){let r=[];for(let _ of e){let e=Zd(_,this._granularity,!0),v=this._pointArrayToIndices(e),b=[];for(let e=1;eb==(x===Wd)?(e.push(_),e.push(r),e.push(this._vertexToIndex(v,x)),e.push(this._vertexToIndex(b,x)),e.push(_),e.push(this._vertexToIndex(v,x))):(e.push(r),e.push(_),e.push(this._vertexToIndex(v,x)),e.push(_),e.push(this._vertexToIndex(b,x)),e.push(this._vertexToIndex(v,x)))}_fillPoles(e,r,_){let v=this._vertexBuffer,b=ce,x=e.length;for(let C=2;C80*_){T=e[0],E=e[1];let r=T,v=E;for(let x=_;xr&&(r=_),b>v&&(v=b)}D=Math.max(r-T,v-E),D=D===0?0:32767/D}return ld(x,C,_,T,E,D,0),C}(_,v),r=this._convertIndices(_,e);b=this._subdivideTrianglesScanline(r)}catch(e){console.error(e)}let x=[];return r&&(x=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(b),{verticesFlattened:this._vertexBuffer,indicesTriangles:b,indicesLineList:x}}_convertIndices(e,r){let _=[];for(let v=0;v0?(Math.floor(H/T)+1)*T:(Math.ceil(H/T)-1)*T,r=R>0?(Math.floor(K/T)+1)*T:(Math.ceil(K/T)-1)*T,_=Math.abs(H-e),b=Math.abs(K-r),x=Math.abs(H-O),C=Math.abs(K-k),D=A?_/z:1/0,q=j?b/B:1/0;if((x<=_||!A)&&(C<=b||!j))break;if(D=0?C-1:x-1,b=(T+1)%x,E=e[2*r[v]],D=e[2*r[b]],O=e[2*r[C]],k=e[2*r[C]+1],A=e[2*r[T]+1],j=!1;if(ED)j=!1;else{let _=A-k,x=-(e[2*r[T]]-O),C=k((D-O)*_+(e[2*r[b]+1]-k)*x)*C&&(j=!0)}if(j){let e=r[v],b=r[C],E=r[T];e!==b&&e!==E&&b!==E&&_.push(E,b,e),C--,C<0&&(C=x-1)}else{let e=r[b],v=r[C],E=r[T];e!==v&&e!==E&&v!==E&&_.push(E,v,e),T++,T>=x&&(T=0)}if(v===b)break}}function $d(e,r,_,v,b,x,C,T,E){let D=b.length/2,O=C&&T&&E;if(Dla.MAX_VERTEX_ARRAY_LENGTH&&(D=e.createNewSegment(r,_),E=T.count,R=!0,z=!0,B=!0,O=0);let H=cf(C,v,x,T,A,R,D),K=cf(C,v,x,T,j,z,D),q=cf(C,v,x,T,F,B,D);_.emplaceBack(O+H-E,O+K-E,O+q-E),D.primitiveLength++}})(r,_,v,b,x,e),O&&function(e,r,_,v,b,x){let C=[];for(let e=0;ela.MAX_VERTEX_ARRAY_LENGTH&&(D=e.createNewSegment(r,_),E=T.count,F=!0,R=!0,O=0);let z=cf(C,v,x,T,b,F,D),B=cf(C,v,x,T,k,R,D);_.emplaceBack(O+z-E,O+B-E),D.primitiveLength++}}}(C,_,T,b,E,e),r.forceNewSegmentOnNextPrepare(),C?.forceNewSegmentOnNextPrepare()}function cf(e,r,_,v,b,x,C){if(x){let x=v.count;return _(r[2*b],r[2*b+1]),e[b]=v.count,v.count++,C.vertexLength++,x}return e[b]}class ku{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new Yo,this.indexArray=new ia,this.indexArray2=new sa,this.programConfigurations=new Oa(e.layers,e.zoom),this.segments=new la,this.segments2=new la,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,r,_){this.hasDependencies=nd(`fill`,this.layers,r);let v=this.layers[0].layout.get(`fill-sort-key`),b=!v.isConstant(),x=[];for(let{feature:C,id:T,index:E,sourceLayerIndex:D}of e){let e=this.layers[0]._featureFilter.needGeometry,O=iu(C,e);if(!this.layers[0]._featureFilter.filter(new Bs(this.zoom),O,_))continue;let k=b?v.evaluate(O,{},_,r.availableImages):void 0,A={id:T,properties:C.properties,type:C.type,sourceLayerIndex:D,index:E,geometry:e?O.geometry:ru(C),patterns:{},sortKey:k};x.push(A)}b&&x.sort((e,r)=>e.sortKey-r.sortKey);for(let v of x){let{geometry:b,index:x,sourceLayerIndex:C}=v;if(this.hasDependencies){let e=rd(`fill`,this.layers,v,{zoom:this.zoom},r);this.patternFeatures.push(e)}else this.addFeature(v,b,x,_,{},r.subdivisionGranularity);r.featureIndex.insert(e[x].feature,b,x,C,this.index)}}update(e,r,_){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,{imagePositions:_})}addFeatures(e,r,_){for(let v of this.patternFeatures)this.addFeature(v,v.geometry,v.index,r,_,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,td),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,r,_,v,b,x){for(let e of pa(r,500)){let r=Jd(e,v,x.fill.getGranularityForZoomLevel(v.z)),_=this.layoutVertexArray;$d((e,r)=>{_.emplaceBack(e,r)},this.segments,this.layoutVertexArray,this.indexArray,r.verticesFlattened,r.indicesTriangles,this.segments2,this.indexArray2,r.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,_,{imagePositions:b,canonical:v})}}let uf,df;$c(`FillBucket`,ku,{omit:[`layers`,`patternFeatures`]});var ff={get paint(){return df||=new Ws({"fill-antialias":new Gs($.paint_fill[`fill-antialias`]),"fill-opacity":new Xs($.paint_fill[`fill-opacity`]),"fill-color":new Xs($.paint_fill[`fill-color`]),"fill-outline-color":new Xs($.paint_fill[`fill-outline-color`]),"fill-translate":new Gs($.paint_fill[`fill-translate`]),"fill-translate-anchor":new Gs($.paint_fill[`fill-translate-anchor`]),"fill-pattern":new Ys($.paint_fill[`fill-pattern`])})},get layout(){return uf||=new Ws({"fill-sort-key":new Xs($.layout_fill[`fill-sort-key`])})}};class Fu extends Qs{constructor(e,r){super(e,ff,r)}recalculate(e,r){super.recalculate(e,r);let _=this.paint._values[`fill-outline-color`];_.value.kind===`constant`&&_.value.value===void 0&&(this.paint._values[`fill-outline-color`]=this.paint._values[`fill-color`])}createBucket(e){return new ku(e)}queryRadius(){return Su(this.paint.get(`fill-translate`))}queryIntersectsFeature({queryGeometry:e,geometry:r,transform:_,pixelsToTileUnits:v}){return lu(Cu(e,this.paint.get(`fill-translate`),this.paint.get(`fill-translate-anchor`),-_.bearingInRadians,v),r)}isTileClipped(){return!0}}let pf=Al([{name:`a_pos`,components:2,type:`Int16`},{name:`a_normal_ed`,components:4,type:`Int16`}],4),mf=Al([{name:`a_centroid`,components:2,type:`Int16`}],4),{members:hf}=pf;class Bu{constructor(e,r,_,v,b){this.properties={},this.extent=_,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=v,this._values=b,e.readFields(gf,this,r)}loadGeometry(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,_=[],b,x=1,C=0,T=0,E=0;for(;e.pos>3}if(C--,x===1||x===2)T+=e.readSVarint(),E+=e.readSVarint(),x===1&&(b&&_.push(b),b=[]),b&&b.push(new v(T,E));else{if(x!==7)throw Error(`unknown command ${x}`);b&&b.push(b[0].clone())}}return b&&_.push(b),_}bbox(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,_=1,v=0,b=0,x=0,C=1/0,T=-1/0,E=1/0,D=-1/0;for(;e.pos>3}if(v--,_===1||_===2)b+=e.readSVarint(),x+=e.readSVarint(),bT&&(T=b),xD&&(D=x);else if(_!==7)throw Error(`unknown command ${_}`)}return[C,E,T,D]}toGeoJSON(e,r,_){let v=this.extent*2**_,b=this.extent*e,x=this.extent*r,C=this.loadGeometry();function T(e){return[360*(e.x+b)/v-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+x)/v)*Math.PI))-90]}function E(e){return e.map(T)}let D;if(this.type===1){let e=[];for(let r of C)e.push(r[0]);let r=E(e);D=e.length===1?{type:`Point`,coordinates:r[0]}:{type:`MultiPoint`,coordinates:r}}else if(this.type===2){let e=C.map(E);D=e.length===1?{type:`LineString`,coordinates:e[0]}:{type:`MultiLineString`,coordinates:e}}else{if(this.type!==3)throw Error(`unknown feature type`);{let e=_f(C),r=[];for(let _ of e)r.push(_.map(E));D=r.length===1?{type:`Polygon`,coordinates:r[0]}:{type:`MultiPolygon`,coordinates:r}}}let O={type:`Feature`,geometry:D,properties:this.properties};return this.id!=null&&(O.id=this.id),O}}function gf(e,r,_){e===1?r.id=_.readVarint():e===2?function(e,r){let _=e.readVarint()+e.pos;for(;e.pos<_;){let _=r._keys[e.readVarint()],v=r._values[e.readVarint()];r.properties[_]=v}}(_,r):e===3?r.type=_.readVarint():e===4&&(r._geometry=_.pos)}function _f(e){let r=e.length;if(r<=1)return[e];let _=[],v,b;for(let x=0;x=this._features.length)throw Error(`feature index out of bounds`);this._pbf.pos=this._features[e];let r=this._pbf.readVarint()+this._pbf.pos;return new Bu(this._pbf,r,this.extent,this._keys,this._values)}}function yf(e,r,_){e===15?r.version=_.readVarint():e===1?r.name=_.readString():e===5?r.extent=_.readVarint():e===2?r._features.push(_.pos):e===3?r._keys.push(_.readString()):e===4&&r._values.push(function(e){let r=null,_=e.readVarint()+e.pos;for(;e.pos<_;){let _=e.readVarint()>>3;r=_===1?e.readString():_===2?e.readFloat():_===3?e.readDouble():_===4?e.readVarint64():_===5?e.readVarint():_===6?e.readSVarint():_===7?e.readBoolean():null}if(r==null)throw Error(`unknown feature value`);return r}(_))}class Ru{constructor(e,r){this.layers=e.readFields(bf,{},r)}}function bf(e,r,_){if(e===3){let e=new Ou(_,_.readVarint()+_.pos);e.length&&(r[e.name]=e)}}let xf=2**13;function Sf(e,r,_,v,b,x,C,T){e.emplaceBack(r,_,2*Math.floor(v*xf)+C,b*xf*2,x*xf*2,Math.round(T))}class qu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Zo,this.centroidVertexArray=new Go,this.indexArray=new ia,this.programConfigurations=new Oa(e.layers,e.zoom),this.segments=new la,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,r,_){this.features=[],this.hasDependencies=nd(`fill-extrusion`,this.layers,r);for(let{feature:v,id:b,index:x,sourceLayerIndex:C}of e){let e=this.layers[0]._featureFilter.needGeometry,T=iu(v,e);if(!this.layers[0]._featureFilter.filter(new Bs(this.zoom),T,_))continue;let E={id:b,sourceLayerIndex:C,index:x,geometry:e?T.geometry:ru(v),properties:v.properties,type:v.type,patterns:{}};this.hasDependencies?this.features.push(rd(`fill-extrusion`,this.layers,E,{zoom:this.zoom},r)):this.addFeature(E,E.geometry,x,_,{},r.subdivisionGranularity),r.featureIndex.insert(v,E.geometry,x,C,this.index,!0)}}addFeatures(e,r,_){for(let v of this.features){let{geometry:b}=v;this.addFeature(v,b,v.index,r,_,e.subdivisionGranularity)}}update(e,r,_){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,{imagePositions:_})}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,hf),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,mf.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,r,_,v,b,x){for(let _ of pa(r,500)){let r={x:0,y:0,sampleCount:0},b=this.layoutVertexArray.length;this.processPolygon(r,v,e,_,x);let C=this.layoutVertexArray.length-b,T=Math.floor(r.x/r.sampleCount),E=Math.floor(r.y/r.sampleCount);for(let e=0;e{Sf(D,e,r,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,E.verticesFlattened,E.indicesTriangles)}_generateSideFaces(e,r){let _=0;for(let v=1;vla.MAX_VERTEX_ARRAY_LENGTH&&(r.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let C=b.sub(x)._perp()._unit(),T=x.dist(b);_+T>32768&&(_=0),Sf(this.layoutVertexArray,b.x,b.y,C.x,C.y,0,0,_),Sf(this.layoutVertexArray,b.x,b.y,C.x,C.y,0,1,_),_+=T,Sf(this.layoutVertexArray,x.x,x.y,C.x,C.y,0,0,_),Sf(this.layoutVertexArray,x.x,x.y,C.x,C.y,0,1,_);let E=r.segment.vertexLength;this.indexArray.emplaceBack(E,E+2,E+1),this.indexArray.emplaceBack(E+1,E+2,E+3),r.segment.vertexLength+=4,r.segment.primitiveLength+=2}}}function Cf(e,r){for(let _=0;_ce)||e.y===r.y&&(e.y<0||e.y>ce)}function Tf(e){return e.every(e=>e.x<0)||e.every(e=>e.x>ce)||e.every(e=>e.y<0)||e.every(e=>e.y>ce)}let Ef;$c(`FillExtrusionBucket`,qu,{omit:[`layers`,`features`]});var Df={get paint(){return Ef||=new Ws({"fill-extrusion-opacity":new Gs($[`paint_fill-extrusion`][`fill-extrusion-opacity`]),"fill-extrusion-color":new Xs($[`paint_fill-extrusion`][`fill-extrusion-color`]),"fill-extrusion-translate":new Gs($[`paint_fill-extrusion`][`fill-extrusion-translate`]),"fill-extrusion-translate-anchor":new Gs($[`paint_fill-extrusion`][`fill-extrusion-translate-anchor`]),"fill-extrusion-pattern":new Ys($[`paint_fill-extrusion`][`fill-extrusion-pattern`]),"fill-extrusion-height":new Xs($[`paint_fill-extrusion`][`fill-extrusion-height`]),"fill-extrusion-base":new Xs($[`paint_fill-extrusion`][`fill-extrusion-base`]),"fill-extrusion-vertical-gradient":new Gs($[`paint_fill-extrusion`][`fill-extrusion-vertical-gradient`])})}};class Wu extends Qs{constructor(e,r){super(e,Df,r)}createBucket(e){return new qu(e)}queryRadius(){return Su(this.paint.get(`fill-extrusion-translate`))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:r,featureState:_,geometry:b,transform:x,pixelsToTileUnits:C,pixelPosMatrix:T}){let E=Cu(e,this.paint.get(`fill-extrusion-translate`),this.paint.get(`fill-extrusion-translate-anchor`),-x.bearingInRadians,C),D=this.paint.get(`fill-extrusion-height`).evaluate(r,_),O=this.paint.get(`fill-extrusion-base`).evaluate(r,_),k=function(e,r){let _=[];for(let b of e){let e=[b.x,b.y,0,1];Z(e,e,r),_.push(new v(e[0]/e[3],e[1]/e[3]))}return _}(E,T),A=function(e,r,_,b){let x=[],C=[],T=b[8]*r,E=b[9]*r,D=b[10]*r,O=b[11]*r,k=b[8]*_,A=b[9]*_,j=b[10]*_,F=b[11]*_;for(let r of e){let e=[],_=[];for(let x of r){let r=x.x,C=x.y,R=b[0]*r+b[4]*C+b[12],z=b[1]*r+b[5]*C+b[13],B=b[2]*r+b[6]*C+b[14],H=b[3]*r+b[7]*C+b[15],K=B+D,q=H+O,Y=R+k,X=z+A,ne=B+j,Z=H+F,ie=new v((R+T)/q,(z+E)/q);ie.z=K/q,e.push(ie);let ae=new v(Y/Z,X/Z);ae.z=ne/Z,_.push(ae)}x.push(e),C.push(_)}return[x,C]}(b,O,D,T);return function(e,r,_){let v=1/0;lu(_,r)&&(v=kf(_,r[0]));for(let b=0;b>4;if(v!==1)throw Error(`Got v${v} data when expected v1.`);let b=Af[15&_];if(!b)throw Error(`Unrecognized array type.`);let[x]=new Uint16Array(e,2,1),[C]=new Uint32Array(e,4,1);return new tc(C,x,b,e)}constructor(e,r=64,_=Float64Array,v){if(isNaN(e)||e<0)throw Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=_,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let b=Af.indexOf(this.ArrayType),x=2*e*this.ArrayType.BYTES_PER_ELEMENT,C=e*this.IndexArrayType.BYTES_PER_ELEMENT,T=(8-C%8)%8;if(b<0)throw Error(`Unexpected typed array class: ${_}.`);v&&v instanceof ArrayBuffer?(this.data=v,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+C+T,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+x+C+T),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+C+T,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+b]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=e)}add(e,r){let _=this._pos>>1;return this.ids[_]=_,this.coords[this._pos++]=e,this.coords[this._pos++]=r,_}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return jf(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,r,_,v){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:b,coords:x,nodeSize:C}=this,T=[0,b.length-1,0],E=[];for(;T.length;){let D=T.pop()||0,O=T.pop()||0,k=T.pop()||0;if(O-k<=C){for(let C=k;C<=O;C++){let T=x[2*C],D=x[2*C+1];T>=e&&T<=_&&D>=r&&D<=v&&E.push(b[C])}continue}let A=k+O>>1,j=x[2*A],F=x[2*A+1];j>=e&&j<=_&&F>=r&&F<=v&&E.push(b[A]),(D===0?e<=j:r<=F)&&(T.push(k),T.push(A-1),T.push(1-D)),(D===0?_>=j:v>=F)&&(T.push(A+1),T.push(O),T.push(1-D))}return E}within(e,r,_){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:v,coords:b,nodeSize:x}=this,C=[0,v.length-1,0],T=[],E=_*_;for(;C.length;){let D=C.pop()||0,O=C.pop()||0,k=C.pop()||0;if(O-k<=x){for(let _=k;_<=O;_++)Ff(b[2*_],b[2*_+1],e,r)<=E&&T.push(v[_]);continue}let A=k+O>>1,j=b[2*A],F=b[2*A+1];Ff(j,F,e,r)<=E&&T.push(v[A]),(D===0?e-_<=j:r-_<=F)&&(C.push(k),C.push(A-1),C.push(1-D)),(D===0?e+_>=j:r+_>=F)&&(C.push(A+1),C.push(O),C.push(1-D))}return T}}function jf(e,r,_,v,b,x){if(b-v<=_)return;let C=v+b>>1;Mf(e,r,C,v,b,x),jf(e,r,_,v,C-1,1-x),jf(e,r,_,C+1,b,1-x)}function Mf(e,r,_,v,b,x){for(;b>v;){if(b-v>600){let C=b-v+1,T=_-v+1,E=Math.log(C),D=.5*Math.exp(2*E/3),O=.5*Math.sqrt(E*D*(C-D)/C)*(T-C/2<0?-1:1);Mf(e,r,_,Math.max(v,Math.floor(_-T*D/C+O)),Math.min(b,Math.floor(_+(C-T)*D/C+O)),x)}let C=r[2*_+x],T=v,E=b;for(Nf(e,r,v,_),r[2*b+x]>C&&Nf(e,r,v,b);TC;)E--}r[2*v+x]===C?Nf(e,r,v,E):(E++,Nf(e,r,E,b)),E<=_&&(v=E+1),_<=E&&(b=E-1)}}function Nf(e,r,_,v){Pf(e,_,v),Pf(r,2*_,2*v),Pf(r,2*_+1,2*v+1)}function Pf(e,r,_){let v=e[r];e[r]=e[_],e[_]=v}function Ff(e,r,_,v){let b=e-_,x=r-v;return b*b+x*x}function If(e,r,_,v){let b=v,x=r+(_-r>>1),C,T=_-r,E=e[r],D=e[r+1],O=e[_],k=e[_+1];for(let v=r+3;v<_;v+=3){let r=Lf(e[v],e[v+1],E,D,O,k);if(r>b)C=v,b=r;else if(r===b){let e=Math.abs(v-x);ev&&(C-r>3&&If(e,r,C,v),e[C+2]=b,_-C>3&&If(e,C,_,v))}function Lf(e,r,_,v,b,x){let C=b-_,T=x-v;if(C!==0||T!==0){let E=((e-_)*C+(r-v)*T)/(C*C+T*T);E>1?(_=b,v=x):E>0&&(_+=C*E,v+=T*E)}return C=e-_,T=r-v,C*C+T*T}function Rf(e,r,_,v){let b={type:r,geom:_},x={id:e??null,type:b.type,geometry:b.geom,tags:v,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};switch(b.type){case`Point`:case`MultiPoint`:case`LineString`:zf(x,b.geom);break;case`Polygon`:zf(x,b.geom[0]);break;case`MultiLineString`:for(let e of b.geom)zf(x,e);break;case`MultiPolygon`:for(let e of b.geom)zf(x,e[0])}return x}function zf(e,r){for(let _=0;_0&&(C+=v?(b*E-T*x)/2:Math.sqrt((T-b)**2+(E-x)**2)),b=T,x=E}let T=r.length-3;r[2]=1,_>0&&If(r,0,T,_),r[T+2]=1,r.size=Math.abs(C),r.start=0,r.end=r.size}function Uf(e,r,_,v){for(let b=0;b1?1:_}function Kf(e){let r={type:`Feature`,geometry:qf(e),properties:e.tags};return e.id!=null&&(r.id=e.id),r}function qf(e){let{type:r,geometry:_}=e;switch(r){case`Point`:return{type:r,coordinates:Yf(_[0],_[1])};case`MultiPoint`:case`LineString`:return{type:r,coordinates:Jf(_)};case`MultiLineString`:case`Polygon`:return{type:r,coordinates:_.map(e=>Jf(e))};case`MultiPolygon`:return{type:r,coordinates:_.map(e=>e.map(e=>Jf(e)))}}}function Jf(e){let r=[];for(let _=0;_=(_/=r)&&C=v)return null;let E=[];for(let r of e){let e=b===$f.X?r.minX:r.minY,x=b===$f.X?r.maxX:r.maxY;if(e>=_&&x=v))switch(r.type){case`Point`:case`MultiPoint`:tp(r,E,_,v,b);continue;case`LineString`:np(r,E,_,v,b,T);continue;case`MultiLineString`:rp(r,E,_,v,b);continue;case`Polygon`:ip(r,E,_,v,b);continue;case`MultiPolygon`:ap(r,E,_,v,b);continue}}return E.length?E:null}function tp(e,r,_,v,b){let x=[];(function(e,r,_,v,b){for(let x=0;x=_&&C<=v&&lp(r,e[x],e[x+1],e[x+2])}})(e.geometry,x,_,v,b),x.length&&r.push(Rf(e.id,x.length===3?`Point`:`MultiPoint`,x,e.tags))}function np(e,r,_,v,b,x){let C=[];if(op(e.geometry,C,_,v,b,!1,x.lineMetrics),C.length)if(x.lineMetrics)for(let _ of C)r.push(Rf(e.id,`LineString`,_,e.tags));else r.push(C.length>1?Rf(e.id,`MultiLineString`,C,e.tags):Rf(e.id,`LineString`,C[0],e.tags))}function rp(e,r,_,v,b){let x=[];cp(e.geometry,x,_,v,b,!1),x.length&&r.push(x.length===1?Rf(e.id,`LineString`,x[0],e.tags):Rf(e.id,`MultiLineString`,x,e.tags))}function ip(e,r,_,v,b){let x=[];cp(e.geometry,x,_,v,b,!0),x.length&&r.push(Rf(e.id,`Polygon`,x,e.tags))}function ap(e,r,_,v,b){let x=[];for(let r of e.geometry){let e=[];cp(r,e,_,v,b,!0),e.length&&x.push(e)}x.length&&r.push(Rf(e.id,`MultiPolygon`,x,e.tags))}function op(e,r,_,v,b,x,C){let T=sp(e),E=b===$f.X?up:dp,D,O,k=e.start;for(let A=0;A_&&(O=E(T,j,F,z,B,_),C&&(T.start=k+D*O)):H>v?K=_&&(O=E(T,j,F,z,B,_),q=!0),K>v&&H<=v&&(O=E(T,j,F,z,B,v),q=!0),!x&&q&&(C&&(T.end=k+D*O),r.push(T),T=sp(e)),C&&(k+=D)}let A=e.length-3,j=e[A],F=e[A+1],R=b===$f.X?j:F;R>=_&&R<=v&&lp(T,j,F,e[A+2]),A=T.length-3,x&&A>=3&&(T[A]!==T[0]||T[A+1]!==T[1])&&lp(T,T[0],T[1],T[2]),T.length&&r.push(T)}function sp(e){let r=[];return r.size=e.size,r.start=e.start,r.end=e.end,r}function cp(e,r,_,v,b,x){for(let C of e)op(C,r,_,v,b,x,!1)}function lp(e,r,_,v){e.push(r,_,v)}function up(e,r,_,v,b,x){let C=(x-r)/(v-r);return lp(e,x,_+(b-_)*C,1),C}function dp(e,r,_,v,b,x){let C=(x-_)/(b-_);return lp(e,r+(v-r)*C,x,1),C}function fp(e,r){let _=r.buffer/r.extent,v=e,b=ep(e,1,-1-_,_,$f.X,-1,2,r),x=ep(e,1,1-_,2+_,$f.X,-1,2,r);return b||x?(v=ep(e,1,-_,1+_,$f.X,-1,2,r)||[],b&&(v=pp(b,1).concat(v)),x&&(v=v.concat(pp(x,-1))),v):v}function pp(e,r){let _=[];for(let v of e)switch(v.type){case`Point`:case`MultiPoint`:case`LineString`:{let e=mp(v.geometry,r);_.push(Rf(v.id,v.type,e,v.tags));continue}case`MultiLineString`:case`Polygon`:{let e=[];for(let _ of v.geometry)e.push(mp(_,r));_.push(Rf(v.id,v.type,e,v.tags));continue}case`MultiPolygon`:{let e=[];for(let _ of v.geometry){let v=[];for(let e of _)v.push(mp(e,r));e.push(v)}_.push(Rf(v.id,v.type,e,v.tags));continue}}return _}function mp(e,r){let _=[];_.size=e.size,e.start!==void 0&&(_.start=e.start,_.end=e.end);for(let v=0;v0||r.addOrUpdateProperties?.length>0;if(v){let v=e[0],x=Bf({type:`FeatureCollection`,features:[{type:`Feature`,id:v.id,geometry:r.newGeometry,properties:b?gp(v.tags,r):v.tags}]},_);return x=fp(x,_),x}if(b){let _=[];for(let v of e){let e={...v};e.tags=gp(e.tags,r),_.push(e)}return _}return[]}function gp(e,r){if(r.removeAllProperties)return{};let _={...e||{}};if(r.removeProperties)for(let e of r.removeProperties)delete _[e];if(r.addOrUpdateProperties)for(let{key:e,value:v}of r.addOrUpdateProperties)_[e]=v;return _}(function(e){e[e.X=0]=`X`,e[e.Y=1]=`Y`})($f||={});let vp={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e};class Nc{constructor(e){this.options=Object.assign(Object.create(vp),e),this.trees=Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[],this.points=[]}load(e){let r=[];for(let _ of e){if(!_.geometry)continue;let[e,v]=_.geometry.coordinates,[b,x]=[Wf(e),Gf(v)];r.push({id:_.id,type:`Point`,geometry:[b,x],tags:_.properties})}this.createIndex(r)}initialize(e){let r=[];for(let _ of e)_.type===`Point`&&r.push(_);this.createIndex(r)}updateIndex(e,r,_){this.options=Object.assign(Object.create(vp),_.clusterOptions),this.initialize(e)}createIndex(e){let{log:r,minZoom:_,maxZoom:v}=this.options;r&&console.time(`total time`);let b=`prepare ${e.length} points`;r&&console.time(b),this.points=e;let x=[];for(let r=0;r=_;e--){let _=Date.now();C=this.trees[e]=this.createTree(this.cluster(C,e)),r&&console.log(`z%d: %d clusters in %dms`,e,C.numItems,Date.now()-_)}r&&console.timeEnd(`total time`)}getClusters(e,r){return this.getClustersInternal(e,r).map(e=>Kf(e))}getClustersInternal(e,r){let _=((e[0]+180)%360+360)%360-180,v=Math.max(-90,Math.min(90,e[1])),b=e[2]===180?180:((e[2]+180)%360+360)%360-180,x=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)_=-180,b=180;else if(_>b){let e=this.getClustersInternal([_,v,180,x],r),C=this.getClustersInternal([-180,v,b,x],r);return e.concat(C)}let C=this.trees[this.limitZoom(r)],T=C.range(Wf(_),Gf(x),Wf(b),Gf(v)),E=C.flatData,D=[];for(let e of T){let r=this.stride*e;D.push(E[r+5]>1?yp(E,r,this.clusterProps):this.points[E[r+3]])}return D}getChildren(e){let r=this.getOriginId(e),_=this.getOriginZoom(e),v=/* @__PURE__ */ Error(`No cluster with the specified id: `+e),b=this.trees[_];if(!b)throw v;let x=b.flatData;if(r*this.stride>=x.length)throw v;let C=this.options.radius/(this.options.extent*2**(_-1)),T=b.within(x[r*this.stride],x[r*this.stride+1],C),E=[];for(let r of T){let _=r*this.stride;x[_+4]===e&&E.push(x[_+5]>1?xp(x,_,this.clusterProps):Kf(this.points[x[_+3]]))}if(E.length===0)throw v;return E}getLeaves(e,r,_){let v=[];return this.appendLeaves(v,e,r||=10,_||=0,0),v}getTile(e,r,_){let v=this.trees[this.limitZoom(e)];if(!v)return null;let b=2**e,{extent:x,radius:C}=this.options,T=C/x,E=(_-T)/b,D=(_+1+T)/b,O={transformed:!0,features:[],source:null,x:r,y:_,z:e};return this.addTileFeatures(v.range((r-T)/b,E,(r+1+T)/b,D),v.flatData,r,_,b,O),r===0&&this.addTileFeatures(v.range(1-T/b,E,1,D),v.flatData,b,_,b,O),r===b-1&&this.addTileFeatures(v.range(0,E,T/b,D),v.flatData,-1,_,b,O),O}getClusterExpansionZoom(e){return this.getOriginZoom(e)}appendLeaves(e,r,_,v,b){let x=this.getChildren(r);for(let r of x){let x=r.properties;if(x?.cluster?b+x.point_count<=v?b+=x.point_count:b=this.appendLeaves(e,x.cluster_id,_,v,b):b1,E,D,O;if(T)E=Sp(r,e,this.clusterProps),D=r[e],O=r[e+1];else{let _=this.points[r[e+3]];E=_.tags,[D,O]=_.geometry}let k={type:1,geometry:[[Math.round(this.options.extent*(D*b-_)),Math.round(this.options.extent*(O*b-v))]],tags:E},A;A=T||this.options.generateId?r[e+3]:this.points[r[e+3]].id,A!==void 0&&(k.id=A),x.features.push(k)}}limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}cluster(e,r){let{radius:_,extent:v,reduce:b,minPoints:x}=this.options,C=_/(v*2**r),T=e.flatData,E=[],D=this.stride;for(let _=0;_r&&(j+=T[_+5])}if(j>A&&j>=x){let e,x=v*A,C=O*A,F=-1,R=(_/D<<5)+(r+1)+this.points.length;for(let v of k){let E=v*D;if(T[E+2]<=r)continue;T[E+2]=r;let O=T[E+5];x+=T[E]*O,C+=T[E+1]*O,T[E+4]=R,b&&(e||(e=this.map(T,_,!0),F=this.clusterProps.length,this.clusterProps.push(e)),b(e,this.map(T,E)))}T[_+4]=R,E.push(x/j,C/j,1/0,R,-1,j),b&&E.push(F)}else{for(let e=0;e1)for(let e of k){let _=e*D;if(!(T[_+2]<=r)){T[_+2]=r;for(let e=0;e>5}getOriginZoom(e){return(e-this.points.length)%32}map(e,r,_){if(e[r+5]>1){let v=this.clusterProps[e[r+6]];return _?Object.assign({},v):v}let v=this.points[e[r+3]].tags,b=this.options.map(v);return _&&b===v?Object.assign({},b):b}}function yp(e,r,_){return{id:e[r+3],type:`Point`,tags:Sp(e,r,_),geometry:[e[r],e[r+1]]}}function xp(e,r,_){return{type:`Feature`,id:e[r+3],properties:Sp(e,r,_),geometry:{type:`Point`,coordinates:[Zf(e[r]),Qf(e[r+1])]}}}function Sp(e,r,_){let v=e[r+5],b=v>=1e4?`${Math.round(v/1e3)}k`:v>=1e3?Math.round(v/100)/10+`k`:v,x=e[r+6],C=x===-1?{}:Object.assign({},_[x]);return Object.assign(C,{cluster:!0,cluster_id:e[r+3],point_count:v,point_count_abbreviated:b})}let Tp=`geojsonvt_clip_start`,Ep=`geojsonvt_clip_end`;function Op(e,r,_,v,b){let x=r===b.maxZoom?0:b.tolerance/((1<0&&r.size<(b?C:v))return void(_.numPoints+=r.length/3);let T=[];for(let e=0;eC)&&(_.numSimplified++,T.push(r[e],r[e+1])),_.numPoints++;b&&function(e,r){let _=0;for(let r=0,v=e.length,b=v-2;r0===r)for(let r=0,_=e.length;r<_/2;r+=2){let v=e[r],b=e[r+1];e[r]=e[_-2-r],e[r+1]=e[_-1-r],e[_-2-r]=v,e[_-1-r]=b}}(T,x),e.push(T)}function Mp(e,r){if(e.transformed)return e;let _=1<1&&(console.log(`invalidating tiles`),console.time(`invalidating`)),this.invalidateTiles(r),_.debug>1&&console.timeEnd(`invalidating`);let[v,b,x]=[0,0,0],C=Op(e,v,b,x,_);C.source=e;let T=zp(v,b,x);if(this.tiles[T]=C,this.tileCoords.push({z:v,x:b,y:x,id:T}),_.debug){let e=`z${v}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}}getClusterExpansionZoom(e){return null}getChildren(e){return null}getLeaves(e,r,_){return null}getTile(e,r,_){let{extent:v,debug:b}=this.options,x=1<1&&console.log(`drilling down to z%d-%d-%d`,e,r,_);let T,E=e,D=r,O=_;for(;!T&&E>0;)E--,D>>=1,O>>=1,T=this.tiles[zp(E,D,O)];return T?.source?(b>1&&(console.log(`found parent tile z%d-%d-%d`,E,D,O),console.time(`drilling down`)),this.splitTile(T.source,E,D,O,e,r,_),b>1&&console.timeEnd(`drilling down`),this.tiles[C]?Mp(this.tiles[C],v):null):null}splitTile(e,r,_,v,b,x,C){let T=[e,r,_,v],E=this.options,D=E.debug;for(;T.length;){v=T.pop(),_=T.pop(),r=T.pop(),e=T.pop();let O=1<1&&console.time(`creation`),A=this.tiles[k]=Op(e,r,_,v,E),this.tileCoords.push({z:r,x:_,y:v,id:k}),D)){D>1&&(console.log(`tile z%d-%d-%d (features: %d, points: %d, simplified: %d)`,r,_,v,A.numFeatures,A.numPoints,A.numSimplified),console.timeEnd(`creation`));let e=`z${r}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(A.source=e,b==null){if(r===E.indexMaxZoom||A.numPoints<=E.indexMaxPoints)continue}else{if(r===E.maxZoom||r===b)continue;if(b!=null){let e=b-r;if(_!==x>>e||v!==C>>e)continue}}if(A.source=null,!e.length)continue;D>1&&console.time(`clipping`);let j=.5*E.buffer/E.extent,F=.5-j,R=.5+j,z=1+j,B=null,H=null,K=null,q=null,Y=ep(e,O,_-j,_+R,$f.X,A.minX,A.maxX,E),X=ep(e,O,_+F,_+z,$f.X,A.minX,A.maxX,E);Y&&(B=ep(Y,O,v-j,v+R,$f.Y,A.minY,A.maxY,E),H=ep(Y,O,v+F,v+z,$f.Y,A.minY,A.maxY,E)),X&&(K=ep(X,O,v-j,v+R,$f.Y,A.minY,A.maxY,E),q=ep(X,O,v+F,v+z,$f.Y,A.minY,A.maxY,E)),D>1&&console.timeEnd(`clipping`),T.push(B||[],r+1,2*_,2*v),T.push(H||[],r+1,2*_,2*v+1),T.push(K||[],r+1,2*_+1,2*v),T.push(q||[],r+1,2*_+1,2*v+1)}}invalidateTiles(e){if(!e.length)return;let r=this.options,{debug:_}=r,v=1/0,b=-1/0,x=1/0,C=-1/0;for(let r of e)v=Math.min(v,r.minX),b=Math.max(b,r.maxX),x=Math.min(x,r.minY),C=Math.max(C,r.maxY);let T=r.buffer/r.extent,E=/* @__PURE__ */ new Set;for(let r in this.tiles){let D=this.tiles[r],O=1<=A||C=F)continue;let R=!1;for(let r of e)if(r.maxX>=k&&r.minX=j&&r.minY1&&console.log(`invalidate tile z%d-%d-%d (features: %d, points: %d, simplified: %d)`,D.z,D.x,D.y,D.numFeatures,D.numPoints,D.numSimplified);let e=`z${D.z}`;this.stats[e]=(this.stats[e]||0)-1,this.total--}delete this.tiles[r],E.add(r)}}E.size&&(this.tileCoords=this.tileCoords.filter(e=>!E.has(e.id)))}}function zp(e,r,_){return 32*((1<e.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new Ho,this.layoutVertexArray2=new Wo,this.indexArray=new ia,this.programConfigurations=new Oa(e.layers,e.zoom),this.segments=new la,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,r,_){this.hasDependencies=nd(`line`,this.layers,r)||this.hasLineDasharray(this.layers);let v=this.layers[0].layout.get(`line-sort-key`),b=!v.isConstant(),x=[];for(let{feature:r,id:C,index:T,sourceLayerIndex:E}of e){let e=this.layers[0]._featureFilter.needGeometry,D=iu(r,e);if(!this.layers[0]._featureFilter.filter(new Bs(this.zoom),D,_))continue;let O=b?v.evaluate(D,{},_):void 0,k={id:C,properties:r.properties,type:r.type,sourceLayerIndex:E,index:T,geometry:e?D.geometry:ru(r),patterns:{},dashes:{},sortKey:O};x.push(k)}b&&x.sort((e,r)=>e.sortKey-r.sortKey);for(let v of x){let{geometry:b,index:x,sourceLayerIndex:C}=v;this.hasDependencies?(nd(`line`,this.layers,r)?rd(`line`,this.layers,v,{zoom:this.zoom},r):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,v,this.zoom,r),this.patternFeatures.push(v)):this.addFeature(v,b,x,_,{},{},r.subdivisionGranularity),r.featureIndex.insert(e[x].feature,b,x,C,this.index)}}update(e,r,_,v){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,{imagePositions:_,dashPositions:v})}addFeatures(e,r,_,v){for(let b of this.patternFeatures)this.addFeature(b,b.geometry,b.index,r,_,v,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Hp)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Vp),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,Tp)&&Object.prototype.hasOwnProperty.call(e.properties,Ep))return{start:+e.properties[Tp],end:+e.properties[Ep]}}addFeature(e,r,_,v,b,x,C){let T=this.layers[0].layout,E=T.get(`line-join`).evaluate(e,{}),D=T.get(`line-cap`).evaluate(e,{}),O=T.get(`line-miter-limit`).evaluate(e,{}),k=T.get(`line-round-limit`).evaluate(e,{});this.lineClips=this.lineFeatureClips(e);for(let _ of r)this.addLine(_,e,E,D,O,k,v,C);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,_,{imagePositions:b,dashPositions:x,canonical:v})}addLine(e,r,_,v,b,x,C,T){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Zd(e,C?T.line.getGranularityForZoomLevel(C.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let r=0;r=2&&e[D-1].equals(e[D-2]);)D--;let O=0;for(;O0;if(Y&&r>O){let e=j.dist(F);if(e>2*k){let r=j.sub(j.sub(F)._mult(k/e)._round());this.updateDistance(F,r),this.addCurrentVertex(r,z,0,0,A),F=r}}let ne=F&&R,Z=ne?_:E?`butt`:v;if(ne&&Z===`round`&&(Kb&&(Z=`bevel`),Z===`bevel`&&(K>2&&(Z=`flipbevel`),K100)C=B.mult(-1);else{let e=K*z.add(B).mag()/z.sub(B).mag();C._perp()._mult(e*(X?-1:1))}this.addCurrentVertex(j,C,0,0,A),this.addCurrentVertex(j,C.mult(-1),0,0,A)}else if(Z===`bevel`||Z===`fakeround`){let e=-Math.sqrt(K*K-1),r=X?e:0,_=X?0:e;if(F&&this.addCurrentVertex(j,z,r,_,A),Z===`fakeround`){let e=Math.round(180*q/Math.PI/20);for(let r=1;r2*k){let r=j.add(R.sub(j)._mult(k/e)._round());this.updateDistance(j,r),this.addCurrentVertex(r,B,0,0,A),j=r}}}}addCurrentVertex(e,r,_,v,b,x=!1){let C=r.y*v-r.x,T=-r.y-r.x*v;this.addHalfVertex(e,r.x+r.y*_,r.y-r.x*_,x,!1,_,b),this.addHalfVertex(e,C,T,x,!0,-v,b),this.distance>Gp/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,r,_,v,b,x))}addHalfVertex({x:e,y:r},_,v,b,x,C,T){let E=.5*(this.lineClips?this.scaledDistance*(Gp-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(b?1:0),(r<<1)+(x?1:0),Math.round(63*_)+128,Math.round(63*v)+128,1+(C===0?0:C<0?-1:1)|(63&E)<<2,E>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);let D=T.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,D,this.e2),T.primitiveLength++),x?this.e2=D:this.e1=D}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,r){this.distance+=e.dist(r),this.updateScaledDistance()}hasLineDasharray(e){for(let r of e){let e=r.paint.get(`line-dasharray`);if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,r,_,v){for(let b of e){let e=b.paint.get(`line-dasharray`);if(!e||e.value.kind===`constant`)continue;let x=b.layout.get(`line-cap`).evaluate(r,{})===`round`,C={dasharray:e.value.evaluate({zoom:_-1},r,{}),round:x},T={dasharray:e.value.evaluate({zoom:_},r,{}),round:x},E={dasharray:e.value.evaluate({zoom:_+1},r,{}),round:x},D=`${C.dasharray.join(`,`)},${C.round}`,O=`${T.dasharray.join(`,`)},${T.round}`,k=`${E.dasharray.join(`,`)},${E.round}`;v.dashDependencies[D]=C,v.dashDependencies[O]=T,v.dashDependencies[k]=E,r.dashes[b.id]={min:D,mid:O,max:k}}}}let $p,em;$c(`LineBucket`,uh,{omit:[`layers`,`patternFeatures`]});var tm={get paint(){return em||=new Ws({"line-opacity":new Xs($.paint_line[`line-opacity`]),"line-color":new Xs($.paint_line[`line-color`]),"line-translate":new Gs($.paint_line[`line-translate`]),"line-translate-anchor":new Gs($.paint_line[`line-translate-anchor`]),"line-width":new Xs($.paint_line[`line-width`]),"line-gap-width":new Xs($.paint_line[`line-gap-width`]),"line-offset":new Xs($.paint_line[`line-offset`]),"line-blur":new Xs($.paint_line[`line-blur`]),"line-dasharray":new Ys($.paint_line[`line-dasharray`]),"line-pattern":new Ys($.paint_line[`line-pattern`]),"line-gradient":new Hs($.paint_line[`line-gradient`])})},get layout(){return $p||=new Ws({"line-cap":new Xs($.layout_line[`line-cap`]),"line-join":new Xs($.layout_line[`line-join`]),"line-miter-limit":new Xs($.layout_line[`line-miter-limit`]),"line-round-limit":new Xs($.layout_line[`line-round-limit`]),"line-sort-key":new Xs($.layout_line[`line-sort-key`])})}};class fh extends Xs{possiblyEvaluate(e,r){return r=new Bs(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(e,r)}evaluate(e,r,_,v){return r=ye({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(e,r,_,v)}}let nm;class yh extends Qs{constructor(e,r){super(e,tm,r),this.gradientVersion=0,nm||(nm=new fh(tm.paint.properties[`line-width`].specification),nm.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e===`line-gradient`){let e=this.gradientExpression();this.stepInterpolant=!!function(e){return e._styleExpression!==void 0}(e)&&e._styleExpression.expression instanceof un,this.gradientVersion=(this.gradientVersion+1)%(2**53-1)}}gradientExpression(){return this._transitionablePaint._values[`line-gradient`].value.expression}recalculate(e,r){super.recalculate(e,r),this.paint._values[`line-floorwidth`]=nm.possiblyEvaluate(this._transitioningPaint._values[`line-width`].value,e)}createBucket(e){return new uh(e)}queryRadius(e){let r=e,_=rm(xu(`line-width`,this,r),xu(`line-gap-width`,this,r)),v=xu(`line-offset`,this,r);return _/2+Math.abs(v)+Su(this.paint.get(`line-translate`))}queryIntersectsFeature({queryGeometry:e,feature:r,featureState:_,geometry:b,transform:x,pixelsToTileUnits:C}){let T=Cu(e,this.paint.get(`line-translate`),this.paint.get(`line-translate-anchor`),-x.bearingInRadians,C),E=C/2*rm(this.paint.get(`line-width`).evaluate(r,_),this.paint.get(`line-gap-width`).evaluate(r,_)),D=this.paint.get(`line-offset`).evaluate(r,_);return D&&(b=function(e,r){let _=[];for(let b=0;b=3){for(let r=0;r0?r+2*e:e}let im=Al([{name:`a_pos_offset`,components:4,type:`Int16`},{name:`a_data`,components:4,type:`Uint16`},{name:`a_pixeloffset`,components:4,type:`Int16`}],4),am=Al([{name:`a_projected_pos`,components:3,type:`Float32`}],4);Al([{name:`a_fade_opacity`,components:1,type:`Uint32`}],4);let om=Al([{name:`a_placed`,components:2,type:`Uint8`},{name:`a_shift`,components:2,type:`Float32`},{name:`a_box_real`,components:2,type:`Int16`}]);Al([{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 sm=Al([{name:`a_pos`,components:2,type:`Int16`},{name:`a_anchor_pos`,components:2,type:`Int16`},{name:`a_extrude`,components:2,type:`Int16`}],4),cm=Al([{name:`a_pos`,components:2,type:`Float32`},{name:`a_radius`,components:1,type:`Float32`},{name:`a_flags`,components:2,type:`Int16`}],4);function lm(e,r,_){return e.sections.forEach(e=>{e.text=function(e,r,_){let v=r.layout.get(`text-transform`).evaluate(_,{});return v===`uppercase`?e=e.toLocaleUpperCase():v===`lowercase`&&(e=e.toLocaleLowerCase()),yl.applyArabicShaping&&(e=yl.applyArabicShaping(e)),e}(e.text,r,_)}),e}Al([{name:`triangle`,components:3,type:`Uint16`}]),Al([{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`}]),Al([{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`}]),Al([{type:`Float32`,name:`offsetX`}]),Al([{type:`Int16`,name:`x`},{type:`Int16`,name:`y`},{type:`Int16`,name:`tileUnitDistanceFromAnchor`}]),Al([{type:`Uint16`,name:`textAnchor`},{type:`Float32`,components:2,name:`textOffset`}]);var um=24;let dm={"!":`︕`,"#":`#`,$:`$`,"%":`%`,"&":`&`,"(":`︵`,")":`︶`,"*":`*`,"+":`+`,",":`︐`,"-":`︲`,".":`・`,"/":`/`,":":`︓`,";":`︔`,"<":`︿`,"=":`=`,">":`﹀`,"?":`︖`,"@":`@`,"[":`﹇`,"\\":`\`,"]":`﹈`,"^":`^`,_:`︳`,"`":```,"{":`︷`,"|":`―`,"}":`︸`,"~":`~`,"¢":`¢`,"£":`£`,"¥":`¥`,"¦":`¦`,"¬":`¬`,"¯":` ̄`,"–":`︲`,"—":`︱`,"‘":`﹃`,"’":`﹄`,"“":`﹁`,"”":`﹂`,"…":`︙`,"⋯":`︙`,"‧":`・`,"₩":`₩`,"、":`︑`,"。":`︒`,"〈":`︿`,"〉":`﹀`,"《":`︽`,"》":`︾`,"「":`﹁`,"」":`﹂`,"『":`﹃`,"』":`﹄`,"【":`︻`,"】":`︼`,"〔":`︹`,"〕":`︺`,"〖":`︗`,"〗":`︘`,"!":`︕`,"(":`︵`,")":`︶`,",":`︐`,"-":`︲`,".":`・`,":":`︓`,";":`︔`,"<":`︿`,">":`﹀`,"?":`︖`,"[":`﹇`,"]":`﹈`,"_":`︳`,"{":`︷`,"|":`―`,"}":`︸`,"⦅":`︵`,"⦆":`︶`,"。":`︒`,"「":`﹁`,"」":`﹂`},fm={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},pm={40:!0};function mm(e,r,_,v,b,x){if(`fontStack`in r){let v=_[r.fontStack],x=v&&v[e];return x?x.metrics.advance*r.scale+b:0}{let e=v[r.imageName];return e?e.displaySize[0]*r.scale*um/x+b:0}}function hm(e,r,_,v){let b=(e-r)**2;return v?eMath.max(e,this.sections[r].scale),0)}getMaxImageSize(e){let r=0,_=0;for(let v=0;v_))}addImageSection(e){let r=e.image?e.image.name:``;if(r.length===0)return void je(`Can't add FormattedSection with an empty image.`);let _=this.getNextImageSectionCharCode();_?(this.text+=String.fromCharCode(_),this.sections.push({scale:1,verticalAlign:e.verticalAlign||`bottom`,imageName:r}),this.sectionIndex.push(this.sections.length-1)):je(`Reached maximum number of images 6401`)}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,r,_,v,b){let x=[],C=this.determineAverageLineWidth(e,r,_,v,b),T=this.hasZeroWidthSpaces(),E=0,D=0,O=this.text[Symbol.iterator](),k=O.next(),A=this.text[Symbol.iterator]();A.next();let j=A.next(),F=this.text[Symbol.iterator]();F.next(),F.next();let R=F.next();for(;!k.done;){let r=this.getSection(D),z=k.value.codePointAt(0);if(sl(z)||(E+=mm(z,r,_,v,e,b)),!j.done){let e=al(z),_=j.value.codePointAt(0);(fm[z]||e||`imageName`in r||!R.done&&pm[_])&&x.push(_m(D+1,E,C,x,gm(z,_,e&&T),!1))}D++,k=O.next(),j=A.next(),R=F.next()}return vm(_m(this.length(),E,C,x,0,!0))}determineAverageLineWidth(e,r,_,v,b){let x=0,C=0;for(let r of this.text){let T=this.getSection(C);x+=mm(r.codePointAt(0),T,_,v,e,b),C++}return x/Math.max(1,Math.ceil(x/r))}}let ym=4294967296,bm=1/ym,xm=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`);class Vh{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,r,_=this.length){for(;this.pos<_;){let _=this.readVarint(),v=_>>3,b=this.pos;this.type=7&_,e(v,r,this),this.pos===b&&this.skip(_)}return r}readMessage(e,r){return this.readFields(e,r,this.readVarint()+this.pos)}readFixed32(){let e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){let e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*ym;return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*ym;return this.pos+=8,e}readFloat(){let e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){let e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){let r=this.buf,_,v;return v=r[this.pos++],_=127&v,v<128?_:(v=r[this.pos++],_|=(127&v)<<7,v<128?_:(v=r[this.pos++],_|=(127&v)<<14,v<128?_:(v=r[this.pos++],_|=(127&v)<<21,v<128?_:(v=r[this.pos],_|=(15&v)<<28,function(e,r,_){let v=_.buf,b,x;if(x=v[_.pos++],b=(112&x)>>4,x<128||(x=v[_.pos++],b|=(127&x)<<3,x<128)||(x=v[_.pos++],b|=(127&x)<<10,x<128)||(x=v[_.pos++],b|=(127&x)<<17,x<128)||(x=v[_.pos++],b|=(127&x)<<24,x<128)||(x=v[_.pos++],b|=(1&x)<<31,x<128))return Sm(e,b,r);throw Error(`Expected varint not more than 10 bytes`)}(_,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){let e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){let e=this.readVarint()+this.pos,r=this.pos;return this.pos=e,e-r>=12&&xm?xm.decode(this.buf.subarray(r,e)):function(e,r,_){let v=``,b=r;for(;b<_;){let r=e[b],x,C,T,E=null,D=r>239?4:r>223?3:r>191?2:1;if(b+D>_)break;D===1?r<128&&(E=r):D===2?(x=e[b+1],(192&x)==128&&(E=(31&r)<<6|63&x,E<=127&&(E=null))):D===3?(x=e[b+1],C=e[b+2],(192&x)==128&&(192&C)==128&&(E=(15&r)<<12|(63&x)<<6|63&C,(E<=2047||E>=55296&&E<=57343)&&(E=null))):D===4&&(x=e[b+1],C=e[b+2],T=e[b+3],(192&x)==128&&(192&C)==128&&(192&T)==128&&(E=(15&r)<<18|(63&x)<<12|(63&C)<<6|63&T,(E<=65535||E>=1114112)&&(E=null))),E===null?(E=65533,D=1):E>65535&&(E-=65536,v+=String.fromCharCode(E>>>10&1023|55296),E=56320|1023&E),v+=String.fromCharCode(E),b+=D}return v}(this.buf,r,e)}readBytes(){let e=this.readVarint()+this.pos,r=this.buf.subarray(this.pos,e);return this.pos=e,r}readPackedVarint(e=[],r){let _=this.readPackedEnd();for(;this.pos<_;)e.push(this.readVarint(r));return e}readPackedSVarint(e=[]){let r=this.readPackedEnd();for(;this.pos127;);else if(r===2)this.pos=this.readVarint()+this.pos;else if(r===5)this.pos+=4;else{if(r!==1)throw Error(`Unimplemented type: ${r}`);this.pos+=8}}writeTag(e,r){this.writeVarint(e<<3|r)}realloc(e){let r=this.length||16;for(;r268435455||e<0?function(e,r){let _,v;if(e>=0?(_=e%4294967296|0,v=e/4294967296|0):(_=~(-e%4294967296),v=~(-e/4294967296),4294967295^_?_=_+1|0:(_=0,v=v+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw Error(`Given varint doesn't fit into 10 bytes`);r.realloc(10),function(e,r,_){_.buf[_.pos++]=127&e|128,e>>>=7,_.buf[_.pos++]=127&e|128,e>>>=7,_.buf[_.pos++]=127&e|128,e>>>=7,_.buf[_.pos++]=127&e|128,_.buf[_.pos]=127&(e>>>=7)}(_,0,r),function(e,r){let _=(7&e)<<4;r.buf[r.pos++]|=_|((e>>>=3)?128:0),e&&(r.buf[r.pos++]=127&e|((e>>>=7)?128:0),e&&(r.buf[r.pos++]=127&e|((e>>>=7)?128:0),e&&(r.buf[r.pos++]=127&e|((e>>>=7)?128:0),e&&(r.buf[r.pos++]=127&e|((e>>>=7)?128:0),e&&(r.buf[r.pos++]=127&e)))))}(v,r)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;let r=this.pos;this.pos=function(e,r,_){for(let v,b,x=0;x55295&&v<57344){if(!b){v>56319||x+1===r.length?(e[_++]=239,e[_++]=191,e[_++]=189):b=v;continue}if(v<56320){e[_++]=239,e[_++]=191,e[_++]=189,b=v;continue}v=b-55296<<10|v-56320|65536,b=null}else b&&=(e[_++]=239,e[_++]=191,e[_++]=189,null);v<128?e[_++]=v:(v<2048?e[_++]=v>>6|192:(v<65536?e[_++]=v>>12|224:(e[_++]=v>>18|240,e[_++]=v>>12&63|128),e[_++]=v>>6&63|128),e[_++]=63&v|128)}return _}(this.buf,e,this.pos);let _=this.pos-r;_>=128&&Cm(r,_,this),this.pos=r-1,this.writeVarint(_),this.pos+=_}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){let r=e.length;this.writeVarint(r),this.realloc(r);for(let _=0;_=128&&Cm(_,v,this),this.pos=_-1,this.writeVarint(v),this.pos+=v}writeMessage(e,r,_){this.writeTag(e,2),this.writeRawMessage(r,_)}writePackedVarint(e,r){r.length&&this.writeMessage(e,wm,r)}writePackedSVarint(e,r){r.length&&this.writeMessage(e,Tm,r)}writePackedBoolean(e,r){r.length&&this.writeMessage(e,Om,r)}writePackedFloat(e,r){r.length&&this.writeMessage(e,Em,r)}writePackedDouble(e,r){r.length&&this.writeMessage(e,Dm,r)}writePackedFixed32(e,r){r.length&&this.writeMessage(e,km,r)}writePackedSFixed32(e,r){r.length&&this.writeMessage(e,Am,r)}writePackedFixed64(e,r){r.length&&this.writeMessage(e,jm,r)}writePackedSFixed64(e,r){r.length&&this.writeMessage(e,Mm,r)}writeBytesField(e,r){this.writeTag(e,2),this.writeBytes(r)}writeFixed32Field(e,r){this.writeTag(e,5),this.writeFixed32(r)}writeSFixed32Field(e,r){this.writeTag(e,5),this.writeSFixed32(r)}writeFixed64Field(e,r){this.writeTag(e,1),this.writeFixed64(r)}writeSFixed64Field(e,r){this.writeTag(e,1),this.writeSFixed64(r)}writeVarintField(e,r){this.writeTag(e,0),this.writeVarint(r)}writeSVarintField(e,r){this.writeTag(e,0),this.writeSVarint(r)}writeStringField(e,r){this.writeTag(e,2),this.writeString(r)}writeFloatField(e,r){this.writeTag(e,5),this.writeFloat(r)}writeDoubleField(e,r){this.writeTag(e,1),this.writeDouble(r)}writeBooleanField(e,r){this.writeVarintField(e,+r)}}function Sm(e,r,_){return _?4294967296*r+(e>>>0):4294967296*(r>>>0)+(e>>>0)}function Cm(e,r,_){let v=r<=16383?1:r<=2097151?2:r<=268435455?3:Math.floor(Math.log(r)/(7*Math.LN2));_.realloc(v);for(let r=_.pos-1;r>=e;r--)_.buf[r+v]=_.buf[r]}function wm(e,r){for(let _=0;_r.h-e.h);let v=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),_),h:1/0}],b=0,x=0;for(let r of e)for(let e=v.length-1;e>=0;e--){let _=v[e];if(!(r.w>_.w||r.h>_.h)){if(r.x=_.x,r.y=_.y,x=Math.max(x,r.y+r.h),b=Math.max(b,r.x+r.w),r.w===_.w&&r.h===_.h){let r=v.pop();r&&ez.toCodeUnitIndex(e));let e=K(z.toString(),H);for(let r of e){let e=[...r].map(()=>0);B.push(new Dh(r,z.sections,e))}}else if(q){B=[],H=H.map(e=>z.toCodeUnitIndex(e));let e=0,r=[];for(let _ of z.text)r.push(...Array(_.length).fill(z.sectionIndex[e])),e++;let _=q(z.text,r,H);for(let e of _){let r=[],_=``;for(let v of e[0])r.push(e[1][_.length]),_+=v;B.push(new Dh(e[0],z.sections,r))}}else B=function(e,r){let _=[],v=0;for(let b of r)_.push(e.substring(v,b)),v=b;return vD){let e=Math.ceil(x/D);b*=e/C,C=e}return{x1:v,y1:b,x2:v+x,y2:b+C}}function Jm(e,r,_,v,b,x){let C=e.image,T;if(C.content){let e=C.content,r=C.pixelRatio||1;T=[e[0]/r,e[1]/r,C.displaySize[0]-e[2]/r,C.displaySize[1]-e[3]/r]}let E=r.left*x,D=r.right*x,O,k,A,j;_===`width`||_===`both`?(j=b[0]+E-v[3],k=b[0]+D+v[1]):(j=b[0]+(E+D-C.displaySize[0])/2,k=j+C.displaySize[0]);let F=r.top*x,R=r.bottom*x;return _===`height`||_===`both`?(O=b[1]+F-v[0],A=b[1]+R+v[2]):(O=b[1]+(F+R-C.displaySize[1])/2,A=O+C.displaySize[1]),{image:C,top:O,right:k,bottom:A,left:j,collisionPadding:T}}$c(`ImagePosition`,Jh),$c(`ImageAtlas`,Qh),r.aw=void 0,(Lm=r.aw||={})[Lm.none=0]=`none`,Lm[Lm.horizontal=1]=`horizontal`,Lm[Lm.vertical=2]=`vertical`,Lm[Lm.horizontalOnly=3]=`horizontalOnly`;let Ym=128,Xm=32640;function Zm(e,r){let{expression:_}=r;if(_.kind===`constant`)return{kind:`constant`,layoutSize:_.evaluate(new Bs(e+1))};if(_.kind===`source`)return{kind:`source`};{let{zoomStops:r,interpolationType:v}=_,b=0;for(;be.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];let _=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Zm(this.zoom,_[`text-size`]),this.iconSizeData=Zm(this.zoom,_[`icon-size`]);let v=this.layers[0].layout,b=v.get(`symbol-sort-key`),x=v.get(`symbol-z-order`);this.canOverlap=Qm(v,`text-overlap`,`text-allow-overlap`)!==`never`||Qm(v,`icon-overlap`,`icon-allow-overlap`)!==`never`||v.get(`text-ignore-placement`)||v.get(`icon-ignore-placement`),this.sortFeaturesByKey=x!==`viewport-y`&&!b.isConstant(),this.sortFeaturesByY=(x===`viewport-y`||x===`auto`&&!this.sortFeaturesByKey)&&this.canOverlap,v.get(`symbol-placement`)===`point`&&(this.writingModes=v.get(`text-writing-mode`).map(e=>r.aw[e])),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID}createArrays(){this.text=new bp(new Oa(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new bp(new Oa(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new $o,this.lineVertexArray=new Ro,this.symbolInstances=new Oo,this.textAnchorOffsets=new Uo}calculateGlyphDependencies(e,r,_,v,b){for(let x of e)if(r[x.codePointAt(0)]=!0,(_||v)&&b){let e=dm[x];e&&(r[e.codePointAt(0)]=!0)}}populate(e,_,v){let b=this.layers[0],x=b.layout,C=x.get(`text-font`),T=x.get(`text-field`),E=x.get(`icon-image`),D=(T.value.kind!==`constant`||T.value.value instanceof De&&!T.value.value.isEmpty()||T.value.value.toString().length>0)&&(C.value.kind!==`constant`||C.value.value.length>0),O=E.value.kind!==`constant`||!!E.value.value||Object.keys(E.parameters).length>0,k=x.get(`symbol-sort-key`);if(this.features=[],!D&&!O)return;let A=_.iconDependencies,j=_.glyphDependencies,F=_.availableImages,R=new Bs(this.zoom);for(let{feature:_,id:T,index:E,sourceLayerIndex:z}of e){let e=b._featureFilter.needGeometry,B=iu(_,e);if(!b._featureFilter.filter(R,B,v))continue;let H,K;if(e||(B.geometry=ru(_)),D){let e=b.getValueAndResolveTokens(`text-field`,B,v,F),r=De.factory(e),_=this.hasRTLText=this.hasRTLText||rh(r);(!_||yl.getRTLTextPluginStatus()===`unavailable`||_&&yl.isParsed())&&(H=lm(r,b,B))}if(O){let e=b.getValueAndResolveTokens(`icon-image`,B,v,F);K=e instanceof $e?e:$e.fromString(e)}if(!H&&!K)continue;let q=this.sortFeaturesByKey?k.evaluate(B,{},v):void 0;if(this.features.push({id:T,text:H,icon:K,index:E,sourceLayerIndex:z,geometry:B.geometry,properties:_.properties,type:Bu.types[_.type],sortKey:q}),K&&(A[K.name]=!0),H){let e=C.evaluate(B,{},v).join(`,`),_=x.get(`text-rotation-alignment`)!==`viewport`&&x.get(`symbol-placement`)!==`point`;this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(r.aw.vertical)>=0;for(let r of H.sections)if(r.image)A[r.image.name]=!0;else{let v=cl(H.toString()),b=r.fontStack||e,x=j[b]=j[b]||{};this.calculateGlyphDependencies(r.text,x,_,this.allowVerticalPlacement,v)}}}x.get(`symbol-placement`)===`line`&&(this.features=function(e){let r={},_={},v=[],b=0;function x(r){v.push(e[r]),b++}function C(e,r,b){let x=_[e];return delete _[e],_[r]=x,v[x].geometry[0].pop(),v[x].geometry[0]=v[x].geometry[0].concat(b[0]),x}function T(e,_,b){let x=r[_];return delete r[_],r[e]=x,v[x].geometry[0].shift(),v[x].geometry[0]=b[0].concat(v[x].geometry[0]),x}function E(e,r,_){let v=_?r[0][r[0].length-1]:r[0][0];return`${e}:${v.x}:${v.y}`}for(let D=0;De.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((e,r)=>e.sortKey-r.sortKey)}update(e,r,_){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,r,this.layers,{imagePositions:_}),this.icon.programConfigurations.updatePaintArrays(e,r,this.layers,{imagePositions:_}))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,r){let _=this.lineVertexArray.length;if(e.segment!==void 0){let _=e.dist(r[e.segment+1]),v=e.dist(r[e.segment]),b={};for(let v=e.segment+1;v=0;_--)b[_]={x:r[_].x,y:r[_].y,tileUnitDistanceFromAnchor:v},_>0&&(v+=r[_-1].dist(r[_]));for(let e=0;e0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,r){let _=e.placedSymbolArray.get(r),v=_.vertexStartIndex+4*_.numGlyphs;for(let r=_.vertexStartIndex;rv[e]-v[r]||b[r]-b[e]),x}addToSortKeyRanges(e,r){let _=this.sortKeyRanges[this.sortKeyRanges.length-1];_&&_.sortKey===r?_.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let e of this.symbolInstanceIndexes){let r=this.symbolInstances.get(e);this.featureSortOrder.push(r.featureIndex),[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex].forEach((e,r,_)=>{e>=0&&_.indexOf(e)===r&&this.addIndicesForPlacedSymbol(this.text,e)}),r.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,r.verticalPlacedTextSymbolIndex),r.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,r.placedIconSymbolIndex),r.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,r.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let ih,ah;$c(`SymbolBucket`,_p,{omit:[`layers`,`collisionBoxArray`,`features`,`compareText`]}),_p.MAX_GLYPHS=65535,_p.addDynamicAttributes=nh;var oh={get paint(){return ah||=new Ws({"icon-opacity":new Xs($.paint_symbol[`icon-opacity`]),"icon-color":new Xs($.paint_symbol[`icon-color`]),"icon-halo-color":new Xs($.paint_symbol[`icon-halo-color`]),"icon-halo-width":new Xs($.paint_symbol[`icon-halo-width`]),"icon-halo-blur":new Xs($.paint_symbol[`icon-halo-blur`]),"icon-translate":new Gs($.paint_symbol[`icon-translate`]),"icon-translate-anchor":new Gs($.paint_symbol[`icon-translate-anchor`]),"text-opacity":new Xs($.paint_symbol[`text-opacity`]),"text-color":new Xs($.paint_symbol[`text-color`],{runtimeType:_n,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Xs($.paint_symbol[`text-halo-color`]),"text-halo-width":new Xs($.paint_symbol[`text-halo-width`]),"text-halo-blur":new Xs($.paint_symbol[`text-halo-blur`]),"text-translate":new Gs($.paint_symbol[`text-translate`]),"text-translate-anchor":new Gs($.paint_symbol[`text-translate-anchor`])})},get layout(){return ih||=new Ws({"symbol-placement":new Gs($.layout_symbol[`symbol-placement`]),"symbol-spacing":new Gs($.layout_symbol[`symbol-spacing`]),"symbol-avoid-edges":new Gs($.layout_symbol[`symbol-avoid-edges`]),"symbol-sort-key":new Xs($.layout_symbol[`symbol-sort-key`]),"symbol-z-order":new Gs($.layout_symbol[`symbol-z-order`]),"icon-allow-overlap":new Gs($.layout_symbol[`icon-allow-overlap`]),"icon-overlap":new Gs($.layout_symbol[`icon-overlap`]),"icon-ignore-placement":new Gs($.layout_symbol[`icon-ignore-placement`]),"icon-optional":new Gs($.layout_symbol[`icon-optional`]),"icon-rotation-alignment":new Gs($.layout_symbol[`icon-rotation-alignment`]),"icon-size":new Xs($.layout_symbol[`icon-size`]),"icon-text-fit":new Gs($.layout_symbol[`icon-text-fit`]),"icon-text-fit-padding":new Gs($.layout_symbol[`icon-text-fit-padding`]),"icon-image":new Xs($.layout_symbol[`icon-image`]),"icon-rotate":new Xs($.layout_symbol[`icon-rotate`]),"icon-padding":new Xs($.layout_symbol[`icon-padding`]),"icon-keep-upright":new Gs($.layout_symbol[`icon-keep-upright`]),"icon-offset":new Xs($.layout_symbol[`icon-offset`]),"icon-anchor":new Xs($.layout_symbol[`icon-anchor`]),"icon-pitch-alignment":new Gs($.layout_symbol[`icon-pitch-alignment`]),"text-pitch-alignment":new Gs($.layout_symbol[`text-pitch-alignment`]),"text-rotation-alignment":new Gs($.layout_symbol[`text-rotation-alignment`]),"text-field":new Xs($.layout_symbol[`text-field`]),"text-font":new Xs($.layout_symbol[`text-font`]),"text-size":new Xs($.layout_symbol[`text-size`]),"text-max-width":new Xs($.layout_symbol[`text-max-width`]),"text-line-height":new Gs($.layout_symbol[`text-line-height`]),"text-letter-spacing":new Xs($.layout_symbol[`text-letter-spacing`]),"text-justify":new Xs($.layout_symbol[`text-justify`]),"text-radial-offset":new Xs($.layout_symbol[`text-radial-offset`]),"text-variable-anchor":new Gs($.layout_symbol[`text-variable-anchor`]),"text-variable-anchor-offset":new Xs($.layout_symbol[`text-variable-anchor-offset`]),"text-anchor":new Xs($.layout_symbol[`text-anchor`]),"text-max-angle":new Gs($.layout_symbol[`text-max-angle`]),"text-writing-mode":new Gs($.layout_symbol[`text-writing-mode`]),"text-rotate":new Xs($.layout_symbol[`text-rotate`]),"text-padding":new Gs($.layout_symbol[`text-padding`]),"text-keep-upright":new Gs($.layout_symbol[`text-keep-upright`]),"text-transform":new Xs($.layout_symbol[`text-transform`]),"text-offset":new Xs($.layout_symbol[`text-offset`]),"text-allow-overlap":new Gs($.layout_symbol[`text-allow-overlap`]),"text-overlap":new Gs($.layout_symbol[`text-overlap`]),"text-ignore-placement":new Gs($.layout_symbol[`text-ignore-placement`]),"text-optional":new Gs($.layout_symbol[`text-optional`])})}};class kp{constructor(e){if(e.property.overrides===void 0)throw Error(`overrides must be provided to instantiate FormatSectionOverride class`);this.type=e.property.overrides?e.property.overrides.runtimeType:pn,this.defaultValue=e}evaluate(e){if(e.formattedSection){let r=this.defaultValue.property.overrides;if(r&&r.hasOverride(e.formattedSection))return r.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}$c(`FormatSectionOverride`,kp,{omit:[`defaultValue`]});class Ip extends Qs{constructor(e,r){super(e,oh,r)}recalculate(e,r){if(super.recalculate(e,r),this.layout.get(`icon-rotation-alignment`)===`auto`&&(this.layout._values[`icon-rotation-alignment`]=this.layout.get(`symbol-placement`)===`point`?`viewport`:`map`),this.layout.get(`text-rotation-alignment`)===`auto`&&(this.layout._values[`text-rotation-alignment`]=this.layout.get(`symbol-placement`)===`point`?`viewport`:`map`),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 e=this.layout.get(`text-writing-mode`);if(e){let r=[];for(let _ of e)r.indexOf(_)<0&&r.push(_);this.layout._values[`text-writing-mode`]=r}else this.layout._values[`text-writing-mode`]=[`horizontal`]}this._setPaintOverrides()}getValueAndResolveTokens(e,r,_,v){let b=this.layout.get(e).evaluate(r,{},_,v),x=this._unevaluatedLayout._values[e];return x.isDataDriven()||Ms(x.value)||!b?b:function(e,r){return r.replace(/{([^{}]+)}/g,(r,_)=>e&&_ in e?String(e[_]):``)}(r.properties,b)}createBucket(e){return new _p(e)}queryRadius(){return 0}queryIntersectsFeature(){throw Error(`Should take a different path in FeatureIndex`)}_setPaintOverrides(){for(let e of oh.paint.overridableProperties){if(!Ip.hasPaintOverride(this.layout,e))continue;let r=this.paint.get(e),_=new ni(new kp(r),r.property.specification),v=null;v=r.value.kind===`constant`||r.value.kind===`source`?new si(`source`,_):new oi(`composite`,_,r.value.zoomStops),this.paint._values[e]=new js(r.property,v,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,_){return!(!this.layout||r.isDataDriven()||_.isDataDriven())&&Ip.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){let _=e.get(`text-field`),v=oh.paint.properties[r],b=!1,x=e=>{for(let r of e)if(v.overrides&&v.overrides.hasOverride(r))return void(b=!0)};if(_.value.kind===`constant`&&_.value.value instanceof De)x(_.value.value.sections);else if(_.value.kind===`source`||_.value.kind===`composite`){let e=r=>{b||(r instanceof Ge&&ei(r.value)===wn?x(r.value.sections):r instanceof Fn?x(r.sections):r.eachChild(e))},r=_.value;r._styleExpression&&e(r._styleExpression.expression)}return b}}let sh;var ch={get paint(){return sh||=new Ws({"background-color":new Gs($.paint_background[`background-color`]),"background-pattern":new Zs($.paint_background[`background-pattern`]),"background-opacity":new Gs($.paint_background[`background-opacity`])})}};class Fp extends Qs{constructor(e,r){super(e,ch,r)}}class Pp extends Qs{constructor(e,r){super(e,{},r),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode===`3d`}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw Error(`Custom layers cannot be serialized`)}}class Dp{constructor(e){this._methodToThrottle=e,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()}}trigger(){var e;this._triggered||(this._triggered=!0,(e=this._channel)==null||e.port1.postMessage(!0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}let lh={once:!0},dh=6371008.8;class Cp{constructor(e,r){if(isNaN(e)||isNaN(r))throw Error(`Invalid LngLat object: (${e}, ${r})`);if(this.lng=+e,this.lat=+r,this.lat>90||this.lat<-90)throw Error(`Invalid LngLat latitude value: must be between -90 and 90`)}wrap(){return new Cp(ve(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){let r=Math.PI/180,_=this.lat*r,v=e.lat*r,b=Math.sin(_)*Math.sin(v)+Math.cos(_)*Math.cos(v)*Math.cos((e.lng-this.lng)*r);return dh*Math.acos(Math.min(b,1))}static convert(e){if(e instanceof Cp)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Cp(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e==`object`&&e)return new Cp(Number(`lng`in e?e.lng:e.lon),Number(e.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}let ph=2*Math.PI*dh;function mh(e){return ph*Math.cos(e*Math.PI/180)}function hh(e){return(180+e)/360}function gh(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function _h(e,r){return e/mh(r)}function vh(e){return 360*e-180}function bh(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function xh(e,r){return e*mh(bh(r))}class qp{constructor(e,r,_=0){this.x=+e,this.y=+r,this.z=+_}static fromLngLat(e,r=0){let _=Cp.convert(e);return new qp(hh(_.lng),gh(_.lat),_h(r,_.lat))}toLngLat(){return new Cp(vh(this.x),bh(this.y))}toAltitude(){return xh(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/ph*(e=bh(this.y),1/Math.cos(e*Math.PI/180));var e}}function Sh(e,r,_){var v=2*Math.PI*6378137/256/2**_;return[e*v-2*Math.PI*6378137/2,r*v-2*Math.PI*6378137/2]}class Xp{constructor(e,r,_){if(!function(e,r,_){return!(e<0||e>25||_<0||_>=2**e||r<0||r>=2**e)}(e,r,_))throw Error(`x=${r}, y=${_}, z=${e} outside of bounds. 0<=x<${2**e}, 0<=y<${2**e} 0<=z<=25 `);this.z=e,this.x=r,this.y=_,this.key=Ch(0,e,e,r,_)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,r,_){let v=(x=this.y,C=this.z,T=Sh(256*(b=this.x),256*(x=2**C-x-1),C),E=Sh(256*(b+1),256*(x+1),C),T[0]+`,`+T[1]+`,`+E[0]+`,`+E[1]);var b,x,C,T,E;let D=function(e,r,_){let v,b=``;for(let x=e;x>0;x--)v=1<1?`@2x`:``).replace(/{quadkey}/g,D).replace(/{bbox-epsg-3857}/g,v)}isChildOf(e){let r=this.z-e.z;return r>0&&e.x===this.x>>r&&e.y===this.y>>r}getTilePoint(e){let r=2**this.z;return new v((e.x*r-this.x)*ce,(e.y*r-this.y)*ce)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Yp{constructor(e,r){this.wrap=e,this.canonical=r,this.key=Ch(e,r.z,r.z,r.x,r.y)}}class Zp{constructor(e,r,_,v,b){if(this.terrainRttPosMatrix32f=null,e<_)throw Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${_}`);this.overscaledZ=e,this.wrap=r,this.canonical=new Xp(_,+v,+b),this.key=Ch(r,e,_,v,b)}clone(){return new Zp(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let r=this.canonical.z-e;return e>this.canonical.z?new Zp(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Zp(e,this.wrap,e,this.canonical.x>>r,this.canonical.y>>r)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,r){if(e>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let _=this.canonical.z-e;return e>this.canonical.z?Ch(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y):Ch(this.wrap*+r,e,e,this.canonical.x>>_,this.canonical.y>>_)}isChildOf(e){if(e.wrap!==this.wrap||this.overscaledZ-e.overscaledZ<=0)return!1;if(e.overscaledZ===0)return this.overscaledZ>0;let r=this.canonical.z-e.canonical.z;return!(r<0)&&e.canonical.x===this.canonical.x>>r&&e.canonical.y===this.canonical.y>>r}children(e){if(this.overscaledZ>=e)return[new Zp(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let r=this.canonical.z+1,_=2*this.canonical.x,v=2*this.canonical.y;return[new Zp(r,this.wrap,r,_,v),new Zp(r,this.wrap,r,_+1,v),new Zp(r,this.wrap,r,_,v+1),new Zp(r,this.wrap,r,_+1,v+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.y=0&&e<_&&r>=0&&r<_)return{tileID:this,x:e,y:r};let v=Math.floor(e/_),b=Math.floor(r/_),x=e-v*_,C=r-b*_,T=this.canonical.z,E=1<=E)return null;let O=this.canonical.x+v,k=this.wrap;return O<0?(k-=Math.ceil(-O/E),O=(O%E+E)%E):O>=E&&(k+=Math.floor(O/E),O%=E),{tileID:new Zp(this.overscaledZ,k,T,O,D),x,y:C}}}function Ch(e,r,_,v,b){(e*=2)<0&&(e=-1*e-1);let x=1<<_;return(x*x*e+x*b+v).toString(36)+_.toString(36)+r.toString(36)}$c(`CanonicalTileID`,Xp),$c(`OverscaledTileID`,Zp,{omit:[`terrainRttPosMatrix32f`]});class Wp{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){let r=new Wp;return r.extend(e(new v(this.minX,this.minY))),r.extend(e(new v(this.maxX,this.minY))),r.extend(e(new v(this.minX,this.maxY))),r.extend(e(new v(this.maxX,this.maxY))),r}static fromPoints(e){let r=new Wp;for(let _ of e)r.extend(_);return r}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}class Kp{constructor(e){this._stringToNumber={},this._numberToString=[];for(let r=0;r=this._numberToString.length)throw Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Jp{constructor(e,r,_,v,b){this.type=`Feature`,this._vectorTileFeature=e,this._x=_,this._y=v,this._z=r,this.properties=e.properties,this.id=b}projectPoint(e,r,_,v){return[360*(e.x+r)/v-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+_)/v)*Math.PI))-90]}projectLine(e,r,_,v){return e.map(e=>this.projectPoint(e,r,_,v))}get geometry(){if(this._geometry)return this._geometry;let e=this._vectorTileFeature,r=e.extent*2**this._z,_=e.extent*this._x,v=e.extent*this._y,b=e.loadGeometry();switch(e.type){case 1:{let e=[];for(let r of b)e.push(r[0]);let x=this.projectLine(e,_,v,r);this._geometry=e.length===1?{type:`Point`,coordinates:x[0]}:{type:`MultiPoint`,coordinates:x};break}case 2:{let e=b.map(e=>this.projectLine(e,_,v,r));this._geometry=e.length===1?{type:`LineString`,coordinates:e[0]}:{type:`MultiLineString`,coordinates:e};break}case 3:{let e=_f(b),x=[];for(let b of e)x.push(b.map(e=>this.projectLine(e,_,v,r)));this._geometry=x.length===1?{type:`Polygon`,coordinates:x[0]}:{type:`MultiPolygon`,coordinates:x};break}default:throw Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){let e={geometry:this.geometry};for(let r in this)r!==`_geometry`&&r!==`_vectorTileFeature`&&r!==`_x`&&r!==`_y`&&r!==`_z`&&(e[r]=this[r]);return e}}class Qp{constructor(e,r,_){this._name=e,this.dataBuffer=r,typeof _==`number`?this._size=_:(this.nullabilityBuffer=_,this._size=_.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer?.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class tf extends Qp{}class ef extends tf{getValueFromBuffer(e){return this.dataBuffer[e]}}class nf extends tf{getValueFromBuffer(e){return this.dataBuffer[e]}}class rf extends Qp{constructor(e,r,_,v){super(e,r,v),this.delta=_}}class sf extends rf{constructor(e,r,_,v){super(e,Int32Array.of(r),_,v)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class of extends Qp{constructor(e,r,_,v){super(e,v?Int32Array.of(r):Uint32Array.of(r),_)}getValueFromBuffer(e){return this.dataBuffer[0]}}class af{constructor(e,r,_,v,b=4096){this._name=e,this._geometryVector=r,this._idVector=_,this._propertyVectors=v,this._extent=b}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||=new Map(this._propertyVectors.map(e=>[e.name,e])),this.propertyVectorsMap.get(e)}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){let e=[],r=this.geometryVector.getGeometries();for(let _=0;_>>32-e;let Oh=Eh,kh=256;function Ah(e,r){return e-e%r}function jh(e){let r=e>>>0;return((255&r)<<24|(65280&r)<<8|r>>>8&65280|r>>>24&255)>>>0}let Mh=function(){let e=Ah(65536,256);return e===0?256:e}(),Nh=3*Mh/256+Mh|0;function Ph(){let e=new Uint8Array(Nh);return{dataToBePacked:Array(33),dataPointers:new Int32Array(33),byteContainer:e,byteContainerI32:new Int32Array(e.buffer,e.byteOffset,e.byteLength>>>2),exceptionSizes:new Int32Array(33)}}function Fh(e,r,_,v,b){switch(b){case 1:(function(e,r,_,v){let b=v,x=r;for(let r=0;r<8;r++){let r=e[x++]>>>0;_[b++]=r>>>0&1,_[b++]=r>>>1&1,_[b++]=r>>>2&1,_[b++]=r>>>3&1,_[b++]=r>>>4&1,_[b++]=r>>>5&1,_[b++]=r>>>6&1,_[b++]=r>>>7&1,_[b++]=r>>>8&1,_[b++]=r>>>9&1,_[b++]=r>>>10&1,_[b++]=r>>>11&1,_[b++]=r>>>12&1,_[b++]=r>>>13&1,_[b++]=r>>>14&1,_[b++]=r>>>15&1,_[b++]=r>>>16&1,_[b++]=r>>>17&1,_[b++]=r>>>18&1,_[b++]=r>>>19&1,_[b++]=r>>>20&1,_[b++]=r>>>21&1,_[b++]=r>>>22&1,_[b++]=r>>>23&1,_[b++]=r>>>24&1,_[b++]=r>>>25&1,_[b++]=r>>>26&1,_[b++]=r>>>27&1,_[b++]=r>>>28&1,_[b++]=r>>>29&1,_[b++]=r>>>30&1,_[b++]=r>>>31&1}})(e,r,_,v);break;case 2:(function(e,r,_,v){let b=v,x=r;for(let r=0;r<8;r++){let r=e[x++]>>>0,v=e[x++]>>>0;_[b++]=r>>>0&3,_[b++]=r>>>2&3,_[b++]=r>>>4&3,_[b++]=r>>>6&3,_[b++]=r>>>8&3,_[b++]=r>>>10&3,_[b++]=r>>>12&3,_[b++]=r>>>14&3,_[b++]=r>>>16&3,_[b++]=r>>>18&3,_[b++]=r>>>20&3,_[b++]=r>>>22&3,_[b++]=r>>>24&3,_[b++]=r>>>26&3,_[b++]=r>>>28&3,_[b++]=r>>>30&3,_[b++]=v>>>0&3,_[b++]=v>>>2&3,_[b++]=v>>>4&3,_[b++]=v>>>6&3,_[b++]=v>>>8&3,_[b++]=v>>>10&3,_[b++]=v>>>12&3,_[b++]=v>>>14&3,_[b++]=v>>>16&3,_[b++]=v>>>18&3,_[b++]=v>>>20&3,_[b++]=v>>>22&3,_[b++]=v>>>24&3,_[b++]=v>>>26&3,_[b++]=v>>>28&3,_[b++]=v>>>30&3}})(e,r,_,v);break;case 3:(function(e,r,_,v){let b=v,x=r;for(let r=0;r<8;r++){let r=e[x++]>>>0,v=e[x++]>>>0,C=e[x++]>>>0;_[b++]=r>>>0&7,_[b++]=r>>>3&7,_[b++]=r>>>6&7,_[b++]=r>>>9&7,_[b++]=r>>>12&7,_[b++]=r>>>15&7,_[b++]=r>>>18&7,_[b++]=r>>>21&7,_[b++]=r>>>24&7,_[b++]=r>>>27&7,_[b++]=7&(r>>>30|(1&v)<<2),_[b++]=v>>>1&7,_[b++]=v>>>4&7,_[b++]=v>>>7&7,_[b++]=v>>>10&7,_[b++]=v>>>13&7,_[b++]=v>>>16&7,_[b++]=v>>>19&7,_[b++]=v>>>22&7,_[b++]=v>>>25&7,_[b++]=v>>>28&7,_[b++]=7&(v>>>31|(3&C)<<1),_[b++]=C>>>2&7,_[b++]=C>>>5&7,_[b++]=C>>>8&7,_[b++]=C>>>11&7,_[b++]=C>>>14&7,_[b++]=C>>>17&7,_[b++]=C>>>20&7,_[b++]=C>>>23&7,_[b++]=C>>>26&7,_[b++]=C>>>29&7}})(e,r,_,v);break;case 4:(function(e,r,_,v){let b=v,x=r;for(let r=0;r<8;r++){let r=e[x++]>>>0,v=e[x++]>>>0,C=e[x++]>>>0,T=e[x++]>>>0;_[b++]=r>>>0&15,_[b++]=r>>>4&15,_[b++]=r>>>8&15,_[b++]=r>>>12&15,_[b++]=r>>>16&15,_[b++]=r>>>20&15,_[b++]=r>>>24&15,_[b++]=r>>>28&15,_[b++]=v>>>0&15,_[b++]=v>>>4&15,_[b++]=v>>>8&15,_[b++]=v>>>12&15,_[b++]=v>>>16&15,_[b++]=v>>>20&15,_[b++]=v>>>24&15,_[b++]=v>>>28&15,_[b++]=C>>>0&15,_[b++]=C>>>4&15,_[b++]=C>>>8&15,_[b++]=C>>>12&15,_[b++]=C>>>16&15,_[b++]=C>>>20&15,_[b++]=C>>>24&15,_[b++]=C>>>28&15,_[b++]=T>>>0&15,_[b++]=T>>>4&15,_[b++]=T>>>8&15,_[b++]=T>>>12&15,_[b++]=T>>>16&15,_[b++]=T>>>20&15,_[b++]=T>>>24&15,_[b++]=T>>>28&15}})(e,r,_,v);break;case 5:(function(e,r,_,v){let b=v,x=r;for(let r=0;r<8;r++){let r=e[x++]>>>0,v=e[x++]>>>0,C=e[x++]>>>0,T=e[x++]>>>0,E=e[x++]>>>0;_[b++]=r>>>0&31,_[b++]=r>>>5&31,_[b++]=r>>>10&31,_[b++]=r>>>15&31,_[b++]=r>>>20&31,_[b++]=r>>>25&31,_[b++]=31&(r>>>30|(7&v)<<2),_[b++]=v>>>3&31,_[b++]=v>>>8&31,_[b++]=v>>>13&31,_[b++]=v>>>18&31,_[b++]=v>>>23&31,_[b++]=31&(v>>>28|(1&C)<<4),_[b++]=C>>>1&31,_[b++]=C>>>6&31,_[b++]=C>>>11&31,_[b++]=C>>>16&31,_[b++]=C>>>21&31,_[b++]=C>>>26&31,_[b++]=31&(C>>>31|(15&T)<<1),_[b++]=T>>>4&31,_[b++]=T>>>9&31,_[b++]=T>>>14&31,_[b++]=T>>>19&31,_[b++]=T>>>24&31,_[b++]=31&(T>>>29|(3&E)<<3),_[b++]=E>>>2&31,_[b++]=E>>>7&31,_[b++]=E>>>12&31,_[b++]=E>>>17&31,_[b++]=E>>>22&31,_[b++]=E>>>27&31}})(e,r,_,v);break;case 6:(function(e,r,_,v){let b=v,x=r;for(let r=0;r<8;r++){let r=e[x++]>>>0,v=e[x++]>>>0,C=e[x++]>>>0,T=e[x++]>>>0,E=e[x++]>>>0,D=e[x++]>>>0;_[b++]=r>>>0&63,_[b++]=r>>>6&63,_[b++]=r>>>12&63,_[b++]=r>>>18&63,_[b++]=r>>>24&63,_[b++]=63&(r>>>30|(15&v)<<2),_[b++]=v>>>4&63,_[b++]=v>>>10&63,_[b++]=v>>>16&63,_[b++]=v>>>22&63,_[b++]=63&(v>>>28|(3&C)<<4),_[b++]=C>>>2&63,_[b++]=C>>>8&63,_[b++]=C>>>14&63,_[b++]=C>>>20&63,_[b++]=C>>>26&63,_[b++]=T>>>0&63,_[b++]=T>>>6&63,_[b++]=T>>>12&63,_[b++]=T>>>18&63,_[b++]=T>>>24&63,_[b++]=63&(T>>>30|(15&E)<<2),_[b++]=E>>>4&63,_[b++]=E>>>10&63,_[b++]=E>>>16&63,_[b++]=E>>>22&63,_[b++]=63&(E>>>28|(3&D)<<4),_[b++]=D>>>2&63,_[b++]=D>>>8&63,_[b++]=D>>>14&63,_[b++]=D>>>20&63,_[b++]=D>>>26&63}})(e,r,_,v);break;case 7:(function(e,r,_,v){let b=v,x=r;for(let r=0;r<8;r++){let r=e[x++]>>>0,v=e[x++]>>>0,C=e[x++]>>>0,T=e[x++]>>>0,E=e[x++]>>>0,D=e[x++]>>>0,O=e[x++]>>>0;_[b++]=r>>>0&127,_[b++]=r>>>7&127,_[b++]=r>>>14&127,_[b++]=r>>>21&127,_[b++]=127&(r>>>28|(7&v)<<4),_[b++]=v>>>3&127,_[b++]=v>>>10&127,_[b++]=v>>>17&127,_[b++]=v>>>24&127,_[b++]=127&(v>>>31|(63&C)<<1),_[b++]=C>>>6&127,_[b++]=C>>>13&127,_[b++]=C>>>20&127,_[b++]=127&(C>>>27|(3&T)<<5),_[b++]=T>>>2&127,_[b++]=T>>>9&127,_[b++]=T>>>16&127,_[b++]=T>>>23&127,_[b++]=127&(T>>>30|(31&E)<<2),_[b++]=E>>>5&127,_[b++]=E>>>12&127,_[b++]=E>>>19&127,_[b++]=127&(E>>>26|(1&D)<<6),_[b++]=D>>>1&127,_[b++]=D>>>8&127,_[b++]=D>>>15&127,_[b++]=D>>>22&127,_[b++]=127&(D>>>29|(15&O)<<3),_[b++]=O>>>4&127,_[b++]=O>>>11&127,_[b++]=O>>>18&127,_[b++]=O>>>25&127}})(e,r,_,v);break;case 8:(function(e,r,_,v){let b=v,x=r;for(let r=0;r<8;r++){let r=e[x++]>>>0,v=e[x++]>>>0,C=e[x++]>>>0,T=e[x++]>>>0,E=e[x++]>>>0,D=e[x++]>>>0,O=e[x++]>>>0,k=e[x++]>>>0;_[b++]=r>>>0&255,_[b++]=r>>>8&255,_[b++]=r>>>16&255,_[b++]=r>>>24&255,_[b++]=v>>>0&255,_[b++]=v>>>8&255,_[b++]=v>>>16&255,_[b++]=v>>>24&255,_[b++]=C>>>0&255,_[b++]=C>>>8&255,_[b++]=C>>>16&255,_[b++]=C>>>24&255,_[b++]=T>>>0&255,_[b++]=T>>>8&255,_[b++]=T>>>16&255,_[b++]=T>>>24&255,_[b++]=E>>>0&255,_[b++]=E>>>8&255,_[b++]=E>>>16&255,_[b++]=E>>>24&255,_[b++]=D>>>0&255,_[b++]=D>>>8&255,_[b++]=D>>>16&255,_[b++]=D>>>24&255,_[b++]=O>>>0&255,_[b++]=O>>>8&255,_[b++]=O>>>16&255,_[b++]=O>>>24&255,_[b++]=k>>>0&255,_[b++]=k>>>8&255,_[b++]=k>>>16&255,_[b++]=k>>>24&255}})(e,r,_,v);break;case 16:(function(e,r,_,v){let b=v,x=r;for(let r=0;r<128;r++){let r=e[x++]>>>0;_[b++]=65535&r,_[b++]=r>>>16&65535}})(e,r,_,v);break;default:(function(e,r,_,v,b){let x=Oh[b]>>>0,C=r,T=0,E=e[C]>>>0,D=v;for(let r=0;r<8;r++){for(let r=0;r<32;r++)if(T+b<=32)_[D+r]=E>>>T&x,T+=b,T===32&&(T=0,C++,r!==31&&(E=e[C]>>>0));else{let v=32-T,O=E>>>T;C++,E=e[C]>>>0;let k=b-v;_[D+r]=(O|(E&-1>>>32-k>>>0)<>>0)}})(e,r,_,v,b)}return r+(b<<3)|0}function Ih(e,r,_,v){if(_+2>r)throw Error(`FastPFOR decode: byteContainer underflow at block=${v} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${_}, byteSize=${r})`);let b=e[_++],x=e[_++];if(b>32)throw Error(`FastPFOR decode: invalid bitWidth=${b} at block=${v} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:b,exceptionCount:x,bytePosIn:_}}function Lh(e,r,_,v,b,x,C,T,E){let{maxBits:D,exceptionBitWidth:O,bytePosIn:k}=function(e,r,_,v,b,x){if(_+1>r)throw Error(`FastPFOR decode: exception header underflow at block=${x} (need 1 byte for maxBits, bytePos=${_}, byteSize=${r})`);let C=e[_++];if(C32)throw Error(`FastPFOR decode: invalid maxBits=${C} at block=${x} (bitWidth=${v}, expected ${v}..32)`);let T=C-v|0;if(T<1||T>32)throw Error(`FastPFOR decode: invalid exceptionBitWidth=${T} at block=${x} (bitWidth=${v}, maxBits=${C})`);if(_+b>r)throw Error(`FastPFOR decode: exception positions underflow at block=${x} (need=${b}, have=${r-_})`);return{maxBits:C,exceptionBitWidth:T,bytePosIn:_}}(b,x,C,_,v,E);if(C=k,O===1){let x=1<<_;for(let _=0;_R)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${O} (ptr=${F}, need ${v}, size=${R}) at block ${E}`);for(let x=0;xe.length-1)throw Error(`FastPFOR decode: invalid whereMeta=${T} at pageStart=${C} (expected > 0 and pageStart+whereMeta < encoded.length=${e.length})`);let E=C+1|0,D=C+T|0,O=e[D]>>>0,k=O+3>>>2,A=D+1,j=A+k;if(j>=e.length)throw Error(`FastPFOR decode: invalid byteSize=${O} (metaInts=${k}, pageStart=${C}, packedEnd=${D}, byteContainerStart=${A}) causes bitmapPos=${j} out of bounds (encoded.length=${e.length})`);let F=function(e,r,_,v){v.byteContainer.length<_&&(v.byteContainer=new Uint8Array(2*_),v.byteContainerI32=void 0);let b=v.byteContainer,x=_>>>2;if(3&b.byteOffset)for(let _=0;_>>8&255,b[x+2|0]=v>>>16&255,b[x+3|0]=v>>>24&255}else{let _=v.byteContainerI32;(!_||_.buffer!==b.buffer||_.byteOffset!==b.byteOffset||_.length>>2)),_.set(e.subarray(r,r+x))}let C=3&_;if(C>0){let _=0|e[r+x|0],v=x<<2;for(let e=0;e>>(e<<3)&255}return b}(e,A,O,x),R=O,z=function(e,r,_){let v=0|e[r++],b=_.dataToBePacked;for(let x=2;x<=32;x=x+1|0){if(!(v>>>x-1&1))continue;if(r>=e.length)throw Error(`FastPFOR decode: truncated exception stream header (bitWidth=${x}, streamWordIndex=${r}, needWords=1, availableWords=${e.length-r}, encodedWords=${e.length})`);let C=e[r++]>>>0,T=Ah(C+31,32),E=C*x+31>>>5;if(r+E>e.length)throw Error(`FastPFOR decode: truncated exception stream (bitWidth=${x}, size=${C}, streamWordIndex=${r}, needWords=${E}, availableWords=${e.length-r}, encodedWords=${e.length})`);let D=b[x];(!D||D.length>>5)|0,_.exceptionSizes[x]=C}return r}(e,j,x);return x.dataPointers.fill(0),function(e,r,_,v,b,x,C,T,E,D){let O=0|_,k=0;for(let r=0;r0&&(k=Lh(b,A,v,C,T,E,k,D,r))}if(O!==v)throw Error(`FastPFOR decode: packed region mismatch (pageStart=${r}, packedStart=${_}, consumedPackedEnd=${O}, expectedPackedEnd=${v}, packedWords=${v-_}, encoded.length=${e.length})`)}(e,C,E,D,r,0|v,b/256|0,F,R,x),z}function zh(e,r,_,v,b){switch(b){case 2:(function(e,r,_,v){let b=v,x=e[r]>>>0,C=e[r+1]>>>0;_[b++]=x>>>0&3,_[b++]=x>>>2&3,_[b++]=x>>>4&3,_[b++]=x>>>6&3,_[b++]=x>>>8&3,_[b++]=x>>>10&3,_[b++]=x>>>12&3,_[b++]=x>>>14&3,_[b++]=x>>>16&3,_[b++]=x>>>18&3,_[b++]=x>>>20&3,_[b++]=x>>>22&3,_[b++]=x>>>24&3,_[b++]=x>>>26&3,_[b++]=x>>>28&3,_[b++]=x>>>30&3,_[b++]=C>>>0&3,_[b++]=C>>>2&3,_[b++]=C>>>4&3,_[b++]=C>>>6&3,_[b++]=C>>>8&3,_[b++]=C>>>10&3,_[b++]=C>>>12&3,_[b++]=C>>>14&3,_[b++]=C>>>16&3,_[b++]=C>>>18&3,_[b++]=C>>>20&3,_[b++]=C>>>22&3,_[b++]=C>>>24&3,_[b++]=C>>>26&3,_[b++]=C>>>28&3,_[b]=C>>>30&3})(e,r,_,v);return;case 3:(function(e,r,_,v){let b=v,x=e[r]>>>0,C=e[r+1]>>>0,T=e[r+2]>>>0;_[b++]=x>>>0&7,_[b++]=x>>>3&7,_[b++]=x>>>6&7,_[b++]=x>>>9&7,_[b++]=x>>>12&7,_[b++]=x>>>15&7,_[b++]=x>>>18&7,_[b++]=x>>>21&7,_[b++]=x>>>24&7,_[b++]=x>>>27&7,_[b++]=7&(x>>>30|(1&C)<<2),_[b++]=C>>>1&7,_[b++]=C>>>4&7,_[b++]=C>>>7&7,_[b++]=C>>>10&7,_[b++]=C>>>13&7,_[b++]=C>>>16&7,_[b++]=C>>>19&7,_[b++]=C>>>22&7,_[b++]=C>>>25&7,_[b++]=C>>>28&7,_[b++]=7&(C>>>31|(3&T)<<1),_[b++]=T>>>2&7,_[b++]=T>>>5&7,_[b++]=T>>>8&7,_[b++]=T>>>11&7,_[b++]=T>>>14&7,_[b++]=T>>>17&7,_[b++]=T>>>20&7,_[b++]=T>>>23&7,_[b++]=T>>>26&7,_[b]=T>>>29&7})(e,r,_,v);return;case 4:(function(e,r,_,v){let b=v,x=e[r]>>>0,C=e[r+1]>>>0,T=e[r+2]>>>0,E=e[r+3]>>>0;_[b++]=x>>>0&15,_[b++]=x>>>4&15,_[b++]=x>>>8&15,_[b++]=x>>>12&15,_[b++]=x>>>16&15,_[b++]=x>>>20&15,_[b++]=x>>>24&15,_[b++]=x>>>28&15,_[b++]=C>>>0&15,_[b++]=C>>>4&15,_[b++]=C>>>8&15,_[b++]=C>>>12&15,_[b++]=C>>>16&15,_[b++]=C>>>20&15,_[b++]=C>>>24&15,_[b++]=C>>>28&15,_[b++]=T>>>0&15,_[b++]=T>>>4&15,_[b++]=T>>>8&15,_[b++]=T>>>12&15,_[b++]=T>>>16&15,_[b++]=T>>>20&15,_[b++]=T>>>24&15,_[b++]=T>>>28&15,_[b++]=E>>>0&15,_[b++]=E>>>4&15,_[b++]=E>>>8&15,_[b++]=E>>>12&15,_[b++]=E>>>16&15,_[b++]=E>>>20&15,_[b++]=E>>>24&15,_[b]=E>>>28&15})(e,r,_,v);return;case 5:(function(e,r,_,v){let b=v,x=e[r]>>>0,C=e[r+1]>>>0,T=e[r+2]>>>0,E=e[r+3]>>>0,D=e[r+4]>>>0;_[b++]=x>>>0&31,_[b++]=x>>>5&31,_[b++]=x>>>10&31,_[b++]=x>>>15&31,_[b++]=x>>>20&31,_[b++]=x>>>25&31,_[b++]=31&(x>>>30|(7&C)<<2),_[b++]=C>>>3&31,_[b++]=C>>>8&31,_[b++]=C>>>13&31,_[b++]=C>>>18&31,_[b++]=C>>>23&31,_[b++]=31&(C>>>28|(1&T)<<4),_[b++]=T>>>1&31,_[b++]=T>>>6&31,_[b++]=T>>>11&31,_[b++]=T>>>16&31,_[b++]=T>>>21&31,_[b++]=T>>>26&31,_[b++]=31&(T>>>31|(15&E)<<1),_[b++]=E>>>4&31,_[b++]=E>>>9&31,_[b++]=E>>>14&31,_[b++]=E>>>19&31,_[b++]=E>>>24&31,_[b++]=31&(E>>>29|(3&D)<<3),_[b++]=D>>>2&31,_[b++]=D>>>7&31,_[b++]=D>>>12&31,_[b++]=D>>>17&31,_[b++]=D>>>22&31,_[b]=D>>>27&31})(e,r,_,v);return;case 6:(function(e,r,_,v){let b=v,x=e[r]>>>0,C=e[r+1]>>>0,T=e[r+2]>>>0,E=e[r+3]>>>0,D=e[r+4]>>>0,O=e[r+5]>>>0;_[b++]=x>>>0&63,_[b++]=x>>>6&63,_[b++]=x>>>12&63,_[b++]=x>>>18&63,_[b++]=x>>>24&63,_[b++]=63&(x>>>30|(15&C)<<2),_[b++]=C>>>4&63,_[b++]=C>>>10&63,_[b++]=C>>>16&63,_[b++]=C>>>22&63,_[b++]=63&(C>>>28|(3&T)<<4),_[b++]=T>>>2&63,_[b++]=T>>>8&63,_[b++]=T>>>14&63,_[b++]=T>>>20&63,_[b++]=T>>>26&63,_[b++]=E>>>0&63,_[b++]=E>>>6&63,_[b++]=E>>>12&63,_[b++]=E>>>18&63,_[b++]=E>>>24&63,_[b++]=63&(E>>>30|(15&D)<<2),_[b++]=D>>>4&63,_[b++]=D>>>10&63,_[b++]=D>>>16&63,_[b++]=D>>>22&63,_[b++]=63&(D>>>28|(3&O)<<4),_[b++]=O>>>2&63,_[b++]=O>>>8&63,_[b++]=O>>>14&63,_[b++]=O>>>20&63,_[b]=O>>>26&63})(e,r,_,v);return;case 7:(function(e,r,_,v){let b=v,x=e[r]>>>0,C=e[r+1]>>>0,T=e[r+2]>>>0,E=e[r+3]>>>0,D=e[r+4]>>>0,O=e[r+5]>>>0,k=e[r+6]>>>0;_[b++]=x>>>0&127,_[b++]=x>>>7&127,_[b++]=x>>>14&127,_[b++]=x>>>21&127,_[b++]=127&(x>>>28|(7&C)<<4),_[b++]=C>>>3&127,_[b++]=C>>>10&127,_[b++]=C>>>17&127,_[b++]=C>>>24&127,_[b++]=127&(C>>>31|(63&T)<<1),_[b++]=T>>>6&127,_[b++]=T>>>13&127,_[b++]=T>>>20&127,_[b++]=127&(T>>>27|(3&E)<<5),_[b++]=E>>>2&127,_[b++]=E>>>9&127,_[b++]=E>>>16&127,_[b++]=E>>>23&127,_[b++]=127&(E>>>30|(31&D)<<2),_[b++]=D>>>5&127,_[b++]=D>>>12&127,_[b++]=D>>>19&127,_[b++]=127&(D>>>26|(1&O)<<6),_[b++]=O>>>1&127,_[b++]=O>>>8&127,_[b++]=O>>>15&127,_[b++]=O>>>22&127,_[b++]=127&(O>>>29|(15&k)<<3),_[b++]=k>>>4&127,_[b++]=k>>>11&127,_[b++]=k>>>18&127,_[b]=k>>>25&127})(e,r,_,v);return;case 8:(function(e,r,_,v){let b=v,x=e[r]>>>0,C=e[r+1]>>>0,T=e[r+2]>>>0,E=e[r+3]>>>0,D=e[r+4]>>>0,O=e[r+5]>>>0,k=e[r+6]>>>0,A=e[r+7]>>>0;_[b++]=x>>>0&255,_[b++]=x>>>8&255,_[b++]=x>>>16&255,_[b++]=x>>>24&255,_[b++]=C>>>0&255,_[b++]=C>>>8&255,_[b++]=C>>>16&255,_[b++]=C>>>24&255,_[b++]=T>>>0&255,_[b++]=T>>>8&255,_[b++]=T>>>16&255,_[b++]=T>>>24&255,_[b++]=E>>>0&255,_[b++]=E>>>8&255,_[b++]=E>>>16&255,_[b++]=E>>>24&255,_[b++]=D>>>0&255,_[b++]=D>>>8&255,_[b++]=D>>>16&255,_[b++]=D>>>24&255,_[b++]=O>>>0&255,_[b++]=O>>>8&255,_[b++]=O>>>16&255,_[b++]=O>>>24&255,_[b++]=k>>>0&255,_[b++]=k>>>8&255,_[b++]=k>>>16&255,_[b++]=k>>>24&255,_[b++]=A>>>0&255,_[b++]=A>>>8&255,_[b++]=A>>>16&255,_[b]=A>>>24&255})(e,r,_,v);return;case 9:(function(e,r,_,v){let b=v,x=e[r]>>>0,C=e[r+1]>>>0,T=e[r+2]>>>0,E=e[r+3]>>>0,D=e[r+4]>>>0,O=e[r+5]>>>0,k=e[r+6]>>>0,A=e[r+7]>>>0,j=e[r+8]>>>0;_[b++]=x>>>0&511,_[b++]=x>>>9&511,_[b++]=x>>>18&511,_[b++]=511&(x>>>27|(15&C)<<5),_[b++]=C>>>4&511,_[b++]=C>>>13&511,_[b++]=C>>>22&511,_[b++]=511&(C>>>31|(255&T)<<1),_[b++]=T>>>8&511,_[b++]=T>>>17&511,_[b++]=511&(T>>>26|(7&E)<<6),_[b++]=E>>>3&511,_[b++]=E>>>12&511,_[b++]=E>>>21&511,_[b++]=511&(E>>>30|(127&D)<<2),_[b++]=D>>>7&511,_[b++]=D>>>16&511,_[b++]=511&(D>>>25|(3&O)<<7),_[b++]=O>>>2&511,_[b++]=O>>>11&511,_[b++]=O>>>20&511,_[b++]=511&(O>>>29|(63&k)<<3),_[b++]=k>>>6&511,_[b++]=k>>>15&511,_[b++]=511&(k>>>24|(1&A)<<8),_[b++]=A>>>1&511,_[b++]=A>>>10&511,_[b++]=A>>>19&511,_[b++]=511&(A>>>28|(31&j)<<4),_[b++]=j>>>5&511,_[b++]=j>>>14&511,_[b]=j>>>23&511})(e,r,_,v);return;case 10:(function(e,r,_,v){let b=v,x=e[r]>>>0,C=e[r+1]>>>0,T=e[r+2]>>>0,E=e[r+3]>>>0,D=e[r+4]>>>0,O=e[r+5]>>>0,k=e[r+6]>>>0,A=e[r+7]>>>0,j=e[r+8]>>>0,F=e[r+9]>>>0;_[b++]=x>>>0&1023,_[b++]=x>>>10&1023,_[b++]=x>>>20&1023,_[b++]=1023&(x>>>30|(255&C)<<2),_[b++]=C>>>8&1023,_[b++]=C>>>18&1023,_[b++]=1023&(C>>>28|(63&T)<<4),_[b++]=T>>>6&1023,_[b++]=T>>>16&1023,_[b++]=1023&(T>>>26|(15&E)<<6),_[b++]=E>>>4&1023,_[b++]=E>>>14&1023,_[b++]=1023&(E>>>24|(3&D)<<8),_[b++]=D>>>2&1023,_[b++]=D>>>12&1023,_[b++]=D>>>22&1023,_[b++]=O>>>0&1023,_[b++]=O>>>10&1023,_[b++]=O>>>20&1023,_[b++]=1023&(O>>>30|(255&k)<<2),_[b++]=k>>>8&1023,_[b++]=k>>>18&1023,_[b++]=1023&(k>>>28|(63&A)<<4),_[b++]=A>>>6&1023,_[b++]=A>>>16&1023,_[b++]=1023&(A>>>26|(15&j)<<6),_[b++]=j>>>4&1023,_[b++]=j>>>14&1023,_[b++]=1023&(j>>>24|(3&F)<<8),_[b++]=F>>>2&1023,_[b++]=F>>>12&1023,_[b]=F>>>22&1023})(e,r,_,v);return;case 11:(function(e,r,_,v){let b=v,x=e[r]>>>0,C=e[r+1]>>>0,T=e[r+2]>>>0,E=e[r+3]>>>0,D=e[r+4]>>>0,O=e[r+5]>>>0,k=e[r+6]>>>0,A=e[r+7]>>>0,j=e[r+8]>>>0,F=e[r+9]>>>0,R=e[r+10]>>>0;_[b++]=x>>>0&2047,_[b++]=x>>>11&2047,_[b++]=2047&(x>>>22|(1&C)<<10),_[b++]=C>>>1&2047,_[b++]=C>>>12&2047,_[b++]=2047&(C>>>23|(3&T)<<9),_[b++]=T>>>2&2047,_[b++]=T>>>13&2047,_[b++]=2047&(T>>>24|(7&E)<<8),_[b++]=E>>>3&2047,_[b++]=E>>>14&2047,_[b++]=2047&(E>>>25|(15&D)<<7),_[b++]=D>>>4&2047,_[b++]=D>>>15&2047,_[b++]=2047&(D>>>26|(31&O)<<6),_[b++]=O>>>5&2047,_[b++]=O>>>16&2047,_[b++]=2047&(O>>>27|(63&k)<<5),_[b++]=k>>>6&2047,_[b++]=k>>>17&2047,_[b++]=2047&(k>>>28|(127&A)<<4),_[b++]=A>>>7&2047,_[b++]=A>>>18&2047,_[b++]=2047&(A>>>29|(255&j)<<3),_[b++]=j>>>8&2047,_[b++]=j>>>19&2047,_[b++]=2047&(j>>>30|(511&F)<<2),_[b++]=F>>>9&2047,_[b++]=F>>>20&2047,_[b++]=2047&(F>>>31|(1023&R)<<1),_[b++]=R>>>10&2047,_[b]=R>>>21&2047})(e,r,_,v);return;case 12:(function(e,r,_,v){let b=v,x=e[r]>>>0,C=e[r+1]>>>0,T=e[r+2]>>>0,E=e[r+3]>>>0,D=e[r+4]>>>0,O=e[r+5]>>>0,k=e[r+6]>>>0,A=e[r+7]>>>0,j=e[r+8]>>>0,F=e[r+9]>>>0,R=e[r+10]>>>0,z=e[r+11]>>>0;_[b++]=x>>>0&4095,_[b++]=x>>>12&4095,_[b++]=4095&(x>>>24|(15&C)<<8),_[b++]=C>>>4&4095,_[b++]=C>>>16&4095,_[b++]=4095&(C>>>28|(255&T)<<4),_[b++]=T>>>8&4095,_[b++]=T>>>20&4095,_[b++]=E>>>0&4095,_[b++]=E>>>12&4095,_[b++]=4095&(E>>>24|(15&D)<<8),_[b++]=D>>>4&4095,_[b++]=D>>>16&4095,_[b++]=4095&(D>>>28|(255&O)<<4),_[b++]=O>>>8&4095,_[b++]=O>>>20&4095,_[b++]=k>>>0&4095,_[b++]=k>>>12&4095,_[b++]=4095&(k>>>24|(15&A)<<8),_[b++]=A>>>4&4095,_[b++]=A>>>16&4095,_[b++]=4095&(A>>>28|(255&j)<<4),_[b++]=j>>>8&4095,_[b++]=j>>>20&4095,_[b++]=F>>>0&4095,_[b++]=F>>>12&4095,_[b++]=4095&(F>>>24|(15&R)<<8),_[b++]=R>>>4&4095,_[b++]=R>>>16&4095,_[b++]=4095&(R>>>28|(255&z)<<4),_[b++]=z>>>8&4095,_[b]=z>>>20&4095})(e,r,_,v);return;case 16:(function(e,r,_,v){let b=v,x=e[r]>>>0,C=e[r+1]>>>0,T=e[r+2]>>>0,E=e[r+3]>>>0,D=e[r+4]>>>0,O=e[r+5]>>>0,k=e[r+6]>>>0,A=e[r+7]>>>0,j=e[r+8]>>>0,F=e[r+9]>>>0,R=e[r+10]>>>0,z=e[r+11]>>>0,B=e[r+12]>>>0,H=e[r+13]>>>0,K=e[r+14]>>>0,q=e[r+15]>>>0;_[b++]=x>>>0&65535,_[b++]=x>>>16&65535,_[b++]=C>>>0&65535,_[b++]=C>>>16&65535,_[b++]=T>>>0&65535,_[b++]=T>>>16&65535,_[b++]=E>>>0&65535,_[b++]=E>>>16&65535,_[b++]=D>>>0&65535,_[b++]=D>>>16&65535,_[b++]=O>>>0&65535,_[b++]=O>>>16&65535,_[b++]=k>>>0&65535,_[b++]=k>>>16&65535,_[b++]=A>>>0&65535,_[b++]=A>>>16&65535,_[b++]=j>>>0&65535,_[b++]=j>>>16&65535,_[b++]=F>>>0&65535,_[b++]=F>>>16&65535,_[b++]=R>>>0&65535,_[b++]=R>>>16&65535,_[b++]=z>>>0&65535,_[b++]=z>>>16&65535,_[b++]=B>>>0&65535,_[b++]=B>>>16&65535,_[b++]=H>>>0&65535,_[b++]=H>>>16&65535,_[b++]=K>>>0&65535,_[b++]=K>>>16&65535,_[b++]=q>>>0&65535,_[b]=q>>>16&65535})(e,r,_,v);return;case 32:for(let b=0;b<32;b=b+1|0)_[v+b|0]=0|e[r+b|0];return}let x=Oh[b]>>>0,C=r,T=0,E=e[C]>>>0;for(let r=0;r<32;r++)if(T+b<=32)_[v+r]=E>>>T&x,T+=b,T===32&&(T=0,C++,r!==31&&(E=e[C]>>>0));else{let D=32-T,O=E>>>T;C++,E=e[C]>>>0,_[v+r]=(O|(E&Oh[b-D]>>>0)<=64)throw Error(`Varint too long`)}return r.set(b),_}function Wh(e,r){let _,v;return v=e[r.get()],r.increment(),_=127&v,v<128?_:(v=e[r.get()],r.increment(),_|=(127&v)<<7,v<128?_:(v=e[r.get()],r.increment(),_|=(127&v)<<14,v<128?_:(v=e[r.get()],r.increment(),_|=(127&v)<<21,v<128?_:(v=e[r.get()],_|=(15&v)<<28,function(e,r,_){let v,b;if(b=r[_.get()],_.increment(),v=(112&b)>>4,b<128||(b=r[_.get()],_.increment(),v|=(127&b)<<3,b<128)||(b=r[_.get()],_.increment(),v|=(127&b)<<10,b<128)||(b=r[_.get()],_.increment(),v|=(127&b)<<17,b<128)||(b=r[_.get()],_.increment(),v|=(127&b)<<24,b<128)||(b=r[_.get()],_.increment(),v|=(1&b)<<31,b<128))return 4294967296*v+(e>>>0);throw Error(`Expected varint not more than 10 bytes`)}(_,e,r)))))}function Gh(e){return e>>>1^-(1&e)}function Kh(e){return e>>1n^-(1n&e)}function qh(e){return e%2==1?(e+1)/-2:e/2}function Yh(e,r,_){if(_===void 0){_=0;for(let v=0;v=4)for(;v<_-4;v+=4){let _=e[v+1],b=e[v+2],x=e[v+3];r[v]=Gh(e[v])+r[v-1],r[v+1]=Gh(_)+r[v],r[v+2]=Gh(b)+r[v+1],r[v+3]=Gh(x)+r[v+2]}for(;v!==e.length;++v)r[v]=Gh(e[v])+r[v-1];return r}function eg(e){let r=new BigInt64Array(e.length);r[0]=Kh(e[0]);let _=e.length/4*4,v=1;if(_>=4)for(;v<_-4;v+=4){let _=e[v+1],b=e[v+2],x=e[v+3];r[v]=Kh(e[v])+r[v-1],r[v+1]=Kh(_)+r[v],r[v+2]=Kh(b)+r[v+1],r[v+3]=Kh(x)+r[v+2]}for(;v!==r.length;++v)r[v]=Kh(e[v])+r[v-1];return r}function tg(e){let r=e.length/4*4,_=1;if(r>=4)for(let v=e[0];_>4],b=null;switch(v){case ng.DATA:b={dictionaryType:Object.values(rg)[15&_]};break;case ng.OFFSET:b={offsetType:Object.values(ig)[15&_]};break;case ng.LENGTH:b={lengthType:Object.values(ag)[15&_]}}r.increment();let x=e[r.get()],C=Object.values(wh)[x>>5],T=Object.values(wh)[x>>2&7],E=Object.values(Th)[3&x];r.increment();let D=Bh(e,r,2),O=D[0];return{physicalStreamType:v,logicalStreamType:b,logicalLevelTechnique1:C,logicalLevelTechnique2:T,physicalLevelTechnique:E,numValues:O,byteLength:D[1],decompressedCount:O}}(e,r);return _.logicalLevelTechnique1===wh.MORTON?function(e,r,_){let v=Bh(r,_,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:e.decompressedCount,numBits:v[0],coordinateShift:v[1]}}(_,e,r):wh.RLE!==_.logicalLevelTechnique1&&wh.RLE!==_.logicalLevelTechnique2||Th.NONE===_.physicalLevelTechnique?_:function(e,r,_){let v=Bh(r,_,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:v[1],runs:v[0],numRleValues:v[1]}}(_,e,r)}(function(e){e.PRESENT=`PRESENT`,e.DATA=`DATA`,e.OFFSET=`OFFSET`,e.LENGTH=`LENGTH`})(ng||={}),function(e){e.NONE=`NONE`,e.SINGLE=`SINGLE`,e.SHARED=`SHARED`,e.VERTEX=`VERTEX`,e.MORTON=`MORTON`,e.FSST=`FSST`}(rg||={}),function(e){e.VERTEX=`VERTEX`,e.INDEX=`INDEX`,e.STRING=`STRING`,e.KEY=`KEY`}(ig||={}),function(e){e.VAR_BINARY=`VAR_BINARY`,e.GEOMETRIES=`GEOMETRIES`,e.PARTS=`PARTS`,e.RINGS=`RINGS`,e.TRIANGLES=`TRIANGLES`,e.SYMBOL=`SYMBOL`,e.DICTIONARY=`DICTIONARY`}(ag||={}),function(e){e[e.FLAT=0]=`FLAT`,e[e.CONST=1]=`CONST`,e[e.SEQUENCE=2]=`SEQUENCE`,e[e.DICTIONARY=3]=`DICTIONARY`,e[e.FSST_DICTIONARY=4]=`FSST_DICTIONARY`}(og||={});class Xf{constructor(e,r){this.values=e,this._size=r}get(e){let r=Math.floor(e/8);return(this.values[r]>>e%8&1)==1}set(e,r){let _=Math.floor(e/8);this.values[_]=this.values[_]|(r?1:0)<>e%8&1}size(){return this._size}getBuffer(){return this.values}}function dg(e,r,_){if(!r)return e;let v=r.size(),b=new e.constructor(v),x=0;for(let C=0;C=4)for(;v<_-4;v+=4){let _=e[v+1],b=e[v+2],x=e[v+3];r[v]=Gh(e[v])+r[v-2],r[v+1]=Gh(_)+r[v-1],r[v+2]=Gh(b)+r[v],r[v+3]=Gh(x)+r[v+1]}for(;v!==e.length;v+=2)r[v]=Gh(e[v])+r[v-2],r[v+1]=Gh(e[v+1])+r[v-1];return r}(e);break;case wh.NONE:b=function(e){let r=new Int32Array(e.length);for(let _=0;_>>0;for(let _=1;_>>0;return r}(r.logicalLevelTechnique2===wh.RLE?Yh(e,r.runs,r.numRleValues):e);break;case wh.RLE:b=Yh(e,r.runs,r.numRleValues);break;case wh.MORTON:tg(e),b=e;break;case wh.COMPONENTWISE_DELTA:b=function(e){if(e.length<2)return new Uint32Array(e);let r=new Uint32Array(e.length);r[0]=Gh(e[0])>>>0,r[1]=Gh(e[1])>>>0;for(let _=2;_>>0,r[_+1]=r[_-1]+Gh(e[_+1])>>>0;return r}(e);break;case wh.NONE:b=e;break;default:throw Error(`The specified Logical level technique is not supported: ${r.logicalLevelTechnique1}`)}return v?dg(b,v,0):b}(hg(e,r,_),_,0,b)}function mg(e,r,_){return function(e,r){if(r.logicalLevelTechnique1===wh.DELTA&&r.logicalLevelTechnique2===wh.NONE)return function(e){let r=new Int32Array(e.length+1);r[0]=0,r[1]=Gh(e[0]);let _=r[1];for(let v=2;v!==r.length;++v)_+=Gh(e[v-1]),r[v]=r[v-1]+_;return new Uint32Array(r)}(e);if(r.logicalLevelTechnique1===wh.RLE&&r.logicalLevelTechnique2===wh.NONE)return function(e,r,_){let v=new Uint32Array(_+1);v[0]=0;let b=1,x=v[0];for(let _=0;_>>2,T=function(e,r){if(r<=e.encodedWords.length)return e.encodedWords;let _=new Uint32Array(Math.max(16,2*r));return e.encodedWords=_,_}(b,C);(function(e,r,_,v){if(r<0||_<0||r+_>e.length)throw RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${r}, byteLength=${_}, bytes.length=${e.length})`);let b=Math.floor(_/4),x=_%4!=0,C=x?b+1:b;if(v.length0){let _=e.byteOffset+r;if(3&_)for(let _=0;_0){let r=0|e[v];if(v=v+1|0,255&r)throw Error(`FastPFOR decode: invalid alignedLength=${r} (expected multiple of 256)`);if(b+r>x.length)throw Error(`FastPFOR decode: output buffer too small (outPos=${b}, alignedLength=${r}, out.length=${x.length})`);v=function(e,r,_,v,b,x){let C=v+Ah(b,256),T=v,E=_;for(;T!==C;){let _=Math.min(Mh,C-T);E=Rh(e,r,E,T,_,x),T=T+_|0}return E}(e,x,v,b,r,C),b=b+r|0}return function(e,r,_,v,b,x){if(x===0)return r;let C=0,T=r,E=r+_,D=b,O=b,k=b+x,A=0,j=0;for(;T>>C&255;if(C+=8,T+=C>>>5,C&=31,A|=(127&r)<28)throw Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${j}, partial=${A}, decoded=${O-D}/${x}, inPos=${T}, inEnd=${E})`)}if(O!==k)throw Error(`FastPFOR VByte: truncated stream (decoded=${O-D}, expected=${x}, consumedWords=${T-r}/${_}, vbyteStart=${r}, vbyteEnd=${E})`)}(e,v,e.length-v|0,x,b,r-b|0),x}(T.subarray(0,C),r,b.decoderWorkspace);return v.add(_),E}(e,r,_,v,function(e=16){if(e<0)throw RangeError(`initialEncodedWordCapacity must be >= 0, got ${e}`);let r=Math.max(16,0|e);return{encodedWords:new Uint32Array(r),decoderWorkspace:Ph()}}(_>>>2))}(e,_.numValues,_.byteLength,r);case Th.VARINT:return Bh(e,r,_.numValues);case Th.NONE:{let v=r.get();r.add(_.byteLength);let b=e.subarray(v,r.get());return new Uint32Array(b)}default:throw Error(`Specified physicalLevelTechnique ${v} is not supported (yet).`)}}function gg(e,r,_){let v=hg(e,r,_);return v.length===1?v[0]:function(e){return e[1]}(v)}function _g(e,r,_){return function(e){if(e.length===2){let r=Gh(e[1]);return[r,r]}return[Gh(e[2]),Gh(e[3])]}(hg(e,r,_))}function vg(e,r,_){return function(e){if(e.length===2){let r=Kh(e[1]);return[r,r]}return[Kh(e[2]),Kh(e[3])]}(Hh(e,r,_.numValues))}function yg(e,r,_,v){return function(e,r,_){let v;switch(r.logicalLevelTechnique1){case wh.DELTA:v=function(e){let r=new BigUint64Array(e.length);r[0]=BigInt.asUintN(64,Kh(e[0]));for(let _=1;_>1,r)-_}}function Cg(e,r){let _=0;for(let v=0;v>v;return _}function wg(e,r,_,b,x,C,T){return e===lg.MORTON?function(e,r,_,b,x,C){let T=Array(x?b+1:b);for(let x=0;x[e]),_+=e,b+=e}break;case sg.LINESTRING:{let v,O;z?(v=j[b]-j[b-1],b++):v=A[_]-A[_-1],_++,R?(O=Tg(B,T,v,!1),T+=2*v):(O=wg(e.vertexBufferType,B,F,E,v,!1,D),E+=v),r[C++]=[O],k&&x++}break;case sg.POLYGON:{let v=A[_]-A[_-1];_++;let O=Array(v-1),z,H=j[b]-j[b-1];if(b++,R){z=Tg(B,T,H,!0),T+=2*H;for(let e=0;e0&&r.push(r[0]),k.push(r)}e[r]=k,x&&D++}break;case sg.MULTIPOLYGON:{let O=x[D]-x[D-1];D++;let k=[];for(let e=0;e0&&r.push(r[0]),k.push(r)}}e[r]=k}}return e}[Symbol.iterator](){return null}}function Eg(e,r,_,v,b,x){return new yd(e,r,_,v,b,x)}class yd extends fd{constructor(e,r,_,v,b,x){super(_,v,b,x),this._numGeometries=e,this._geometryType=r}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function Dg(e,r,_,v,b){return new gd(e,r,_,v,b)}class gd extends fd{constructor(e,r,_,v,b){super(r,_,v,b),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function Og(e,r,_,v,b){let x=ug(e,_),C,T,E,D;if(xg(x,v,e,_)===og.CONST){let b=gg(e,_,x),O,k,A,j;for(let v=0;v_?r[x++]:1);return v}function Ag(e,r,_,v){let b=new Uint32Array(r[r.length-1]+1),x=0;b[0]=x;let C=1,T=0;for(let E=0;E=C);){let _=e[v.increment()];if(_<=127){let C=_+3,T=e[v.increment()],E=Math.min(x+C,r);b.fill(T,x,E),x=E}else{let C=256-_;for(let _=0;_=12?Mg.decode(e.subarray(r,_)):function(e,r,_){let v=``,b=r;for(;b<_;){let r=e[b],x,C,T,E=null,D=r>239?4:r>223?3:r>191?2:1;if(b+D>_)break;D===1?r<128&&(E=r):D===2?(x=e[b+1],(192&x)==128&&(E=(31&r)<<6|63&x,E<=127&&(E=null))):D===3?(x=e[b+1],C=e[b+2],(192&x)==128&&(192&C)==128&&(E=(15&r)<<12|(63&x)<<6|63&C,(E<=2047||E>=55296&&E<=57343)&&(E=null))):D===4&&(x=e[b+1],C=e[b+2],T=e[b+3],(192&x)==128&&(192&C)==128&&(192&T)==128&&(E=(15&r)<<18|(63&x)<<12|(63&C)<<6|63&T,(E<=65535||E>=1114112)&&(E=null))),E===null?(E=65533,D=1):E>65535&&(E-=65536,v+=String.fromCharCode(E>>>10&1023|55296),E=56320|1023&E),v+=String.fromCharCode(E),b+=D}return v}(e,r,_)}class Id extends Qp{constructor(e,r,_,v){super(e,_,v),this.offsetBuffer=r}}class Ed extends Id{constructor(e,r,_,v){super(e,r,_,v??r.length-1)}getValueFromBuffer(e){return Ng(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class Td extends Id{constructor(e,r,_,v,b){super(e,_,v,b??r.length),this.indexBuffer=r,this.indexBuffer=r}getValueFromBuffer(e){let r=this.indexBuffer[e];return Ng(this.dataBuffer,this.offsetBuffer[r],this.offsetBuffer[r+1])}}class Fd extends Id{constructor(e,r,_,v,b,x,C){super(e,_,v,C),this.indexBuffer=r,this.symbolOffsetBuffer=b,this.symbolTableBuffer=x}getValueFromBuffer(e){this.decodedDictionary??=(this.symbolLengthBuffer??=this.offsetToLengthBuffer(this.symbolOffsetBuffer),function(e,r,_){let v=[],b=Array(r.length).fill(0);for(let e=1;e=10}function Rg(e){return e===30}function zg(e){if(e.type===`scalarType`){let r=e.scalarType;if(r.type===`physicalType`)switch(r.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}if(r.type===`logicalType`)return!1}else if(e.type===`complexType`){let r=e.complexType;if(r.type===`physicalType`)switch(r.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn(`Unexpected column type in hasStreamCount`,e),!1}function Bg(e){return e.type===`complexType`&&e.complexType?.type===`physicalType`&&e.complexType.physicalType===0}let Vg=new TextDecoder;function Hg(e,r){let _=Bh(e,r,1)[0];if(_===0)return``;let v=r.get(),b=e.subarray(v,v+_);return r.add(_),Vg.decode(b)}function Ug(e,r){let _=Bh(e,r,1)[0]>>>0;if(_<10||_>30)throw Error(`Unsupported field type code ${_}. Supported: 10-29(scalars), 30(STRUCT)`);let v=Ig(_);if(Lg(_)&&(v.name=Hg(e,r)),Rg(_)){let _=Bh(e,r,1)[0]>>>0;v.complexType.children=Array(_);for(let b=0;b<_;b++)v.complexType.children[b]=Ug(e,r)}return function(e){return{name:e.name,nullable:e.nullable,scalarField:e.scalarType,complexField:e.complexType,type:e.type===`scalarType`?`scalarField`:`complexField`}}(v)}function Wg(e,r){let _=Bh(e,r,1)[0]>>>0,v=Ig(_);if(!v)throw Error(`Unsupported column type code ${_}. Supported: 0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT)`);if(Lg(_)?v.name=Hg(e,r):_>=0&&_<=3?v.name=`id`:_===4&&(v.name=`geometry`),Rg(_)){let _=Bh(e,r,1)[0]>>>0,b=v.complexType;b.children=Array(_);for(let v=0;v<_;v++)b.children[v]=Ug(e,r)}return v}function Gg(e,r){let _={featureTables:[]},v={};v.name=Hg(e,r);let b=Bh(e,r,1)[0]>>>0,x=Bh(e,r,1)[0]>>>0;v.columns=Array(x);for(let _=0;_=4)for(;_>>0,C=v.get()+r;if(C>e.length)throw Error(`Block overruns tile: ${C} > ${e.length}`);if(Bh(e,v,1)[0]>>>0!=1){v.set(C);continue}let[T,E]=Gg(e,v),D=T.featureTables[0],O=null,k=null,A=[],j=0;for(let r of D.columns){let b=r.name;if((x=r).type===`scalarType`&&x.scalarType?.type===`logicalType`&&x.scalarType.logicalType===0){let x=null;if(r.nullable){let r=ug(e,v),_=v.get(),b=jg(e,r.numValues,r.byteLength,v);v.set(_+r.byteLength),x=new Xf(b,r.numValues)}let C=ug(e,v);j=x?x.size():C.decompressedCount,O=Kg(e,r,v,b,C,x??j,_)}else if(Bg(r)){let r=Bh(e,v,1)[0];if(j===0){let r=v.get();j=ug(e,v).decompressedCount,v.set(r)}k=Og(e,r,v,j)}else{let _=zg(r)?Bh(e,v,1)[0]:1;if(_===0)continue;let b=Pg(e,v,r,_,j);if(b)if(Array.isArray(b))for(let e of b)A.push(e);else A.push(b)}}let F=new af(D.name,k,O,A,E);b.push(F),v.set(C)}var x;return b}(new Uint8Array(e)).reduce((e,r)=>Object.assign(Object.assign({},e),{[r.name]:new Gd(r)}),{})}}class Yd{constructor(e,r){this.feature=e,this.type=e.type,this.properties=e.tags?e.tags:{},this.extent=r,`id`in e&&(typeof e.id==`string`?this.id=parseInt(e.id,10):typeof e.id!=`number`||isNaN(e.id)||(this.id=e.id))}loadGeometry(){let e=[],r=this.feature.type===1?[this.feature.geometry]:this.feature.geometry;for(let _ of r){let r=[];for(let e of _)r.push(new v(e[0],e[1]));e.push(r)}return e}}let qg=`_geojsonTileLayer`;function Jg(e,r,_=``){r.writeVarintField(15,e.version||1),r.writeStringField(1,e.name||``),r.writeVarintField(5,e.extent||4096);let v={jsonPrefix:_,keys:[],values:[],keycache:{},valuecache:{}};for(let _=0;_>31}function $g(e,r){let _=e.loadGeometry(),v=e.type,b=0,x=0;for(let C of _){let _=1;v===1&&(_=C.length),r.writeVarint(Zg(1,_));let T=v===3?C.length-1:C.length;for(let e=0;e=0&&v[3]>=0&&T.insert(C,v[0],v[1],v[2],v[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=this.encoding===`mlt`?new Xd(this.rawTileData).layers:new Ru(new Vh(this.rawTileData)).layers,this.sourceLayerCoder=new Kp(this.vtLayers?Object.keys(this.vtLayers).sort():[qg])),this.vtLayers}query(e,r,_,b){this.loadVTLayers();let x=e.params,C=ce/e.tileSize/e.scale,T=ec(x.filter,x.globalState),E=e.queryGeometry,D=e.queryPadding*C,O=Wp.fromPoints(E),k=this.grid.query(O.minX-D,O.minY-D,O.maxX+D,O.maxY+D),A=Wp.fromPoints(e.cameraQueryGeometry).expandBy(D),j=this.grid3D.query(A.minX,A.minY,A.maxX,A.maxY,(r,_,b,x)=>function(e,r,_,b,x){for(let v of e)if(r<=v.x&&_<=v.y&&b>=v.x&&x>=v.y)return!0;let C=[new v(r,_),new v(r,x),new v(b,x),new v(b,_)];if(e.length>2){for(let r of C)if(vu(e,r))return!0}for(let r=0;r(A||=ru(r),_.queryIntersectsFeature({queryGeometry:E,feature:r,featureState:v,geometry:A,zoom:this.z,transform:e.transform,pixelsToTileUnits:C,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation})))}return F}loadMatchingFeature(e,r,_,v,b,x,C,T,E,D,O){let k=this.bucketLayerIDs[r];if(x&&!k.some(e=>x.has(e)))return;let A=this.sourceLayerCoder.decode(_),j=this.vtLayers[A].feature(v);if(b.needGeometry){let e=iu(j,!0);if(!b.filter(new Bs(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!b.filter(new Bs(this.tileID.overscaledZ),j))return;let F=this.getId(j,A);for(let r=0;r{let C=r instanceof qs?r.get(x):null;return C&&C.evaluate?C.evaluate(_,v,b):C})}function n_(e,r){return r-e}function r_(e,r,_,b,x){let C=[];for(let T=0;T=b&&O.x>=b||(T.x>=b?T=new v(b,T.y+(b-T.x)/(O.x-T.x)*(O.y-T.y))._round():O.x>=b&&(O=new v(b,T.y+(b-T.x)/(O.x-T.x)*(O.y-T.y))._round()),T.y>=x&&O.y>=x||(T.y>=x?T=new v(T.x+(x-T.y)/(O.y-T.y)*(O.x-T.x),x)._round():O.y>=x&&(O=new v(T.x+(x-T.y)/(O.y-T.y)*(O.x-T.x),x)._round()),D&&T.equals(D[D.length-1])||(D=[T],C.push(D)),D.push(O)))))}}return C}function i_(e,r,_,v,b){switch(r){case 1:return function(e,r,_,v){let b=[];for(let x of e)for(let e of x){let x=v===0?e.x:e.y;x>=r&&x<=_&&b.push([e])}return b}(e,_,v,b);case 2:return o_(e,_,v,b,!1);case 3:return o_(e,_,v,b,!0)}return[]}function a_(e,r,_,b,x){let C=b===0?s_:c_,T=[],E=[];for(let v=0;vr&&T.push(C(D,O,r)):k>_?A<_&&T.push(C(D,O,_)):T.push(D),A=r&&(T.push(C(D,O,r)),j=!0),A>_&&k<=_&&(T.push(C(D,O,_)),j=!0),!x&&j&&(E.push(T),T=[])}let D=e.length-1,O=b===0?e[D].x:e[D].y;return O>=r&&O<=_&&T.push(e[D]),x&&T.length>0&&!T[0].equals(T[T.length-1])&&T.push(new v(T[0].x,T[0].y)),T.length>0&&E.push(T),E}function o_(e,r,_,v,b){let x=[];for(let C of e){let e=a_(C,r,_,v,b);e.length>0&&x.push(...e)}return x}function s_(e,r,_){return new v(_,e.y+(_-e.x)/(r.x-e.x)*(r.y-e.y))}function c_(e,r,_){return new v(e.x+(_-e.y)/(r.y-e.y)*(r.x-e.x),_)}$c(`FeatureIndex`,ny,{omit:[`rawTileData`,`sourceLayerCoder`]});class hy extends v{constructor(e,r,_,v){super(e,r),this.angle=_,v!==void 0&&(this.segment=v)}clone(){return new hy(this.x,this.y,this.angle,this.segment)}}function l_(e,r,_,v,b){if(r.segment===void 0||_===0)return!0;let x=r,C=r.segment+1,T=0;for(;T>-_/2;){if(C--,C<0)return!1;T-=e[C].dist(x),x=e[C]}T+=e[C].dist(e[C+1]),C++;let E=[],D=0;for(;T<_/2;){let r=e[C],_=e[C+1];if(!_)return!1;let x=e[C-1].angleTo(r)-r.angleTo(_);for(x=Math.abs((x+3*Math.PI)%(2*Math.PI)-Math.PI),E.push({distance:T,angleDelta:x}),D+=x;T-E[0].distance>v;)D-=E.shift().angleDelta;if(D>b)return!1;C++,T+=r.dist(_)}return!0}function u_(e){let r=0;for(let _=0;_D){let O=(D-E)/x,k=new hy(vi.number(v.x,b.x,O),vi.number(v.y,b.y,O),b.angleTo(v),_);return k._round(),!C||l_(e,k,T,C,r)?k:void 0}E+=x}}function m_(e,r,_,v,b,x,C,T,E){let D=d_(v,x,C),O=f_(v,b),k=O*C,A=e[0].x===0||e[0].x===E||e[0].y===0||e[0].y===E;return r-k=0&&B=0&&H=0&&A+D<=O){let _=new hy(B,H,R,r);_._round(),v&&!l_(e,_,x,v,b)||j.push(_)}}k+=F}return T||j.length||C||(j=h_(e,k/2,_,v,b,x,C,!0,E)),j}function g_(e,r,_,b){let x=[],C=e.image,T=C.pixelRatio,E=C.paddedRect.w-2,D=C.paddedRect.h-2,O={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom},k=C.stretchX||[[0,E]],A=C.stretchY||[[0,D]],j=(e,r)=>e+r[1]-r[0],F=k.reduce(j,0),R=A.reduce(j,0),z=E-F,B=D-R,H=0,K=F,q=0,Y=R,X=0,ne=z,Z=0,ie=B;if(C.content&&b){let r=C.content,_=r[2]-r[0],v=r[3]-r[1];(C.textFitWidth||C.textFitHeight)&&(O=qm(e)),H=__(k,0,r[0]),q=__(A,0,r[1]),K=__(k,r[0],r[2]),Y=__(A,r[1],r[3]),X=r[0]-H,Z=r[1]-q,ne=_-K,ie=v-Y}let ae=O.x1,oe=O.y1,se=O.x2-ae,ce=O.y2-oe,le=(e,b,x,E)=>{let D=y_(e.stretch-H,K,se,ae),O=b_(e.fixed-X,ne,e.stretch,F),k=y_(b.stretch-q,Y,ce,oe),A=b_(b.fixed-Z,ie,b.stretch,R),j=y_(x.stretch-H,K,se,ae),z=b_(x.fixed-X,ne,x.stretch,F),B=y_(E.stretch-q,Y,ce,oe),le=b_(E.fixed-Z,ie,E.stretch,R),de=new v(D,k),fe=new v(j,k),pe=new v(j,B),me=new v(D,B),ge=new v(O/T,A/T),_e=new v(z/T,le/T),ve=r*Math.PI/180;if(ve){let e=Math.sin(ve),r=Math.cos(ve),_=[r,-e,e,r];de._matMult(_),fe._matMult(_),me._matMult(_),pe._matMult(_)}let ye=e.stretch+e.fixed,be=b.stretch+b.fixed;return{tl:de,tr:fe,bl:me,br:pe,tex:{x:C.paddedRect.x+1+ye,y:C.paddedRect.y+1+be,w:x.stretch+x.fixed-ye,h:E.stretch+E.fixed-be},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:ge,pixelOffsetBR:_e,minFontScaleX:ne/T/se,minFontScaleY:ie/T/ce,isSDF:_}};if(b&&(C.stretchX||C.stretchY)){let e=v_(k,z,F),r=v_(A,B,R);for(let _=0;_0&&(v=Math.max(10,v),this.circleDiameter=v)}else{let D=(k=C.image)?.content&&(C.image.textFitWidth||C.image.textFitHeight)?qm(C):{x1:C.left,y1:C.top,x2:C.right,y2:C.bottom};D.y1=D.y1*T-E[0],D.y2=D.y2*T+E[2],D.x1=D.x1*T-E[3],D.x2=D.x2*T+E[1];let A=C.collisionPadding;if(A&&(D.x1-=A[0]*T,D.y1-=A[1]*T,D.x2+=A[2]*T,D.y2+=A[3]*T),O){let e=new v(D.x1,D.y1),r=new v(D.x2,D.y1),_=new v(D.x1,D.y2),b=new v(D.x2,D.y2),x=O*Math.PI/180;e._rotate(x),r._rotate(x),_._rotate(x),b._rotate(x),D.x1=Math.min(e.x,r.x,_.x,b.x),D.x2=Math.max(e.x,r.x,_.x,b.x),D.y1=Math.min(e.y,r.y,_.y,b.y),D.y2=Math.max(e.y,r.y,_.y,b.y)}e.emplaceBack(r.x,r.y,D.x1,D.y1,D.x2,D.y2,_,b,x)}this.boxEndIndex=e.length}}class My{constructor(e=[],r=(e,r)=>er?1:0){if(this.data=e,this.length=this.data.length,this.compare=r,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:r,compare:_}=this,v=r[e];for(;e>0;){let b=e-1>>1,x=r[b];if(_(v,x)>=0)break;r[e]=x,e=b}r[e]=v}_down(e){let{data:r,compare:_}=this,v=this.length>>1,b=r[e];for(;e=0)break;r[e]=r[v],e=v}r[e]=b}}function x_(e,r=1,_=!1){let b=Wp.fromPoints(e[0]),x=Math.min(b.width(),b.height()),C=x/2,T=new My([],S_),{minX:E,minY:D,maxX:O,maxY:k}=b;if(x===0)return new v(E,D);for(let r=E;rA.d||!A.d)&&(A=v,_&&console.log(`found best %d after %d probes`,Math.round(1e4*v.d)/1e4,j)),v.max-A.d<=r||(C=v.h/2,T.push(new C_(v.p.x-C,v.p.y-C,C,e)),T.push(new C_(v.p.x+C,v.p.y-C,C,e)),T.push(new C_(v.p.x-C,v.p.y+C,C,e)),T.push(new C_(v.p.x+C,v.p.y+C,C,e)),j+=4)}return _&&(console.log(`num probes: ${j}`),console.log(`best distance: ${A.d}`)),A.p}function S_(e,r){return r.max-e.max}function C_(r,_,b,x){(this||e).p=new v(r,_),(this||e).h=b,(this||e).d=function(e,r){let _=!1,v=1/0;for(let b=0;be.y!=T.y>e.y&&e.x<(T.x-b.x)*(e.y-b.y)/(T.y-b.y)+b.x&&(_=!_),v=Math.min(v,hu(e,b,T))}}return(_?1:-1)*Math.sqrt(v)}((this||e).p,x),(this||e).max=(this||e).d+(this||e).h*Math.SQRT2}var w_;r.aM=void 0,(w_=r.aM||={})[w_.center=1]=`center`,w_[w_.left=2]=`left`,w_[w_.right=3]=`right`,w_[w_.top=4]=`top`,w_[w_.bottom=5]=`bottom`,w_[w_[`top-left`]=6]=`top-left`,w_[w_[`top-right`]=7]=`top-right`,w_[w_[`bottom-left`]=8]=`bottom-left`,w_[w_[`bottom-right`]=9]=`bottom-right`;let T_=1/0;function E_(e,r){return r[1]===T_?function(e,r){let _=0,v=0;r<0&&(r=0);let b=r/Math.SQRT2;switch(e){case`top-right`:case`top-left`:v=b-7;break;case`bottom-right`:case`bottom-left`:v=7-b;break;case`bottom`:v=7-r;break;case`top`:v=r-7}switch(e){case`top-right`:case`bottom-right`:_=-b;break;case`top-left`:case`bottom-left`:_=b;break;case`left`:_=r;break;case`right`:_=-r}return[_,v]}(e,r[0]):function(e,r,_){let v=0,b=0;switch(r=Math.abs(r),_=Math.abs(_),e){case`top-right`:case`top-left`:case`top`:b=_-7;break;case`bottom-right`:case`bottom-left`:case`bottom`:b=7-_}switch(e){case`top-right`:case`bottom-right`:case`right`:v=-r;break;case`top-left`:case`bottom-left`:case`left`:v=r}return[v,b]}(e,r[0],r[1])}function D_(e,r,_){var v;let b=e.layout,x=(v=b.get(`text-variable-anchor-offset`))?.evaluate(r,{},_);if(x){let e=x.values,r=[];for(let _=0;_e*um);v.startsWith(`top`)?b[1]-=7:v.startsWith(`bottom`)&&(b[1]+=7),r[_+1]=b}return new Oe(r)}let C=b.get(`text-variable-anchor`);if(C){let v;v=e._unevaluatedLayout.getValue(`text-radial-offset`)===void 0?b.get(`text-offset`).evaluate(r,{},_).map(e=>e*um):[b.get(`text-radial-offset`).evaluate(r,{},_)*um,T_];let x=[];for(let e of C)x.push(e,E_(e,v));return new Oe(x)}return null}function O_(e){switch(e){case`right`:case`top-right`:case`bottom-right`:return`right`;case`left`:case`top-left`:case`bottom-left`:return`left`}return`center`}function k_(e,_,v,b,x,C,T,E,D,O,k,A){let j=C.textMaxSize.evaluate(_,{});j===void 0&&(j=T);let F=e.layers[0].layout,R=F.get(`icon-offset`).evaluate(_,{},k),z=j_(v.horizontal),B=T/24,H=e.tilePixelRatio*B,K=e.tilePixelRatio*j/24,q=e.tilePixelRatio*E,Y=e.tilePixelRatio*F.get(`symbol-spacing`),X=F.get(`text-padding`)*e.tilePixelRatio,ne=function(e,r,_,v=1){let b=e.get(`icon-padding`).evaluate(r,{},_),x=b&&b.values;return[x[0]*v,x[1]*v,x[2]*v,x[3]*v]}(F,_,k,e.tilePixelRatio),Z=F.get(`text-max-angle`)/180*Math.PI,ie=F.get(`text-rotation-alignment`)!==`viewport`&&F.get(`symbol-placement`)!==`point`,ae=F.get(`icon-rotation-alignment`)===`map`&&F.get(`symbol-placement`)!==`point`,oe=F.get(`symbol-placement`),se=Y/2,le=F.get(`icon-text-fit`),de;b&&le!==`none`&&(e.allowVerticalPlacement&&v.vertical&&(de=Jm(b,v.vertical,le,F.get(`icon-text-fit-padding`),R,B)),z&&(b=Jm(b,z,le,F.get(`icon-text-fit-padding`),R,B)));let fe=k?A.line.getGranularityForZoomLevel(k.z):1,pe=(E,A)=>{A.x<0||A.x>=ce||A.y<0||A.y>=ce||function(e,_,v,b,x,C,T,E,D,O,k,A,j,F,R,z,B,H,K,q,Y,X,ne,Z,ie){let ae=e.addToLineVertexArray(_,v),oe,se,ce,le,de=0,fe=0,pe=0,me=0,ge=-1,_e=-1,ve={},ye=ql(``);if(e.allowVerticalPlacement&&b.vertical){let e=E.layout.get(`text-rotate`).evaluate(Y,{},Z)+90;ce=new Ay(D,_,O,k,A,b.vertical,j,F,R,e),T&&(le=new Ay(D,_,O,k,A,T,B,H,R,e))}if(x){let v=E.layout.get(`icon-rotate`).evaluate(Y,{}),b=E.layout.get(`icon-text-fit`)!==`none`,C=g_(x,v,ne,b),j=T?g_(T,v,ne,b):void 0;se=new Ay(D,_,O,k,A,x,B,H,!1,v),de=4*C.length;let F=e.iconSizeData,R=null;F.kind===`source`?(R=[128*E.layout.get(`icon-size`).evaluate(Y,{})],R[0]>Xm&&je(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):F.kind===`composite`&&(R=[128*X.compositeIconSizes[0].evaluate(Y,{},Z),128*X.compositeIconSizes[1].evaluate(Y,{},Z)],(R[0]>Xm||R[1]>Xm)&&je(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,C,R,q,K,Y,r.aw.none,_,ae.lineStartIndex,ae.lineLength,-1,Z),ge=e.icon.placedSymbolArray.length-1,j&&(fe=4*j.length,e.addSymbols(e.icon,j,R,q,K,Y,r.aw.vertical,_,ae.lineStartIndex,ae.lineLength,-1,Z),_e=e.icon.placedSymbolArray.length-1)}let be=Object.keys(b.horizontal);for(let v of be){let x=b.horizontal[v];oe||=(ye=ql(x.text),new Ay(D,_,O,k,A,x,j,F,R,E.layout.get(`text-rotate`).evaluate(Y,{},Z)));let T=x.positionedLines.length===1;if(pe+=A_(e,_,x,C,E,R,Y,z,ae,b.vertical?r.aw.horizontal:r.aw.horizontalOnly,T?be:[v],ve,ge,X,Z),T)break}b.vertical&&(me+=A_(e,_,b.vertical,C,E,R,Y,z,ae,r.aw.vertical,[`vertical`],ve,_e,X,Z));let xe=oe?oe.boxStartIndex:e.collisionBoxArray.length,Se=oe?oe.boxEndIndex:e.collisionBoxArray.length,we=ce?ce.boxStartIndex:e.collisionBoxArray.length,ke=ce?ce.boxEndIndex:e.collisionBoxArray.length,Me=se?se.boxStartIndex:e.collisionBoxArray.length,Ne=se?se.boxEndIndex:e.collisionBoxArray.length,Ie=le?le.boxStartIndex:e.collisionBoxArray.length,Ue=le?le.boxEndIndex:e.collisionBoxArray.length,We=-1,qe=(e,r)=>e&&e.circleDiameter?Math.max(e.circleDiameter,r):r;We=qe(oe,We),We=qe(ce,We),We=qe(se,We),We=qe(le,We);let Xe=We>-1?1:0;Xe&&(We*=ie/um),e.glyphOffsetArray.length>=_p.MAX_GLYPHS&&je(`Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907`),Y.sortKey!==void 0&&e.addToSortKeyRanges(e.symbolInstances.length,Y.sortKey);let Ze=D_(E,Y,Z),[et,tt]=function(e,_){let v=e.length,b=_?.values;if(b?.length>0)for(let _=0;_=0?ve.right:-1,ve.center>=0?ve.center:-1,ve.left>=0?ve.left:-1,ve.vertical||-1,ge,_e,ye,xe,Se,we,ke,Me,Ne,Ie,Ue,O,pe,me,de,fe,Xe,0,j,We,et,tt)}(e,A,E,v,b,x,de,e.layers[0],e.collisionBoxArray,_.index,_.sourceLayerIndex,e.index,H,[X,X,X,X],ie,D,q,ne,ae,R,_,C,O,k,T)};if(oe===`line`)for(let r of r_(_.geometry,0,0,ce,ce)){let _=Zd(r,fe),x=m_(_,Y,Z,v.vertical||z,b,24,K,e.overscaling,ce);for(let r of x)z&&M_(e,z.text,se,r)||pe(_,r)}else if(oe===`line-center`){for(let e of _.geometry)if(e.length>1){let r=Zd(e,fe),_=p_(r,Z,v.vertical||z,b,24,K);_&&pe(r,_)}}else if(_.type===`Polygon`)for(let e of pa(_.geometry,0)){let r=x_(e,16);pe(Zd(e[0],fe,!0),new hy(r.x,r.y,0))}else if(_.type===`LineString`)for(let e of _.geometry){let r=Zd(e,fe);pe(r,new hy(r[0].x,r[0].y,0))}else if(_.type===`Point`)for(let e of _.geometry)for(let r of e)pe([r],new hy(r.x,r.y,0))}function A_(e,r,_,b,x,C,T,E,D,O,k,A,j,F,R){let z=function(e,r,_,b,x,C,T,E){let D=b.layout.get(`text-rotate`).evaluate(C,{})*Math.PI/180,O=[];for(let e of r.positionedLines)for(let b of e.positionedGlyphs){if(!b.rect)continue;let C=b.rect||{},k=4,A=!0,j=1,F=0,R=(x||E)&&b.vertical,z=b.metrics.advance*b.scale/2;if(E&&r.verticalizable&&(F=e.lineOffset/2-(b.imageName?-(um-b.metrics.width*b.scale)/2:(b.scale-1)*um)),b.imageName){let e=T[b.imageName];A=e.sdf,j=e.pixelRatio,k=1/j}let B=x?[b.x+z,b.y]:[0,0],H=x?[0,0]:[b.x+z+_[0],b.y+_[1]-F],K=[0,0];R&&(K=H,H=[0,0]);let q=b.metrics.isDoubleResolution?2:1,Y=(b.metrics.left-k)*b.scale-z+H[0],X=(-b.metrics.top-k)*b.scale+H[1],ne=Y+C.w/q*b.scale/j,Z=X+C.h/q*b.scale/j,ie=new v(Y,X),ae=new v(ne,X),oe=new v(Y,Z),se=new v(ne,Z);if(R){let e=new v(-z,z- -17),r=-Math.PI/2,_=12-z,x=new v(22-_,-(b.imageName?_:0)),C=new v(...K);ie._rotateAround(r,e)._add(x)._add(C),ae._rotateAround(r,e)._add(x)._add(C),oe._rotateAround(r,e)._add(x)._add(C),se._rotateAround(r,e)._add(x)._add(C)}if(D){let e=Math.sin(D),r=Math.cos(D),_=[r,-e,e,r];ie._matMult(_),ae._matMult(_),oe._matMult(_),se._matMult(_)}let ce=new v(0,0),le=new v(0,0);O.push({tl:ie,tr:ae,bl:oe,br:se,tex:C,writingMode:r.writingMode,glyphOffset:B,sectionIndex:b.sectionIndex,isSDF:A,pixelOffsetTL:ce,pixelOffsetBR:le,minFontScaleX:0,minFontScaleY:0})}return O}(0,_,E,x,C,T,b,e.allowVerticalPlacement),B=e.textSizeData,H=null;B.kind===`source`?(H=[128*x.layout.get(`text-size`).evaluate(T,{})],H[0]>Xm&&je(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):B.kind===`composite`&&(H=[128*F.compositeTextSizes[0].evaluate(T,{},R),128*F.compositeTextSizes[1].evaluate(T,{},R)],(H[0]>Xm||H[1]>Xm)&&je(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,z,H,E,C,T,O,r,D.lineStartIndex,D.lineLength,j,R);for(let r of k)A[r]=e.text.placedSymbolArray.length-1;return 4*z.length}function j_(e){for(let r in e)return e[r];return null}function M_(e,r,_,v){let b=e.compareText;if(r in b){let e=b[r];for(let r=e.length-1;r>=0;r--)if(v.dist(e[r])<_)return!0}else b[r]=[];return b[r].push(v),!1}r.$=O,r.A=j,r.B=Zc,r.C=Kc,r.D=Gs,r.E=vt,r.F=function([e,r,_]){return r+=90,r*=Math.PI/180,_*=Math.PI/180,{x:e*Math.cos(r)*Math.sin(_),y:e*Math.sin(r)*Math.sin(_),z:e*Math.cos(_)}},r.G=vi,r.H=Bs,r.I=Jh,r.J=Jc,r.K=function(e){if(Ie==null){let r=e.navigator?e.navigator.userAgent:null;Ie=!!e.safari||!(!r||!(/\b(iPad|iPhone|iPod)\b/.test(r)||r.match(`Safari`)&&!r.match(`Chrome`)))}return Ie},r.L=class{constructor(e,r){this.target=e,this.mapId=r,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Dp(()=>this.process()),this.subscription=et(this.target,`message`,e=>this.receive(e),!1),this.globalScope=Ne(self)?e:window}registerMessageHandler(e,r){this.messageHandlers[e]=r}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,r){return new Promise((_,v)=>{let b=Math.round(0xde0b6b3a7640000*Math.random()).toString(36).substring(0,10),x=r?et(r.signal,`abort`,()=>{x?.unsubscribe(),delete this.resolveRejects[b];let r={id:b,type:``,origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(r)},lh):null;this.resolveRejects[b]={resolve:e=>{x?.unsubscribe(),_(e)},reject:e=>{x?.unsubscribe(),v(e)}};let C=[],T=Object.assign(Object.assign({},e),{id:b,sourceMapId:this.mapId,origin:location.origin,data:rl(e.data,C)});this.target.postMessage(T,{transfer:C})})}receive(e){let r=e.data,_=r.id,v=[`file://`,`resource://android`,`null`],b=[r.origin,location.origin],x=r.origin===location.origin,C=b.some(e=>v.includes(e));if((x||C)&&(!r.targetMapId||this.mapId===r.targetMapId)){if(r.type===``){delete this.tasks[_];let e=this.abortControllers[_];delete this.abortControllers[_],e&&e.abort();return}if(Ne(self)||r.mustQueue)return this.tasks[_]=r,this.taskQueue.push(_),void this.invoker.trigger();this.processTask(_,r)}}process(){if(this.taskQueue.length===0)return;let e=this.taskQueue.shift(),r=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),r&&this.processTask(e,r)}processTask(e,r){return _(this,void 0,void 0,function*(){if(r.type===``){let _=this.resolveRejects[e];if(delete this.resolveRejects[e],!_)return;r.error?_.reject(il(r.error)):_.resolve(il(r.data));return}if(!this.messageHandlers[r.type])return void this.completeTask(e,/* @__PURE__ */ Error(`Could not find a registered handler for ${r.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(`, `)}`));let _=il(r.data),v=new AbortController;this.abortControllers[e]=v;try{let b=yield this.messageHandlers[r.type](r.sourceMapId,_,v);this.completeTask(e,null,b)}catch(r){this.completeTask(e,r)}})}completeTask(e,r,_){let v=[];delete this.abortControllers[e];let b={id:e,type:``,sourceMapId:this.mapId,origin:location.origin,error:r?rl(r):null,data:rl(_,v)};this.target.postMessage(b,{transfer:v})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},r.M=yt,r.N=function(){var e=new j(16);return j!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},r.O=function(e,r,_){var v,b,x,C,T,E,D,O,k,A,j,F,R=_[0],z=_[1],B=_[2];return r===e?(e[12]=r[0]*R+r[4]*z+r[8]*B+r[12],e[13]=r[1]*R+r[5]*z+r[9]*B+r[13],e[14]=r[2]*R+r[6]*z+r[10]*B+r[14],e[15]=r[3]*R+r[7]*z+r[11]*B+r[15]):(b=r[1],x=r[2],C=r[3],T=r[4],E=r[5],D=r[6],O=r[7],k=r[8],A=r[9],j=r[10],F=r[11],e[0]=v=r[0],e[1]=b,e[2]=x,e[3]=C,e[4]=T,e[5]=E,e[6]=D,e[7]=O,e[8]=k,e[9]=A,e[10]=j,e[11]=F,e[12]=v*R+T*z+k*B+r[12],e[13]=b*R+E*z+A*B+r[13],e[14]=x*R+D*z+j*B+r[14],e[15]=C*R+O*z+F*B+r[15]),e},r.P=v,r.Q=function(e,r,_){var v=_[0],b=_[1],x=_[2];return e[0]=r[0]*v,e[1]=r[1]*v,e[2]=r[2]*v,e[3]=r[3]*v,e[4]=r[4]*b,e[5]=r[5]*b,e[6]=r[6]*b,e[7]=r[7]*b,e[8]=r[8]*x,e[9]=r[9]*x,e[10]=r[10]*x,e[11]=r[11]*x,e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],e},r.R=kl,r.S=function(e,r,_){var v=r[0],b=r[1],x=r[2],C=r[3],T=r[4],E=r[5],D=r[6],O=r[7],k=r[8],A=r[9],j=r[10],F=r[11],R=r[12],z=r[13],B=r[14],H=r[15],K=_[0],q=_[1],Y=_[2],X=_[3];return e[0]=K*v+q*T+Y*k+X*R,e[1]=K*b+q*E+Y*A+X*z,e[2]=K*x+q*D+Y*j+X*B,e[3]=K*C+q*O+Y*F+X*H,e[4]=(K=_[4])*v+(q=_[5])*T+(Y=_[6])*k+(X=_[7])*R,e[5]=K*b+q*E+Y*A+X*z,e[6]=K*x+q*D+Y*j+X*B,e[7]=K*C+q*O+Y*F+X*H,e[8]=(K=_[8])*v+(q=_[9])*T+(Y=_[10])*k+(X=_[11])*R,e[9]=K*b+q*E+Y*A+X*z,e[10]=K*x+q*D+Y*j+X*B,e[11]=K*C+q*O+Y*F+X*H,e[12]=(K=_[12])*v+(q=_[13])*T+(Y=_[14])*k+(X=_[15])*R,e[13]=K*b+q*E+Y*A+X*z,e[14]=K*x+q*D+Y*j+X*B,e[15]=K*C+q*O+Y*F+X*H,e},r.T=Ll,r.U=function(e,r){let _={};for(let v=0;ve.type===`symbol`,r.aR=tc,r.aS=Al,r.aT=gu,r.aU=Go,r.aV=la,r.aW=ia,r.aX=it,r.aY=xh,r.aZ=q,r.a_=K,r.aa=e=>{let r=window.document.createElement(`video`);return r.muted=!0,new Promise(_=>{r.onloadstart=()=>{_(r)};for(let _ of e){let e=window.document.createElement(`source`);kt(_)||(r.crossOrigin=`Anonymous`),e.src=_,r.appendChild(e)}})},r.ab=Dt,r.ac=function(){return be++},r.ad=Bo,r.ae=_p,r.af=qg,r.ag=ec,r.ah=iu,r.ai=Jp,r.aj=function(e){let r={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,_,v,b)=>{let x=v||b;return r[_]=!x||x.toLowerCase(),``}),r[`max-age`]){let e=parseInt(r[`max-age`],10);isNaN(e)?delete r[`max-age`]:r[`max-age`]=e}return r},r.ak=_e,r.al=85.051129,r.am=tt,r.an=function(e){return 2**e},r.ao=R,r.ap=_h,r.aq=function(e){return Math.log(e)/Math.LN2},r.ar=function(e){var r=e[0],_=e[1];return r*r+_*_},r.as=function(e){if(!e.length)return/* @__PURE__ */ new Set;let r=Math.max(...e.map(e=>e.canonical.z)),_=1/0,v=-1/0,b=1/0,x=-1/0,C=[];for(let T of e){let{x:e,y:E,z:D}=T.canonical,O=2**(r-D),k=e*O,A=E*O;C.push({id:T,x:k,y:A}),k<_&&(_=k),k>v&&(v=k),Ax&&(x=A)}let T=/* @__PURE__ */ new Set;for(let e of C)e.x!==_&&e.x!==v&&e.y!==b&&e.y!==x||T.add(e.id);return T},r.at=function(e,r){let _=Math.abs(2*e.wrap)-+(e.wrap<0),v=Math.abs(2*r.wrap)-+(r.wrap<0);return e.overscaledZ-r.overscaledZ||v-_||r.canonical.y-e.canonical.y||r.canonical.x-e.canonical.x},r.au=class{constructor(e,r){this.max=e,this.onRemove=r,this.reset()}reset(){for(let e in this.data)for(let r of this.data[e])r.timeout&&clearTimeout(r.timeout),this.onRemove(r.value);return this.data={},this.order=[],this}add(e,r,_){let v=e.wrapped().key;this.data[v]===void 0&&(this.data[v]=[]);let b={value:r,timeout:void 0};if(_!==void 0&&(b.timeout=setTimeout(()=>{this.remove(e,b)},_)),this.data[v].push(b),this.order.push(v),this.order.length>this.max){let e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){let r=this.data[e].shift();return r.timeout&&clearTimeout(r.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),r.value}getByKey(e){let r=this.data[e];return r?r[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,r){if(!this.has(e))return this;let _=e.wrapped().key,v=r===void 0?0:this.data[_].indexOf(r),b=this.data[_][v];return this.data[_].splice(v,1),b.timeout&&clearTimeout(b.timeout),this.data[_].length===0&&delete this.data[_],this.onRemove(b.value),this.order.splice(this.order.indexOf(_),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){let e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){let r=[];for(let _ in this.data)for(let v of this.data[_])e(v.value)||r.push(v);for(let e of r)this.remove(e.value.tileID,e)}},r.av=function(e,r){let _=0,v=0;if(e.kind===`constant`)v=e.layoutSize;else if(e.kind!==`source`){let{interpolationType:b,minZoom:x,maxZoom:C}=e,T=b?_e(yn.interpolationFactor(b,r,x,C),0,1):0;e.kind===`camera`?v=vi.number(e.minSize,e.maxSize,T):_=T}return{uSizeT:_,uSize:v}},r.ax=function(e,{uSize:r,uSizeT:_},{lowerSize:v,upperSize:b}){return e.kind===`source`?v/128:e.kind===`composite`?vi.number(v/128,b/128,_):r},r.ay=function(e,r){var _=r[0],v=r[1],b=r[2],x=r[3],C=r[4],T=r[5],E=r[6],D=r[7],O=r[8],k=r[9],A=r[10],j=r[11],F=r[12],R=r[13],z=r[14],B=r[15],H=_*T-v*C,K=_*E-b*C,q=_*D-x*C,Y=v*E-b*T,X=v*D-x*T,ne=b*D-x*E,Z=O*R-k*F,ie=O*z-A*F,ae=O*B-j*F,oe=k*z-A*R,se=k*B-j*R,ce=A*B-j*z,le=H*ce-K*se+q*oe+Y*ae-X*ie+ne*Z;return le?(e[0]=(T*ce-E*se+D*oe)*(le=1/le),e[1]=(b*se-v*ce-x*oe)*le,e[2]=(R*ne-z*X+B*Y)*le,e[3]=(A*X-k*ne-j*Y)*le,e[4]=(E*ae-C*ce-D*ie)*le,e[5]=(_*ce-b*ae+x*ie)*le,e[6]=(z*q-F*ne-B*K)*le,e[7]=(O*ne-A*q+j*K)*le,e[8]=(C*se-T*ae+D*Z)*le,e[9]=(v*ae-_*se-x*Z)*le,e[10]=(F*X-R*q+B*H)*le,e[11]=(k*q-O*X-j*H)*le,e[12]=(T*ie-C*oe-E*Z)*le,e[13]=(_*oe-v*ie+b*Z)*le,e[14]=(R*K-F*Y-z*H)*le,e[15]=(O*Y-k*K+A*H)*le,e):null},r.az=oe,r.b=Ue,r.b$=class extends Aa{constructor(e,r){super(e,r),this.current=Zl}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let r=1;r<16;r++)if(e[r]!==this.current[r]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},r.b0=function(e,r,_){return e[0]=r[0]-_[0],e[1]=r[1]-_[1],e[2]=r[2]-_[2],e},r.b1=function(e,r){var _=r[0],v=r[1],b=r[2],x=_*_+v*v+b*b;return x>0&&(x=1/Math.sqrt(x)),e[0]=r[0]*x,e[1]=r[1]*x,e[2]=r[2]*x,e},r.b2=Y,r.b3=function(e,r){return e[0]*r[0]+e[1]*r[1]+e[2]*r[2]},r.b4=function(e,r,_){return e[0]=r[0]*_[0],e[1]=r[1]*_[1],e[2]=r[2]*_[2],e[3]=r[3]*_[3],e},r.b5=B,r.b6=function(e,r,_){let v=r[0]*_[0]+r[1]*_[1]+r[2]*_[2];return v===0?null:(-(e[0]*_[0]+e[1]*_[1]+e[2]*_[2])-_[3])/v},r.b7=ne,r.b8=function(e,r,_){return e[0]=r[0]*_,e[1]=r[1]*_,e[2]=r[2]*_,e[3]=r[3]*_,e},r.b9=function(e,r){return e[0]*r[0]+e[1]*r[1]+e[2]*r[2]+e[3]},r.bA=function(e,r,_){var v=_[0],b=_[1],x=_[2],C=_[3],T=r[0],E=r[1],D=r[2],O=b*D-x*E,k=x*T-v*D,A=v*E-b*T;return e[0]=T+C*(O+=O)+b*(A+=A)-x*(k+=k),e[1]=E+C*k+x*O-v*A,e[2]=D+C*A+v*k-b*O,e},r.bB=function(e,r,_){let v=(b=[e[0],e[1],e[2],r[0],r[1],r[2],_[0],_[1],_[2]])[0]*((O=b[8])*(C=b[4])-(T=b[5])*(D=b[7]))+b[1]*(-O*(x=b[3])+T*(E=b[6]))+b[2]*(D*x-C*E);var b,x,C,T,E,D,O;if(v===0)return null;let k=Y([],[r[0],r[1],r[2]],[_[0],_[1],_[2]]),A=Y([],[_[0],_[1],_[2]],[e[0],e[1],e[2]]),j=Y([],[e[0],e[1],e[2]],[r[0],r[1],r[2]]),F=q([],k,-e[3]);return K(F,F,q([],A,-r[3])),K(F,F,q([],j,-_[3])),q(F,F,1/v),F},r.bC=dh,r.bD=function(){return new Float64Array(4)},r.bE=function(e,r,_,v){var b=[],x=[];return b[0]=r[0]-_[0],b[1]=r[1]-_[1],b[2]=r[2]-_[2],x[0]=b[0]*Math.cos(v)-b[1]*Math.sin(v),x[1]=b[0]*Math.sin(v)+b[1]*Math.cos(v),x[2]=b[2],e[0]=x[0]+_[0],e[1]=x[1]+_[1],e[2]=x[2]+_[2],e},r.bF=function(e,r,_,v){var b=[],x=[];return b[0]=r[0]-_[0],b[1]=r[1]-_[1],b[2]=r[2]-_[2],x[0]=b[0],x[1]=b[1]*Math.cos(v)-b[2]*Math.sin(v),x[2]=b[1]*Math.sin(v)+b[2]*Math.cos(v),e[0]=x[0]+_[0],e[1]=x[1]+_[1],e[2]=x[2]+_[2],e},r.bG=function(e,r,_,v){var b=[],x=[];return b[0]=r[0]-_[0],b[1]=r[1]-_[1],b[2]=r[2]-_[2],x[0]=b[2]*Math.sin(v)+b[0]*Math.cos(v),x[1]=b[1],x[2]=b[2]*Math.cos(v)-b[0]*Math.sin(v),e[0]=x[0]+_[0],e[1]=x[1]+_[1],e[2]=x[2]+_[2],e},r.bH=function(e,r,_){var v=Math.sin(_),b=Math.cos(_),x=r[0],C=r[1],T=r[2],E=r[3],D=r[8],O=r[9],k=r[10],A=r[11];return r!==e&&(e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15]),e[0]=x*b-D*v,e[1]=C*b-O*v,e[2]=T*b-k*v,e[3]=E*b-A*v,e[8]=x*v+D*b,e[9]=C*v+O*b,e[10]=T*v+k*b,e[11]=E*v+A*b,e},r.bI=function(e,r){let _=de(e,360),v=de(r,360),b=v-_,x=v>_?b-360:b+360;return Math.abs(b)0?C:-C},r.bL=function(e,r){let _=de(e,2*Math.PI),v=de(r,2*Math.PI);return Math.min(Math.abs(_-v),Math.abs(_-v+2*Math.PI),Math.abs(_-v-2*Math.PI))},r.bM=function(){let e={},r=$.$version;for(let _ in $.$root){let v=$.$root[_];if(v.required){let b=null;b=_===`version`?r:v.type===`array`?[]:{},b!=null&&(e[_]=b)}}return e},r.bN=bt,r.bO=vs,r.bP=function e(r,_){if(Array.isArray(r)){if(!Array.isArray(_)||r.length!==_.length)return!1;for(let v=0;ve.type===`raster`,r.bU=we,r.bV=function(e,r){if(!e)return[{command:`setStyle`,args:[r]}];let _=[];try{if(!zt(e.version,r.version))return[{command:`setStyle`,args:[r]}];zt(e.center,r.center)||_.push({command:`setCenter`,args:[r.center]}),zt(e.state,r.state)||_.push({command:`setGlobalState`,args:[r.state]}),zt(e.centerAltitude,r.centerAltitude)||_.push({command:`setCenterAltitude`,args:[r.centerAltitude]}),zt(e.zoom,r.zoom)||_.push({command:`setZoom`,args:[r.zoom]}),zt(e.bearing,r.bearing)||_.push({command:`setBearing`,args:[r.bearing]}),zt(e.pitch,r.pitch)||_.push({command:`setPitch`,args:[r.pitch]}),zt(e.roll,r.roll)||_.push({command:`setRoll`,args:[r.roll]}),zt(e.sprite,r.sprite)||_.push({command:`setSprite`,args:[r.sprite]}),zt(e.glyphs,r.glyphs)||_.push({command:`setGlyphs`,args:[r.glyphs]}),zt(e.transition,r.transition)||_.push({command:`setTransition`,args:[r.transition]}),zt(e.light,r.light)||_.push({command:`setLight`,args:[r.light]}),zt(e.terrain,r.terrain)||_.push({command:`setTerrain`,args:[r.terrain]}),zt(e.sky,r.sky)||_.push({command:`setSky`,args:[r.sky]}),zt(e.projection,r.projection)||_.push({command:`setProjection`,args:[r.projection]});let v={},b=[];(function(e,r,_,v){let b;for(b in r||={},e||={})Object.prototype.hasOwnProperty.call(e,b)&&(Object.prototype.hasOwnProperty.call(r,b)||Yt(b,_,v));for(b in r)Object.prototype.hasOwnProperty.call(r,b)&&(Object.prototype.hasOwnProperty.call(e,b)?zt(e[b],r[b])||(e[b].type===`geojson`&&r[b].type===`geojson`&&$t(e,r,b)?Ht(_,{command:`setGeoJSONSourceData`,args:[b,r[b].data]}):Zt(b,r,_,v)):qt(b,r,_))})(e.sources,r.sources,b,v);let x=[];e.layers&&e.layers.forEach(e=>{`source`in e&&v[e.source]?_.push({command:`removeLayer`,args:[e.id]}):x.push(e)}),_=_.concat(b),function(e,r,_){r||=[];let v=(e||=[]).map(ln),b=r.map(ln),x=e.reduce(dn,{}),C=r.reduce(dn,{}),T=v.slice(),E=Object.create(null),D,O,k,A,j;for(let e=0,r=0;eA?(b=Math.acos(x),C=Math.sin(b),T=Math.sin((1-v)*b)/C,E=Math.sin(v*b)/C):(T=1-v,E=v),e[0]=T*D+E*F,e[1]=T*O+E*R,e[2]=T*k+E*z,e[3]=T*j+E*B,e},r.bl=function(e){let r=new Float64Array(9);var _,v,b,x,C,T,E,D,O,k=(b=(v=e)[0])*(E=b+b),A=(x=v[1])*E,j,F=(C=v[2])*E,R=C*(D=x+x),z,B=(T=v[3])*E,H=T*D,K=T*(O=C+C);(_=r)[0]=1-(j=x*D)-(z=C*O),_[3]=A-K,_[6]=F+H,_[1]=A+K,_[4]=1-k-z,_[7]=R-B,_[2]=F-H,_[5]=R+B,_[8]=1-k-j;let q=it(-Math.asin(_e(r[2],-1,1))),Y,X;return Math.hypot(r[5],r[8])<.001?(Y=0,X=-it(Math.atan2(r[3],r[4]))):(Y=it(r[5]===0&&r[8]===0?0:Math.atan2(r[5],r[8])),X=it(r[1]===0&&r[0]===0?0:Math.atan2(r[1],r[0]))),{roll:Y,pitch:q+90,bearing:X}},r.bm=function(e,r){return e.roll==r.roll&&e.pitch==r.pitch&&e.bearing==r.bearing},r.bn=Ee,r.bo=Ma,r.bp=Wd,r.bq=Kd,r.br=mu,r.bs=fe,r.bt=pe,r.bu=Re,r.bv=function(e,r,_,v,b){return fe(v,b,_e((e-r)/(_-r),0,1))},r.bw=function(e,r,_,v){return e[0]=r[0]+_[0]*v,e[1]=r[1]+_[1]*v,e[2]=r[2]+_[2]*v,e},r.bx=de,r.by=function(){return new Float64Array(3)},r.bz=ae,r.c=mt,r.c$=class{get tiles(){return this.tileIndex?.tiles??{}}get stats(){return this.tileIndex.stats}get total(){return this.tileIndex.total}constructor(e,r){let _=(r=this.options=Object.assign({},Bp,r)).debug;if(_&&console.time(`preprocess data`),r.maxZoom<0||r.maxZoom>24)throw Error(`maxZoom should be in the 0-24 range`);if(r.promoteId&&r.generateId)throw Error(`promoteId and generateId cannot be used together.`);let v=Bf(e,r);_&&(console.timeEnd(`preprocess data`),console.log(`index: maxZoom: %d, maxPoints: %d`,r.indexMaxZoom,r.indexMaxPoints),console.time(`generate tiles`)),v=fp(v,r),r.updateable&&(this.source=v),this.initializeIndex(v,r)}initializeIndex(e,r){this.tileIndex=r.cluster?new Nc(r.clusterOptions):new th(r),e.length&&this.tileIndex.initialize(e)}getTile(e,r,_){return r=+r,_=+_,(e=+e)<0||e>24?null:this.tileIndex.getTile(e,r,_)}updateData(e,r){let _=this.options;if(!_.updateable)throw Error("to update tile geojson `updateable` option must be set to true");let{affected:v,source:b}=function(e,r,_){let v=function(e){return e?{removeAll:e.removeAll,remove:new Set(e.remove||[]),add:new Map(e.add?.map(e=>[e.id,e])),update:new Map(e.update?.map(e=>[e.id,e]))}:{remove:/* @__PURE__ */ new Set,add:/* @__PURE__ */ new Map,update:/* @__PURE__ */ new Map}}(r),b=[];if(v.removeAll&&(b=e,e=[]),v.remove.size||v.add.size){let r=[];for(let _ of e)(v.remove.has(_.id)||v.add.has(_.id))&&r.push(_);if(r.length){b.push(...r);let _=new Set(r.map(e=>e.id));e=e.filter(e=>!_.has(e.id))}if(v.add.size){let r=Bf({type:`FeatureCollection`,features:Array.from(v.add.values())},_);r=fp(r,_),b.push(...r),e.push(...r)}}if(v.update.size)for(let[r,x]of v.update){let v=[],C=[];for(let _ of e)_.id===r?v.push(_):C.push(_);if(!v.length)continue;let T=hp(v,x,_);T.length&&(b.push(...v,...T),C.push(...T),e=C)}return{affected:b,source:e}}(this.source,e,_);r&&({affected:v,source:b}=this.filterUpdate(b,v,r)),v.length&&(this.source=b,this.tileIndex.updateIndex(b,v,_))}filterUpdate(e,r,_){let v=/* @__PURE__ */ new Set;for(let b of e)b.id!=null&&(_(Kf(b))||(r.push(b),v.add(b.id)));return{affected:r,source:e=e.filter(e=>!v.has(e.id))}}getData(){if(!this.options.updateable)throw Error("to retrieve data the `updateable` option must be set to true");return{type:`FeatureCollection`,features:this.source.map(e=>Kf(e))}}updateClusterOptions(e,r){let _=this.options.cluster;this.options.cluster=e,this.options.clusterOptions=r,_==e?this.tileIndex.updateIndex(this.source,[],this.options):this.initializeIndex(this.source,this.options)}getClusterExpansionZoom(e){return this.tileIndex.getClusterExpansionZoom(e)}getClusterChildren(e){return this.tileIndex.getChildren(e)}getClusterLeaves(e,r,_){return this.tileIndex.getLeaves(e,r,_)}},r.c0=ka,r.c1=class extends Aa{constructor(e,r){super(e,r),this.current=[0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]||(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},r.c2=class extends Aa{constructor(e,r){super(e,r),this.current=[0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]||(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},r.c3=F,r.c4=function(e,r){var _=Math.sin(r),v=Math.cos(r);return e[0]=v,e[1]=_,e[2]=0,e[3]=-_,e[4]=v,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},r.c5=function(e,r,_){var v=r[0],b=r[1],x=r[2];return e[0]=v*_[0]+b*_[3]+x*_[6],e[1]=v*_[1]+b*_[4]+x*_[7],e[2]=v*_[2]+b*_[5]+x*_[8],e},r.c6=function(e,r,_,v,b,x,C){var T=1/(r-_),E=1/(v-b),D=1/(x-C);return e[0]=-2*T,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*E,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*D,e[11]=0,e[12]=(r+_)*T,e[13]=(b+v)*E,e[14]=(C+x)*D,e[15]=1,e},r.c7=class extends Aa{constructor(e,r){super(e,r),this.current=[]}set(e){if(e!=this.current){this.current=e;let r=new Float32Array(4*e.length);for(let _=0;_25||v<0||v>=1||_<0||_>=1)},r.cD=function(e,r){return e[0]=r[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=r[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},r.cE=class extends uo{},r.cF=ht,r.cG=function(e,r){mt.REGISTERED_PROTOCOLS[e]=r},r.cH=function(e){delete mt.REGISTERED_PROTOCOLS[e]},r.cI=function(e,r){let _={};for(let v=0;ve*um)}let K=E?`center`:b.get(`text-justify`).evaluate(x,{},e.canonical),q=b.get(`symbol-placement`)===`point`?b.get(`text-max-width`).evaluate(x,{},e.canonical)*um:1/0,Y=()=>{e.bucket.allowVerticalPlacement&&cl(_)&&(R.vertical=Rm(z,e.glyphMap,e.glyphPositions,e.imagePositions,k,q,T,F,`left`,O,H,r.aw.vertical,!0,j,A))};if(!E&&B){let _=/* @__PURE__ */ new Set;if(K===`auto`)for(let e=0;eJg(e,r,_),e.layers[v])}(e,_,r),_.finish()},r.cS=function(e,r,_,v,b,x){let C=i_(e,r,_,b,0);return C=i_(C,r,v,x,1),C},r.cT=class{constructor(e){this.maxEntries=e,this.map=/* @__PURE__ */ new Map}get(e){let r=this.map.get(e);return r!==void 0&&(this.map.delete(e),this.map.set(e,r)),r}set(e,r){if(this.map.has(e))this.map.delete(e);else if(this.map.size>=this.maxEntries){let e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,r)}clear(){this.map.clear()}},r.cU=Ru,r.cV=Vh,r.cW=Xd,r.cX=function(r,v,b,x,C){return _(this||e,void 0,void 0,function*(){if(k())try{return yield qe(r,v,b,x,C)}catch{}return function(e,r,_,v,b){let x=e.width,C=e.height;Xe&&Ze||(Xe=new OffscreenCanvas(x,C),Ze=Xe.getContext(`2d`,{willReadFrequently:!0})),Xe.width=x,Xe.height=C,Ze.drawImage(e,0,0,x,C);let T=Ze.getImageData(r,_,v,b);return Ze.clearRect(0,0,x,C),T.data}(r,v,b,x,C)})},r.cY=Ol,r.cZ=class{constructor(e,r){this.layers={[qg]:this},this.name=qg,this.version=r?r.version:1,this.extent=r?r.extent:4096,this.length=e.length,this.features=e}feature(e){return new Yd(this.features[e],this.extent)}},r.c_=Ps,r.ca=cm,r.cb=class extends Ao{},r.cc=Ju,r.cd=function(e){return e<=1?1:2**Math.ceil(Math.log(e)/Math.LN2)},r.ce=Ku,r.cf=function(e,r,_){var v=r[0],b=r[1],x=r[2],C=_[3]*v+_[7]*b+_[11]*x+_[15];return e[0]=(_[0]*v+_[4]*b+_[8]*x+_[12])/(C||=1),e[1]=(_[1]*v+_[5]*b+_[9]*x+_[13])/C,e[2]=(_[2]*v+_[6]*b+_[10]*x+_[14])/C,e},r.cg=class extends co{},r.ch=class extends Po{},r.ci=function(e,r){return e[0]===r[0]&&e[1]===r[1]&&e[2]===r[2]&&e[3]===r[3]&&e[4]===r[4]&&e[5]===r[5]&&e[6]===r[6]&&e[7]===r[7]&&e[8]===r[8]&&e[9]===r[9]&&e[10]===r[10]&&e[11]===r[11]&&e[12]===r[12]&&e[13]===r[13]&&e[14]===r[14]&&e[15]===r[15]},r.cj=function(e,r){var _=e[0],v=e[1],b=e[2],x=e[3],C=e[4],T=e[5],E=e[6],D=e[7],O=e[8],k=e[9],j=e[10],F=e[11],R=e[12],z=e[13],B=e[14],H=e[15],K=r[0],q=r[1],Y=r[2],X=r[3],ne=r[4],Z=r[5],ie=r[6],ae=r[7],oe=r[8],se=r[9],ce=r[10],le=r[11],de=r[12],fe=r[13],pe=r[14],me=r[15];return Math.abs(_-K)<=A*Math.max(1,Math.abs(_),Math.abs(K))&&Math.abs(v-q)<=A*Math.max(1,Math.abs(v),Math.abs(q))&&Math.abs(b-Y)<=A*Math.max(1,Math.abs(b),Math.abs(Y))&&Math.abs(x-X)<=A*Math.max(1,Math.abs(x),Math.abs(X))&&Math.abs(C-ne)<=A*Math.max(1,Math.abs(C),Math.abs(ne))&&Math.abs(T-Z)<=A*Math.max(1,Math.abs(T),Math.abs(Z))&&Math.abs(E-ie)<=A*Math.max(1,Math.abs(E),Math.abs(ie))&&Math.abs(D-ae)<=A*Math.max(1,Math.abs(D),Math.abs(ae))&&Math.abs(O-oe)<=A*Math.max(1,Math.abs(O),Math.abs(oe))&&Math.abs(k-se)<=A*Math.max(1,Math.abs(k),Math.abs(se))&&Math.abs(j-ce)<=A*Math.max(1,Math.abs(j),Math.abs(ce))&&Math.abs(F-le)<=A*Math.max(1,Math.abs(F),Math.abs(le))&&Math.abs(R-de)<=A*Math.max(1,Math.abs(R),Math.abs(de))&&Math.abs(z-fe)<=A*Math.max(1,Math.abs(z),Math.abs(fe))&&Math.abs(B-pe)<=A*Math.max(1,Math.abs(B),Math.abs(pe))&&Math.abs(H-me)<=A*Math.max(1,Math.abs(H),Math.abs(me))},r.ck=function(e,r){return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],e},r.cl=e=>e.type===`circle`,r.cm=e=>e.type===`heatmap`,r.cn=e=>e.type===`line`,r.co=e=>e.type===`fill`,r.cp=e=>e.type===`fill-extrusion`,r.cq=e=>e.type===`hillshade`,r.cr=e=>e.type===`color-relief`,r.cs=e=>e.type===`background`,r.ct=e=>e.type===`custom`,r.cu=me,r.cv=function(e,r,_){if(r<=0)return e;let v=1/r;return _===void 0||Math.abs(_)<1e-10?Math.round(e*v)/v:(_>0?Math.ceil(e*v-1e-9):Math.floor(e*v+1e-10))/v},r.cw=function(e,r,_){let v=se(r.x-_.x,r.y-_.y),b=se(e.x-_.x,e.y-_.y);var x,C;return it(Math.atan2(v[0]*b[1]-v[1]*b[0],(x=v)[0]*(C=b)[0]+x[1]*C[1]))},r.cx=ge,r.cy=function(e,r){var _;if(!ot[r])return!1;let v=(_=e?.target?.ownerDocument)?.defaultView||window;return e instanceof v.MouseEvent||e instanceof v.WheelEvent},r.cz=function(e,r){return at[r]&&`touches`in e},r.d=kt,r.d0=yl,r.e=ye,r.f=e=>_(void 0,void 0,void 0,function*(){if(e.byteLength===0)return createImageBitmap(new ImageData(1,1));let r=new Blob([new Uint8Array(e)],{type:`image/png`});try{return createImageBitmap(r)}catch(e){throw Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),r.g=_t,r.h=e=>new Promise((r,_)=>{let v=new Image;v.onload=()=>{r(v),URL.revokeObjectURL(v.src),v.onload=null,window.requestAnimationFrame(()=>{v.src=We})},v.onerror=()=>_(/* @__PURE__ */ 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 b=new Blob([new Uint8Array(e)],{type:`image/png`});v.src=e.byteLength?URL.createObjectURL(b):We}),r.i=Ne,r.j=(e,r)=>wt(ye(e,{type:`json`}),r),r.k=xt,r.l=gt,r.m=wt,r.n=(e,r)=>wt(ye(e,{type:`arrayBuffer`}),r),r.o=function(e){return new Vh(e).readFields(Nm,[])},r.p=Im,r.q=function(e){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))},r.r=Ml,r.s=et,r.t=Ws,r.u=$,r.v=Gc,r.w=je,r.x=$s,r.y=qc,r.z=Sl}),v(`worker`,[`./shared`],function(e){class t{constructor(e,r){this.keyCache={},e&&this.replace(e,r)}replace(e,r){this._layerConfigs={},this._layers={},this.update(e,[],r)}update(r,_,v){for(let _ of r){this._layerConfigs[_.id]=_;let r=this._layers[_.id]=e.bS(_,v);r._featureFilter=e.ag(r.filter,v),this.keyCache[_.id]&&delete this.keyCache[_.id]}for(let e of _)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};let b=e.cI(Object.values(this._layerConfigs),this.keyCache);for(let r of b){let _=r.map(e=>this._layers[e.id]),v=_[0];if(v.isHidden())continue;let b=v.source||``,x=this.familiesBySource[b];x||=this.familiesBySource[b]={};let C=v.sourceLayer||e.af,T=x[C];T||=x[C]=[],T.push(_)}}}class s{constructor(r){let _={},v=[];for(let e in r){let b=r[e],x=_[e]={};for(let e in b){let r=b[+e];if(!r||r.bitmap.width===0||r.bitmap.height===0)continue;let _={x:0,y:0,w:r.bitmap.width+2,h:r.bitmap.height+2};v.push(_),x[e]={rect:_,metrics:r.metrics}}}let{w:b,h:x}=e.p(v),C=new e.r({width:b||1,height:x||1});for(let v in r){let b=r[v];for(let r in b){let x=b[+r];if(!x||x.bitmap.width===0||x.bitmap.height===0)continue;let T=_[v][r].rect;e.r.copy(x.bitmap,C,{x:0,y:0},{x:T.x+1,y:T.y+1},x.bitmap)}}this.image=C,this.positions=_}}e.cJ(`GlyphAtlas`,s);class i{constructor(r){this.tileID=new e.a2(r.tileID.overscaledZ,r.tileID.wrap,r.tileID.canonical.z,r.tileID.canonical.x,r.tileID.canonical.y),this.uid=r.uid,this.zoom=r.zoom,this.pixelRatio=r.pixelRatio,this.tileSize=r.tileSize,this.source=r.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=r.showCollisionBoxes,this.collectResourceTiming=!!r.collectResourceTiming,this.returnDependencies=!!r.returnDependencies,this.promoteId=r.promoteId,this.inFlightDependencies=[]}parse(_,v,b,x,C){return e._(this,void 0,void 0,function*(){this.status=`parsing`,this.data=_,this.collisionBoxArray=new e.ad;let T=new e.cK(Object.keys(_.layers).sort()),E=new e.cL(this.tileID,this.promoteId);E.bucketLayerIDs=[];let D={},O={featureIndex:E,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:b,subdivisionGranularity:C},k=v.familiesBySource[this.source];for(let v in k){let x=_.layers[v];if(!x)continue;x.version===1&&e.w(`Vector tile source "${this.source}" layer "${v}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let C=T.encode(v),A=[];for(let e=0;ee.id)))}}let A=e.bX(O.glyphDependencies,e=>Object.keys(e).map(Number));this.inFlightDependencies.forEach(e=>e?.abort()),this.inFlightDependencies=[];let j=Promise.resolve({});if(Object.keys(A).length){let e=new AbortController;this.inFlightDependencies.push(e),j=x.sendAsync({type:`GG`,data:{stacks:A,source:this.source,tileID:this.tileID,type:`glyphs`}},e)}let F=Object.keys(O.iconDependencies),R=Promise.resolve({});if(F.length){let e=new AbortController;this.inFlightDependencies.push(e),R=x.sendAsync({type:`GI`,data:{icons:F,source:this.source,tileID:this.tileID,type:`icons`}},e)}let z=Object.keys(O.patternDependencies),B=Promise.resolve({});if(z.length){let e=new AbortController;this.inFlightDependencies.push(e),B=x.sendAsync({type:`GI`,data:{icons:z,source:this.source,tileID:this.tileID,type:`patterns`}},e)}let H=O.dashDependencies,K=Promise.resolve({});if(Object.keys(H).length){let e=new AbortController;this.inFlightDependencies.push(e),K=x.sendAsync({type:`GDA`,data:{dashes:H}},e)}let[q,Y,X,ne]=yield Promise.all([j,R,B,K]),Z=new s(q),ie=new e.cM(Y,X);for(let _ in D){let v=D[_];v instanceof e.ae?(r(v.layers,this.zoom,b),e.cN({bucket:v,glyphMap:q,glyphPositions:Z.positions,imageMap:Y,imagePositions:ie.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:O.subdivisionGranularity})):v.hasDependencies&&(v instanceof e.cO||v instanceof e.cP||v instanceof e.cQ)&&(r(v.layers,this.zoom,b),v.addFeatures(O,this.tileID.canonical,ie.patternPositions,ne))}return this.status=`done`,{buckets:Object.values(D).filter(e=>!e.isEmpty()),featureIndex:E,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Z.image,imageAtlas:ie,dashPositions:ne,glyphMap:this.returnDependencies?q:null,iconMap:this.returnDependencies?Y:null,glyphPositions:this.returnDependencies?Z.positions:null}})}}function r(r,_,v){let b=new e.H(_);for(let e of r)e.recalculate(b,v)}class o{constructor(){this.loading={},this.loaded={},this.parsing={}}startLoading(e,r){this.loading[e]=r}finishLoading(e){delete this.loading[e]}abort(e){let r=this.loading[e];r?.abort&&(r.abort.abort(),delete this.loading[e])}setParsing(e,r){this.parsing[e]=r}consumeParsing(e){let r=this.parsing[e];if(r)return delete this.parsing[e],r}clearParsing(e){delete this.parsing[e]}markLoaded(e,r){this.loaded[e]=r}getLoaded(e){let r=this.loaded[e];if(r)return r}removeLoaded(e){delete this.loaded[e]}clearLoaded(){this.loaded={}}}class n{constructor(e){this.start=`${e}#start`,this.end=`${e}#end`,this.measure=e,performance.mark(this.start)}finish(){performance.mark(this.end);let e=performance.getEntriesByName(this.measure);return e.length===0&&(performance.measure(this.measure,this.start,this.end),e=performance.getEntriesByName(this.measure),performance.clearMarks(this.start),performance.clearMarks(this.end),performance.clearMeasures(this.measure)),e}}class a{constructor(e,r,_,v,b){this.type=e,this.properties=_||{},this.extent=b,this.pointsArray=r,this.id=v}loadGeometry(){return this.pointsArray.map(r=>r.map(r=>new e.P(r.x,r.y)))}}class l{constructor(e,r,_){this.version=2,this._myFeatures=e,this.name=r,this.length=e.length,this.extent=_}feature(e){return this._myFeatures[e]}}class c{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}}function _(r){let _=e.cR(r);return _.byteOffset===0&&_.byteLength===_.buffer.byteLength||(_=new Uint8Array(_)),{vectorTile:r,rawData:_.buffer}}function v(r,_,v){let{extent:b}=r,x=2**(v.z-_.z),C=(v.x-_.x*x)*b,T=(v.y-_.y*x)*b,E=[];for(let _=0;_0&&O.addLayer(x)}let A=_(O);return this.overzoomedTileResultCache.set(E,A),A}reloadTile(r){return e._(this,void 0,void 0,function*(){let e=r.uid,_=this.tileState.getLoaded(e);if(!_)throw Error(`Should not be trying to reload a tile that was never loaded or has been removed`);if(_.showCollisionBoxes=r.showCollisionBoxes,_.status===`parsing`){let v=this.tileState.consumeParsing(e);return yield this._parseWorkerTile(_,r,v)}if(_.status===`done`&&_.vectorTile)return yield this._parseWorkerTile(_,r)})}abortTile(r){return e._(this,void 0,void 0,function*(){this.tileState.abort(r.uid)})}removeTile(r){return e._(this,void 0,void 0,function*(){this.tileState.removeLoaded(r.uid)})}}class g{constructor(){this.loaded={}}loadTile(r){return e._(this,void 0,void 0,function*(){let{uid:_,encoding:v,rawImageData:b,redFactor:x,greenFactor:C,blueFactor:T,baseShift:E}=r,D=b.width+2,O=b.height+2,k=e.b(b)?new e.R({width:D,height:O},yield e.cX(b,-1,-1,D,O)):b,A=new e.cY(_,k,v,x,C,T,E);return this.loaded=this.loaded||{},this.loaded[_]=A,A})}removeTile(e){let r=this.loaded,_=e.uid;r&&r[_]&&delete r[_]}}class p{constructor(e,r,_,v=b){this.actor=e,this.layerIndex=r,this.availableImages=_,this.tileState=new o,this._createGeoJSONIndex=v}loadVectorTile(r){if(!this._geoJSONIndex)throw Error(`Unable to parse the data into a cluster or geojson`);let{z:v,x:b,y:x}=r.tileID.canonical,C=this._geoJSONIndex.getTile(v,b,x);return C?_(new e.cZ(C.features,{version:2,extent:e.a5})):null}loadTile(r){return e._(this,void 0,void 0,function*(){let{uid:e}=r,_=new i(r);_.abort=new AbortController;try{let v=this.loadVectorTile(r);if(!v)return null;let{vectorTile:b,rawData:x}=v;_.vectorTile=b,this.tileState.markLoaded(e,_);let C={rawData:x};this.tileState.setParsing(e,C);try{return yield this._parseWorkerTile(_,r,C)}finally{this.tileState.clearParsing(e)}}catch(r){throw _.status=`done`,this.tileState.markLoaded(e,_),r}})}_reloadLoadedTile(r){return e._(this,void 0,void 0,function*(){let e=r.uid,_=this.tileState.getLoaded(e);if(!_)throw Error(`Should not be trying to reload a tile that was never loaded or has been removed`);if(_.showCollisionBoxes=r.showCollisionBoxes,_.status===`parsing`){let v=this.tileState.consumeParsing(e);return yield this._parseWorkerTile(_,r,v)}if(_.status===`done`&&_.vectorTile)return yield this._parseWorkerTile(_,r)})}_parseWorkerTile(r,_,v){return e._(this,void 0,void 0,function*(){let b=yield r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor,_.subdivisionGranularity);if(v){let{rawData:r}=v;b=e.e({rawTileData:r.slice(0),encoding:`mvt`},b)}return b})}abortTile(r){return e._(this,void 0,void 0,function*(){this.tileState.abort(r.uid)})}removeTile(r){return e._(this,void 0,void 0,function*(){this.tileState.removeLoaded(r.uid)})}loadData(r){return e._(this,void 0,void 0,function*(){var _;(_=this._pendingRequest)==null||_.abort();let v=this._startRequestTiming(r);this._pendingRequest=new AbortController;try{yield this.loadAndProcessGeoJSON(r,this._pendingRequest),delete this._pendingRequest,this.tileState.clearLoaded();let e={};return r.request&&(e.data=r.data),this._finishRequestTiming(v,r,e),e}catch(r){if(delete this._pendingRequest,!e.Z(r))throw r;return{abandoned:!0}}})}_startRequestTiming(e){var r;if((r=e.request)?.collectResourceTiming)return new n(e.request.url)}_finishRequestTiming(e,r,_){let v=e?.finish();v&&(_.resourceTiming={[r.source]:JSON.parse(JSON.stringify(v))})}reloadTile(e){return this.tileState.getLoaded(e.uid)?this._reloadLoadedTile(e):this.loadTile(e)}loadAndProcessGeoJSON(r,_){return e._(this,void 0,void 0,function*(){var v;if(r.request&&(r.data=(yield e.j(r.request,_)).data),r.data)return r.data=this._filterGeoJSON(r.data,r.filter),void(this._geoJSONIndex=this._createGeoJSONIndex(r.data,r));if(r.dataDiff)return(v=this._geoJSONIndex)??(this._geoJSONIndex=this._createGeoJSONIndex({type:`FeatureCollection`,features:[]},r)),void this._geoJSONIndex.updateData(r.dataDiff,this._getFilterPredicate(r.filter));if(r.updateCluster&&this._geoJSONIndex.updateClusterOptions(r.geojsonVtOptions.cluster,x(r)),this._geoJSONIndex==null)throw Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`)})}_filterGeoJSON(e,r){if(e.type!==`FeatureCollection`)return e;let _=this._getFilterPredicate(r);return _?{type:`FeatureCollection`,features:e.features.filter(e=>_(e))}:e}_getFilterPredicate(r){if(typeof r!=`boolean`&&!r?.length)return;let _=e.c_(r,{type:`boolean`,"property-type":`data-driven`,overridable:!1,transition:!1});if(_.result===`error`)throw Error(_.value.map(e=>`${e.key}: ${e.message}`).join(`, `));return e=>_.value.evaluate({zoom:0},e)}removeSource(r){return e._(this,void 0,void 0,function*(){var e;(e=this._pendingRequest)==null||e.abort()})}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getClusterChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getClusterLeaves(e.clusterId,e.limit,e.offset)}}function b(r,_){let v=e.e(_.geojsonVtOptions||{},{updateable:!0,clusterOptions:x(_)});return new e.c$(r,v)}function x({geojsonVtOptions:r,clusterProperties:_}){if(!_||!r.clusterOptions)return r.clusterOptions;let v={},b={},x={accumulated:null,zoom:0},C={properties:null},T=Object.keys(_);for(let r of T){let[x,C]=_[r],T=e.c_(C),E=e.c_(typeof x==`string`?[x,[`accumulated`],[`get`,r]]:x);v[r]=T.value,b[r]=E.value}return r.clusterOptions.map=e=>{C.properties=e;let r={};for(let e of T)r[e]=v[e].evaluate(x,C);return r},r.clusterOptions.reduce=(e,r)=>{C.properties=r;for(let r of T)x.accumulated=e[r],e[r]=b[r].evaluate(x,C)},r.clusterOptions}class m{constructor(r){this.self=r,this.actor=new e.L(r),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=/* @__PURE__ */ new Map,this.self.registerWorkerSource=(e,r)=>{if(this.externalWorkerSourceTypes[e])throw Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=r},this.self.addProtocol=e.cG,this.self.removeProtocol=e.cH,this.self.registerRTLTextPlugin=r=>{e.d0.setMethods(r)},this.actor.registerMessageHandler(`LDT`,(e,r)=>this._getDEMWorkerSource(e,r.source).loadTile(r)),this.actor.registerMessageHandler(`RDT`,(r,_)=>e._(this,void 0,void 0,function*(){this._getDEMWorkerSource(r,_.source).removeTile(_)})),this.actor.registerMessageHandler(`GCEZ`,(r,_)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(r,_.type,_.source).getClusterExpansionZoom(_)})),this.actor.registerMessageHandler(`GCC`,(r,_)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(r,_.type,_.source).getClusterChildren(_)})),this.actor.registerMessageHandler(`GCL`,(r,_)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(r,_.type,_.source).getClusterLeaves(_)})),this.actor.registerMessageHandler(`LD`,(e,r)=>this._getWorkerSource(e,r.type,r.source).loadData(r)),this.actor.registerMessageHandler(`LT`,(e,r)=>this._getWorkerSource(e,r.type,r.source).loadTile(r)),this.actor.registerMessageHandler(`RT`,(e,r)=>this._getWorkerSource(e,r.type,r.source).reloadTile(r)),this.actor.registerMessageHandler(`AT`,(e,r)=>this._getWorkerSource(e,r.type,r.source).abortTile(r)),this.actor.registerMessageHandler(`RMT`,(e,r)=>this._getWorkerSource(e,r.type,r.source).removeTile(r)),this.actor.registerMessageHandler(`RS`,(r,_)=>e._(this,void 0,void 0,function*(){if(!this.workerSources[r]||!this.workerSources[r][_.type]||!this.workerSources[r][_.type][_.source])return;let e=this.workerSources[r][_.type][_.source];delete this.workerSources[r][_.type][_.source],e.removeSource!==void 0&&e.removeSource(_)})),this.actor.registerMessageHandler(`RM`,r=>e._(this,void 0,void 0,function*(){delete this.layerIndexes[r],delete this.availableImages[r],delete this.workerSources[r],delete this.demWorkerSources[r],this.globalStates.delete(r)})),this.actor.registerMessageHandler(`SR`,(r,_)=>e._(this,void 0,void 0,function*(){this.referrer=_})),this.actor.registerMessageHandler(`SRPS`,(e,r)=>this._syncRTLPluginState(e,r)),this.actor.registerMessageHandler(`IS`,(r,_)=>e._(this,void 0,void 0,function*(){this.self.importScripts(_)})),this.actor.registerMessageHandler(`SI`,(e,r)=>this._setImages(e,r)),this.actor.registerMessageHandler(`UL`,(r,_)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(r).update(_.layers,_.removedIds,this._getGlobalState(r))})),this.actor.registerMessageHandler(`UGS`,(r,_)=>e._(this,void 0,void 0,function*(){let e=this._getGlobalState(r);for(let r in _)e[r]=_[r]})),this.actor.registerMessageHandler(`SL`,(r,_)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(r).replace(_,this._getGlobalState(r))}))}_getGlobalState(e){let r=this.globalStates.get(e);return r||(r={},this.globalStates.set(e,r)),r}_setImages(r,_){return e._(this,void 0,void 0,function*(){this.availableImages[r]=_;for(let e in this.workerSources[r]){let v=this.workerSources[r][e];for(let e in v)v[e].availableImages=_}})}_syncRTLPluginState(r,_){return e._(this,void 0,void 0,function*(){return yield e.d0.syncState(_,this.self.importScripts)})}_getAvailableImages(e){let r=this.availableImages[e];return r||=[],r}_getLayerIndex(e){let r=this.layerIndexes[e];return r||=this.layerIndexes[e]=new t,r}_getWorkerSource(e,r,_){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][r]||(this.workerSources[e][r]={}),!this.workerSources[e][r][_]){let v={sendAsync:(r,_)=>(r.targetMapId=e,this.actor.sendAsync(r,_))};switch(r){case`vector`:this.workerSources[e][r][_]=new u(v,this._getLayerIndex(e),this._getAvailableImages(e));break;case`geojson`:this.workerSources[e][r][_]=new p(v,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][r][_]=new this.externalWorkerSourceTypes[r](v,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][r][_]}_getDEMWorkerSource(e,r){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][r]||(this.demWorkerSources[e][r]=new g),this.demWorkerSources[e][r]}}return e.i(self)&&(self.worker=new m(self)),m}),v(`index`,[`exports`,`./shared`],function(r,_){var v=`5.22.0`;function b(){var e=new _.A(4);return _.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let x,C,T,E={frame(e,r,v,b){let x=b||window,C=x.requestAnimationFrame(e=>{T(),r(e)}),{unsubscribe:T}=_.s(e.signal,`abort`,()=>{T(),x.cancelAnimationFrame(C),v(new _.a(e.signal.reason))},!1)},frameAsync(e,r){return new Promise((_,v)=>{this.frame(e,_,v,r)})},getImageData(e,r=0){return this.getImageCanvasContext(e).getImageData(-r,-r,e.width+2*r,e.height+2*r)},getImageCanvasContext(e){let r=window.document.createElement(`canvas`),_=r.getContext(`2d`,{willReadFrequently:!0});if(!_)throw Error(`failed to create canvas 2d context`);return r.width=e.width,r.height=e.height,_.drawImage(e,0,0,e.width,e.height),_},resolveURL:e=>(x||=document.createElement(`a`),x.href=e,x.href),hardwareConcurrency:typeof navigator<`u`&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return T===void 0?!!matchMedia&&(C??=matchMedia(`(prefers-reduced-motion: reduce)`),C.matches):T},set prefersReducedMotion(e){T=e}},D=new class{constructor(){this._frozenAt=null}getCurrentTime(){return this._frozenAt===null?performance.now():this._frozenAt}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return this._frozenAt!==null}};function O(){return D.getCurrentTime()}class h{static create(e,r,_){let v=window.document.createElement(e);return r!==void 0&&(v.className=r),_&&_.appendChild(v),v}static createNS(e,r){return window.document.createElementNS(e,r)}static disableDrag(){h.docStyle&&h.selectProp&&(h.userSelect=h.docStyle[h.selectProp],h.docStyle[h.selectProp]=`none`)}static enableDrag(){h.docStyle&&h.selectProp&&(h.docStyle[h.selectProp]=h.userSelect)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener(`click`,h.suppressClickInternal,!0)}static suppressClick(){window.addEventListener(`click`,h.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener(`click`,h.suppressClickInternal,!0)},0)}static getScale(e){let r=e.getBoundingClientRect();return{x:r.width/e.offsetWidth||1,y:r.height/e.offsetHeight||1,boundingClientRect:r}}static getPoint(e,r,v){let b=r.boundingClientRect;return new _.P((v.clientX-b.left)/r.x-e.clientLeft,(v.clientY-b.top)/r.y-e.clientTop)}static mousePos(e,r){let _=h.getScale(e);return h.getPoint(e,_,r)}static touchPos(e,r){let _=[],v=h.getScale(e);for(let b=0;b{v=[],b=0,x=0,C={}},r.addThrottleControl=e=>{let r=x++;return C[r]=e,r},r.removeThrottleControl=e=>{delete C[e],E()},r.getImage=(e,r,b=!0)=>new Promise((x,C)=>{e.headers||={},e.headers.accept=`image/webp,*/*`,_.e(e,{type:`image`}),v.push({abortController:r,requestParameters:e,supportImageRefresh:b,state:`queued`,onError:e=>{C(e)},onSuccess:e=>{x(e)}}),E()});let T=r=>_._(this||e,void 0,void 0,function*(){r.state=`running`;let{requestParameters:e,supportImageRefresh:v,onError:x,onSuccess:C,abortController:T}=r,O=!1===v&&!_.i(self)&&!_.g(e.url)&&(!e.headers||Object.keys(e.headers).reduce((e,r)=>e&&r===`accept`,!0));b++;let k=O?D(e,T):_.m(e,T);try{let e=yield k;delete r.abortController,r.state=`completed`,e.data instanceof HTMLImageElement||_.b(e.data)?C(e):e.data&&C({data:yield(A=e.data,typeof createImageBitmap==`function`?_.f(A):_.h(A)),cacheControl:e.cacheControl,expires:e.expires})}catch(e){delete r.abortController,x(e)}finally{b--,E()}var A}),E=()=>{let e=(()=>{for(let e of Object.keys(C))if(C[e]())return!0;return!1})()?_.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:_.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let r=b;r0;r++){let e=v.shift();e.abortController.signal.aborted?r--:T(e)}},D=(e,r)=>new Promise((v,b)=>{let x=new Image,C=e.url,T=e.credentials;T&&T===`include`?x.crossOrigin=`use-credentials`:(T&&T===`same-origin`||!_.d(C))&&(x.crossOrigin=`anonymous`),r.signal.addEventListener(`abort`,()=>{x.src=``,b(new _.a(r.signal.reason))}),x.fetchPriority=`high`,x.onload=()=>{x.onerror=x.onload=null,v({data:x})},x.onerror=()=>{x.onerror=x.onload=null,r.signal.aborted||b(/* @__PURE__ */ 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.`))},x.src=C})}(k||={}),k.resetRequestQueue();class d{constructor(e){this._transformRequestFn=e??null}transformRequest(e,r){return this._transformRequestFn&&this._transformRequestFn(e,r)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function A(e){let r=[];if(typeof e==`string`)r.push({id:`default`,url:e});else if(e&&e.length>0){let _=[];for(let{id:v,url:b}of e){let e=`${v}${b}`;_.indexOf(e)===-1&&(_.push(e),r.push({id:v,url:b}))}}return r}function j(e,r,_){try{let v=new URL(e);return v.pathname+=`${r}${_}`,v.toString()}catch{throw Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function F(e){let{userImage:r}=e;return!!(r&&r.render&&r.render())&&(e.data.replace(new Uint8Array(r.data.buffer)),!0)}class f extends _.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new _.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&=(this.atlasTexture.destroy(),null);for(let e of Object.keys(this.images))this.removeImage(e);this.patterns={},this.atlasImage=new _.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:e,promiseResolve:r}of this.requestors)r(this._getImagesForIds(e));this.requestors=[]}}getImage(e){let r=this.images[e];if(r&&!r.data&&r.spriteData){let e=r.spriteData;r.data=new _.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),r.spriteData=null}return r}addImage(e,r){if(this.images[e])throw Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,r)&&(this.images[e]=r)}_validate(e,r){let v=!0,b=r.data||r.spriteData;return this._validateStretch(r.stretchX,b&&b.width)||(this.fire(new _.k(/* @__PURE__ */ Error(`Image "${e}" has invalid "stretchX" value`))),v=!1),this._validateStretch(r.stretchY,b&&b.height)||(this.fire(new _.k(/* @__PURE__ */ Error(`Image "${e}" has invalid "stretchY" value`))),v=!1),this._validateContent(r.content,r)||(this.fire(new _.k(/* @__PURE__ */ Error(`Image "${e}" has invalid "content" value`))),v=!1),v}_validateStretch(e,r){if(!e)return!0;let _=0;for(let v of e){if(v[0]<_||v[1]{let v=!0;if(!this.isLoaded())for(let r of e)this.images[r]||(v=!1);this.isLoaded()||v?r(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:r})})}_getImagesForIds(e){let r={};for(let v of e){let e=this.getImage(v);e||=(this.fire(new _.l(`styleimagemissing`,{id:v})),this.getImage(v)),e?r[v]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:!!(e.userImage&&e.userImage.render)}:_.w(`Image "${v}" 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 r}getPixelSize(){let{width:e,height:r}=this.atlasImage;return{width:e,height:r}}getPattern(e){let r=this.patterns[e],v=this.getImage(e);if(!v)return null;if(r&&r.position.version===v.version)return r.position;if(r)r.position.version=v.version;else{let r={w:v.data.width+2,h:v.data.height+2,x:0,y:0},b=new _.I(r,v);this.patterns[e]={bin:r,position:b}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){let r=e.gl;this.atlasTexture?this.dirty&&=(this.atlasTexture.update(this.atlasImage),!1):this.atlasTexture=new _.T(e,this.atlasImage,r.RGBA),this.atlasTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}_updatePatternAtlas(){let e=[];for(let r in this.patterns)e.push(this.patterns[r].bin);let{w:r,h:v}=_.p(e),b=this.atlasImage;b.resize({width:r||1,height:v||1});for(let e in this.patterns){let{bin:r}=this.patterns[e],v=r.x+1,x=r.y+1,C=this.getImage(e).data,T=C.width,E=C.height;_.R.copy(C,b,{x:0,y:0},{x:v,y:x},{width:T,height:E}),_.R.copy(C,b,{x:0,y:E-1},{x:v,y:x-1},{width:T,height:1}),_.R.copy(C,b,{x:0,y:0},{x:v,y:x+E},{width:T,height:1}),_.R.copy(C,b,{x:T-1,y:0},{x:v-1,y:x},{width:1,height:E}),_.R.copy(C,b,{x:0,y:0},{x:v+T,y:x},{width:1,height:E})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(let r of e){if(this.callbackDispatchedThisFrame[r])continue;this.callbackDispatchedThisFrame[r]=!0;let e=this.getImage(r);e||_.w(`Image with ID: "${r}" was not found`),F(e)&&this.updateImage(r,e)}}cloneImages(){let e={};for(let r in this.images){let _=this.images[r];e[r]=Object.assign(Object.assign({},_),{data:_.data?_.data.clone():null})}return e}}let R=0x56bc75e2d63100000;function z(e,r,_,v,b,x,C,T,E){for(let D=r;D-1);E++,x[E]=T,C[E]=D,C[E+1]=R}for(let T=0,E=0;T/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`).join(`,`);return new y.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:_,fontWeight:this._fontWeight(r[0]),fontStyle:this._fontStyle(r[0]),lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?`italic`:/oblique/i.test(e)?`oblique`:`normal`}_fontWeight(e){let r={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950},_;for(let[v,b]of Object.entries(r))RegExp(`\\b${v}\\b`,`i`).test(e)&&(_=`${b}`);return _}destroy(){for(let e in this.entries){let r=this.entries[e];r.tinySDF&&=null,r.ideographTinySDF&&=null,r.glyphs={},r.requests={},r.ranges={}}this.entries={}}}y.loadGlyphRange=function(r,v,b,x){return _._(this||e,void 0,void 0,function*(){let e=256*v,C=e+255,T=yield x.transformRequest(b.replace(`{fontstack}`,r).replace(`{range}`,`${e}-${C}`),`Glyphs`),E=yield _.n(T,new AbortController);if(!E||!E.data)throw Error(`Could not load glyph range. range: ${v}, ${e}-${C}`);let D={};for(let e of _.o(E.data))D[e.id]=e;return D})},y.TinySDF=class{constructor({fontSize:e=24,buffer:r=3,radius:_=8,cutoff:v=.25,fontFamily:b=`sans-serif`,fontWeight:x=`normal`,fontStyle:C=`normal`,lang:T=null}={}){this.buffer=r,this.cutoff=v,this.radius=_,this.lang=T;let E=this.size=e+4*r,D=this.ctx=this._createCanvas(E).getContext(`2d`,{willReadFrequently:!0});D.font=`${C} ${x} ${e}px ${b}`,D.textBaseline=`alphabetic`,D.textAlign=`left`,D.fillStyle=`black`,this.gridOuter=new Float64Array(E*E),this.gridInner=new Float64Array(E*E),this.f=new Float64Array(E),this.z=new Float64Array(E+1),this.v=new Uint16Array(E)}_createCanvas(e){let r=document.createElement(`canvas`);return r.width=r.height=e,r}draw(e){let{width:r,actualBoundingBoxAscent:_,actualBoundingBoxDescent:v,actualBoundingBoxLeft:b,actualBoundingBoxRight:x}=this.ctx.measureText(e),C=Math.ceil(_),T=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(x-b))),E=Math.min(this.size-this.buffer,C+Math.ceil(v)),D=T+2*this.buffer,O=E+2*this.buffer,k=Math.max(D*O,0),A=new Uint8ClampedArray(k),j={data:A,width:D,height:O,glyphWidth:T,glyphHeight:E,glyphTop:C,glyphLeft:0,glyphAdvance:r};if(T===0||E===0)return j;let{ctx:F,buffer:B,gridInner:H,gridOuter:K}=this;this.lang&&(F.lang=this.lang),F.clearRect(B,B,T,E),F.fillText(e,B,B+C);let q=F.getImageData(B,B,T,E);K.fill(R,0,k),H.fill(0,0,k);for(let e=0;e0?e*e:0,H[v]=e<0?e*e:0}}z(K,0,0,D,O,D,this.f,this.v,this.z),z(H,B,B,T,E,D,this.f,this.v,this.z);for(let e=0;e1&&(C=e[++x]);let E=Math.abs(T-C.left),D=Math.abs(T-C.right),O=Math.min(E,D),k,A=r/_*(v+1);if(C.isDash){let e=v-Math.abs(A);k=Math.sqrt(O*O+e*e)}else k=v-Math.sqrt(O*O+A*A);this.data[b+T]=Math.max(0,Math.min(255,k+128))}}}addRegularDash(e){for(let r=e.length-1;r>=0;--r){let _=e[r],v=e[r+1];_.zeroLength?e.splice(r,1):v&&v.isDash===_.isDash&&(v.left=_.left,e.splice(r,1))}let r=e[0],_=e[e.length-1];r.isDash===_.isDash&&(r.left=_.left-this.width,_.right=r.right+this.width);let v=this.width*this.nextRow,b=0,x=e[b];for(let r=0;r1&&(x=e[++b]);let _=Math.abs(r-x.left),C=Math.abs(r-x.right),T=Math.min(_,C);this.data[v+r]=Math.max(0,Math.min(255,(x.isDash?T:-T)+128))}}addDash(e,r){let v=r?7:0,b=2*v+1;if(this.nextRow+b>this.height)return _.w(`LineAtlas out of space`),null;let x=0;for(let r=0;r{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Y]}numActive(){return Object.keys(this.active).length}}let X=Math.floor(E.hardwareConcurrency/2),ne,Z;function ie(){return ne||=new S,ne}S.workerCount=_.K(globalThis)?Math.max(Math.min(X,3),1):1;class L{constructor(e,r){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=r;let v=this.workerPool.acquire(r);for(let e=0;e{e.remove()}),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,r){for(let _ of this.actors)_.registerMessageHandler(e,r)}unregisterMessageHandler(e){for(let r of this.actors)r.unregisterMessageHandler(e)}}function ae(){return Z||(Z=new L(ie(),_.M),Z.registerMessageHandler(`GR`,(e,r,v)=>_.m(r,v))),Z}function oe(e,r){let v=_.N();return _.O(v,v,[1,1,0]),_.Q(v,v,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?_.S(v,v,e.calculatePosMatrix(r.toUnwrapped())):v}function se(e,r,_,v,b,x,C){var T;let E=function(e,r,_){if(e)for(let v of e){let e=r[v];if(e&&e.source===_&&e.type===`fill-extrusion`)return!0}else for(let e in r){let v=r[e];if(v.source===_&&v.type===`fill-extrusion`)return!0}return!1}((T=b?.layers)??null,r,e.id),D=x.maxPitchScaleFactor(),O=e.tilesIn(v,D,E);O.sort(ce);let k=[];for(let v of O)k.push({wrappedTileID:v.tileID.wrapped().key,queryResults:v.tile.queryRenderedFeatures(r,_,e.getState(),v.queryGeometry,v.cameraQueryGeometry,v.scale,b,x,D,oe(x,v.tileID),C?(e,r)=>C(v.tileID,e,r):void 0)});return function(e,r){for(let _ in e)for(let v of e[_])le(v,r);return e}(function(e){let r={},_={};for(let v of e){let e=v.queryResults,b=v.wrappedTileID,x=_[b]=_[b]||{};for(let _ in e){let v=e[_],b=x[_]=x[_]||{},C=r[_]=r[_]||[];for(let e of v)b[e.featureIndex]||(b[e.featureIndex]=!0,C.push(e))}}return r}(k),e)}function ce(e,r){let _=e.tileID,v=r.tileID;return _.overscaledZ-v.overscaledZ||_.canonical.y-v.canonical.y||_.wrap-v.wrap||_.canonical.x-v.canonical.x}function le(e,r){let _=e.feature,v=r.getFeatureState(_.layer[`source-layer`],_.id);_.source=_.layer.source,_.layer[`source-layer`]&&(_.sourceLayer=_.layer[`source-layer`]),_.state=v}function de(r,v,b,x){return _._(this||e,void 0,void 0,function*(){let e=r;if(r.url?e=(yield _.j(yield v.transformRequest(r.url,`Source`),b)).data:yield E.frameAsync(b,x),!e)return null;let C=_.U(_.e(e,r),[`tiles`,`minzoom`,`maxzoom`,`attribution`,`bounds`,`scheme`,`tileSize`,`encoding`]);return`vector_layers`in e&&e.vector_layers&&(C.vectorLayerIds=e.vector_layers.map(e=>e.id)),C})}class N{constructor(e,r){e&&(r?this.setSouthWest(e).setNorthEast(r):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 _.V?new _.V(e.lng,e.lat):_.V.convert(e),this}setSouthWest(e){return this._sw=e instanceof _.V?new _.V(e.lng,e.lat):_.V.convert(e),this}extend(e){let r=this._sw,v=this._ne,b,x;if(e instanceof _.V)b=e,x=e;else{if(!(e instanceof N))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(N.convert(e)):this.extend(_.V.convert(e)):e&&(`lng`in e||`lon`in e)&&`lat`in e?this.extend(_.V.convert(e)):this;if(b=e._sw,x=e._ne,!b||!x)return this}return r||v?(r.lng=Math.min(b.lng,r.lng),r.lat=Math.min(b.lat,r.lat),v.lng=Math.max(x.lng,v.lng),v.lat=Math.max(x.lat,v.lat)):(this._sw=new _.V(b.lng,b.lat),this._ne=new _.V(x.lng,x.lat)),this}getCenter(){return new _.V((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new _.V(this.getWest(),this.getNorth())}getSouthEast(){return new _.V(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){let{lng:r,lat:v}=_.V.convert(e),b=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(b=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=v&&v<=this._ne.lat&&b}intersects(e){if(!((e=N.convert(e)).getNorth()>=this.getSouth()&&e.getSouth()<=this.getNorth()))return!1;let r=Math.abs(this.getEast()-this.getWest()),v=Math.abs(e.getEast()-e.getWest());if(r>=360||v>=360)return!0;let b=_.W(this.getWest(),-180,180),x=_.W(this.getEast(),-180,180),C=_.W(e.getWest(),-180,180),T=_.W(e.getEast(),-180,180),E=b>x,D=C>T;return!(!E||!D)||(E?T>=b||C<=x:D?x>=C||b<=T:C<=x&&T>=b)}static convert(e){return e instanceof N?e:e&&new N(e)}static fromLngLat(e,r=0){let v=360*r/40075017,b=v/Math.cos(Math.PI/180*e.lat);return new N(new _.V(e.lng-b,e.lat-v),new _.V(e.lng+b,e.lat+v))}adjustAntiMeridian(){let e=new _.V(this._sw.lng,this._sw.lat),r=new _.V(this._ne.lng,this._ne.lat);return new N(e,e.lng>r.lng?new _.V(r.lng+360,r.lat):r)}}class U{constructor(e,r,_){this.bounds=N.convert(this.validateBounds(e)),this.minzoom=r||0,this.maxzoom=_||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 r=2**e.z,v=Math.floor(_.Y(this.bounds.getWest())*r),b=Math.floor(_.X(this.bounds.getNorth())*r),x=Math.ceil(_.Y(this.bounds.getEast())*r),C=Math.ceil(_.X(this.bounds.getSouth())*r);return e.x>=v&&e.x=b&&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(),null)}serialize(){return _.e({},this._options)}loadTile(e){return _._(this,void 0,void 0,function*(){let r=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),_={request:yield this.map._requestManager.transformRequest(r,`Tile`),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:yield this._getOverzoomParameters(e),etag:e.etag};_.request.collectResourceTiming=this._collectResourceTiming;let v=`RT`;if(e.actor&&e.state!==`expired`){if(e.state===`loading`)return new Promise((r,_)=>{e.reloadPromise={resolve:r,reject:_}})}else e.actor=this.dispatcher.getActor(),v=`LT`;e.abortController=new AbortController;try{let r=yield e.actor.sendAsync({type:v,data:_},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,r);let b={};return r?.etagUnmodified&&(b.unmodified=!0),b}catch(r){if(delete e.abortController,e.aborted)return;if(r&&r.status!==404)throw r;this._afterTileLoadWorkerResponse(e,null)}})}_getOverzoomParameters(e){return _._(this,void 0,void 0,function*(){if(e.tileID.canonical.z<=this.maxzoom||this.map._zoomLevelsToOverscale===void 0)return;let r=e.tileID.scaledTo(this.maxzoom).canonical,_=r.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:r,overzoomRequest:yield this.map._requestManager.transformRequest(_,`Tile`)}})}_afterTileLoadWorkerResponse(e,r){if(r?.resourceTiming&&(e.resourceTiming=r.resourceTiming),r&&this.map._refreshExpiredTiles&&e.setExpiryData(r),e.etag=r?.etag,e.loadVectorData(r,this.map.painter),e.reloadPromise){let r=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(r.resolve).catch(r.reject)}}abortTile(e){return _._(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 _._(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 V extends _.E{constructor(e,r,v,b){super(),this.id=e,this.dispatcher=v,this.setEventedParent(b),this.type=`raster`,this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme=`xyz`,this.tileSize=512,this._loaded=!1,this._options=_.e({type:`raster`},r),_.e(this,_.U(r,[`url`,`scheme`,`tileSize`]))}load(){return _._(this,arguments,void 0,function*(e=!1){this._loaded=!1,this.fire(new _.l(`dataloading`,{dataType:`source`})),this._tileJSONRequest=new AbortController;try{let r=yield de(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,r&&(_.e(this,r),r.bounds&&(this.tileBounds=new U(r.bounds,this.minzoom,this.maxzoom)),this.fire(new _.l(`data`,{dataType:`source`,sourceDataType:`metadata`})),this.fire(new _.l(`data`,{dataType:`source`,sourceDataType:`content`,sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,_.Z(e)||this.fire(new _.k(e))}})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}setSourceProperty(e){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return _.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return _._(this,void 0,void 0,function*(){let r=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{let v=yield k.getImage(yield this.map._requestManager.transformRequest(r,`Tile`),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state=`unloaded`);if(v&&v.data){this.map._refreshExpiredTiles&&(v.cacheControl||v.expires)&&e.setExpiryData({cacheControl:v.cacheControl,expires:v.expires});let r=this.map.painter.context,b=r.gl,x=v.data;e.texture=this.map.painter.getTileTexture(x.width),e.texture?e.texture.update(x,{useMipmap:!0}):(e.texture=new _.T(r,x,b.RGBA,{useMipmap:!0}),e.texture.bind(b.LINEAR,b.CLAMP_TO_EDGE,b.LINEAR_MIPMAP_NEAREST)),e.state=`loaded`}}catch(r){if(delete e.abortController,e.aborted)e.state=`unloaded`;else if(r)throw e.state=`errored`,r}})}abortTile(e){return _._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)})}unloadTile(e){return _._(this,void 0,void 0,function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)})}hasTransition(){return!1}}class W extends V{constructor(e,r,v,b){super(e,r,v,b),this.type=`raster-dem`,this.maxzoom=22,this._options=_.e({type:`raster-dem`},r),this.encoding=r.encoding||`mapbox`,this.redFactor=r.redFactor,this.greenFactor=r.greenFactor,this.blueFactor=r.blueFactor,this.baseShift=r.baseShift}loadTile(e){return _._(this,void 0,void 0,function*(){let r=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),v=yield this.map._requestManager.transformRequest(r,`Tile`);e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{let r=yield k.getImage(v,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state=`unloaded`);if(r&&r.data){let v=r.data;this.map._refreshExpiredTiles&&(r.cacheControl||r.expires)&&e.setExpiryData({cacheControl:r.cacheControl,expires:r.expires});let b=_.b(v)&&_.$()?v:yield this.readImageNow(v),x={type:this.type,uid:e.uid,source:this.id,rawImageData:b,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(e.actor&&e.state!==`expired`&&e.state!==`reloading`)return;e.actor&&e.state!==`expired`||(e.actor=this.dispatcher.getActor()),e.dem=yield e.actor.sendAsync({type:`LDT`,data:x}),e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state=`loaded`}}catch(r){if(delete e.abortController,e.aborted)e.state=`unloaded`;else if(r)throw e.state=`errored`,r}})}readImageNow(e){return _._(this,void 0,void 0,function*(){if(typeof VideoFrame<`u`&&_.a0()){let r=e.width+2,v=e.height+2;try{return new _.R({width:r,height:v},yield _.a1(e,-1,-1,r,v))}catch{}}return E.getImageData(e,1)})}_getNeighboringTiles(e){let r=e.canonical,v=2**r.z,b=(r.x-1+v)%v,x=r.x===0?e.wrap-1:e.wrap,C=(r.x+1+v)%v,T=r.x+1===v?e.wrap+1:e.wrap,E={};return E[new _.a2(e.overscaledZ,x,r.z,b,r.y).key]={backfilled:!1},E[new _.a2(e.overscaledZ,T,r.z,C,r.y).key]={backfilled:!1},r.y>0&&(E[new _.a2(e.overscaledZ,x,r.z,b,r.y-1).key]={backfilled:!1},E[new _.a2(e.overscaledZ,e.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},E[new _.a2(e.overscaledZ,T,r.z,C,r.y-1).key]={backfilled:!1}),r.y+1e.key===_);r>-1&&e.addOrUpdateProperties.splice(r,1)}return(e.removeAllProperties||r.removeAllProperties)&&(_.removeAllProperties=!0),(e.removeProperties||r.removeProperties)&&(_.removeProperties=[...e.removeProperties||[],...r.removeProperties||[]]),(e.addOrUpdateProperties||r.addOrUpdateProperties)&&(_.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...r.addOrUpdateProperties||[]]),(e.newGeometry||r.newGeometry)&&(_.newGeometry=r.newGeometry||e.newGeometry),_}function me(e){var r,_;if(!e)return{};let v={};return v.removeAll=e.removeAll,v.remove=new Set(e.remove||[]),v.add=new Map((r=e.add)?.map(e=>[e.id,e])),v.update=new Map((_=e.update)?.map(e=>[e.id,e])),v}function ge(e){return e&&e.length!==0?typeof e[0]==`number`?[e]:e.flatMap(e=>ge(e)):[]}function _e(e){return e.type===`GeometryCollection`?e.geometries.flatMap(e=>_e(e)):ge(e.coordinates)}function ve(e){let r=new N,_;switch(e.type){case`FeatureCollection`:_=e.features.flatMap(e=>_e(e.geometry));break;case`Feature`:_=_e(e.geometry);break;default:_=_e(e)}if(_.length===0)return r;for(let e=0;e<_.length;e++){let[v,b]=_[e];r.extend([v,b])}return r}class Q extends _.E{constructor(e,r,v,b){super(),this.id=e,this.type=`geojson`,this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:r.data},this.actor=v.getActor(),this.setEventedParent(b),this._data=typeof r.data==`string`?{url:r.data}:{geojson:r.data},this._options=_.e({},r),this._collectResourceTiming=r.collectResourceTiming,r.maxzoom!==void 0&&(this.maxzoom=r.maxzoom),r.type&&(this.type=r.type),r.attribution&&(this.attribution=r.attribution),this.promoteId=r.promoteId,r.clusterMaxZoom!==void 0&&this.maxzoom<=r.clusterMaxZoom&&_.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${r.clusterMaxZoom}".`),this.workerOptions=_.e({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(r.buffer===void 0?128:r.buffer),tolerance:this._pixelsToTileUnits(r.tolerance===void 0?.375:r.tolerance),extent:_.a5,maxZoom:this.maxzoom,lineMetrics:r.lineMetrics||!1,generateId:r.generateId||!1,promoteId:typeof r.promoteId==`string`?r.promoteId:void 0,cluster:r.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(r.clusterMaxZoom),minPoints:Math.max(2,r.clusterMinPoints||2),extent:_.a5,radius:this._pixelsToTileUnits(r.clusterRadius||50),log:!1,generateId:r.generateId||!1}},clusterProperties:r.clusterProperties,filter:r.filter},r.workerOptions)}_hasPendingWorkerUpdate(){return this._pendingWorkerUpdate.data!==void 0||this._pendingWorkerUpdate.diff!==void 0||this._pendingWorkerUpdate.updateCluster}_pixelsToTileUnits(e){return e*(_.a5/this.tileSize)}_getClusterMaxZoom(e){let r=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||e===void 0||_.w(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${r}"`),r}load(){return _._(this,void 0,void 0,function*(){yield this._updateWorkerData()})}onAdd(e){this.map=e,this.load()}setData(e,r){this._data=typeof e==`string`?{url:e}:{geojson:e},this._pendingWorkerUpdate={data:e};let _=this._updateWorkerData();return r?_:this}updateData(e,r){this._pendingWorkerUpdate.diff=function(e,r){if(!e)return r||{};if(!r)return e||{};let _=me(e),v=me(r);(function(e,r){r.removeAll&&(e.add.clear(),e.update.clear(),e.remove.clear(),r.remove.clear());for(let _ of r.remove)e.add.delete(_),e.update.delete(_);for(let[_,v]of r.update){let b=e.update.get(_);b&&(r.update.set(_,pe(b,v)),e.update.delete(_))}})(_,v);let b={};if((_.removeAll||v.removeAll)&&(b.removeAll=!0),b.remove=new Set([..._.remove,...v.remove]),b.add=new Map([..._.add,...v.add]),b.update=new Map([..._.update,...v.update]),b.remove.size&&b.add.size)for(let e of b.add.keys())b.remove.delete(e);return function(e){let r={};return e.removeAll&&(r.removeAll=e.removeAll),e.remove&&(r.remove=Array.from(e.remove)),e.add&&(r.add=Array.from(e.add.values())),e.update&&(r.update=Array.from(e.update.values())),r}(b)}(this._pendingWorkerUpdate.diff,e);let _=this._updateWorkerData();return r?_:this}getData(){return _._(this,void 0,void 0,function*(){return this._data.url&&(yield this.once(`data`)),this._data.geojson?this._data.geojson:{type:`FeatureCollection`,features:Array.from(this._data.updateable.values())}})}getBounds(){return _._(this,void 0,void 0,function*(){return ve(yield this.getData())})}setClusterOptions(e){return this.workerOptions.geojsonVtOptions.cluster=e.cluster,e.clusterRadius!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),e.clusterMaxZoom!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(e.clusterMaxZoom)),this._pendingWorkerUpdate.updateCluster=!0,this._updateWorkerData(),this}getClusterExpansionZoom(e){return this.actor.sendAsync({type:`GCEZ`,data:{type:this.type,clusterId:e,source:this.id}})}getClusterChildren(e){return this.actor.sendAsync({type:`GCC`,data:{type:this.type,clusterId:e,source:this.id}})}getClusterLeaves(e,r,_){return this.actor.sendAsync({type:`GCL`,data:{type:this.type,source:this.id,clusterId:e,limit:r,offset:_}})}_updateWorkerData(){return _._(this,void 0,void 0,function*(){if(this._isUpdatingWorker)return;if(!this._hasPendingWorkerUpdate())return void _.w(`No pending worker updates for GeoJSONSource ${this.id}.`);let{data:e,diff:r,updateCluster:v}=this._pendingWorkerUpdate,b=this._getLoadGeoJSONParameters(e,r,v);e===void 0?r?this._pendingWorkerUpdate.diff=void 0:v&&(this._pendingWorkerUpdate.updateCluster=void 0):this._pendingWorkerUpdate.data=void 0,yield this._dispatchWorkerUpdate(b)})}_getLoadGeoJSONParameters(e,r,v){return _._(this,void 0,void 0,function*(){let b=_.e({type:this.type},this.workerOptions);return typeof e==`string`?(b.request=yield this.map._requestManager.transformRequest(E.resolveURL(e),`Source`),b.request.collectResourceTiming=this._collectResourceTiming,b):e===void 0?r?(b.dataDiff=r,b):v?(b.updateCluster=!0,b):void 0:(b.data=e,b)})}_dispatchWorkerUpdate(e){return _._(this,void 0,void 0,function*(){this._isUpdatingWorker=!0,this.fire(new _.l(`dataloading`,{dataType:`source`}));try{let r=yield e,v=yield this.actor.sendAsync({type:`LD`,data:r});if(this._isUpdatingWorker=!1,this._removed||v.abandoned)return void this.fire(new _.l(`dataabort`,{dataType:`source`}));v.data&&(this._data={geojson:v.data});let b=this._applyDiffToSource(r.dataDiff),x=this._getShouldReloadTileOptions(b),C={dataType:`source`};this._applyResourceTiming(C,v),this.fire(new _.l(`data`,Object.assign(Object.assign({},C),{sourceDataType:`metadata`}))),this.fire(new _.l(`data`,Object.assign(Object.assign({},C),{sourceDataType:`content`,shouldReloadTileOptions:x})))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new _.l(`dataabort`,{dataType:`source`}));this.fire(new _.k(e))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}})}_applyResourceTiming(e,r){var v;if(!this._collectResourceTiming)return;let b=(v=r.resourceTiming)?.[this.id];if(!b)return;let x=b.slice(0);x?.length&&_.e(e,{resourceTiming:x})}_applyDiffToSource(e){if(!e)return;let r=typeof this.promoteId==`string`?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){let e=function(e,r){let _=/* @__PURE__ */ new Map;if(e==null||e.type==null)return _;if(e.type===`Feature`){let v=fe(e,r);return v==null?void 0:(_.set(v,e),_)}if(e.type===`FeatureCollection`){let v=/* @__PURE__ */ new Set;for(let b of e.features){let e=fe(b,r);if(e==null||v.has(e))return;v.add(e),_.set(e,b)}return _}}(this._data.geojson,r);if(!e)throw Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:e}}if(!this._data.updateable)return;let _=function(e,r,_){var v,b;let x=[];if(r.removeAll)e.clear();else if(r.remove)for(let _ of r.remove){let r=e.get(_);r&&(x.push(r.geometry),e.delete(_))}if(r.add)for(let v of r.add){let r=fe(v,_);if(r==null)continue;let b=e.get(r);b&&x.push(b.geometry),x.push(v.geometry),e.set(r,v)}if(r.update)for(let _ of r.update){let r=e.get(_.id);if(!r)continue;let C=!!_.newGeometry,T=_.removeAllProperties||(v=_.removeProperties)?.length>0||(b=_.addOrUpdateProperties)?.length>0;if(!C&&!T)continue;x.push(r.geometry);let E=Object.assign({},r);if(e.set(_.id,E),C&&(x.push(_.newGeometry),E.geometry=_.newGeometry),T){if(E.properties=_.removeAllProperties?{}:Object.assign({},E.properties||{}),_.removeProperties)for(let e of _.removeProperties)delete E.properties[e];if(_.addOrUpdateProperties)for(let{key:e,value:r}of _.addOrUpdateProperties)E.properties[e]=r}}return x}(this._data.updateable,e,r);return e.removeAll||this._options.cluster?void 0:_}_getShouldReloadTileOptions(e){if(e)return{affectedBounds:e.filter(Boolean).map(e=>ve(e))}}shouldReloadTile(e,{affectedBounds:r}){if(e.state===`loading`)return!0;if(e.state===`unloaded`)return!1;let{buffer:v,extent:b}=this.workerOptions.geojsonVtOptions,x=function({x:e,y:r,z:v},b=0){let x=_.a3((e-b)/2**v),C=_.a4((r+1+b)/2**v),T=_.a3((e+1+b)/2**v),E=_.a4((r-b)/2**v);return new N([x,C],[T,E])}(e.tileID.canonical,v/b);for(let e of r)if(x.intersects(e))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(e){return _._(this,void 0,void 0,function*(){let r=e.actor?`RT`:`LT`;e.actor=this.actor;let _={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;let v=yield this.actor.sendAsync({type:r,data:_},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(v,this.map.painter,r===`RT`)})}abortTile(e){return _._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0})}unloadTile(e){return _._(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 _.e({},this._options,{type:this.type,data:this._data.updateable?{type:`FeatureCollection`,features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}}class J extends _.E{constructor(e,r,_,v){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=_,this.coordinates=r.coordinates,this.type=`image`,this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(v),this.options=r}load(e){return _._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new _.l(`dataloading`,{dataType:`source`})),this.url=this.options.url,this._request=new AbortController;try{let r=yield k.getImage(yield this.map._requestManager.transformRequest(this.url,`Image`),this._request);this._request=null,this._loaded=!0,r&&r.data&&(this.image=r.data,e&&(this.coordinates=e),this._finishLoading())}catch(e){this._request=null,this._loaded=!0,_.Z(e)||this.fire(new _.k(e))}})}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&=(this._request.abort(),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 _.l(`data`,{dataType:`source`,sourceDataType:`metadata`})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&=(this._request.abort(),null)}setCoordinates(e){this.coordinates=e;let r=e.map(_.a6.fromLngLat);var v;return this.tileID=function(e){let r=_.a7.fromPoints(e),v=r.width(),b=r.height(),x=Math.max(v,b),C=Math.max(0,Math.floor(-Math.log(x)/Math.LN2)),T=2**C;return new _.a9(C,Math.floor((r.minX+r.maxX)/2*T),Math.floor((r.minY+r.maxY)/2*T))}(r),this.terrainTileRanges=this._getOverlappingTileRanges(r),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=r.map(e=>this.tileID.getTilePoint(e)._round()),this.flippedWindingOrder=((v=this.tileCoords)[1].x-v[0].x)*(v[2].y-v[0].y)-(v[1].y-v[0].y)*(v[2].x-v[0].x)<0,this.fire(new _.l(`data`,{dataType:`source`,sourceDataType:`content`})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;let e=this.map.painter.context,r=e.gl;this.texture||(this.texture=new _.T(e,this.image,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let v=!1;for(let e in this.tiles){let r=this.tiles[e];r.state!==`loaded`&&(r.state=`loaded`,r.texture=this.texture,v=!0)}v&&this.fire(new _.l(`data`,{dataType:`source`,sourceDataType:`idle`,sourceId:this.id}))}loadTile(e){return _._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state=`errored`})}serialize(){return{type:`image`,url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){let{minX:r,minY:v,maxX:b,maxY:x}=_.a7.fromPoints(e),C={};for(let e=0;e<=_.a8;e++){let _=2**e,T=Math.floor(r*_),E=Math.floor(v*_),D=Math.floor(b*_),O=Math.floor(x*_),k=(T%_+_)%_,A=D%_;C[e]={minWrap:Math.floor(T/_),maxWrap:Math.floor(D/_),minTileXWrapped:k,maxTileXWrapped:A,minTileY:E,maxTileY:O}}return C}}class ee extends J{constructor(e,r,_,v){super(e,r,_,v),this._onPlayingHandler=()=>{var e;(e=this.map)==null||e.triggerRepaint()},this.roundZoom=!0,this.type=`video`,this.options=r}load(){return _._(this,void 0,void 0,function*(){this._loaded=!1;let e=this.options;this.urls=[];for(let r of e.urls)this.urls.push((yield this.map._requestManager.transformRequest(r,`Source`)).url);try{let e=yield _.aa(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener(`playing`,this._onPlayingHandler),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new _.k(e))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){let r=this.video.seekable;er.end(0)?this.fire(new _.k(new _.ab(`sources.${this.id}`,null,`Playback for this video can be set only between the ${r.start(0)} and ${r.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)))}onRemove(){super.onRemove(),this.video&&(this.video.removeEventListener(`playing`,this._onPlayingHandler),this.video.pause())}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;let e=this.map.painter.context,r=e.gl;this.texture?this.video.paused||(this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,this.video)):(this.texture=new _.T(e,this.video,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let v=!1;for(let e in this.tiles){let r=this.tiles[e];r.state!==`loaded`&&(r.state=`loaded`,r.texture=this.texture,v=!0)}v&&this.fire(new _.l(`data`,{dataType:`source`,sourceDataType:`idle`,sourceId:this.id}))}serialize(){return{type:`video`,urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class te extends J{constructor(e,r,v,b){super(e,r,v,b),r.coordinates?Array.isArray(r.coordinates)&&r.coordinates.length===4&&!r.coordinates.some(e=>!Array.isArray(e)||e.length!==2||e.some(e=>typeof e!=`number`))||this.fire(new _.k(new _.ab(`sources.${e}`,null,`"coordinates" property must be an array of 4 longitude/latitude array pairs`))):this.fire(new _.k(new _.ab(`sources.${e}`,null,`missing required property "coordinates"`))),r.animate&&typeof r.animate!=`boolean`&&this.fire(new _.k(new _.ab(`sources.${e}`,null,`optional "animate" property must be a boolean value`))),r.canvas?typeof r.canvas==`string`||r.canvas instanceof HTMLCanvasElement||this.fire(new _.k(new _.ab(`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 _.k(new _.ab(`sources.${e}`,null,`missing required property "canvas"`))),this.options=r,this.animate=r.animate===void 0||r.animate}load(){return _._(this,void 0,void 0,function*(){this._loaded=!0,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 _.k(/* @__PURE__ */ 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(),!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 r=this.map.painter.context,v=r.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new _.T(r,this.canvas,v.RGBA,{premultiply:!0}),this.texture.bind(v.LINEAR,v.CLAMP_TO_EDGE));let b=!1;for(let e in this.tiles){let r=this.tiles[e];r.state!==`loaded`&&(r.state=`loaded`,r.texture=this.texture,b=!0)}b&&this.fire(new _.l(`data`,{dataType:`source`,sourceDataType:`idle`,sourceId:this.id}))}serialize(){return{type:`canvas`,animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}let ye={},be=e=>{switch(e){case`geojson`:return Q;case`image`:return J;case`raster`:return V;case`raster-dem`:return W;case`vector`:return G;case`video`:return ee;case`canvas`:return te}return ye[e]},xe=`RTLPluginLoaded`;class re extends _.E{constructor(){super(...arguments),this.status=`unavailable`,this.url=null,this.dispatcher=ae()}_syncState(e){return this.status=e,this.dispatcher.broadcast(`SRPS`,{pluginStatus:e,pluginURL:this.url}).catch(e=>{throw this.status=`error`,e})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status=`unavailable`,this.url=null}setRTLTextPlugin(e){return _._(this,arguments,void 0,function*(e,r=!1){if(this.url)throw Error(`setRTLTextPlugin cannot be called multiple times.`);if(this.url=E.resolveURL(e),!this.url)throw Error(`requested url ${e} is invalid`);if(this.status===`unavailable`){if(!r)return this._requestImport();this.status=`deferred`,this._syncState(this.status)}else if(this.status===`requested`)return this._requestImport()})}_requestImport(){return _._(this,void 0,void 0,function*(){yield this._syncState(`loading`),this.status=`loaded`,this.fire(new _.l(xe))})}lazyLoad(){this.status===`unavailable`?this.status=`requested`:this.status===`deferred`&&this._requestImport()}}let Se=null;function we(){return Se||=new re,Se}var ke,je;(function(e){e[e.Base=0]=`Base`,e[e.Parent=1]=`Parent`})(ke||={}),function(e){e[e.Departing=0]=`Departing`,e[e.Incoming=1]=`Incoming`}(je||={});class he{constructor(e,r){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=_.ac(),this.uses=0,this.tileSize=r,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state=`loading`}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:r,fadingParentID:_,fadeEndTime:v}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=r,this.fadingParentID=_,this.fadeEndTime=v}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=O(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return this.state===`errored`||this.state===`loaded`||this.state===`reloading`}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,r,v){if(!0!==e?.etagUnmodified)if(this.hasData()&&this.unloadVectorData(),this.state=`loaded`,e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestEncoding=e.encoding,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,r){let _={};if(!r)return _;for(let v of e){let e=v.layerIds.map(e=>r.getLayer(e)).filter(Boolean);if(e.length!==0){v.layers=e,v.stateDependentLayerIds&&(v.stateDependentLayers=v.stateDependentLayerIds.map(r=>e.filter(e=>e.id===r)[0]));for(let r of e)_[r.id]=v}}return _}(e.buckets,r?.style),this.hasSymbolBuckets=!1;for(let e in this.buckets){let r=this.buckets[e];if(r instanceof _.ae){if(this.hasSymbolBuckets=!0,!v)break;r.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let e in this.buckets){let r=this.buckets[e];if(r instanceof _.ae&&r.hasRTLText){this.hasRTLText=!0,we().lazyLoad();break}}this.queryPadding=0;for(let e in this.buckets){let _=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(e).queryRadius(_))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new _.ad;else this.state=`loaded`}unloadVectorData(){for(let e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&=null,this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.dashPositions&&=null,this.latestFeatureIndex=null,this.state=`unloaded`}getBucket(e){return this.buckets[e.id]}upload(e){for(let r in this.buckets){let _=this.buckets[r];_.uploadPending()&&_.upload(e)}let r=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new _.T(e,this.imageAtlas.image,r.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&=(this.glyphAtlasTexture=new _.T(e,this.glyphAtlasImage,r.ALPHA),null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,r,_,v,b,x,C,T,E,D,O){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:v,cameraQueryGeometry:b,scale:x,tileSize:this.tileSize,pixelPosMatrix:D,transform:T,params:C,queryPadding:this.queryPadding*E,getElevation:O},e,r,_):{}}querySourceFeatures(e,r){let v=this.latestFeatureIndex;if(!v||!v.rawTileData)return;let b=v.loadVTLayers(),x=r&&r.sourceLayer?r.sourceLayer:``,C=b[_.af]||b[x];if(!C)return;let T=_.ag(r?.filter,r?.globalState),{z:E,x:D,y:O}=this.tileID.canonical,k={z:E,x:D,y:O};for(let r=0;re)_=!1;else if(r)if(this.expirationTime({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),q=[],Y=[];if(e.renderWorldCopies&&T.allowWorldCopies())for(let e=1;e<=3;e++)q.push(K(-e)),q.push(K(e));for(q.push(K(0));q.length>0;){let j=q.pop(),z=j.x,K=j.y,X=j.fullyVisible,ne={x:z,y:K,z:j.zoom},Z=T.getTileBoundingVolume(ne,j.wrap,e.elevation,r);if(!X){let e=Ze(v,Z,b);if(e===0)continue;X=e===2}let ie=T.distanceToTile2d(x.x,x.y,ne,Z),ae=D;E&&(ae=(r.calculateTileZoom||it)(e.zoom+_.aq(e.tileSize/r.tileSize),ie,B,H,e.fov)),ae=(r.roundZoom?Math.round:Math.floor)(ae),ae=Math.max(0,ae);let oe=Math.min(ae,k);if(j.wrap=T.getWrap(C,ne,j.wrap),j.zoom>=oe){if(j.zoom>1),wrap:j.wrap,fullyVisible:X})}return Y.sort((e,r)=>e.distanceSq-r.distanceSq).map(e=>e.tileID)}let ut=_.a7.fromPoints([new _.P(0,0),new _.P(_.a5,_.a5)]);function ft(e){return e===`raster`||e===`image`||e===`video`}function pt(e,r,_,v,b,x,C){if(!r.hasData())return!1;let{tileID:T,fadingRole:E,fadingDirection:D,fadingParentID:O}=r;if(E===ke.Base&&D===je.Incoming&&O)return _[O.key]=O,!0;let k=Math.max(T.overscaledZ-b,x);for(let b=T.overscaledZ-1;b>=k;b--){let x=T.scaledTo(b),E=e.getLoadedTile(x);if(E)return r.setCrossFadeLogic({fadingRole:ke.Base,fadingDirection:je.Incoming,fadingParentID:E.tileID,fadeEndTime:v+C}),E.setCrossFadeLogic({fadingRole:ke.Parent,fadingDirection:je.Departing,fadeEndTime:v+C}),_[x.key]=x,!0}return!1}function mt(e,r,_,v,b,x){if(!r.hasData())return!1;let C=r.tileID.children(b),T=_t(e,r,C,_,v,b,x);if(T)return!0;for(let E of C)_t(e,r,E.children(b),_,v,b,x)&&(T=!0);return T}function _t(e,r,_,v,b,x,C){if(_[0].overscaledZ>=x)return!1;let T=!1;for(let x of _){let _=e.getLoadedTile(x);if(!_)continue;let{fadingRole:E,fadingDirection:D,fadingParentID:O}=_;E===ke.Base&&D===je.Departing&&O||(_.setCrossFadeLogic({fadingRole:ke.Base,fadingDirection:je.Departing,fadingParentID:r.tileID,fadeEndTime:b+C}),r.setCrossFadeLogic({fadingRole:ke.Parent,fadingDirection:je.Incoming,fadeEndTime:b+C})),v[x.key]=x,T=!0}return T}function yt(e,r,_,v){let b=e.tileID;return!!e.selfFading||!e.hasData()&&!!r.has(b)&&(e.setSelfFadeLogic(_+v),!0)}function bt(e,r){var _;e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0;let v=r.tileID.canonical.x-e.tileID.canonical.x,b=r.tileID.canonical.y-e.tileID.canonical.y,x=2**e.tileID.canonical.z,C=r.tileID.key;v===0&&b===0||Math.abs(b)>1||(Math.abs(v)>1&&(Math.abs(v+x)===1?v+=x:Math.abs(v-x)===1&&(v-=x)),r.dem&&e.dem&&(e.dem.backfillBorder(r.dem,v,b),(_=e.neighboringTiles)?.[C]&&(e.neighboringTiles[C].backfilled=!0)))}class De{constructor(){this._tiles={}}handleWrapJump(e){let r={};for(let _ in this._tiles){let v=this._tiles[_];v.tileID=v.tileID.unwrapTo(v.tileID.wrap+e),r[v.tileID.key]=v}this._tiles=r}setFeatureState(e,r){for(let _ in this._tiles)this._tiles[_].setFeatureState(e,r)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map(e=>e.tileID).sort(_.at).map(e=>e.key):Object.keys(this._tiles)}getTileById(e){return this._tiles[e]}setTile(e,r){this._tiles[e]=r}deleteTileById(e){delete this._tiles[e]}getLoadedTile(e){let r=this.getTileById(e.key);return r?.hasData()?r:null}isIdRenderable(e,r=!1){var _;return(_=this.getTileById(e))?.isRenderable(r)}getRenderableIds(e=0,r){let v=[];for(let e of this.getAllIds())this.isIdRenderable(e,r)&&v.push(this.getTileById(e));return r?v.sort((r,v)=>{let b=r.tileID,x=v.tileID,C=new _.P(b.canonical.x,b.canonical.y)._rotate(-e),T=new _.P(x.canonical.x,x.canonical.y)._rotate(-e);return b.overscaledZ-x.overscaledZ||T.y-C.y||T.x-C.x}).map(e=>e.tileID.key):v.map(e=>e.tileID).sort(_.at).map(e=>e.key)}}class Ae extends _.E{constructor(e,r,v){super(),this.id=e,this.dispatcher=v,this.on(`data`,e=>this._dataHandler(e)),this.on(`dataloading`,()=>{this._sourceErrored=!1}),this.on(`error`,()=>{this._sourceErrored=this._source.loaded()}),this._source=((e,r,_,v)=>{let b=new(be(r.type))(e,r,_,v);if(b.id!==e)throw Error(`Expected Source id to be ${e} instead of ${b.id}`);return b})(e,r,v,this),this._inViewTiles=new De,this._outOfViewCache=new _.au(0,e=>this._unloadTile(e)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new ue,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){for(let e of this._inViewTiles.getAllTiles())e.unloadVectorData();this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e),this._inViewTiles=new De}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 of this._inViewTiles.getAllTiles())if(e.state!==`loaded`&&e.state!==`errored`)return!1;return!0}getSource(){return this._source}getState(){return this._state}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,r,v){return _._(this,void 0,void 0,function*(){try{let _=yield this._source.loadTile(e);this._tileLoaded(e,r,v,_)}catch(r){e.state=`errored`,r.status===404?this.update(this.transform,this.terrain):this._source.fire(new _.k(r,{tile:e}))}})}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new _.l(`dataabort`,{tile:e,coord:e.tileID,dataType:`source`}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(let r of this._inViewTiles.getAllTiles())r.upload(e),r.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(e){var r;return this._inViewTiles.getRenderableIds((r=this.transform)?.bearingInRadians,e)}hasRenderableParent(e){let r=e.overscaledZ-1;if(r>=this._source.minzoom){let _=this.getLoadedTile(e.scaledTo(r));if(_)return this._inViewTiles.isIdRenderable(_.tileID.key)}return!1}reload(e,r=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(let _ of this._inViewTiles.getAllIds()){let v=this._inViewTiles.getTileById(_);r&&!this._source.shouldReloadTile(v,r)||(e?this._reloadTile(_,`expired`):v.state!==`errored`&&this._reloadTile(_,`reloading`))}}}_reloadTile(e,r){return _._(this,void 0,void 0,function*(){let _=this._inViewTiles.getTileById(e);_&&(_.state!==`loading`&&(_.state=r),yield this._loadTile(_,e,r))})}_tileLoaded(e,r,v,b){e.timeAdded=O(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),v===`expired`&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(r,e),b?.unmodified||(this.getSource().type===`raster-dem`&&e.dem&&function(e,r){var _,v;let b=r.getRenderableIds();for(let x of b){if(!e.neighboringTiles||!e.neighboringTiles[x])continue;let b=r.getTileById(x);e.neighboringTiles[x].backfilled||bt(e,b),(v=(_=b.neighboringTiles)?.[e.tileID.key])?.backfilled||bt(b,e)}}(e,this._inViewTiles),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new _.l(`data`,{dataType:`source`,tile:e,coord:e.tileID})))}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._inViewTiles.getTileById(e)}_retainLoadedChildren(e,r){let _=this._getLoadedDescendents(r),v=/* @__PURE__ */ new Set;for(let b of r){let r=_[b.key];if(!r?.length){v.add(b);continue}let x=b.overscaledZ+Ae.maxOverzooming,C=r.filter(e=>e.tileID.overscaledZ<=x);if(!C.length){v.add(b);continue}let T=Math.min(...C.map(e=>e.tileID.overscaledZ)),E=C.filter(e=>e.tileID.overscaledZ===T).map(e=>e.tileID);for(let r of E)e[r.key]=r;this._areDescendentsComplete(E,T,b.overscaledZ)||v.add(b)}return v}_getLoadedDescendents(e){var r;let _={};for(let v of this._inViewTiles.getAllTiles().filter(e=>e.hasData()))for(let b of e)v.tileID.isChildOf(b)&&(_[r=b.key]||(_[r]=[])).push(v);return _}_areDescendentsComplete(e,r,_){return e.length===1&&e[0].isOverscaled()?e[0].overscaledZ===r:4**(r-_)===e.length}getLoadedTile(e){return this._inViewTiles.getLoadedTile(e)}updateCacheSize(e){let r=Math.ceil(e.width/this._source.tileSize)+1,v=Math.ceil(e.height/this._source.tileSize)+1,b=Math.floor(r*v*(this._maxTileCacheZoomLevels===null?_.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),x=typeof this._maxTileCacheSize==`number`?Math.min(this._maxTileCacheSize,b):b;this._outOfViewCache.setMaxSize(x)}handleWrapJump(e){let r=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);this._prevLng=e,r&&(this._inViewTiles.handleWrapJump(r),this._resetTileReloadTimers())}update(e,r){if(!this._sourceLoaded||this._paused)return;let v;this.transform=e,this.terrain=r,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?v=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new _.a2(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(v=ot(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.type===`vector`&&this.map._zoomLevelsToOverscale!==void 0?e.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:r,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(v=v.filter(e=>this._source.hasTile(e)))):v=[],this.usedForTerrain&&(v=this._addTerrainIdealTiles(v));let b=v.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,b&&this.fire(new _.l(`data`,{sourceDataType:`idle`,dataType:`source`,sourceId:this.id}));let x=at(e,this._source),C=this._updateRetainedTiles(v,x),T=ft(this._source.type);T&&this._rasterFadeDuration>0&&!r&&function(e,r,v,b,x,C,T){let E=O(),D=_.as(r);for(let _ of r){let r=e.getTileById(_.key);r.fadingDirection!==je.Departing&&r.fadeOpacity!==0||r.resetFadeLogic(),pt(e,r,v,E,b,x,T)||mt(e,r,v,E,C,T)||yt(r,D,E,T)||r.resetFadeLogic()}}(this._inViewTiles,v,C,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),T?this._cleanUpRasterTiles(C):this._cleanUpVectorTiles(C)}_cleanUpRasterTiles(e){for(let r of this._inViewTiles.getAllIds())e[r]||this._removeTile(r)}_cleanUpVectorTiles(e){for(let r of this._inViewTiles.getAllIds()){let _=this._inViewTiles.getTileById(r);e[r]?_.clearSymbolFadeHold():_.hasSymbolBuckets?_.holdingForSymbolFade()?_.symbolFadeFinished()&&this._removeTile(r):_.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(r)}}_addTerrainIdealTiles(e){let r=[];for(let _ of e)if(_.canonical.z>this._source.minzoom){let e=_.scaledTo(_.canonical.z-1);r.push(e);let v=_.scaledTo(Math.max(this._source.minzoom,Math.min(_.canonical.z,5)));r.push(v)}return e.concat(r)}releaseSymbolFadeTiles(){for(let e of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(e).holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,r){var _;let v=/* @__PURE__ */ new Set;for(let r of e)this._addTile(r).hasData()||v.add(r);let b=e.reduce((e,r)=>(e[r.key]=r,e),{}),x=this._retainLoadedChildren(b,v),C={},T=Math.max(r-Ae.maxUnderzooming,this._source.minzoom);for(let e of x){let r=this._inViewTiles.getTileById(e.key),v=r?.wasRequested();for(let x=e.overscaledZ-1;x>=T;--x){let T=e.scaledTo(x);if(C[T.key])break;if(C[T.key]=!0,r=this.getTile(T),!r&&v&&(r=this._addTile(T)),r){let e=r.hasData();if((e||!(_=this.map)?.cancelPendingTileRequestsWhileZooming||v)&&(b[T.key]=T),v=r.wasRequested(),e)break}}}return b}_addTile(e){let r=this._inViewTiles.getTileById(e.key);if(r)return r;r=this._outOfViewCache.getAndRemove(e),r&&(r.resetFadeLogic(),this._setTileReloadTimer(e.key,r),r.tileID=e,this._state.initializeTileState(r,this.map?this.map.painter:null));let v=r;return r||(r=new he(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(r,e.key,r.state)),r.uses++,this._inViewTiles.setTile(e.key,r),v||this._source.fire(new _.l(`dataloading`,{tile:r,coord:r.tileID,dataType:`source`})),r}_setTileReloadTimer(e,r){this._clearTileReloadTimer(e);let _=r.getExpiryTimeout();_&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,`expired`),delete this._timers[e]},_))}_clearTileReloadTimer(e){let r=this._timers[e];r&&(clearTimeout(r),delete this._timers[e])}_resetTileReloadTimers(){for(let e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(let e of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(e);this._setTileReloadTimer(e,r)}}refreshTiles(e){for(let r of this._inViewTiles.getAllIds()){let _=this._inViewTiles.getTileById(r);(this._inViewTiles.isIdRenderable(r)||_.state==`errored`)&&e.some(e=>e.equals(_.tileID.canonical))&&this._reloadTile(r,`expired`)}}_removeTile(e){let r=this._inViewTiles.getTileById(e);r&&(r.uses--,this._inViewTiles.deleteTileById(e),this._clearTileReloadTimer(e),r.uses>0||(r.hasData()&&r.state!==`reloading`?this._outOfViewCache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}_dataHandler(e){e.dataType===`source`&&(e.sourceDataType===`metadata`?this._sourceLoaded=!0:e.sourceDataType===`content`&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(let e of this._inViewTiles.getAllIds())this._removeTile(e);this._outOfViewCache.reset()}tilesIn(e,r,v){let b=[],x=this.transform;if(!x)return b;let C=x.getCoveringTilesDetailsProvider().allowWorldCopies(),T=v?x.getCameraQueryGeometry(e):e,E=e=>x.screenPointToMercatorCoordinate(e,this.terrain),D=this.transformBbox(e,E,!C),O=this.transformBbox(T,E,!C),k=this.getIds(),A=_.a7.fromPoints(O);for(let e=0;ee.getTilePoint(new _.a6(r.x,r.y)));if(r.expandBy(j),r.intersects(ut)){let r=D.map(r=>e.getTilePoint(r)),_=O.map(r=>e.getTilePoint(r));b.push({tile:v,tileID:C?e:e.unwrapTo(0),queryGeometry:r,cameraQueryGeometry:_,scale:E})}}}return b}transformBbox(e,r,v){let b=e.map(r);if(v){let v=_.a7.fromPoints(e);v.shrinkBy(.001*Math.min(v.width(),v.height()));let x=v.map(r);_.a7.fromPoints(b).covers(x)||(b=b.map(e=>e.x>.5?new _.a6(e.x-1,e.y,e.z):e))}return b}getVisibleCoordinates(e){let r=this.getRenderableIds(e).map(e=>this._inViewTiles.getTileById(e).tileID);return this.transform&&this.transform.populateCache(r),r}hasTransition(){return!!this._source.hasTransition()||!(!ft(this._source.type)||!function(e,r){if(r<=0)return!1;let _=O();for(let r of e.getAllTiles())if(r.fadeEndTime>=_)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration))}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,r,v){this._state.updateState(e||=_.af,r,v)}removeFeatureState(e,r,v){this._state.removeFeatureState(e||=_.af,r,v)}getFeatureState(e,r){return this._state.getState(e||=_.af,r)}setDependencies(e,r,_){let v=this._inViewTiles.getTileById(e);v&&v.setDependencies(r,_)}reloadTilesForDependencies(e,r){for(let _ of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(_).hasDependency(e,r)&&this._reloadTile(_,`reloading`);this._outOfViewCache.filter(_=>!_.hasDependency(e,r))}areTilesLoaded(){for(let e of this._inViewTiles.getAllTiles())if(e.state!==`loaded`&&e.state!==`errored`)return!1;return!0}}Ae.maxUnderzooming=10,Ae.maxOverzooming=3;class Le{constructor(e,r){this.reset(e,r)}reset(e,r){this.points=e||[],this._distances=[0];for(let e=1;e0?(b-C)/T:0;return this.points[x].mult(1-E).add(this.points[r].mult(E))}}function wt(e,r){let _=!0;return e===`always`||e!==`never`&&r!==`never`||(_=!1),_}class Fe{constructor(e,r,_){let v=this.boxCells=[],b=this.circleCells=[];this.xCellCount=Math.ceil(e/_),this.yCellCount=Math.ceil(r/_);for(let e=0;ethis.width||v<0||r>this.height)return[];let T=[];if(e<=0&&r<=0&&this.width<=_&&this.height<=v){if(b)return[{key:null,x1:e,y1:r,x2:_,y2:v}];for(let e=0;e0}hitTestCircle(e,r,_,v,b){let x=e-_,C=e+_,T=r-_,E=r+_;if(C<0||x>this.width||E<0||T>this.height)return!1;let D=[];return this._forEachCell(x,T,C,E,this._queryCellCircle,D,{hitTest:!0,overlapMode:v,circle:{x:e,y:r,radius:_},seenUids:{box:{},circle:{}}},b),D.length>0}_queryCell(e,r,_,v,b,x,C,T){let{seenUids:E,hitTest:D,overlapMode:O}=C,k=this.boxCells[b],A=1e-6;if(k!==null){let b=this.bboxes;for(let C of k)if(!E.box[C]){E.box[C]=!0;let k=4*C,j=this.boxKeys[C];if(e<=b[k+2]+A&&r<=b[k+3]+A&&_>=b[k+0]-A&&v>=b[k+1]-A&&(!T||T(j))&&(!D||!wt(O,j.overlapMode))&&(x.push({key:j,x1:b[k],y1:b[k+1],x2:b[k+2],y2:b[k+3]}),D))return!0}}let j=this.circleCells[b];if(j!==null){let b=this.circles;for(let C of j)if(!E.circle[C]){E.circle[C]=!0;let k=3*C,A=this.circleKeys[C];if(this._circleAndRectCollide(b[k],b[k+1],b[k+2],e,r,_,v)&&(!T||T(A))&&(!D||!wt(O,A.overlapMode))){let e=b[k],r=b[k+1],_=b[k+2];if(x.push({key:A,x1:e-_,y1:r-_,x2:e+_,y2:r+_}),D)return!0}}}return!1}_queryCellCircle(e,r,_,v,b,x,C,T){let{circle:E,seenUids:D,overlapMode:O}=C,k=this.boxCells[b];if(k!==null){let e=this.bboxes;for(let r of k)if(!D.box[r]){D.box[r]=!0;let _=4*r,v=this.boxKeys[r];if(this._circleAndRectCollide(E.x,E.y,E.radius,e[_+0],e[_+1],e[_+2],e[_+3])&&(!T||T(v))&&!wt(O,v.overlapMode))return x.push(!0),!0}}let A=this.circleCells[b];if(A!==null){let e=this.circles;for(let r of A)if(!D.circle[r]){D.circle[r]=!0;let _=3*r,v=this.circleKeys[r];if(this._circlesCollide(e[_],e[_+1],e[_+2],E.x,E.y,E.radius)&&(!T||T(v))&&!wt(O,v.overlapMode))return x.push(!0),!0}}}_forEachCell(e,r,_,v,b,x,C,T){let E=this._convertToXCellCoord(e),D=this._convertToYCellCoord(r),O=this._convertToXCellCoord(_),k=this._convertToYCellCoord(v);for(let A=E;A<=O;A++)for(let E=D;E<=k;E++)if(b.call(this,e,r,_,v,this.xCellCount*E+A,x,C,T))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,r,_,v,b,x){let C=v-e,T=b-r,E=_+x;return E*E>C*C+T*T}_circleAndRectCollide(e,r,_,v,b,x,C){let T=(x-v)/2,E=Math.abs(e-(v+T));if(E>T+_)return!1;let D=(C-b)/2,O=Math.abs(r-(b+D));if(O>D+_)return!1;if(E<=T||O<=D)return!0;let k=E-T,A=O-D;return k*k+A*A<=_*_}}function kt(e,r,v){let x=_.N();if(!e){let{vecSouth:e,vecEast:_}=Ft(r),v=b();v[0]=_[0],v[1]=_[1],v[2]=e[0],v[3]=e[1],C=v,(A=(E=(T=v)[0])*(k=T[3])-(O=T[2])*(D=T[1]))&&(C[0]=k*(A=1/A),C[1]=-D*A,C[2]=-O*A,C[3]=E*A),x[0]=v[0],x[1]=v[1],x[4]=v[2],x[5]=v[3]}var C,T,E,D,O,k,A;return _.Q(x,x,[1/v,1/v,1]),x}function jt(e,r,v,b){if(e){let e=_.N();if(!r){let{vecSouth:r,vecEast:_}=Ft(v);e[0]=_[0],e[1]=_[1],e[4]=r[0],e[5]=r[1]}return _.Q(e,e,[b,b,1]),e}return v.pixelsToClipSpaceMatrix}function Ft(e){let r=Math.cos(e.rollInRadians),v=Math.sin(e.rollInRadians),b=Math.cos(e.pitchInRadians),x=Math.cos(e.bearingInRadians),C=Math.sin(e.bearingInRadians),T=_.az();T[0]=-x*b*v-C*r,T[1]=-C*b*v+x*r;let E=_.aA(T);E<1e-9?_.aB(T):_.aC(T,T,1/E);let D=_.az();D[0]=x*b*r-C*v,D[1]=C*b*r+x*v;let O=_.aA(D);return O<1e-9?_.aB(D):_.aC(D,D,1/O),{vecEast:D,vecSouth:T}}function $(e,r,v,b){let x;b?(x=[e,r,b(e,r),1],_.aE(x,x,v)):(x=[e,r,0,1],_n(x,x,v));let C=x[3];return{point:new _.P(x[0]/C,x[1]/C),signedDistanceFromCamera:C,isOccluded:!1}}function Lt(e,r){return .5+e/r*.5}function Rt(e,r){return e.x>=-r[0]&&e.x<=r[0]&&e.y>=-r[1]&&e.y<=r[1]}function zt(e,r,v,b,x,C,T,E,D,O,k,A,j){let F=v?e.textSizeData:e.iconSizeData,R=_.av(F,r.transform.zoom),z=[256/r.width*2+1,256/r.height*2+1],B=v?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;B.clear();let H=e.lineVertexArray,K=v?e.text.placedSymbolArray:e.icon.placedSymbolArray,q=r.transform.width/r.transform.height,Y=!1;for(let v=0;vMath.abs(v.x-r.x)*b?{useVertical:!0}:(e===_.aw.vertical?r.yv.x)?{needsFlipping:!0}:null}function Yt(e){let{projectionContext:r,pitchedLabelPlaneMatrixInverse:v,symbol:b,fontSize:x,flip:C,keepUpright:T,glyphOffsetArray:E,dynamicLayoutVertexArray:D,aspectRatio:O,rotateToLine:k}=e,A=x/24,j=b.lineOffsetX*A,F=b.lineOffsetY*A,R;if(b.numGlyphs>1){let e=b.glyphStartIndex+b.numGlyphs,_=b.lineStartIndex,x=b.lineStartIndex+b.lineLength,D=Ht(A,E,j,F,C,b,k,r);if(!D)return{notEnoughRoom:!0};let z=ln(D.first.point.x,D.first.point.y,r,v),B=ln(D.last.point.x,D.last.point.y,r,v);if(T&&!C){let e=qt(b.writingMode,z,B,O);if(e)return e}R=[D.first];for(let v=b.glyphStartIndex+1;v0?T.point:Zt(r.tileAnchorPoint,C,e,1,r),D=ln(e.x,e.y,r,v),k=ln(E.x,E.y,r,v),A=qt(b.writingMode,D,k,O);if(A)return A}let e=mn(A*E.getoffsetX(b.glyphStartIndex),j,F,C,b.segment,b.lineStartIndex,b.lineStartIndex+b.lineLength,r,k);if(!e||r.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};R=[e]}for(let e of R)_.aD(D,e.point,e.angle);return{}}function Zt(e,r,_,v,b){let x=e.add(e.sub(r)._unit()),C=cn(x.x,x.y,b).point,T=_.sub(C);return _.add(T._mult(v/T.mag()))}function $t(e,r,v){let b=r.projectionCache;if(b.projections[e])return b.projections[e];let x=new _.P(r.lineVertexArray.getx(e),r.lineVertexArray.gety(e)),C=cn(x.x,x.y,r);if(C.signedDistanceFromCamera>0)return b.projections[e]=C.point,b.anyProjectionOccluded=b.anyProjectionOccluded||C.isOccluded,C.point;let T=e-v.direction;return Zt(v.distanceFromAnchor===0?r.tileAnchorPoint:new _.P(r.lineVertexArray.getx(T),r.lineVertexArray.gety(T)),x,v.previousVertex,v.absOffsetX-v.distanceFromAnchor+1,r)}function cn(e,r,_){let v=e+_.translation[0],b=r+_.translation[1],x;return _.pitchWithMap?(x=$(v,b,_.pitchedLabelPlaneMatrix,_.getElevation),x.isOccluded=!1):(x=_.transform.projectTileCoordinates(v,b,_.unwrappedTileID,_.getElevation),x.point.x=(.5*x.point.x+.5)*_.width,x.point.y=(.5*-x.point.y+.5)*_.height),x}function ln(e,r,v,b){if(v.pitchWithMap){let x=[e,r,0,1];return _.aE(x,x,b),v.transform.projectTileCoordinates(x[0]/x[3],x[1]/x[3],v.unwrappedTileID,v.getElevation).point}return{x:e/v.width*2-1,y:1-r/v.height*2}}function dn(e,r,_){return _.transform.projectTileCoordinates(e,r,_.unwrappedTileID,_.getElevation)}function fn(e,r,_){return e._unit()._perp()._mult(r*_)}function pn(e,r,v,b,x,C,T,E,D){if(E.projectionCache.offsets[e])return E.projectionCache.offsets[e];let O=v.add(r);if(e+D.direction=x)return E.projectionCache.offsets[e]=O,O;let k=$t(e+D.direction,E,D),A=fn(k.sub(v),T,D.direction),j=v.add(A),F=k.add(A);return E.projectionCache.offsets[e]=_.aF(C,O,j,F)||O,E.projectionCache.offsets[e]}function mn(e,r,_,v,b,x,C,T,E){let D=v?e-r:e+r,O=D>0?1:-1,k=0;v&&(O*=-1,k=Math.PI),O<0&&(k+=Math.PI);let A,j=O>0?x+b:x+b+1;T.projectionCache.cachedAnchorPoint?A=T.projectionCache.cachedAnchorPoint:(A=cn(T.tileAnchorPoint.x,T.tileAnchorPoint.y,T).point,T.projectionCache.cachedAnchorPoint=A);let F,R,z=A,B=A,H=0,K=0,q=Math.abs(D),Y=[],X;for(;H+K<=q;){if(j+=O,j=C)return null;H+=K,B=z,R=F;let e={absOffsetX:q,direction:O,distanceFromAnchor:H,previousVertex:B};if(z=$t(j,T,e),_===0)Y.push(B),X=z.sub(B);else{let r,v=z.sub(B);r=v.mag()===0?fn($t(j+O,T,e).sub(z),_,O):fn(v,_,O),R||=B.add(r),F=pn(j,r,z,x,C,R,_,T,e),Y.push(R),X=F.sub(R)}K=X.mag()}let ne=X._mult((q-H)/K)._add(R||B),Z=k+Math.atan2(z.y-B.y,z.x-B.x);return Y.push(ne),{point:ne,angle:E?Z:0,path:Y}}let hn=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function gn(e,r){for(let _=0;_=1;e--)j.push(C.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0)?[]:e.map(e=>e.point)}let z=[];if(j.length>0){let e=j[0].clone(),r=j[0].clone();for(let _=1;_=v.x&&r.x<=b.x&&e.y>=v.y&&r.y<=b.y?[j]:r.xb.x||r.yb.y?[]:_.aG([j],v.x,v.y,b.x,b.y)}for(let _ of z){x.reset(_,.25*r);let v=0;v=x.length<=.5*r?1:Math.ceil(x.paddedLength/F)+1;for(let _=0;__&&(_=b,r=v));return e.slice(r,r+_)}(function(e,r){let v=_.N();return _.ay(v,r.pitchedLabelPlaneMatrix),e.map(e=>{let _=$(e.x,e.y,v,r.getElevation),b=r.transform.projectTileCoordinates(_.point.x,_.point.y,r.unwrappedTileID,r.getElevation);return b.point.x=(.5*b.point.x+.5)*r.width,b.point.y=(.5*-b.point.y+.5)*r.height,b})}(e,r))}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};let r=[],v=new _.a7;for(let b of e){let e=new _.P(b.x+100,b.y+100);v.extend(e),r.push(e)}let{minX:b,minY:x,maxX:C,maxY:T}=v,E=this.grid.query(b,x,C,T).concat(this.ignoredGrid.query(b,x,C,T)),D={},O={};for(let e of E){let v=e.key;if(D[v.bucketInstanceId]===void 0&&(D[v.bucketInstanceId]={}),D[v.bucketInstanceId][v.featureIndex])continue;let b=[new _.P(e.x1,e.y1),new _.P(e.x2,e.y1),new _.P(e.x2,e.y2),new _.P(e.x1,e.y2)];_.aH(r,b)&&(D[v.bucketInstanceId][v.featureIndex]=!0,O[v.bucketInstanceId]===void 0&&(O[v.bucketInstanceId]=[]),O[v.bucketInstanceId].push(v.featureIndex))}return O}insertCollisionBox(e,r,_,v,b,x){(_?this.ignoredGrid:this.grid).insert({bucketInstanceId:v,featureIndex:b,collisionGroupID:x,overlapMode:r},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,r,_,v,b,x){let C=_?this.ignoredGrid:this.grid,T={bucketInstanceId:v,featureIndex:b,collisionGroupID:x,overlapMode:r};for(let r=0;r=this.screenRightBoundary||v<100||r>this.screenBottomBoundary}isInsideGrid(e,r,_,v){return _>=0&&e=0&&rthis.projectAndGetPerspectiveRatio(e.x,e.y,b,D,k));ce=e.some(e=>!e.isOccluded),se=e.map(e=>new _.P(e.x,e.y))}else ce=!0;return{box:_.aI(se),allPointsOccluded:!ce}}}class st{constructor(e,r,_,v){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?r:-r))):v&&_?1:0,this.placed=_}isHidden(){return this.opacity===0&&!this.placed}}class nt{constructor(e,r,_,v,b){this.text=new st(e?e.text:null,r,_,b),this.icon=new st(e?e.icon:null,r,v,b)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class lt{constructor(e,r,_){this.text=e,this.icon=r,this.skipFade=_}}class ct{constructor(e,r,_,v,b){this.bucketInstanceId=e,this.featureIndex=r,this.sourceLayerIndex=_,this.bucketIndex=v,this.tileID=b}}class ht{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 r=++this.maxGroupID;this.collisionGroups[e]={ID:r,predicate:e=>e.collisionGroupID===r}}return this.collisionGroups[e]}}function bn(e,r,v,b,x){let{horizontalAlign:C,verticalAlign:T}=_.aP(e);return new _.P(-(C-.5)*r+b[0]*x,-(T-.5)*v+b[1]*x)}class dt{constructor(e,r,_,v,b){this.transform=e.clone(),this.terrain=r,this.collisionIndex=new rt(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=_,this.retainedQueryData={},this.collisionGroups=new ht(v),this.collisionCircleArrays={},this.collisionBoxArrays=/* @__PURE__ */ new Map,this.prevPlacement=b,b&&(b.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){let r=this.terrain;return r?(_,v)=>r.getElevation(e,_,v):null}getBucketParts(e,r,v,b){let x=v.getBucket(r),C=v.latestFeatureIndex;if(!x||!C||r.id!==x.layerIds[0])return;let T=v.collisionBoxArray,E=x.layers[0].layout,D=x.layers[0].paint,O=2**(this.transform.zoom-v.tileID.overscaledZ),k=v.tileSize/_.a5,A=v.tileID.toUnwrapped(),j=E.get(`text-rotation-alignment`)===`map`,F=_.aK(v,1,this.transform.zoom),R=_.aL(this.collisionIndex.transform,v,D.get(`text-translate`),D.get(`text-translate-anchor`)),z=_.aL(this.collisionIndex.transform,v,D.get(`icon-translate`),D.get(`icon-translate-anchor`)),B=kt(j,this.transform,F);this.retainedQueryData[x.bucketInstanceId]=new ct(x.bucketInstanceId,C,x.sourceLayerIndex,x.index,v.tileID);let H={bucket:x,layout:E,translationText:R,translationIcon:z,unwrappedTileID:A,pitchedLabelPlaneMatrix:B,scale:O,textPixelRatio:k,holdingForFade:v.holdingForSymbolFade(),collisionBoxArray:T,partiallyEvaluatedTextSize:_.av(x.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(x.sourceID)};if(b)for(let r of x.sortKeyRanges){let{sortKey:_,symbolInstanceStart:v,symbolInstanceEnd:b}=r;e.push({sortKey:_,symbolInstanceStart:v,symbolInstanceEnd:b,parameters:H})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:x.symbolInstances.length,parameters:H})}attemptAnchorPlacement(e,r,v,b,x,C,T,E,D,O,k,A,j,F,R,z,B,H,K,q){let Y=_.aM[e.textAnchor],X=[e.textOffset0,e.textOffset1],ne=bn(Y,v,b,X,x),Z=this.collisionIndex.placeCollisionBox(r,A,E,D,O,T,C,z,k.predicate,K,ne,q);if((!H||this.collisionIndex.placeCollisionBox(H,A,E,D,O,T,C,B,k.predicate,K,ne,q).placeable)&&Z.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[j.crossTileID]&&this.prevPlacement.placements[j.crossTileID]&&this.prevPlacement.placements[j.crossTileID].text&&(e=this.prevPlacement.variableOffsets[j.crossTileID].anchor),j.crossTileID===0)throw Error(`symbolInstance.crossTileID can't be 0`);return this.variableOffsets[j.crossTileID]={textOffset:X,width:v,height:b,anchor:Y,textBoxScale:x,prevAnchor:e},this.markUsedJustification(F,Y,j,R),F.allowVerticalPlacement&&(this.markUsedOrientation(F,R,j),this.placedOrientations[j.crossTileID]=R),{shift:ne,placedGlyphBoxes:Z}}}placeLayerBucketPart(e,r,v){let{bucket:b,layout:x,translationText:C,translationIcon:T,unwrappedTileID:E,pitchedLabelPlaneMatrix:D,textPixelRatio:O,holdingForFade:k,collisionBoxArray:A,partiallyEvaluatedTextSize:j,collisionGroup:F}=e.parameters,R=x.get(`text-optional`),z=x.get(`icon-optional`),B=_.aN(x,`text-overlap`,`text-allow-overlap`),H=B===`always`,K=_.aN(x,`icon-overlap`,`icon-allow-overlap`),q=K===`always`,Y=x.get(`text-rotation-alignment`)===`map`,X=x.get(`text-pitch-alignment`)===`map`,ne=x.get(`icon-text-fit`)!==`none`,Z=x.get(`symbol-z-order`)===`viewport-y`,ie=H&&(q||!b.hasIconData()||z),ae=q&&(H||!b.hasTextData()||R);!b.collisionArrays&&A&&b.deserializeCollisionBoxes(A);let oe=this.retainedQueryData[b.bucketInstanceId].tileID,se=this._getTerrainElevationFunc(oe),ce=this.transform.getFastPathSimpleProjectionMatrix(oe),le=(e,A,q)=>{var Z,le;if(r[e.crossTileID])return;if(k)return void(this.placements[e.crossTileID]=new lt(!1,!1,!1));let de=!1,fe=!1,pe=!0,me=null,ge={box:null,placeable:!1,offscreen:null,occluded:!1},_e={placeable:!1},ve=null,ye=null,be=null,xe=0,Se=0,we=0;A.textFeatureIndex?xe=A.textFeatureIndex:e.useRuntimeCollisionCircles&&(xe=e.featureIndex),A.verticalTextFeatureIndex&&(Se=A.verticalTextFeatureIndex);let ke=A.textBox;if(ke){let r=r=>{let v=_.aw.horizontal;if(b.allowVerticalPlacement&&!r&&this.prevPlacement){let r=this.prevPlacement.placedOrientations[e.crossTileID];r&&(this.placedOrientations[e.crossTileID]=r,v=r,this.markUsedOrientation(b,v,e))}return v},x=(r,v)=>{if(b.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&A.verticalTextBox){for(let e of b.writingModes)if(e===_.aw.vertical?(ge=v(),_e=ge):ge=r(),ge&&ge.placeable)break}else ge=r()},D=e.textAnchorOffsetStartIndex,k=e.textAnchorOffsetEndIndex;if(k===D){let v=(r,_)=>{let v=this.collisionIndex.placeCollisionBox(r,B,O,oe,E,X,Y,C,F.predicate,se,void 0,ce);return v&&v.placeable&&(this.markUsedOrientation(b,_,e),this.placedOrientations[e.crossTileID]=_),v};x(()=>v(ke,_.aw.horizontal),()=>{let r=A.verticalTextBox;return b.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&r?v(r,_.aw.vertical):{box:null,offscreen:null}}),r(ge&&ge.placeable)}else{let j=_.aM[(le=(Z=this.prevPlacement)?.variableOffsets[e.crossTileID])?.anchor],R=(r,_,x)=>{let A=r.x2-r.x1,R=r.y2-r.y1,z=e.textBoxScale,H=ne&&K===`never`?_:null,q=null,Z=B===`never`?1:2,ie=`never`;j&&Z++;for(let _=0;_R(ke,A.iconBox,_.aw.horizontal),()=>{let r=A.verticalTextBox;return b.allowVerticalPlacement&&(!ge||!ge.placeable)&&e.numVerticalGlyphVertices>0&&r?R(r,A.verticalIconBox,_.aw.vertical):{box:null,occluded:!0,offscreen:null}}),ge&&(de=ge.placeable,pe=ge.offscreen);let z=r(ge&&ge.placeable);if(!de&&this.prevPlacement){let r=this.prevPlacement.variableOffsets[e.crossTileID];r&&(this.variableOffsets[e.crossTileID]=r,this.markUsedJustification(b,r.anchor,e,z))}}}if(ve=ge,de=ve&&ve.placeable,pe=ve&&ve.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){let r=b.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),T=_.ax(b.textSizeData,j,r),O=x.get(`text-padding`);ye=this.collisionIndex.placeCollisionCircles(B,r,b.lineVertexArray,b.glyphOffsetArray,T,E,D,v,X,F.predicate,e.collisionCircleDiameter,O,C,se),ye.circles.length&&ye.collisionDetected&&!v&&_.w(`Collisions detected, but collision boxes are not shown`),de=H||ye.circles.length>0&&!ye.collisionDetected,pe&&=ye.offscreen}if(A.iconFeatureIndex&&(we=A.iconFeatureIndex),A.iconBox){let e=e=>this.collisionIndex.placeCollisionBox(e,K,O,oe,E,X,Y,T,F.predicate,se,ne&&me?me:void 0,ce);_e&&_e.placeable&&A.verticalIconBox?(be=e(A.verticalIconBox),fe=be.placeable):(be=e(A.iconBox),fe=be.placeable),pe&&=be.offscreen}let je=R||e.numHorizontalGlyphVertices===0&&e.numVerticalGlyphVertices===0,Me=z||e.numIconVertices===0;je||Me?Me?je||(fe&&=de):de=fe&&de:fe=de=fe&&de;let Ne=fe&&be.placeable;if(de&&ve.placeable&&this.collisionIndex.insertCollisionBox(ve.box,B,x.get(`text-ignore-placement`),b.bucketInstanceId,_e&&_e.placeable&&Se?Se:xe,F.ID),Ne&&this.collisionIndex.insertCollisionBox(be.box,K,x.get(`icon-ignore-placement`),b.bucketInstanceId,we,F.ID),ye&&de&&this.collisionIndex.insertCollisionCircles(ye.circles,B,x.get(`text-ignore-placement`),b.bucketInstanceId,xe,F.ID),v&&this.storeCollisionData(b.bucketInstanceId,q,A,ve,be,ye),e.crossTileID===0)throw Error(`symbolInstance.crossTileID can't be 0`);if(b.bucketInstanceId===0)throw Error(`bucket.bucketInstanceId can't be 0`);this.placements[e.crossTileID]=new lt((de||ie)&&!ve?.occluded,(fe||ae)&&!be?.occluded,pe||b.justReloaded),r[e.crossTileID]=!0};if(Z){if(e.symbolInstanceStart!==0)throw Error(`bucket.bucketInstanceId should be 0`);let r=b.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=r.length-1;e>=0;--e){let _=r[e];le(b.symbolInstances.get(_),b.collisionArrays[_],_)}}else for(let r=e.symbolInstanceStart;r=0&&(e.text.placedSymbolArray.get(r).crossTileID=x>=0&&r!==x?0:v.crossTileID)}markUsedOrientation(e,r,v){let b=r===_.aw.horizontal||r===_.aw.horizontalOnly?r:0,x=r===_.aw.vertical?r:0,C=[v.leftJustifiedTextSymbolIndex,v.centerJustifiedTextSymbolIndex,v.rightJustifiedTextSymbolIndex];for(let r of C)e.text.placedSymbolArray.get(r).placedOrientation=b;v.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(v.verticalPlacedTextSymbolIndex).placedOrientation=x)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;let r=this.prevPlacement,_=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;let v=r?r.symbolFadeChange(e):1,b=r?r.opacities:{},x=r?r.variableOffsets:{},C=r?r.placedOrientations:{};for(let e in this.placements){let r=this.placements[e],x=b[e];x?(this.opacities[e]=new nt(x,v,r.text,r.icon),_=_||r.text!==x.text.placed||r.icon!==x.icon.placed):(this.opacities[e]=new nt(null,v,r.text,r.icon,r.skipFade),_=_||r.text||r.icon)}for(let e in b){let r=b[e];if(!this.opacities[e]){let b=new nt(r,v,!1,!1);b.isHidden()||(this.opacities[e]=b,_=_||r.text.placed||r.icon.placed)}}for(let e in x)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=x[e]);for(let e in C)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=C[e]);if(r&&r.lastPlacementChangeTime===void 0)throw Error(`Last placement time for previous placement is not defined`);_?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!=`number`&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:e)}updateLayerOpacities(e,r){let _={};for(let v of r){let r=v.getBucket(e);r&&v.latestFeatureIndex&&e.id===r.layerIds[0]&&this.updateBucketOpacities(r,v.tileID,_,v.collisionBoxArray)}}updateBucketOpacities(e,r,v,b){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 x=e.layers[0],C=x.layout,T=new nt(null,0,!1,!1,!0),E=C.get(`text-allow-overlap`),D=C.get(`icon-allow-overlap`),O=x._unevaluatedLayout.hasValue(`text-variable-anchor`)||x._unevaluatedLayout.hasValue(`text-variable-anchor-offset`),k=C.get(`text-rotation-alignment`)===`map`,A=C.get(`text-pitch-alignment`)===`map`,j=C.get(`icon-text-fit`)!==`none`,F=new nt(null,0,E&&(D||!e.hasIconData()||C.get(`icon-optional`)),D&&(E||!e.hasTextData()||C.get(`text-optional`)),!0);!e.collisionArrays&&b&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(b);let R=(e,r,_)=>{for(let v=0;v0,H=this.placedOrientations[b.crossTileID],K=H===_.aw.vertical,q=H===_.aw.horizontal||H===_.aw.horizontalOnly;if(x>0||C>0){let r=Nn(D.text);R(e.text,x,K?In:r),R(e.text,C,q?In:r);let _=D.text.isHidden();[b.rightJustifiedTextSymbolIndex,b.centerJustifiedTextSymbolIndex,b.leftJustifiedTextSymbolIndex].forEach(r=>{r>=0&&(e.text.placedSymbolArray.get(r).hidden=_||K?1:0)}),b.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(b.verticalPlacedTextSymbolIndex).hidden=_||q?1:0);let v=this.variableOffsets[b.crossTileID];v&&this.markUsedJustification(e,v.anchor,b,H);let T=this.placedOrientations[b.crossTileID];T&&(this.markUsedJustification(e,`left`,b,T),this.markUsedOrientation(e,T,b))}if(B){let r=Nn(D.icon),_=!(j&&b.verticalPlacedIconSymbolIndex&&K);b.placedIconSymbolIndex>=0&&(R(e.icon,b.numIconVertices,_?r:In),e.icon.placedSymbolArray.get(b.placedIconSymbolIndex).hidden=D.icon.isHidden()),b.verticalPlacedIconSymbolIndex>=0&&(R(e.icon,b.numVerticalIconVertices,_?In:r),e.icon.placedSymbolArray.get(b.verticalPlacedIconSymbolIndex).hidden=D.icon.isHidden())}let Y=z&&z.has(r)?z.get(r):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){let v=e.collisionArrays[r];if(v){let r=new _.P(0,0);if(v.textBox||v.verticalTextBox){let _=!0;if(O){let e=this.variableOffsets[E];e?(r=bn(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),k&&r._rotate(A?-this.transform.bearingInRadians:this.transform.bearingInRadians)):_=!1}if(v.textBox||v.verticalTextBox){let b;v.textBox&&(b=K),v.verticalTextBox&&(b=q),Sn(e.textCollisionBox.collisionVertexArray,D.text.placed,!_||b,Y.text,r.x,r.y)}}if(v.iconBox||v.verticalIconBox){let _=!!(!q&&v.verticalIconBox),b;v.iconBox&&(b=_),v.verticalIconBox&&(b=!_),Sn(e.iconCollisionBox.collisionVertexArray,D.icon.placed,b,Y.icon,j?r.x:0,j?r.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw 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 Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return 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 Sn(e,r,_,v,b,x){v&&v.length!==0||(v=[0,0,0,0]);let C=v[0]-100,T=v[1]-100,E=v[2]-100,D=v[3]-100;e.emplaceBack(r?1:0,_?1:0,b||0,x||0,C,T),e.emplaceBack(r?1:0,_?1:0,b||0,x||0,E,T),e.emplaceBack(r?1:0,_?1:0,b||0,x||0,E,D),e.emplaceBack(r?1:0,_?1:0,b||0,x||0,C,D)}let Cn=2**25,wn=2**24,On=2**17,kn=2**16,An=2**9,jn=2**8,Mn=2**1;function Nn(e){if(e.opacity===0&&!e.placed)return 0;if(e.opacity===1&&e.placed)return 4294967295;let r=e.placed?1:0,_=Math.floor(127*e.opacity);return _*Cn+r*wn+_*On+r*kn+_*512+r*256+_*2+r}let In=0;class Tt{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,r,_,v,b){let x=this._bucketParts;for(;this._currentTileIndexe.sortKey-r.sortKey));this._currentPartIndex!this._forceFullPlacement&&O()-b>2;for(;this._currentPlacementIndex>=0;){let b=r[e[this._currentPlacementIndex]],C=this.placement.collisionIndex.transform.zoom;if(_.aQ(b)&&b.layout&&(!b.minzoom||b.minzoom<=C)&&(!b.maxzoom||b.maxzoom>C)){if(this._inProgressLayer||=new Tt(b),this._inProgressLayer.continuePlacement(v[b.source],this.placement,this._showCollisionBoxes,b,x))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}let Ln=512/_.a5/2;class It{constructor(e,r,v){this.tileID=e,this.bucketInstanceId=v,this._symbolsByKey={};let b=/* @__PURE__ */ new Map;for(let e=0;e({x:Math.floor(e.anchorX*Ln),y:Math.floor(e.anchorY*Ln)})),crossTileIDs:r.map(e=>e.crossTileID)};if(v.positions.length>128){let e=new _.aR(v.positions.length,16,Uint16Array);for(let{x:r,y:_}of v.positions)e.add(r,_);e.finish(),delete v.positions,v.index=e}this._symbolsByKey[e]=v}}getScaledCoordinates(e,r){let{x:v,y:b,z:x}=this.tileID.canonical,{x:C,y:T,z:E}=r.canonical,D=Ln/2**(E-x),O=(T*_.a5+e.anchorY)*D,k=b*_.a5*Ln;return{x:Math.floor((C*_.a5+e.anchorX)*D-v*_.a5*Ln),y:Math.floor(O-k)}}findMatches(e,r,_){let v=this.tileID.canonical.ze)}}class Mt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Et{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){let r=Math.round((e-this.lng)/360);if(r!==0)for(let e in this.indexes){let _=this.indexes[e],v={};for(let e in _){let b=_[e];b.tileID=b.tileID.unwrapTo(b.tileID.wrap+r),v[b.tileID.key]=b}this.indexes[e]=v}this.lng=e}addBucket(e,r,_){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===r.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;ee.overscaledZ)for(let _ in b){let x=b[_];x.tileID.isChildOf(e)&&x.findMatches(r.symbolInstances,e,v)}else{let x=b[e.scaledTo(Number(_)).key];x&&x.findMatches(r.symbolInstances,e,v)}}for(let e=0;e{r[e]=!0});for(let e in this.layerIndexes)r[e]||delete this.layerIndexes[e]}}var Rn=`void main() {fragColor=vec4(1.0);}`;let zn={prelude:Bn(`#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 +out highp vec4 fragColor;`,`#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;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c +);} +#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(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0)); +#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=(texture(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 +#ifdef GLOBE +if ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;} +#endif +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 +}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;`),projectionMercator:Bn(``,`float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}`),projectionGlobe:Bn(``,`#define GLOBE_RADIUS 6371008.8 +uniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos +);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); +if (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len +);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}`),background:Bn(`uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity; +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,`in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}`),backgroundPattern:Bn(`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity; +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,`uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}`),circle:Bn(`in vec3 v_data;in 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));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;} +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,`uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility; +#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 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) { +#ifdef GLOBE +vec3 center_vector=projectToSphere(circle_center); +#endif +float angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else { +#ifdef GLOBE +vec4 projected_center=interpolateProjection(circle_center,center_vector,ele); +#else +vec4 projected_center=projectTileWithElevation(circle_center,ele); +#endif +corner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);} +#ifdef GLOBE +vec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele); +#else +gl_Position=projectTileWithElevation(corner_position,ele); +#endif +} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}`),clippingMask:Bn(Rn,`in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}`),heatmap:Bn(`uniform highp float u_intensity;in 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);fragColor=vec4(val,1.0,1.0,1.0); +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,`uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude; +#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 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0); +#ifdef GLOBE +vec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0); +#else +gl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center)); +#endif +}`),heatmapTexture:Bn(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity; +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(0.0); +#endif +}`,`uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}`),collisionBox:Bn(`in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}`,`in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:Bn(`in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}`,`in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),colorRelief:Bn(`#ifdef GL_ES +precision highp float; +#endif +uniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else +{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0)); +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,`uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}`),debug:Bn(`uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}`,`in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}`),depth:Bn(Rn,`in vec2 a_pos;void main() { +#ifdef GLOBE +gl_Position=projectTileFor3D(a_pos,0.0); +#else +gl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0); +#endif +}`),fill:Bn(`#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 +fragColor=color*opacity; +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,`uniform vec2 u_fill_translate;in vec2 a_pos; +#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=projectTile(a_pos+u_fill_translate,a_pos);}`),fillOutline:Bn(`in vec2 v_pos; +#ifdef GLOBE +in float v_depth; +#endif +#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);fragColor=outline_color*(alpha*opacity); +#ifdef GLOBE +if (v_depth > 1.0) {discard;} +#endif +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,`uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos; +#ifdef GLOBE +out float v_depth; +#endif +#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=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; +#ifdef GLOBE +v_depth=gl_Position.z/gl_Position.w; +#endif +}`),fillOutlinePattern:Bn(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos; +#ifdef GLOBE +in float v_depth; +#endif +#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=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity; +#ifdef GLOBE +if (v_depth > 1.0) {discard;} +#endif +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,`uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos; +#ifdef GLOBE +out float v_depth; +#endif +#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=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; +#ifdef GLOBE +v_depth=gl_Position.z/gl_Position.w; +#endif +}`),fillPattern:Bn(`#ifdef GL_ES +precision highp float; +#endif +uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in 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=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity; +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b; +#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=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}`),fillExtrusion:Bn(`in vec4 v_color;void main() {fragColor=v_color; +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,`uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed; +#ifdef TERRAIN3D +in vec2 a_centroid; +#endif +out 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);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate; +#ifdef GLOBE +vec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation); +#else +gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0); +#endif +float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0); +#ifdef GLOBE +mat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition); +#endif +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:Bn(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting; +#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=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting; +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed; +#ifdef TERRAIN3D +in vec2 a_centroid; +#endif +#ifdef GLOBE +out vec3 v_sphere_pos; +#endif +out vec2 v_pos_a;out vec2 v_pos_b;out 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 elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate; +#ifdef GLOBE +vec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation); +#else +gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0); +#endif +vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0 +? a_pos +: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}`),hillshadePrepare:Bn(`#ifdef GL_ES +precision highp float; +#endif +uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0); +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,`uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}`),hillshade:Bn(`uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES]; +#define PI 3.141592653589793 +#define STANDARD 0 +#define COMBINED 1 +#define IGOR 2 +#define MULTIDIRECTIONAL 3 +#define BASIC 4 +float get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else +{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else +{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);} +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,`uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}`),line:Bn(`uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale; +#ifdef GLOBE +in float v_depth; +#endif +#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);fragColor=color*(alpha*opacity); +#ifdef GLOBE +if (v_depth > 1.0) {discard;} +#endif +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,` +#define scale 0.015873016 +in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar; +#ifdef GLOBE +out float v_depth; +#endif +#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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; +#ifdef GLOBE +v_depth=gl_Position.z/gl_Position.w; +#endif +#ifdef TERRAIN3D +v_gamma_scale=1.0; +#else +float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; +#endif +v_width2=vec2(outset,inset);}`),lineGradient:Bn(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv; +#ifdef GLOBE +in float v_depth; +#endif +#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=texture(u_image,v_uv);fragColor=color*(alpha*opacity); +#ifdef GLOBE +if (v_depth > 1.0) {discard;} +#endif +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,` +#define scale 0.015873016 +in vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv; +#ifdef GLOBE +out float v_depth; +#endif +#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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; +#ifdef GLOBE +v_depth=gl_Position.z/gl_Position.w; +#endif +#ifdef TERRAIN3D +v_gamma_scale=1.0; +#else +float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; +#endif +v_width2=vec2(outset,inset);}`),linePattern:Bn(`#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;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width; +#ifdef GLOBE +in float v_depth; +#endif +#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(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity; +#ifdef GLOBE +if (v_depth > 1.0) {discard;} +#endif +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,` +#define scale 0.015873016 +#define LINE_DISTANCE_SCALE 2.0 +in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width; +#ifdef GLOBE +out float v_depth; +#endif +#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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; +#ifdef GLOBE +v_depth=gl_Position.z/gl_Position.w; +#endif +#ifdef TERRAIN3D +v_gamma_scale=1.0; +#else +float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; +#endif +v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:Bn(`uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale; +#ifdef GLOBE +in float v_depth; +#endif +#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 +#pragma mapbox: define mediump vec4 dasharray_from +#pragma mapbox: define mediump vec4 dasharray_to +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 +#pragma mapbox: initialize mediump vec4 dasharray_from +#pragma mapbox: initialize mediump vec4 dasharray_to +float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity); +#ifdef GLOBE +if (v_depth > 1.0) {discard;} +#endif +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,` +#define scale 0.015873016 +#define LINE_DISTANCE_SCALE 2.0 +in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale; +#ifdef GLOBE +out float v_depth; +#endif +#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 +#pragma mapbox: define mediump vec4 dasharray_from +#pragma mapbox: define mediump vec4 dasharray_to +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 +#pragma mapbox: initialize mediump vec4 dasharray_from +#pragma mapbox: initialize mediump vec4 dasharray_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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; +#ifdef GLOBE +v_depth=gl_Position.z/gl_Position.w; +#endif +#ifdef TERRAIN3D +v_gamma_scale=1.0; +#else +float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; +#endif +float u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}`),lineGradientSDF:Bn(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv; +#ifdef GLOBE +in float v_depth; +#endif +#pragma mapbox: define lowp float blur +#pragma mapbox: define lowp float opacity +#pragma mapbox: define mediump float width +#pragma mapbox: define lowp float floorwidth +#pragma mapbox: define mediump vec4 dasharray_from +#pragma mapbox: define mediump vec4 dasharray_to +void main() { +#pragma mapbox: initialize lowp float blur +#pragma mapbox: initialize lowp float opacity +#pragma mapbox: initialize mediump float width +#pragma mapbox: initialize lowp float floorwidth +#pragma mapbox: initialize mediump vec4 dasharray_from +#pragma mapbox: initialize mediump vec4 dasharray_to +float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity); +#ifdef GLOBE +if (v_depth > 1.0) {discard;} +#endif +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,` +#define scale 0.015873016 +#define LINE_DISTANCE_SCALE 2.0 +in vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b; +#ifdef GLOBE +out float v_depth; +#endif +#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 +#pragma mapbox: define mediump vec4 dasharray_from +#pragma mapbox: define mediump vec4 dasharray_to +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 +#pragma mapbox: initialize lowp float floorwidth +#pragma mapbox: initialize mediump vec4 dasharray_from +#pragma mapbox: initialize mediump vec4 dasharray_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;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; +#ifdef GLOBE +v_depth=gl_Position.z/gl_Position.w; +#endif +#ifdef TERRAIN3D +v_gamma_scale=1.0; +#else +float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; +#endif +float u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}`),raster:Bn(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a); +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,`uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5; +#ifdef GLOBE +if (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;} +#endif +v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),symbolIcon:Bn(`uniform sampler2D u_texture;in vec2 v_tex;in float v_total_opacity;void main() {fragColor=texture(u_texture,v_tex)*v_total_opacity; +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,`in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_total_opacity; +#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);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_total_opacity=opacity*max(0.0,min(visibility,fade_opacity[0]+fade_change));if (v_total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}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; +#ifdef GLOBE +if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);} +#endif +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;}`),symbolSDF:Bn(`#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;in vec2 v_data0;in vec3 v_data1; +#pragma mapbox: define highp vec4 fill_color +#pragma mapbox: define highp vec4 halo_color +#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 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 total_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*total_opacity); +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,`in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1; +#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/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);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));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}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; +#ifdef GLOBE +if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);} +#endif +vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,total_opacity);}`),symbolTextAndIcon:Bn(`#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;in vec4 v_data0;in vec4 v_data1; +#pragma mapbox: define highp vec4 fill_color +#pragma mapbox: define highp vec4 halo_color +#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 halo_width +#pragma mapbox: initialize lowp float halo_blur +float total_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;fragColor=texture(u_texture_icon,tex_icon)*total_opacity; +#ifdef OVERDRAW_INSPECTOR +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=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*total_opacity); +#ifdef OVERDRAW_INSPECTOR +fragColor=vec4(1.0); +#endif +}`,`in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1; +#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);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));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}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; +#ifdef GLOBE +if(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);} +#endif +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;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,total_opacity,is_sdf);}`),terrain:Bn(`uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}`,`in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}`),terrainDepth:Bn(`in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}`,`in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}`),terrainCoords:Bn(`precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}`,`in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}`),projectionErrorMeasurement:Bn(`in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}`,`in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}`),atmosphere:Bn(`#ifdef GL_ES +precision highp float; +#endif +in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758 +);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}`,`in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}`),sky:Bn(`uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}`,`in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}`)};function Bn(e,r){let _=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,v=r.match(/in ([\w]+) ([\w]+)/g),b=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),x=r.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),C=x?x.concat(b):b,T={};return{fragmentSource:e=e.replace(_,(e,r,_,v,b)=>(T[b]=!0,r===`define`?`\n#ifndef HAS_UNIFORM_u_${b}\nin ${_} ${v} ${b};\n#else\nuniform ${_} ${v} u_${b};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${b}\n ${_} ${v} ${b} = u_${b};\n#endif\n`)),vertexSource:r=r.replace(_,(e,r,_,v,b)=>{let x=v===`float`?`vec2`:`vec4`,C=b.match(/color/)?`color`:x;return T[b]?r===`define`?`\n#ifndef HAS_UNIFORM_u_${b}\nuniform lowp float u_${b}_t;\nin ${_} ${x} a_${b};\nout ${_} ${v} ${b};\n#else\nuniform ${_} ${v} u_${b};\n#endif\n`:C===`vec4`?`\n#ifndef HAS_UNIFORM_u_${b}\n ${b} = a_${b};\n#else\n ${_} ${v} ${b} = u_${b};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${b}\n ${b} = unpack_mix_${C}(a_${b}, u_${b}_t);\n#else\n ${_} ${v} ${b} = u_${b};\n#endif\n`:r===`define`?`\n#ifndef HAS_UNIFORM_u_${b}\nuniform lowp float u_${b}_t;\nin ${_} ${x} a_${b};\n#else\nuniform ${_} ${v} u_${b};\n#endif\n`:C===`vec4`?`\n#ifndef HAS_UNIFORM_u_${b}\n ${_} ${v} ${b} = a_${b};\n#else\n ${_} ${v} ${b} = u_${b};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${b}\n ${_} ${v} ${b} = unpack_mix_${C}(a_${b}, u_${b}_t);\n#else\n ${_} ${v} ${b} = u_${b};\n#endif\n`}),staticAttributes:v,staticUniforms:C}}class At{constructor(e,r,_){this.vertexBuffer=e,this.indexBuffer=r,this.segments=_}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Vn=_.aS([{name:`a_pos`,type:`Int16`,components:2}]);let Hn=`#define PROJECTION_MERCATOR`,Un=`mercator`;class Bt{constructor(){this._cachedMesh=null}get name(){return`mercator`}get useSubdivision(){return!1}get shaderVariantName(){return Un}get shaderDefine(){return Hn}get shaderPreludeCode(){return zn.projectionMercator}get vertexShaderPreludeCode(){return zn.projectionMercator.vertexSource}get subdivisionGranularity(){return _.aT.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,r,v,b,x){if(this._cachedMesh)return this._cachedMesh;let C=new _.aU;C.emplaceBack(0,0),C.emplaceBack(_.a5,0),C.emplaceBack(0,_.a5),C.emplaceBack(_.a5,_.a5);let T=e.createVertexBuffer(C,Vn.members),E=_.aV.simpleSegment(0,0,4,2),D=new _.aW;return D.emplaceBack(1,0,2),D.emplaceBack(1,2,3),this._cachedMesh=new At(T,e.createIndexBuffer(D),E),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class Ot{constructor(e=0,r=0,_=0,v=0){if(isNaN(e)||e<0||isNaN(r)||r<0||isNaN(_)||_<0||isNaN(v)||v<0)throw Error(`Invalid value for edge-insets, top, bottom, left and right must all be numbers`);this.top=e,this.bottom=r,this.left=_,this.right=v}interpolate(e,r,v){return r.top!=null&&e.top!=null&&(this.top=_.G.number(e.top,r.top,v)),r.bottom!=null&&e.bottom!=null&&(this.bottom=_.G.number(e.bottom,r.bottom,v)),r.left!=null&&e.left!=null&&(this.left=_.G.number(e.left,r.left,v)),r.right!=null&&e.right!=null&&(this.right=_.G.number(e.right,r.right,v)),this}getCenter(e,r){let v=_.ak((this.left+e-this.right)/2,0,e),b=_.ak((this.top+r-this.bottom)/2,0,r);return new _.P(v,b)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Ot(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Wn(e,r){if(!e.renderWorldCopies||e.lngRange)return;let _=r.lng-e.center.lng;r.lng+=_>180?-360:_<-180?360:0}function Gn(e){return Math.max(0,Math.floor(e))}class Nt{constructor(e,r){var v;this.applyConstrain=(e,r)=>this._constrainOverride===null?this._callbacks.defaultConstrain(e,r):this._constrainOverride(e,r),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=r?.renderWorldCopies===void 0||!!r?.renderWorldCopies,this._minZoom=r?.minZoom||0,this._maxZoom=r?.maxZoom||22,this._minPitch=r?.minPitch==null?0:r?.minPitch,this._maxPitch=r?.maxPitch==null?60:r?.maxPitch,this._constrainOverride=(v=r?.constrainOverride)??null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new _.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Gn(this._zoom),this._scale=_.an(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Ot,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,r,v){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=Gn(this._zoom),this._scale=_.an(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Ot(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!v&&e.autoCalculateNearFarZ,r&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){e===void 0&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new _.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){let r=_.W(e,-180,180)*Math.PI/180;var v,x,C,T,E,D,O,k,A;this._bearingInRadians!==r&&(this._unmodified=!1,this._bearingInRadians=r,this._calcMatrices(),this._rotationMatrix=b(),v=this._rotationMatrix,C=-this._bearingInRadians,T=(x=this._rotationMatrix)[0],E=x[1],D=x[2],O=x[3],k=Math.sin(C),A=Math.cos(C),v[0]=T*A+D*k,v[1]=E*A+O*k,v[2]=T*-k+D*A,v[3]=E*-k+O*A)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){let r=_.ak(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==r&&(this._unmodified=!1,this._pitchInRadians=r,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){let r=e/180*Math.PI;this._rollInRadians!==r&&(this._unmodified=!1,this._rollInRadians=r,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return _.aX(this._fovInRadians)}setFov(e){e=_.ak(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=_.am(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){let r=this.applyConstrain(this._center,e).zoom;this._zoom!==r&&(this._unmodified=!1,this._zoom=r,this._tileZoom=Math.max(0,Math.floor(r)),this._scale=_.an(r),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,r){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=r,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,r,_){this._unmodified=!1,this._edgeInsets.interpolate(e,r,_),this.constrainInternal(),this._calcMatrices()}resize(e,r,_=!0){this._width=e,this._height=r,_&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&this._latRange.length===2&&this._lngRange&&this._lngRange.length===2?new N([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-_.al,_.al])}getCameraQueryGeometry(e,r){if(r.length===1)return[r[0],e];{let{minX:v,minY:b,maxX:x,maxY:C}=_.a7.fromPoints(r).extend(e);return[new _.P(v,b),new _.P(x,b),new _.P(x,C),new _.P(v,C),new _.P(v,b)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let e=this._unmodified,{center:r,zoom:_}=this.applyConstrain(this.center,this.zoom);this.setCenter(r),this.setZoom(_),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=_.ao(new Float64Array(16));_.Q(e,e,[this._width/2,-this._height/2,1]),_.O(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=_.ao(new Float64Array(16)),_.Q(e,e,[1,-1,1]),_.O(e,e,[-1,-1,0]),_.Q(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,r,v,b){let x=v===void 0?this.bearing:v,C=b=b===void 0?this.pitch:b,{distanceToCenter:T,clampedElevation:E}=this._distanceToCenterFromAltElevationPitch(r,this.elevation,C),{x:D,y:O}=Xe(C,x),k=_.a6.fromLngLat(e,r),A,j,F=_.aY(1,k.y),R=0;do{if(R+=1,R>10)break;j=T/F,A=new _.a6(k.x+D*j,k.y+O*j),F=1/A.meterInMercatorCoordinateUnits()}while(Math.abs(T-j*F)>1e-12);return{center:A.toLngLat(),elevation:E,zoom:_.aq(this.height/2/Math.tan(this.fovInRadians/2)/j/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;let r=1/this.worldSize,v=_.ap(1,this.center.lat)*this.worldSize,b=_.a6.fromLngLat(this.center,this.elevation),x=b.x/r,C=b.y/r,T=b.z/r,E=this.pitch,D=this.bearing,{x:O,y:k,z:A}=Xe(E,D),j=this.cameraToCenterDistance,F=x+j*-O,R=C+j*-k,z=T+j*A,{distanceToCenter:B,clampedElevation:H}=this._distanceToCenterFromAltElevationPitch(z/v,e,E),K=B*v,q=new _.a6((F+O*K)*r,(R+k*K)*r,0).toLngLat(),Y=_.ap(1,q.lat),X=_.aq(this.height/2/Math.tan(this.fovInRadians/2)/B/Y/this.tileSize);this._elevation=H,this._center=q,this.setZoom(X)}_distanceToCenterFromAltElevationPitch(e,r,v){let b=-Math.cos(_.am(v)),x=e-r,C,T=r;return b*x>=0||Math.abs(b)<.1?(C=1e4,T=e+C*b):C=-x/b,{distanceToCenter:C,clampedElevation:T}}getCameraPoint(){let e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new _.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){let e=_.ap(1,this.center.lat)*this.worldSize;return qe(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];let r=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(r+=e[v]*this.min[v],_+=e[v]*this.max[v]):(_+=e[v]*this.min[v],r+=e[v]*this.max[v]);return r>=0?2:_<0?0:1}}class Gt{distanceToTile2d(e,r,_,v){let b=v.distanceX([e,r]),x=v.distanceY([e,r]);return Math.hypot(b,x)}getWrap(e,r,_){return _}getTileBoundingVolume(e,r,v,b){var x,C;let T=0,E=0;if(b?.terrain){let D=new _.a2(e.z,r,e.z,e.x,e.y),O=b.terrain.getMinMaxElevation(D);T=(x=O.minElevation)??Math.min(0,v),E=(C=O.maxElevation)??Math.max(0,v)}let D=1<b}allowWorldCopies(){return!0}prepareNextFrame(){}}class Vt{constructor(e,r,_){this.points=e,this.planes=r,this.aabb=_}static fromInvProjectionMatrix(e,r=1,v=0,b,x){let C=x?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],T=2**v,E=[[-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(v=>function(e,r,v,b){let x=_.aE([],e,r),C=1/x[3]/v*b;return _.b4(x,x,[C,C,1/x[3],C])}(v,e,r,T));b&&function(e,r,v,b){let x=b?4:0,C=b?0:4,T=0,E=[],D=[];for(let r=0;r<4;r++){let v=_.b0([],e[r+C],e[r+x]),b=_.b5(v);_.aZ(v,v,1/b),E.push(b),D.push(v)}for(let r=0;r<4;r++){let b=_.b6(e[r+x],D[r],v);T=b!==null&&b>=0?Math.max(T,b):Math.max(T,E[r])}let O=function(e,r){let v=_.b0([],e[r[0]],e[r[1]]),b=_.b0([],e[r[2]],e[r[1]]),x=[0,0,0,0];return _.b1(x,_.b2([],v,b)),x[3]=-_.b3(x,e[r[0]]),x}(e,r),k=function(e,r){let v=_.b7(e),b=_.b8([],e,1/v),x=_.b0([],r,_.aZ([],b,_.b3(r,b))),C=_.b7(x);if(C>0){let e=Math.sqrt(1-b[3]*b[3]),v=_.aZ([],b,-b[3]),T=_.a_([],v,_.aZ([],x,e/C));return _.b9(r,T)}return null}(v,O);if(k!==null){let e=k/_.b3(D[0],O);T=Math.min(T,e)}for(let r=0;r<4;r++){let _=Math.min(T,E[r]);e[r+C]=[e[r+x][0]+D[r][0]*_,e[r+x][1]+D[r][1]*_,e[r+x][2]+D[r][2]*_,1]}}(E,C[0],b,x);let D=C.map(e=>{let r=_.b0([],E[e[0]],E[e[1]]),v=_.b0([],E[e[2]],E[e[1]]),b=_.b1([],_.b2([],r,v)),x=-_.b3(b,E[e[1]]);return b.concat(x)}),O=[1/0,1/0,1/0],k=[-1/0,-1/0,-1/0];for(let e of E)for(let r=0;r<3;r++)O[r]=Math.min(O[r],e[r]),k[r]=Math.max(k[r],e[r]);return new Vt(E,D,new Ut(O,k))}}class Wt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,r,_){return this._helper.interpolatePadding(e,r,_)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,r,_=!0){this._helper.resize(e,r,_)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,r){this._helper.overrideNearFarZ(e,r)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,r){}constructor(e){this._posMatrixCache=/* @__PURE__ */ new Map,this._alignedPosMatrixCache=/* @__PURE__ */ new Map,this._fogMatrixCacheF32=/* @__PURE__ */ new Map,this.defaultConstrain=(e,r)=>{r=_.ak(+r,this.minZoom,this.maxZoom);let v={center:new _.V(e.lng,e.lat),zoom:r},b=this._helper._lngRange;if(!this._helper._renderWorldCopies&&b===null){let e=179.9999999999;b=[-e,e]}let x=this.tileSize*_.an(v.zoom),C=0,T=x,E=0,D=x,O=0,k=0,{x:A,y:j}=this.size;if(this._helper._latRange){let e=this._helper._latRange;C=_.X(e[1])*x,T=_.X(e[0])*x,T-CT&&(B=T-e)}if(b){let e=(E+D)/2,r=F;this._helper._renderWorldCopies&&(r=_.W(F,e-x/2,e+x/2));let v=A/2;r-vD&&(z=D-v)}return(z!==void 0||B!==void 0)&&(v.center=Ie(x,new _.P(z??F,B??R)).wrap()),v},this.applyConstrain=(e,r)=>this._helper.applyConstrain(e,r),this._helper=new Nt({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,r)=>this.defaultConstrain(e,r)},e),this._coveringTilesDetailsProvider=new Gt}clone(){let e=new Wt;return e.apply(this,!1),e}apply(e,r,_){this._helper.apply(e,r,_)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){let r=[new _.ba(0,e)];if(this._helper._renderWorldCopies){let v=this.screenPointToMercatorCoordinate(new _.P(0,0)),b=this.screenPointToMercatorCoordinate(new _.P(this._helper._width,0)),x=this.screenPointToMercatorCoordinate(new _.P(this._helper._width,this._helper._height)),C=this.screenPointToMercatorCoordinate(new _.P(0,this._helper._height)),T=Math.floor(Math.min(v.x,b.x,x.x,C.x)),E=Math.floor(Math.max(v.x,b.x,x.x,C.x)),D=1;for(let v=T-1;v<=E+1;v++)v!==0&&r.push(new _.ba(v,e))}return r}getCameraFrustum(){return Vt.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){let r=this.screenPointToLocation(this.centerPoint,e),_=e?e.getElevationForLngLatZoom(r,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(_)}setLocationAtPoint(e,r){let v=_.ap(this.elevation,this.center.lat),b=this.screenPointToMercatorCoordinateAtZ(r,v),x=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,v),C=_.a6.fromLngLat(e),T=new _.a6(C.x-(b.x-x.x),C.y-(b.y-x.y));this.setCenter(T?.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,r){return r?this.coordinatePoint(_.a6.fromLngLat(e),r.getElevationForLngLat(e,this),this._pixelMatrix3D):this.coordinatePoint(_.a6.fromLngLat(e))}screenPointToLocation(e,r){var _;return(_=this.screenPointToMercatorCoordinate(e,r))?.toLngLat()}screenPointToMercatorCoordinate(e,r){if(r){let _=r.pointCoordinate(e);if(_!=null)return _}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,r){let v=r||0,b=[e.x,e.y,0,1],x=[e.x,e.y,1,1];_.aE(b,b,this._pixelMatrixInverse),_.aE(x,x,this._pixelMatrixInverse);let C=b[3],T=x[3],E=b[1]/C,D=x[1]/T,O=b[2]/C,k=x[2]/T,A=O===k?0:(v-O)/(k-O);return new _.a6(_.G.number(b[0]/C,x[0]/T,A)/this.worldSize,_.G.number(E,D,A)/this.worldSize,v)}coordinatePoint(e,r=0,v=this._pixelMatrix){let b=[e.x*this.worldSize,e.y*this.worldSize,r,1];return _.aE(b,b,v),new _.P(b[0]/b[3],b[1]/b[3])}getBounds(){let e=Math.max(0,this._helper._height/2-Ue(this));return new N().extend(this.screenPointToLocation(new _.P(0,e))).extend(this.screenPointToLocation(new _.P(this._helper._width,e))).extend(this.screenPointToLocation(new _.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new _.P(0,this._helper._height)))}isPointOnMapSurface(e,r){return r?r.pointCoordinate(e)!=null:e.y>this.height/2-Ue(this)}calculatePosMatrix(e,r=!1,v){var b;let x=(b=e.key)??_.bb(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),C=r?this._alignedPosMatrixCache:this._posMatrixCache;if(C.has(x)){let e=C.get(x);return v?e.f32:e.f64}let T=We(e,this.worldSize);_.S(T,r?this._alignedProjMatrix:this._viewProjMatrix,T);let E={f64:T,f32:new Float32Array(T)};return C.set(x,E),v?E.f32:E.f64}calculateFogMatrix(e){let r=e.key,v=this._fogMatrixCacheF32;if(v.has(r))return v.get(r);let b=We(e,this.worldSize);return _.S(b,this._fogMatrix,b),v.set(r,new Float32Array(b)),v.get(r)}calculateCenterFromCameraLngLatAlt(e,r,_,v){return this._helper.calculateCenterFromCameraLngLatAlt(e,r,_,v)}_calculateNearFarZIfNeeded(e,r,v){if(!this._helper.autoCalculateNearFarZ)return;let b=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),x=e-b*this._helper._pixelPerMeter/Math.cos(r),C=b<0?x:e,T=Math.PI/2+this.pitchInRadians,E=_.am(this.fov)*(Math.abs(Math.cos(_.am(this.roll)))*this.height+Math.abs(Math.sin(_.am(this.roll)))*this.width)/this.height*(.5+v.y/this.height),D=Math.sin(E)*C/Math.sin(_.ak(Math.PI-T-E,.01,Math.PI-.01)),O=Ue(this),k=Math.atan(O/this._helper.cameraToCenterDistance),A=_.am(.75),j=k>A?2*k*(.5+v.y/(2*O)):A,F=Math.sin(j)*C/Math.sin(_.ak(Math.PI-T-j,.01,Math.PI-.01)),R=Math.min(D,F);this._helper._farZ=1.01*(Math.cos(Math.PI/2-r)*R+C),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;let e=this.centerOffset,r=Ne(this.worldSize,this.center),v=r.x,b=r.y;this._helper._pixelPerMeter=_.ap(1,this.center.lat)*this.worldSize;let x=_.am(Math.min(this.pitch,Me)),C=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(x)),T;this._calculateNearFarZIfNeeded(C,x,e),T=new Float64Array(16),_.bc(T,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),_.ay(this._invProjMatrix,T),T[8]=2*-e.x/this._helper._width,T[9]=2*e.y/this._helper._height,this._projectionMatrix=_.bd(T),_.Q(T,T,[1,-1,1]),_.O(T,T,[0,0,-this._helper.cameraToCenterDistance]),_.be(T,T,-this.rollInRadians),_.bf(T,T,this.pitchInRadians),_.be(T,T,-this.bearingInRadians),_.O(T,T,[-v,-b,0]),this._mercatorMatrix=_.Q([],T,[this.worldSize,this.worldSize,this.worldSize]),_.Q(T,T,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=_.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,T),_.O(T,T,[0,0,-this.elevation]),this._viewProjMatrix=T,this._invViewProjMatrix=_.ay([],T);let E=[0,0,-1,1];_.aE(E,E,this._invViewProjMatrix),this._cameraPosition=[E[0]/E[3],E[1]/E[3],E[2]/E[3]],this._fogMatrix=new Float64Array(16),_.bc(this._fogMatrix,this.fovInRadians,this.width/this.height,C,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,_.Q(this._fogMatrix,this._fogMatrix,[1,-1,1]),_.O(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),_.be(this._fogMatrix,this._fogMatrix,-this.rollInRadians),_.bf(this._fogMatrix,this._fogMatrix,this.pitchInRadians),_.be(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),_.O(this._fogMatrix,this._fogMatrix,[-v,-b,0]),_.Q(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),_.O(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=_.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,T);let D=this._helper._width%2/2,O=this._helper._height%2/2,k=Math.cos(this.bearingInRadians),A=Math.sin(-this.bearingInRadians),j=v-Math.round(v)+k*D+A*O,F=b-Math.round(b)+k*O+A*D,R=new Float64Array(T);if(_.O(R,R,[j>.5?j-1:j,F>.5?F-1:F,0]),this._alignedProjMatrix=R,T=_.ay(new Float64Array(16),this._pixelMatrix),!T)throw Error(`failed to invert matrix`);this._pixelMatrixInverse=T,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let e=this.screenPointToMercatorCoordinate(new _.P(0,0)),r=[e.x*this.worldSize,e.y*this.worldSize,0,1];return _.aE(r,r,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){let e=_.ap(1,this.center.lat)*this.worldSize;return qe(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,r){let v=_.a6.fromLngLat(e),b=[v.x*this.worldSize,v.y*this.worldSize,r,1];return _.aE(b,b,this._viewProjMatrix),b[2]/b[3]}getProjectionData(e){let{overscaledTileID:r,aligned:v,applyTerrainMatrix:b}=e,x=this._helper.getMercatorTileCoordinates(r),C=r?this.calculatePosMatrix(r,v,!0):null,T;return T=r&&r.terrainRttPosMatrix32f&&b?r.terrainRttPosMatrix32f:C||_.bg(),{mainMatrix:T,tileMercatorCoords:x,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:T}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,r,_){return 1}transformLightDirection(e){return _.a$(e)}getRayDirectionFromPixel(e){throw Error(`Not implemented.`)}projectTileCoordinates(e,r,v,b){let x=this.calculatePosMatrix(v),C;b?(C=[e,r,b(e,r),1],_.aE(C,C,x)):(C=[e,r,0,1],_n(C,C,x));let T=C[3];return{point:new _.P(C[0]/T,C[1]/T),signedDistanceFromCamera:T,isOccluded:!1}}populateCache(e){for(let r of e)this.calculatePosMatrix(r)}getMatrixForModel(e,r){let v=_.a6.fromLngLat(e,r),b=v.meterInMercatorCoordinateUnits(),x=_.bh();return _.O(x,x,[v.x,v.y,v.z]),_.be(x,x,Math.PI),_.bf(x,x,Math.PI/2),_.Q(x,x,[-b,b,b]),x}getProjectionDataForCustomLayer(e=!0){let r=new _.a2(0,0,0,0,0),v=this.getProjectionData({overscaledTileID:r,applyGlobeMatrix:e}),b=We(r,this.worldSize);_.S(b,this._viewProjMatrix,b),v.tileMercatorCoords=[0,0,1,1];let x=[_.a5,_.a5,this.worldSize/this._helper.pixelsPerMeter],C=_.bi();return _.Q(C,b,x),v.fallbackMatrix=C,v.mainMatrix=C,v}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function qn(){_.w(`Map cannot fit within canvas with the given bounds, padding, and/or offset.`)}function Yn(e){if(e.useSlerp)if(e.k<1){let r=_.bj(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),v=_.bj(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),b=new Float64Array(4);_.bk(b,r,v,e.k);let x=_.bl(b);e.tr.setRoll(x.roll),e.tr.setPitch(x.pitch),e.tr.setBearing(x.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(_.G.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(_.G.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(_.G.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Xn(e,r,v,b,x){let C=x.padding,T=Ne(x.worldSize,v.getNorthWest()),E=Ne(x.worldSize,v.getNorthEast()),D=Ne(x.worldSize,v.getSouthEast()),O=Ne(x.worldSize,v.getSouthWest()),k=_.am(-b),A=T.rotate(k),j=E.rotate(k),F=D.rotate(k),R=O.rotate(k),z=new _.P(Math.max(A.x,j.x,R.x,F.x),Math.max(A.y,j.y,R.y,F.y)),B=new _.P(Math.min(A.x,j.x,R.x,F.x),Math.min(A.y,j.y,R.y,F.y)),H=z.sub(B),K=(x.width-(C.left+C.right+r.left+r.right))/H.x,q=(x.height-(C.top+C.bottom+r.top+r.bottom))/H.y;if(q<0||K<0)return void qn();let Y=Math.min(_.aq(x.scale*Math.min(K,q)),e.maxZoom),X=_.P.convert(e.offset),ne=new _.P((r.left-r.right)/2,(r.top-r.bottom)/2).rotate(_.am(b)),Z=X.add(ne).mult(x.scale/_.an(Y));return{center:Ie(x.worldSize,T.add(D).div(2).sub(Z)),zoom:Y,bearing:b}}class Xt{get useGlobeControls(){return!1}handlePanInertia(e,r){let _=e.mag(),v=Math.abs(Ue(r));return{easingOffset:e.mult(Math.min(.75*v/_,1)),easingCenter:r.center}}handleMapControlsRollPitchBearingZoom(e,r){e.bearingDelta&&r.setBearing(r.bearing+e.bearingDelta),e.pitchDelta&&r.setPitch(r.pitch+e.pitchDelta),e.rollDelta&&r.setRoll(r.roll+e.rollDelta),e.zoomDelta&&r.setZoom(r.zoom+e.zoomDelta)}handleMapControlsPan(e,r,_){e.around.distSqr(r.centerPoint)<.01||r.setLocationAtPoint(_,e.around)}cameraForBoxAndBearing(e,r,_,v,b){return Xn(e,r,_,v,b)}handleJumpToCenterZoom(e,r){e.zoom!==(r.zoom===void 0?e.zoom:+r.zoom)&&e.setZoom(+r.zoom),r.center!==void 0&&e.setCenter(_.V.convert(r.center))}handleEaseTo(e,r){let v=e.zoom,b=e.padding,x={roll:e.roll,pitch:e.pitch,bearing:e.bearing},C={roll:r.roll===void 0?e.roll:r.roll,pitch:r.pitch===void 0?e.pitch:r.pitch,bearing:r.bearing===void 0?e.bearing:r.bearing},T=r.zoom!==void 0,E=!e.isPaddingEqual(r.padding),D=!1,O=T?+r.zoom:e.zoom,k=e.centerPoint.add(r.offsetAsPoint),A=e.screenPointToLocation(k),{center:j,zoom:F}=e.applyConstrain(_.V.convert(r.center||A),O??v);Wn(e,j);let R=Ne(e.worldSize,A),z=Ne(e.worldSize,j).sub(R),B=_.an(F-v);return D=F!==v,{easeFunc:T=>{if(D&&e.setZoom(_.G.number(v,F,T)),_.bm(x,C)||Yn({startEulerAngles:x,endEulerAngles:C,tr:e,k:T,useSlerp:x.roll!=C.roll}),E&&(e.interpolatePadding(b,r.padding,T),k=e.centerPoint.add(r.offsetAsPoint)),r.around)e.setLocationAtPoint(r.around,r.aroundPoint);else{let r=_.an(e.zoom-v),b=(F>v?Math.min(2,B):Math.max(.5,B))**(1-T),x=Ie(e.worldSize,R.add(z.mult(T*b)).mult(r));e.setLocationAtPoint(e.renderWorldCopies?x.wrap():x,k)}},isZooming:D,elevationCenter:j}}handleFlyTo(e,r){let v=r.zoom!==void 0,b=e.zoom,x=e.applyConstrain(_.V.convert(r.center||r.locationAtOffset),v?+r.zoom:b),C=x.center,T=x.zoom;Wn(e,C);let E=Ne(e.worldSize,r.locationAtOffset),D=Ne(e.worldSize,C).sub(E),O=D.mag(),k=_.an(T-b),A;if(r.minZoom!==void 0){let v=Math.min(+r.minZoom,b,T),x=e.applyConstrain(C,v).zoom;A=_.an(x-b)}return{easeFunc:(r,v,x,O)=>{e.setZoom(r===1?T:b+_.aq(v));let k=r===1?C:Ie(e.worldSize,E.add(D.mult(x)).mult(v));e.setLocationAtPoint(e.renderWorldCopies?k.wrap():k,O)},scaleOfZoom:k,targetCenter:C,scaleOfMinZoom:A,pixelPathLength:O}}}class Kt{constructor(e,r,_){this.blendFunction=e,this.blendColor=r,this.mask=_}}Kt.Replace=[1,0],Kt.disabled=new Kt(Kt.Replace,_.bn.transparent,[!1,!1,!1,!1]),Kt.unblended=new Kt(Kt.Replace,_.bn.transparent,[!0,!0,!0,!0]),Kt.alphaBlended=new Kt([1,771],_.bn.transparent,[!0,!0,!0,!0]);let Zn=2305;class Qt{constructor(e,r,_){this.enable=e,this.mode=r,this.frontFace=_}}Qt.disabled=new Qt(!1,1029,Zn),Qt.backCCW=new Qt(!0,1029,Zn),Qt.frontCCW=new Qt(!0,1028,Zn);class Jt{constructor(e,r,_){this.func=e,this.mask=r,this.range=_}}Jt.ReadOnly=!1,Jt.ReadWrite=!0,Jt.disabled=new Jt(519,Jt.ReadOnly,[0,1]);let Qn=7680;class ti{constructor(e,r,_,v,b,x){this.test=e,this.ref=r,this.mask=_,this.fail=v,this.depthFail=b,this.pass=x}}ti.disabled=new ti({func:519,mask:0},0,0,Qn,Qn,Qn);let $n=/* @__PURE__ */ new WeakMap;function er(e){var r;if($n.has(e))return $n.get(e);{let _=(r=e.getParameter(e.VERSION))?.startsWith(`WebGL 2.0`);return $n.set(e,_),_}}class ai{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;let r=e.context,v=r.gl;this._texFormat=v.RGBA,this._texType=v.UNSIGNED_BYTE;let b=new _.aU;b.emplaceBack(-1,-1),b.emplaceBack(2,-1),b.emplaceBack(-1,2);let x=new _.aW;x.emplaceBack(0,1,2),this._fullscreenTriangle=new At(r.createVertexBuffer(b,Vn.members),r.createIndexBuffer(x),_.aV.simpleSegment(0,0,b.length,x.length)),this._resultBuffer=new Uint8Array(4),r.activeTexture.set(v.TEXTURE1);let C=v.createTexture();v.bindTexture(v.TEXTURE_2D,C),v.texParameteri(v.TEXTURE_2D,v.TEXTURE_WRAP_S,v.CLAMP_TO_EDGE),v.texParameteri(v.TEXTURE_2D,v.TEXTURE_WRAP_T,v.CLAMP_TO_EDGE),v.texParameteri(v.TEXTURE_2D,v.TEXTURE_MIN_FILTER,v.NEAREST),v.texParameteri(v.TEXTURE_2D,v.TEXTURE_MAG_FILTER,v.NEAREST),v.texImage2D(v.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=r.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(C),er(v)&&(this._pbo=v.createBuffer(),v.bindBuffer(v.PIXEL_PACK_BUFFER,this._pbo),v.bufferData(v.PIXEL_PACK_BUFFER,4,v.STREAM_READ),v.bindBuffer(v.PIXEL_PACK_BUFFER,null))}destroy(){let e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,r){let _=this._updateCount;return this._readbackQueue?_>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():_>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,r),this._updateCount++,this._measuredError}_bindFramebuffer(){let e=this._cachedRenderContext.context,r=e.gl;e.activeTexture.set(r.TEXTURE1),r.bindTexture(r.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,r){let v=this._cachedRenderContext.context,b=v.gl;if(this._bindFramebuffer(),v.viewport.set([0,0,this._texWidth,this._texHeight]),v.clear({color:_.bn.transparent}),this._cachedRenderContext.useProgram(`projectionErrorMeasurement`).draw(v,b.TRIANGLES,Jt.disabled,ti.disabled,Kt.unblended,Qt.disabled,((e,r)=>({u_input:e,u_output_expected:r}))(e,r),null,null,`$clipping`,this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&er(b)){b.bindBuffer(b.PIXEL_PACK_BUFFER,this._pbo),b.readBuffer(b.COLOR_ATTACHMENT0),b.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),b.bindBuffer(b.PIXEL_PACK_BUFFER,null);let e=b.fenceSync(b.SYNC_GPU_COMMANDS_COMPLETE,0);b.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){let e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&er(e)){let r=e.clientWaitSync(this._readbackQueue.sync,0,0);if(r===e.WAIT_FAILED)return _.w(`WebGL2 clientWaitSync failed.`),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(r===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=ai._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let r=0;return r+=e[0]/256,r+=e[1]/65536,r+=e[2]/16777216,e[3]<127&&(r=-r),r/128}}let tr=_.a5/128;function cr(e,r){let v=e.granularity===void 0?1:Math.max(e.granularity,1),b=v+(e.generateBorders?2:0),x=v+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),C=b+1,T=x+1,E=e.generateBorders?-1:0,D=e.generateBorders||e.extendToNorthPole?-1:0,O=v+(e.generateBorders?1:0),k=v+(e.generateBorders||e.extendToSouthPole?1:0),A=C*T,j=b*x*6,F=C*T>65536;if(F&&r===`16bit`)throw Error(`Granularity is too large and meshes would not fit inside 16 bit vertex indices.`);let R=F||r===`32bit`,z=new Int16Array(2*A),B=0;for(let r=D;r<=k;r++)for(let b=E;b<=O;b++){let x=b/v*_.a5;b===-1&&(x=-tr),b===v+1&&(x=_.a5+tr);let C=r/v*_.a5;r===-1&&(C=e.extendToNorthPole?_.bp:-tr),r===v+1&&(C=e.extendToSouthPole?_.bq:_.a5+tr),z[B++]=x,z[B++]=C}let H=R?new Uint32Array(j):new Uint16Array(j),K=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return`globe`}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,r,_,v,b){return this.currentProjection.getMeshFromTileID(e,r,_,v,b)}setProjection(e){this._transitionable.setValue(`type`,e?.type||`mercator`)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function mr(e){let r=Er(e.worldSize,e.center.lat);return 2*Math.PI*r}function br(e,r,v,b,x){let C=1/(1<1e-6){let b=e[0]/v,x=Math.acos(e[2]/v),C=(b>0?x:-x)/Math.PI*180;return new _.V(_.W(C,-180,180),r)}return new _.V(0,r)}function Ar(e){return Math.cos(e*Math.PI/180)}function Ir(e,r){let v=Ar(e),b=Ar(r);return _.aq(b/v)}function Lr(e,r){let v=e.rotate(r.bearingInRadians),b=r.zoom+Ir(r.center.lat,0),x=_.bs(1/Ar(r.center.lat),1/Ar(Math.min(Math.abs(r.center.lat),60)),_.bv(b,7,3,0,1)),C=360/mr({worldSize:r.worldSize,center:{lat:r.center.lat}});return new _.V(r.center.lng-v.x*C*x,_.ak(r.center.lat+v.y*C,-_.al,_.al))}function Rr(e){let r=.5*e,_=Math.sin(r),v=Math.cos(r);return Math.log(_+v)-Math.log(v-_)}function Hr(e,r,v,b){let x=e.lat+v*b;if(Math.abs(v)>1){let C=(Math.sign(e.lat+v)===Math.sign(e.lat)?Math.abs(e.lat):-Math.abs(e.lat))*Math.PI/180,T=Math.abs(e.lat+v)*Math.PI/180,E=Rr(C+b*(T-C)),D=Rr(C),O=Rr(T);return new _.V(e.lng+r*((E-D)/(O-D)),x)}return new _.V(e.lng+r*b,x)}class yi{constructor(e){this._cachePrevious=/* @__PURE__ */ new Map,this._cache=/* @__PURE__ */ new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;let e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,r,_,v){let b=`${e.z}_${e.x}_${e.y}_${v?.terrain?`t`:``}`,x=this._cache.get(b);if(x)return x;let C=this._cachePrevious.get(b);if(C)return this._cache.set(b,C),C;let T=this._boundingVolumeFactory(e,r,_,v);return this._cache.set(b,T),this._hadAnyChanges=!0,T}}class wi{constructor(e,r,_,v){this.min=_,this.max=v,this.points=e,this.planes=r}static fromAabb(e,r){let _=[];for(let v=0;v<8;v++)_.push([1&~v?e[0]:r[0],(v>>1&1)==1?r[1]:e[1],(v>>2&1)==1?r[2]:e[2]]);return new wi(_,[[-1,0,0,r[0]],[1,0,0,-e[0]],[0,-1,0,r[1]],[0,1,0,-e[1]],[0,0,-1,r[2]],[0,0,1,-e[2]]],e,r)}static fromCenterSizeAngles(e,r,v){let b=_.bz([],v[0],v[1],v[2]),x=_.bA([],[r[0],0,0],b),C=_.bA([],[0,r[1],0],b),T=_.bA([],[0,0,r[2]],b),E=[...e],D=[...e];for(let r=0;r<8;r++)for(let _=0;_<3;_++){let v=e[_]+x[_]*(1&~r?-1:1)+C[_]*((r>>1&1)==1?1:-1)+T[_]*((r>>2&1)==1?1:-1);E[_]=Math.min(E[_],v),D[_]=Math.max(D[_],v)}let O=[];for(let r=0;r<8;r++){let v=[...e];_.a_(v,v,_.aZ([],x,1&~r?-1:1)),_.a_(v,v,_.aZ([],C,(r>>1&1)==1?1:-1)),_.a_(v,v,_.aZ([],T,(r>>2&1)==1?1:-1)),O.push(v)}return new wi(O,[[...x,-_.b3(x,O[0])],[...C,-_.b3(C,O[0])],[...T,-_.b3(T,O[0])],[-x[0],-x[1],-x[2],-_.b3(x,O[7])],[-C[0],-C[1],-C[2],-_.b3(C,O[7])],[-T[0],-T[1],-T[2],-_.b3(T,O[7])]],E,D)}intersectsFrustum(e){let r=!0,_=this.points.length,v=this.planes.length,b=e.planes.length,x=e.points.length;for(let v=0;v=0&&x++}if(x===0)return 0;x<_&&(r=!1)}if(r)return 2;for(let r=0;r=0&&v++}if(v===0)return 0}return 1}intersectsPlane(e){let r=this.points.length,_=0;for(let v=0;v=0&&_++}return _===r?2:_===0?0:1}}function Wr(e,r,_){let v=e-r;return v<0?-v:Math.max(0,v-_)}function Gr(e,r,_,v,b){let x=e-_,C;return C=x<0?Math.min(-x,1+x-b):x>b?Math.min(Math.max(x-b,0),1-x):0,Math.max(C,Wr(r,v,b))}class Ci{constructor(){this._boundingVolumeCache=new yi(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,r,_,v){let b=1<<_.z,x=1/b,C=_.x/b,T=_.y/b,E=2;return E=Math.min(E,Gr(e,r,C,T,x)),E=Math.min(E,Gr(e,r,C+.5,-T-x,x)),E=Math.min(E,Gr(e,r,C+.5,2-T-x,x)),E}getWrap(e,r,_){let v=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(e,r,_,v){return this._boundingVolumeCache.getTileBoundingVolume(e,r,_,v)}_computeTileBoundingVolume(e,r,v,b){var x,C;let T=0,E=0;if(b?.terrain){let D=new _.a2(e.z,r,e.z,e.x,e.y),O=b.terrain.getMinMaxElevation(D);T=(x=O.minElevation)??Math.min(0,v),E=(C=O.maxElevation)??Math.max(0,v)}if(T/=_.bC,E/=_.bC,T+=1,E+=1,e.z<=0)return wi.fromAabb([-E,-E,-E],[E,E,E]);if(e.z===1)return wi.fromAabb([e.x===0?-E:0,e.y===0?0:-E,-E],[e.x===0?0:E,e.y===0?E:0,E]);{let r=[br(0,0,e.x,e.y,e.z),br(_.a5,0,e.x,e.y,e.z),br(_.a5,_.a5,e.x,e.y,e.z),br(0,_.a5,e.x,e.y,e.z)],v=[];for(let e of r)v.push(_.aZ([],e,E));if(E!==T)for(let e of r)v.push(_.aZ([],e,T));e.y===0&&v.push([0,1,0]),e.y===(1<=(1<{let v=_.ak(e.lat,-_.al,_.al),b=_.ak(+r,this.minZoom+Ir(0,v),this.maxZoom);return{center:new _.V(e.lng,v),zoom:b}},this.applyConstrain=(e,r)=>this._helper.applyConstrain(e,r),this._helper=new Nt({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,r)=>this.defaultConstrain(e,r)},e),this._coveringTilesDetailsProvider=new Ci}clone(){let e=new Mi;return e.apply(this,!1),e}apply(e,r,_){this._globeLatitudeErrorCorrectionRadians=_||0,this._helper.apply(e,r)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let e=_.by();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){let{overscaledTileID:r,applyGlobeMatrix:_}=e,v=this._helper.getMercatorTileCoordinates(r);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:v,clippingPlane:this._cachedClippingPlane,projectionTransition:_?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){let r=this.pitchInRadians,v=this.cameraToCenterDistance/e,b=Math.sin(r)*v,x=Math.cos(r)*v+1,C=1/Math.sqrt(b*b+x*x)*1,T=-b,E=x,D=Math.sqrt(T*T+E*E);T/=D,E/=D;let O=[0,T,E];_.bE(O,O,[0,0,0],-this.bearingInRadians),_.bF(O,O,[0,0,0],-1*this.center.lat*Math.PI/180),_.bG(O,O,[0,0,0],this.center.lng*Math.PI/180);let k=1/_.b5(O);return _.aZ(O,O,k),[...O,-C*k]}isLocationOccluded(e){return!this.isSurfacePointVisible(Tr(e))}transformLightDirection(e){let r=this._helper._center.lng*Math.PI/180,v=this._helper._center.lat*Math.PI/180,b=Math.cos(v),x=[Math.sin(r)*b,Math.sin(v),Math.cos(r)*b],C=[x[2],0,-x[0]],T=[0,0,0];_.b2(T,C,x),_.b1(C,C),_.b1(T,T);let E=[0,0,0];return _.b1(E,[C[0]*e[0]+T[0]*e[1]+x[0]*e[2],C[1]*e[0]+T[1]*e[1]+x[1]*e[2],C[2]*e[0]+T[2]*e[1]+x[2]*e[2]]),E}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,r,v){let b=function(e,r,v){let b=1/(1<x&&(x=r),vT&&(T=v)}let O=[D.lng+C,D.lat+E,D.lng+x,D.lat+T];return this.isSurfacePointOnScreen([0,1,0])&&(O[3]=90,O[0]=-180,O[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(O[1]=-90,O[0]=-180,O[2]=180),new N(O)}calculateCenterFromCameraLngLatAlt(e,r,_,v){return this._helper.calculateCenterFromCameraLngLatAlt(e,r,_,v)}setLocationAtPoint(e,r){let v=Tr(this.unprojectScreenPoint(r)),b=Tr(e),x=_.by();_.bJ(x);let C=_.by();_.bG(C,v,x,-this.center.lng*Math.PI/180),_.bF(C,C,x,this.center.lat*Math.PI/180);let T=b[0]*b[0]+b[2]*b[2],E=C[0]*C[0];if(T=-B&&F<=B,K=z>=-B&&z<=B,q,Y;if(H&&K){let e=this.center.lng*Math.PI/180,r=this.center.lat*Math.PI/180;_.bL(k,e)+_.bL(F,r)<_.bL(A,e)+_.bL(z,r)?(q=k,Y=F):(q=A,Y=z)}else if(H)q=k,Y=F;else{if(!K)return;q=A,Y=z}let X=q/Math.PI*180,ne=Y/Math.PI*180,Z=this.center.lat;this.setCenter(new _.V(X,_.ak(ne,-90,90))),this.setZoom(this.zoom+Ir(Z,this.center.lat))}locationToScreenPoint(e,r){let v=Tr(e);if(r){let b=r.getElevationForLngLatZoom(e,this._helper._tileZoom);_.aZ(v,v,1+b/_.bC)}return this._projectSurfacePointToScreen(v)}_projectSurfacePointToScreen(e){let r=_.bD();return _.aE(r,[...e,1],this._globeViewProjMatrixNoCorrection),r[0]/=r[3],r[1]/=r[3],new _.P((.5*r[0]+.5)*this.width,(.5*-r[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,r){if(r){let _=r.pointCoordinate(e);if(_)return _}return _.a6.fromLngLat(this.unprojectScreenPoint(e))}screenPointToLocation(e,r){var _;return(_=this.screenPointToMercatorCoordinate(e,r))?.toLngLat()}isPointOnMapSurface(e,r){let _=this._cameraPosition,v=this.getRayDirectionFromPixel(e);return!!this.rayPlanetIntersection(_,v)}getRayDirectionFromPixel(e){let r=_.bD();r[0]=e.x/this.width*2-1,r[1]=-1*(e.y/this.height*2-1),r[2]=1,r[3]=1,_.aE(r,r,this._globeViewProjMatrixNoCorrectionInverted),r[0]/=r[3],r[1]/=r[3],r[2]/=r[3];let v=_.by();v[0]=r[0]-this._cameraPosition[0],v[1]=r[1]-this._cameraPosition[1],v[2]=r[2]-this._cameraPosition[2];let b=_.by();return _.b1(b,v),b}isSurfacePointVisible(e){let r=this._cachedClippingPlane;return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]+r[3]>=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;let r=_.bD();return _.aE(r,[...e,1],this._globeViewProjMatrixNoCorrection),r[0]/=r[3],r[1]/=r[3],r[2]/=r[3],r[0]>-1&&r[0]<1&&r[1]>-1&&r[1]<1&&r[2]>-1&&r[2]<1}rayPlanetIntersection(e,r){let v=_.b3(e,r),b=_.by(),x=_.by();_.aZ(x,r,v),_.b0(b,e,x);let C=1-_.b3(b,b);if(C<0)return null;let T=_.b3(e,e)-1,E=-v+(v<0?1:-1)*Math.sqrt(C),D=T/E,O=E;return{tMin:Math.min(D,O),tMax:Math.max(D,O)}}unprojectScreenPoint(e){let r=this._cameraPosition,v=this.getRayDirectionFromPixel(e),b=this.rayPlanetIntersection(r,v);if(b){let e=_.by();_.a_(e,r,[v[0]*b.tMin,v[1]*b.tMin,v[2]*b.tMin]);let x=_.by();return _.b1(x,e),Dr(x)}let x=this._cachedClippingPlane,C=x[0]*v[0]+x[1]*v[1]+x[2]*v[2],T=-_.b9(x,r)/C,E=_.by();if(T>0)_.a_(E,r,[v[0]*T,v[1]*T,v[2]*T]);else{let e=_.by();_.a_(e,r,[2*v[0],2*v[1],2*v[2]]);let b=_.b9(this._cachedClippingPlane,e);_.b0(E,e,[this._cachedClippingPlane[0]*b,this._cachedClippingPlane[1]*b,this._cachedClippingPlane[2]*b])}let D=function(e){let r=_.by();return r[0]=e[0]*-e[3],r[1]=e[1]*-e[3],r[2]=e[2]*-e[3],{center:r,radius:Math.sqrt(1-e[3]*e[3])}}(x);return Dr(function(e,r,v){let b=_.by();_.b0(b,v,e);let x=_.by();return _.bw(x,e,b,r/_.b7(b)),x}(D.center,D.radius,E))}getMatrixForModel(e,r){let v=_.V.convert(e),b=1/_.bC,x=_.bh();return _.bH(x,x,v.lng/180*Math.PI),_.bf(x,x,-v.lat/180*Math.PI),_.O(x,x,[0,0,1+r/_.bC]),_.bf(x,x,.5*Math.PI),_.Q(x,x,[b,b,b]),x}getProjectionDataForCustomLayer(e=!0){let r=this.getProjectionData({overscaledTileID:new _.a2(0,0,0,0,0),applyGlobeMatrix:e});return r.tileMercatorCoords=[0,0,1,1],r}getFastPathSimpleProjectionMatrix(e){}}class Ei{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,r,_){return this._helper.interpolatePadding(e,r,_)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,r,_=!0){this._helper.resize(e,r,_)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,r){this._helper.overrideNearFarZ(e,r)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,r){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=r,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(e,r)=>this.currentTransform.defaultConstrain(e,r),this.applyConstrain=(e,r)=>this._helper.applyConstrain(e,r),this._helper=new Nt({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,r)=>this.defaultConstrain(e,r)},e),this._globeness=1,this._mercatorTransform=new Wt,this._verticalPerspectiveTransform=new Mi}clone(){let e=new Ei;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this,!1),e}apply(e,r){this._helper.apply(e,r),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){let r=this._mercatorTransform.getProjectionData(e),_=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?_.mainMatrix:r.mainMatrix,clippingPlane:_.clippingPlane,tileMercatorCoords:_.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:r.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return _.bs(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return _.bs(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,r,v){let b=this._mercatorTransform.getPitchedTextCorrection(e,r,v),x=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,r,v);return _.bs(b,x,this._globeness)}projectTileCoordinates(e,r,_,v){return this.currentTransform.projectTileCoordinates(e,r,_,v)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,r){return this.currentTransform.lngLatToCameraDepth(e,r)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,r,_,v){return this._helper.calculateCenterFromCameraLngLatAlt(e,r,_,v)}setLocationAtPoint(e,r){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,r),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(e,r),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(e,r){return this.currentTransform.locationToScreenPoint(e,r)}screenPointToMercatorCoordinate(e,r){return this.currentTransform.screenPointToMercatorCoordinate(e,r)}screenPointToLocation(e,r){return this.currentTransform.screenPointToLocation(e,r)}isPointOnMapSurface(e,r){return this.currentTransform.isPointOnMapSurface(e,r)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,r){return this.currentTransform.getMatrixForModel(e,r)}getProjectionDataForCustomLayer(e=!0){let r=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return r;let _=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return _.fallbackMatrix=r.mainMatrix,_}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Si{get useGlobeControls(){return!0}handlePanInertia(e,r){let v=Lr(e,r);return Math.abs(v.lng-r.center.lng)>180&&(v.lng=r.center.lng+179.5*Math.sign(v.lng-r.center.lng)),{easingCenter:v,easingOffset:new _.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,r){let v=e.around,b=r.screenPointToLocation(v);e.bearingDelta&&r.setBearing(r.bearing+e.bearingDelta),e.pitchDelta&&r.setPitch(r.pitch+e.pitchDelta),e.rollDelta&&r.setRoll(r.roll+e.rollDelta);let x=r.zoom;e.zoomDelta&&r.setZoom(r.zoom+e.zoomDelta);let C=r.zoom-x;if(C===0)return;let T=_.bI(r.center.lng,b.lng),E=T/(Math.abs(T/180)+1),D=_.bI(r.center.lat,b.lat),O=r.getRayDirectionFromPixel(v),k=r.cameraPosition,A=-1*_.b3(k,O),j=_.by();_.a_(j,k,[O[0]*A,O[1]*A,O[2]*A]);let F=_.b5(j)-1,R=Math.exp(.5*-Math.max(F-.3,0)),z=Er(r.worldSize,r.center.lat)/Math.min(r.width,r.height),B=_.bv(z,.9,.5,1,.25),H=(1-_.an(-C))*Math.min(R,B),K=r.center.lat,q=r.zoom,Y=new _.V(r.center.lng+E*H,_.ak(r.center.lat+D*H,-_.al,_.al));r.setLocationAtPoint(b,v);let X=r.center,ne=_.bv(Math.abs(T),45,85,0,1),Z=_.bv(z,.75,.35,0,1),ie=Math.max(ne,Z)**.25,ae=_.bI(X.lng,Y.lng),oe=_.bI(X.lat,Y.lat);r.setCenter(new _.V(X.lng+ae*ie,X.lat+oe*ie).wrap()),r.setZoom(q+Ir(K,r.center.lat))}handleMapControlsPan(e,r,_){if(!e.panDelta)return;let v=r.center.lat,b=r.zoom;r.setCenter(Lr(e.panDelta,r).wrap()),r.setZoom(b+Ir(v,r.center.lat))}cameraForBoxAndBearing(e,r,v,b,x){let C=Xn(e,r,v,b,x),T=r.left/x.width*2-1,E=(x.width-r.right)/x.width*2-1,D=r.top/x.height*-2+1,O=(x.height-r.bottom)/x.height*-2+1,k=_.bI(v.getWest(),v.getEast())<0,A=k?v.getEast():v.getWest(),j=k?v.getWest():v.getEast(),F=Math.max(v.getNorth(),v.getSouth()),R=Math.min(v.getNorth(),v.getSouth()),z=A+.5*_.bI(A,j),B=F+.5*_.bI(F,R),H=x.clone();H.setCenter(C.center),H.setBearing(C.bearing),H.setPitch(0),H.setRoll(0),H.setZoom(C.zoom);let K=H.modelViewProjectionMatrix,q=[Tr(v.getNorthWest()),Tr(v.getNorthEast()),Tr(v.getSouthWest()),Tr(v.getSouthEast()),Tr(new _.V(j,B)),Tr(new _.V(A,B)),Tr(new _.V(z,F)),Tr(new _.V(z,R))],Y=Tr(C.center),X=1/0;for(let e of q)T<0&&(X=Si.getLesserNonNegativeNonNull(X,Si.solveVectorScale(e,Y,K,`x`,T))),E>0&&(X=Si.getLesserNonNegativeNonNull(X,Si.solveVectorScale(e,Y,K,`x`,E))),D>0&&(X=Si.getLesserNonNegativeNonNull(X,Si.solveVectorScale(e,Y,K,`y`,D))),O<0&&(X=Si.getLesserNonNegativeNonNull(X,Si.solveVectorScale(e,Y,K,`y`,O)));if(Number.isFinite(X)&&X!==0)return C.zoom=Math.min(H.zoom+_.aq(X),e.maxZoom),C;qn()}handleJumpToCenterZoom(e,r){let v=e.center.lat,b=e.applyConstrain(r.center?_.V.convert(r.center):e.center,e.zoom).center;e.setCenter(b.wrap());let x=r.zoom===void 0?e.zoom+Ir(v,b.lat):+r.zoom;e.zoom!==x&&e.setZoom(x)}handleEaseTo(e,r){let v=e.zoom,b=e.center,x=e.padding,C={roll:e.roll,pitch:e.pitch,bearing:e.bearing},T={roll:r.roll===void 0?e.roll:r.roll,pitch:r.pitch===void 0?e.pitch:r.pitch,bearing:r.bearing===void 0?e.bearing:r.bearing},E=r.zoom!==void 0,D=!e.isPaddingEqual(r.padding),O=!1,k=r.center?_.V.convert(r.center):b,A=e.applyConstrain(k,v).center;Wn(e,A);let j=e.clone();j.setCenter(A),j.setZoom(E?+r.zoom:v+Ir(b.lat,k.lat)),j.setBearing(r.bearing);let F=new _.P(_.ak(e.centerPoint.x+r.offsetAsPoint.x,0,e.width),_.ak(e.centerPoint.y+r.offsetAsPoint.y,0,e.height));j.setLocationAtPoint(A,F);let R=(r.offset&&r.offsetAsPoint.mag())>0?j.center:A,z=E?+r.zoom:v+Ir(b.lat,R.lat),B=v+Ir(b.lat,0),H=z+Ir(R.lat,0),K=_.bI(b.lng,R.lng),q=_.bI(b.lat,R.lat),Y=_.an(H-B);return O=z!==v,{easeFunc:v=>{if(_.bm(C,T)||Yn({startEulerAngles:C,endEulerAngles:T,tr:e,k:v,useSlerp:C.roll!=T.roll}),D&&e.interpolatePadding(x,r.padding,v),r.around)_.w(`Easing around a point is not supported under globe projection.`),e.setLocationAtPoint(r.around,r.aroundPoint);else{let r=Hr(b,K,q,v*(H>B?Math.min(2,Y):Math.max(.5,Y))**(1-v));e.setCenter(r.wrap())}if(O){let r=_.G.number(B,H,v)+Ir(0,e.center.lat);e.setZoom(r)}},isZooming:O,elevationCenter:R}}handleFlyTo(e,r){let v=r.zoom!==void 0,b=e.center,x=e.zoom,C=e.padding,T=!e.isPaddingEqual(r.padding),E=e.applyConstrain(_.V.convert(r.center||r.locationAtOffset),x).center,D=v?+r.zoom:e.zoom+Ir(e.center.lat,E.lat),O=e.clone();O.setCenter(E),O.setZoom(D),O.setBearing(r.bearing);let k=new _.P(_.ak(e.centerPoint.x+r.offsetAsPoint.x,0,e.width),_.ak(e.centerPoint.y+r.offsetAsPoint.y,0,e.height));O.setLocationAtPoint(E,k);let A=O.center;Wn(e,A);let j=function(e,r,v){let b=Tr(r),x=Tr(v),C=_.b3(b,x),T=Math.acos(C),E=mr(e);return T/(2*Math.PI)*E}(e,b,A),F=x+Ir(b.lat,0),R=D+Ir(A.lat,0),z=_.an(R-F),B;if(typeof r.minZoom==`number`){let v=+r.minZoom+Ir(A.lat,0),b=Math.min(v,F,R)+Ir(0,A.lat),x=e.applyConstrain(A,b).zoom+Ir(A.lat,0);B=_.an(x-F)}let H=_.bI(b.lng,A.lng),K=_.bI(b.lat,A.lat);return{easeFunc:(v,x,E,O)=>{let k=Hr(b,H,K,E);T&&e.interpolatePadding(C,r.padding,v);let j=v===1?A:k;e.setCenter(j.wrap());let R=F+_.aq(x);e.setZoom(v===1?D:R+Ir(0,j.lat))},scaleOfZoom:z,targetCenter:A,scaleOfMinZoom:B,pixelPathLength:j}}static solveVectorScale(e,r,_,v,b){let x=v===`x`?[_[0],_[4],_[8],_[12]]:[_[1],_[5],_[9],_[13]],C=[_[3],_[7],_[11],_[15]],T=e[0]*x[0]+e[1]*x[1]+e[2]*x[2],E=e[0]*C[0]+e[1]*C[1]+e[2]*C[2],D=r[0]*x[0]+r[1]*x[1]+r[2]*x[2],O=r[0]*C[0]+r[1]*C[1]+r[2]*C[2];return D+b*E===T+b*O||C[3]*(T-D)+x[3]*(O-E)+T*O==D*E?null:(D+x[3]-b*O-b*C[3])/(D-T-b*O+b*E)}static getLesserNonNegativeNonNull(e,r){return r!==null&&r>=0&&r_.B(e,r&&r.filter(e=>e.identifier!==`source.canvas`)),ri=_.bM();class Ai extends _.E{constructor(e,r={}){var v,b;super(),this._rtlPluginLoaded=()=>{for(let e in this.tileManagers){let r=this.tileManagers[e].getSource().type;r!==`vector`&&r!==`geojson`||this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new L(ie(),e._getMapId()),this.dispatcher.registerMessageHandler(`GG`,(e,r)=>this.getGlyphs(e,r)),this.dispatcher.registerMessageHandler(`GI`,(e,r)=>this.getImages(e,r)),this.dispatcher.registerMessageHandler(`GDA`,(e,r)=>this.getDashes(e,r)),this.imageManager=new f,this.imageManager.setEventedParent(this);let x=(v=e._container)?.lang||typeof document<`u`&&(b=document.documentElement)?.lang||void 0;this.glyphManager=new y(e._requestManager,r.localIdeographFontFamily,x),this.lineAtlas=new M(256,512),this.crossTileSymbolIndex=new St,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast(`SR`,_.bN()),we().on(xe,this._rtlPluginLoaded),this.on(`data`,e=>{if(e.dataType!==`source`||e.sourceDataType!==`metadata`)return;let r=this.tileManagers[e.sourceId];if(!r)return;let _=r.getSource();if(_&&_.vectorLayerIds)for(let e in this._layers){let r=this._layers[e];r.source===_.id&&this._validateLayer(r)}})}_setInitialValues(){var e;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new _.bO,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new((e=this.crossTileSymbolIndex)?.constructor||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,r){var v,b,x;this._checkLoaded();let C=r===null?(x=(b=(v=this.stylesheet.state)?.[e])?.default)??null:r;if(_.bP(C,this._globalState[e]))return this;this._globalState[e]=C,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();let r=[];for(let v in e)!_.bP(this._globalState[v],e[v].default)&&(r.push(v),this._globalState[v]=e[v].default);this._applyGlobalStateChanges(r)}_applyGlobalStateChanges(e){if(e.length===0)return;let r=/* @__PURE__ */ new Set,_={};for(let v of e){_[v]=this._globalState[v];for(let e in this._layers){let _=this._layers[e],b=_.getLayoutAffectingGlobalStateRefs(),x=_.getPaintAffectingGlobalStateRefs(),C=_.getVisibilityAffectingGlobalStateRefs();if(b.has(v)&&r.add(_.source),x.has(v))for(let{name:e,value:r}of x.get(v))this._updatePaintProperty(_,e,r);C?.has(v)&&(_.recalculateVisibility(),this._updateLayer(_))}}this.dispatcher.broadcast(`UGS`,_);for(let e in this.tileManagers)r.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e){return _._(this,arguments,void 0,function*(e,r={},v){this.fire(new _.l(`dataloading`,{dataType:`style`})),r.validate=typeof r.validate!=`boolean`||r.validate,this._loadStyleRequest=new AbortController;let b=this._loadStyleRequest;try{let x=yield this.map._requestManager.transformRequest(e,`Style`);_.bQ(b.signal);let C=yield _.j(x,b);this._loadStyleRequest===b&&(this._loadStyleRequest=null),this._load(C.data,r,v)}catch(e){this._loadStyleRequest===b&&(this._loadStyleRequest=null),e&&!b.signal.aborted&&this.fire(new _.k(e))}})}loadJSON(e,r={},v){this.fire(new _.l(`dataloading`,{dataType:`style`})),this._frameRequest=new AbortController,E.frameAsync(this._frameRequest,this.map._ownerWindow).then(()=>{this._frameRequest=null,r.validate=!1!==r.validate,this._load(e,r,v)}).catch(()=>{})}loadEmpty(){this.fire(new _.l(`dataloading`,{dataType:`style`})),this._load(ri,{validate:!1})}_load(e,r,v){var b,x;let C=r.transformStyle?r.transformStyle(v,e):e;if(!r.validate||!ei(this,_.C(C))){C=Object.assign({},C),this._loaded=!0,this.stylesheet=C;for(let e in C.sources)this.addSource(e,C.sources[e],{validate:!1});C.sprite?this._loadSprite(C.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(C.glyphs),this._createLayers(),this.light=new P(this.stylesheet.light),this._setProjectionInternal((b=this.stylesheet.projection)?.type||`mercator`),this.sky=new I(this.stylesheet.sky),this.map.setTerrain((x=this.stylesheet.terrain)??null),this.fire(new _.l(`data`,{dataType:`style`})),this.fire(new _.l(`style.load`))}}_createLayers(){var e,r,v;let b=_.bR(this.stylesheet.layers);this.setGlobalState((e=this.stylesheet.state)??null),this.dispatcher.broadcast(`SL`,b),this._order=b.map(e=>e.id),this._layers={},this._serializedLayers=null;for(let e of b){let b=_.bS(e,this._globalState);if(b.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=b,_.bT(b)&&this.tileManagers[b.source]){let _=(v=(r=e.paint)?.[`raster-fade-duration`])??b.paint.get(`raster-fade-duration`);this.tileManagers[b.source].setRasterFadeDuration(_)}}}_loadSprite(e,r=!1,v=void 0){this.imageManager.setLoaded(!1);let b=new AbortController,x;this._spriteRequest=b,function(e,r,v,b){return _._(this,void 0,void 0,function*(){let x=A(e),C=v>1?`@2x`:``,T={},D={};for(let{id:e,url:v}of x){let x=yield r.transformRequest(j(v,C,`.json`),`SpriteJSON`);T[e]=_.j(x,b);let E=yield r.transformRequest(j(v,C,`.png`),`SpriteImage`);D[e]=k.getImage(E,b)}return yield Promise.all([...Object.values(T),...Object.values(D)]),function(e,r){return _._(this,void 0,void 0,function*(){let _={};for(let v in e){_[v]={};let b=E.getImageCanvasContext((yield r[v]).data),x=(yield e[v]).data;for(let e in x){let{width:r,height:C,x:T,y:E,sdf:D,pixelRatio:O,stretchX:k,stretchY:A,content:j,textFitWidth:F,textFitHeight:R}=x[e];_[v][e]={data:null,pixelRatio:O,sdf:D,stretchX:k,stretchY:A,content:j,textFitWidth:F,textFitHeight:R,spriteData:{width:r,height:C,x:T,y:E,context:b}}}}return _})}(T,D)})}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(e=>{if(this._spriteRequest=null,e)for(let _ in e){this._spritesImagesIds[_]=[];let v=this._spritesImagesIds[_]?this._spritesImagesIds[_].filter(r=>!(r in e)):[];for(let e of v)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(let v in e[_]){let b=_===`default`?v:`${_}:${v}`;this._spritesImagesIds[_].push(b),b in this.imageManager.images?this.imageManager.updateImage(b,e[_][v],!1):this.imageManager.addImage(b,e[_][v]),r&&(this._changedImages[b]=!0)}}}).catch(e=>{this._spriteRequest=null,x=e,b.signal.aborted||this.fire(new _.k(x))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),r&&(this._changed=!0),this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new _.l(`data`,{dataType:`style`})),v&&v(x)})}_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 _.l(`data`,{dataType:`style`}))}_validateLayer(e){let r=this.tileManagers[e.source];if(!r)return;let v=e.sourceLayer;if(!v)return;let b=r.getSource();(b.type===`geojson`||b.vectorLayerIds&&b.vectorLayerIds.indexOf(v)===-1)&&this.fire(new _.k(/* @__PURE__ */ Error(`Source layer "${v}" does not exist on source "${b.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,r=!1){let v=this._serializedAllLayers();if(!e||e.length===0)return Object.values(r?_.bU(v):v);let b=[];for(let x of e)if(v[x]){let e=r?_.bU(v[x]):v[x];b.push(e)}return b}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};let r=Object.keys(this._layers);for(let _ of r){let r=this._layers[_];r.type!==`custom`&&(e[_]=r.serialize())}return e}hasTransitions(){var e,r,_;if((e=this.light)?.hasTransition()||(r=this.sky)?.hasTransition()||(_=this.projection)?.hasTransition())return!0;for(let e in this.tileManagers)if(this.tileManagers[e].hasTransition())return!0;for(let e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw Error(`Style is not done loading.`)}update(e){if(!this._loaded)return;let r=this._changed;if(r){let r=Object.keys(this._updatedLayers),_=Object.keys(this._removedLayers);(r.length||_.length)&&this._updateWorkerLayers(r,_);for(let e in this._updatedSources){let r=this._updatedSources[e];if(r===`reload`)this._reloadSource(e);else{if(r!==`clear`)throw Error(`Invalid action ${r}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let r in this._updatedPaintProps)this._layers[r].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}let v={};for(let e in this.tileManagers){let r=this.tileManagers[e];v[e]=r.used,r.used=!1}for(let r of this._order){let _=this._layers[r];_.recalculate(e,this._availableImages),!_.isHidden(e.zoom)&&_.source&&(this.tileManagers[_.source].used=!0)}for(let e in v){let r=this.tileManagers[e];!!v[e]!=!!r.used&&r.fire(new _.l(`data`,{sourceDataType:`visibility`,dataType:`source`,sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,r&&this.fire(new _.l(`data`,{dataType:`style`}))}_updateTilesForChangedImages(){let e=Object.keys(this._changedImages);if(e.length){for(let r in this.tileManagers)this.tileManagers[r].reloadTilesForDependencies([`icons`,`patterns`],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies([`glyphs`],[``]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,r){this.dispatcher.broadcast(`UL`,{layers:this._serializeByIds(e,!1),removedIds:r})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,r={}){var v;this._checkLoaded();let b=this.serialize();if(e=r.transformStyle?r.transformStyle(b,e):e,((v=r.validate)==null||v)&&ei(this,_.C(e)))return!1;(e=_.bU(e)).layers=_.bR(e.layers);let x=_.bV(b,e),C=this._getOperationsToPerform(x);if(C.unimplemented.length>0)throw Error(`Unimplemented: ${C.unimplemented.join(`, `)}.`);if(C.operations.length===0)return!1;for(let e of C.operations)e();return this.stylesheet=e,this._serializedLayers=null,this.fire(new _.l(`style.load`,{style:this})),!0}_getOperationsToPerform(e){let r=[],_=[];for(let v of e)switch(v.command){case`setCenter`:case`setZoom`:case`setBearing`:case`setPitch`:case`setRoll`:continue;case`addLayer`:r.push(()=>this.addLayer.apply(this,v.args));break;case`removeLayer`:r.push(()=>this.removeLayer.apply(this,v.args));break;case`setPaintProperty`:r.push(()=>this.setPaintProperty.apply(this,v.args));break;case`setLayoutProperty`:r.push(()=>this.setLayoutProperty.apply(this,v.args));break;case`setFilter`:r.push(()=>this.setFilter.apply(this,v.args));break;case`addSource`:r.push(()=>this.addSource.apply(this,v.args));break;case`removeSource`:r.push(()=>this.removeSource.apply(this,v.args));break;case`setLayerZoomRange`:r.push(()=>this.setLayerZoomRange.apply(this,v.args));break;case`setLight`:r.push(()=>this.setLight.apply(this,v.args));break;case`setGeoJSONSourceData`:r.push(()=>this.setGeoJSONSourceData.apply(this,v.args));break;case`setGlyphs`:r.push(()=>this.setGlyphs.apply(this,v.args));break;case`setSprite`:r.push(()=>this.setSprite.apply(this,v.args));break;case`setTerrain`:r.push(()=>this.map.setTerrain.apply(this,v.args));break;case`setSky`:r.push(()=>this.setSky.apply(this,v.args));break;case`setProjection`:this.setProjection.apply(this,v.args);break;case`setGlobalState`:r.push(()=>this.setGlobalState.apply(this,v.args));break;case`setTransition`:r.push(()=>{});break;default:_.push(v.command)}return{operations:r,unimplemented:_}}addImage(e,r){if(this.getImage(e))return this.fire(new _.k(/* @__PURE__ */ Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,r),this._afterImageUpdated(e)}updateImage(e,r){this.imageManager.updateImage(e,r)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new _.k(/* @__PURE__ */ 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 _.l(`data`,{dataType:`style`}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,r,v={}){if(this._checkLoaded(),this.tileManagers[e]!==void 0)throw Error(`Source "${e}" already exists.`);if(!r.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(r).join(`, `)}.`);if([`vector`,`raster`,`geojson`,`video`,`image`].indexOf(r.type)>=0&&this._validate(_.C.source,`sources.${e}`,r,null,v))return;this.map&&this.map._collectResourceTiming&&(r.collectResourceTiming=!0);let b=this.tileManagers[e]=new Ae(e,r,this.dispatcher);b.style=this,b.setEventedParent(this,()=>({isSourceLoaded:b.loaded(),source:b.serialize(),sourceId:e})),b.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.tileManagers[e]===void 0)throw Error(`There is no source with this ID=${e}`);for(let r in this._layers)if(this._layers[r].source===e)return this.fire(new _.k(/* @__PURE__ */ Error(`Source "${e}" cannot be removed while layer "${r}" is using it.`)));let r=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],r.fire(new _.l(`data`,{sourceDataType:`metadata`,dataType:`source`,sourceId:e})),r.setEventedParent(null),r.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,r){if(this._checkLoaded(),this.tileManagers[e]===void 0)throw Error(`There is no source with this ID=${e}`);let _=this.tileManagers[e].getSource();if(_.type!==`geojson`)throw Error(`geojsonSource.type is ${_.type}, which is !== 'geojson`);_.setData(r),this._changed=!0}getSource(e){return this.tileManagers[e]&&this.tileManagers[e].getSource()}addLayer(e,r,v={}){this._checkLoaded();let b=e.id;if(this.getLayer(b))return void this.fire(new _.k(/* @__PURE__ */ Error(`Layer "${b}" already exists on this map.`)));let x;if(e.type===`custom`){if(ei(this,_.bW(e)))return;x=_.bS(e,this._globalState)}else{if(`source`in e&&typeof e.source==`object`&&(this.addSource(b,e.source),e=_.bU(e),e=_.e(e,{source:b})),this._validate(_.C.layer,`layers.${b}`,e,{arrayIndex:-1},v))return;x=_.bS(e,this._globalState),this._validateLayer(x),x.setEventedParent(this,{layer:{id:b}})}let C=r?this._order.indexOf(r):this._order.length;if(r&&C===-1)this.fire(new _.k(/* @__PURE__ */ Error(`Cannot add layer "${b}" before non-existing layer "${r}".`)));else{if(this._order.splice(C,0,b),this._layerOrderChanged=!0,this._layers[b]=x,this._removedLayers[b]&&x.source&&x.type!==`custom`){let e=this._removedLayers[b];delete this._removedLayers[b],e.type===x.type?(this._updatedSources[x.source]=`reload`,this.tileManagers[x.source].pause()):this._updatedSources[x.source]=`clear`}this._updateLayer(x),x.onAdd&&x.onAdd(this.map)}}moveLayer(e,r){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new _.k(/* @__PURE__ */ Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===r)return;let v=this._order.indexOf(e);this._order.splice(v,1);let b=r?this._order.indexOf(r):this._order.length;r&&b===-1?this.fire(new _.k(/* @__PURE__ */ Error(`Cannot move layer "${e}" before non-existing layer "${r}".`))):(this._order.splice(b,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();let r=this._layers[e];if(!r)return void this.fire(new _.k(/* @__PURE__ */ Error(`Cannot remove non-existing layer "${e}".`)));r.setEventedParent(null);let v=this._order.indexOf(e);this._order.splice(v,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=r,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],r.onRemove&&r.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,r,v){this._checkLoaded();let b=this.getLayer(e);b?b.minzoom===r&&b.maxzoom===v||(r!=null&&(b.minzoom=r),v!=null&&(b.maxzoom=v),this._updateLayer(b)):this.fire(new _.k(/* @__PURE__ */ Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,r,v={}){this._checkLoaded();let b=this.getLayer(e);if(b){if(!_.bP(b.filter,r))return r==null?(b.setFilter(void 0),void this._updateLayer(b)):void(this._validate(_.C.filter,`layers.${b.id}.filter`,r,null,v)||(b.setFilter(_.bU(r)),this._updateLayer(b)))}else this.fire(new _.k(/* @__PURE__ */ Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return _.bU(this.getLayer(e).filter)}setLayoutProperty(e,r,v,b={}){this._checkLoaded();let x=this.getLayer(e);x?_.bP(x.getLayoutProperty(r),v)||(x.setLayoutProperty(r,v,b),this._updateLayer(x)):this.fire(new _.k(/* @__PURE__ */ Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,r){let v=this.getLayer(e);if(v)return v.getLayoutProperty(r);this.fire(new _.k(/* @__PURE__ */ Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,r,v,b={}){this._checkLoaded();let x=this.getLayer(e);x?_.bP(x.getPaintProperty(r),v)||this._updatePaintProperty(x,r,v,b):this.fire(new _.k(/* @__PURE__ */ Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,r,v,b={}){e.setPaintProperty(r,v,b)&&this._updateLayer(e),_.bT(e)&&r===`raster-fade-duration`&&this.tileManagers[e.source].setRasterFadeDuration(v),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,r){return this.getLayer(e).getPaintProperty(r)}setFeatureState(e,r){this._checkLoaded();let v=e.source,b=e.sourceLayer,x=this.tileManagers[v];if(x===void 0)return void this.fire(new _.k(/* @__PURE__ */ Error(`The source '${v}' does not exist in the map's style.`)));let C=x.getSource().type;C===`geojson`&&b?this.fire(new _.k(/* @__PURE__ */ Error(`GeoJSON sources cannot have a sourceLayer parameter.`))):C!==`vector`||b?(e.id===void 0&&this.fire(new _.k(/* @__PURE__ */ Error(`The feature id parameter must be provided.`))),x.setFeatureState(b,e.id,r)):this.fire(new _.k(/* @__PURE__ */ Error(`The sourceLayer parameter must be provided for vector source types.`)))}removeFeatureState(e,r){this._checkLoaded();let v=e.source,b=this.tileManagers[v];if(b===void 0)return void this.fire(new _.k(/* @__PURE__ */ Error(`The source '${v}' does not exist in the map's style.`)));let x=b.getSource().type,C=x===`vector`?e.sourceLayer:void 0;x!==`vector`||C?r&&typeof e.id!=`string`&&typeof e.id!=`number`?this.fire(new _.k(/* @__PURE__ */ Error(`A feature id is required to remove its specific state property.`))):b.removeFeatureState(C,e.id,r):this.fire(new _.k(/* @__PURE__ */ Error(`The sourceLayer parameter must be provided for vector source types.`)))}getFeatureState(e){this._checkLoaded();let r=e.source,v=e.sourceLayer,b=this.tileManagers[r];if(b!==void 0)return b.getSource().type!==`vector`||v?(e.id===void 0&&this.fire(new _.k(/* @__PURE__ */ Error(`The feature id parameter must be provided.`))),b.getFeatureState(v,e.id)):void this.fire(new _.k(/* @__PURE__ */ Error(`The sourceLayer parameter must be provided for vector source types.`)));this.fire(new _.k(/* @__PURE__ */ Error(`The source '${r}' does not exist in the map's style.`)))}getTransition(){return _.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;let e=_.bX(this.tileManagers,e=>e.serialize()),r=this._serializeByIds(this._order,!0),v=this.map.getTerrain()||void 0,b=this.stylesheet;return _.bY({version:b.version,name:b.name,metadata:b.metadata,light:b.light,sky:b.sky,center:b.center,zoom:b.zoom,bearing:b.bearing,pitch:b.pitch,sprite:b.sprite,glyphs:b.glyphs,transition:b.transition,projection:b.projection,sources:e,layers:r,terrain:v},e=>e!==void 0)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.tileManagers[e.source].getSource().type!==`raster`&&(this._updatedSources[e.source]=`reload`,this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){let r=e=>this._layers[e].type===`fill-extrusion`,_={},v=[];for(let b=this._order.length-1;b>=0;b--){let x=this._order[b];if(r(x)){_[x]=b;for(let r of e){let e=r[x];if(e)for(let r of e)v.push(r)}}}v.sort((e,r)=>r.intersectionZ-e.intersectionZ);let b=[];for(let x=this._order.length-1;x>=0;x--){let C=this._order[x];if(r(C))for(let e=v.length-1;e>=0;e--){let r=v[e].feature;if(_[r.layer.id]this.map.terrain.getElevation(e,r,_):void 0));return this.placement&&x.push(function(e,r,_,v,b,x,C){let T={},E=x.queryRenderedSymbols(v),D=[];for(let e of Object.keys(E).map(Number))D.push(C[e]);D.sort(ce);for(let _ of D){let v=_.featureIndex.lookupSymbolFeatures(E[_.bucketInstanceId],r,_.bucketIndex,_.sourceLayerIndex,{filterSpec:b.filter,globalState:b.globalState},b.layers,b.availableImages,e);for(let e in v){let r=T[e]=T[e]||[],b=v[e];b.sort((e,r)=>{let v=_.featureSortOrder;if(v){let _=v.indexOf(e.featureIndex);return v.indexOf(r.featureIndex)-_}return r.featureIndex-e.featureIndex});for(let e of b)r.push(e)}}return function(e,r,_){for(let v in e)for(let b of e[v])le(b,_[r[v].source]);return e}(T,e,_)}(this._layers,C,this.tileManagers,e,E,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(x)}querySourceFeatures(e,r){r?.filter&&this._validate(_.C.filter,`querySourceFeatures.filter`,r.filter,null,r);let v=this.tileManagers[e];return v?function(e,r){let _=e.getRenderableIds().map(r=>e.getTileByID(r)),v=[],b={};for(let e=0;e<_.length;e++){let x=_[e],C=x.tileID.canonical.key;b[C]||(b[C]=!0,x.querySourceFeatures(v,r))}return v}(v,r?Object.assign(Object.assign({},r),{globalState:this._globalState}):{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(e,r={}){this._checkLoaded();let v=this.light.getLight(),b=!1;for(let r in e)if(!_.bP(e[r],v[r])){b=!0;break}if(!b)return;let x={now:O(),transition:_.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,r),this.light.updateTransitions(x)}getProjection(){var e;return(e=this.stylesheet)?.projection}setProjection(e){this._checkLoaded();let r=e??{type:`mercator`};if(this.stylesheet.projection=e,this.projection){if(this.projection.name===r.type)return;this.projection.destroy(),delete this.projection}this._setProjectionInternal(r.type)}getSky(){var e;return(e=this.stylesheet)?.sky}setSky(e,r={}){this._checkLoaded();let v=this.getSky(),b=!1;if(!e&&!v)return;if(e&&!v)b=!0;else if(!e&&v)b=!0;else for(let r in e)if(!_.bP(e[r],v[r])){b=!0;break}if(!b)return;let x={now:O(),transition:_.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,r),this.sky.updateTransitions(x)}_setProjectionInternal(e){let r=function(e,r){let v={constrainOverride:r};if(Array.isArray(e)){let r=new hi({type:e});return{projection:r,transform:new Ei(v),cameraHelper:new Ri(r)}}switch(e){case`mercator`:return{projection:new Bt,transform:new Wt(v),cameraHelper:new Xt};case`globe`:{let e=new hi({type:[`interpolate`,[`linear`],[`zoom`],11,`vertical-perspective`,12,`mercator`]});return{projection:e,transform:new Ei(v),cameraHelper:new Ri(e)}}case`vertical-perspective`:return{projection:new li,transform:new Mi(v),cameraHelper:new Si};default:return _.w(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new Bt,transform:new Wt(v),cameraHelper:new Xt}}}(e,this.map.transformConstrain);this.projection=r.projection,this.map.migrateProjection(r.transform,r.cameraHelper);for(let e in this.tileManagers)this.tileManagers[e].reload()}_validate(e,r,v,b,x={}){return(!x||!1!==x.validate)&&ei(this,e.call(_.C,_.e({key:r,style:this.serialize(),value:v,styleSpec:_.u},b)))}_remove(e=!0){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null),we().off(xe,this._rtlPluginLoaded);for(let e in this._layers)this._layers[e].setEventedParent(null);for(let e in this.tileManagers){let r=this.tileManagers[e];r.setEventedParent(null),r.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast(`RM`,void 0),this.dispatcher.remove(e)}_clearSource(e){this.tileManagers[e].clearTiles()}_reloadSource(e){this.tileManagers[e].resume(),this.tileManagers[e].reload()}_updateSources(e){for(let r in this.tileManagers)this.tileManagers[r].update(e,this.map.terrain)}_generateCollisionBoxes(){for(let e in this.tileManagers)this._reloadSource(e)}_updatePlacement(e,r,_,v,b=!1){let x=!1,C=!1,T={};for(let r of this._order){let _=this._layers[r];if(_.type!==`symbol`)continue;if(!T[_.source]){let e=this.tileManagers[_.source];T[_.source]=e.getRenderableIds(!0).map(r=>e.getTileByID(r)).sort((e,r)=>r.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(r.tileID)?-1:1))}let v=this.crossTileSymbolIndex.addLayer(_,T[_.source],e.center.lng);x||=v}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((b=b||this._layerOrderChanged||_===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(O(),e.zoom))&&(this.pauseablePlacement=new Pt(e,this.map.terrain,this._order,b,r,_,v,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,T),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(O()),C=!0),x&&this.pauseablePlacement.placement.setStale()),C||x)for(let e of this._order){let r=this._layers[e];r.type===`symbol`&&this.placement.updateLayerOpacities(r,T[r.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(O())}_releaseSymbolFadeTiles(){for(let e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}getImages(e,r){return _._(this,void 0,void 0,function*(){let e=yield this.imageManager.getImages(r.icons);this._updateTilesForChangedImages();let _=this.tileManagers[r.source];return _&&_.setDependencies(r.tileID.key,r.type,r.icons),e})}getGlyphs(e,r){return _._(this,void 0,void 0,function*(){let e=yield this.glyphManager.getGlyphs(r.stacks),_=this.tileManagers[r.source];return _&&_.setDependencies(r.tileID.key,r.type,[``]),e})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,r={}){this._checkLoaded(),e&&this._validate(_.C.glyphs,`glyphs`,e,null,r)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getDashes(e,r){return _._(this,void 0,void 0,function*(){let e={};for(let[_,v]of Object.entries(r.dashes))e[_]=this.lineAtlas.getDash(v.dasharray,v.round);return e})}addSprite(e,r,v={},b){this._checkLoaded();let x=[{id:e,url:r}],C=[...A(this.stylesheet.sprite),...x];this._validate(_.C.sprite,`sprite`,C,null,v)||(this.stylesheet.sprite=C,this._loadSprite(x,!0,b))}removeSprite(e){this._checkLoaded();let r=A(this.stylesheet.sprite);if(r.find(r=>r.id===e)){if(this._spritesImagesIds[e])for(let r of this._spritesImagesIds[e])this.imageManager.removeImage(r),this._changedImages[r]=!0;r.splice(r.findIndex(r=>r.id===e),1),this.stylesheet.sprite=r.length>0?r:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new _.l(`data`,{dataType:`style`}))}else this.fire(new _.k(/* @__PURE__ */ Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return A(this.stylesheet.sprite)}setSprite(e,r={},v){this._checkLoaded(),e&&this._validate(_.C.sprite,`sprite`,e,null,r)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,v):(this._unloadSprite(),v&&v(null)))}destroy(){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null);for(let e in this.tileManagers){let r=this.tileManagers[e];r.setEventedParent(null),r.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(let e in this._layers){let r=this._layers[e];r.setEventedParent(null),r.onRemove&&r.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler(`GG`),this.dispatcher.unregisterMessageHandler(`GI`),this.dispatcher.unregisterMessageHandler(`GDA`),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}}var ii=_.aS([{name:`a_pos`,type:`Int16`,components:2},{name:`a_texture_pos`,type:`Int16`,components:2}]);class ki{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,r,_,v,b,x,C,T,E){this.context=e;let D=this.boundPaintVertexBuffers.length!==v.length;for(let e=0;!D&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:r,u_fog_color:v?v.properties.get(`fog-color`):_.bn.white,u_fog_ground_blend:v?v.properties.get(`fog-ground-blend`):1,u_fog_ground_blend_opacity:x?0:v?v.calculateFogBlendOpacity(b):0,u_horizon_color:v?v.properties.get(`horizon-color`):_.bn.white,u_horizon_fog_blend:v?v.properties.get(`horizon-fog-blend`):1,u_is_globe_mode:x?1:0}),ui={mainMatrix:`u_projection_matrix`,tileMercatorCoords:`u_projection_tile_mercator_coords`,clippingPlane:`u_projection_clipping_plane`,projectionTransition:`u_projection_transition`,fallbackMatrix:`u_projection_fallback_matrix`};function di(e){let r=[];for(let _=0;_({u_depth:new _.bZ(e,r.u_depth),u_terrain:new _.bZ(e,r.u_terrain),u_terrain_dim:new _.bo(e,r.u_terrain_dim),u_terrain_matrix:new _.b$(e,r.u_terrain_matrix),u_terrain_unpack:new _.c0(e,r.u_terrain_unpack),u_terrain_exaggeration:new _.bo(e,r.u_terrain_exaggeration)}))(e,ie),this.projectionUniforms=((e,r)=>({u_projection_matrix:new _.b$(e,r.u_projection_matrix),u_projection_tile_mercator_coords:new _.c0(e,r.u_projection_tile_mercator_coords),u_projection_clipping_plane:new _.c0(e,r.u_projection_clipping_plane),u_projection_transition:new _.bo(e,r.u_projection_transition),u_projection_fallback_matrix:new _.b$(e,r.u_projection_fallback_matrix)}))(e,ie),this.binderUniforms=v?v.getUniforms(e,ie):[]}draw(e,r,_,v,b,x,C,T,E,D,O,k,A,j,F,R,z,B,H){let K=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(_),e.setStencilMode(v),e.setColorMode(b),e.setCullFace(x),T){e.activeTexture.set(K.TEXTURE2),K.bindTexture(K.TEXTURE_2D,T.depthTexture),e.activeTexture.set(K.TEXTURE3),K.bindTexture(K.TEXTURE_2D,T.texture);for(let e in this.terrainUniforms)this.terrainUniforms[e].set(T[e])}if(E)for(let e in E)this.projectionUniforms[ui[e]].set(E[e]);if(C)for(let e in this.fixedUniforms)this.fixedUniforms[e].set(C[e]);R&&R.setUniforms(e,this.binderUniforms,j,{zoom:F});let q=0;switch(r){case K.LINES:q=2;break;case K.TRIANGLES:q=3;break;case K.LINE_STRIP:q=1}for(let _ of A.get()){let v=_.vaos||={};(v[D]||(v[D]=new ki)).bind(e,this,O,R?R.getPaintVertexBuffers():[],k,_.vertexOffset,z,B,H),K.drawElements(r,_.primitiveLength*q,K.UNSIGNED_SHORT,_.primitiveOffset*q*2)}}}function fi(e,r,v){let b=1/_.aK(v,1,r.transform.tileZoom),x=2**v.tileID.overscaledZ,C=v.tileSize*2**r.transform.tileZoom/x,T=C*(v.tileID.canonical.x+v.tileID.wrap*x),E=C*v.tileID.canonical.y;return{u_image:0,u_texsize:v.imageAtlasTexture.size,u_scale:[b,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[T>>16,E>>16],u_pixel_coord_lower:[65535&T,65535&E]}}let pi=(e,r,v,b)=>{let x=e.style.light,C=x.properties.get(`position`),T=[C.x,C.y,C.z],E=_.c3();x.properties.get(`anchor`)===`viewport`&&_.c4(E,e.transform.bearingInRadians),_.c5(T,T,E);let D=e.transform.transformLightDirection(T),O=x.properties.get(`color`);return{u_lightpos:T,u_lightpos_globe:D,u_lightintensity:x.properties.get(`intensity`),u_lightcolor:[O.r,O.g,O.b],u_vertical_gradient:+r,u_opacity:v,u_fill_translate:b}},mi=(e,r,v,b,x,C,T)=>_.e(pi(e,r,v,b),fi(C,e,T),{u_height_factor:-(2**x.overscaledZ)/T.tileSize/8}),gi=(e,r,v,b)=>_.e(fi(r,e,v),{u_fill_translate:b}),_i=(e,r)=>({u_world:e,u_fill_translate:r}),vi=(e,r,v,b,x)=>_.e(gi(e,r,v,x),{u_world:b}),bi=(e,r,v,b,x)=>{let C=e.transform,T,E,D=0;if(v.paint.get(`circle-pitch-alignment`)===`map`){let e=_.aK(r,1,C.zoom);T=!0,E=[e,e],D=e/(_.a5*2**r.tileID.overscaledZ)*2*Math.PI*x}else T=!1,E=C.pixelsToGLUnits;return{u_camera_to_center_distance:C.cameraToCenterDistance,u_scale_with_map:+(v.paint.get(`circle-pitch-scale`)===`map`),u_pitch_with_map:+T,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:E,u_globe_extrude_scale:D,u_translate:b}},xi=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Ti=e=>({u_viewport_size:[e.width,e.height]}),Di=(e,r=1)=>({u_color:e,u_overlay:0,u_overlay_scale:r}),Oi=(e,r,v,b)=>{let x=_.aK(e,1,r)/(_.a5*2**e.tileID.overscaledZ)*2*Math.PI*b;return{u_extrude_scale:_.aK(e,1,r),u_intensity:v,u_globe_extrude_scale:x}},Ni=(e,r,v,b)=>{let x=_.N();_.c6(x,0,e.width,e.height,0,0,1);let C=e.context.gl;return{u_matrix:x,u_world:[C.drawingBufferWidth,C.drawingBufferHeight],u_image:v,u_color_ramp:b,u_opacity:r.paint.get(`heatmap-opacity`)}},Pi=(e,r,_)=>{let v=_.paint.get(`hillshade-accent-color`),b;switch(_.paint.get(`hillshade-method`)){case`basic`:b=4;break;case`combined`:b=1;break;case`igor`:b=2;break;case`multidirectional`:b=3;break;default:b=0}let x=_.getIlluminationProperties();for(let r=0;r{let v=r.stride,b=_.N();return _.c6(b,0,_.a5,-_.a5,0,0,1),_.O(b,b,[0,-_.a5,0]),{u_matrix:b,u_image:1,u_dimension:[v,v],u_zoom:e.overscaledZ,u_unpack:r.getUnpackVector()}};function Ii(e,r){let v=2**r.canonical.z,b=r.canonical.y;return[new _.a6(0,b/v).toLngLat().lat,new _.a6(0,(b+1)/v).toLngLat().lat]}let Li=(e,r,_=0)=>({u_image:0,u_unpack:r.getUnpackVector(),u_dimension:[r.stride,r.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:_,u_opacity:e.paint.get(`color-relief-opacity`)}),zi=(e,r,v,b)=>{let x=e.transform;return{u_translation:Gi(e,r,v),u_ratio:b/_.aK(r,1,x.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/x.pixelsToGLUnits[0],1/x.pixelsToGLUnits[1]]}},Bi=(e,r,v,b,x)=>_.e(zi(e,r,v,b),{u_image:0,u_image_height:x}),Vi=(e,r,v,b,x)=>{let C=e.transform,T=Wi(r,C);return{u_translation:Gi(e,r,v),u_texsize:r.imageAtlasTexture.size,u_ratio:b/_.aK(r,1,C.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[T,x.fromScale,x.toScale],u_fade:x.t,u_units_to_pixels:[1/C.pixelsToGLUnits[0],1/C.pixelsToGLUnits[1]]}},Hi=(e,r,v,b,x)=>{let C=Wi(r,e.transform);return _.e(zi(e,r,v,b),{u_tileratio:C,u_crossfade_from:x.fromScale,u_crossfade_to:x.toScale,u_image:0,u_mix:x.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},Ui=(e,r,v,b,x,C)=>{let T=Wi(r,e.transform);return _.e(zi(e,r,v,b),{u_image:0,u_image_height:C,u_tileratio:T,u_crossfade_from:x.fromScale,u_crossfade_to:x.toScale,u_image_dash:1,u_mix:x.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function Wi(e,r){return 1/_.aK(e,1,r.tileZoom)}function Gi(e,r,v){return _.aL(e.transform,r,v.paint.get(`line-translate`),v.paint.get(`line-translate-anchor`))}let Ki=(e,r,_,v,b)=>{return{u_tl_parent:e,u_scale_parent:r,u_buffer_scale:1,u_fade_t:_.mix,u_opacity:_.opacity*v.paint.get(`raster-opacity`),u_image0:0,u_image1:1,u_brightness_low:v.paint.get(`raster-brightness-min`),u_brightness_high:v.paint.get(`raster-brightness-max`),u_saturation_factor:(C=v.paint.get(`raster-saturation`),C>0?1-1/(1.001-C):-C),u_contrast_factor:(x=v.paint.get(`raster-contrast`),x>0?1/(1-x):1+x),u_spin_weights:qi(v.paint.get(`raster-hue-rotate`)),u_coords_top:[b[0].x,b[0].y,b[1].x,b[1].y],u_coords_bottom:[b[3].x,b[3].y,b[2].x,b[2].y]};var x,C};function qi(e){e*=Math.PI/180;let r=Math.sin(e),_=Math.cos(e);return[(2*_+1)/3,(-Math.sqrt(3)*r-_+1)/3,(Math.sqrt(3)*r-_+1)/3]}let Ji=(e,r,_,v,b,x,C,T,E,D,O,k,A)=>{let j=C.transform;return{u_is_size_zoom_constant:+(e===`constant`||e===`source`),u_is_size_feature_constant:+(e===`constant`||e===`camera`),u_size_t:r?r.uSizeT:0,u_size:r?r.uSize:0,u_camera_to_center_distance:j.cameraToCenterDistance,u_pitch:j.pitch/360*2*Math.PI,u_rotate_symbol:+_,u_aspect_ratio:j.width/j.height,u_fade_change:C.options.fadeDuration?C.symbolFadeChange:1,u_label_plane_matrix:T,u_coord_matrix:E,u_is_text:+O,u_pitch_with_map:+v,u_is_along_line:b,u_is_variable_anchor:x,u_texsize:k,u_texture:0,u_translation:D,u_pitched_scale:A}},Yi=(e,r,v,b,x,C,T,E,D,O,k,A,j,F)=>{let R=T.transform;return _.e(Ji(e,r,v,b,x,C,T,E,D,O,k,A,F),{u_gamma_scale:b?Math.cos(R.pitch*Math.PI/180)*R.cameraToCenterDistance:1,u_device_pixel_ratio:T.pixelRatio,u_is_halo:1})},Xi=(e,r,v,b,x,C,T,E,D,O,k,A,j)=>_.e(Yi(e,r,v,b,x,C,T,E,D,O,!0,k,0,j),{u_texsize_icon:A,u_texture_icon:1}),Zi=(e,r)=>({u_opacity:e,u_color:r}),Qi=(e,r,v,b,x)=>_.e(function(e,r,v,b){let x=v.imageManager.getPattern(e.from.toString()),C=v.imageManager.getPattern(e.to.toString()),{width:T,height:E}=v.imageManager.getPixelSize(),D=2**b.tileID.overscaledZ,O=b.tileSize*2**v.transform.tileZoom/D,k=O*(b.tileID.canonical.x+b.tileID.wrap*D),A=O*b.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:x.tl,u_pattern_br_a:x.br,u_pattern_tl_b:C.tl,u_pattern_br_b:C.br,u_texsize:[T,E],u_mix:r.t,u_pattern_size_a:x.displaySize,u_pattern_size_b:C.displaySize,u_scale_a:r.fromScale,u_scale_b:r.toScale,u_tile_units_to_pixels:1/_.aK(b,1,v.transform.tileZoom),u_pixel_coord_upper:[k>>16,A>>16],u_pixel_coord_lower:[65535&k,65535&A]}}(v,x,r,b),{u_opacity:e}),$i=(e,r)=>{},aa={fillExtrusion:(e,r)=>({u_lightpos:new _.c1(e,r.u_lightpos),u_lightpos_globe:new _.c1(e,r.u_lightpos_globe),u_lightintensity:new _.bo(e,r.u_lightintensity),u_lightcolor:new _.c1(e,r.u_lightcolor),u_vertical_gradient:new _.bo(e,r.u_vertical_gradient),u_opacity:new _.bo(e,r.u_opacity),u_fill_translate:new _.c2(e,r.u_fill_translate)}),fillExtrusionPattern:(e,r)=>({u_lightpos:new _.c1(e,r.u_lightpos),u_lightpos_globe:new _.c1(e,r.u_lightpos_globe),u_lightintensity:new _.bo(e,r.u_lightintensity),u_lightcolor:new _.c1(e,r.u_lightcolor),u_vertical_gradient:new _.bo(e,r.u_vertical_gradient),u_height_factor:new _.bo(e,r.u_height_factor),u_opacity:new _.bo(e,r.u_opacity),u_fill_translate:new _.c2(e,r.u_fill_translate),u_image:new _.bZ(e,r.u_image),u_texsize:new _.c2(e,r.u_texsize),u_pixel_coord_upper:new _.c2(e,r.u_pixel_coord_upper),u_pixel_coord_lower:new _.c2(e,r.u_pixel_coord_lower),u_scale:new _.c1(e,r.u_scale),u_fade:new _.bo(e,r.u_fade)}),fill:(e,r)=>({u_fill_translate:new _.c2(e,r.u_fill_translate)}),fillPattern:(e,r)=>({u_image:new _.bZ(e,r.u_image),u_texsize:new _.c2(e,r.u_texsize),u_pixel_coord_upper:new _.c2(e,r.u_pixel_coord_upper),u_pixel_coord_lower:new _.c2(e,r.u_pixel_coord_lower),u_scale:new _.c1(e,r.u_scale),u_fade:new _.bo(e,r.u_fade),u_fill_translate:new _.c2(e,r.u_fill_translate)}),fillOutline:(e,r)=>({u_world:new _.c2(e,r.u_world),u_fill_translate:new _.c2(e,r.u_fill_translate)}),fillOutlinePattern:(e,r)=>({u_world:new _.c2(e,r.u_world),u_image:new _.bZ(e,r.u_image),u_texsize:new _.c2(e,r.u_texsize),u_pixel_coord_upper:new _.c2(e,r.u_pixel_coord_upper),u_pixel_coord_lower:new _.c2(e,r.u_pixel_coord_lower),u_scale:new _.c1(e,r.u_scale),u_fade:new _.bo(e,r.u_fade),u_fill_translate:new _.c2(e,r.u_fill_translate)}),circle:(e,r)=>({u_camera_to_center_distance:new _.bo(e,r.u_camera_to_center_distance),u_scale_with_map:new _.bZ(e,r.u_scale_with_map),u_pitch_with_map:new _.bZ(e,r.u_pitch_with_map),u_extrude_scale:new _.c2(e,r.u_extrude_scale),u_device_pixel_ratio:new _.bo(e,r.u_device_pixel_ratio),u_globe_extrude_scale:new _.bo(e,r.u_globe_extrude_scale),u_translate:new _.c2(e,r.u_translate)}),collisionBox:(e,r)=>({u_pixel_extrude_scale:new _.c2(e,r.u_pixel_extrude_scale)}),collisionCircle:(e,r)=>({u_viewport_size:new _.c2(e,r.u_viewport_size)}),debug:(e,r)=>({u_color:new _.b_(e,r.u_color),u_overlay:new _.bZ(e,r.u_overlay),u_overlay_scale:new _.bo(e,r.u_overlay_scale)}),depth:$i,clippingMask:$i,heatmap:(e,r)=>({u_extrude_scale:new _.bo(e,r.u_extrude_scale),u_intensity:new _.bo(e,r.u_intensity),u_globe_extrude_scale:new _.bo(e,r.u_globe_extrude_scale)}),heatmapTexture:(e,r)=>({u_matrix:new _.b$(e,r.u_matrix),u_world:new _.c2(e,r.u_world),u_image:new _.bZ(e,r.u_image),u_color_ramp:new _.bZ(e,r.u_color_ramp),u_opacity:new _.bo(e,r.u_opacity)}),hillshade:(e,r)=>({u_image:new _.bZ(e,r.u_image),u_latrange:new _.c2(e,r.u_latrange),u_exaggeration:new _.bo(e,r.u_exaggeration),u_altitudes:new _.c8(e,r.u_altitudes),u_azimuths:new _.c8(e,r.u_azimuths),u_accent:new _.b_(e,r.u_accent),u_method:new _.bZ(e,r.u_method),u_shadows:new _.c7(e,r.u_shadows),u_highlights:new _.c7(e,r.u_highlights)}),hillshadePrepare:(e,r)=>({u_matrix:new _.b$(e,r.u_matrix),u_image:new _.bZ(e,r.u_image),u_dimension:new _.c2(e,r.u_dimension),u_zoom:new _.bo(e,r.u_zoom),u_unpack:new _.c0(e,r.u_unpack)}),colorRelief:(e,r)=>({u_image:new _.bZ(e,r.u_image),u_unpack:new _.c0(e,r.u_unpack),u_dimension:new _.c2(e,r.u_dimension),u_elevation_stops:new _.bZ(e,r.u_elevation_stops),u_color_stops:new _.bZ(e,r.u_color_stops),u_color_ramp_size:new _.bZ(e,r.u_color_ramp_size),u_opacity:new _.bo(e,r.u_opacity)}),line:(e,r)=>({u_translation:new _.c2(e,r.u_translation),u_ratio:new _.bo(e,r.u_ratio),u_device_pixel_ratio:new _.bo(e,r.u_device_pixel_ratio),u_units_to_pixels:new _.c2(e,r.u_units_to_pixels)}),lineGradient:(e,r)=>({u_translation:new _.c2(e,r.u_translation),u_ratio:new _.bo(e,r.u_ratio),u_device_pixel_ratio:new _.bo(e,r.u_device_pixel_ratio),u_units_to_pixels:new _.c2(e,r.u_units_to_pixels),u_image:new _.bZ(e,r.u_image),u_image_height:new _.bo(e,r.u_image_height)}),linePattern:(e,r)=>({u_translation:new _.c2(e,r.u_translation),u_texsize:new _.c2(e,r.u_texsize),u_ratio:new _.bo(e,r.u_ratio),u_device_pixel_ratio:new _.bo(e,r.u_device_pixel_ratio),u_image:new _.bZ(e,r.u_image),u_units_to_pixels:new _.c2(e,r.u_units_to_pixels),u_scale:new _.c1(e,r.u_scale),u_fade:new _.bo(e,r.u_fade)}),lineSDF:(e,r)=>({u_translation:new _.c2(e,r.u_translation),u_ratio:new _.bo(e,r.u_ratio),u_device_pixel_ratio:new _.bo(e,r.u_device_pixel_ratio),u_units_to_pixels:new _.c2(e,r.u_units_to_pixels),u_image:new _.bZ(e,r.u_image),u_mix:new _.bo(e,r.u_mix),u_tileratio:new _.bo(e,r.u_tileratio),u_crossfade_from:new _.bo(e,r.u_crossfade_from),u_crossfade_to:new _.bo(e,r.u_crossfade_to),u_lineatlas_width:new _.bo(e,r.u_lineatlas_width),u_lineatlas_height:new _.bo(e,r.u_lineatlas_height)}),lineGradientSDF:(e,r)=>({u_translation:new _.c2(e,r.u_translation),u_ratio:new _.bo(e,r.u_ratio),u_device_pixel_ratio:new _.bo(e,r.u_device_pixel_ratio),u_units_to_pixels:new _.c2(e,r.u_units_to_pixels),u_image:new _.bZ(e,r.u_image),u_image_height:new _.bo(e,r.u_image_height),u_tileratio:new _.bo(e,r.u_tileratio),u_crossfade_from:new _.bo(e,r.u_crossfade_from),u_crossfade_to:new _.bo(e,r.u_crossfade_to),u_image_dash:new _.bZ(e,r.u_image_dash),u_mix:new _.bo(e,r.u_mix),u_lineatlas_width:new _.bo(e,r.u_lineatlas_width),u_lineatlas_height:new _.bo(e,r.u_lineatlas_height)}),raster:(e,r)=>({u_tl_parent:new _.c2(e,r.u_tl_parent),u_scale_parent:new _.bo(e,r.u_scale_parent),u_buffer_scale:new _.bo(e,r.u_buffer_scale),u_fade_t:new _.bo(e,r.u_fade_t),u_opacity:new _.bo(e,r.u_opacity),u_image0:new _.bZ(e,r.u_image0),u_image1:new _.bZ(e,r.u_image1),u_brightness_low:new _.bo(e,r.u_brightness_low),u_brightness_high:new _.bo(e,r.u_brightness_high),u_saturation_factor:new _.bo(e,r.u_saturation_factor),u_contrast_factor:new _.bo(e,r.u_contrast_factor),u_spin_weights:new _.c1(e,r.u_spin_weights),u_coords_top:new _.c0(e,r.u_coords_top),u_coords_bottom:new _.c0(e,r.u_coords_bottom)}),symbolIcon:(e,r)=>({u_is_size_zoom_constant:new _.bZ(e,r.u_is_size_zoom_constant),u_is_size_feature_constant:new _.bZ(e,r.u_is_size_feature_constant),u_size_t:new _.bo(e,r.u_size_t),u_size:new _.bo(e,r.u_size),u_camera_to_center_distance:new _.bo(e,r.u_camera_to_center_distance),u_pitch:new _.bo(e,r.u_pitch),u_rotate_symbol:new _.bZ(e,r.u_rotate_symbol),u_aspect_ratio:new _.bo(e,r.u_aspect_ratio),u_fade_change:new _.bo(e,r.u_fade_change),u_label_plane_matrix:new _.b$(e,r.u_label_plane_matrix),u_coord_matrix:new _.b$(e,r.u_coord_matrix),u_is_text:new _.bZ(e,r.u_is_text),u_pitch_with_map:new _.bZ(e,r.u_pitch_with_map),u_is_along_line:new _.bZ(e,r.u_is_along_line),u_is_variable_anchor:new _.bZ(e,r.u_is_variable_anchor),u_texsize:new _.c2(e,r.u_texsize),u_texture:new _.bZ(e,r.u_texture),u_translation:new _.c2(e,r.u_translation),u_pitched_scale:new _.bo(e,r.u_pitched_scale)}),symbolSDF:(e,r)=>({u_is_size_zoom_constant:new _.bZ(e,r.u_is_size_zoom_constant),u_is_size_feature_constant:new _.bZ(e,r.u_is_size_feature_constant),u_size_t:new _.bo(e,r.u_size_t),u_size:new _.bo(e,r.u_size),u_camera_to_center_distance:new _.bo(e,r.u_camera_to_center_distance),u_pitch:new _.bo(e,r.u_pitch),u_rotate_symbol:new _.bZ(e,r.u_rotate_symbol),u_aspect_ratio:new _.bo(e,r.u_aspect_ratio),u_fade_change:new _.bo(e,r.u_fade_change),u_label_plane_matrix:new _.b$(e,r.u_label_plane_matrix),u_coord_matrix:new _.b$(e,r.u_coord_matrix),u_is_text:new _.bZ(e,r.u_is_text),u_pitch_with_map:new _.bZ(e,r.u_pitch_with_map),u_is_along_line:new _.bZ(e,r.u_is_along_line),u_is_variable_anchor:new _.bZ(e,r.u_is_variable_anchor),u_texsize:new _.c2(e,r.u_texsize),u_texture:new _.bZ(e,r.u_texture),u_gamma_scale:new _.bo(e,r.u_gamma_scale),u_device_pixel_ratio:new _.bo(e,r.u_device_pixel_ratio),u_is_halo:new _.bZ(e,r.u_is_halo),u_translation:new _.c2(e,r.u_translation),u_pitched_scale:new _.bo(e,r.u_pitched_scale)}),symbolTextAndIcon:(e,r)=>({u_is_size_zoom_constant:new _.bZ(e,r.u_is_size_zoom_constant),u_is_size_feature_constant:new _.bZ(e,r.u_is_size_feature_constant),u_size_t:new _.bo(e,r.u_size_t),u_size:new _.bo(e,r.u_size),u_camera_to_center_distance:new _.bo(e,r.u_camera_to_center_distance),u_pitch:new _.bo(e,r.u_pitch),u_rotate_symbol:new _.bZ(e,r.u_rotate_symbol),u_aspect_ratio:new _.bo(e,r.u_aspect_ratio),u_fade_change:new _.bo(e,r.u_fade_change),u_label_plane_matrix:new _.b$(e,r.u_label_plane_matrix),u_coord_matrix:new _.b$(e,r.u_coord_matrix),u_is_text:new _.bZ(e,r.u_is_text),u_pitch_with_map:new _.bZ(e,r.u_pitch_with_map),u_is_along_line:new _.bZ(e,r.u_is_along_line),u_is_variable_anchor:new _.bZ(e,r.u_is_variable_anchor),u_texsize:new _.c2(e,r.u_texsize),u_texsize_icon:new _.c2(e,r.u_texsize_icon),u_texture:new _.bZ(e,r.u_texture),u_texture_icon:new _.bZ(e,r.u_texture_icon),u_gamma_scale:new _.bo(e,r.u_gamma_scale),u_device_pixel_ratio:new _.bo(e,r.u_device_pixel_ratio),u_is_halo:new _.bZ(e,r.u_is_halo),u_translation:new _.c2(e,r.u_translation),u_pitched_scale:new _.bo(e,r.u_pitched_scale)}),background:(e,r)=>({u_opacity:new _.bo(e,r.u_opacity),u_color:new _.b_(e,r.u_color)}),backgroundPattern:(e,r)=>({u_opacity:new _.bo(e,r.u_opacity),u_image:new _.bZ(e,r.u_image),u_pattern_tl_a:new _.c2(e,r.u_pattern_tl_a),u_pattern_br_a:new _.c2(e,r.u_pattern_br_a),u_pattern_tl_b:new _.c2(e,r.u_pattern_tl_b),u_pattern_br_b:new _.c2(e,r.u_pattern_br_b),u_texsize:new _.c2(e,r.u_texsize),u_mix:new _.bo(e,r.u_mix),u_pattern_size_a:new _.c2(e,r.u_pattern_size_a),u_pattern_size_b:new _.c2(e,r.u_pattern_size_b),u_scale_a:new _.bo(e,r.u_scale_a),u_scale_b:new _.bo(e,r.u_scale_b),u_pixel_coord_upper:new _.c2(e,r.u_pixel_coord_upper),u_pixel_coord_lower:new _.c2(e,r.u_pixel_coord_lower),u_tile_units_to_pixels:new _.bo(e,r.u_tile_units_to_pixels)}),terrain:(e,r)=>({u_texture:new _.bZ(e,r.u_texture),u_ele_delta:new _.bo(e,r.u_ele_delta),u_fog_matrix:new _.b$(e,r.u_fog_matrix),u_fog_color:new _.b_(e,r.u_fog_color),u_fog_ground_blend:new _.bo(e,r.u_fog_ground_blend),u_fog_ground_blend_opacity:new _.bo(e,r.u_fog_ground_blend_opacity),u_horizon_color:new _.b_(e,r.u_horizon_color),u_horizon_fog_blend:new _.bo(e,r.u_horizon_fog_blend),u_is_globe_mode:new _.bo(e,r.u_is_globe_mode)}),terrainDepth:(e,r)=>({u_ele_delta:new _.bo(e,r.u_ele_delta)}),terrainCoords:(e,r)=>({u_texture:new _.bZ(e,r.u_texture),u_terrain_coords_id:new _.bo(e,r.u_terrain_coords_id),u_ele_delta:new _.bo(e,r.u_ele_delta)}),projectionErrorMeasurement:(e,r)=>({u_input:new _.bo(e,r.u_input),u_output_expected:new _.bo(e,r.u_output_expected)}),atmosphere:(e,r)=>({u_sun_pos:new _.c1(e,r.u_sun_pos),u_atmosphere_blend:new _.bo(e,r.u_atmosphere_blend),u_globe_position:new _.c1(e,r.u_globe_position),u_globe_radius:new _.bo(e,r.u_globe_radius),u_inv_proj_matrix:new _.b$(e,r.u_inv_proj_matrix)}),sky:(e,r)=>({u_sky_color:new _.b_(e,r.u_sky_color),u_horizon_color:new _.b_(e,r.u_horizon_color),u_horizon:new _.c2(e,r.u_horizon),u_horizon_normal:new _.c2(e,r.u_horizon_normal),u_sky_horizon_blend:new _.bo(e,r.u_sky_horizon_blend),u_sky_blend:new _.bo(e,r.u_sky_blend)})};class xo{constructor(e,r,_){this.context=e;let v=e.gl;this.buffer=v.createBuffer(),this.dynamicDraw=!!_,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),v.bufferData(v.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?v.DYNAMIC_DRAW:v.STATIC_DRAW),this.dynamicDraw||r.freeBufferAfterUpload()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){let r=this.context.gl;if(!this.dynamicDraw)throw Error(`Attempted to update data while not in dynamic mode.`);this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let ca={Int8:`BYTE`,Uint8:`UNSIGNED_BYTE`,Int16:`SHORT`,Uint16:`UNSIGNED_SHORT`,Int32:`INT`,Uint32:`UNSIGNED_INT`,Float32:`FLOAT`};class yo{constructor(e,r,_,v){this.length=r.length,this.attributes=_,this.itemSize=r.bytesPerElement,this.dynamicDraw=v,this.context=e;let b=e.gl;this.buffer=b.createBuffer(),e.bindVertexBuffer.set(this.buffer),b.bufferData(b.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?b.DYNAMIC_DRAW:b.STATIC_DRAW),this.dynamicDraw||r.freeBufferAfterUpload()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);let r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,r){for(let _=0;_0&&(O.push({circleArray:z,circleOffset:A,coord:j}),k+=z.length/4,A=k),R&&D.draw(C,E.LINES,Jt.disabled,ti.disabled,e.colorModeForRenderPass(),Qt.disabled,xi(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(j),T.getProjectionData({overscaledTileID:j,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),v.id,R.layoutVertexBuffer,R.indexBuffer,R.segments,null,e.transform.zoom,null,null,R.collisionVertexBuffer)}if(!x||!O.length)return;let j=e.useProgram(`collisionCircle`),F=new _.c9;F.resize(4*k),F._trim();let R=0;for(let e of O)for(let r=0;r=0&&(z[B.associatedIconIndex]={shiftedAnchor:se,angle:ce})}else gn(B.numGlyphs,F)}if(D){R.clear();let r=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(E,r,_):null;zt(D,e,x,ye,be,H,O,v.layout.get(`text-rotation-alignment`)===`map`,E.toUnwrapped(),z.width,z.height,Se,r)}let Me=x&&Z||je,Ne=K||Me?pa:H?ye:e.transform.clipSpaceToPixelsMatrix,Ie=F&&v.paint.get(x?`text-halo-width`:`icon-halo-width`).constantOr(1)!==0,Ue;Ue=F?D.iconsInText?Xi(ne.kind,ce,q,H,K,Me,e,Ne,xe,Se,de,ge,ae):Yi(ne.kind,ce,q,H,K,Me,e,Ne,xe,Se,x,de,0,ae):Ji(ne.kind,ce,q,H,K,Me,e,Ne,xe,Se,x,de,ae);let We={program:se,buffers:k,uniformValues:Ue,projectionData:we,atlasTexture:fe,atlasTextureIcon:_e,atlasInterpolation:pe,atlasInterpolationIcon:me,isSDF:F,hasHalo:Ie};if(Y&&D.canOverlap){X=!0;let e=k.segments.get();for(let r of e)ie.push({segments:new _.aV([r]),sortKey:r.sortKey,state:We,terrainData:le})}else ie.push({segments:k.segments,sortKey:0,state:We,terrainData:le})}X&&ie.sort((e,r)=>e.sortKey-r.sortKey);for(let r of ie){let _=r.state;if(F.activeTexture.set(R.TEXTURE0),_.atlasTexture.bind(_.atlasInterpolation,R.CLAMP_TO_EDGE),_.atlasTextureIcon&&(F.activeTexture.set(R.TEXTURE1),_.atlasTextureIcon&&_.atlasTextureIcon.bind(_.atlasInterpolationIcon,R.CLAMP_TO_EDGE)),_.isSDF){let b=_.uniformValues;_.hasHalo&&(b.u_is_halo=1,ya(_.buffers,r.segments,v,e,_.program,ne,k,A,b,_.projectionData,r.terrainData)),b.u_is_halo=0}ya(_.buffers,r.segments,v,e,_.program,ne,k,A,_.uniformValues,_.projectionData,r.terrainData)}}function ya(e,r,_,v,b,x,C,T,E,D,O){let k=v.context;b.draw(k,k.gl.TRIANGLES,x,C,T,Qt.backCCW,E,O,D,_.id,e.layoutVertexBuffer,e.indexBuffer,r,_.paint,v.transform.zoom,e.programConfigurations.get(_.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function xa(e,r,v,b,x){let C=e.context,T=C.gl,E=ti.disabled,D=new Kt([T.ONE,T.ONE],_.bn.transparent,[!0,!0,!0,!0]),O=r.getBucket(v);if(!O)return;let k=b.key,A=v.heatmapFbos.get(k);A||(A=wa(C,r.tileSize,r.tileSize),v.heatmapFbos.set(k,A)),C.bindFramebuffer.set(A.framebuffer),C.viewport.set([0,0,r.tileSize,r.tileSize]),C.clear({color:_.bn.transparent});let j=O.programConfigurations.get(v.id),F=e.useProgram(`heatmap`,j,!x),R=e.transform.getProjectionData({overscaledTileID:r.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),z=e.style.map.terrain.getTerrainData(b);F.draw(C,T.TRIANGLES,Jt.disabled,E,D,Qt.disabled,Oi(r,e.transform.zoom,v.paint.get(`heatmap-intensity`),1),z,R,v.id,O.layoutVertexBuffer,O.indexBuffer,O.segments,v.paint,e.transform.zoom,j)}function Sa(e,r,_,v,b){let x=e.context,C=x.gl,T=e.transform;x.setColorMode(e.colorModeForRenderPass());let E=Ta(x,r),D=_.key,O=r.heatmapFbos.get(D);if(!O)return;x.activeTexture.set(C.TEXTURE0),C.bindTexture(C.TEXTURE_2D,O.colorAttachment.get()),x.activeTexture.set(C.TEXTURE1),E.bind(C.LINEAR,C.CLAMP_TO_EDGE);let k=T.getProjectionData({overscaledTileID:_,applyTerrainMatrix:b,applyGlobeMatrix:!v});e.useProgram(`heatmapTexture`).draw(x,C.TRIANGLES,Jt.disabled,ti.disabled,e.colorModeForRenderPass(),Qt.disabled,Ni(e,r,0,1),null,k,r.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,r.paint,T.zoom),O.destroy(),r.heatmapFbos.delete(D)}function wa(e,r,_){var v,b;let x=e.gl,C=x.createTexture();x.bindTexture(x.TEXTURE_2D,C),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_WRAP_S,x.CLAMP_TO_EDGE),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_WRAP_T,x.CLAMP_TO_EDGE),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_MIN_FILTER,x.LINEAR),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_MAG_FILTER,x.LINEAR);let T=(v=e.HALF_FLOAT)??x.UNSIGNED_BYTE,E=(b=e.RGBA16F)??x.RGBA;x.texImage2D(x.TEXTURE_2D,0,E,r,_,0,x.RGBA,T,null);let D=e.createFramebuffer(r,_,!1,!1);return D.colorAttachment.set(C),D}function Ta(e,r){return r.colorRampTexture||=new _.T(e,r.colorRamp,e.gl.RGBA),r.colorRampTexture}function Ea(e,r,v,b,x,C,T,E){let D=256;if(x.stepInterpolant){let b=r.getSource().maxzoom,x=T.canonical.z===b?Math.ceil(1<e.options.anisotropicFilterPitch&&A.texParameterf(A.TEXTURE_2D,k.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,k.extTextureFilterAnisotropicMax);let se=e.style.map.terrain&&e.style.map.terrain.getTerrainData(X),ce=F.getProjectionData({overscaledTileID:X,aligned:B,applyGlobeMatrix:!D,applyTerrainMatrix:!0}),le=Ki(ae,ie,oe.fadeMix,_,T),de=R.getMeshFromTileID(k,X.canonical,x,C,`raster`);j.draw(k,A.TRIANGLES,v,b?b[X.overscaledZ]:ti.disabled,z,E?Qt.frontCCW:Qt.backCCW,le,se,ce,_.id,de.vertexBuffer,de.indexBuffer,de.segments)}}function $a(e,r,v,b){let x={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(v===0||b)return x;if(e.fadingParentID){let b=r.getLoadedTile(e.fadingParentID);if(!b)return x;let C=2**(b.tileID.overscaledZ-e.tileID.overscaledZ);return{parentTile:b,parentScaleBy:C,parentTopLeft:[e.tileID.canonical.x*C%1,e.tileID.canonical.y*C%1],fadeValues:function(e,r,v){let b=O(),x=(b-r.timeAdded)/v,C=e.fadingDirection===je.Incoming,T=_.ak((b-e.timeAdded)/v,0,1),E=_.ak(1-x,0,1),D=C?T:E;return{tileOpacity:D,parentTileOpacity:C?E:T,fadeMix:{opacity:1,mix:1-D}}}(e,b,v)}}return e.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:function(e,r){let v=(O()-e.timeAdded)/r,b=_.ak(v,0,1);return{tileOpacity:b,fadeMix:{opacity:b,mix:0}}}(e,v)}:x}let eo=new _.bn(1,0,0,1),to=new _.bn(0,1,0,1),ro=new _.bn(0,0,1,1),ao=new _.bn(1,0,1,1),oo=new _.bn(0,1,1,1);function is(e,r,_,v){ss(e,0,r+_/2,e.transform.width,_,v)}function as(e,r,_,v){ss(e,r-_/2,0,_,e.transform.height,v)}function ss(e,r,_,v,b,x){let C=e.context,T=C.gl;T.enable(T.SCISSOR_TEST),T.scissor(r*e.pixelRatio,_*e.pixelRatio,v*e.pixelRatio,b*e.pixelRatio),C.clear({color:x}),T.disable(T.SCISSOR_TEST)}function ls(e,r,v){let b=e.context,x=b.gl,C=e.useProgram(`debug`),T=Jt.disabled,E=ti.disabled,D=e.colorModeForRenderPass(),O=`$debug`,k=e.style.map.terrain&&e.style.map.terrain.getTerrainData(v);b.activeTexture.set(x.TEXTURE0);let A=r.getTileByID(v.key).latestRawTileData,j=Math.floor((A&&A.byteLength||0)/1024),F=r.getTile(v).tileSize,R=512/Math.min(F,512)*(v.overscaledZ/e.transform.zoom)*.5,z=v.canonical.toString();v.overscaledZ!==v.canonical.z&&(z+=` => ${v.overscaledZ}`),function(e,r){e.initDebugOverlayCanvas();let _=e.debugOverlayCanvas,v=e.context.gl,b=e.debugOverlayCanvas.getContext(`2d`);b.clearRect(0,0,_.width,_.height),b.shadowColor=`white`,b.shadowBlur=2,b.lineWidth=1.5,b.strokeStyle=`white`,b.textBaseline=`top`,b.font=`bold 36px Open Sans, sans-serif`,b.fillText(r,5,5),b.strokeText(r,5,5),e.debugOverlayTexture.update(_),e.debugOverlayTexture.bind(v.LINEAR,v.CLAMP_TO_EDGE)}(e,`${z} ${j}kB`);let B=e.transform.getProjectionData({overscaledTileID:v,applyGlobeMatrix:!0,applyTerrainMatrix:!0});C.draw(b,x.TRIANGLES,T,E,Kt.alphaBlended,Qt.disabled,Di(_.bn.transparent,R),null,B,O,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),C.draw(b,x.LINE_STRIP,T,E,D,Qt.disabled,Di(_.bn.red),k,B,O,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function us(e,r,_,v){let{isRenderingGlobe:b}=v,x=e.context,C=x.gl,T=e.transform,E=e.colorModeForRenderPass(),D=e.getDepthModeFor3D(),O=e.useProgram(`terrain`);x.bindFramebuffer.set(null),x.viewport.set([0,0,e.width,e.height]);for(let v of _){let _=r.getTerrainMesh(v.tileID),k=e.renderToTexture.getTexture(v),A=r.getTerrainData(v.tileID);x.activeTexture.set(C.TEXTURE0),C.bindTexture(C.TEXTURE_2D,k.texture);let j=ci(r.getMeshFrameDelta(T.zoom),T.calculateFogMatrix(v.tileID.toUnwrapped()),e.style.sky,T.pitch,b),F=T.getProjectionData({overscaledTileID:v.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});O.draw(x,C.TRIANGLES,D,ti.disabled,E,Qt.backCCW,j,A,F,`terrain`,_.vertexBuffer,_.indexBuffer,_.segments)}}function ds(e,r){if(!r.mesh){let v=new _.aU;v.emplaceBack(-1,-1),v.emplaceBack(1,-1),v.emplaceBack(1,1),v.emplaceBack(-1,1);let b=new _.aW;b.emplaceBack(0,1,2),b.emplaceBack(0,2,3),r.mesh=new At(e.createVertexBuffer(v,Vn.members),e.createIndexBuffer(b),_.aV.simpleSegment(0,0,v.length,b.length))}return r.mesh}class Va{constructor(e,r){this.context=new sa(e),this.transform=r,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:_.ao(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Ae.maxOverzooming+Ae.maxUnderzooming+1,this.depthEpsilon=1/2**16,this.crossTileSymbolIndex=new St}resize(e,r,_){if(this.width=Math.floor(e*_),this.height=Math.floor(r*_),this.pixelRatio=_,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let e of this.style._order)this.style._layers[e].resize()}setup(){let e=this.context,r=new _.aU;r.emplaceBack(0,0),r.emplaceBack(_.a5,0),r.emplaceBack(0,_.a5),r.emplaceBack(_.a5,_.a5),this.tileExtentBuffer=e.createVertexBuffer(r,Vn.members),this.tileExtentSegments=_.aV.simpleSegment(0,0,4,2);let v=new _.aU;v.emplaceBack(0,0),v.emplaceBack(_.a5,0),v.emplaceBack(0,_.a5),v.emplaceBack(_.a5,_.a5),this.debugBuffer=e.createVertexBuffer(v,Vn.members),this.debugSegments=_.aV.simpleSegment(0,0,4,5);let b=new _.cg;b.emplaceBack(0,0,0,0),b.emplaceBack(_.a5,0,_.a5,0),b.emplaceBack(0,_.a5,0,_.a5),b.emplaceBack(_.a5,_.a5,_.a5,_.a5),this.rasterBoundsBuffer=e.createVertexBuffer(b,ii.members),this.rasterBoundsSegments=_.aV.simpleSegment(0,0,4,2);let x=new _.aU;x.emplaceBack(0,0),x.emplaceBack(_.a5,0),x.emplaceBack(0,_.a5),x.emplaceBack(_.a5,_.a5),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(x,Vn.members),this.rasterBoundsSegmentsPosOnly=_.aV.simpleSegment(0,0,4,5);let C=new _.aU;C.emplaceBack(0,0),C.emplaceBack(1,0),C.emplaceBack(0,1),C.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(C,Vn.members),this.viewportSegments=_.aV.simpleSegment(0,0,4,2);let T=new _.ch;T.emplaceBack(0),T.emplaceBack(1),T.emplaceBack(3),T.emplaceBack(2),T.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(T);let E=new _.aW;E.emplaceBack(1,0,2),E.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(E);let D=this.context.gl;this.stencilClearMode=new ti({func:D.ALWAYS,mask:0},0,255,D.ZERO,D.ZERO,D.ZERO),this.tileExtentMesh=new At(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){let e=this.context,r=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let v=_.N();_.c6(v,0,this.width,this.height,0,0,1),_.Q(v,v,[r.drawingBufferWidth,r.drawingBufferHeight,0]);let b={mainMatrix:v,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:v};this.useProgram(`clippingMask`,null,!0).draw(e,r.TRIANGLES,Jt.disabled,this.stencilClearMode,Kt.disabled,Qt.disabled,null,null,b,`$clipping`,this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,r,_){if(this.currentStencilSource===e.source||!e.isTileClipped()||!r||!r.length)return;this.currentStencilSource=e.source,this.nextStencilID+r.length>256&&this.clearStencil();let v=this.context;v.setColorMode(Kt.disabled),v.setDepthMode(Jt.disabled);let b={};for(let e of r)b[e.key]=this.nextStencilID++;this._renderTileMasks(b,r,_,!0),this._renderTileMasks(b,r,_,!1),this._tileClippingMaskIDs=b}_renderTileMasks(e,r,_,v){let b=this.context,x=b.gl,C=this.style.projection,T=this.transform,E=this.useProgram(`clippingMask`);for(let D of r){let r=e[D.key],O=this.style.map.terrain&&this.style.map.terrain.getTerrainData(D),k=C.getMeshFromTileID(this.context,D.canonical,v,!0,`stencil`),A=T.getProjectionData({overscaledTileID:D,applyGlobeMatrix:!_,applyTerrainMatrix:!0});E.draw(b,x.TRIANGLES,Jt.disabled,new ti({func:x.ALWAYS,mask:0},r,255,x.KEEP,x.KEEP,x.REPLACE),Kt.disabled,_?Qt.disabled:Qt.backCCW,null,O,A,`$clipping`,k.vertexBuffer,k.indexBuffer,k.segments)}}_renderTilesDepthBuffer(){let e=this.context,r=e.gl,_=this.style.projection,v=this.transform,b=this.useProgram(`depth`),x=this.getDepthModeFor3D(),C=ot(v,{tileSize:v.tileSize});for(let T of C){let C=this.style.map.terrain&&this.style.map.terrain.getTerrainData(T),E=_.getMeshFromTileID(this.context,T.canonical,!0,!0,`raster`),D=v.getProjectionData({overscaledTileID:T,applyGlobeMatrix:!0,applyTerrainMatrix:!0});b.draw(e,r.TRIANGLES,x,ti.disabled,Kt.disabled,Qt.backCCW,null,C,D,`$clipping`,E.vertexBuffer,E.indexBuffer,E.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let e=this.nextStencilID++,r=this.context.gl;return new ti({func:r.NOTEQUAL,mask:255},e,255,r.KEEP,r.KEEP,r.REPLACE)}stencilModeForClipping(e){let r=this.context.gl;return new ti({func:r.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,r.KEEP,r.KEEP,r.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){let r=this.context.gl,_=e.sort((e,r)=>r.overscaledZ-e.overscaledZ),v=_[_.length-1].overscaledZ,b=_[0].overscaledZ-v+1;if(b>1){this.currentStencilSource=void 0,this.nextStencilID+b>256&&this.clearStencil();let e={};for(let _=0;_r.overscaledZ-e.overscaledZ),v=_[_.length-1].overscaledZ,b=_[0].overscaledZ-v+1;if(this.clearStencil(),b>1){let e={},x={};for(let _=0;_0};for(let e in C){let r=C[e];r.used&&r.prepare(this.context),T[e]=r.getVisibleCoordinates(!1),E[e]=T[e].slice().reverse(),D[e]=r.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:r.showOverdrawInspector?_.bn.black:_.bn.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,r){let _=e.context,v=_.gl,b=((e,r,_)=>{let v=Math.cos(r.rollInRadians),b=Math.sin(r.rollInRadians),x=Ue(r),C=r.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get(`sky-color`),u_horizon_color:e.properties.get(`horizon-color`),u_horizon:[(r.width/2-x*b)*_,(r.height/2+x*v)*_],u_horizon_normal:[-b,v],u_sky_horizon_blend:e.properties.get(`sky-horizon-blend`)*r.height/2*_,u_sky_blend:C}})(r,e.style.map.transform,e.pixelRatio),x=new Jt(v.LEQUAL,Jt.ReadWrite,[0,1]),C=ti.disabled,T=e.colorModeForRenderPass(),E=e.useProgram(`sky`),D=ds(_,r);E.draw(_,v.TRIANGLES,x,C,T,Qt.disabled,b,null,void 0,`sky`,D.vertexBuffer,D.indexBuffer,D.segments)}(this,this.style.sky),this._showOverdrawInspector=r.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass=`opaque`,this.currentLayer=x.length-1;this.currentLayer>=0;this.currentLayer--){let e=this.style._layers[x[this.currentLayer]],r=C[e.source],_=T[e.source];this._renderTileClippingMasks(e,_,!1),this.renderLayer(this,r,e,_,k)}this.renderPass=`translucent`;let A=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:r,u_globe_position:_,u_globe_radius:v,u_inv_proj_matrix:b}))(D,k,[F[0],F[1],F[2]],A,j),z=ds(b,r);C.draw(b,x.TRIANGLES,T,ti.disabled,Kt.alphaBlended,Qt.disabled,R,null,null,`atmosphere`,z.vertexBuffer,z.indexBuffer,z.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){let e=function(e,r){let _=null,v=Object.values(e._layers).flatMap(_=>_.source&&!_.isHidden(r)?[e.tileManagers[_.source]]:[]),b=v.filter(e=>e.getSource().type===`vector`),x=v.filter(e=>e.getSource().type!==`vector`),C=e=>{(!_||_.getSource().maxzoomC(e)),_||x.forEach(e=>C(e)),_}(this.style,this.transform.zoom);e&&function(e,r,_){for(let v=0;v<_.length;v++)ls(e,r,_[v])}(this,e,e.getVisibleCoordinates())}this.options.showPadding&&function(e){let r=e.transform.padding;is(e,e.transform.height-(r.top||0),3,eo),is(e,r.bottom||0,3,to),as(e,r.left||0,3,ro),as(e,e.transform.width-(r.right||0),3,ao);let _=e.transform.centerPoint;(function(e,r,_,v){ss(e,r-1,_-10,2,20,v),ss(e,r-10,_-1,20,2,v)})(e,_.x,e.transform.height-_.y,oo)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(e){if(!this.style||!this.style.map||!this.style.map.terrain)return;let r=this.terrainFacilitator.matrix,v=this.transform.modelViewProjectionMatrix,b=this.terrainFacilitator.dirty;b||=e?!_.ci(r,v):!_.cj(r,v),b||=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime),b&&(_.ck(r,v),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(e,r){let v=e.context,b=v.gl,x=e.transform,C=Kt.unblended,T=new Jt(b.LEQUAL,Jt.ReadWrite,[0,1]),E=r.tileManager.getRenderableTiles(),D=e.useProgram(`terrainDepth`);v.bindFramebuffer.set(r.getFramebuffer(`depth`).framebuffer),v.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),v.clear({color:_.bn.transparent,depth:1});for(let e of E){let _=r.getTerrainMesh(e.tileID),E=r.getTerrainData(e.tileID),O=x.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),k={u_ele_delta:r.getMeshFrameDelta(x.zoom)};D.draw(v,b.TRIANGLES,T,ti.disabled,C,Qt.backCCW,k,E,O,`terrain`,_.vertexBuffer,_.indexBuffer,_.segments)}v.bindFramebuffer.set(null),v.viewport.set([0,0,e.width,e.height])}(this,this.style.map.terrain),function(e,r){let v=e.context,b=v.gl,x=e.transform,C=Kt.unblended,T=new Jt(b.LEQUAL,Jt.ReadWrite,[0,1]),E=r.getCoordsTexture(),D=r.tileManager.getRenderableTiles(),O=e.useProgram(`terrainCoords`);v.bindFramebuffer.set(r.getFramebuffer(`coords`).framebuffer),v.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),v.clear({color:_.bn.transparent,depth:1}),r.coordsIndex=[];for(let e of D){let _=r.getTerrainMesh(e.tileID),D=r.getTerrainData(e.tileID);v.activeTexture.set(b.TEXTURE0),b.bindTexture(b.TEXTURE_2D,E.texture);let k={u_terrain_coords_id:(255-r.coordsIndex.length)/255,u_texture:0,u_ele_delta:r.getMeshFrameDelta(x.zoom)},A=x.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});O.draw(v,b.TRIANGLES,T,ti.disabled,C,Qt.backCCW,k,D,A,`terrain`,_.vertexBuffer,_.indexBuffer,_.segments),r.coordsIndex.push(e.tileID.key)}v.bindFramebuffer.set(null),v.viewport.set([0,0,e.width,e.height])}(this,this.style.map.terrain))}renderLayer(e,r,v,b,x){v.isHidden(this.transform.zoom)||(v.type===`background`||v.type===`custom`||(b||[]).length)&&(this.id=v.id,_.aQ(v)?function(e,r,v,b,x,C){if(e.renderPass!==`translucent`)return;let{isRenderingToTexture:T}=C,E=ti.disabled,D=e.colorModeForRenderPass();(v._unevaluatedLayout.hasValue(`text-variable-anchor`)||v._unevaluatedLayout.hasValue(`text-variable-anchor-offset`))&&function(e,r,v,b,x,C,T,E,D){let O=r.transform,k=r.style.map.terrain,A=x===`map`,j=C===`map`;for(let x of e){let e=b.getTile(x),C=e.getBucket(v);if(!C||!C.text||!C.text.segments.get().length)continue;let F=_.av(C.textSizeData,O.zoom),R=_.aK(e,1,r.transform.zoom),z=kt(A,r.transform,R),B=v.layout.get(`icon-text-fit`)!==`none`&&C.hasIconData();if(F){let r=2**(O.zoom-e.tileID.overscaledZ),v=k?(e,r)=>k.getElevation(x,e,r):null;ga(C,A,j,D,O,z,r,F,B,_.aL(O,e,T,E),x.toUnwrapped(),v)}}}(b,e,v,r,v.layout.get(`text-rotation-alignment`),v.layout.get(`text-pitch-alignment`),v.paint.get(`text-translate`),v.paint.get(`text-translate-anchor`),x),v.paint.get(`icon-opacity`).constantOr(1)!==0&&va(e,r,v,b,!1,v.paint.get(`icon-translate`),v.paint.get(`icon-translate-anchor`),v.layout.get(`icon-rotation-alignment`),v.layout.get(`icon-pitch-alignment`),v.layout.get(`icon-keep-upright`),E,D,T),v.paint.get(`text-opacity`).constantOr(1)!==0&&va(e,r,v,b,!0,v.paint.get(`text-translate`),v.paint.get(`text-translate-anchor`),v.layout.get(`text-rotation-alignment`),v.layout.get(`text-pitch-alignment`),v.layout.get(`text-keep-upright`),E,D,T),r.map.showCollisionBoxes&&(fa(e,r,v,b,!0),fa(e,r,v,b,!1))}(e,r,v,b,this.style.placement.variableOffsets,x):_.cl(v)?function(e,r,v,b,x){if(e.renderPass!==`translucent`)return;let{isRenderingToTexture:C}=x,T=v.paint.get(`circle-opacity`),E=v.paint.get(`circle-stroke-width`),D=v.paint.get(`circle-stroke-opacity`),O=!v.layout.get(`circle-sort-key`).isConstant();if(T.constantOr(1)===0&&(E.constantOr(1)===0||D.constantOr(1)===0))return;let k=e.context,A=k.gl,j=e.transform,F=e.getDepthModeForSublayer(0,Jt.ReadOnly),R=ti.disabled,z=e.colorModeForRenderPass(),B=[],H=j.getCircleRadiusCorrection();for(let x=0;xe.sortKey-r.sortKey);for(let r of B){let{programConfiguration:_,program:b,layoutVertexBuffer:x,indexBuffer:C,uniformValues:T,terrainData:E,projectionData:D}=r.state;b.draw(k,A.TRIANGLES,F,R,z,Qt.backCCW,T,E,D,v.id,x,C,r.segments,v.paint,e.transform.zoom,_)}}(e,r,v,b,x):_.cm(v)?function(e,r,v,b,x){if(v.paint.get(`heatmap-opacity`)===0)return;let C=e.context,{isRenderingToTexture:T,isRenderingGlobe:E}=x;if(e.style.map.terrain){for(let _ of b){let b=r.getTile(_);r.hasRenderableParent(_)||(e.renderPass===`offscreen`?xa(e,b,v,_,E):e.renderPass===`translucent`&&Sa(e,v,_,T,E))}C.viewport.set([0,0,e.width,e.height])}else e.renderPass===`offscreen`?function(e,r,v,b){let x=e.context,C=x.gl,T=e.transform,E=ti.disabled,D=new Kt([C.ONE,C.ONE],_.bn.transparent,[!0,!0,!0,!0]);(function(e,r,v){let b=e.gl;e.activeTexture.set(b.TEXTURE1),e.viewport.set([0,0,r.width/4,r.height/4]);let x=v.heatmapFbos.get(_.cc);x?(b.bindTexture(b.TEXTURE_2D,x.colorAttachment.get()),e.bindFramebuffer.set(x.framebuffer)):(x=wa(e,r.width/4,r.height/4),v.heatmapFbos.set(_.cc,x))})(x,e,v),x.clear({color:_.bn.transparent});for(let _=0;_0?r.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;let r=this.imageManager.getPattern(e.from.toString()),_=this.imageManager.getPattern(e.to.toString());return!r||!_}useProgram(e,r,_=!1,v=[]){this.cache=this.cache||{};let b=!!this.style.map.terrain,x=this.style.projection,C=_?zn.projectionMercator:x.shaderPreludeCode,T=_?Hn:x.shaderDefine,E=e+(r?r.cacheKey:``)+`/${_?Un:x.shaderVariantName}`+(this._showOverdrawInspector?`/overdraw`:``)+(b?`/terrain`:``)+(v?`/${v.join(`/`)}`:``);return this.cache[E]||(this.cache[E]=new ji(this.context,zn[e],r,aa[e],this._showOverdrawInspector,b,C,T,v)),this.cache[E]}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??(this.debugOverlayCanvas=document.createElement(`canvas`),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new _.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var e,r;if(this._tileTextures){for(let e in this._tileTextures){let r=this._tileTextures[e];if(r)for(let e of r)e.destroy()}this._tileTextures={}}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&((e=this.tileExtentMesh.vertexBuffer)==null||e.destroy()),this.tileExtentMesh&&((r=this.tileExtentMesh.indexBuffer)==null||r.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(let e in this.cache){let r=this.cache[e];r&&r.program&&this.context.gl.deleteProgram(r.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){let{drawingBufferWidth:e,drawingBufferHeight:r}=this.context.gl;return this.width!==e||this.height!==r}}function fs(r,_){let v,b=!1,x=null,C=null,T=()=>{x=null,b&&=(r.apply(C,v),x=setTimeout(T,_),!1)};return(...r)=>(b=!0,C=this||e,v=r,x||T(),x)}Va.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50;class qa{constructor(e){this._getCurrentHash=()=>{let e=window.location.hash.replace(`#`,``);if(this._hashName){let r;return e.split(`&`).map(e=>e.split(`=`)).forEach(e=>{e[0]===this._hashName&&(r=e)}),(r&&r[1]||``).split(`/`)}return e.split(`/`)},this._onHashChange=()=>{let e=this._getCurrentHash();if(!this._isValidHash(e))return!1;let r=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:r,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{let e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{let e=this._getCurrentHash();if(e.length===0)return;let r=e.join(`/`),_=r;_.split(`&`).length>0&&(_=_.split(`&`)[0]),this._hashName&&(_=`${this._hashName}=${r}`);let v=window.location.hash.replace(_,``);v.startsWith(`#&`)?v=v.slice(0,1)+v.slice(2):v===`#`&&(v=``);let b=window.location.href.replace(/(#.+)?$/,v);b=b.replace(`&&`,`&`),window.history.replaceState(window.history.state,null,b)},this._updateHash=fs(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 r=this._map.getCenter(),_=Math.round(100*this._map.getZoom())/100,v=10**Math.ceil((_*Math.LN2+Math.log(512/360/.5))/Math.LN10),b=Math.round(r.lng*v)/v,x=Math.round(r.lat*v)/v,C=this._map.getBearing(),T=this._map.getPitch(),E=``;if(E+=e?`/${b}/${x}/${_}`:`${_}/${x}/${b}`,(C||T)&&(E+=`/`+Math.round(10*C)/10),T&&(E+=`/${Math.round(T)}`),this._hashName){let e=this._hashName,r=!1,_=window.location.hash.slice(1).split(`&`).map(_=>{let v=_.split(`=`)[0];return v===e?(r=!0,`${v}=${E}`):_}).filter(e=>e);return r||_.push(`${e}=${E}`),`#${_.join(`&`)}`}return`#${E}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new _.V(+e[2],+e[1])}catch{return!1}let r=+e[0],v=+(e[3]||0),b=+(e[4]||0);return r>=this._map.getMinZoom()&&r<=this._map.getMaxZoom()&&v>=-180&&v<=180&&b>=this._map.getMinPitch()&&b<=this._map.getMaxPitch()}}let ms={linearity:.3,easing:_.cu(0,0,.3,1)},gs=_.e({deceleration:2500,maxSpeed:1400},ms),_s=_.e({deceleration:20,maxSpeed:1400},ms),ys=_.e({deceleration:1e3,maxSpeed:360},ms),bs=_.e({deceleration:1e3,maxSpeed:90},ms),xs=_.e({deceleration:1e3,maxSpeed:360},ms);class Ja{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:O(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,r=O();for(;e.length>0&&r-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let r={zoom:0,bearing:0,pitch:0,roll:0,pan:new _.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:e}of this._inertiaBuffer)r.zoom+=e.zoomDelta||0,r.bearing+=e.bearingDelta||0,r.pitch+=e.pitchDelta||0,r.roll+=e.rollDelta||0,e.panDelta&&r.pan._add(e.panDelta),e.around&&(r.around=e.around),e.pinchAround&&(r.pinchAround=e.pinchAround);let v=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,b={};if(r.pan.mag()){let x=Cs(r.pan.mag(),v,_.e({},gs,e||{})),C=r.pan.mult(x.amount/r.pan.mag()),T=this._map.cameraHelper.handlePanInertia(C,this._map.transform);b.center=T.easingCenter,b.offset=T.easingOffset,Ss(b,x)}if(r.zoom){let e=Cs(r.zoom,v,_s);b.zoom=_.cv(this._map.transform.zoom+e.amount,this._map.getZoomSnap(),e.amount),Ss(b,e)}if(r.bearing){let e=Cs(r.bearing,v,ys);b.bearing=this._map.transform.bearing+_.ak(e.amount,-179,179),Ss(b,e)}if(r.pitch){let e=Cs(r.pitch,v,bs);b.pitch=this._map.transform.pitch+e.amount,Ss(b,e)}if(r.roll){let e=Cs(r.roll,v,xs);b.roll=this._map.transform.roll+_.ak(e.amount,-179,179),Ss(b,e)}if(b.zoom||b.bearing){let e=r.pinchAround===void 0?r.around:r.pinchAround;b.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),_.e(b,{noMoveStart:!0})}}function Ss(e,r){(!e.duration||e.durationr.unproject(e)),T=x.reduce((e,r,_,v)=>e.add(r.div(v.length)),new _.P(0,0));super(e,{points:x,point:T,lngLats:C,lngLat:r.unproject(T),originalEvent:v}),this._defaultPrevented=!1}}class ar extends _.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,r,_){super(e,{originalEvent:_}),this._defaultPrevented=!1}}class rr{constructor(e,r){this._map=e,this._clickTolerance=r.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new ar(e.type,this._map,e))}mousedown(e,r){return this._mousedownPos=r,this._firePreventable(new ir(e.type,this._map,e))}mouseup(e){this._map.fire(new ir(e.type,this._map,e))}click(e,r){this._mousedownPos&&this._mousedownPos.dist(r)>=this._clickTolerance||this._map.fire(new ir(e.type,this._map,e))}dblclick(e){return this._firePreventable(new ir(e.type,this._map,e))}mouseover(e){this._map.fire(new ir(e.type,this._map,e))}mouseout(e){this._map.fire(new ir(e.type,this._map,e))}touchstart(e){return this._firePreventable(new or(e.type,this._map,e))}touchmove(e){this._map.fire(new or(e.type,this._map,e))}touchend(e){this._map.fire(new or(e.type,this._map,e))}touchcancel(e){this._map.fire(new or(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class sr{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new ir(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ir(`contextmenu`,this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ir(e.type,this._map,e)),this._map.listens(`contextmenu`)&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class nr{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(_.P.convert(e),this._map.terrain)}}class lr{constructor(e,r){this._map=e,this._tr=new nr(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=r.clickTolerance||1,r.boxZoom&&typeof r.boxZoom==`object`&&(this._boxZoomEnd=r.boxZoom.boxZoomEnd)}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,r){this.isEnabled()&&e.shiftKey&&e.button===0&&(h.disableDrag(),this._startPos=this._lastPos=r,this._active=!0)}mousemoveWindow(e,r){if(!this._active)return;let _=r;if(this._lastPos.equals(_)||!this._box&&_.dist(this._startPos)e.fitScreenCoordinates(v,b,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&&=(this._box.remove(),null),h.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,r){return this._map.fire(new _.l(e,{originalEvent:r}))}}function ws(e,r){if(e.length!==r.length)throw Error(`The number of touches and points are not equal - touches ${e.length}, points ${r.length}`);let _={};for(let v=0;vthis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),v.length===this.numTouches&&(this.centroid=function(e){let r=new _.P(0,0);for(let _ of e)r._add(_);return r.div(e.length)}(r),this.touches=ws(v,r)))}touchmove(e,r,_){if(this.aborted||!this.centroid)return;let v=ws(_,r);for(let e in this.touches){let r=v[e];(!r||r.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,r,_){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),_.length===0){let e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class ur{constructor(e){this.singleTap=new hr(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,r,_){this.singleTap.touchstart(e,r,_)}touchmove(e,r,_){this.singleTap.touchmove(e,r,_)}touchend(e,r,_){let v=this.singleTap.touchend(e,r,_);if(v){let r=e.timeStamp-this.lastTime<500,_=!this.lastTap||this.lastTap.dist(v)<30;if(r&&_||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=v,this.count===this.numTaps)return this.reset(),v}}}class dr{constructor(e){this._tr=new nr(e),this._zoomIn=new ur({numTouches:1,numTaps:2}),this._zoomOut=new ur({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,r,_){this._zoomIn.touchstart(e,r,_),this._zoomOut.touchstart(e,r,_)}touchmove(e,r,_){this._zoomIn.touchmove(e,r,_),this._zoomOut.touchmove(e,r,_)}touchend(e,r,v){let b=this._zoomIn.touchend(e,r,v),x=this._zoomOut.touchend(e,r,v),C=this._tr;return b?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:r=>r.easeTo({duration:300,zoom:_.cv(C.zoom+1,r.getZoomSnap()),around:C.unproject(b)},{originalEvent:e})}):x?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:r=>r.easeTo({duration:300,zoom:_.cv(C.zoom-1,r.getZoomSnap()),around:C.unproject(x)},{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 r=this._moveFunction(...e);if(r.bearingDelta||r.pitchDelta||r.rollDelta||r.around||r.panDelta)return this._active=!0,r}dragStart(e,r){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(r)?r[0]:r,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,r){if(!this.isEnabled())return;let _=this._lastPoint;if(!_)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);let v=Array.isArray(r)?r[0]:r;return!this._moved&&v.dist(_)!0}),r=new vr){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=r}_executeRelevantHandler(e,r,_){return e instanceof MouseEvent?r(e):typeof TouchEvent<`u`&&e instanceof TouchEvent?_(e):void 0}startMove(e){this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.startMove(e),e=>this.oneFingerTouchMoveStateManager.startMove(e))}endMove(e){this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.endMove(e),e=>this.oneFingerTouchMoveStateManager.endMove(e))}isValidStartEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidStartEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e))}isValidMoveEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidMoveEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e))}isValidEndEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidEndEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e))}}let ks=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class yr{constructor(e,r){this._clickTolerance=e.clickTolerance||1,this._map=r,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new _.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,r,_){return this._calculateTransform(e,r,_)}touchmove(e,r,_){if(this._active){if(!this._shouldBePrevented(_.length))return e.preventDefault(),this._calculateTransform(e,r,_);this._map.cooperativeGestures.notifyGestureBlocked(`touch_pan`,e)}}touchend(e,r,_){this._calculateTransform(e,r,_),this._active&&this._shouldBePrevented(_.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,r,v){v.length>0&&(this._active=!0);let b=ws(v,r),x=new _.P(0,0),C=new _.P(0,0),T=0;for(let e in b){let r=b[e],_=this._touches[e];_&&(x._add(r),C._add(r.sub(_)),T++,b[e]=r)}if(this._touches=b,this._shouldBePrevented(T)||!C.mag())return;let E=C.div(T);return this._sum._add(E),this._sum.mag()Math.abs(e.x)}class Sr extends wr{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,r,_){super.touchstart(e,r,_),this._currentTouchCount=_.length}_start(e){this._lastPoints=e,Fs(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,r,_){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let v=e[0].sub(this._lastPoints[0]),b=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(v,b,_.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(v.y+b.y)/2*-.5}):void 0}gestureBeginsVertically(e,r,_){if(this._valid!==void 0)return this._valid;let v=e.mag()>=2,b=r.mag()>=2;if(!v&&!b)return;if(!v||!b)return this._firstMove===void 0&&(this._firstMove=_),_-this._firstMove<100&&void 0;let x=e.y>0==r.y>0;return Fs(e)&&Fs(r)&&x}}let Is={panStep:100,bearingStep:15,pitchStep:10};class zr{constructor(e){this._tr=new nr(e);let r=Is;this._panStep=r.panStep,this._bearingStep=r.bearingStep,this._pitchStep=r.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let r=0,v=0,b=0,x=0,C=0;switch(e.keyCode){case 61:case 107:case 171:case 187:r=1;break;case 189:case 109:case 173:r=-1;break;case 37:e.shiftKey?v=-1:(e.preventDefault(),x=-1);break;case 39:e.shiftKey?v=1:(e.preventDefault(),x=1);break;case 38:e.shiftKey?b=1:(e.preventDefault(),C=-1);break;case 40:e.shiftKey?b=-1:(e.preventDefault(),C=1);break;default:return}return this._rotationDisabled&&(v=0,b=0),{cameraAnimation:T=>{let E=this._tr;T.easeTo({duration:300,easeId:`keyboardHandler`,easing:zs,zoom:r?_.cv(E.zoom+r*(e.shiftKey?2:1),T.getZoomSnap()):E.zoom,bearing:E.bearing+v*this._bearingStep,pitch:E.pitch+b*this._pitchStep,offset:[-x*this._panStep,-C*this._panStep],center:E.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 zs(e){return e*(2-e)}let Vs=4.000244140625,Ks=1/450;class kr{constructor(e,r){this._onTimeout=e=>{this._type=`wheel`,this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new nr(e),this._triggerRenderFrame=r,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 r=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,_=O(),v=_-(this._lastWheelEventTime||0);this._lastWheelEventTime=_,r!==0&&r%Vs==0?this._type=`wheel`:r!==0&&Math.abs(r)<4?this._type=`trackpad`:v>400?(this._type=null,this._lastValue=r,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(v*r)<200?`trackpad`:`wheel`,this._timeout&&(clearTimeout(this._timeout),this._timeout=null,r+=this._lastValue)),e.shiftKey&&r&&(r/=4),this._type&&(this._lastWheelEvent=e,this._delta-=r,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._frameId&&=null,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let r=h.mousePos(this._map.getCanvas(),e),v=this._tr;this._aroundPoint=this._aroundCenter?v.transform.locationToScreenPoint(_.V.convert(v.center)):r,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let e=this._tr.transform;if(typeof this._lastExpectedZoom==`number`){let r=e.zoom-this._lastExpectedZoom;typeof this._startZoom==`number`&&(this._startZoom+=r),typeof this._targetZoom==`number`&&(this._targetZoom+=r)}if(this._delta!==0){let r=this._type===`wheel`&&Math.abs(this._delta)>Vs?this._wheelZoomRate:this._defaultZoomRate,v=2/(1+Math.exp(-Math.abs(this._delta*r)));this._delta<0&&v!==0&&(v=1/v);let b=typeof this._targetZoom==`number`?_.an(this._targetZoom):e.scale,x=e.applyConstrain(e.getCameraLngLat(),_.aq(b*v)).zoom,C=this._map.getZoomSnap();if(this._type===`wheel`&&C>0){let r=_.cv(e.zoom,C);this._targetZoom=_.cv(x,C,x-r)}else this._targetZoom=x;this._type===`wheel`&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let r=typeof this._targetZoom==`number`?this._targetZoom:e.zoom,v=this._startZoom,b=this._easing,x,C=!1;if(this._type===`wheel`&&v&&b){let e=O()-this._lastWheelEventTime,T=Math.min((e+5)/200,1),E=b(T);x=_.G.number(v,r,E),T<1?this._frameId||=!0:C=!0}else x=r,C=!0;return this._active=!0,C&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=x,{noInertia:!0,needsRenderFrame:!C,zoomDelta:x-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let r=_.cx;if(this._prevEase){let e=this._prevEase,v=(O()-e.start)/e.duration,b=e.easing(v+.01)-e.easing(v),x=.27/Math.sqrt(b*b+1e-4)*.01,C=Math.sqrt(.0729-x*x);r=_.cu(x,C,.25,1)}return this._prevEase={start:O(),duration:e,easing:r},r}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Fr{constructor(e,r){this._clickZoom=e,this._tapZoom=r}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 Br{constructor(e){this._tr=new nr(e),this.reset()}reset(){this._active=!1}dblclick(e,r){return e.preventDefault(),{cameraAnimation:v=>{v.easeTo({duration:300,zoom:_.cv(this._tr.zoom+(e.shiftKey?-1:1),v.getZoomSnap()),around:this._tr.unproject(r)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Or{constructor(){this._tap=new ur({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,r,_){if(!this._swipePoint)if(this._tapTime){let v=r[0],b=e.timeStamp-this._tapTime<500,x=this._tapPoint.dist(v)<30;b&&x?_.length>0&&(this._swipePoint=v,this._swipeTouch=_[0].identifier):this.reset()}else this._tap.touchstart(e,r,_)}touchmove(e,r,_){if(this._tapTime){if(this._swipePoint){if(_[0].identifier!==this._swipeTouch)return;let v=r[0],b=v.y-this._swipePoint.y;return this._swipePoint=v,e.preventDefault(),this._active=!0,{zoomDelta:b/128}}}else this._tap.touchmove(e,r,_)}touchend(e,r,_){if(this._tapTime)this._swipePoint&&_.length===0&&this.reset();else{let v=this._tap.touchend(e,r,_);v&&(this._tapTime=e.timeStamp,this._tapPoint=v)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class jr{constructor(e,r,_){this._el=e,this._mousePan=r,this._touchPan=_}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 Zr{constructor(e,r,_,v){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=r,this._mousePitch=_,this._mouseRoll=v}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class Nr{constructor(e,r,_,v){this._el=e,this._touchZoom=r,this._touchRotate=_,this._tapDragZoom=v,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 Ur{constructor(e,r){this._bypassKey=navigator.userAgent.indexOf(`Mac`)===-1?`ctrlKey`:`metaKey`,this._map=e,this._options=r,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=h.create(`div`,`maplibregl-cooperative-gesture-screen`,e);let r=this._map._getUIString(`CooperativeGesturesHandler.WindowsHelpText`);this._bypassKey===`metaKey`&&(r=this._map._getUIString(`CooperativeGesturesHandler.MacHelpText`));let _=this._map._getUIString(`CooperativeGesturesHandler.MobileHelpText`),v=document.createElement(`div`);v.className=`maplibregl-desktop-message`,v.textContent=r,this._container.appendChild(v);let b=document.createElement(`div`);b.className=`maplibregl-mobile-message`,b.textContent=_,this._container.appendChild(b),this._container.setAttribute(`aria-hidden`,`true`)}_destroyUI(){this._container&&(this._container.remove(),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,r){this._enabled&&(this._map.fire(new _.l(`cooperativegestureprevented`,{gestureType:e,originalEvent:r})),this._container.classList.add(`maplibregl-show`),setTimeout(()=>{this._container.classList.remove(`maplibregl-show`)},100))}}let Js=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Vr extends _.l{}function ec(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class qr{get _ownerDocument(){var e;return(e=this._el)?.ownerDocument||document}get _ownerWindow(){var e,r;return(r=(e=this._el)?.ownerDocument)?.defaultView||window}constructor(e,r){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,r)=>{if(e.type===`blur`)return void this.stop(!0);this._updatingCamera=!0;let v=e.type===`renderFrame`?void 0:e,b={needsRenderFrame:!1},x={},C={};for(let{handlerName:T,handler:E,allowed:D}of this._handlers){if(!E.isEnabled())continue;let O;if(this._blockedByActive(C,D,T))E.reset();else if(E[r||e.type]){if(_.cy(e,r||e.type)){let _=h.mousePos(this._map.getCanvas(),e);O=E[r||e.type](e,_)}else if(_.cz(e,r||e.type)){let _=this._getMapTouches(e.touches),v=h.touchPos(this._map.getCanvas(),_);O=E[r||e.type](e,v,_)}else _.cA(r||e.type)||(O=E[r||e.type](e));this.mergeHandlerResult(b,x,O,T,v),O&&O.needsRenderFrame&&this._triggerRenderFrame()}(O||E.isActive())&&(C[T]=E)}let T={};for(let e in this._previousActiveHandlers)C[e]||(T[e]=v);this._previousActiveHandlers=C,(Object.keys(T).length||ec(b))&&(this._changes.push([b,x,T]),this._triggerRenderFrame()),(Object.keys(C).length||ec(b))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:E}=b;E&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],E(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Ja(e),this._bearingSnap=r.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(r);let v=this._el;this._listeners=[[v,`touchstart`,{passive:!0}],[v,`touchmove`,{passive:!1}],[v,`touchend`,void 0],[v,`touchcancel`,void 0],[v,`mousedown`,void 0],[v,`mousemove`,void 0],[v,`mouseup`,void 0],[this._ownerDocument,`mousemove`,{capture:!0}],[this._ownerDocument,`mouseup`,void 0],[v,`mouseover`,void 0],[v,`mouseout`,void 0],[v,`dblclick`,void 0],[v,`click`,void 0],[v,`keydown`,{capture:!1}],[v,`keyup`,void 0],[v,`wheel`,{passive:!1}],[v,`contextmenu`,void 0],[this._ownerWindow,`blur`,void 0]];for(let[e,r,_]of this._listeners)e.addEventListener(r,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,_)}destroy(){for(let[e,r,_]of this._listeners)e.removeEventListener(r,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,_)}_addDefaultHandlers(e){let r=this._map,v=r.getCanvasContainer();this._add(`mapEvent`,new rr(r,e));let b=r.boxZoom=new lr(r,e);this._add(`boxZoom`,b),e.interactive&&e.boxZoom&&b.enable();let x=r.cooperativeGestures=new Ur(r,e.cooperativeGestures);this._add(`cooperativeGestures`,x),e.cooperativeGestures&&x.enable();let C=new dr(r),T=new Br(r);r.doubleClickZoom=new Fr(T,C),this._add(`tapZoom`,C),this._add(`clickZoom`,T),e.interactive&&e.doubleClickZoom&&r.doubleClickZoom.enable();let E=new Or;this._add(`tapDragZoom`,E);let D=r.touchPitch=new Sr(r);this._add(`touchPitch`,D),e.interactive&&e.touchPitch&&r.touchPitch.enable(e.touchPitch);let O=()=>r.project(r.getCenter()),k=function({enable:e,clickTolerance:r,aroundCenter:v=!0,minPixelCenterThreshold:b=100,rotateDegreesPerPixelMoved:x=.8},C){return new _r({clickTolerance:r,move:(e,r)=>{let T=C();if(v&&Math.abs(T.y-e.y)>b)return{bearingDelta:_.cw(new _.P(e.x,r.y),r,T)};let E=(r.x-e.x)*x;return v&&r.ye.button===0&&e.ctrlKey||e.button===2&&!e.ctrlKey}),enable:e,assignEvents:ks})}(e,O),A=function({enable:e,clickTolerance:r,pitchDegreesPerPixelMoved:_=-.5}){return new _r({clickTolerance:r,move:(e,r)=>({pitchDelta:(r.y-e.y)*_}),moveStateManager:new gr({checkCorrectEvent:e=>e.button===0&&e.ctrlKey||e.button===2}),enable:e,assignEvents:ks})}(e),j=function({enable:e,clickTolerance:r,rollDegreesPerPixelMoved:_=.3},v){return new _r({clickTolerance:r,move:(e,r)=>{let b=v(),x=(r.x-e.x)*_;return r.ye.button===2&&e.ctrlKey}),enable:e,assignEvents:ks})}(e,O);r.dragRotate=new Zr(e,k,A,j),this._add(`mouseRotate`,k,[`mousePitch`]),this._add(`mousePitch`,A,[`mouseRotate`,`mouseRoll`]),this._add(`mouseRoll`,j,[`mousePitch`]),e.interactive&&e.dragRotate&&r.dragRotate.enable();let F=function({enable:e,clickTolerance:r}){return new _r({clickTolerance:r,move:(e,r)=>({around:r,panDelta:r.sub(e)}),activateOnStart:!0,moveStateManager:new gr({checkCorrectEvent:e=>e.button===0&&!e.ctrlKey}),enable:e,assignEvents:ks})}(e),R=new yr(e,r);r.dragPan=new jr(v,F,R),this._add(`mousePan`,F),this._add(`touchPan`,R,[`touchZoom`,`touchRotate`]),e.interactive&&e.dragPan&&r.dragPan.enable(e.dragPan);let z=new Mr,B=new Cr;r.touchZoomRotate=new Nr(v,B,z,E),this._add(`touchRotate`,z,[`touchPan`,`touchZoom`]),this._add(`touchZoom`,B,[`touchPan`,`touchRotate`]),e.interactive&&e.touchZoomRotate&&r.touchZoomRotate.enable(e.touchZoomRotate),this._add(`blockableMapEvent`,new sr(r));let H=r.scrollZoom=new kr(r,()=>this._triggerRenderFrame());this._add(`scrollZoom`,H,[`mousePan`]),e.interactive&&e.scrollZoom&&r.scrollZoom.enable(e.scrollZoom);let K=r.keyboard=new zr(r);this._add(`keyboard`,K),e.interactive&&e.keyboard&&r.keyboard.enable()}_add(e,r,_){this._handlers.push({handlerName:e,handler:r,allowed:_}),this._handlersById[e]=r}stop(e){if(!this._updatingCamera){for(let{handler:e}of this._handlers)e.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!!Js(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,r,_){for(let v in e)if(v!==_&&(!r||r.indexOf(v)<0))return!0;return!1}_getMapTouches(e){let r=[];for(let _ of e)this._el.contains(_.target)&&r.push(_);return r}mergeHandlerResult(e,r,v,b,x){if(!v)return;_.e(e,v);let C={handlerName:b,originalEvent:v.originalEvent||x};v.zoomDelta!==void 0&&(r.zoom=C),v.panDelta!==void 0&&(r.drag=C),v.rollDelta!==void 0&&(r.roll=C),v.pitchDelta!==void 0&&(r.pitch=C),v.bearingDelta!==void 0&&(r.rotate=C)}_applyChanges(){let e={},r={},v={};for(let[b,x,C]of this._changes)b.panDelta&&(e.panDelta=(e.panDelta||new _.P(0,0))._add(b.panDelta)),b.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+b.zoomDelta),b.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+b.bearingDelta),b.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+b.pitchDelta),b.rollDelta&&(e.rollDelta=(e.rollDelta||0)+b.rollDelta),b.around!==void 0&&(e.around=b.around),b.pinchAround!==void 0&&(e.pinchAround=b.pinchAround),b.noInertia&&(e.noInertia=b.noInertia),_.e(r,x),_.e(v,C);this._updateMapTransform(e,r,v),this._changes=[]}_updateMapTransform(e,r,_){let v=this._map,b=v._getTransformForUpdate(),x=v.terrain;if(!(ec(e)||x&&this._terrainMovement))return this._fireEvents(r,_,!0);v._stop(!0);let{panDelta:C,zoomDelta:T,bearingDelta:E,pitchDelta:D,rollDelta:O,around:k,pinchAround:A}=e;A!==void 0&&(k=A),k||=v.transform.centerPoint,x&&!b.isPointOnMapSurface(k)&&(k=b.centerPoint);let j={panDelta:C,zoomDelta:T,rollDelta:O,pitchDelta:D,bearingDelta:E,around:k};this._map.cameraHelper.useGlobeControls&&!b.isPointOnMapSurface(k)&&(k=b.centerPoint);let F=k.distSqr(b.centerPoint)<.01?b.center:b.screenPointToLocation(C?k.sub(C):k);this._handleMapControls({terrain:x,tr:b,deltasForHelper:j,preZoomAroundLoc:F,combinedEventsInProgress:r,panDelta:C}),v._applyUpdatedTransform(b),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(r,_,!0)}_handleMapControls({terrain:e,tr:r,deltasForHelper:_,preZoomAroundLoc:v,combinedEventsInProgress:b,panDelta:x}){let C=this._map.cameraHelper;if(C.handleMapControlsRollPitchBearingZoom(_,r),e)return C.useGlobeControls?(this._terrainMovement||!b.drag&&!b.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void C.handleMapControlsPan(_,r,v)):this._terrainMovement||!b.drag&&!b.zoom?void(b.drag&&this._terrainMovement&&x?r.setCenter(r.screenPointToLocation(r.centerPoint.sub(x))):C.handleMapControlsPan(_,r,v)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void C.handleMapControlsPan(_,r,v));C.handleMapControlsPan(_,r,v)}_fireEvents(e,r,v){let b=Js(this._eventsInProgress),x=Js(e),C={};for(let r in e){let{originalEvent:_}=e[r];this._eventsInProgress[r]||(C[`${r}start`]=_),this._eventsInProgress[r]=e[r]}!b&&x&&this._fireEvent(`movestart`,x.originalEvent);for(let e in C)this._fireEvent(e,C[e]);x&&this._fireEvent(`move`,x.originalEvent);for(let r in e){let{originalEvent:_}=e[r];this._fireEvent(r,_)}let T={},D;for(let e in this._eventsInProgress){let{handlerName:_,originalEvent:v}=this._eventsInProgress[e];this._handlersById[_].isActive()||(delete this._eventsInProgress[e],D=r[_]||v,T[`${e}end`]=D)}for(let e in T)this._fireEvent(e,T[e]);let O=Js(this._eventsInProgress),k=(b||x)&&!O;if(k&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;let e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(v&&k){this._updatingCamera=!0;let e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),r=e=>e!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Vr(`renderFrame`,{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class $r extends _.E{constructor(e,r,_){super(),this._renderFrameCallback=()=>{let e=Math.min((O()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=_.bearingSnap,this._zoomSnap=_.zoomSnap,this.cameraHelper=r,this.on(`moveend`,()=>{delete this._requestedCameraState})}migrateProjection(e,r){e.apply(this.transform,!0),this.transform=e,this.cameraHelper=r}getCenter(){return new _.V(this.transform.center.lng,this.transform.center.lat)}setCenter(e,r){return this.jumpTo({center:e},r)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,r){return this.jumpTo({elevation:e},r),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,r,v){return e=_.P.convert(e).mult(-1),this.panTo(this.transform.center,_.e({offset:e},r),v)}panTo(e,r,v){return this.easeTo(_.e({center:e},r),v)}getZoom(){return this.transform.zoom}setZoom(e,r){return this.jumpTo({zoom:e},r),this}zoomTo(e,r,v){return this.easeTo(_.e({zoom:e},r),v)}zoomIn(e,r){return this.zoomTo(_.cv(this.getZoom()+1,this._zoomSnap),e,r),this}zoomOut(e,r){return this.zoomTo(_.cv(this.getZoom()-1,this._zoomSnap),e,r),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,r){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new _.l(`movestart`,r)).fire(new _.l(`move`,r)).fire(new _.l(`moveend`,r))),this}getBearing(){return this.transform.bearing}setZoomSnap(e){return this._zoomSnap=e,this}getZoomSnap(){return this._zoomSnap}setBearing(e,r){return this.jumpTo({bearing:e},r),this}getPadding(){return this.transform.padding}setPadding(e,r){return this.jumpTo({padding:e},r),this}rotateTo(e,r,v){return this.easeTo(_.e({bearing:e},r),v)}resetNorth(e,r){return this.rotateTo(0,_.e({duration:1e3},e),r),this}resetNorthPitch(e,r){return this.easeTo(_.e({bearing:0,pitch:0,roll:0,duration:1e3},e),r),this}snapToNorth(e,r){return Math.abs(this.getBearing()){z.easeFunc(_),this.terrain&&!e.freezeElevation&&this._updateElevation(_),this._applyUpdatedTransform(v),this._fireMoveEvents(r)},_=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(r,_)},e),this}_prepareEase(e,r,v={}){this._moving=!0,r||v.moving||this.fire(new _.l(`movestart`,e)),this._zooming&&!v.zooming&&this.fire(new _.l(`zoomstart`,e)),this._rotating&&!v.rotating&&this.fire(new _.l(`rotatestart`,e)),this._pitching&&!v.pitching&&this.fire(new _.l(`pitchstart`,e)),this._rolling&&!v.rolling&&this.fire(new _.l(`rollstart`,e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this._elevationStart!==void 0&&this._elevationCenter!==void 0||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));let r=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&r!==this._elevationTarget){let _=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(_-(r-(_*e+this._elevationStart))/(1-e)),this._elevationTarget=r}this.transform.setElevation(_.G.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||=this.transform.clone(),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};let r=e.getCameraLngLat(),_=e.getCameraAltitude(),v=this.terrain?this.terrain.getElevationForLngLatZoom(r,e.zoom):0;if(_this._elevateCameraIfInsideTerrain(e)),this.transformCameraUpdate&&r.push(e=>this.transformCameraUpdate(e)),!r.length)return;let _=e.clone();for(let e of r){let r=_.clone(),{center:v,zoom:b,roll:x,pitch:C,bearing:T,elevation:E}=e(r);v&&r.setCenter(v),E!==void 0&&r.setElevation(E),b!==void 0&&r.setZoom(b),x!==void 0&&r.setRoll(x),C!==void 0&&r.setPitch(C),T!==void 0&&r.setBearing(T),_.apply(r,!1)}this.transform.apply(_,!1)}_fireMoveEvents(e){this.fire(new _.l(`move`,e)),this._zooming&&this.fire(new _.l(`zoom`,e)),this._rotating&&this.fire(new _.l(`rotate`,e)),this._pitching&&this.fire(new _.l(`pitch`,e)),this._rolling&&this.fire(new _.l(`roll`,e))}_afterEase(e,r){if(this._easeId&&r&&this._easeId===r)return;delete this._easeId;let v=this._zooming,b=this._rotating,x=this._pitching,C=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,v&&this.fire(new _.l(`zoomend`,e)),b&&this.fire(new _.l(`rotateend`,e)),x&&this.fire(new _.l(`pitchend`,e)),C&&this.fire(new _.l(`rollend`,e)),this.fire(new _.l(`moveend`,e))}flyTo(e,r){if(!e.essential&&E.prefersReducedMotion){let v=_.U(e,[`center`,`zoom`,`bearing`,`pitch`,`roll`,`elevation`,`padding`]);return this.jumpTo(v,r)}this.stop(),`zoom`in(e=_.e({offset:[0,0],speed:1.2,curve:1.42,easing:_.cx},e))&&this._zoomSnap&&(e.zoom=_.cv(e.zoom,this._zoomSnap));let v=this._getTransformForUpdate(),b=v.bearing,x=v.pitch,C=v.roll,T=v.padding,D=`bearing`in e?this._normalizeBearing(e.bearing,b):b,O=`pitch`in e?+e.pitch:x,k=`roll`in e?this._normalizeBearing(e.roll,C):C,A=`padding`in e?e.padding:v.padding,j=_.P.convert(e.offset),F=v.centerPoint.add(j),R=v.screenPointToLocation(F),z=this.cameraHelper.handleFlyTo(v,{bearing:D,pitch:O,roll:k,padding:A,locationAtOffset:R,offsetAsPoint:j,center:e.center,minZoom:e.minZoom,zoom:e.zoom}),B=e.curve,H=Math.max(v.width,v.height),K=H/z.scaleOfZoom,q=z.pixelPathLength;typeof z.scaleOfMinZoom==`number`&&(B=Math.sqrt(H/z.scaleOfMinZoom/q*2));let Y=B*B;function X(e){let r=(K*K-H*H+(e?-1:1)*Y*Y*q*q)/(2*(e?K:H)*Y*q);return Math.log(Math.sqrt(r*r+1)-r)}function ne(e){return(Math.exp(e)-Math.exp(-e))/2}function Z(e){return(Math.exp(e)+Math.exp(-e))/2}let ie=X(!1),ae=function(e){return Z(ie)/Z(ie+B*e)},oe=function(e){return H*((Z(ie)*(ne(r=ie+B*e)/Z(r))-ne(ie))/Y)/q;var r},se=(X(!0)-ie)/B;if(Math.abs(q)<2e-6||!isFinite(se)){if(Math.abs(H-K)<1e-6)return this.easeTo(e,r);let _=K0,ae=e=>Math.exp(_*B*e)}return e.duration=`duration`in e?+e.duration:1e3*se/(`screenSpeed`in e?+e.screenSpeed/B:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=b!==D,this._pitching=O!==x,this._rolling=k!==C,this._padding=!v.isPaddingEqual(A),this._prepareEase(r,!1),this.terrain&&this._prepareElevation(z.targetCenter),this._ease(E=>{let R=E*se,B=1/ae(R),H=oe(R);this._rotating&&v.setBearing(_.G.number(b,D,E)),this._pitching&&v.setPitch(_.G.number(x,O,E)),this._rolling&&v.setRoll(_.G.number(C,k,E)),this._padding&&(v.interpolatePadding(T,A,E),F=v.centerPoint.add(j)),z.easeFunc(E,B,H,F),this.terrain&&!e.freezeElevation&&this._updateElevation(E),this._applyUpdatedTransform(v),this._fireMoveEvents(r)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(r)},e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,r){var _;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,r)}return e||(_=this.handlers)==null||_.stop(!1),this}_ease(e,r,_){!1===_.animate||_.duration===0?(e(1),r()):(this._easeStart=O(),this._easeOptions=_,this._onEaseFrame=e,this._onEaseEnd=r,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,r){e=_.W(e,-180,180);let v=Math.abs(e-r);return Math.abs(e-360-r)MapLibre`};class Xr{constructor(e=nc){this._toggleAttribution=()=>{this._container.classList.contains(`maplibregl-compact`)&&(this._container.classList.contains(`maplibregl-compact-show`)?(this._container.setAttribute(`open`,``),this._container.classList.remove(`maplibregl-compact-show`)):(this._container.classList.add(`maplibregl-compact-show`),this._container.removeAttribute(`open`)))},this._updateData=e=>{!e||e.sourceDataType!==`metadata`&&e.sourceDataType!==`visibility`&&e.dataType!==`style`&&e.type!==`terrain`||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute(`open`,``):this._container.classList.contains(`maplibregl-compact`)||this._container.classList.contains(`maplibregl-attrib-empty`)||(this._container.setAttribute(`open`,``),this._container.classList.add(`maplibregl-compact`,`maplibregl-compact-show`)):(this._container.setAttribute(`open`,``),this._container.classList.contains(`maplibregl-compact`)&&this._container.classList.remove(`maplibregl-compact`,`maplibregl-compact-show`))},this._updateCompactMinimize=()=>{this._container.classList.contains(`maplibregl-compact`)&&this._container.classList.contains(`maplibregl-compact-show`)&&this._container.classList.remove(`maplibregl-compact-show`)},this.options=e}getDefaultPosition(){return`bottom-right`}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=h.create(`details`,`maplibregl-ctrl maplibregl-ctrl-attrib`),this._compactButton=h.create(`summary`,`maplibregl-ctrl-attrib-button`,this._container),this._compactButton.addEventListener(`click`,this._toggleAttribution),this._setElementTitle(this._compactButton,`ToggleAttribution`),this._innerContainer=h.create(`div`,`maplibregl-ctrl-attrib-inner`,this._container),this._updateAttributions(),this._updateCompact(),this._map.on(`styledata`,this._updateData),this._map.on(`sourcedata`,this._updateData),this._map.on(`terrain`,this._updateData),this._map.on(`resize`,this._updateCompact),this._map.on(`drag`,this._updateCompactMinimize),this._container}onRemove(){this._container.remove(),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,r){let _=this._map._getUIString(`AttributionControl.${r}`);e.title=_,e.setAttribute(`aria-label`,_)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(e=>typeof e==`string`?e:``)):typeof this.options.customAttribution==`string`&&e.push(this.options.customAttribution)),this._map.style.stylesheet){let e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}let r=this._map.style.tileManagers;for(let _ in r){let v=r[_];if(v.used||v.usedForTerrain){let r=v.getSource();r.attribution&&e.indexOf(r.attribution)<0&&e.push(r.attribution)}}e=e.filter(e=>String(e).trim()),e.sort((e,r)=>e.length-r.length),e=e.filter((r,_)=>{for(let v=_+1;v=0)return!1;return!0});let _=e.join(` | `);_!==this._attribHTML&&(this._attribHTML=_,e.length?(this._innerContainer.innerHTML=h.sanitize(_),this._container.classList.remove(`maplibregl-attrib-empty`)):this._container.classList.add(`maplibregl-attrib-empty`),this._updateCompact(),this._editLink=null)}}class Kr{constructor(e={}){this._updateCompact=()=>{let e=this._container.children;if(e.length){let r=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&r.classList.add(`maplibregl-compact`):r.classList.remove(`maplibregl-compact`)}},this.options=e}getDefaultPosition(){return`bottom-left`}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=h.create(`div`,`maplibregl-ctrl`);let r=h.create(`a`,`maplibregl-ctrl-logo`);return r.target=`_blank`,r.rel=`noopener nofollow`,r.href=`https://maplibre.org/`,r.setAttribute(`aria-label`,this._map._getUIString(`LogoControl.Title`)),r.setAttribute(`rel`,`noopener nofollow`),this._container.appendChild(r),this._container.style.display=`block`,this._map.on(`resize`,this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off(`resize`,this._updateCompact),this._map=void 0,this._compact=void 0}}class Yr{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){let r=++this._id;return this._queue.push({callback:e,id:r,cancelled:!1}),r}remove(e){let r=this._currentlyRunning,_=r?this._queue.concat(r):this._queue;for(let r of _)if(r.id===e)return void(r.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw Error(`Attempting to run(), but is already running.`);let r=this._currentlyRunning=this._queue;this._queue=[];for(let _ of r)if(!_.cancelled&&(_.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var rc=_.aS([{name:`a_pos3d`,type:`Int16`,components:3}]);class Jr extends _.E{constructor(e){super(),this._lastTilesetChange=O(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(e,r){this.tileManager.update(e,r),this._renderableTilesKeys=[];let v={};for(let b of ot(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:r,calculateTileZoom:this.tileManager._source.calculateTileZoom}))v[b.key]=!0,this._renderableTilesKeys.push(b.key),this._tiles[b.key]||(b.terrainRttPosMatrix32f=new Float64Array(16),_.c6(b.terrainRttPosMatrix32f,0,_.a5,_.a5,0,0,1),this._tiles[b.key]=new he(b,this.tileSize),this._lastTilesetChange=O());for(let e in this._tiles)v[e]||delete this._tiles[e]}freeRtt(e){for(let r in this._tiles){let _=this._tiles[r];(!e||_.tileID.equals(e)||_.tileID.isChildOf(e)||e.isChildOf(_.tileID))&&(_.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,r){return r?this._getTerrainCoordsForTileRanges(e,r):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){let r={};for(let v of this._renderableTilesKeys){let b=this._tiles[v].tileID,x=e.clone(),C=_.bi();if(b.canonical.equals(e.canonical))_.c6(C,0,_.a5,_.a5,0,0,1);else if(b.canonical.isChildOf(e.canonical)){let r=b.canonical.z-e.canonical.z,v=b.canonical.x-(b.canonical.x>>r<>r<>r;_.c6(C,0,T,T,0,0,1),_.O(C,C,[-v*T,-x*T,0])}else{if(!e.canonical.isChildOf(b.canonical))continue;{let r=e.canonical.z-b.canonical.z,v=e.canonical.x-(e.canonical.x>>r<>r<>r;_.c6(C,0,_.a5,_.a5,0,0,1),_.O(C,C,[v*T,x*T,0]),_.Q(C,C,[1/2**r,1/2**r,0])}}x.terrainRttPosMatrix32f=new Float32Array(C),r[v]=x}return r}_getTerrainCoordsForTileRanges(e,r){let v={};for(let b of this._renderableTilesKeys){let x=this._tiles[b].tileID;if(!this._isWithinTileRanges(x,r))continue;let C=e.clone(),T=_.bi();if(x.canonical.z===e.canonical.z){let r=e.canonical.x-x.canonical.x+e.wrap*(1<e.canonical.z){let r=x.canonical.z-e.canonical.z,v=x.canonical.x-(x.canonical.x>>r<>r<>r),E=e.canonical.y-(x.canonical.y>>r),D=_.a5>>r;_.c6(T,0,D,D,0,0,1),_.O(T,T,[-v*D+C*_.a5,-b*D+E*_.a5,0])}else{let r=e.canonical.z-x.canonical.z,v=e.canonical.x-(e.canonical.x>>r<>r<>r)-x.canonical.x,E=(e.canonical.y>>r)-x.canonical.y,D=_.a5<_.maxzoom&&(v=_.maxzoom),v<_.minzoom)return;this._sourceTileCache[e.key]||(this._sourceTileCache[e.key]=e.scaledTo(v).key);let b=this.findTileInCaches(this._sourceTileCache[e.key]);if(!b?.dem&&r)for(;v>=_.minzoom&&!b?.dem;)b=this.findTileInCaches(e.scaledTo(v--).key);return b}findTileInCaches(e){let r=this.tileManager.getTileByID(e);return r||(r=this.tileManager._outOfViewCache.getByKey(e),r)}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,r){let _=r[e.canonical.z];return!!_&&(e.wrap>_.minWrap||e.wrap<_.maxWrap||e.canonical.x>=_.minTileXWrapped&&e.canonical.x<=_.maxTileXWrapped&&e.canonical.y>=_.minTileY&&e.canonical.y<=_.maxTileY)}}class es{constructor(e,r,_){this._meshCache={},this.painter=e,this.tileManager=new Jr(r),this.options=_,this.exaggeration=typeof _.exaggeration==`number`?_.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}destroy(){this._fbo&&=(this._fbo.destroy(),null),this._fboCoordsTexture&&=(this._fboCoordsTexture.destroy(),null),this._fboDepthTexture&&=(this._fboDepthTexture.destroy(),null),this._emptyDemTexture&&=(this._emptyDemTexture.destroy(),null),this._emptyDepthTexture&&=(this._emptyDepthTexture.destroy(),null),this._coordsTexture&&=(this._coordsTexture.destroy(),null);for(let e in this._meshCache)this._meshCache[e].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(e,r,v,b=_.a5){var x;let C=e.normalizeCoordinates(r,v,b);if(!C)return 0;let T=this.getTerrainData(C.tileID),E=(x=T.tile)?.dem;if(!E)return 0;let D=_.cB([],[C.x/b*_.a5,C.y/b*_.a5],T.u_terrain_matrix),O=[D[0]*E.dim,D[1]*E.dim],k=Math.floor(O[0]),A=Math.floor(O[1]),j=O[0]-k,F=O[1]-A;return E.get(k,A)*(1-j)*(1-F)+E.get(k+1,A)*j*(1-F)+E.get(k,A+1)*(1-j)*F+E.get(k+1,A+1)*j*F}getElevationForLngLatZoom(e,r){if(!_.cC(r,e.wrap()))return 0;let{tileID:v,mercatorX:b,mercatorY:x}=this._getOverscaledTileIDFromLngLatZoom(e,r);return this.getElevation(v,b%_.a5,x%_.a5,_.a5)}getElevationForLngLat(e,r){let _=ot(r,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this}),v=0;for(let e of _)e.canonical.z>v&&(v=Math.min(e.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,v)}getElevation(e,r,v,b=_.a5){return this.getDEMElevation(e,r,v,b)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){let e=this.painter.context,r=new _.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new _.T(e,r,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new _.T(e,new _.R({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=_.ao([])}let r=this.tileManager.getSourceTile(e,!0);if(r&&r.dem&&(!r.demTexture||r.needsTerrainPrepare)){let e=this.painter.context;r.demTexture=this.painter.getTileTexture(r.dem.stride),r.demTexture?r.demTexture.update(r.dem.getPixels(),{premultiply:!1}):r.demTexture=new _.T(e,r.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),r.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),r.needsTerrainPrepare=!1}let v=r&&r.toString()+r.tileID.key+e.key;if(v&&!this._demMatrixCache[v]){let v=this.tileManager.getSource().maxzoom,b=e.canonical.z-r.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=v?b=e.canonical.z-v:_.w(`cannot calculate elevation if elevation maxzoom > source.maxzoom`));let x=e.canonical.x-(e.canonical.x>>b<>b<>8<<4|e>>8,r[_+3]=0;let v=new _.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(r.buffer)),b=new _.T(e,v,e.gl.RGBA,{premultiply:!1});return b.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=b,b}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);let r=new Uint8Array(4),v=this.painter.context,b=v.gl,x=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),C=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),T=Math.round(this.painter.height/devicePixelRatio);v.bindFramebuffer.set(this.getFramebuffer(`coords`).framebuffer),b.readPixels(x,T-C-1,1,1,b.RGBA,b.UNSIGNED_BYTE,r),v.bindFramebuffer.set(null);let E=r[0]+(r[2]>>4<<8),D=r[1]+((15&r[2])<<8),O=this.coordsIndex[255-r[3]],k=O&&this.tileManager.getTileByID(O);if(!k)return null;let A=this._coordsTextureSize,j=(1<0,b=v&&e.canonical.y===0,x=v&&e.canonical.y===(1<e.id!==r),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(let e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw 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)}}let ic={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class os{constructor(e,r){this.painter=e,this.terrain=r,this.pool=new ts(e.context,30,r.tileManager.tileSize*r.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,r){var _,v;this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(_=>!e._layers[_].isHidden(r)),this._coordsAscending={};for(let r in e.tileManagers){this._coordsAscending[r]={};let _=e.tileManagers[r].getVisibleCoordinates(),v=e.tileManagers[r].getSource(),b=v instanceof J?v.terrainTileRanges:null;for(let e of _){let _=this.terrain.tileManager.getTerrainCoords(e,b);for(let e in _)this._coordsAscending[r][e]||(this._coordsAscending[r][e]=[]),this._coordsAscending[r][e].push(_[e])}}this._rttFingerprints={};for(let r of e._order){let b=e._layers[r],x=b.source;if(ic[b.type]&&!this._rttFingerprints[x]){this._rttFingerprints[x]={};let r=(v=(_=e.tileManagers[x])?.getState().revision)??0;for(let e in this._coordsAscending[x])this._rttFingerprints[x][e]=`${this._coordsAscending[x][e].map(e=>e.key).sort().join()}#${r}`}}for(let e of this._renderableTiles)for(let r in this._rttFingerprints){let _=this._rttFingerprints[r][e.tileID.key];_&&_!==e.rttFingerprint[r]&&(e.rtt=[])}}renderLayer(e,r){if(e.isHidden(this.painter.transform.zoom))return!1;let v=Object.assign(Object.assign({},r),{isRenderingToTexture:!0}),b=e.type,x=this.painter,C=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(ic[b]&&(this._prevType&&ic[this._prevType]||this._stacks.push([]),this._prevType=b,this._stacks[this._stacks.length-1].push(e.id),!C))return!0;if(ic[this._prevType]||ic[b]&&C){this._prevType=b;let e=this._stacks.length-1,r=this._stacks[e]||[];for(let b of this._renderableTiles){if(this.pool.isFull()&&(us(this.painter,this.terrain,this._rttTiles,v),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(b),b.rtt[e]){let r=this.pool.getObjectForId(b.rtt[e].id);if(r.stamp===b.rtt[e].stamp){this.pool.useObject(r);continue}}let C=this.pool.getOrCreateFreeObject();this.pool.useObject(C),this.pool.stampObject(C),b.rtt[e]={id:C.id,stamp:C.stamp},x.context.bindFramebuffer.set(C.fbo.framebuffer),x.context.clear({color:_.bn.transparent,stencil:0}),x.currentStencilSource=void 0;for(let e=0;eb.maxZoom)throw Error(`maxZoom must be greater than or equal to minZoom`);if(b.minPitch!=null&&b.maxPitch!=null&&b.minPitch>b.maxPitch)throw Error(`maxPitch must be greater than or equal to minPitch`);if(b.minPitch!=null&&b.minPitch<0)throw Error(`minPitch must be greater than or equal to 0`);if(b.maxPitch!=null&&b.maxPitch>180)throw Error(`maxPitch must be less than or equal to 180`);let x=new Wt,C=new Xt;b.minZoom!==void 0&&x.setMinZoom(b.minZoom),b.maxZoom!==void 0&&x.setMaxZoom(b.maxZoom),b.minPitch!==void 0&&x.setMinPitch(b.minPitch),b.maxPitch!==void 0&&x.setMaxPitch(b.maxPitch),b.renderWorldCopies!==void 0&&x.setRenderWorldCopies(b.renderWorldCopies),b.transformConstrain!==null&&x.setConstrainOverride(b.transformConstrain),super(x,C,{bearingSnap:b.bearingSnap,zoomSnap:b.zoomSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Yr,this._controls=[],this._mapId=_.ac(),this._lostContextStyle={style:null,images:null},this._contextLost=e=>{if(e.preventDefault(),this._frameRequest&&=(this._frameRequest.abort(),null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),this.style){for(let e of Object.values(this.style._layers))if(e.type===`custom`&&console.warn(`Custom layer with id '${e.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),e._listeners)for(let[r]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${r}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.destroy(),this.style=null,this.fire(new _.l(`webglcontextlost`,{originalEvent:e}))}else this.fire(new _.l(`webglcontextlost`,{originalEvent:e}))},this._contextRestored=e=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.resize(),this._update(),this._resizeInternal(),this.fire(new _.l(`webglcontextrestored`,{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=b.interactive,this._maxTileCacheSize=b.maxTileCacheSize,this._maxTileCacheZoomLevels=b.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},b.canvasContextAttributes),this._trackResize=!0===b.trackResize,this._bearingSnap=b.bearingSnap,this._zoomSnap=b.zoomSnap,this._centerClampedToGround=b.centerClampedToGround,this._refreshExpiredTiles=!0===b.refreshExpiredTiles,this._fadeDuration=b.fadeDuration,this._crossSourceCollisions=!0===b.crossSourceCollisions,this._collectResourceTiming=!0===b.collectResourceTiming,this._locale=Object.assign(Object.assign({},ac),b.locale),this._clickTolerance=b.clickTolerance,this._overridePixelRatio=b.pixelRatio,this._maxCanvasSize=b.maxCanvasSize,this._zoomLevelsToOverscale=b.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=b.transformCameraUpdate,this.transformConstrain=b.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===b.cancelPendingTileRequestsWhileZooming,this.setAnisotropicFilterPitch(b.anisotropicFilterPitch),b.reduceMotion!==void 0&&(E.prefersReducedMotion=b.reduceMotion),this._imageQueueHandle=k.addThrottleControl(()=>this.isMoving()),this._requestManager=new d(b.transformRequest),this._container=this._resolveContainer(b.container),b.maxBounds&&this.setMaxBounds(b.maxBounds),this._setupContainer(),this._setupPainter(),this.on(`move`,()=>this._update(!1)),this.on(`moveend`,()=>this._update(!1)),this.on(`zoom`,()=>this._update(!0)),this.on(`terrain`,()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once(`idle`,()=>{this._idleTriggered=!0}),typeof window<`u`&&(this._ownerWindow.addEventListener(`online`,this._onWindowOnline,!1),this._setupResizeObserver()),this.handlers=new qr(this,b),this._hash=b.hash&&new qa(typeof b.hash==`string`&&b.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:b.center,elevation:b.elevation,zoom:b.zoom,bearing:b.bearing,pitch:b.pitch,roll:b.roll}),b.bounds&&(this.resize(),this.fitBounds(b.bounds,_.e({},b.fitBoundsOptions,{duration:0}))));let T=typeof b.style==`string`||(v=(r=b.style)?.projection)?.type!==`globe`;this.resize(null,T),this._localIdeographFontFamily=b.localIdeographFontFamily,this._validateStyle=b.validateStyle,b.style&&this.setStyle(b.style,{localIdeographFontFamily:b.localIdeographFontFamily}),b.attributionControl&&this.addControl(new Xr(typeof b.attributionControl==`boolean`?void 0:b.attributionControl)),b.maplibreLogo&&this.addControl(new Kr,b.logoPosition),this.on(`style.load`,()=>{if(T||this._resizeTransform(),this.transform.unmodified){let e=_.U(this.style.stylesheet,[`center`,`zoom`,`bearing`,`pitch`,`roll`]);this.jumpTo(e)}}),this.on(`data`,e=>{this._update(e.dataType===`style`),this.fire(new _.l(`${e.dataType}data`,e))}),this.on(`dataloading`,e=>{this.fire(new _.l(`${e.dataType}dataloading`,e))}),this.on(`dataabort`,e=>{this.fire(new _.l(`sourcedataabort`,e))})}_getMapId(){return this._mapId}setGlobalStateProperty(e,r){return this.style.setGlobalStateProperty(e,r),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,r){if(r===void 0&&(r=e.getDefaultPosition?e.getDefaultPosition():`top-right`),!e||!e.onAdd)return this.fire(new _.k(/* @__PURE__ */ Error(`Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.`)));let v=e.onAdd(this);this._controls.push(e);let b=this._controlPositions[r];return r.indexOf(`bottom`)===-1?b.appendChild(v):b.insertBefore(v,b.firstChild),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new _.k(/* @__PURE__ */ Error(`Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.`)));let r=this._controls.indexOf(e);return r>-1&&this._controls.splice(r,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}coveringTiles(e){return ot(this.transform,e)}calculateCameraOptionsFromTo(e,r,_,v){return v==null&&this.terrain&&(v=this.terrain.getElevationForLngLat(_,this.transform)),super.calculateCameraOptionsFromTo(e,r,_,v)}resize(e,r=!0){if(this._lostContextStyle.style!==null)return this;this._resizeInternal(r);let v=!this._moving;return v&&(this.stop(),this.fire(new _.l(`movestart`,e)).fire(new _.l(`move`,e))),this.fire(new _.l(`resize`,e)),v&&this.fire(new _.l(`moveend`,e)),this}_resizeInternal(e=!0){let[r,_]=this._containerDimensions(),v=this._getClampedPixelRatio(r,_);if(this._resizeCanvas(r,_,v),this.painter.resize(r,_,v),this.painter.overLimit()){let e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];let v=this._getClampedPixelRatio(r,_);this._resizeCanvas(r,_,v),this.painter.resize(r,_,v)}this._resizeTransform(e)}_resizeTransform(e=!0){var r;let[_,v]=this._containerDimensions();this.transform.resize(_,v,e),(r=this._requestedCameraState)==null||r.resize(_,v,e)}_getClampedPixelRatio(e,r){let{0:_,1:v}=this._maxCanvasSize,b=this.getPixelRatio(),x=e*b,C=r*b;return Math.min(x>_?_/x:1,C>v?v/C:1)*b}getPixelRatio(){var e;return(e=this._overridePixelRatio)??devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(N.convert(e)),this._update()}setMinZoom(e){if((e??=-2)>=-2&&e<=this.transform.maxZoom){let r=this.transform.zoom,v=this._getTransformForUpdate();return v.setMinZoom(e),this._applyUpdatedTransform(v),this._update(),r!==this.transform.zoom&&this.fire(new _.l(`zoomstart`)).fire(new _.l(`zoom`)).fire(new _.l(`zoomend`)).fire(new _.l(`movestart`)).fire(new _.l(`move`)).fire(new _.l(`moveend`)),this}throw Error(`minZoom must be between -2 and the current maxZoom, inclusive`)}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e??=22)>=this.transform.minZoom){let r=this.transform.zoom,v=this._getTransformForUpdate();return v.setMaxZoom(e),this._applyUpdatedTransform(v),this._update(),r!==this.transform.zoom&&this.fire(new _.l(`zoomstart`)).fire(new _.l(`zoom`)).fire(new _.l(`zoomend`)).fire(new _.l(`movestart`)).fire(new _.l(`move`)).fire(new _.l(`moveend`)),this}throw Error(`maxZoom must be greater than the current minZoom`)}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e??=0)<0)throw Error(`minPitch must be greater than or equal to 0`);if(e>=0&&e<=this.transform.maxPitch){let r=this.transform.pitch,v=this._getTransformForUpdate();return v.setMinPitch(e),this._applyUpdatedTransform(v),this._update(),r!==this.transform.pitch&&this.fire(new _.l(`pitchstart`)).fire(new _.l(`pitch`)).fire(new _.l(`pitchend`)).fire(new _.l(`movestart`)).fire(new _.l(`move`)).fire(new _.l(`moveend`)),this}throw Error(`minPitch must be between 0 and the current maxPitch, inclusive`)}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e??=60)>180)throw Error(`maxPitch must be less than or equal to 180`);if(e>=this.transform.minPitch){let r=this.transform.pitch,v=this._getTransformForUpdate();return v.setMaxPitch(e),this._applyUpdatedTransform(v),this._update(),r!==this.transform.pitch&&this.fire(new _.l(`pitchstart`)).fire(new _.l(`pitch`)).fire(new _.l(`pitchend`)).fire(new _.l(`movestart`)).fire(new _.l(`move`)).fire(new _.l(`moveend`)),this}throw Error(`maxPitch must be greater than the current minPitch`)}getMaxPitch(){return this.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(e){if((e??=20)>180)throw Error(`anisotropicFilterPitch must be less than or equal to 180`);if(e<0)throw Error(`anisotropicFilterPitch must be greater than or equal to 0`);return this._anisotropicFilterPitch=e,this._update()}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this.transform.setConstrainOverride(e),this._update()}project(e){return this.transform.locationToScreenPoint(_.V.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(_.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(e=this.handlers)?.isMoving()}isZooming(){var e;return this._zooming||(e=this.handlers)?.isZooming()}isRotating(){var e;return this._rotating||(e=this.handlers)?.isRotating()}_createDelegatedListener(e,r,_){if(e===`mouseenter`||e===`mouseover`){let v=!1,b=b=>{let x=r.filter(e=>this.getLayer(e)),C=x.length===0?[]:this.queryRenderedFeatures(b.point,{layers:x});C.length?v||(v=!0,_.call(this,new ir(e,this,b.originalEvent,{features:C}))):v=!1};return{layers:r,listener:_,delegates:{mousemove:b,mouseout:()=>{v=!1}}}}if(e===`mouseleave`||e===`mouseout`){let v=!1,b=b=>{let x=r.filter(e=>this.getLayer(e));(x.length===0?[]:this.queryRenderedFeatures(b.point,{layers:x})).length?v=!0:v&&(v=!1,_.call(this,new ir(e,this,b.originalEvent)))},x=r=>{v&&(v=!1,_.call(this,new ir(e,this,r.originalEvent)))};return{layers:r,listener:_,delegates:{mousemove:b,mouseout:x}}}{let v=e=>{let v=r.filter(e=>this.getLayer(e)),b=v.length===0?[]:this.queryRenderedFeatures(e.point,{layers:v});b.length&&(e.features=b,_.call(this,e),delete e.features)};return{layers:r,listener:_,delegates:{[e]:v}}}}_saveDelegatedListener(e,r){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r)}_removeDelegatedListener(e,r,_){if(!this._delegatedListeners||!this._delegatedListeners[e])return;let v=this._delegatedListeners[e];for(let e=0;er.includes(e))){for(let e in b.delegates)this.off(e,b.delegates[e]);v.splice(e,1);return}}}on(e,r,_){if(_===void 0)return super.on(e,r);let v=typeof r==`string`?[r]:r,b=this._createDelegatedListener(e,v,_);this._saveDelegatedListener(e,b);for(let e in b.delegates)this.on(e,b.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,v,_)}}}once(e,r,_){if(_===void 0)return super.once(e,r);let v=typeof r==`string`?[r]:r,b=this._createDelegatedListener(e,v,_);for(let r in b.delegates){let x=b.delegates[r];b.delegates[r]=(...r)=>{this._removeDelegatedListener(e,v,_),x(...r)}}this._saveDelegatedListener(e,b);for(let e in b.delegates)this.once(e,b.delegates[e]);return this}off(e,r,_){return _===void 0?super.off(e,r):(this._removeDelegatedListener(e,typeof r==`string`?[r]:r,_),this)}queryRenderedFeatures(e,r){if(!this.style)return[];let v,b=e instanceof _.P||Array.isArray(e),x=b?e:[[0,0],[this.transform.width,this.transform.height]];if(r=r||(b?{}:e)||{},x instanceof _.P||typeof x[0]==`number`)v=[_.P.convert(x)];else{let e=_.P.convert(x[0]),r=_.P.convert(x[1]);v=[e,new _.P(r.x,e.y),r,new _.P(e.x,r.y),e]}return this.style.queryRenderedFeatures(v,r,this.transform)}querySourceFeatures(e,r){return this.style.querySourceFeatures(e,r)}setStyle(e,r){return!1!==(r=_.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},r)).diff&&r.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,r),this):(this._localIdeographFontFamily=r.localIdeographFontFamily,this._updateStyle(e,r))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){let r=this._locale[e];if(r==null)throw Error(`Missing UI string '${e}'`);return r}_updateStyle(e,r){var _,v,b;if((_=this._diffStyleRequest)==null||_.abort(),this._diffStyleRequest=null,r.transformStyle&&this.style&&!this.style._loaded)return void this.style.once(`style.load`,()=>this._updateStyle(e,r));let x=this.style&&r.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new Ai(this,r||{}),this.style.setEventedParent(this,{style:this.style}),typeof e==`string`?this.style.loadURL(e,r,x):this.style.loadJSON(e,r,x),this):(this._frameRequest&&=(this._frameRequest.abort(),null),(b=(v=this.style)?.projection)==null||b.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Ai(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,r){return _._(this,void 0,void 0,function*(){var v;if((v=this._diffStyleRequest)==null||v.abort(),typeof e==`string`){let v=e;this._diffStyleRequest=new AbortController;let b=this._diffStyleRequest;try{let e=yield this._requestManager.transformRequest(v,`Style`);if(b.signal.aborted)return void(this._diffStyleRequest=null);let x=yield _.j(e,b);this._diffStyleRequest=null,this._updateDiff(x.data,r)}catch(e){this._diffStyleRequest=null,_.Z(e)||this.fire(new _.k(e))}}else typeof e==`object`&&(this._diffStyleRequest=null,this._updateDiff(e,r))})}_updateDiff(e,r){try{this.style.setState(e,r)&&this._update(!0)}catch(v){_.w(`Unable to perform style diff: ${v.message||v.error||v}. Rebuilding the style from scratch.`),this._updateStyle(e,r)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){return this.style?this.style.loaded():_.w(`There is no style added to the map.`)}addSource(e,r){return this._lazyInitEmptyStyle(),this.style.addSource(e,r),this._update(!0)}isSourceLoaded(e){let r=this.style&&this.style.tileManagers[e];if(r!==void 0)return r.loaded();this.fire(new _.k(/* @__PURE__ */ Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off(`data`,this._terrainDataCallback),e){let r=this.style.tileManagers[e.source];if(!r)throw Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);this.terrain===null&&r.reload();for(let r in this.style._layers){let v=this.style._layers[r];v.type===`hillshade`&&v.source===e.source&&_.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.`),v.type===`color-relief`&&v.source===e.source&&_.w(`You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.`)}this.terrain=new es(this.painter,r,e),this.painter.renderToTexture=new os(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=r=>{var _;r.dataType===`style`?this.terrain.tileManager.freeRtt():r.dataType===`source`&&r.tile&&(r.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),(_=r.source)?.type===`image`?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(r.tile.tileID))},this.style.on(`data`,this._terrainDataCallback)}else this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new _.l(`terrain`,{terrain:e})),this}getTerrain(){var e,r;return(r=(e=this.terrain)?.options)??null}areTilesLoaded(){let e=this.style&&this.style.tileManagers;for(let r of Object.values(e))if(!r.areTilesLoaded())return!1;return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,r,_){if(_){let v=this.getSource(_);if(!v)throw Error(`There is no source with ID "${_}", cannot set LOD parameters`);v.calculateTileZoom=tt(Math.max(1,e),Math.max(1,r))}else for(let _ in this.style.tileManagers)this.style.tileManagers[_].getSource().calculateTileZoom=tt(Math.max(1,e),Math.max(1,r));return this._update(!0),this}refreshTiles(e,r){let v=this.style.tileManagers[e];if(!v)throw Error(`There is no tile manager with ID "${e}", cannot refresh tile`);r===void 0?v.reload(!0):v.refreshTiles(r.map(e=>new _.a9(e.z,e.x,e.y)))}addImage(e,r,v={}){let{pixelRatio:b=1,sdf:x=!1,stretchX:C,stretchY:T,content:D,textFitWidth:O,textFitHeight:k}=v;if(this._lazyInitEmptyStyle(),!(r instanceof HTMLImageElement||_.b(r))){if(r.width===void 0||r.height===void 0)return this.fire(new _.k(/* @__PURE__ */ 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:v,height:E,data:A}=r,j=r;return this.style.addImage(e,{data:new _.R({width:v,height:E},new Uint8Array(A)),pixelRatio:b,stretchX:C,stretchY:T,content:D,textFitWidth:O,textFitHeight:k,sdf:x,version:0,userImage:j}),j.onAdd&&j.onAdd(this,e),this}}{let{width:v,height:A,data:j}=E.getImageData(r);this.style.addImage(e,{data:new _.R({width:v,height:A},j),pixelRatio:b,stretchX:C,stretchY:T,content:D,textFitWidth:O,textFitHeight:k,sdf:x,version:0})}}updateImage(e,r){let v=this.style.getImage(e);if(!v)return this.fire(new _.k(/* @__PURE__ */ Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:b,height:x,data:C}=r instanceof HTMLImageElement||_.b(r)?E.getImageData(r):r;if(b===void 0||x===void 0)return this.fire(new _.k(/* @__PURE__ */ 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(b!==v.data.width||x!==v.data.height)return this.fire(new _.k(/* @__PURE__ */ Error(`The width and height of the updated image must be that same as the previous version of the image`)));let T=!(r instanceof HTMLImageElement||_.b(r));return v.data.replace(C,T),this.style.updateImage(e,v),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new _.k(/* @__PURE__ */ Error(`Missing required image id`))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return _._(this,void 0,void 0,function*(){return k.getImage(yield this._requestManager.transformRequest(e,`Image`),new AbortController)})}listImages(){return this.style.listImages()}addLayer(e,r){return this._lazyInitEmptyStyle(),this.style.addLayer(e,r),this._update(!0)}moveLayer(e,r){return this.style.moveLayer(e,r),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,r,_){return this.style.setLayerZoomRange(e,r,_),this._update(!0)}setFilter(e,r,_={}){return this.style.setFilter(e,r,_),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,r,_,v={}){return this.style.setPaintProperty(e,r,_,v),this._update(!0)}getPaintProperty(e,r){return this.style.getPaintProperty(e,r)}setLayoutProperty(e,r,_,v={}){return this.style.setLayoutProperty(e,r,_,v),this._update(!0)}getLayoutProperty(e,r){return this.style.getLayoutProperty(e,r)}setGlyphs(e,r={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,r),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,r,_={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,r,_,e=>{e||this._update(!0)}),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,r={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,r,e=>{e||this._update(!0)}),this}setLight(e,r={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,r),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,r={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,r),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,r){return this.style.setFeatureState(e,r),this._update()}removeFeatureState(e,r){return this.style.removeFeatureState(e,r),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,r=0;return this._container&&(e=this._container.clientWidth||400,r=this._container.clientHeight||300),[e,r]}_setupResizeObserver(){var e;let r=!1,_=fs(e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())},50);this._resizeObserver=new((e=this._ownerWindow.ResizeObserver)??ResizeObserver)(e=>{r?_(e):r=!0}),this._resizeObserver.observe(this._container)}_resolveContainer(e){if(typeof e==`string`){let r=document.getElementById(e);if(!r)throw Error(`Container '${e}' not found.`);return r}if(e instanceof HTMLElement||e&&typeof e==`object`&&e.nodeType===1)return e;throw Error(`Invalid type: 'container' must be a String or HTMLElement.`)}_setupContainer(){let e=this._container;e.classList.add(`maplibregl-map`);let r=this._canvasContainer=h.create(`div`,`maplibregl-canvas-container`,e);this._interactive&&r.classList.add(`maplibregl-interactive`),this._canvas=h.create(`canvas`,`maplibregl-canvas`,r),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 _=this._containerDimensions(),v=this._getClampedPixelRatio(_[0],_[1]);this._resizeCanvas(_[0],_[1],v);let b=this._controlContainer=h.create(`div`,`maplibregl-control-container`,e),x=this._controlPositions={};[`top-left`,`top-right`,`bottom-left`,`bottom-right`].forEach(e=>{x[e]=h.create(`div`,`maplibregl-ctrl-${e} `,b)}),this._container.addEventListener(`scroll`,this._onMapScroll,!1)}_resizeCanvas(e,r,_){this._canvas.width=Math.floor(_*e),this._canvas.height=Math.floor(_*r),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${r}px`}_setupPainter(){let e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0}),r=null;this._canvas.addEventListener(`webglcontextcreationerror`,_=>{r={requestedAttributes:e},_&&(r.statusMessage=_.statusMessage,r.type=_.type)},{once:!0});let _=null;if(_=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext(`webgl2`,e)||this._canvas.getContext(`webgl`,e),!_){let e=`Failed to initialize WebGL`;throw r?(r.message=e,Error(JSON.stringify(r))):Error(e)}this.painter=new Va(_,this.transform)}migrateProjection(e,r){super.migrateProjection(e,r),this.painter.transform=e,this.fire(new _.l(`projectiontransition`,{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){var r,v,b,x,C;let T=this._idleTriggered?this._fadeDuration:0,E=(r=this.style.projection)?.transitionState>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let D=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let e=this.transform.zoom,r=O();this.style.zoomHistory.update(e,r);let v=new _.H(e,{now:r,fadeDuration:T,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),b=v.crossFadingFactor();b===1&&b===this._crossFadingFactor||(D=!0,this._crossFadingFactor=b),this.style.update(v)}let k=(v=this.style.projection)?.transitionState>0!==E;(b=this.style.projection)==null||b.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState((x=this.style.projection)?.transitionState,(C=this.style.projection)?.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||k)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,T,this._crossSourceCollisions,k),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:T,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new _.l(`render`)),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new _.l(`load`))),this.style&&(this.style.hasTransitions()||D)&&(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 _.l(`idle`)),!this._loaded||this._fullyLoaded||A||(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&=(this._frameRequest.abort(),null),this._render(0)),this}remove(){var e,r;this._hash&&this._hash.remove();for(let e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&=(this._frameRequest.abort(),null),this._renderTaskQueue.clear(),(e=this._diffStyleRequest)==null||e.abort(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<`u`&&this._ownerWindow.removeEventListener(`online`,this._onWindowOnline,!1),k.removeThrottleControl(this._imageQueueHandle),(r=this._resizeObserver)==null||r.disconnect();let v=this.painter.context.gl.getExtension(`WEBGL_lose_context`);v?.loseContext&&v.loseContext(),this._canvas.removeEventListener(`webglcontextrestored`,this._contextRestored,!1),this._canvas.removeEventListener(`webglcontextlost`,this._contextLost,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._container.removeEventListener(`scroll`,this._onMapScroll,!1),this._container.classList.remove(`maplibregl-map`),this._removed=!0,this.fire(new _.l(`remove`))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,E.frame(this._frameRequest,e=>{this._frameRequest=null;try{this._render(e)}catch(e){if(!_.Z(e)&&!function(e){return e.message===ua}(e))throw e}},()=>{},this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get version(){return oc}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},cc={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class cs{constructor(e,r,v=!1){this.mousedown=e=>{this.startMove(e,h.mousePos(this.element,e)),window.addEventListener(`mousemove`,this.mousemove),window.addEventListener(`mouseup`,this.mouseup)},this.mousemove=e=>{this.move(e,h.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{e.targetTouches.length===1?(this._startPos=this._lastPos=h.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),window.addEventListener(`touchmove`,this.touchmove,{passive:!1}),window.addEventListener(`touchend`,this.touchend)):this.reset()},this.touchmove=e=>{e.targetTouches.length===1?(this._lastPos=h.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos)):this.reset()},this.touchend=e=>{e.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=r,this._rotatePitchHandler=new _r({clickTolerance:3,move:(e,b)=>{let x=r.getBoundingClientRect(),C=new _.P((x.bottom-x.top)/2,(x.right-x.left)/2);return{bearingDelta:_.cw(new _.P(e.x,b.y),b,C),pitchDelta:v?-.5*(b.y-e.y):void 0}},moveStateManager:new xr,enable:!0,assignEvents:()=>{}}),this.map=e,r.addEventListener(`mousedown`,this.mousedown),r.addEventListener(`touchstart`,this.touchstart,{passive:!1}),r.addEventListener(`touchcancel`,this.reset)}startMove(e,r){this._rotatePitchHandler.dragStart(e,r),h.disableDrag()}move(e,r){let _=this.map,{bearingDelta:v,pitchDelta:b}=this._rotatePitchHandler.dragMove(e,r)||{};v&&_.setBearing(_.getBearing()+v),b&&_.setPitch(_.getPitch()+b)}off(){let e=this.element;e.removeEventListener(`mousedown`,this.mousedown),e.removeEventListener(`touchstart`,this.touchstart),window.removeEventListener(`touchmove`,this.touchmove),window.removeEventListener(`touchend`,this.touchend),e.removeEventListener(`touchcancel`,this.reset),this.offTemp()}offTemp(){h.enableDrag(),window.removeEventListener(`mousemove`,this.mousemove),window.removeEventListener(`mouseup`,this.mouseup),window.removeEventListener(`touchmove`,this.touchmove),window.removeEventListener(`touchend`,this.touchend)}}let lc;function uc(e,r,v,b=!1){if(b||!v.getCoveringTilesDetailsProvider().allowWorldCopies())return e?.wrap();let x=new _.V(e.lng,e.lat);if(e=new _.V(e.lng,e.lat),r){let b=new _.V(e.lng-360,e.lat),x=new _.V(e.lng+360,e.lat),C=v.locationToScreenPoint(e).distSqr(r);v.locationToScreenPoint(b).distSqr(r)180;){let r=v.locationToScreenPoint(e);if(r.x>=0&&r.y>=0&&r.x<=v.width&&r.y<=v.height)break;e.lng>v.center.lng?e.lng-=360:e.lng+=360}return e.lng!==x.lng&&v.isPointOnMapSurface(v.locationToScreenPoint(e))?e:x}let dc={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 fc(e,r,_){let v=e.classList;for(let e in dc)v.remove(`maplibregl-${_}-anchor-${e}`);v.add(`maplibregl-${_}-anchor-${r}`)}class ps extends _.E{constructor(e){if(super(),this._onClick=e=>{this.fire(new _.l(`click`,{originalEvent:e}))},this._onKeyPress=e=>{e.code!==`Space`&&e.code!==`Enter`||this.togglePopup()},this._onMapClick=e=>{let r=e.originalEvent.target,_=this._element;this._popup&&(r===_||_.contains(r))&&this.togglePopup()},this._update=e=>{if(!this._map)return;let r=this._map.loaded()&&!this._map.isMoving();(e?.type===`terrain`||e?.type===`render`&&!r)&&this._map.once(`render`,this._update),this._lngLat=uc(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let _=``;this._rotationAlignment===`viewport`||this._rotationAlignment===`auto`?_=`rotateZ(${this._rotation}deg)`:this._rotationAlignment===`map`&&(_=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let v=``;this._pitchAlignment===`viewport`||this._pitchAlignment===`auto`?v=`rotateX(0deg)`:this._pitchAlignment===`map`&&(v=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&e.type!==`moveend`||(this._pos=this._pos.round()),this._element.style.transform=`${dc[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${v} ${_}`,E.frameAsync(new AbortController,this._map._ownerWindow).then(()=>{this._updateOpacity(e&&e.type===`moveend`)}).catch(()=>{})},this._onMove=e=>{if(!this._isDragging){let r=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=r}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents=`none`,this._state===`pending`&&(this._state=`active`,this.fire(new _.l(`dragstart`))),this.fire(new _.l(`drag`)))},this._onUp=()=>{this._element.style.pointerEvents=`auto`,this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off(`mousemove`,this._onMove),this._map.off(`touchmove`,this._onMove),this._state===`active`&&this.fire(new _.l(`dragend`)),this._state=`inactive`},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state=`pending`,this._map.on(`mousemove`,this._onMove),this._map.on(`touchmove`,this._onMove),this._map.once(`mouseup`,this._onUp),this._map.once(`touchend`,this._onUp))},this._anchor=e&&e.anchor||`center`,this._color=e&&e.color||`#3FB1CE`,this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state=`inactive`,this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||`auto`,this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment!==`auto`?e.pitchAlignment:this._rotationAlignment,this.setOpacity(e?.opacity,e?.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=_.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=h.create(`div`);let r=h.createNS(`http://www.w3.org/2000/svg`,`svg`),v=41,b=27;r.setAttributeNS(null,`display`,`block`),r.setAttributeNS(null,`height`,`41px`),r.setAttributeNS(null,`width`,`27px`),r.setAttributeNS(null,`viewBox`,`0 0 27 41`);let x=h.createNS(`http://www.w3.org/2000/svg`,`g`);x.setAttributeNS(null,`stroke`,`none`),x.setAttributeNS(null,`stroke-width`,`1`),x.setAttributeNS(null,`fill`,`none`),x.setAttributeNS(null,`fill-rule`,`evenodd`);let C=h.createNS(`http://www.w3.org/2000/svg`,`g`);C.setAttributeNS(null,`fill-rule`,`nonzero`);let T=h.createNS(`http://www.w3.org/2000/svg`,`g`);T.setAttributeNS(null,`transform`,`translate(3.0, 29.0)`),T.setAttributeNS(null,`fill`,`#000000`);for(let e of[{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`}]){let r=h.createNS(`http://www.w3.org/2000/svg`,`ellipse`);r.setAttributeNS(null,`opacity`,`0.04`),r.setAttributeNS(null,`cx`,`10.5`),r.setAttributeNS(null,`cy`,`5.80029008`),r.setAttributeNS(null,`rx`,e.rx),r.setAttributeNS(null,`ry`,e.ry),T.appendChild(r)}let E=h.createNS(`http://www.w3.org/2000/svg`,`g`);E.setAttributeNS(null,`fill`,this._color);let D=h.createNS(`http://www.w3.org/2000/svg`,`path`);D.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`),E.appendChild(D);let O=h.createNS(`http://www.w3.org/2000/svg`,`g`);O.setAttributeNS(null,`opacity`,`0.25`),O.setAttributeNS(null,`fill`,`#000000`);let k=h.createNS(`http://www.w3.org/2000/svg`,`path`);k.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`),O.appendChild(k);let A=h.createNS(`http://www.w3.org/2000/svg`,`g`);A.setAttributeNS(null,`transform`,`translate(6.0, 7.0)`),A.setAttributeNS(null,`fill`,`#FFFFFF`);let j=h.createNS(`http://www.w3.org/2000/svg`,`g`);j.setAttributeNS(null,`transform`,`translate(8.0, 8.0)`);let F=h.createNS(`http://www.w3.org/2000/svg`,`circle`);F.setAttributeNS(null,`fill`,`#000000`),F.setAttributeNS(null,`opacity`,`0.25`),F.setAttributeNS(null,`cx`,`5.5`),F.setAttributeNS(null,`cy`,`5.5`),F.setAttributeNS(null,`r`,`5.4999962`);let R=h.createNS(`http://www.w3.org/2000/svg`,`circle`);R.setAttributeNS(null,`fill`,`#FFFFFF`),R.setAttributeNS(null,`cx`,`5.5`),R.setAttributeNS(null,`cy`,`5.5`),R.setAttributeNS(null,`r`,`5.4999962`),j.appendChild(F),j.appendChild(R),C.appendChild(T),C.appendChild(E),C.appendChild(O),C.appendChild(A),C.appendChild(j),r.appendChild(C),r.setAttributeNS(null,`height`,41*this._scale+`px`),r.setAttributeNS(null,`width`,27*this._scale+`px`),this._element.appendChild(r),this._offset=_.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add(`maplibregl-marker`),this._element.addEventListener(`dragstart`,e=>{e.preventDefault()}),this._element.addEventListener(`mousedown`,e=>{e.preventDefault()}),fc(this._element,this._anchor,`marker`),e&&e.className)for(let r of e.className.split(` `))this._element.classList.add(r);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute(`aria-label`)||this._element.setAttribute(`aria-label`,e._getUIString(`Marker.Title`)),this._element.hasAttribute(`role`)||this._element.setAttribute(`role`,`button`),e.getCanvasContainer().appendChild(this._element),e.on(`move`,this._update),e.on(`moveend`,this._update),e.on(`terrain`,this._update),e.on(`projectiontransition`,this._update),this._element.addEventListener(`click`,this._onClick),this.setDraggable(this._draggable),this._update(),this._map.on(`click`,this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off(`click`,this._onMapClick),this._map.off(`move`,this._update),this._map.off(`moveend`,this._update),this._map.off(`terrain`,this._update),this._map.off(`projectiontransition`,this._update),this._map.off(`mousedown`,this._addDragHandler),this._map.off(`touchstart`,this._addDragHandler),this._map.off(`mouseup`,this._onUp),this._map.off(`touchend`,this._onUp),this._map.off(`mousemove`,this._onMove),this._map.off(`touchmove`,this._onMove),delete this._map),this._element.removeEventListener(`click`,this._onClick),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=_.V.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 r=38.1,_=13.5,v=13.5/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-r],"bottom-left":[v,-1*(r-_+v)],"bottom-right":[-v,-1*(r-_+v)],left:[_,-1*(r-_)],right:[-_,-1*(r-_)]}: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||e&&(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map))),this}_updateOpacity(e=!1){var r,v;let b=(r=this._map)?.terrain,x=this._map.transform.isLocationOccluded(this._lngLat);if(!b||x){let e=x?this._opacityWhenCovered:this._opacity;this._element.style.opacity!==e&&(this._element.style.opacity=e);return}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}let C=this._map,T=C.terrain.depthAtPoint(this._pos),E=C.terrain.getElevationForLngLat(this._lngLat,C.transform);if(C.transform.lngLatToCameraDepth(this._lngLat,E)-T<.006)return void(this._element.style.opacity=this._opacity);let D=-this._offset.y/C.transform.pixelsPerMeter,O=Math.sin(C.getPitch()*Math.PI/180)*D,k=C.terrain.depthAtPoint(new _.P(this._pos.x,this._pos.y-this._offset.y)),A=C.transform.lngLatToCameraDepth(this._lngLat,E+O)-k>.006;(v=this._popup)?.isOpen()&&A&&this._popup.remove(),this._element.style.opacity=A?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=_.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,r){return(this._opacity===void 0||e===void 0&&r===void 0)&&(this._opacity=`1`,this._opacityWhenCovered=`0.2`),e!==void 0&&(this._opacity=e),r!==void 0&&(this._opacityWhenCovered=r),this._map&&this._updateOpacity(!0),this}}let pc={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},mc=0,hc=!1,gc={maxWidth:100,unit:`metric`};function _c(e,r,_){let v=_&&_.maxWidth||100,b=e._container.clientHeight/2,x=e._container.clientWidth/2,C=e.unproject([x-v/2,b]),T=e.unproject([x+v/2,b]),E=Math.round(e.project(T).x-e.project(C).x),D=Math.min(v,E,e._container.clientWidth),O=C.distanceTo(T);if(_&&_.unit===`imperial`){let _=3.2808*O;_>5280?vc(r,D,_/5280,e._getUIString(`ScaleControl.Miles`)):vc(r,D,_,e._getUIString(`ScaleControl.Feet`))}else _&&_.unit===`nautical`?vc(r,D,O/1852,e._getUIString(`ScaleControl.NauticalMiles`)):O>=1e3?vc(r,D,O/1e3,e._getUIString(`ScaleControl.Kilometers`)):vc(r,D,O,e._getUIString(`ScaleControl.Meters`))}function vc(e,r,_,v){let b=function(e){let r=10**(`${Math.floor(e)}`.length-1),_=e/r;return _=_>=10?10:_>=5?5:_>=3?3:_>=2?2:_>=1?1:function(e){let r=10**Math.ceil(-Math.log(e)/Math.LN10);return Math.round(e*r)/r}(_),r*_}(_);e.style.width=b/_*r+`px`,e.innerHTML=`${b} ${v}`}let yc={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:``,maxWidth:`240px`,subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},bc=[`a[href]`,`[tabindex]:not([tabindex='-1'])`,`[contenteditable]:not([contenteditable='false'])`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`].join(`, `);function xc(e){if(e){if(typeof e==`number`){let r=Math.round(Math.abs(e)/Math.SQRT2);return{center:new _.P(0,0),top:new _.P(0,e),"top-left":new _.P(r,r),"top-right":new _.P(-r,r),bottom:new _.P(0,-e),"bottom-left":new _.P(r,-r),"bottom-right":new _.P(-r,-r),left:new _.P(e,0),right:new _.P(-e,0)}}if(e instanceof _.P||Array.isArray(e)){let r=_.P.convert(e);return{center:r,top:r,"top-left":r,"top-right":r,bottom:r,"bottom-left":r,"bottom-right":r,left:r,right:r}}return{center:_.P.convert(e.center||[0,0]),top:_.P.convert(e.top||[0,0]),"top-left":_.P.convert(e[`top-left`]||[0,0]),"top-right":_.P.convert(e[`top-right`]||[0,0]),bottom:_.P.convert(e.bottom||[0,0]),"bottom-left":_.P.convert(e[`bottom-left`]||[0,0]),"bottom-right":_.P.convert(e[`bottom-right`]||[0,0]),left:_.P.convert(e.left||[0,0]),right:_.P.convert(e.right||[0,0])}}return xc(new _.P(0,0))}let Sc=v;r.AJAXError=_.cF,r.EXTENT=_.a5,r.Event=_.l,r.Evented=_.E,r.LngLat=_.V,r.MercatorCoordinate=_.a6,r.Point=_.P,r.addProtocol=_.cG,r.config=_.c,r.removeProtocol=_.cH,r.AttributionControl=Xr,r.BoxZoomHandler=lr,r.CanvasSource=te,r.CooperativeGesturesHandler=Ur,r.DoubleClickZoomHandler=Fr,r.DragPanHandler=jr,r.DragRotateHandler=Zr,r.EdgeInsets=Ot,r.FullscreenControl=class extends _.E{constructor(e={}){var r;super(),this._onFullscreenChange=()=>{var e;let r=window.document.fullscreenElement||window.document.webkitFullscreenElement;for(;(e=r?.shadowRoot)?.fullscreenElement;)r=r.shadowRoot.fullscreenElement;r===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,this._pseudo=(r=e.pseudo)!=null&&r,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:_.w(`Full screen control 'container' must be a DOM element.`)),`onfullscreenchange`in document?this._fullscreenchange=`fullscreenchange`:`onmozfullscreenchange`in document?this._fullscreenchange=`mozfullscreenchange`:`onwebkitfullscreenchange`in document?this._fullscreenchange=`webkitfullscreenchange`:`onmsfullscreenchange`in document&&(this._fullscreenchange=`MSFullscreenChange`)}onAdd(e){return this._map=e,this._container||=this._map.getContainer(),this._controlContainer=h.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._setupUI(),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let e=this._fullscreenButton=h.create(`button`,`maplibregl-ctrl-fullscreen`,this._controlContainer);h.create(`span`,`maplibregl-ctrl-icon`,e).setAttribute(`aria-hidden`,`true`),e.type=`button`,this._updateTitle(),this._fullscreenButton.addEventListener(`click`,this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let e=this._getTitle();this._fullscreenButton.setAttribute(`aria-label`,e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?`FullscreenControl.Exit`:`FullscreenControl.Enter`)}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle(`maplibregl-ctrl-shrink`),this._fullscreenButton.classList.toggle(`maplibregl-ctrl-fullscreen`),this._updateTitle(),this._fullscreen?(this.fire(new _.l(`fullscreenstart`)),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new _.l(`fullscreenend`)),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){this._pseudo?this._togglePseudoFullScreen():window.document.exitFullscreen?window.document.exitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._pseudo?this._togglePseudoFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle(`maplibregl-pseudo-fullscreen`),this._handleFullscreenChange(),this._map.resize()}},r.GeoJSONSource=Q,r.GeolocateControl=class extends _.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new _.l(`outofmaxbounds`,e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case`WAITING_ACTIVE`:case`ACTIVE_LOCK`:case`ACTIVE_ERROR`:this._watchState=`ACTIVE_LOCK`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`BACKGROUND`:case`BACKGROUND_ERROR`:this._watchState=`BACKGROUND`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background`);break;default:throw 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 _.l(`geolocate`,e)),this._finish()}},this._updateCamera=e=>{let r=new _.V(e.coords.longitude,e.coords.latitude),v=e.coords.accuracy,b=this._map.getBearing(),x=_.e({bearing:b},this.options.fitBoundsOptions),C=N.fromLngLat(r,v);this._map.fitBounds(C,x,{geolocateSource:!0})},this._updateMarker=e=>{if(e){let r=new _.V(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(r).addTo(this._map),this._userLocationDotMarker.setLngLat(r).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(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 e=this._map._getUIString(`GeolocateControl.LocationNotAvailable`);this._geolocateButton.title=e,this._geolocateButton.setAttribute(`aria-label`,e),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(e.code===3&&hc)return;this._setErrorState()}this._watchState!==`OFF`&&this.options.showUserLocation&&this._dotElement.classList.add(`maplibregl-user-location-dot-stale`),this.fire(new _.l(`error`,e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._onMoveStart=e=>{if(!this._map)return;let r=e?.[0]instanceof ResizeObserverEntry;e.geolocateSource||this._watchState!==`ACTIVE_LOCK`||r||this._map.isZooming()||(this._watchState=`BACKGROUND`,this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this.fire(new _.l(`trackuserlocationend`)),this.fire(new _.l(`userlocationlostfocus`)))},this._setupUI=()=>{this._map&&(this._container.addEventListener(`contextmenu`,e=>e.preventDefault()),this._geolocateButton=h.create(`button`,`maplibregl-ctrl-geolocate`,this._container),h.create(`span`,`maplibregl-ctrl-icon`,this._geolocateButton).setAttribute(`aria-hidden`,`true`),this._geolocateButton.type=`button`,this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){_.w(`Geolocation support is not available so the GeolocateControl will be disabled.`);let e=this._map._getUIString(`GeolocateControl.LocationNotAvailable`);this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute(`aria-label`,e)}else{let e=this._map._getUIString(`GeolocateControl.FindMyLocation`);this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute(`aria-label`,e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute(`aria-pressed`,`false`),this._watchState=`OFF`),this.options.showUserLocation&&(this._dotElement=h.create(`div`,`maplibregl-user-location-dot`),this._userLocationDotMarker=new ps({element:this._dotElement}),this._circleElement=h.create(`div`,`maplibregl-user-location-accuracy-circle`),this._accuracyCircleMarker=new ps({element:this._circleElement,pitchAlignment:`map`}),this.options.trackUserLocation&&(this._watchState=`OFF`),this._map.on(`zoom`,this._onUpdate),this._map.on(`move`,this._onUpdate),this._map.on(`rotate`,this._onUpdate),this._map.on(`pitch`,this._onUpdate)),this._geolocateButton.addEventListener(`click`,()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on(`movestart`,this._onMoveStart)}},this.options=_.e({},pc,e)}onAdd(e){return this._map=e,this._container=h.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._setupUI(),function(){return _._(this,arguments,void 0,function*(e=!1){if(lc!==void 0&&!e)return lc;if(window.navigator.permissions===void 0)return lc=!!window.navigator.geolocation,lc;try{lc=(yield window.navigator.permissions.query({name:`geolocation`})).state!==`denied`}catch{lc=!!window.navigator.geolocation}return lc})}().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(),this._container.remove(),this._map.off(`movestart`,this._onMoveStart),this._map.off(`zoom`,this._onUpdate),this._map.off(`move`,this._onUpdate),this._map.off(`rotate`,this._onUpdate),this._map.off(`pitch`,this._onUpdate),this._map=void 0,mc=0,hc=!1}_isOutOfMapMaxBounds(e){let r=this._map.getMaxBounds(),_=e.coords;return r&&(_.longituder.getEast()||_.latituder.getNorth())}_setErrorState(){switch(this._watchState){case`WAITING_ACTIVE`:this._watchState=`ACTIVE_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active-error`);break;case`ACTIVE_LOCK`:this._watchState=`ACTIVE_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`);break;case`BACKGROUND`:this._watchState=`BACKGROUND_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`);break;case`ACTIVE_ERROR`:case`BACKGROUND_ERROR`:case`OFF`:case void 0:break;default:throw Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){let e=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&e))return;let r=this._map.project(e),_=this._map.unproject([r.x+100,r.y]),v=e.distanceTo(_)/100,b=2*this._accuracy/v;this._circleElement.style.width=`${b.toFixed(2)}px`,this._circleElement.style.height=`${b.toFixed(2)}px`}trigger(){if(!this._setup)return _.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 _.l(`trackuserlocationstart`));break;case`WAITING_ACTIVE`:case`ACTIVE_LOCK`:case`ACTIVE_ERROR`:case`BACKGROUND_ERROR`:mc--,hc=!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 _.l(`trackuserlocationend`));break;case`BACKGROUND`:this._watchState=`ACTIVE_LOCK`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new _.l(`trackuserlocationstart`)),this.fire(new _.l(`userlocationfocus`));break;default:throw 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 Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState===`OFF`&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let e;this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.setAttribute(`aria-pressed`,`true`),mc++,mc>1?(e={maximumAge:6e5,timeout:0},hc=!0):(e=this.options.positionOptions,hc=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.setAttribute(`aria-pressed`,`false`),this.options.showUserLocation&&this._updateMarker(null)}},r.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;let r=(e=this._map.getProjection())?.type;this._map.setProjection(r!==`mercator`&&r?{type:`mercator`}:{type:`globe`}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove(`maplibregl-ctrl-globe`),this._globeButton.classList.remove(`maplibregl-ctrl-globe-enabled`),(e=this._map.getProjection())?.type===`globe`?(this._globeButton.classList.add(`maplibregl-ctrl-globe-enabled`),this._globeButton.title=this._map._getUIString(`GlobeControl.Disable`)):(this._globeButton.classList.add(`maplibregl-ctrl-globe`),this._globeButton.title=this._map._getUIString(`GlobeControl.Enable`))}}onAdd(e){return this._map=e,this._container=h.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._globeButton=h.create(`button`,`maplibregl-ctrl-globe`,this._container),h.create(`span`,`maplibregl-ctrl-icon`,this._globeButton).setAttribute(`aria-hidden`,`true`),this._globeButton.type=`button`,this._globeButton.addEventListener(`click`,this._toggleProjection),this._updateGlobeIcon(),this._map.on(`styledata`,this._updateGlobeIcon),this._map.on(`projectiontransition`,this._updateGlobeIcon),this._container}onRemove(){this._container.remove(),this._map.off(`styledata`,this._updateGlobeIcon),this._map.off(`projectiontransition`,this._updateGlobeIcon),this._globeButton.removeEventListener(`click`,this._toggleProjection),this._map=void 0}},r.Hash=qa,r.ImageSource=J,r.KeyboardHandler=zr,r.LngLatBounds=N,r.LogoControl=Kr,r.Map=ns,r.MapLibreMap=ns,r.MapMouseEvent=ir,r.MapTouchEvent=or,r.MapWheelEvent=ar,r.Marker=ps,r.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{let e=this._map.getZoom(),r=e===this._map.getMaxZoom(),_=e===this._map.getMinZoom();this._zoomInButton.disabled=r,this._zoomOutButton.disabled=_,this._zoomInButton.setAttribute(`aria-disabled`,r.toString()),this._zoomOutButton.setAttribute(`aria-disabled`,_.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.cos(this._map.transform.pitchInRadians)**.5}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.cos(this._map.transform.pitchInRadians)**.5}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,r)=>{let _=this._map._getUIString(`NavigationControl.${r}`);e.title=_,e.setAttribute(`aria-label`,_)},this.options=_.e({},cc,e),this._container=h.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._container.addEventListener(`contextmenu`,e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton(`maplibregl-ctrl-zoom-in`,e=>this._map.zoomIn({},{originalEvent:e})),h.create(`span`,`maplibregl-ctrl-icon`,this._zoomInButton).setAttribute(`aria-hidden`,`true`),this._zoomOutButton=this._createButton(`maplibregl-ctrl-zoom-out`,e=>this._map.zoomOut({},{originalEvent:e})),h.create(`span`,`maplibregl-ctrl-icon`,this._zoomOutButton).setAttribute(`aria-hidden`,`true`)),this.options.showCompass&&(this._compass=this._createButton(`maplibregl-ctrl-compass`,e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=h.create(`span`,`maplibregl-ctrl-icon`,this._compass),this._compassIcon.setAttribute(`aria-hidden`,`true`))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,`ZoomIn`),this._setButtonTitle(this._zoomOutButton,`ZoomOut`),this._map.on(`zoom`,this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,`ResetBearing`),this.options.visualizePitch&&this._map.on(`pitch`,this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on(`roll`,this._rotateCompassArrow),this._map.on(`rotate`,this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new cs(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off(`zoom`,this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off(`pitch`,this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off(`roll`,this._rotateCompassArrow),this._map.off(`rotate`,this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,r){let _=h.create(`button`,e,this._container);return _.type=`button`,_.addEventListener(`click`,r),_}},r.Popup=class extends _.E{constructor(e){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:``)},this.remove=()=>(this._content&&this._content.remove(),this._container&&(this._container.remove(),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._update),this._map.off(`mouseup`,this._update),this._map.off(`drag`,this._update),this._map._canvasContainer.classList.remove(`maplibregl-track-pointer`),delete this._map,this.fire(new _.l(`close`))),this),this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=h.create(`div`,`maplibregl-popup`,this._map.getContainer()),this._tip=h.create(`div`,`maplibregl-popup-tip`,this._container),this._container.appendChild(this._content),this.options.className)for(let e of this.options.className.split(` `))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute(`aria-label`,this._map._getUIString(`Popup.Close`)),this._trackPointer&&this._container.classList.add(`maplibregl-popup-track-pointer`)}let r;if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=uc(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),e&&`point`in e&&e.point&&(r=e.point),this._trackPointer&&!r)return;let _=this._flatPos=this._pos=this._trackPointer&&r?r:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&r?r:this._map.transform.locationToScreenPoint(this._lngLat));let v=this.options.anchor,b=xc(this.options.offset);if(!v){let e=this._container.offsetWidth,r=this._container.offsetHeight,x=function(e){var r,_,v,b;return e?{top:(r=e.top)??0,right:(_=e.right)??0,bottom:(v=e.bottom)??0,left:(b=e.left)??0}:{top:0,right:0,bottom:0,left:0}}(this.options.padding),C;C=_.y+b.bottom.ythis._map.transform.height-r-x.bottom?[`bottom`]:[],_.xthis._map.transform.width-e/2-x.right&&C.push(`right`),v=C.length===0?`bottom`:C.join(`-`)}let x=_.add(b[v]);this.options.subpixelPositioning||(x=x.round()),this._container.style.transform=`${dc[v]} translate(${x.x}px,${x.y}px)`,fc(this._container,v,`popup`),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=_.e(Object.create(yc),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on(`click`,this._onClose),this.options.closeOnMove&&this._map.on(`move`,this._onClose),this._map.on(`remove`,this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on(`mousemove`,this._update),this._map.on(`mouseup`,this._update),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 _.l(`open`)),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=_.V.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on(`move`,this._update),this._map.off(`mousemove`,this._update),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._update),this._map.on(`drag`,this._update),this._container&&this._container.classList.add(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.add(`maplibregl-track-pointer`)),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){let r=document.createDocumentFragment(),_=document.createElement(`body`),v;for(_.innerHTML=e;v=_.firstChild,v;)r.appendChild(v);return this.setDOMContent(r)}getMaxWidth(){var e;return(e=this._container)?.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=h.create(`div`,`maplibregl-popup-content`,this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}setPadding(e){this.options.padding=e,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=h.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 e=this._container.querySelector(bc);e&&e.focus()}},r.RasterDEMTileSource=W,r.RasterTileSource=V,r.ScaleControl=class{constructor(e){this._onMove=()=>{_c(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,_c(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},gc),e)}getDefaultPosition(){return`bottom-left`}onAdd(e){return this._map=e,this._container=h.create(`div`,`maplibregl-ctrl maplibregl-ctrl-scale`,e.getContainer()),this._map.on(`move`,this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off(`move`,this._onMove),this._map=void 0}},r.ScrollZoomHandler=kr,r.Style=Ai,r.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove(`maplibregl-ctrl-terrain`),this._terrainButton.classList.remove(`maplibregl-ctrl-terrain-enabled`),this._map.terrain?(this._terrainButton.classList.add(`maplibregl-ctrl-terrain-enabled`),this._terrainButton.title=this._map._getUIString(`TerrainControl.Disable`)):(this._terrainButton.classList.add(`maplibregl-ctrl-terrain`),this._terrainButton.title=this._map._getUIString(`TerrainControl.Enable`))},this.options=e}onAdd(e){return this._map=e,this._container=h.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._terrainButton=h.create(`button`,`maplibregl-ctrl-terrain`,this._container),h.create(`span`,`maplibregl-ctrl-icon`,this._terrainButton).setAttribute(`aria-hidden`,`true`),this._terrainButton.type=`button`,this._terrainButton.addEventListener(`click`,this._toggleTerrain),this._updateTerrainIcon(),this._map.on(`terrain`,this._updateTerrainIcon),this._container}onRemove(){this._container.remove(),this._map.off(`terrain`,this._updateTerrainIcon),this._map=void 0}},r.TwoFingersTouchPitchHandler=Sr,r.TwoFingersTouchRotateHandler=Mr,r.TwoFingersTouchZoomHandler=Cr,r.TwoFingersTouchZoomRotateHandler=Nr,r.VectorTileSource=G,r.VideoSource=ee,r.addSourceType=(e,r)=>_._(void 0,void 0,void 0,function*(){if(be(e))throw Error(`A source type called "${e}" already exists.`);((e,r)=>{ye[e]=r})(e,r)}),r.clearPrewarmedResources=function(){let e=ne;e&&(e.isPreloaded()&&e.numActive()===1?(e.release(Y),ne=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()`))},r.createTileMesh=cr,r.getMaxParallelImageRequests=function(){return _.c.MAX_PARALLEL_IMAGE_REQUESTS},r.getRTLTextPluginStatus=function(){return we().getRTLTextPluginStatus()},r.getVersion=function(){return Sc},r.getWorkerCount=function(){return S.workerCount},r.getWorkerUrl=function(){return _.c.WORKER_URL},r.importScriptInWorkers=function(e){return ae().broadcast(`IS`,e)},r.isTimeFrozen=function(){return D.isFrozen()},r.now=O,r.prewarm=function(){ie().acquire(Y)},r.restoreNow=function(){D.restoreNow()},r.setMaxParallelImageRequests=function(e){_.c.MAX_PARALLEL_IMAGE_REQUESTS=e},r.setNow=function(e){D.setNow(e)},r.setRTLTextPlugin=function(e,r){return we().setRTLTextPlugin(e,r)},r.setWorkerCount=function(e){S.workerCount=e},r.setWorkerUrl=function(e){_.c.WORKER_URL=e}}),r});var _=r;export{_ as default};