You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

729 lines
889 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import{g as Yp}from"./index-CNEkaNgL.js";function Jp(Da,Tc){for(var Rr=0;Rr<Tc.length;Rr++){const Ri=Tc[Rr];if(typeof Ri!="string"&&!Array.isArray(Ri)){for(const Lr in Ri)if(Lr!=="default"&&!(Lr in Da)){const Ra=Object.getOwnPropertyDescriptor(Ri,Lr);Ra&&Object.defineProperty(Da,Lr,Ra.get?Ra:{enumerable:!0,get:()=>Ri[Lr]})}}}return Object.freeze(Object.defineProperty(Da,Symbol.toStringTag,{value:"Module"}))}var wc={exports:{}};/**
* MapLibre GL JS
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.1.0/LICENSE.txt
*/var Qp=wc.exports,fd;function ef(){return fd||(fd=1,function(Da,Tc){(function(Rr,Ri){Da.exports=Ri()})(Qp,function(){var Rr={},Ri={};function Lr(z,c,Pi){if(Ri[z]=Pi,z==="index"){var fr="var sharedModule = {}; ("+Ri.shared+")(sharedModule); ("+Ri.worker+")(sharedModule);",Mi={};return Ri.shared(Mi),Ri.index(Rr,Mi),typeof window<"u"&&Rr.setWorkerUrl(window.URL.createObjectURL(new Blob([fr],{type:"text/javascript"}))),Rr}}Lr("shared",["exports"],function(z){function c(n,t,r,s){return new(r||(r=Promise))(function(l,d){function p(x){try{g(s.next(x))}catch(b){d(b)}}function m(x){try{g(s.throw(x))}catch(b){d(b)}}function g(x){var b;x.done?l(x.value):(b=x.value,b instanceof r?b:new r(function(w){w(b)})).then(p,m)}g((s=s.apply(n,t||[])).next())})}function Pi(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var fr,Mi;function mr(){if(Mi)return fr;function n(t,r){this.x=t,this.y=r}return Mi=1,fr=n,n.prototype={clone:function(){return new n(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,r){return this.clone()._rotateAround(t,r)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var r=t.x-this.x,s=t.y-this.y;return r*r+s*s},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,r){return Math.atan2(this.x*r-this.y*t,this.x*t+this.y*r)},_matMult:function(t){var r=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=r,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var r=Math.cos(t),s=Math.sin(t),l=s*this.x+r*this.y;return this.x=r*this.x-s*this.y,this.y=l,this},_rotateAround:function(t,r){var s=Math.cos(t),l=Math.sin(t),d=r.y+l*(this.x-r.x)+s*(this.y-r.y);return this.x=r.x+s*(this.x-r.x)-l*(this.y-r.y),this.y=d,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},n.convert=function(t){return t instanceof n?t:Array.isArray(t)?new n(t[0],t[1]):t},fr}typeof SuppressedError=="function"&&SuppressedError;var Ze,ue,Oe=Pi(mr()),Br=function(){if(ue)return Ze;function n(t,r,s,l){this.cx=3*t,this.bx=3*(s-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*r,this.by=3*(l-r)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=r,this.p2x=s,this.p2y=l}return ue=1,Ze=n,n.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,r){if(r===void 0&&(r=1e-6),t<0)return 0;if(t>1)return 1;for(var s=t,l=0;l<8;l++){var d=this.sampleCurveX(s)-t;if(Math.abs(d)<r)return s;var p=this.sampleCurveDerivativeX(s);if(Math.abs(p)<1e-6)break;s-=d/p}var m=0,g=1;for(s=t,l=0;l<20&&(d=this.sampleCurveX(s),!(Math.abs(d-t)<r));l++)t>d?m=s:g=s,s=.5*(g-m)+m;return s},solve:function(t,r){return this.sampleCurveY(this.solveCurveX(t,r))}},Ze}(),_r=Pi(Br);let Fr,Or;function Xn(){return Fr==null&&(Fr=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Fr}function oi(){if(Or==null&&(Or=!1,Xn())){const t=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(t){for(let s=0;s<5*5;s++){const l=4*s;t.fillStyle=`rgb(${l},${l+1},${l+2})`,t.fillRect(s%5,Math.floor(s/5),1,1)}const r=t.getImageData(0,0,5,5).data;for(let s=0;s<5*5*4;s++)if(s%4!=3&&r[s]!==s){Or=!0;break}}}return Or||!1}var gr,Mt=1e-6,ft=typeof Float32Array<"u"?Float32Array:Array;function Ct(){var n=new ft(9);return ft!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=0,n[7]=0),n[0]=1,n[4]=1,n[8]=1,n}function Wn(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Rs(){var n=new ft(3);return ft!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function yr(n,t,r){var s=new ft(3);return s[0]=n,s[1]=t,s[2]=r,s}function Ji(n,t,r){var s=t[0],l=t[1],d=t[2],p=t[3];return n[0]=r[0]*s+r[4]*l+r[8]*d+r[12]*p,n[1]=r[1]*s+r[5]*l+r[9]*d+r[13]*p,n[2]=r[2]*s+r[6]*l+r[10]*d+r[14]*p,n[3]=r[3]*s+r[7]*l+r[11]*d+r[15]*p,n}function Si(){var n=new ft(4);return ft!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n[3]=1,n}function ei(){var n=new ft(2);return ft!=Float32Array&&(n[0]=0,n[1]=0),n}function Kn(n,t){var r=new ft(2);return r[0]=n,r[1]=t,r}Math.hypot||(Math.hypot=function(){for(var n=0,t=arguments.length;t--;)n+=arguments[t]*arguments[t];return Math.sqrt(n)}),Rs(),gr=new ft(4),ft!=Float32Array&&(gr[0]=0,gr[1]=0,gr[2]=0,gr[3]=0),Rs(),yr(1,0,0),yr(0,1,0),Si(),Si(),Ct(),ei();const rt=8192;function yn(n,t,r){return t*(rt/(n.tileSize*Math.pow(2,r-n.tileID.overscaledZ)))}function xr(n,t){return(n%t+t)%t}function jr(n,t,r){return n*(1-r)+t*r}function Nr(n){if(n<=0)return 0;if(n>=1)return 1;const t=n*n,r=t*n;return 4*(n<.5?r:3*(n-t)+r-.75)}function xn(n,t,r,s){const l=new _r(n,t,r,s);return d=>l.solve(d)}const $i=xn(.25,.1,.25,1);function Li(n,t,r){return Math.min(r,Math.max(t,n))}function Ii(n,t,r){const s=r-t,l=((n-t)%s+s)%s+t;return l===t?r:l}function Wt(n,...t){for(const r of t)for(const s in r)n[s]=r[s];return n}let Vr=1;function Ur(n,t,r){const s={};for(const l in n)s[l]=t.call(this,n[l],l,n);return s}function Zr(n,t,r){const s={};for(const l in n)t.call(this,n[l],l,n)&&(s[l]=n[l]);return s}function fi(n){return Array.isArray(n)?n.map(fi):typeof n=="object"&&n?Ur(n,fi):n}const Yn={};function ti(n){Yn[n]||(typeof console<"u"&&console.warn(n),Yn[n]=!0)}function Ot(n,t,r){return(r.y-n.y)*(t.x-n.x)>(t.y-n.y)*(r.x-n.x)}function Qi(n){return typeof WorkerGlobalScope<"u"&&n!==void 0&&n instanceof WorkerGlobalScope}let zt=null;function Gr(n){return typeof ImageBitmap<"u"&&n instanceof ImageBitmap}const $r="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Bi(n,t,r,s,l){return c(this,void 0,void 0,function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");const d=new VideoFrame(n,{timestamp:0});try{const p=d==null?void 0:d.format;if(!p||!p.startsWith("BGR")&&!p.startsWith("RGB"))throw new Error(`Unrecognized format ${p}`);const m=p.startsWith("BGR"),g=new Uint8ClampedArray(s*l*4);if(yield d.copyTo(g,function(x,b,w,M,C){const E=4*Math.max(1,0),k=(Math.max(0,w)-w)*M*4+E,O=4*M,Z=Math.max(0,b),ee=Math.max(0,w);return{rect:{x:Z,y:ee,width:Math.min(x.width,b+M)-Z,height:Math.min(x.height,w+C)-ee},layout:[{offset:k,stride:O}]}}(n,t,r,s,l)),m)for(let x=0;x<g.length;x+=4){const b=g[x];g[x]=g[x+2],g[x+2]=b}return g}finally{d.close()}})}let vr,br;function mi(n){return n/Math.PI*180}const qr="AbortError";function Hr(){return new Error(qr)}const wr={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function Jn(n){return wr.REGISTERED_PROTOCOLS[n.substring(0,n.indexOf("://"))]}const Xr="global-dispatcher";class er extends Error{constructor(t,r,s,l){super(`AJAXError: ${r} (${t}): ${s}`),this.status=t,this.statusText=r,this.url=s,this.body=l}}const Wr=()=>Qi(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,tr=function(n,t){if(/:\/\//.test(n.url)&&!/^https?:|^file:/.test(n.url)){const s=Jn(n.url);if(s)return s(n,t);if(Qi(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:n,targetMapId:Xr},t)}if(!(/^file:/.test(r=n.url)||/^file:/.test(Wr())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(s,l){return c(this,void 0,void 0,function*(){const d=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:Wr(),signal:l.signal});let p,m;s.type!=="json"||d.headers.has("Accept")||d.headers.set("Accept","application/json");try{p=yield fetch(d)}catch(x){throw new er(0,x.message,s.url,new Blob)}if(!p.ok){const x=yield p.blob();throw new er(p.status,p.statusText,s.url,x)}m=s.type==="arrayBuffer"||s.type==="image"?p.arrayBuffer():s.type==="json"?p.json():p.text();const g=yield m;if(l.signal.aborted)throw Hr();return{data:g,cacheControl:p.headers.get("Cache-Control"),expires:p.headers.get("Expires")}})}(n,t);if(Qi(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:n,mustQueue:!0,targetMapId:Xr},t)}var r;return function(s,l){return new Promise((d,p)=>{var m;const g=new XMLHttpRequest;g.open(s.method||"GET",s.url,!0),s.type!=="arrayBuffer"&&s.type!=="image"||(g.responseType="arraybuffer");for(const x in s.headers)g.setRequestHeader(x,s.headers[x]);s.type==="json"&&(g.responseType="text",!((m=s.headers)===null||m===void 0)&&m.Accept||g.setRequestHeader("Accept","application/json")),g.withCredentials=s.credentials==="include",g.onerror=()=>{p(new Error(g.statusText))},g.onload=()=>{if(!l.signal.aborted)if((g.status>=200&&g.status<300||g.status===0)&&g.response!==null){let x=g.response;if(s.type==="json")try{x=JSON.parse(g.response)}catch(b){return void p(b)}d({data:x,cacheControl:g.getResponseHeader("Cache-Control"),expires:g.getResponseHeader("Expires")})}else{const x=new Blob([g.response],{type:g.getResponseHeader("Content-Type")});p(new er(g.status,g.statusText,s.url,x))}},l.signal.addEventListener("abort",()=>{g.abort(),p(Hr())}),g.send(s.body)})}(n,t)};function Kr(n){if(!n||n.indexOf("://")<=0||n.indexOf("data:image/")===0||n.indexOf("blob:")===0)return!0;const t=new URL(n),r=window.location;return t.protocol===r.protocol&&t.host===r.host}function Tr(n,t,r){r[n]&&r[n].indexOf(t)!==-1||(r[n]=r[n]||[],r[n].push(t))}function vn(n,t,r){if(r&&r[n]){const s=r[n].indexOf(t);s!==-1&&r[n].splice(s,1)}}class bn{constructor(t,r={}){Wt(this,r),this.type=t}}class Qn extends bn{constructor(t,r={}){super("error",Wt({error:t},r))}}class Pr{on(t,r){return this._listeners=this._listeners||{},Tr(t,r,this._listeners),{unsubscribe:()=>{this.off(t,r)}}}off(t,r){return vn(t,r,this._listeners),vn(t,r,this._oneTimeListeners),this}once(t,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},Tr(t,r,this._oneTimeListeners),this):new Promise(s=>this.once(t,s))}fire(t,r){typeof t=="string"&&(t=new bn(t,r||{}));const s=t.type;if(this.listens(s)){t.target=this;const l=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(const m of l)m.call(this,t);const d=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(const m of d)vn(s,m,this._oneTimeListeners),m.call(this,t);const p=this._eventedParent;p&&(Wt(t,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),p.fire(t))}else t instanceof Qn&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,r){return this._eventedParent=t,this._eventedParentData=r,this}}var j={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"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_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const D=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function L(n,t){const r={};for(const s in n)s!=="ref"&&(r[s]=n[s]);return D.forEach(s=>{s in t&&(r[s]=t[s])}),r}function B(n,t){if(Array.isArray(n)){if(!Array.isArray(t)||n.length!==t.length)return!1;for(let r=0;r<n.length;r++)if(!B(n[r],t[r]))return!1;return!0}if(typeof n=="object"&&n!==null&&t!==null){if(typeof t!="object"||Object.keys(n).length!==Object.keys(t).length)return!1;for(const r in n)if(!B(n[r],t[r]))return!1;return!0}return n===t}function $(n,t){n.push(t)}function Y(n,t,r){$(r,{command:"addSource",args:[n,t[n]]})}function re(n,t,r){$(t,{command:"removeSource",args:[n]}),r[n]=!0}function le(n,t,r,s){re(n,r,s),Y(n,t,r)}function ie(n,t,r){let s;for(s in n[r])if(Object.prototype.hasOwnProperty.call(n[r],s)&&s!=="data"&&!B(n[r][s],t[r][s]))return!1;for(s in t[r])if(Object.prototype.hasOwnProperty.call(t[r],s)&&s!=="data"&&!B(n[r][s],t[r][s]))return!1;return!0}function fe(n,t,r,s,l,d){n=n||{},t=t||{};for(const p in n)Object.prototype.hasOwnProperty.call(n,p)&&(B(n[p],t[p])||r.push({command:d,args:[s,p,t[p],l]}));for(const p in t)Object.prototype.hasOwnProperty.call(t,p)&&!Object.prototype.hasOwnProperty.call(n,p)&&(B(n[p],t[p])||r.push({command:d,args:[s,p,t[p],l]}))}function he(n){return n.id}function ne(n,t){return n[t.id]=t,n}class te{constructor(t,r,s,l){this.message=(t?`${t}: `:"")+s,l&&(this.identifier=l),r!=null&&r.__line__&&(this.line=r.__line__)}}function Ie(n,...t){for(const r of t)for(const s in r)n[s]=r[s];return n}class Me extends Error{constructor(t,r){super(r),this.message=r,this.key=t}}class je{constructor(t,r=[]){this.parent=t,this.bindings={};for(const[s,l]of r)this.bindings[s]=l}concat(t){return new je(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const Ue={kind:"null"},ge={kind:"number"},Ce={kind:"string"},De={kind:"boolean"},qe={kind:"color"},Je={kind:"projectionDefinition"},Ve={kind:"object"},ze={kind:"value"},St={kind:"collator"},Mr={kind:"formatted"},jt={kind:"padding"},Rt={kind:"resolvedImage"},mt={kind:"variableAnchorOffsetCollection"};function _i(n,t){return{kind:"array",itemType:n,N:t}}function _t(n){if(n.kind==="array"){const t=_t(n.itemType);return typeof n.N=="number"?`array<${t}, ${n.N}>`:n.itemType.kind==="value"?"array":`array<${t}>`}return n.kind}const es=[Ue,ge,Ce,De,qe,Je,Mr,Ve,_i(ze),jt,Rt,mt];function wn(n,t){if(t.kind==="error")return null;if(n.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!wn(n.itemType,t.itemType))&&(typeof n.N!="number"||n.N===t.N))return null}else{if(n.kind===t.kind)return null;if(n.kind==="value"){for(const r of es)if(!wn(r,t))return null}}return`Expected ${_t(n)} but found ${_t(t)} instead.`}function La(n,t){return t.some(r=>r.kind===n.kind)}function Yr(n,t){return t.some(r=>r==="null"?n===null:r==="array"?Array.isArray(n):r==="object"?n&&!Array.isArray(n)&&typeof n=="object":r===typeof n)}function Jr(n,t){return n.kind==="array"&&t.kind==="array"?n.itemType.kind===t.itemType.kind&&typeof n.N=="number":n.kind===t.kind}const rl=.96422,Ba=.82521,nl=4/29,Tn=6/29,sl=3*Tn*Tn,Pc=Tn*Tn*Tn,Mc=Math.PI/180,Sc=180/Math.PI;function al(n){return(n%=360)<0&&(n+=360),n}function Fa([n,t,r,s]){let l,d;const p=Oa((.2225045*(n=Qr(n))+.7168786*(t=Qr(t))+.0606169*(r=Qr(r)))/1);n===t&&t===r?l=d=p:(l=Oa((.4360747*n+.3850649*t+.1430804*r)/rl),d=Oa((.0139322*n+.0971045*t+.7141733*r)/Ba));const m=116*p-16;return[m<0?0:m,500*(l-p),200*(p-d),s]}function Qr(n){return n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function Oa(n){return n>Pc?Math.pow(n,1/3):n/sl+nl}function ol([n,t,r,s]){let l=(n+16)/116,d=isNaN(t)?l:l+t/500,p=isNaN(r)?l:l-r/200;return l=1*ja(l),d=rl*ja(d),p=Ba*ja(p),[en(3.1338561*d-1.6168667*l-.4906146*p),en(-.9787684*d+1.9161415*l+.033454*p),en(.0719453*d-.2289914*l+1.4052427*p),s]}function en(n){return(n=n<=.00304?12.92*n:1.055*Math.pow(n,1/2.4)-.055)<0?0:n>1?1:n}function ja(n){return n>Tn?n*n*n:sl*(n-nl)}function Ls(n){return parseInt(n.padEnd(2,n),16)/255}function ll(n,t){return tn(t?n/100:n,0,1)}function tn(n,t,r){return Math.min(Math.max(t,n),r)}function Na(n){return!n.some(Number.isNaN)}const qi={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 He(n,t,r){return n+r*(t-n)}function Hi(n,t,r){return n.map((s,l)=>He(s,t[l],r))}class Xe{constructor(t,r,s,l=1,d=!0){this.r=t,this.g=r,this.b=s,this.a=l,d||(this.r*=l,this.g*=l,this.b*=l,l||this.overwriteGetter("rgb",[t,r,s,l]))}static parse(t){if(t instanceof Xe)return t;if(typeof t!="string")return;const r=function(s){if((s=s.toLowerCase().trim())==="transparent")return[0,0,0,0];const l=qi[s];if(l){const[p,m,g]=l;return[p/255,m/255,g/255,1]}if(s.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(s)){const p=s.length<6?1:2;let m=1;return[Ls(s.slice(m,m+=p)),Ls(s.slice(m,m+=p)),Ls(s.slice(m,m+=p)),Ls(s.slice(m,m+p)||"ff")]}if(s.startsWith("rgb")){const p=s.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(p){const[m,g,x,b,w,M,C,E,k,O,Z,ee]=p,q=[b||" ",C||" ",O].join("");if(q===" "||q===" /"||q===",,"||q===",,,"){const I=[x,M,k].join(""),F=I==="%%%"?100:I===""?255:0;if(F){const H=[tn(+g/F,0,1),tn(+w/F,0,1),tn(+E/F,0,1),Z?ll(+Z,ee):1];if(Na(H))return H}}return}}const d=s.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(d){const[p,m,g,x,b,w,M,C,E]=d,k=[g||" ",b||" ",M].join("");if(k===" "||k===" /"||k===",,"||k===",,,"){const O=[+m,tn(+x,0,100),tn(+w,0,100),C?ll(+C,E):1];if(Na(O))return function([Z,ee,q,I]){function F(H){const ae=(H+Z/30)%12,xe=ee*Math.min(q,1-q);return q-xe*Math.max(-1,Math.min(ae-3,9-ae,1))}return Z=al(Z),ee/=100,q/=100,[F(0),F(8),F(4),I]}(O)}}}(t);return r?new Xe(...r,!1):void 0}get rgb(){const{r:t,g:r,b:s,a:l}=this,d=l||1/0;return this.overwriteGetter("rgb",[t/d,r/d,s/d,l])}get hcl(){return this.overwriteGetter("hcl",function(t){const[r,s,l,d]=Fa(t),p=Math.sqrt(s*s+l*l);return[Math.round(1e4*p)?al(Math.atan2(l,s)*Sc):NaN,p,r,d]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Fa(this.rgb))}overwriteGetter(t,r){return Object.defineProperty(this,t,{value:r}),r}toString(){const[t,r,s,l]=this.rgb;return`rgba(${[t,r,s].map(d=>Math.round(255*d)).join(",")},${l})`}static interpolate(t,r,s,l="rgb"){switch(l){case"rgb":{const[d,p,m,g]=Hi(t.rgb,r.rgb,s);return new Xe(d,p,m,g,!1)}case"hcl":{const[d,p,m,g]=t.hcl,[x,b,w,M]=r.hcl;let C,E;if(isNaN(d)||isNaN(x))isNaN(d)?isNaN(x)?C=NaN:(C=x,m!==1&&m!==0||(E=b)):(C=d,w!==1&&w!==0||(E=p));else{let q=x-d;x>d&&q>180?q-=360:x<d&&d-x>180&&(q+=360),C=d+s*q}const[k,O,Z,ee]=function([q,I,F,H]){return q=isNaN(q)?0:q*Mc,ol([F,Math.cos(q)*I,Math.sin(q)*I,H])}([C,E??He(p,b,s),He(m,w,s),He(g,M,s)]);return new Xe(k,O,Z,ee,!1)}case"lab":{const[d,p,m,g]=ol(Hi(t.lab,r.lab,s));return new Xe(d,p,m,g,!1)}}}}Xe.black=new Xe(0,0,0,1),Xe.white=new Xe(1,1,1,1),Xe.transparent=new Xe(0,0,0,0),Xe.red=new Xe(1,0,0,1);class Bs{constructor(t,r,s){this.sensitivity=t?r?"variant":"case":r?"accent":"base",this.locale=s,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,r){return this.collator.compare(t,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const cl=["bottom","center","top"];class ts{constructor(t,r,s,l,d,p){this.text=t,this.image=r,this.scale=s,this.fontStack=l,this.textColor=d,this.verticalAlign=p}}class Et{constructor(t){this.sections=t}static fromString(t){return new Et([new ts(t,null,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(t=>t.text.length!==0||t.image&&t.image.name.length!==0)}static factory(t){return t instanceof Et?t:Et.fromString(t)}toString(){return this.sections.length===0?"":this.sections.map(t=>t.text).join("")}}class Nt{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Nt)return t;if(typeof t=="number")return new Nt([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const r of t)if(typeof r!="number")return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new Nt(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,r,s){return new Nt(Hi(t.values,r.values,s))}}class wt{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const Va=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class ii{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof ii)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let r=0;r<t.length;r+=2){const s=t[r],l=t[r+1];if(typeof s!="string"||!Va.has(s)||!Array.isArray(l)||l.length!==2||typeof l[0]!="number"||typeof l[1]!="number")return}return new ii(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,r,s){const l=t.values,d=r.values;if(l.length!==d.length)throw new wt(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${r.toString()}`);const p=[];for(let m=0;m<l.length;m+=2){if(l[m]!==d[m])throw new wt(`Cannot interpolate values containing mismatched anchors. from[${m}]: ${l[m]}, to[${m}]: ${d[m]}`);p.push(l[m]);const[g,x]=l[m+1],[b,w]=d[m+1];p.push([He(g,b,s),He(x,w,s)])}return new ii(p)}}class ri{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new ri({name:t,available:!1}):null}}class ni{constructor(t,r,s){this.from=t,this.to=r,this.transition=s}static interpolate(t,r,s){return new ni(t,r,s)}static parse(t){return t instanceof ni?t:Array.isArray(t)&&t.length===3&&typeof t[0]=="string"&&typeof t[1]=="string"&&typeof t[2]=="number"?new ni(t[0],t[1],t[2]):typeof t=="object"&&typeof t.from=="string"&&typeof t.to=="string"&&typeof t.transition=="number"?new ni(t.from,t.to,t.transition):typeof t=="string"?new ni(t,t,1):void 0}}function Ua(n,t,r,s){return typeof n=="number"&&n>=0&&n<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof r=="number"&&r>=0&&r<=255?s===void 0||typeof s=="number"&&s>=0&&s<=1?null:`Invalid rgba value [${[n,t,r,s].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof s=="number"?[n,t,r,s]:[n,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function rn(n){if(n===null||typeof n=="string"||typeof n=="boolean"||typeof n=="number"||n instanceof ni||n instanceof Xe||n instanceof Bs||n instanceof Et||n instanceof Nt||n instanceof ii||n instanceof ri)return!0;if(Array.isArray(n)){for(const t of n)if(!rn(t))return!1;return!0}if(typeof n=="object"){for(const t in n)if(!rn(n[t]))return!1;return!0}return!1}function ut(n){if(n===null)return Ue;if(typeof n=="string")return Ce;if(typeof n=="boolean")return De;if(typeof n=="number")return ge;if(n instanceof Xe)return qe;if(n instanceof ni)return Je;if(n instanceof Bs)return St;if(n instanceof Et)return Mr;if(n instanceof Nt)return jt;if(n instanceof ii)return mt;if(n instanceof ri)return Rt;if(Array.isArray(n)){const t=n.length;let r;for(const s of n){const l=ut(s);if(r){if(r===l)continue;r=ze;break}r=l}return _i(r||ze,t)}return Ve}function is(n){const t=typeof n;return n===null?"":t==="string"||t==="number"||t==="boolean"?String(n):n instanceof Xe||n instanceof ni||n instanceof Et||n instanceof Nt||n instanceof ii||n instanceof ri?n.toString():JSON.stringify(n)}class Xi{constructor(t,r){this.type=t,this.value=r}static parse(t,r){if(t.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!rn(t[1]))return r.error("invalid value");const s=t[1];let l=ut(s);const d=r.expectedType;return l.kind!=="array"||l.N!==0||!d||d.kind!=="array"||typeof d.N=="number"&&d.N!==0||(l=d),new Xi(l,s)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const ir={string:Ce,number:ge,boolean:De,object:Ve};class Ci{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let s,l=1;const d=t[0];if(d==="array"){let m,g;if(t.length>2){const x=t[1];if(typeof x!="string"||!(x in ir)||x==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);m=ir[x],l++}else m=ze;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return r.error('The length argument to "array" must be a positive integer literal',2);g=t[2],l++}s=_i(m,g)}else{if(!ir[d])throw new Error(`Types doesn't contain name = ${d}`);s=ir[d]}const p=[];for(;l<t.length;l++){const m=r.parse(t[l],l,ze);if(!m)return null;p.push(m)}return new Ci(s,p)}evaluate(t){for(let r=0;r<this.args.length;r++){const s=this.args[r].evaluate(t);if(!wn(this.type,ut(s)))return s;if(r===this.args.length-1)throw new wt(`Expected value to be of type ${_t(this.type)}, but found ${_t(ut(s))} instead.`)}throw new Error}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}const Za={"to-boolean":De,"to-color":qe,"to-number":ge,"to-string":Ce};class rr{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");const s=t[0];if(!Za[s])throw new Error(`Can't parse ${s} as it is not part of the known types`);if((s==="to-boolean"||s==="to-string")&&t.length!==2)return r.error("Expected one argument.");const l=Za[s],d=[];for(let p=1;p<t.length;p++){const m=r.parse(t[p],p,ze);if(!m)return null;d.push(m)}return new rr(l,d)}evaluate(t){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(t);case"color":{let r,s;for(const l of this.args){if(r=l.evaluate(t),s=null,r instanceof Xe)return r;if(typeof r=="string"){const d=t.parseColor(r);if(d)return d}else if(Array.isArray(r)&&(s=r.length<3||r.length>4?`Invalid rgba value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:Ua(r[0],r[1],r[2],r[3]),!s))return new Xe(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new wt(s||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"padding":{let r;for(const s of this.args){r=s.evaluate(t);const l=Nt.parse(r);if(l)return l}throw new wt(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"variableAnchorOffsetCollection":{let r;for(const s of this.args){r=s.evaluate(t);const l=ii.parse(r);if(l)return l}throw new wt(`Could not parse variableAnchorOffsetCollection from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"number":{let r=null;for(const s of this.args){if(r=s.evaluate(t),r===null)return 0;const l=Number(r);if(!isNaN(l))return l}throw new wt(`Could not convert ${JSON.stringify(r)} to number.`)}case"formatted":return Et.fromString(is(this.args[0].evaluate(t)));case"resolvedImage":return ri.fromString(is(this.args[0].evaluate(t)));case"projectionDefinition":return this.args[0].evaluate(t);default:return is(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}const Fs=["Unknown","Point","LineString","Polygon"];class dt{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?Fs[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let r=this._parseColorCache[t];return r||(r=this._parseColorCache[t]=Xe.parse(t)),r}}class Pn{constructor(t,r,s=[],l,d=new je,p=[]){this.registry=t,this.path=s,this.key=s.map(m=>`[${m}]`).join(""),this.scope=d,this.errors=p,this.expectedType=l,this._isConstant=r}parse(t,r,s,l,d={}){return r?this.concat(r,s,l)._parse(t,d):this._parse(t,d)}_parse(t,r){function s(l,d,p){return p==="assert"?new Ci(d,[l]):p==="coerce"?new rr(d,[l]):l}if(t!==null&&typeof t!="string"&&typeof t!="boolean"&&typeof t!="number"||(t=["literal",t]),Array.isArray(t)){if(t.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const l=t[0];if(typeof l!="string")return this.error(`Expression name must be a string, but found ${typeof l} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const d=this.registry[l];if(d){let p=d.parse(t,this);if(!p)return null;if(this.expectedType){const m=this.expectedType,g=p.type;if(m.kind!=="string"&&m.kind!=="number"&&m.kind!=="boolean"&&m.kind!=="object"&&m.kind!=="array"||g.kind!=="value")if(m.kind!=="projectionDefinition"||g.kind!=="string"&&g.kind!=="array")if(m.kind!=="color"&&m.kind!=="formatted"&&m.kind!=="resolvedImage"||g.kind!=="value"&&g.kind!=="string")if(m.kind!=="padding"||g.kind!=="value"&&g.kind!=="number"&&g.kind!=="array")if(m.kind!=="variableAnchorOffsetCollection"||g.kind!=="value"&&g.kind!=="array"){if(this.checkSubtype(m,g))return null}else p=s(p,m,r.typeAnnotation||"coerce");else p=s(p,m,r.typeAnnotation||"coerce");else p=s(p,m,r.typeAnnotation||"coerce");else p=s(p,m,r.typeAnnotation||"coerce");else p=s(p,m,r.typeAnnotation||"assert")}if(!(p instanceof Xi)&&p.type.kind!=="resolvedImage"&&this._isConstant(p)){const m=new dt;try{p=new Xi(p.type,p.evaluate(m))}catch(g){return this.error(g.message),null}}return p}return this.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(t===void 0?"'undefined' value invalid. Use null instead.":typeof t=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,r,s){const l=typeof t=="number"?this.path.concat(t):this.path,d=s?this.scope.concat(s):this.scope;return new Pn(this.registry,this._isConstant,l,r||null,d,this.errors)}error(t,...r){const s=`${this.key}${r.map(l=>`[${l}]`).join("")}`;this.errors.push(new Me(s,t))}checkSubtype(t,r){const s=wn(t,r);return s&&this.error(s),s}}class Ye{constructor(t,r){this.type=r.type,this.bindings=[].concat(t),this.result=r}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const r of this.bindings)t(r[1]);t(this.result)}static parse(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const s=[];for(let d=1;d<t.length-1;d+=2){const p=t[d];if(typeof p!="string")return r.error(`Expected string, but found ${typeof p} instead.`,d);if(/[^a-zA-Z0-9_]/.test(p))return r.error("Variable names must contain only alphanumeric characters or '_'.",d);const m=r.parse(t[d+1],d+1);if(!m)return null;s.push([p,m])}const l=r.parse(t[t.length-1],t.length-1,r.expectedType,s);return l?new Ye(s,l):null}outputDefined(){return this.result.outputDefined()}}class Ge{constructor(t,r){this.type=r.type,this.name=t,this.boundExpression=r}static parse(t,r){if(t.length!==2||typeof t[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");const s=t[1];return r.scope.has(s)?new Ge(s,r.scope.get(s)):r.error(`Unknown variable "${s}". Make sure "${s}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}}class rs{constructor(t,r,s){this.type=t,this.index=r,this.input=s}static parse(t,r){if(t.length!==3)return r.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const s=r.parse(t[1],1,ge),l=r.parse(t[2],2,_i(r.expectedType||ze));return s&&l?new rs(l.type.itemType,s,l):null}evaluate(t){const r=this.index.evaluate(t),s=this.input.evaluate(t);if(r<0)throw new wt(`Array index out of bounds: ${r} < 0.`);if(r>=s.length)throw new wt(`Array index out of bounds: ${r} > ${s.length-1}.`);if(r!==Math.floor(r))throw new wt(`Array index must be an integer, but found ${r} instead.`);return s[r]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class Qe{constructor(t,r){this.type=De,this.needle=t,this.haystack=r}static parse(t,r){if(t.length!==3)return r.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const s=r.parse(t[1],1,ze),l=r.parse(t[2],2,ze);return s&&l?La(s.type,[De,Ce,ge,Ue,ze])?new Qe(s,l):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${_t(s.type)} instead`):null}evaluate(t){const r=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!s)return!1;if(!Yr(r,["boolean","string","number","null"]))throw new wt(`Expected first argument to be of type boolean, string, number or null, but found ${_t(ut(r))} instead.`);if(!Yr(s,["string","array"]))throw new wt(`Expected second argument to be of type array or string, but found ${_t(ut(s))} instead.`);return s.indexOf(r)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class Mn{constructor(t,r,s){this.type=ge,this.needle=t,this.haystack=r,this.fromIndex=s}static parse(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const s=r.parse(t[1],1,ze),l=r.parse(t[2],2,ze);if(!s||!l)return null;if(!La(s.type,[De,Ce,ge,Ue,ze]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${_t(s.type)} instead`);if(t.length===4){const d=r.parse(t[3],3,ge);return d?new Mn(s,l,d):null}return new Mn(s,l)}evaluate(t){const r=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!Yr(r,["boolean","string","number","null"]))throw new wt(`Expected first argument to be of type boolean, string, number or null, but found ${_t(ut(r))} instead.`);let l;if(this.fromIndex&&(l=this.fromIndex.evaluate(t)),Yr(s,["string"])){const d=s.indexOf(r,l);return d===-1?-1:[...s.slice(0,d)].length}if(Yr(s,["array"]))return s.indexOf(r,l);throw new wt(`Expected second argument to be of type array or string, but found ${_t(ut(s))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class Fi{constructor(t,r,s,l,d,p){this.inputType=t,this.type=r,this.input=s,this.cases=l,this.outputs=d,this.otherwise=p}static parse(t,r){if(t.length<5)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return r.error("Expected an even number of arguments.");let s,l;r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);const d={},p=[];for(let x=2;x<t.length-1;x+=2){let b=t[x];const w=t[x+1];Array.isArray(b)||(b=[b]);const M=r.concat(x);if(b.length===0)return M.error("Expected at least one branch label.");for(const E of b){if(typeof E!="number"&&typeof E!="string")return M.error("Branch labels must be numbers or strings.");if(typeof E=="number"&&Math.abs(E)>Number.MAX_SAFE_INTEGER)return M.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof E=="number"&&Math.floor(E)!==E)return M.error("Numeric branch labels must be integer values.");if(s){if(M.checkSubtype(s,ut(E)))return null}else s=ut(E);if(d[String(E)]!==void 0)return M.error("Branch labels must be unique.");d[String(E)]=p.length}const C=r.parse(w,x,l);if(!C)return null;l=l||C.type,p.push(C)}const m=r.parse(t[1],1,ze);if(!m)return null;const g=r.parse(t[t.length-1],t.length-1,l);return g?m.type.kind!=="value"&&r.concat(1).checkSubtype(s,m.type)?null:new Fi(s,l,m,d,p,g):null}evaluate(t){const r=this.input.evaluate(t);return(ut(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every(t=>t.outputDefined())&&this.otherwise.outputDefined()}}class ns{constructor(t,r,s){this.type=t,this.branches=r,this.otherwise=s}static parse(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return r.error("Expected an odd number of arguments.");let s;r.expectedType&&r.expectedType.kind!=="value"&&(s=r.expectedType);const l=[];for(let p=1;p<t.length-1;p+=2){const m=r.parse(t[p],p,De);if(!m)return null;const g=r.parse(t[p+1],p+1,s);if(!g)return null;l.push([m,g]),s=s||g.type}const d=r.parse(t[t.length-1],t.length-1,s);if(!d)return null;if(!s)throw new Error("Can't infer output type");return new ns(s,l,d)}evaluate(t){for(const[r,s]of this.branches)if(r.evaluate(t))return s.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[r,s]of this.branches)t(r),t(s);t(this.otherwise)}outputDefined(){return this.branches.every(([t,r])=>r.outputDefined())&&this.otherwise.outputDefined()}}class ss{constructor(t,r,s,l){this.type=t,this.input=r,this.beginIndex=s,this.endIndex=l}static parse(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const s=r.parse(t[1],1,ze),l=r.parse(t[2],2,ge);if(!s||!l)return null;if(!La(s.type,[_i(ze),Ce,ze]))return r.error(`Expected first argument to be of type array or string, but found ${_t(s.type)} instead`);if(t.length===4){const d=r.parse(t[3],3,ge);return d?new ss(s.type,s,l,d):null}return new ss(s.type,s,l)}evaluate(t){const r=this.input.evaluate(t),s=this.beginIndex.evaluate(t);let l;if(this.endIndex&&(l=this.endIndex.evaluate(t)),Yr(r,["string"]))return[...r].slice(s,l).join("");if(Yr(r,["array"]))return r.slice(s,l);throw new wt(`Expected first argument to be of type array or string, but found ${_t(ut(r))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function as(n,t){const r=n.length-1;let s,l,d=0,p=r,m=0;for(;d<=p;)if(m=Math.floor((d+p)/2),s=n[m],l=n[m+1],s<=t){if(m===r||t<l)return m;d=m+1}else{if(!(s>t))throw new wt("Input is not a number.");p=m-1}return 0}class nn{constructor(t,r,s){this.type=t,this.input=r,this.labels=[],this.outputs=[];for(const[l,d]of s)this.labels.push(l),this.outputs.push(d)}static parse(t,r){if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");const s=r.parse(t[1],1,ge);if(!s)return null;const l=[];let d=null;r.expectedType&&r.expectedType.kind!=="value"&&(d=r.expectedType);for(let p=1;p<t.length;p+=2){const m=p===1?-1/0:t[p],g=t[p+1],x=p,b=p+1;if(typeof m!="number")return r.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',x);if(l.length&&l[l.length-1][0]>=m)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',x);const w=r.parse(g,b,d);if(!w)return null;d=d||w.type,l.push([m,w])}return new nn(d,s,l)}evaluate(t){const r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(t);const l=this.input.evaluate(t);if(l<=r[0])return s[0].evaluate(t);const d=r.length;return l>=r[d-1]?s[d-1].evaluate(t):s[as(r,l)].evaluate(t)}eachChild(t){t(this.input);for(const r of this.outputs)t(r)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function hl(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ga,$a,ul=function(){if($a)return Ga;function n(t,r,s,l){this.cx=3*t,this.bx=3*(s-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*r,this.by=3*(l-r)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=r,this.p2x=s,this.p2y=l}return $a=1,Ga=n,n.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,r){if(r===void 0&&(r=1e-6),t<0)return 0;if(t>1)return 1;for(var s=t,l=0;l<8;l++){var d=this.sampleCurveX(s)-t;if(Math.abs(d)<r)return s;var p=this.sampleCurveDerivativeX(s);if(Math.abs(p)<1e-6)break;s-=d/p}var m=0,g=1;for(s=t,l=0;l<20&&(d=this.sampleCurveX(s),!(Math.abs(d-t)<r));l++)t>d?m=s:g=s,s=.5*(g-m)+m;return s},solve:function(t,r){return this.sampleCurveY(this.solveCurveX(t,r))}},Ga}(),os=hl(ul);class ct{constructor(t,r,s,l,d){this.type=t,this.operator=r,this.interpolation=s,this.input=l,this.labels=[],this.outputs=[];for(const[p,m]of d)this.labels.push(p),this.outputs.push(m)}static interpolationFactor(t,r,s,l){let d=0;if(t.name==="exponential")d=Sn(r,t.base,s,l);else if(t.name==="linear")d=Sn(r,1,s,l);else if(t.name==="cubic-bezier"){const p=t.controlPoints;d=new os(p[0],p[1],p[2],p[3]).solve(Sn(r,1,s,l))}return d}static parse(t,r){let[s,l,d,...p]=t;if(!Array.isArray(l)||l.length===0)return r.error("Expected an interpolation type expression.",1);if(l[0]==="linear")l={name:"linear"};else if(l[0]==="exponential"){const x=l[1];if(typeof x!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);l={name:"exponential",base:x}}else{if(l[0]!=="cubic-bezier")return r.error(`Unknown interpolation type ${String(l[0])}`,1,0);{const x=l.slice(1);if(x.length!==4||x.some(b=>typeof b!="number"||b<0||b>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);l={name:"cubic-bezier",controlPoints:x}}}if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(d=r.parse(d,2,ge),!d)return null;const m=[];let g=null;s==="interpolate-hcl"||s==="interpolate-lab"?g=qe:r.expectedType&&r.expectedType.kind!=="value"&&(g=r.expectedType);for(let x=0;x<p.length;x+=2){const b=p[x],w=p[x+1],M=x+3,C=x+4;if(typeof b!="number")return r.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',M);if(m.length&&m[m.length-1][0]>=b)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',M);const E=r.parse(w,C,g);if(!E)return null;g=g||E.type,m.push([b,E])}return Jr(g,ge)||Jr(g,Je)||Jr(g,qe)||Jr(g,jt)||Jr(g,mt)||Jr(g,_i(ge))?new ct(g,s,l,d,m):r.error(`Type ${_t(g)} is not interpolatable.`)}evaluate(t){const r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(t);const l=this.input.evaluate(t);if(l<=r[0])return s[0].evaluate(t);const d=r.length;if(l>=r[d-1])return s[d-1].evaluate(t);const p=as(r,l),m=ct.interpolationFactor(this.interpolation,l,r[p],r[p+1]),g=s[p].evaluate(t),x=s[p+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return He(g,x,m);case"color":return Xe.interpolate(g,x,m);case"padding":return Nt.interpolate(g,x,m);case"variableAnchorOffsetCollection":return ii.interpolate(g,x,m);case"array":return Hi(g,x,m);case"projectionDefinition":return ni.interpolate(g,x,m)}case"interpolate-hcl":return Xe.interpolate(g,x,m,"hcl");case"interpolate-lab":return Xe.interpolate(g,x,m,"lab")}}eachChild(t){t(this.input);for(const r of this.outputs)t(r)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function Sn(n,t,r,s){const l=s-r,d=n-r;return l===0?0:t===1?d/l:(Math.pow(t,d)-1)/(Math.pow(t,l)-1)}const Oi={color:Xe.interpolate,number:He,padding:Nt.interpolate,variableAnchorOffsetCollection:ii.interpolate,array:Hi};class sn{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let s=null;const l=r.expectedType;l&&l.kind!=="value"&&(s=l);const d=[];for(const m of t.slice(1)){const g=r.parse(m,1+d.length,s,void 0,{typeAnnotation:"omit"});if(!g)return null;s=s||g.type,d.push(g)}if(!s)throw new Error("No output type");const p=l&&d.some(m=>wn(l,m.type));return new sn(p?ze:s,d)}evaluate(t){let r,s=null,l=0;for(const d of this.args)if(l++,s=d.evaluate(t),s&&s instanceof ri&&!s.available&&(r||(r=s.name),s=null,l===this.args.length&&(s=r)),s!==null)break;return s}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}function Vt(n,t){return n==="=="||n==="!="?t.kind==="boolean"||t.kind==="string"||t.kind==="number"||t.kind==="null"||t.kind==="value":t.kind==="string"||t.kind==="number"||t.kind==="value"}function qa(n,t,r,s){return s.compare(t,r)===0}function Sr(n,t,r){const s=n!=="=="&&n!=="!=";return class md{constructor(d,p,m){this.type=De,this.lhs=d,this.rhs=p,this.collator=m,this.hasUntypedArgument=d.type.kind==="value"||p.type.kind==="value"}static parse(d,p){if(d.length!==3&&d.length!==4)return p.error("Expected two or three arguments.");const m=d[0];let g=p.parse(d[1],1,ze);if(!g)return null;if(!Vt(m,g.type))return p.concat(1).error(`"${m}" comparisons are not supported for type '${_t(g.type)}'.`);let x=p.parse(d[2],2,ze);if(!x)return null;if(!Vt(m,x.type))return p.concat(2).error(`"${m}" comparisons are not supported for type '${_t(x.type)}'.`);if(g.type.kind!==x.type.kind&&g.type.kind!=="value"&&x.type.kind!=="value")return p.error(`Cannot compare types '${_t(g.type)}' and '${_t(x.type)}'.`);s&&(g.type.kind==="value"&&x.type.kind!=="value"?g=new Ci(x.type,[g]):g.type.kind!=="value"&&x.type.kind==="value"&&(x=new Ci(g.type,[x])));let b=null;if(d.length===4){if(g.type.kind!=="string"&&x.type.kind!=="string"&&g.type.kind!=="value"&&x.type.kind!=="value")return p.error("Cannot use collator to compare non-string types.");if(b=p.parse(d[3],3,St),!b)return null}return new md(g,x,b)}evaluate(d){const p=this.lhs.evaluate(d),m=this.rhs.evaluate(d);if(s&&this.hasUntypedArgument){const g=ut(p),x=ut(m);if(g.kind!==x.kind||g.kind!=="string"&&g.kind!=="number")throw new wt(`Expected arguments for "${n}" to be (string, string) or (number, number), but found (${g.kind}, ${x.kind}) instead.`)}if(this.collator&&!s&&this.hasUntypedArgument){const g=ut(p),x=ut(m);if(g.kind!=="string"||x.kind!=="string")return t(d,p,m)}return this.collator?r(d,p,m,this.collator.evaluate(d)):t(d,p,m)}eachChild(d){d(this.lhs),d(this.rhs),this.collator&&d(this.collator)}outputDefined(){return!0}}}const dl=Sr("==",function(n,t,r){return t===r},qa),Ic=Sr("!=",function(n,t,r){return t!==r},function(n,t,r,s){return!qa(0,t,r,s)}),Os=Sr("<",function(n,t,r){return t<r},function(n,t,r,s){return s.compare(t,r)<0}),Ha=Sr(">",function(n,t,r){return t>r},function(n,t,r,s){return s.compare(t,r)>0}),Cc=Sr("<=",function(n,t,r){return t<=r},function(n,t,r,s){return s.compare(t,r)<=0}),js=Sr(">=",function(n,t,r){return t>=r},function(n,t,r,s){return s.compare(t,r)>=0});class an{constructor(t,r,s){this.type=St,this.locale=s,this.caseSensitive=t,this.diacriticSensitive=r}static parse(t,r){if(t.length!==2)return r.error("Expected one argument.");const s=t[1];if(typeof s!="object"||Array.isArray(s))return r.error("Collator options argument must be an object.");const l=r.parse(s["case-sensitive"]!==void 0&&s["case-sensitive"],1,De);if(!l)return null;const d=r.parse(s["diacritic-sensitive"]!==void 0&&s["diacritic-sensitive"],1,De);if(!d)return null;let p=null;return s.locale&&(p=r.parse(s.locale,1,Ce),!p)?null:new an(l,d,p)}evaluate(t){return new Bs(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}}class gi{constructor(t,r,s,l,d){this.type=Ce,this.number=t,this.locale=r,this.currency=s,this.minFractionDigits=l,this.maxFractionDigits=d}static parse(t,r){if(t.length!==3)return r.error("Expected two arguments.");const s=r.parse(t[1],1,ge);if(!s)return null;const l=t[2];if(typeof l!="object"||Array.isArray(l))return r.error("NumberFormat options argument must be an object.");let d=null;if(l.locale&&(d=r.parse(l.locale,1,Ce),!d))return null;let p=null;if(l.currency&&(p=r.parse(l.currency,1,Ce),!p))return null;let m=null;if(l["min-fraction-digits"]&&(m=r.parse(l["min-fraction-digits"],1,ge),!m))return null;let g=null;return l["max-fraction-digits"]&&(g=r.parse(l["max-fraction-digits"],1,ge),!g)?null:new gi(s,d,p,m,g)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}}class ls{constructor(t){this.type=Mr,this.sections=t}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");const s=t[1];if(!Array.isArray(s)&&typeof s=="object")return r.error("First argument must be an image or text section.");const l=[];let d=!1;for(let p=1;p<=t.length-1;++p){const m=t[p];if(d&&typeof m=="object"&&!Array.isArray(m)){d=!1;let g=null;if(m["font-scale"]&&(g=r.parse(m["font-scale"],1,ge),!g))return null;let x=null;if(m["text-font"]&&(x=r.parse(m["text-font"],1,_i(Ce)),!x))return null;let b=null;if(m["text-color"]&&(b=r.parse(m["text-color"],1,qe),!b))return null;let w=null;if(m["vertical-align"]){if(typeof m["vertical-align"]=="string"&&!cl.includes(m["vertical-align"]))return r.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${m["vertical-align"]}' instead.`);if(w=r.parse(m["vertical-align"],1,Ce),!w)return null}const M=l[l.length-1];M.scale=g,M.font=x,M.textColor=b,M.verticalAlign=w}else{const g=r.parse(t[p],1,ze);if(!g)return null;const x=g.type.kind;if(x!=="string"&&x!=="value"&&x!=="null"&&x!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");d=!0,l.push({content:g,scale:null,font:null,textColor:null,verticalAlign:null})}}return new ls(l)}evaluate(t){return new Et(this.sections.map(r=>{const s=r.content.evaluate(t);return ut(s)===Rt?new ts("",s,null,null,null,r.verticalAlign?r.verticalAlign.evaluate(t):null):new ts(is(s),null,r.scale?r.scale.evaluate(t):null,r.font?r.font.evaluate(t).join(","):null,r.textColor?r.textColor.evaluate(t):null,r.verticalAlign?r.verticalAlign.evaluate(t):null)}))}eachChild(t){for(const r of this.sections)t(r.content),r.scale&&t(r.scale),r.font&&t(r.font),r.textColor&&t(r.textColor),r.verticalAlign&&t(r.verticalAlign)}outputDefined(){return!1}}class In{constructor(t){this.type=Rt,this.input=t}static parse(t,r){if(t.length!==2)return r.error("Expected two arguments.");const s=r.parse(t[1],1,Ce);return s?new In(s):r.error("No image name provided.")}evaluate(t){const r=this.input.evaluate(t),s=ri.fromString(r);return s&&t.availableImages&&(s.available=t.availableImages.indexOf(r)>-1),s}eachChild(t){t(this.input)}outputDefined(){return!1}}class Xa{constructor(t){this.type=ge,this.input=t}static parse(t,r){if(t.length!==2)return r.error(`Expected 1 argument, but found ${t.length-1} instead.`);const s=r.parse(t[1],1);return s?s.type.kind!=="array"&&s.type.kind!=="string"&&s.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${_t(s.type)} instead.`):new Xa(s):null}evaluate(t){const r=this.input.evaluate(t);if(typeof r=="string")return[...r].length;if(Array.isArray(r))return r.length;throw new wt(`Expected value to be of type string or array, but found ${_t(ut(r))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const Ei=8192;function Ec(n,t){const r=(180+n[0])/360,s=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+n[1]*Math.PI/360)))/360,l=Math.pow(2,t.z);return[Math.round(r*l*Ei),Math.round(s*l*Ei)]}function Wa(n,t){const r=Math.pow(2,t.z);return[(l=(n[0]/Ei+t.x)/r,360*l-180),(s=(n[1]/Ei+t.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90)];var s,l}function cs(n,t){n[0]=Math.min(n[0],t[0]),n[1]=Math.min(n[1],t[1]),n[2]=Math.max(n[2],t[0]),n[3]=Math.max(n[3],t[1])}function hs(n,t){return!(n[0]<=t[0]||n[2]>=t[2]||n[1]<=t[1]||n[3]>=t[3])}function Ns(n,t,r){const s=n[0]-t[0],l=n[1]-t[1],d=n[0]-r[0],p=n[1]-r[1];return s*p-d*l==0&&s*d<=0&&l*p<=0}function Vs(n,t,r,s){return(l=[s[0]-r[0],s[1]-r[1]])[0]*(d=[t[0]-n[0],t[1]-n[1]])[1]-l[1]*d[0]!=0&&!(!fl(n,t,r,s)||!fl(r,s,n,t));var l,d}function pl(n,t,r){for(const s of r)for(let l=0;l<s.length-1;++l)if(Vs(n,t,s[l],s[l+1]))return!0;return!1}function on(n,t,r=!1){let s=!1;for(const m of t)for(let g=0;g<m.length-1;g++){if(Ns(n,m[g],m[g+1]))return r;(d=m[g])[1]>(l=n)[1]!=(p=m[g+1])[1]>l[1]&&l[0]<(p[0]-d[0])*(l[1]-d[1])/(p[1]-d[1])+d[0]&&(s=!s)}var l,d,p;return s}function Ac(n,t){for(const r of t)if(on(n,r))return!0;return!1}function Ka(n,t){for(const r of n)if(!on(r,t))return!1;for(let r=0;r<n.length-1;++r)if(pl(n[r],n[r+1],t))return!1;return!0}function zc(n,t){for(const r of t)if(Ka(n,r))return!0;return!1}function fl(n,t,r,s){const l=s[0]-r[0],d=s[1]-r[1],p=(n[0]-r[0])*d-l*(n[1]-r[1]),m=(t[0]-r[0])*d-l*(t[1]-r[1]);return p>0&&m<0||p<0&&m>0}function Ya(n,t,r){const s=[];for(let l=0;l<n.length;l++){const d=[];for(let p=0;p<n[l].length;p++){const m=Ec(n[l][p],r);cs(t,m),d.push(m)}s.push(d)}return s}function ml(n,t,r){const s=[];for(let l=0;l<n.length;l++){const d=Ya(n[l],t,r);s.push(d)}return s}function _l(n,t,r,s){if(n[0]<r[0]||n[0]>r[2]){const l=.5*s;let d=n[0]-r[0]>l?-s:r[0]-n[0]>l?s:0;d===0&&(d=n[0]-r[2]>l?-s:r[2]-n[0]>l?s:0),n[0]+=d}cs(t,n)}function Ja(n,t,r,s){const l=Math.pow(2,s.z)*Ei,d=[s.x*Ei,s.y*Ei],p=[];for(const m of n)for(const g of m){const x=[g.x+d[0],g.y+d[1]];_l(x,t,r,l),p.push(x)}return p}function Qa(n,t,r,s){const l=Math.pow(2,s.z)*Ei,d=[s.x*Ei,s.y*Ei],p=[];for(const g of n){const x=[];for(const b of g){const w=[b.x+d[0],b.y+d[1]];cs(t,w),x.push(w)}p.push(x)}if(t[2]-t[0]<=l/2){(m=t)[0]=m[1]=1/0,m[2]=m[3]=-1/0;for(const g of p)for(const x of g)_l(x,t,r,l)}var m;return p}class Ir{constructor(t,r){this.type=De,this.geojson=t,this.geometries=r}static parse(t,r){if(t.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(rn(t[1])){const s=t[1];if(s.type==="FeatureCollection"){const l=[];for(const d of s.features){const{type:p,coordinates:m}=d.geometry;p==="Polygon"&&l.push(m),p==="MultiPolygon"&&l.push(...m)}if(l.length)return new Ir(s,{type:"MultiPolygon",coordinates:l})}else if(s.type==="Feature"){const l=s.geometry.type;if(l==="Polygon"||l==="MultiPolygon")return new Ir(s,s.geometry)}else if(s.type==="Polygon"||s.type==="MultiPolygon")return new Ir(s,s)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return function(r,s){const l=[1/0,1/0,-1/0,-1/0],d=[1/0,1/0,-1/0,-1/0],p=r.canonicalID();if(s.type==="Polygon"){const m=Ya(s.coordinates,d,p),g=Ja(r.geometry(),l,d,p);if(!hs(l,d))return!1;for(const x of g)if(!on(x,m))return!1}if(s.type==="MultiPolygon"){const m=ml(s.coordinates,d,p),g=Ja(r.geometry(),l,d,p);if(!hs(l,d))return!1;for(const x of g)if(!Ac(x,m))return!1}return!0}(t,this.geometries);if(t.geometryType()==="LineString")return function(r,s){const l=[1/0,1/0,-1/0,-1/0],d=[1/0,1/0,-1/0,-1/0],p=r.canonicalID();if(s.type==="Polygon"){const m=Ya(s.coordinates,d,p),g=Qa(r.geometry(),l,d,p);if(!hs(l,d))return!1;for(const x of g)if(!Ka(x,m))return!1}if(s.type==="MultiPolygon"){const m=ml(s.coordinates,d,p),g=Qa(r.geometry(),l,d,p);if(!hs(l,d))return!1;for(const x of g)if(!zc(x,m))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let gl=class{constructor(n=[],t=(r,s)=>r<s?-1:r>s?1:0){if(this.data=n,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(n){this.data.push(n),this._up(this.length++)}pop(){if(this.length===0)return;const n=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),n}peek(){return this.data[0]}_up(n){const{data:t,compare:r}=this,s=t[n];for(;n>0;){const l=n-1>>1,d=t[l];if(r(s,d)>=0)break;t[n]=d,n=l}t[n]=s}_down(n){const{data:t,compare:r}=this,s=this.length>>1,l=t[n];for(;n<s;){let d=1+(n<<1);const p=d+1;if(p<this.length&&r(t[p],t[d])<0&&(d=p),r(t[d],l)>=0)break;t[n]=t[d],n=d}t[n]=l}};function yl(n,t,r=0,s=n.length-1,l=eo){for(;s>r;){if(s-r>600){const g=s-r+1,x=t-r+1,b=Math.log(g),w=.5*Math.exp(2*b/3),M=.5*Math.sqrt(b*w*(g-w)/g)*(x-g/2<0?-1:1);yl(n,t,Math.max(r,Math.floor(t-x*w/g+M)),Math.min(s,Math.floor(t+(g-x)*w/g+M)),l)}const d=n[t];let p=r,m=s;for(us(n,r,t),l(n[s],d)>0&&us(n,r,s);p<m;){for(us(n,p,m),p++,m--;l(n[p],d)<0;)p++;for(;l(n[m],d)>0;)m--}l(n[r],d)===0?us(n,r,m):(m++,us(n,m,s)),m<=t&&(r=m+1),t<=m&&(s=m-1)}}function us(n,t,r){const s=n[t];n[t]=n[r],n[r]=s}function eo(n,t){return n<t?-1:n>t?1:0}function Us(n,t){if(n.length<=1)return[n];const r=[];let s,l;for(const d of n){const p=Dc(d);p!==0&&(d.area=Math.abs(p),l===void 0&&(l=p<0),l===p<0?(s&&r.push(s),s=[d]):s.push(d))}if(s&&r.push(s),t>1)for(let d=0;d<r.length;d++)r[d].length<=t||(yl(r[d],t,1,r[d].length-1,kc),r[d]=r[d].slice(0,t));return r}function kc(n,t){return t.area-n.area}function Dc(n){let t=0;for(let r,s,l=0,d=n.length,p=d-1;l<d;p=l++)r=n[l],s=n[p],t+=(s.x-r.x)*(r.y+s.y);return t}const to=1/298.257223563,io=to*(2-to),xl=Math.PI/180;class ro{constructor(t){const r=6378.137*xl*1e3,s=Math.cos(t*xl),l=1/(1-io*(1-s*s)),d=Math.sqrt(l);this.kx=r*d*s,this.ky=r*d*l*(1-io)}distance(t,r){const s=this.wrap(t[0]-r[0])*this.kx,l=(t[1]-r[1])*this.ky;return Math.sqrt(s*s+l*l)}pointOnLine(t,r){let s,l,d,p,m=1/0;for(let g=0;g<t.length-1;g++){let x=t[g][0],b=t[g][1],w=this.wrap(t[g+1][0]-x)*this.kx,M=(t[g+1][1]-b)*this.ky,C=0;w===0&&M===0||(C=(this.wrap(r[0]-x)*this.kx*w+(r[1]-b)*this.ky*M)/(w*w+M*M),C>1?(x=t[g+1][0],b=t[g+1][1]):C>0&&(x+=w/this.kx*C,b+=M/this.ky*C)),w=this.wrap(r[0]-x)*this.kx,M=(r[1]-b)*this.ky;const E=w*w+M*M;E<m&&(m=E,s=x,l=b,d=g,p=C)}return{point:[s,l],index:d,t:Math.max(0,Math.min(1,p))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}function no(n,t){return t[0]-n[0]}function ds(n){return n[1]-n[0]+1}function nr(n,t){return n[1]>=n[0]&&n[1]<t}function so(n,t){if(n[0]>n[1])return[null,null];const r=ds(n);if(t){if(r===2)return[n,null];const l=Math.floor(r/2);return[[n[0],n[0]+l],[n[0]+l,n[1]]]}if(r===1)return[n,null];const s=Math.floor(r/2)-1;return[[n[0],n[0]+s],[n[0]+s+1,n[1]]]}function ao(n,t){if(!nr(t,n.length))return[1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let s=t[0];s<=t[1];++s)cs(r,n[s]);return r}function Zs(n){const t=[1/0,1/0,-1/0,-1/0];for(const r of n)for(const s of r)cs(t,s);return t}function vl(n){return n[0]!==-1/0&&n[1]!==-1/0&&n[2]!==1/0&&n[3]!==1/0}function oo(n,t,r){if(!vl(n)||!vl(t))return NaN;let s=0,l=0;return n[2]<t[0]&&(s=t[0]-n[2]),n[0]>t[2]&&(s=n[0]-t[2]),n[1]>t[3]&&(l=n[1]-t[3]),n[3]<t[1]&&(l=t[1]-n[3]),r.distance([0,0],[s,l])}function ln(n,t,r){const s=r.pointOnLine(t,n);return r.distance(n,s.point)}function lo(n,t,r,s,l){const d=Math.min(ln(n,[r,s],l),ln(t,[r,s],l)),p=Math.min(ln(r,[n,t],l),ln(s,[n,t],l));return Math.min(d,p)}function it(n,t,r,s,l){if(!nr(t,n.length)||!nr(s,r.length))return 1/0;let d=1/0;for(let p=t[0];p<t[1];++p){const m=n[p],g=n[p+1];for(let x=s[0];x<s[1];++x){const b=r[x],w=r[x+1];if(Vs(m,g,b,w))return 0;d=Math.min(d,lo(m,g,b,w,l))}}return d}function Rc(n,t,r,s,l){if(!nr(t,n.length)||!nr(s,r.length))return NaN;let d=1/0;for(let p=t[0];p<=t[1];++p)for(let m=s[0];m<=s[1];++m)if(d=Math.min(d,l.distance(n[p],r[m])),d===0)return d;return d}function Lc(n,t,r){if(on(n,t,!0))return 0;let s=1/0;for(const l of t){const d=l[0],p=l[l.length-1];if(d!==p&&(s=Math.min(s,ln(n,[p,d],r)),s===0))return s;const m=r.pointOnLine(l,n);if(s=Math.min(s,r.distance(n,m.point)),s===0)return s}return s}function Bc(n,t,r,s){if(!nr(t,n.length))return NaN;for(let d=t[0];d<=t[1];++d)if(on(n[d],r,!0))return 0;let l=1/0;for(let d=t[0];d<t[1];++d){const p=n[d],m=n[d+1];for(const g of r)for(let x=0,b=g.length,w=b-1;x<b;w=x++){const M=g[w],C=g[x];if(Vs(p,m,M,C))return 0;l=Math.min(l,lo(p,m,M,C,s))}}return l}function bl(n,t){for(const r of n)for(const s of r)if(on(s,t,!0))return!0;return!1}function Fc(n,t,r,s=1/0){const l=Zs(n),d=Zs(t);if(s!==1/0&&oo(l,d,r)>=s)return s;if(hs(l,d)){if(bl(n,t))return 0}else if(bl(t,n))return 0;let p=1/0;for(const m of n)for(let g=0,x=m.length,b=x-1;g<x;b=g++){const w=m[b],M=m[g];for(const C of t)for(let E=0,k=C.length,O=k-1;E<k;O=E++){const Z=C[O],ee=C[E];if(Vs(w,M,Z,ee))return 0;p=Math.min(p,lo(w,M,Z,ee,r))}}return p}function wl(n,t,r,s,l,d){if(!d)return;const p=oo(ao(s,d),l,r);p<t&&n.push([p,d,[0,0]])}function Gs(n,t,r,s,l,d,p){if(!d||!p)return;const m=oo(ao(s,d),ao(l,p),r);m<t&&n.push([m,d,p])}function $s(n,t,r,s,l=1/0){let d=Math.min(s.distance(n[0],r[0][0]),l);if(d===0)return d;const p=new gl([[0,[0,n.length-1],[0,0]]],no),m=Zs(r);for(;p.length>0;){const g=p.pop();if(g[0]>=d)continue;const x=g[1],b=t?50:100;if(ds(x)<=b){if(!nr(x,n.length))return NaN;if(t){const w=Bc(n,x,r,s);if(isNaN(w)||w===0)return w;d=Math.min(d,w)}else for(let w=x[0];w<=x[1];++w){const M=Lc(n[w],r,s);if(d=Math.min(d,M),d===0)return 0}}else{const w=so(x,t);wl(p,d,s,n,m,w[0]),wl(p,d,s,n,m,w[1])}}return d}function qs(n,t,r,s,l,d=1/0){let p=Math.min(d,l.distance(n[0],r[0]));if(p===0)return p;const m=new gl([[0,[0,n.length-1],[0,r.length-1]]],no);for(;m.length>0;){const g=m.pop();if(g[0]>=p)continue;const x=g[1],b=g[2],w=t?50:100,M=s?50:100;if(ds(x)<=w&&ds(b)<=M){if(!nr(x,n.length)&&nr(b,r.length))return NaN;let C;if(t&&s)C=it(n,x,r,b,l),p=Math.min(p,C);else if(t&&!s){const E=n.slice(x[0],x[1]+1);for(let k=b[0];k<=b[1];++k)if(C=ln(r[k],E,l),p=Math.min(p,C),p===0)return p}else if(!t&&s){const E=r.slice(b[0],b[1]+1);for(let k=x[0];k<=x[1];++k)if(C=ln(n[k],E,l),p=Math.min(p,C),p===0)return p}else C=Rc(n,x,r,b,l),p=Math.min(p,C)}else{const C=so(x,t),E=so(b,s);Gs(m,p,l,n,r,C[0],E[0]),Gs(m,p,l,n,r,C[0],E[1]),Gs(m,p,l,n,r,C[1],E[0]),Gs(m,p,l,n,r,C[1],E[1])}}return p}function co(n){return n.type==="MultiPolygon"?n.coordinates.map(t=>({type:"Polygon",coordinates:t})):n.type==="MultiLineString"?n.coordinates.map(t=>({type:"LineString",coordinates:t})):n.type==="MultiPoint"?n.coordinates.map(t=>({type:"Point",coordinates:t})):[n]}class cn{constructor(t,r){this.type=ge,this.geojson=t,this.geometries=r}static parse(t,r){if(t.length!==2)return r.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(rn(t[1])){const s=t[1];if(s.type==="FeatureCollection")return new cn(s,s.features.map(l=>co(l.geometry)).flat());if(s.type==="Feature")return new cn(s,co(s.geometry));if("type"in s&&"coordinates"in s)return new cn(s,co(s))}return r.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return function(r,s){const l=r.geometry(),d=l.flat().map(g=>Wa([g.x,g.y],r.canonical));if(l.length===0)return NaN;const p=new ro(d[0][1]);let m=1/0;for(const g of s){switch(g.type){case"Point":m=Math.min(m,qs(d,!1,[g.coordinates],!1,p,m));break;case"LineString":m=Math.min(m,qs(d,!1,g.coordinates,!0,p,m));break;case"Polygon":m=Math.min(m,$s(d,!1,g.coordinates,p,m))}if(m===0)return m}return m}(t,this.geometries);if(t.geometryType()==="LineString")return function(r,s){const l=r.geometry(),d=l.flat().map(g=>Wa([g.x,g.y],r.canonical));if(l.length===0)return NaN;const p=new ro(d[0][1]);let m=1/0;for(const g of s){switch(g.type){case"Point":m=Math.min(m,qs(d,!0,[g.coordinates],!1,p,m));break;case"LineString":m=Math.min(m,qs(d,!0,g.coordinates,!0,p,m));break;case"Polygon":m=Math.min(m,$s(d,!0,g.coordinates,p,m))}if(m===0)return m}return m}(t,this.geometries);if(t.geometryType()==="Polygon")return function(r,s){const l=r.geometry();if(l.length===0||l[0].length===0)return NaN;const d=Us(l,0).map(g=>g.map(x=>x.map(b=>Wa([b.x,b.y],r.canonical)))),p=new ro(d[0][0][0][1]);let m=1/0;for(const g of s)for(const x of d){switch(g.type){case"Point":m=Math.min(m,$s([g.coordinates],!1,x,p,m));break;case"LineString":m=Math.min(m,$s(g.coordinates,!0,x,p,m));break;case"Polygon":m=Math.min(m,Fc(x,g.coordinates,p,m))}if(m===0)return m}return m}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}const Cn={"==":dl,"!=":Ic,">":Ha,"<":Os,">=":js,"<=":Cc,array:Ci,at:rs,boolean:Ci,case:ns,coalesce:sn,collator:an,format:ls,image:In,in:Qe,"index-of":Mn,interpolate:ct,"interpolate-hcl":ct,"interpolate-lab":ct,length:Xa,let:Ye,literal:Xi,match:Fi,number:Ci,"number-format":gi,object:Ci,slice:ss,step:nn,string:Ci,"to-boolean":rr,"to-color":rr,"to-number":rr,"to-string":rr,var:Ge,within:Ir,distance:cn};class Ai{constructor(t,r,s,l){this.name=t,this.type=r,this._evaluate=s,this.args=l}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,r){const s=t[0],l=Ai.definitions[s];if(!l)return r.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0);const d=Array.isArray(l)?l[0]:l.type,p=Array.isArray(l)?[[l[1],l[2]]]:l.overloads,m=p.filter(([x])=>!Array.isArray(x)||x.length===t.length-1);let g=null;for(const[x,b]of m){g=new Pn(r.registry,Hs,r.path,null,r.scope);const w=[];let M=!1;for(let C=1;C<t.length;C++){const E=t[C],k=Array.isArray(x)?x[C-1]:x.type,O=g.parse(E,1+w.length,k);if(!O){M=!0;break}w.push(O)}if(!M)if(Array.isArray(x)&&x.length!==w.length)g.error(`Expected ${x.length} arguments, but found ${w.length} instead.`);else{for(let C=0;C<w.length;C++){const E=Array.isArray(x)?x[C]:x.type,k=w[C];g.concat(C+1).checkSubtype(E,k.type)}if(g.errors.length===0)return new Ai(s,d,b,w)}}if(m.length===1)r.errors.push(...g.errors);else{const x=(m.length?m:p).map(([w])=>{return M=w,Array.isArray(M)?`(${M.map(_t).join(", ")})`:`(${_t(M.type)}...)`;var M}).join(" | "),b=[];for(let w=1;w<t.length;w++){const M=r.parse(t[w],1+b.length);if(!M)return null;b.push(_t(M.type))}r.error(`Expected arguments of type ${x}, but found (${b.join(", ")}) instead.`)}return null}static register(t,r){Ai.definitions=r;for(const s in r)t[s]=Ai}}function Tl(n,[t,r,s,l]){t=t.evaluate(n),r=r.evaluate(n),s=s.evaluate(n);const d=l?l.evaluate(n):1,p=Ua(t,r,s,d);if(p)throw new wt(p);return new Xe(t/255,r/255,s/255,d,!1)}function Pl(n,t){return n in t}function ho(n,t){const r=t[n];return r===void 0?null:r}function hn(n){return{type:n}}function Hs(n){if(n instanceof Ge)return Hs(n.boundExpression);if(n instanceof Ai&&n.name==="error"||n instanceof an||n instanceof Ir||n instanceof cn)return!1;const t=n instanceof rr||n instanceof Ci;let r=!0;return n.eachChild(s=>{r=t?r&&Hs(s):r&&s instanceof Xi}),!!r&&Xs(n)&&Ws(n,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Xs(n){if(n instanceof Ai&&(n.name==="get"&&n.args.length===1||n.name==="feature-state"||n.name==="has"&&n.args.length===1||n.name==="properties"||n.name==="geometry-type"||n.name==="id"||/^filter-/.test(n.name))||n instanceof Ir||n instanceof cn)return!1;let t=!0;return n.eachChild(r=>{t&&!Xs(r)&&(t=!1)}),t}function ps(n){if(n instanceof Ai&&n.name==="feature-state")return!1;let t=!0;return n.eachChild(r=>{t&&!ps(r)&&(t=!1)}),t}function Ws(n,t){if(n instanceof Ai&&t.indexOf(n.name)>=0)return!1;let r=!0;return n.eachChild(s=>{r&&!Ws(s,t)&&(r=!1)}),r}function Ml(n){return{result:"success",value:n}}function En(n){return{result:"error",value:n}}function An(n){return n["property-type"]==="data-driven"||n["property-type"]==="cross-faded-data-driven"}function Sl(n){return!!n.expression&&n.expression.parameters.indexOf("zoom")>-1}function uo(n){return!!n.expression&&n.expression.interpolated}function tt(n){return n instanceof Number?"number":n instanceof String?"string":n instanceof Boolean?"boolean":Array.isArray(n)?"array":n===null?"null":typeof n}function Ks(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Oc(n){return n}function Il(n,t){const r=t.type==="color",s=n.stops&&typeof n.stops[0][0]=="object",l=s||!(s||n.property!==void 0),d=n.type||(uo(t)?"exponential":"interval");if(r||t.type==="padding"){const b=r?Xe.parse:Nt.parse;(n=Ie({},n)).stops&&(n.stops=n.stops.map(w=>[w[0],b(w[1])])),n.default=b(n.default?n.default:t.default)}if(n.colorSpace&&(p=n.colorSpace)!=="rgb"&&p!=="hcl"&&p!=="lab")throw new Error(`Unknown color space: "${n.colorSpace}"`);var p;let m,g,x;if(d==="exponential")m=Cl;else if(d==="interval")m=jc;else if(d==="categorical"){m=po,g=Object.create(null);for(const b of n.stops)g[b[0]]=b[1];x=typeof n.stops[0][0]}else{if(d!=="identity")throw new Error(`Unknown function type "${d}"`);m=Nc}if(s){const b={},w=[];for(let E=0;E<n.stops.length;E++){const k=n.stops[E],O=k[0].zoom;b[O]===void 0&&(b[O]={zoom:O,type:n.type,property:n.property,default:n.default,stops:[]},w.push(O)),b[O].stops.push([k[0].value,k[1]])}const M=[];for(const E of w)M.push([b[E].zoom,Il(b[E],t)]);const C={name:"linear"};return{kind:"composite",interpolationType:C,interpolationFactor:ct.interpolationFactor.bind(void 0,C),zoomStops:M.map(E=>E[0]),evaluate:({zoom:E},k)=>Cl({stops:M,base:n.base},t,E).evaluate(E,k)}}if(l){const b=d==="exponential"?{name:"exponential",base:n.base!==void 0?n.base:1}:null;return{kind:"camera",interpolationType:b,interpolationFactor:ct.interpolationFactor.bind(void 0,b),zoomStops:n.stops.map(w=>w[0]),evaluate:({zoom:w})=>m(n,t,w,g,x)}}return{kind:"source",evaluate(b,w){const M=w&&w.properties?w.properties[n.property]:void 0;return M===void 0?fs(n.default,t.default):m(n,t,M,g,x)}}}function fs(n,t,r){return n!==void 0?n:t!==void 0?t:r!==void 0?r:void 0}function po(n,t,r,s,l){return fs(typeof r===l?s[r]:void 0,n.default,t.default)}function jc(n,t,r){if(tt(r)!=="number")return fs(n.default,t.default);const s=n.stops.length;if(s===1||r<=n.stops[0][0])return n.stops[0][1];if(r>=n.stops[s-1][0])return n.stops[s-1][1];const l=as(n.stops.map(d=>d[0]),r);return n.stops[l][1]}function Cl(n,t,r){const s=n.base!==void 0?n.base:1;if(tt(r)!=="number")return fs(n.default,t.default);const l=n.stops.length;if(l===1||r<=n.stops[0][0])return n.stops[0][1];if(r>=n.stops[l-1][0])return n.stops[l-1][1];const d=as(n.stops.map(b=>b[0]),r),p=function(b,w,M,C){const E=C-M,k=b-M;return E===0?0:w===1?k/E:(Math.pow(w,k)-1)/(Math.pow(w,E)-1)}(r,s,n.stops[d][0],n.stops[d+1][0]),m=n.stops[d][1],g=n.stops[d+1][1],x=Oi[t.type]||Oc;return typeof m.evaluate=="function"?{evaluate(...b){const w=m.evaluate.apply(void 0,b),M=g.evaluate.apply(void 0,b);if(w!==void 0&&M!==void 0)return x(w,M,p,n.colorSpace)}}:x(m,g,p,n.colorSpace)}function Nc(n,t,r){switch(t.type){case"color":r=Xe.parse(r);break;case"formatted":r=Et.fromString(r.toString());break;case"resolvedImage":r=ri.fromString(r.toString());break;case"padding":r=Nt.parse(r);break;default:tt(r)===t.type||t.type==="enum"&&t.values[r]||(r=void 0)}return fs(r,n.default,t.default)}Ai.register(Cn,{error:[{kind:"error"},[Ce],(n,[t])=>{throw new wt(t.evaluate(n))}],typeof:[Ce,[ze],(n,[t])=>_t(ut(t.evaluate(n)))],"to-rgba":[_i(ge,4),[qe],(n,[t])=>{const[r,s,l,d]=t.evaluate(n).rgb;return[255*r,255*s,255*l,d]}],rgb:[qe,[ge,ge,ge],Tl],rgba:[qe,[ge,ge,ge,ge],Tl],has:{type:De,overloads:[[[Ce],(n,[t])=>Pl(t.evaluate(n),n.properties())],[[Ce,Ve],(n,[t,r])=>Pl(t.evaluate(n),r.evaluate(n))]]},get:{type:ze,overloads:[[[Ce],(n,[t])=>ho(t.evaluate(n),n.properties())],[[Ce,Ve],(n,[t,r])=>ho(t.evaluate(n),r.evaluate(n))]]},"feature-state":[ze,[Ce],(n,[t])=>ho(t.evaluate(n),n.featureState||{})],properties:[Ve,[],n=>n.properties()],"geometry-type":[Ce,[],n=>n.geometryType()],id:[ze,[],n=>n.id()],zoom:[ge,[],n=>n.globals.zoom],"heatmap-density":[ge,[],n=>n.globals.heatmapDensity||0],"line-progress":[ge,[],n=>n.globals.lineProgress||0],accumulated:[ze,[],n=>n.globals.accumulated===void 0?null:n.globals.accumulated],"+":[ge,hn(ge),(n,t)=>{let r=0;for(const s of t)r+=s.evaluate(n);return r}],"*":[ge,hn(ge),(n,t)=>{let r=1;for(const s of t)r*=s.evaluate(n);return r}],"-":{type:ge,overloads:[[[ge,ge],(n,[t,r])=>t.evaluate(n)-r.evaluate(n)],[[ge],(n,[t])=>-t.evaluate(n)]]},"/":[ge,[ge,ge],(n,[t,r])=>t.evaluate(n)/r.evaluate(n)],"%":[ge,[ge,ge],(n,[t,r])=>t.evaluate(n)%r.evaluate(n)],ln2:[ge,[],()=>Math.LN2],pi:[ge,[],()=>Math.PI],e:[ge,[],()=>Math.E],"^":[ge,[ge,ge],(n,[t,r])=>Math.pow(t.evaluate(n),r.evaluate(n))],sqrt:[ge,[ge],(n,[t])=>Math.sqrt(t.evaluate(n))],log10:[ge,[ge],(n,[t])=>Math.log(t.evaluate(n))/Math.LN10],ln:[ge,[ge],(n,[t])=>Math.log(t.evaluate(n))],log2:[ge,[ge],(n,[t])=>Math.log(t.evaluate(n))/Math.LN2],sin:[ge,[ge],(n,[t])=>Math.sin(t.evaluate(n))],cos:[ge,[ge],(n,[t])=>Math.cos(t.evaluate(n))],tan:[ge,[ge],(n,[t])=>Math.tan(t.evaluate(n))],asin:[ge,[ge],(n,[t])=>Math.asin(t.evaluate(n))],acos:[ge,[ge],(n,[t])=>Math.acos(t.evaluate(n))],atan:[ge,[ge],(n,[t])=>Math.atan(t.evaluate(n))],min:[ge,hn(ge),(n,t)=>Math.min(...t.map(r=>r.evaluate(n)))],max:[ge,hn(ge),(n,t)=>Math.max(...t.map(r=>r.evaluate(n)))],abs:[ge,[ge],(n,[t])=>Math.abs(t.evaluate(n))],round:[ge,[ge],(n,[t])=>{const r=t.evaluate(n);return r<0?-Math.round(-r):Math.round(r)}],floor:[ge,[ge],(n,[t])=>Math.floor(t.evaluate(n))],ceil:[ge,[ge],(n,[t])=>Math.ceil(t.evaluate(n))],"filter-==":[De,[Ce,ze],(n,[t,r])=>n.properties()[t.value]===r.value],"filter-id-==":[De,[ze],(n,[t])=>n.id()===t.value],"filter-type-==":[De,[Ce],(n,[t])=>n.geometryType()===t.value],"filter-<":[De,[Ce,ze],(n,[t,r])=>{const s=n.properties()[t.value],l=r.value;return typeof s==typeof l&&s<l}],"filter-id-<":[De,[ze],(n,[t])=>{const r=n.id(),s=t.value;return typeof r==typeof s&&r<s}],"filter->":[De,[Ce,ze],(n,[t,r])=>{const s=n.properties()[t.value],l=r.value;return typeof s==typeof l&&s>l}],"filter-id->":[De,[ze],(n,[t])=>{const r=n.id(),s=t.value;return typeof r==typeof s&&r>s}],"filter-<=":[De,[Ce,ze],(n,[t,r])=>{const s=n.properties()[t.value],l=r.value;return typeof s==typeof l&&s<=l}],"filter-id-<=":[De,[ze],(n,[t])=>{const r=n.id(),s=t.value;return typeof r==typeof s&&r<=s}],"filter->=":[De,[Ce,ze],(n,[t,r])=>{const s=n.properties()[t.value],l=r.value;return typeof s==typeof l&&s>=l}],"filter-id->=":[De,[ze],(n,[t])=>{const r=n.id(),s=t.value;return typeof r==typeof s&&r>=s}],"filter-has":[De,[ze],(n,[t])=>t.value in n.properties()],"filter-has-id":[De,[],n=>n.id()!==null&&n.id()!==void 0],"filter-type-in":[De,[_i(Ce)],(n,[t])=>t.value.indexOf(n.geometryType())>=0],"filter-id-in":[De,[_i(ze)],(n,[t])=>t.value.indexOf(n.id())>=0],"filter-in-small":[De,[Ce,_i(ze)],(n,[t,r])=>r.value.indexOf(n.properties()[t.value])>=0],"filter-in-large":[De,[Ce,_i(ze)],(n,[t,r])=>function(s,l,d,p){for(;d<=p;){const m=d+p>>1;if(l[m]===s)return!0;l[m]>s?p=m-1:d=m+1}return!1}(n.properties()[t.value],r.value,0,r.value.length-1)],all:{type:De,overloads:[[[De,De],(n,[t,r])=>t.evaluate(n)&&r.evaluate(n)],[hn(De),(n,t)=>{for(const r of t)if(!r.evaluate(n))return!1;return!0}]]},any:{type:De,overloads:[[[De,De],(n,[t,r])=>t.evaluate(n)||r.evaluate(n)],[hn(De),(n,t)=>{for(const r of t)if(r.evaluate(n))return!0;return!1}]]},"!":[De,[De],(n,[t])=>!t.evaluate(n)],"is-supported-script":[De,[Ce],(n,[t])=>{const r=n.globals&&n.globals.isSupportedScript;return!r||r(t.evaluate(n))}],upcase:[Ce,[Ce],(n,[t])=>t.evaluate(n).toUpperCase()],downcase:[Ce,[Ce],(n,[t])=>t.evaluate(n).toLowerCase()],concat:[Ce,hn(ze),(n,t)=>t.map(r=>is(r.evaluate(n))).join("")],"resolved-locale":[Ce,[St],(n,[t])=>t.evaluate(n).resolvedLocale()]});class Ys{constructor(t,r){var s;this.expression=t,this._warningHistory={},this._evaluator=new dt,this._defaultValue=r?(s=r).type==="color"&&Ks(s.default)?new Xe(0,0,0,0):s.type==="color"?Xe.parse(s.default)||null:s.type==="padding"?Nt.parse(s.default)||null:s.type==="variableAnchorOffsetCollection"?ii.parse(s.default)||null:s.type==="projectionDefinition"?ni.parse(s.default)||null:s.default===void 0?null:s.default:null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(t,r,s,l,d,p){return this._evaluator.globals=t,this._evaluator.feature=r,this._evaluator.featureState=s,this._evaluator.canonical=l,this._evaluator.availableImages=d||null,this._evaluator.formattedSection=p,this.expression.evaluate(this._evaluator)}evaluate(t,r,s,l,d,p){this._evaluator.globals=t,this._evaluator.feature=r||null,this._evaluator.featureState=s||null,this._evaluator.canonical=l,this._evaluator.availableImages=d||null,this._evaluator.formattedSection=p||null;try{const m=this.expression.evaluate(this._evaluator);if(m==null||typeof m=="number"&&m!=m)return this._defaultValue;if(this._enumValues&&!(m in this._enumValues))throw new wt(`Expected value to be one of ${Object.keys(this._enumValues).map(g=>JSON.stringify(g)).join(", ")}, but found ${JSON.stringify(m)} instead.`);return m}catch(m){return this._warningHistory[m.message]||(this._warningHistory[m.message]=!0,typeof console<"u"&&console.warn(m.message)),this._defaultValue}}}function Js(n){return Array.isArray(n)&&n.length>0&&typeof n[0]=="string"&&n[0]in Cn}function Qs(n,t){const r=new Pn(Cn,Hs,[],t?function(l){const d={color:qe,string:Ce,number:ge,enum:Ce,boolean:De,formatted:Mr,padding:jt,projectionDefinition:Je,resolvedImage:Rt,variableAnchorOffsetCollection:mt};return l.type==="array"?_i(d[l.value]||ze,l.length):d[l.type]}(t):void 0),s=r.parse(n,void 0,void 0,void 0,t&&t.type==="string"?{typeAnnotation:"coerce"}:void 0);return s?Ml(new Ys(s,t)):En(r.errors)}class zn{constructor(t,r){this.kind=t,this._styleExpression=r,this.isStateDependent=t!=="constant"&&!ps(r.expression)}evaluateWithoutErrorHandling(t,r,s,l,d,p){return this._styleExpression.evaluateWithoutErrorHandling(t,r,s,l,d,p)}evaluate(t,r,s,l,d,p){return this._styleExpression.evaluate(t,r,s,l,d,p)}}class ea{constructor(t,r,s,l){this.kind=t,this.zoomStops=s,this._styleExpression=r,this.isStateDependent=t!=="camera"&&!ps(r.expression),this.interpolationType=l}evaluateWithoutErrorHandling(t,r,s,l,d,p){return this._styleExpression.evaluateWithoutErrorHandling(t,r,s,l,d,p)}evaluate(t,r,s,l,d,p){return this._styleExpression.evaluate(t,r,s,l,d,p)}interpolationFactor(t,r,s){return this.interpolationType?ct.interpolationFactor(this.interpolationType,t,r,s):0}}function El(n,t){const r=Qs(n,t);if(r.result==="error")return r;const s=r.value.expression,l=Xs(s);if(!l&&!An(t))return En([new Me("","data expressions not supported")]);const d=Ws(s,["zoom"]);if(!d&&!Sl(t))return En([new Me("","zoom expressions not supported")]);const p=ia(s);return p||d?p instanceof Me?En([p]):p instanceof ct&&!uo(t)?En([new Me("",'"interpolate" expressions cannot be used with this property')]):Ml(p?new ea(l?"camera":"composite",r.value,p.labels,p instanceof ct?p.interpolation:void 0):new zn(l?"constant":"source",r.value)):En([new Me("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class ta{constructor(t,r){this._parameters=t,this._specification=r,Ie(this,Il(this._parameters,this._specification))}static deserialize(t){return new ta(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function ia(n){let t=null;if(n instanceof Ye)t=ia(n.result);else if(n instanceof sn){for(const r of n.args)if(t=ia(r),t)break}else(n instanceof nn||n instanceof ct)&&n.input instanceof Ai&&n.input.name==="zoom"&&(t=n);return t instanceof Me||n.eachChild(r=>{const s=ia(r);s instanceof Me?t=s:!t&&s?t=new Me("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&s&&t!==s&&(t=new Me("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function fo(n){if(n===!0||n===!1)return!0;if(!Array.isArray(n)||n.length===0)return!1;switch(n[0]){case"has":return n.length>=2&&n[1]!=="$id"&&n[1]!=="$type";case"in":return n.length>=3&&(typeof n[1]!="string"||Array.isArray(n[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return n.length!==3||Array.isArray(n[1])||Array.isArray(n[2]);case"any":case"all":for(const t of n.slice(1))if(!fo(t)&&typeof t!="boolean")return!1;return!0;default:return!0}}const Vc={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function ra(n){if(n==null)return{filter:()=>!0,needGeometry:!1};fo(n)||(n=na(n));const t=Qs(n,Vc);if(t.result==="error")throw new Error(t.value.map(r=>`${r.key}: ${r.message}`).join(", "));return{filter:(r,s,l)=>t.value.evaluate(r,s,{},l),needGeometry:zl(n)}}function Al(n,t){return n<t?-1:n>t?1:0}function zl(n){if(!Array.isArray(n))return!1;if(n[0]==="within"||n[0]==="distance")return!0;for(let t=1;t<n.length;t++)if(zl(n[t]))return!0;return!1}function na(n){if(!n)return!0;const t=n[0];return n.length<=1?t!=="any":t==="=="?sa(n[1],n[2],"=="):t==="!="?ms(sa(n[1],n[2],"==")):t==="<"||t===">"||t==="<="||t===">="?sa(n[1],n[2],t):t==="any"?(r=n.slice(1),["any"].concat(r.map(na))):t==="all"?["all"].concat(n.slice(1).map(na)):t==="none"?["all"].concat(n.slice(1).map(na).map(ms)):t==="in"?mo(n[1],n.slice(2)):t==="!in"?ms(mo(n[1],n.slice(2))):t==="has"?_o(n[1]):t!=="!has"||ms(_o(n[1]));var r}function sa(n,t,r){switch(n){case"$type":return[`filter-type-${r}`,t];case"$id":return[`filter-id-${r}`,t];default:return[`filter-${r}`,n,t]}}function mo(n,t){if(t.length===0)return!1;switch(n){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(r=>typeof r!=typeof t[0])?["filter-in-large",n,["literal",t.sort(Al)]]:["filter-in-small",n,["literal",t]]}}function _o(n){switch(n){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",n]}}function ms(n){return["!",n]}function _s(n){const t=typeof n;if(t==="number"||t==="boolean"||t==="string"||n==null)return JSON.stringify(n);if(Array.isArray(n)){let l="[";for(const d of n)l+=`${_s(d)},`;return`${l}]`}const r=Object.keys(n).sort();let s="{";for(let l=0;l<r.length;l++)s+=`${JSON.stringify(r[l])}:${_s(n[r[l]])},`;return`${s}}`}function go(n){let t="";for(const r of D)t+=`/${_s(n[r])}`;return t}function aa(n){const t=n.value;return t?[new te(n.key,t,"constants have been deprecated as of v8")]:[]}function gt(n){return n instanceof Number||n instanceof String||n instanceof Boolean?n.valueOf():n}function un(n){if(Array.isArray(n))return n.map(un);if(n instanceof Object&&!(n instanceof Number||n instanceof String||n instanceof Boolean)){const t={};for(const r in n)t[r]=un(n[r]);return t}return gt(n)}function zi(n){const t=n.key,r=n.value,s=n.valueSpec||{},l=n.objectElementValidators||{},d=n.style,p=n.styleSpec,m=n.validateSpec;let g=[];const x=tt(r);if(x!=="object")return[new te(t,r,`object expected, ${x} found`)];for(const b in r){const w=b.split(".")[0],M=s[w]||s["*"];let C;if(l[w])C=l[w];else if(s[w])C=m;else if(l["*"])C=l["*"];else{if(!s["*"]){g.push(new te(t,r[b],`unknown property "${b}"`));continue}C=m}g=g.concat(C({key:(t&&`${t}.`)+b,value:r[b],valueSpec:M,style:d,styleSpec:p,object:r,objectKey:b,validateSpec:m},r))}for(const b in s)l[b]||s[b].required&&s[b].default===void 0&&r[b]===void 0&&g.push(new te(t,r,`missing required property "${b}"`));return g}function yo(n){const t=n.value,r=n.valueSpec,s=n.style,l=n.styleSpec,d=n.key,p=n.arrayElementValidator||n.validateSpec;if(tt(t)!=="array")return[new te(d,t,`array expected, ${tt(t)} found`)];if(r.length&&t.length!==r.length)return[new te(d,t,`array length ${r.length} expected, length ${t.length} found`)];if(r["min-length"]&&t.length<r["min-length"])return[new te(d,t,`array length at least ${r["min-length"]} expected, length ${t.length} found`)];let m={type:r.value,values:r.values};l.$version<7&&(m.function=r.function),tt(r.value)==="object"&&(m=r.value);let g=[];for(let x=0;x<t.length;x++)g=g.concat(p({array:t,arrayIndex:x,value:t[x],valueSpec:m,validateSpec:n.validateSpec,style:s,styleSpec:l,key:`${d}[${x}]`}));return g}function xo(n){const t=n.key,r=n.value,s=n.valueSpec;let l=tt(r);return l==="number"&&r!=r&&(l="NaN"),l!=="number"?[new te(t,r,`number expected, ${l} found`)]:"minimum"in s&&r<s.minimum?[new te(t,r,`${r} is less than the minimum value ${s.minimum}`)]:"maximum"in s&&r>s.maximum?[new te(t,r,`${r} is greater than the maximum value ${s.maximum}`)]:[]}function kl(n){const t=n.valueSpec,r=gt(n.value.type);let s,l,d,p={};const m=r!=="categorical"&&n.value.property===void 0,g=!m,x=tt(n.value.stops)==="array"&&tt(n.value.stops[0])==="array"&&tt(n.value.stops[0][0])==="object",b=zi({key:n.key,value:n.value,valueSpec:n.styleSpec.function,validateSpec:n.validateSpec,style:n.style,styleSpec:n.styleSpec,objectElementValidators:{stops:function(C){if(r==="identity")return[new te(C.key,C.value,'identity function may not have a "stops" property')];let E=[];const k=C.value;return E=E.concat(yo({key:C.key,value:k,valueSpec:C.valueSpec,validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec,arrayElementValidator:w})),tt(k)==="array"&&k.length===0&&E.push(new te(C.key,k,"array must have at least one stop")),E},default:function(C){return C.validateSpec({key:C.key,value:C.value,valueSpec:t,validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec})}}});return r==="identity"&&m&&b.push(new te(n.key,n.value,'missing required property "property"')),r==="identity"||n.value.stops||b.push(new te(n.key,n.value,'missing required property "stops"')),r==="exponential"&&n.valueSpec.expression&&!uo(n.valueSpec)&&b.push(new te(n.key,n.value,"exponential functions not supported")),n.styleSpec.$version>=8&&(g&&!An(n.valueSpec)?b.push(new te(n.key,n.value,"property functions not supported")):m&&!Sl(n.valueSpec)&&b.push(new te(n.key,n.value,"zoom functions not supported"))),r!=="categorical"&&!x||n.value.property!==void 0||b.push(new te(n.key,n.value,'"property" property is required')),b;function w(C){let E=[];const k=C.value,O=C.key;if(tt(k)!=="array")return[new te(O,k,`array expected, ${tt(k)} found`)];if(k.length!==2)return[new te(O,k,`array length 2 expected, length ${k.length} found`)];if(x){if(tt(k[0])!=="object")return[new te(O,k,`object expected, ${tt(k[0])} found`)];if(k[0].zoom===void 0)return[new te(O,k,"object stop key must have zoom")];if(k[0].value===void 0)return[new te(O,k,"object stop key must have value")];if(d&&d>gt(k[0].zoom))return[new te(O,k[0].zoom,"stop zoom values must appear in ascending order")];gt(k[0].zoom)!==d&&(d=gt(k[0].zoom),l=void 0,p={}),E=E.concat(zi({key:`${O}[0]`,value:k[0],valueSpec:{zoom:{}},validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec,objectElementValidators:{zoom:xo,value:M}}))}else E=E.concat(M({key:`${O}[0]`,value:k[0],validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec},k));return Js(un(k[1]))?E.concat([new te(`${O}[1]`,k[1],"expressions are not allowed in function stops.")]):E.concat(C.validateSpec({key:`${O}[1]`,value:k[1],valueSpec:t,validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec}))}function M(C,E){const k=tt(C.value),O=gt(C.value),Z=C.value!==null?C.value:E;if(s){if(k!==s)return[new te(C.key,Z,`${k} stop domain type must match previous stop domain type ${s}`)]}else s=k;if(k!=="number"&&k!=="string"&&k!=="boolean")return[new te(C.key,Z,"stop domain value must be a number, string, or boolean")];if(k!=="number"&&r!=="categorical"){let ee=`number expected, ${k} found`;return An(t)&&r===void 0&&(ee+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new te(C.key,Z,ee)]}return r!=="categorical"||k!=="number"||isFinite(O)&&Math.floor(O)===O?r!=="categorical"&&k==="number"&&l!==void 0&&O<l?[new te(C.key,Z,"stop domain values must appear in ascending order")]:(l=O,r==="categorical"&&O in p?[new te(C.key,Z,"stop domain values must be unique")]:(p[O]=!0,[])):[new te(C.key,Z,`integer expected, found ${O}`)]}}function kn(n){const t=(n.expressionContext==="property"?El:Qs)(un(n.value),n.valueSpec);if(t.result==="error")return t.value.map(s=>new te(`${n.key}${s.key}`,n.value,s.message));const r=t.value.expression||t.value._styleExpression.expression;if(n.expressionContext==="property"&&n.propertyKey==="text-font"&&!r.outputDefined())return[new te(n.key,n.value,`Invalid data expression for "${n.propertyKey}". Output values must be contained as literals within the expression.`)];if(n.expressionContext==="property"&&n.propertyType==="layout"&&!ps(r))return[new te(n.key,n.value,'"feature-state" data expressions are not supported with layout properties.')];if(n.expressionContext==="filter"&&!ps(r))return[new te(n.key,n.value,'"feature-state" data expressions are not supported with filters.')];if(n.expressionContext&&n.expressionContext.indexOf("cluster")===0){if(!Ws(r,["zoom","feature-state"]))return[new te(n.key,n.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(n.expressionContext==="cluster-initial"&&!Xs(r))return[new te(n.key,n.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Dn(n){const t=n.key,r=n.value,s=n.valueSpec,l=[];return Array.isArray(s.values)?s.values.indexOf(gt(r))===-1&&l.push(new te(t,r,`expected one of [${s.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(s.values).indexOf(gt(r))===-1&&l.push(new te(t,r,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(r)} found`)),l}function oa(n){return fo(un(n.value))?kn(Ie({},n,{expressionContext:"filter",valueSpec:{value:"boolean"}})):gs(n)}function gs(n){const t=n.value,r=n.key;if(tt(t)!=="array")return[new te(r,t,`array expected, ${tt(t)} found`)];const s=n.styleSpec;let l,d=[];if(t.length<1)return[new te(r,t,"filter array must have at least 1 element")];switch(d=d.concat(Dn({key:`${r}[0]`,value:t[0],valueSpec:s.filter_operator,style:n.style,styleSpec:n.styleSpec})),gt(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&gt(t[1])==="$type"&&d.push(new te(r,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&d.push(new te(r,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(l=tt(t[1]),l!=="string"&&d.push(new te(`${r}[1]`,t[1],`string expected, ${l} found`)));for(let p=2;p<t.length;p++)l=tt(t[p]),gt(t[1])==="$type"?d=d.concat(Dn({key:`${r}[${p}]`,value:t[p],valueSpec:s.geometry_type,style:n.style,styleSpec:n.styleSpec})):l!=="string"&&l!=="number"&&l!=="boolean"&&d.push(new te(`${r}[${p}]`,t[p],`string, number, or boolean expected, ${l} found`));break;case"any":case"all":case"none":for(let p=1;p<t.length;p++)d=d.concat(gs({key:`${r}[${p}]`,value:t[p],style:n.style,styleSpec:n.styleSpec}));break;case"has":case"!has":l=tt(t[1]),t.length!==2?d.push(new te(r,t,`filter array for "${t[0]}" operator must have 2 elements`)):l!=="string"&&d.push(new te(`${r}[1]`,t[1],`string expected, ${l} found`))}return d}function Dl(n,t){const r=n.key,s=n.validateSpec,l=n.style,d=n.styleSpec,p=n.value,m=n.objectKey,g=d[`${t}_${n.layerType}`];if(!g)return[];const x=m.match(/^(.*)-transition$/);if(t==="paint"&&x&&g[x[1]]&&g[x[1]].transition)return s({key:r,value:p,valueSpec:d.transition,style:l,styleSpec:d});const b=n.valueSpec||g[m];if(!b)return[new te(r,p,`unknown property "${m}"`)];let w;if(tt(p)==="string"&&An(b)&&!b.tokens&&(w=/^{([^}]+)}$/.exec(p)))return[new te(r,p,`"${m}" does not support interpolation syntax
Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(w[1])} }\`.`)];const M=[];return n.layerType==="symbol"&&(m==="text-field"&&l&&!l.glyphs&&M.push(new te(r,p,'use of "text-field" requires a style "glyphs" property')),m==="text-font"&&Ks(un(p))&&gt(p.type)==="identity"&&M.push(new te(r,p,'"text-font" does not support identity functions'))),M.concat(s({key:n.key,value:p,valueSpec:b,style:l,styleSpec:d,expressionContext:"property",propertyType:t,propertyKey:m}))}function vo(n){return Dl(n,"paint")}function bo(n){return Dl(n,"layout")}function Rl(n){let t=[];const r=n.value,s=n.key,l=n.style,d=n.styleSpec;r.type||r.ref||t.push(new te(s,r,'either "type" or "ref" is required'));let p=gt(r.type);const m=gt(r.ref);if(r.id){const g=gt(r.id);for(let x=0;x<n.arrayIndex;x++){const b=l.layers[x];gt(b.id)===g&&t.push(new te(s,r.id,`duplicate layer id "${r.id}", previously used at line ${b.id.__line__}`))}}if("ref"in r){let g;["type","source","source-layer","filter","layout"].forEach(x=>{x in r&&t.push(new te(s,r[x],`"${x}" is prohibited for ref layers`))}),l.layers.forEach(x=>{gt(x.id)===m&&(g=x)}),g?g.ref?t.push(new te(s,r.ref,"ref cannot reference another ref layer")):p=gt(g.type):t.push(new te(s,r.ref,`ref layer "${m}" not found`))}else if(p!=="background")if(r.source){const g=l.sources&&l.sources[r.source],x=g&&gt(g.type);g?x==="vector"&&p==="raster"?t.push(new te(s,r.source,`layer "${r.id}" requires a raster source`)):x!=="raster-dem"&&p==="hillshade"?t.push(new te(s,r.source,`layer "${r.id}" requires a raster-dem source`)):x==="raster"&&p!=="raster"?t.push(new te(s,r.source,`layer "${r.id}" requires a vector source`)):x!=="vector"||r["source-layer"]?x==="raster-dem"&&p!=="hillshade"?t.push(new te(s,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):p!=="line"||!r.paint||!r.paint["line-gradient"]||x==="geojson"&&g.lineMetrics||t.push(new te(s,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new te(s,r,`layer "${r.id}" must specify a "source-layer"`)):t.push(new te(s,r.source,`source "${r.source}" not found`))}else t.push(new te(s,r,'missing required property "source"'));return t=t.concat(zi({key:s,value:r,valueSpec:d.layer,style:n.style,styleSpec:n.styleSpec,validateSpec:n.validateSpec,objectElementValidators:{"*":()=>[],type:()=>n.validateSpec({key:`${s}.type`,value:r.type,valueSpec:d.layer.type,style:n.style,styleSpec:n.styleSpec,validateSpec:n.validateSpec,object:r,objectKey:"type"}),filter:oa,layout:g=>zi({layer:r,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":x=>bo(Ie({layerType:p},x))}}),paint:g=>zi({layer:r,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":x=>vo(Ie({layerType:p},x))}})}})),t}function Cr(n){const t=n.value,r=n.key,s=tt(t);return s!=="string"?[new te(r,t,`string expected, ${s} found`)]:[]}const wo={promoteId:function({key:n,value:t}){if(tt(t)==="string")return Cr({key:n,value:t});{const r=[];for(const s in t)r.push(...Cr({key:`${n}.${s}`,value:t[s]}));return r}}};function Rn(n){const t=n.value,r=n.key,s=n.styleSpec,l=n.style,d=n.validateSpec;if(!t.type)return[new te(r,t,'"type" is required')];const p=gt(t.type);let m;switch(p){case"vector":case"raster":return m=zi({key:r,value:t,valueSpec:s[`source_${p.replace("-","_")}`],style:n.style,styleSpec:s,objectElementValidators:wo,validateSpec:d}),m;case"raster-dem":return m=function(g){var x;const b=(x=g.sourceName)!==null&&x!==void 0?x:"",w=g.value,M=g.styleSpec,C=M.source_raster_dem,E=g.style;let k=[];const O=tt(w);if(w===void 0)return k;if(O!=="object")return k.push(new te("source_raster_dem",w,`object expected, ${O} found`)),k;const Z=gt(w.encoding)==="custom",ee=["redFactor","greenFactor","blueFactor","baseShift"],q=g.value.encoding?`"${g.value.encoding}"`:"Default";for(const I in w)!Z&&ee.includes(I)?k.push(new te(I,w[I],`In "${b}": "${I}" is only valid when "encoding" is set to "custom". ${q} encoding found`)):C[I]?k=k.concat(g.validateSpec({key:I,value:w[I],valueSpec:C[I],validateSpec:g.validateSpec,style:E,styleSpec:M})):k.push(new te(I,w[I],`unknown property "${I}"`));return k}({sourceName:r,value:t,style:n.style,styleSpec:s,validateSpec:d}),m;case"geojson":if(m=zi({key:r,value:t,valueSpec:s.source_geojson,style:l,styleSpec:s,validateSpec:d,objectElementValidators:wo}),t.cluster)for(const g in t.clusterProperties){const[x,b]=t.clusterProperties[g],w=typeof x=="string"?[x,["accumulated"],["get",g]]:x;m.push(...kn({key:`${r}.${g}.map`,value:b,expressionContext:"cluster-map"})),m.push(...kn({key:`${r}.${g}.reduce`,value:w,expressionContext:"cluster-reduce"}))}return m;case"video":return zi({key:r,value:t,valueSpec:s.source_video,style:l,validateSpec:d,styleSpec:s});case"image":return zi({key:r,value:t,valueSpec:s.source_image,style:l,validateSpec:d,styleSpec:s});case"canvas":return[new te(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Dn({key:`${r}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Ll(n){const t=n.value,r=n.styleSpec,s=r.light,l=n.style;let d=[];const p=tt(t);if(t===void 0)return d;if(p!=="object")return d=d.concat([new te("light",t,`object expected, ${p} found`)]),d;for(const m in t){const g=m.match(/^(.*)-transition$/);d=d.concat(g&&s[g[1]]&&s[g[1]].transition?n.validateSpec({key:m,value:t[m],valueSpec:r.transition,validateSpec:n.validateSpec,style:l,styleSpec:r}):s[m]?n.validateSpec({key:m,value:t[m],valueSpec:s[m],validateSpec:n.validateSpec,style:l,styleSpec:r}):[new te(m,t[m],`unknown property "${m}"`)])}return d}function Bl(n){const t=n.value,r=n.styleSpec,s=r.sky,l=n.style,d=tt(t);if(t===void 0)return[];if(d!=="object")return[new te("sky",t,`object expected, ${d} found`)];let p=[];for(const m in t)p=p.concat(s[m]?n.validateSpec({key:m,value:t[m],valueSpec:s[m],style:l,styleSpec:r}):[new te(m,t[m],`unknown property "${m}"`)]);return p}function Fl(n){const t=n.value,r=n.styleSpec,s=r.terrain,l=n.style;let d=[];const p=tt(t);if(t===void 0)return d;if(p!=="object")return d=d.concat([new te("terrain",t,`object expected, ${p} found`)]),d;for(const m in t)d=d.concat(s[m]?n.validateSpec({key:m,value:t[m],valueSpec:s[m],validateSpec:n.validateSpec,style:l,styleSpec:r}):[new te(m,t[m],`unknown property "${m}"`)]);return d}function Ol(n){let t=[];const r=n.value,s=n.key;if(Array.isArray(r)){const l=[],d=[];for(const p in r)r[p].id&&l.includes(r[p].id)&&t.push(new te(s,r,`all the sprites' ids must be unique, but ${r[p].id} is duplicated`)),l.push(r[p].id),r[p].url&&d.includes(r[p].url)&&t.push(new te(s,r,`all the sprites' URLs must be unique, but ${r[p].url} is duplicated`)),d.push(r[p].url),t=t.concat(zi({key:`${s}[${p}]`,value:r[p],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:n.validateSpec}));return t}return Cr({key:s,value:r})}const jl={"*":()=>[],array:yo,boolean:function(n){const t=n.value,r=n.key,s=tt(t);return s!=="boolean"?[new te(r,t,`boolean expected, ${s} found`)]:[]},number:xo,color:function(n){const t=n.key,r=n.value,s=tt(r);return s!=="string"?[new te(t,r,`color expected, ${s} found`)]:Xe.parse(String(r))?[]:[new te(t,r,`color expected, "${r}" found`)]},constants:aa,enum:Dn,filter:oa,function:kl,layer:Rl,object:zi,source:Rn,light:Ll,sky:Bl,terrain:Fl,projection:function(n){const t=n.value,r=n.styleSpec,s=r.projection,l=n.style,d=tt(t);if(t===void 0)return[];if(d!=="object")return[new te("projection",t,`object expected, ${d} found`)];let p=[];for(const m in t)p=p.concat(s[m]?n.validateSpec({key:m,value:t[m],valueSpec:s[m],style:l,styleSpec:r}):[new te(m,t[m],`unknown property "${m}"`)]);return p},projectionDefinition:function(n){const t=n.key;let r=n.value;r=r instanceof String?r.valueOf():r;const s=tt(r);return s!=="array"||function(l){return Array.isArray(l)&&l.length===3&&typeof l[0]=="string"&&typeof l[1]=="string"&&typeof l[2]=="number"}(r)||function(l){return!!["interpolate","step","literal"].includes(l[0])}(r)?["array","string"].includes(s)?[]:[new te(t,r,`projection expected, invalid type "${s}" found`)]:[new te(t,r,`projection expected, invalid array ${JSON.stringify(r)} found`)]},string:Cr,formatted:function(n){return Cr(n).length===0?[]:kn(n)},resolvedImage:function(n){return Cr(n).length===0?[]:kn(n)},padding:function(n){const t=n.key,r=n.value;if(tt(r)==="array"){if(r.length<1||r.length>4)return[new te(t,r,`padding requires 1 to 4 values; ${r.length} values found`)];const s={type:"number"};let l=[];for(let d=0;d<r.length;d++)l=l.concat(n.validateSpec({key:`${t}[${d}]`,value:r[d],validateSpec:n.validateSpec,valueSpec:s}));return l}return xo({key:t,value:r,valueSpec:{}})},variableAnchorOffsetCollection:function(n){const t=n.key,r=n.value,s=tt(r),l=n.styleSpec;if(s!=="array"||r.length<1||r.length%2!=0)return[new te(t,r,"variableAnchorOffsetCollection requires a non-empty array of even length")];let d=[];for(let p=0;p<r.length;p+=2)d=d.concat(Dn({key:`${t}[${p}]`,value:r[p],valueSpec:l.layout_symbol["text-anchor"]})),d=d.concat(yo({key:`${t}[${p+1}]`,value:r[p+1],valueSpec:{length:2,value:"number"},validateSpec:n.validateSpec,style:n.style,styleSpec:l}));return d},sprite:Ol};function la(n){const t=n.value,r=n.valueSpec,s=n.styleSpec;return n.validateSpec=la,r.expression&&Ks(gt(t))?kl(n):r.expression&&Js(un(t))?kn(n):r.type&&jl[r.type]?jl[r.type](n):zi(Ie({},n,{valueSpec:r.type?s[r.type]:r}))}function Ln(n){const t=n.value,r=n.key,s=Cr(n);return s.length||(t.indexOf("{fontstack}")===-1&&s.push(new te(r,t,'"glyphs" url must include a "{fontstack}" token')),t.indexOf("{range}")===-1&&s.push(new te(r,t,'"glyphs" url must include a "{range}" token'))),s}function li(n,t=j){let r=[];return r=r.concat(la({key:"",value:n,valueSpec:t.$root,styleSpec:t,style:n,validateSpec:la,objectElementValidators:{glyphs:Ln,"*":()=>[]}})),n.constants&&(r=r.concat(aa({key:"constants",value:n.constants}))),Bn(r)}function At(n){return function(t){return n({...t,validateSpec:la})}}function Bn(n){return[].concat(n).sort((t,r)=>t.line-r.line)}function ji(n){return function(...t){return Bn(n.apply(this,t))}}li.source=ji(At(Rn)),li.sprite=ji(At(Ol)),li.glyphs=ji(At(Ln)),li.light=ji(At(Ll)),li.sky=ji(At(Bl)),li.terrain=ji(At(Fl)),li.layer=ji(At(Rl)),li.filter=ji(At(oa)),li.paintProperty=ji(At(vo)),li.layoutProperty=ji(At(bo));const Fn=li,Uc=Fn.light,ys=Fn.sky,Nl=Fn.paintProperty,To=Fn.layoutProperty;function Vl(n,t){let r=!1;if(t&&t.length)for(const s of t)n.fire(new Qn(new Error(s.message))),r=!0;return r}class dn{constructor(t,r,s){const l=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const p=new Int32Array(this.arrayBuffer);t=p[0],this.d=(r=p[1])+2*(s=p[2]);for(let g=0;g<this.d*this.d;g++){const x=p[3+g],b=p[3+g+1];l.push(x===b?null:p.subarray(x,b))}const m=p[3+l.length+1];this.keys=p.subarray(p[3+l.length],m),this.bboxes=p.subarray(m),this.insert=this._insertReadonly}else{this.d=r+2*s;for(let p=0;p<this.d*this.d;p++)l.push([]);this.keys=[],this.bboxes=[]}this.n=r,this.extent=t,this.padding=s,this.scale=r/t,this.uid=0;const d=s/r*t;this.min=-d,this.max=t+d}insert(t,r,s,l,d){this._forEachCell(r,s,l,d,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(r),this.bboxes.push(s),this.bboxes.push(l),this.bboxes.push(d)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,r,s,l,d,p){this.cells[d].push(p)}query(t,r,s,l,d){const p=this.min,m=this.max;if(t<=p&&r<=p&&m<=s&&m<=l&&!d)return Array.prototype.slice.call(this.keys);{const g=[];return this._forEachCell(t,r,s,l,this._queryCell,g,{},d),g}}_queryCell(t,r,s,l,d,p,m,g){const x=this.cells[d];if(x!==null){const b=this.keys,w=this.bboxes;for(let M=0;M<x.length;M++){const C=x[M];if(m[C]===void 0){const E=4*C;(g?g(w[E+0],w[E+1],w[E+2],w[E+3]):t<=w[E+2]&&r<=w[E+3]&&s>=w[E+0]&&l>=w[E+1])?(m[C]=!0,p.push(b[C])):m[C]=!1}}}}_forEachCell(t,r,s,l,d,p,m,g){const x=this._convertToCellCoord(t),b=this._convertToCellCoord(r),w=this._convertToCellCoord(s),M=this._convertToCellCoord(l);for(let C=x;C<=w;C++)for(let E=b;E<=M;E++){const k=this.d*E+C;if((!g||g(this._convertFromCellCoord(C),this._convertFromCellCoord(E),this._convertFromCellCoord(C+1),this._convertFromCellCoord(E+1)))&&d.call(this,t,r,s,l,k,p,m,g))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,r=3+this.cells.length+1+1;let s=0;for(let p=0;p<this.cells.length;p++)s+=this.cells[p].length;const l=new Int32Array(r+s+this.keys.length+this.bboxes.length);l[0]=this.extent,l[1]=this.n,l[2]=this.padding;let d=r;for(let p=0;p<t.length;p++){const m=t[p];l[3+p]=d,l.set(m,d),d+=m.length}return l[3+t.length]=d,l.set(this.keys,d),d+=this.keys.length,l[3+t.length+1]=d,l.set(this.bboxes,d),d+=this.bboxes.length,l.buffer}static serialize(t,r){const s=t.toArrayBuffer();return r&&r.push(s),{buffer:s}}static deserialize(t){return new dn(t.buffer)}}const sr={};function Ae(n,t,r={}){if(sr[n])throw new Error(`${n} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:n,writeable:!1}),sr[n]={klass:t,omit:r.omit||[],shallow:r.shallow||[]}}Ae("Object",Object),Ae("TransferableGridIndex",dn),Ae("Color",Xe),Ae("Error",Error),Ae("AJAXError",er),Ae("ResolvedImage",ri),Ae("StylePropertyFunction",ta),Ae("StyleExpression",Ys,{omit:["_evaluator"]}),Ae("ZoomDependentExpression",ea),Ae("ZoomConstantExpression",zn),Ae("CompoundExpression",Ai,{omit:["_evaluate"]});for(const n in Cn)Cn[n]._classRegistryKey||Ae(`Expression_${n}`,Cn[n]);function Ul(n){return n&&typeof ArrayBuffer<"u"&&(n instanceof ArrayBuffer||n.constructor&&n.constructor.name==="ArrayBuffer")}function pn(n){return n.$name||n.constructor._classRegistryKey}function Zl(n){return!function(t){if(t===null||typeof t!="object")return!1;const r=pn(t);return!(!r||r==="Object")}(n)&&(n==null||typeof n=="boolean"||typeof n=="number"||typeof n=="string"||n instanceof Boolean||n instanceof Number||n instanceof String||n instanceof Date||n instanceof RegExp||n instanceof Blob||n instanceof Error||Ul(n)||Gr(n)||ArrayBuffer.isView(n)||n instanceof ImageData)}function xs(n,t){if(Zl(n))return(Ul(n)||Gr(n))&&t&&t.push(n),ArrayBuffer.isView(n)&&t&&t.push(n.buffer),n instanceof ImageData&&t&&t.push(n.data.buffer),n;if(Array.isArray(n)){const d=[];for(const p of n)d.push(xs(p,t));return d}if(typeof n!="object")throw new Error("can't serialize object of type "+typeof n);const r=pn(n);if(!r)throw new Error(`can't serialize object of unregistered class ${n.constructor.name}`);if(!sr[r])throw new Error(`${r} is not registered.`);const{klass:s}=sr[r],l=s.serialize?s.serialize(n,t):{};if(s.serialize){if(t&&l===t[t.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const d in n){if(!n.hasOwnProperty(d)||sr[r].omit.indexOf(d)>=0)continue;const p=n[d];l[d]=sr[r].shallow.indexOf(d)>=0?p:xs(p,t)}n instanceof Error&&(l.message=n.message)}if(l.$name)throw new Error("$name property is reserved for worker serialization logic.");return r!=="Object"&&(l.$name=r),l}function Er(n){if(Zl(n))return n;if(Array.isArray(n))return n.map(Er);if(typeof n!="object")throw new Error("can't deserialize object of type "+typeof n);const t=pn(n)||"Object";if(!sr[t])throw new Error(`can't deserialize unregistered class ${t}`);const{klass:r}=sr[t];if(!r)throw new Error(`can't deserialize unregistered class ${t}`);if(r.deserialize)return r.deserialize(n);const s=Object.create(r.prototype);for(const l of Object.keys(n)){if(l==="$name")continue;const d=n[l];s[l]=sr[t].shallow.indexOf(l)>=0?d:Er(d)}return s}class Gl{constructor(){this.first=!0}update(t,r){const s=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=s,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=s,!0):(this.lastFloorZoom>s?(this.lastIntegerZoom=s+1,this.lastIntegerZoomTime=r):this.lastFloorZoom<s&&(this.lastIntegerZoom=s,this.lastIntegerZoomTime=r),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=s,!0))}}const We={"Latin-1 Supplement":n=>n>=128&&n<=255,"Hangul Jamo":n=>n>=4352&&n<=4607,Khmer:n=>n>=6016&&n<=6143,"General Punctuation":n=>n>=8192&&n<=8303,"Letterlike Symbols":n=>n>=8448&&n<=8527,"Number Forms":n=>n>=8528&&n<=8591,"Miscellaneous Technical":n=>n>=8960&&n<=9215,"Control Pictures":n=>n>=9216&&n<=9279,"Optical Character Recognition":n=>n>=9280&&n<=9311,"Enclosed Alphanumerics":n=>n>=9312&&n<=9471,"Geometric Shapes":n=>n>=9632&&n<=9727,"Miscellaneous Symbols":n=>n>=9728&&n<=9983,"Miscellaneous Symbols and Arrows":n=>n>=11008&&n<=11263,"Ideographic Description Characters":n=>n>=12272&&n<=12287,"CJK Symbols and Punctuation":n=>n>=12288&&n<=12351,Katakana:n=>n>=12448&&n<=12543,Kanbun:n=>n>=12688&&n<=12703,"CJK Strokes":n=>n>=12736&&n<=12783,"Enclosed CJK Letters and Months":n=>n>=12800&&n<=13055,"CJK Compatibility":n=>n>=13056&&n<=13311,"Yijing Hexagram Symbols":n=>n>=19904&&n<=19967,"Private Use Area":n=>n>=57344&&n<=63743,"Vertical Forms":n=>n>=65040&&n<=65055,"CJK Compatibility Forms":n=>n>=65072&&n<=65103,"Small Form Variants":n=>n>=65104&&n<=65135,"Halfwidth and Fullwidth Forms":n=>n>=65280&&n<=65519};function On(n){for(const t of n)if(ua(t.charCodeAt(0)))return!0;return!1}function $l(n){for(const t of n)if(!Hl(t.charCodeAt(0)))return!1;return!0}function ca(n){const t=n.map(r=>{try{return new RegExp(`\\p{sc=${r}}`,"u").source}catch{return null}}).filter(r=>r);return new RegExp(t.join("|"),"u")}const ql=ca(["Arab","Dupl","Mong","Ougr","Syrc"]);function Hl(n){return!ql.test(String.fromCodePoint(n))}const ha=ca(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function ua(n){return!(n!==746&&n!==747&&(n<4352||!(We["CJK Compatibility Forms"](n)&&!(n>=65097&&n<=65103)||We["CJK Compatibility"](n)||We["CJK Strokes"](n)||!(!We["CJK Symbols and Punctuation"](n)||n>=12296&&n<=12305||n>=12308&&n<=12319||n===12336)||We["Enclosed CJK Letters and Months"](n)||We["Ideographic Description Characters"](n)||We.Kanbun(n)||We.Katakana(n)&&n!==12540||!(!We["Halfwidth and Fullwidth Forms"](n)||n===65288||n===65289||n===65293||n>=65306&&n<=65310||n===65339||n===65341||n===65343||n>=65371&&n<=65503||n===65507||n>=65512&&n<=65519)||!(!We["Small Form Variants"](n)||n>=65112&&n<=65118||n>=65123&&n<=65126)||We["Vertical Forms"](n)||We["Yijing Hexagram Symbols"](n)||new RegExp("\\p{sc=Cans}","u").test(String.fromCodePoint(n))||new RegExp("\\p{sc=Hang}","u").test(String.fromCodePoint(n))||ha.test(String.fromCodePoint(n)))))}function Xl(n){return!(ua(n)||function(t){return!!(We["Latin-1 Supplement"](t)&&(t===167||t===169||t===174||t===177||t===188||t===189||t===190||t===215||t===247)||We["General Punctuation"](t)&&(t===8214||t===8224||t===8225||t===8240||t===8241||t===8251||t===8252||t===8258||t===8263||t===8264||t===8265||t===8273)||We["Letterlike Symbols"](t)||We["Number Forms"](t)||We["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||t===9003||t>=9085&&t<=9114||t>=9150&&t<=9165||t===9167||t>=9169&&t<=9179||t>=9186&&t<=9215)||We["Control Pictures"](t)&&t!==9251||We["Optical Character Recognition"](t)||We["Enclosed Alphanumerics"](t)||We["Geometric Shapes"](t)||We["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||We["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||We["CJK Symbols and Punctuation"](t)||We.Katakana(t)||We["Private Use Area"](t)||We["CJK Compatibility Forms"](t)||We["Small Form Variants"](t)||We["Halfwidth and Fullwidth Forms"](t)||t===8734||t===8756||t===8757||t>=9984&&t<=10087||t>=10102&&t<=10131||t===65532||t===65533)}(n))}const Wl=ca(["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 Kl(n){return Wl.test(String.fromCodePoint(n))}function Yl(n,t){return!(!t&&Kl(n)||n>=2304&&n<=3583||n>=3840&&n<=4255||We.Khmer(n))}function Jl(n){for(const t of n)if(Kl(t.charCodeAt(0)))return!0;return!1}const ar=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(n){this.pluginStatus=n.pluginStatus,this.pluginURL=n.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(n){if(ar.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=n.applyArabicShaping,this.processBidirectionalText=n.processBidirectionalText,this.processStyledBidirectionalText=n.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}syncState(n,t){return c(this,void 0,void 0,function*(){if(this.isParsed())return this.getState();if(n.pluginStatus!=="loading")return this.setState(n),n;const r=n.pluginURL,s=new Promise(d=>{this.loadScriptResolve=d});t(r);const l=new Promise(d=>setTimeout(()=>d(),this.TIMEOUT));if(yield Promise.race([s,l]),this.isParsed()){const d={pluginStatus:"loaded",pluginURL:r};return this.setState(d),d}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${r}`)})}};class yt{constructor(t,r){this.zoom=t,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Gl,this.transition={})}isSupportedScript(t){return function(r,s){for(const l of r)if(!Yl(l.charCodeAt(0),s))return!1;return!0}(t,ar.getRTLTextPluginStatus()==="loaded")}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,r=t-Math.floor(t),s=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*s}:{fromScale:.5,toScale:1,t:1-(1-s)*r}}}class da{constructor(t,r){this.property=t,this.value=r,this.expression=function(s,l){if(Ks(s))return new ta(s,l);if(Js(s)){const d=El(s,l);if(d.result==="error")throw new Error(d.value.map(p=>`${p.key}: ${p.message}`).join(", "));return d.value}{let d=s;return l.type==="color"&&typeof s=="string"?d=Xe.parse(s):l.type!=="padding"||typeof s!="number"&&!Array.isArray(s)?l.type==="variableAnchorOffsetCollection"&&Array.isArray(s)?d=ii.parse(s):l.type==="projectionDefinition"&&typeof s=="string"&&(d=ni.parse(s)):d=Nt.parse(s),{kind:"constant",evaluate:()=>d}}}(r===void 0?t.specification.default:r,t.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(t,r,s){return this.property.possiblyEvaluate(this,t,r,s)}}class pa{constructor(t){this.property=t,this.value=new da(t,void 0)}transitioned(t,r){return new Mo(this.property,this.value,r,Wt({},t.transition,this.transition),t.now)}untransitioned(){return new Mo(this.property,this.value,null,{},0)}}class Po{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return fi(this._values[t].value.value)}setValue(t,r){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new pa(this._values[t].property)),this._values[t].value=new da(this._values[t].property,r===null?void 0:fi(r))}getTransition(t){return fi(this._values[t].transition)}setTransition(t,r){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new pa(this._values[t].property)),this._values[t].transition=fi(r)||void 0}serialize(){const t={};for(const r of Object.keys(this._values)){const s=this.getValue(r);s!==void 0&&(t[r]=s);const l=this.getTransition(r);l!==void 0&&(t[`${r}-transition`]=l)}return t}transitioned(t,r){const s=new So(this._properties);for(const l of Object.keys(this._values))s._values[l]=this._values[l].transitioned(t,r._values[l]);return s}untransitioned(){const t=new So(this._properties);for(const r of Object.keys(this._values))t._values[r]=this._values[r].untransitioned();return t}}class Mo{constructor(t,r,s,l,d){this.property=t,this.value=r,this.begin=d+l.delay||0,this.end=this.begin+l.duration||0,t.specification.transition&&(l.delay||l.duration)&&(this.prior=s)}possiblyEvaluate(t,r,s){const l=t.now||0,d=this.value.possiblyEvaluate(t,r,s),p=this.prior;if(p){if(l>this.end)return this.prior=null,d;if(this.value.isDataDriven())return this.prior=null,d;if(l<this.begin)return p.possiblyEvaluate(t,r,s);{const m=(l-this.begin)/(this.end-this.begin);return this.property.interpolate(p.possiblyEvaluate(t,r,s),d,Nr(m))}}return d}}class So{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,r,s){const l=new jn(this._properties);for(const d of Object.keys(this._values))l._values[d]=this._values[d].possiblyEvaluate(t,r,s);return l}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class fa{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}hasValue(t){return this._values[t].value!==void 0}getValue(t){return fi(this._values[t].value)}setValue(t,r){this._values[t]=new da(this._values[t].property,r===null?void 0:fi(r))}serialize(){const t={};for(const r of Object.keys(this._values)){const s=this.getValue(r);s!==void 0&&(t[r]=s)}return t}possiblyEvaluate(t,r,s){const l=new jn(this._properties);for(const d of Object.keys(this._values))l._values[d]=this._values[d].possiblyEvaluate(t,r,s);return l}}class Wi{constructor(t,r,s){this.property=t,this.value=r,this.parameters=s}isConstant(){return this.value.kind==="constant"}constantOr(t){return this.value.kind==="constant"?this.value.value:t}evaluate(t,r,s,l){return this.property.evaluate(this.value,this.parameters,t,r,s,l)}}class jn{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class Le{constructor(t){this.specification=t}possiblyEvaluate(t,r){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(r)}interpolate(t,r,s){const l=Oi[this.specification.type];return l?l(t,r,s):t}}class Ne{constructor(t,r){this.specification=t,this.overrides=r}possiblyEvaluate(t,r,s,l){return new Wi(this,t.expression.kind==="constant"||t.expression.kind==="camera"?{kind:"constant",value:t.expression.evaluate(r,null,{},s,l)}:t.expression,r)}interpolate(t,r,s){if(t.value.kind!=="constant"||r.value.kind!=="constant")return t;if(t.value.value===void 0||r.value.value===void 0)return new Wi(this,{kind:"constant",value:void 0},t.parameters);const l=Oi[this.specification.type];if(l){const d=l(t.value.value,r.value.value,s);return new Wi(this,{kind:"constant",value:d},t.parameters)}return t}evaluate(t,r,s,l,d,p){return t.kind==="constant"?t.value:t.evaluate(r,s,l,d,p)}}class vs extends Ne{possiblyEvaluate(t,r,s,l){if(t.value===void 0)return new Wi(this,{kind:"constant",value:void 0},r);if(t.expression.kind==="constant"){const d=t.expression.evaluate(r,null,{},s,l),p=t.property.specification.type==="resolvedImage"&&typeof d!="string"?d.name:d,m=this._calculate(p,p,p,r);return new Wi(this,{kind:"constant",value:m},r)}if(t.expression.kind==="camera"){const d=this._calculate(t.expression.evaluate({zoom:r.zoom-1}),t.expression.evaluate({zoom:r.zoom}),t.expression.evaluate({zoom:r.zoom+1}),r);return new Wi(this,{kind:"constant",value:d},r)}return new Wi(this,t.expression,r)}evaluate(t,r,s,l,d,p){if(t.kind==="source"){const m=t.evaluate(r,s,l,d,p);return this._calculate(m,m,m,r)}return t.kind==="composite"?this._calculate(t.evaluate({zoom:Math.floor(r.zoom)-1},s,l),t.evaluate({zoom:Math.floor(r.zoom)},s,l),t.evaluate({zoom:Math.floor(r.zoom)+1},s,l),r):t.value}_calculate(t,r,s,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:t,to:r}:{from:s,to:r}}interpolate(t){return t}}class ma{constructor(t){this.specification=t}possiblyEvaluate(t,r,s,l){if(t.value!==void 0){if(t.expression.kind==="constant"){const d=t.expression.evaluate(r,null,{},s,l);return this._calculate(d,d,d,r)}return this._calculate(t.expression.evaluate(new yt(Math.floor(r.zoom-1),r)),t.expression.evaluate(new yt(Math.floor(r.zoom),r)),t.expression.evaluate(new yt(Math.floor(r.zoom+1),r)),r)}}_calculate(t,r,s,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:t,to:r}:{from:s,to:r}}interpolate(t){return t}}class _a{constructor(t){this.specification=t}possiblyEvaluate(t,r,s,l){return!!t.expression.evaluate(r,null,{},s,l)}interpolate(){return!1}}class ui{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const r in t){const s=t[r];s.specification.overridable&&this.overridableProperties.push(r);const l=this.defaultPropertyValues[r]=new da(s,void 0),d=this.defaultTransitionablePropertyValues[r]=new pa(s);this.defaultTransitioningPropertyValues[r]=d.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=l.possiblyEvaluate({})}}}Ae("DataDrivenProperty",Ne),Ae("DataConstantProperty",Le),Ae("CrossFadedDataDrivenProperty",vs),Ae("CrossFadedProperty",ma),Ae("ColorRampProperty",_a);const Ql="-transition";class Ki extends Pr{constructor(t,r){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},t.type!=="custom"&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,t.type!=="background"&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),r.layout&&(this._unevaluatedLayout=new fa(r.layout)),r.paint)){this._transitionablePaint=new Po(r.paint);for(const s in t.paint)this.setPaintProperty(s,t.paint[s],{validate:!1});for(const s in t.layout)this.setLayoutProperty(s,t.layout[s],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new jn(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return t==="visibility"?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,r,s={}){r!=null&&this._validate(To,`layers.${this.id}.layout.${t}`,t,r,s)||(t!=="visibility"?this._unevaluatedLayout.setValue(t,r):this.visibility=r)}getPaintProperty(t){return t.endsWith(Ql)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,r,s={}){if(r!=null&&this._validate(Nl,`layers.${this.id}.paint.${t}`,t,r,s))return!1;if(t.endsWith(Ql))return this._transitionablePaint.setTransition(t.slice(0,-11),r||void 0),!1;{const l=this._transitionablePaint._values[t],d=l.property.specification["property-type"]==="cross-faded-data-driven",p=l.value.isDataDriven(),m=l.value;this._transitionablePaint.setValue(t,r),this._handleSpecialPaintPropertyUpdate(t);const g=this._transitionablePaint._values[t].value;return g.isDataDriven()||p||d||this._handleOverridablePaintPropertyUpdate(t,m,g)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,r,s){return!1}isHidden(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&t>=this.maxzoom)||this.visibility==="none"}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,r){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,r)}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),Zr(t,(r,s)=>!(r===void 0||s==="layout"&&!Object.keys(r).length||s==="paint"&&!Object.keys(r).length))}_validate(t,r,s,l,d={}){return(!d||d.validate!==!1)&&Vl(this,t.call(Fn,{key:r,layerType:this.type,objectKey:s,value:l,styleSpec:j,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const r=this.paint.get(t);if(r instanceof Wi&&An(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}}const Zc={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class bs{constructor(t,r){this._structArray=t,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class ht{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,r){return t._trim(),r&&(t.isTransferred=!0,r.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const r=Object.create(this.prototype);return r.arrayBuffer=t.arrayBuffer,r.length=t.length,r.capacity=t.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function kt(n,t=1){let r=0,s=0;return{members:n.map(l=>{const d=Zc[l.type].BYTES_PER_ELEMENT,p=r=ec(r,Math.max(t,d)),m=l.components||1;return s=Math.max(s,d),r+=d*m,{name:l.name,type:l.type,components:m,offset:p}}),size:ec(r,Math.max(s,t)),alignment:t}}function ec(n,t){return Math.ceil(n/t)*t}class ws extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){const l=2*t;return this.int16[l+0]=r,this.int16[l+1]=s,t}}ws.prototype.bytesPerElement=4,Ae("StructArrayLayout2i4",ws);class Ts extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){const d=3*t;return this.int16[d+0]=r,this.int16[d+1]=s,this.int16[d+2]=l,t}}Ts.prototype.bytesPerElement=6,Ae("StructArrayLayout3i6",Ts);class Io extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l){const d=this.length;return this.resize(d+1),this.emplace(d,t,r,s,l)}emplace(t,r,s,l,d){const p=4*t;return this.int16[p+0]=r,this.int16[p+1]=s,this.int16[p+2]=l,this.int16[p+3]=d,t}}Io.prototype.bytesPerElement=8,Ae("StructArrayLayout4i8",Io);class Co extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,d,p){const m=this.length;return this.resize(m+1),this.emplace(m,t,r,s,l,d,p)}emplace(t,r,s,l,d,p,m){const g=6*t;return this.int16[g+0]=r,this.int16[g+1]=s,this.int16[g+2]=l,this.int16[g+3]=d,this.int16[g+4]=p,this.int16[g+5]=m,t}}Co.prototype.bytesPerElement=12,Ae("StructArrayLayout2i4i12",Co);class or extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,d,p){const m=this.length;return this.resize(m+1),this.emplace(m,t,r,s,l,d,p)}emplace(t,r,s,l,d,p,m){const g=4*t,x=8*t;return this.int16[g+0]=r,this.int16[g+1]=s,this.uint8[x+4]=l,this.uint8[x+5]=d,this.uint8[x+6]=p,this.uint8[x+7]=m,t}}or.prototype.bytesPerElement=8,Ae("StructArrayLayout2i4ub8",or);class Nn extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){const l=2*t;return this.float32[l+0]=r,this.float32[l+1]=s,t}}Nn.prototype.bytesPerElement=8,Ae("StructArrayLayout2f8",Nn);class Ps extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,d,p,m,g,x,b){const w=this.length;return this.resize(w+1),this.emplace(w,t,r,s,l,d,p,m,g,x,b)}emplace(t,r,s,l,d,p,m,g,x,b,w){const M=10*t;return this.uint16[M+0]=r,this.uint16[M+1]=s,this.uint16[M+2]=l,this.uint16[M+3]=d,this.uint16[M+4]=p,this.uint16[M+5]=m,this.uint16[M+6]=g,this.uint16[M+7]=x,this.uint16[M+8]=b,this.uint16[M+9]=w,t}}Ps.prototype.bytesPerElement=20,Ae("StructArrayLayout10ui20",Ps);class ga extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,d,p,m,g,x,b,w,M){const C=this.length;return this.resize(C+1),this.emplace(C,t,r,s,l,d,p,m,g,x,b,w,M)}emplace(t,r,s,l,d,p,m,g,x,b,w,M,C){const E=12*t;return this.int16[E+0]=r,this.int16[E+1]=s,this.int16[E+2]=l,this.int16[E+3]=d,this.uint16[E+4]=p,this.uint16[E+5]=m,this.uint16[E+6]=g,this.uint16[E+7]=x,this.int16[E+8]=b,this.int16[E+9]=w,this.int16[E+10]=M,this.int16[E+11]=C,t}}ga.prototype.bytesPerElement=24,Ae("StructArrayLayout4i4ui4i24",ga);class Ms extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){const d=3*t;return this.float32[d+0]=r,this.float32[d+1]=s,this.float32[d+2]=l,t}}Ms.prototype.bytesPerElement=12,Ae("StructArrayLayout3f12",Ms);class Eo extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.uint32[1*t+0]=r,t}}Eo.prototype.bytesPerElement=4,Ae("StructArrayLayout1ul4",Eo);class Vn extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,d,p,m,g,x){const b=this.length;return this.resize(b+1),this.emplace(b,t,r,s,l,d,p,m,g,x)}emplace(t,r,s,l,d,p,m,g,x,b){const w=10*t,M=5*t;return this.int16[w+0]=r,this.int16[w+1]=s,this.int16[w+2]=l,this.int16[w+3]=d,this.int16[w+4]=p,this.int16[w+5]=m,this.uint32[M+3]=g,this.uint16[w+8]=x,this.uint16[w+9]=b,t}}Vn.prototype.bytesPerElement=20,Ae("StructArrayLayout6i1ul2ui20",Vn);class fn extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,d,p){const m=this.length;return this.resize(m+1),this.emplace(m,t,r,s,l,d,p)}emplace(t,r,s,l,d,p,m){const g=6*t;return this.int16[g+0]=r,this.int16[g+1]=s,this.int16[g+2]=l,this.int16[g+3]=d,this.int16[g+4]=p,this.int16[g+5]=m,t}}fn.prototype.bytesPerElement=12,Ae("StructArrayLayout2i2i2i12",fn);class Ao extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,d){const p=this.length;return this.resize(p+1),this.emplace(p,t,r,s,l,d)}emplace(t,r,s,l,d,p){const m=4*t,g=8*t;return this.float32[m+0]=r,this.float32[m+1]=s,this.float32[m+2]=l,this.int16[g+6]=d,this.int16[g+7]=p,t}}Ao.prototype.bytesPerElement=16,Ae("StructArrayLayout2f1f2i16",Ao);class ya extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,d,p){const m=this.length;return this.resize(m+1),this.emplace(m,t,r,s,l,d,p)}emplace(t,r,s,l,d,p,m){const g=16*t,x=4*t,b=8*t;return this.uint8[g+0]=r,this.uint8[g+1]=s,this.float32[x+1]=l,this.float32[x+2]=d,this.int16[b+6]=p,this.int16[b+7]=m,t}}ya.prototype.bytesPerElement=16,Ae("StructArrayLayout2ub2f2i16",ya);class Ar extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){const d=3*t;return this.uint16[d+0]=r,this.uint16[d+1]=s,this.uint16[d+2]=l,t}}Ar.prototype.bytesPerElement=6,Ae("StructArrayLayout3ui6",Ar);class zo extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s,l,d,p,m,g,x,b,w,M,C,E,k,O,Z){const ee=this.length;return this.resize(ee+1),this.emplace(ee,t,r,s,l,d,p,m,g,x,b,w,M,C,E,k,O,Z)}emplace(t,r,s,l,d,p,m,g,x,b,w,M,C,E,k,O,Z,ee){const q=24*t,I=12*t,F=48*t;return this.int16[q+0]=r,this.int16[q+1]=s,this.uint16[q+2]=l,this.uint16[q+3]=d,this.uint32[I+2]=p,this.uint32[I+3]=m,this.uint32[I+4]=g,this.uint16[q+10]=x,this.uint16[q+11]=b,this.uint16[q+12]=w,this.float32[I+7]=M,this.float32[I+8]=C,this.uint8[F+36]=E,this.uint8[F+37]=k,this.uint8[F+38]=O,this.uint32[I+10]=Z,this.int16[q+22]=ee,t}}zo.prototype.bytesPerElement=48,Ae("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",zo);class ko extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s,l,d,p,m,g,x,b,w,M,C,E,k,O,Z,ee,q,I,F,H,ae,xe,ce,pe,we,be){const Te=this.length;return this.resize(Te+1),this.emplace(Te,t,r,s,l,d,p,m,g,x,b,w,M,C,E,k,O,Z,ee,q,I,F,H,ae,xe,ce,pe,we,be)}emplace(t,r,s,l,d,p,m,g,x,b,w,M,C,E,k,O,Z,ee,q,I,F,H,ae,xe,ce,pe,we,be,Te){const _e=32*t,ke=16*t;return this.int16[_e+0]=r,this.int16[_e+1]=s,this.int16[_e+2]=l,this.int16[_e+3]=d,this.int16[_e+4]=p,this.int16[_e+5]=m,this.int16[_e+6]=g,this.int16[_e+7]=x,this.uint16[_e+8]=b,this.uint16[_e+9]=w,this.uint16[_e+10]=M,this.uint16[_e+11]=C,this.uint16[_e+12]=E,this.uint16[_e+13]=k,this.uint16[_e+14]=O,this.uint16[_e+15]=Z,this.uint16[_e+16]=ee,this.uint16[_e+17]=q,this.uint16[_e+18]=I,this.uint16[_e+19]=F,this.uint16[_e+20]=H,this.uint16[_e+21]=ae,this.uint16[_e+22]=xe,this.uint32[ke+12]=ce,this.float32[ke+13]=pe,this.float32[ke+14]=we,this.uint16[_e+30]=be,this.uint16[_e+31]=Te,t}}ko.prototype.bytesPerElement=64,Ae("StructArrayLayout8i15ui1ul2f2ui64",ko);class Ss extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.float32[1*t+0]=r,t}}Ss.prototype.bytesPerElement=4,Ae("StructArrayLayout1f4",Ss);class Do extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){const d=3*t;return this.uint16[6*t+0]=r,this.float32[d+1]=s,this.float32[d+2]=l,t}}Do.prototype.bytesPerElement=12,Ae("StructArrayLayout1ui2f12",Do);class h extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){const d=4*t;return this.uint32[2*t+0]=r,this.uint16[d+2]=s,this.uint16[d+3]=l,t}}h.prototype.bytesPerElement=8,Ae("StructArrayLayout1ul2ui8",h);class e extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){const l=2*t;return this.uint16[l+0]=r,this.uint16[l+1]=s,t}}e.prototype.bytesPerElement=4,Ae("StructArrayLayout2ui4",e);class i extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.uint16[1*t+0]=r,t}}i.prototype.bytesPerElement=2,Ae("StructArrayLayout1ui2",i);class a extends ht{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s,l){const d=this.length;return this.resize(d+1),this.emplace(d,t,r,s,l)}emplace(t,r,s,l,d){const p=4*t;return this.float32[p+0]=r,this.float32[p+1]=s,this.float32[p+2]=l,this.float32[p+3]=d,t}}a.prototype.bytesPerElement=16,Ae("StructArrayLayout4f16",a);class o extends bs{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 Oe(this.anchorPointX,this.anchorPointY)}}o.prototype.size=20;class u extends Vn{get(t){return new o(this,t)}}Ae("CollisionBoxArray",u);class f extends bs{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}f.prototype.size=48;class _ extends zo{get(t){return new f(this,t)}}Ae("PlacedSymbolArray",_);class y extends bs{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}y.prototype.size=64;class v extends ko{get(t){return new y(this,t)}}Ae("SymbolInstanceArray",v);class T extends Ss{getoffsetX(t){return this.float32[1*t+0]}}Ae("GlyphOffsetArray",T);class P extends Ts{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Ae("SymbolLineVertexArray",P);class S extends bs{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]}}S.prototype.size=12;class A extends Do{get(t){return new S(this,t)}}Ae("TextAnchorOffsetArray",A);class R extends bs{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]}}R.prototype.size=8;class V extends h{get(t){return new R(this,t)}}Ae("FeatureIndexArray",V);class N extends ws{}class U extends ws{}class G extends ws{}class X extends Co{}class W extends or{}class K extends Nn{}class Q extends Ps{}class J extends ga{}class se extends Ms{}class oe extends Eo{}class me extends fn{}class ye extends ya{}class de extends Ar{}class Se extends e{}const Pe=kt([{name:"a_pos",components:2,type:"Int16"}],4),{members:ve}=Pe;class Ee{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t}prepareSegment(t,r,s,l){const d=this.segments[this.segments.length-1];return t>Ee.MAX_VERTEX_ARRAY_LENGTH&&ti(`Max vertices per segment is ${Ee.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Ee.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!d||d.vertexLength+t>Ee.MAX_VERTEX_ARRAY_LENGTH||d.sortKey!==l?this.createNewSegment(r,s,l):d}createNewSegment(t,r,s){const l={vertexOffset:t.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0,vaos:{}};return s!==void 0&&(l.sortKey=s),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(l),l}getOrCreateLatestSegment(t,r,s){return this.prepareSegment(0,t,r,s)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const t of this.segments)for(const r in t.vaos)t.vaos[r].destroy()}static simpleSegment(t,r,s,l){return new Ee([{vertexOffset:t,primitiveOffset:r,vertexLength:s,primitiveLength:l,vaos:{},sortKey:0}])}}function $e(n,t){return 256*(n=Li(Math.floor(n),0,255))+Li(Math.floor(t),0,255)}Ee.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Ae("SegmentVector",Ee);const et=kt([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var xt,st,vt,at={exports:{}},nt={exports:{}},ot={exports:{}},Kt=function(){if(vt)return at.exports;vt=1;var n=(xt||(xt=1,nt.exports=function(r,s){var l,d,p,m,g,x,b,w;for(d=r.length-(l=3&r.length),p=s,g=3432918353,x=461845907,w=0;w<d;)b=255&r.charCodeAt(w)|(255&r.charCodeAt(++w))<<8|(255&r.charCodeAt(++w))<<16|(255&r.charCodeAt(++w))<<24,++w,p=27492+(65535&(m=5*(65535&(p=(p^=b=(65535&(b=(b=(65535&b)*g+(((b>>>16)*g&65535)<<16)&4294967295)<<15|b>>>17))*x+(((b>>>16)*x&65535)<<16)&4294967295)<<13|p>>>19))+((5*(p>>>16)&65535)<<16)&4294967295))+((58964+(m>>>16)&65535)<<16);switch(b=0,l){case 3:b^=(255&r.charCodeAt(w+2))<<16;case 2:b^=(255&r.charCodeAt(w+1))<<8;case 1:p^=b=(65535&(b=(b=(65535&(b^=255&r.charCodeAt(w)))*g+(((b>>>16)*g&65535)<<16)&4294967295)<<15|b>>>17))*x+(((b>>>16)*x&65535)<<16)&4294967295}return p^=r.length,p=2246822507*(65535&(p^=p>>>16))+((2246822507*(p>>>16)&65535)<<16)&4294967295,p=3266489909*(65535&(p^=p>>>13))+((3266489909*(p>>>16)&65535)<<16)&4294967295,(p^=p>>>16)>>>0}),nt.exports),t=(st||(st=1,ot.exports=function(r,s){for(var l,d=r.length,p=s^d,m=0;d>=4;)l=1540483477*(65535&(l=255&r.charCodeAt(m)|(255&r.charCodeAt(++m))<<8|(255&r.charCodeAt(++m))<<16|(255&r.charCodeAt(++m))<<24))+((1540483477*(l>>>16)&65535)<<16),p=1540483477*(65535&p)+((1540483477*(p>>>16)&65535)<<16)^(l=1540483477*(65535&(l^=l>>>24))+((1540483477*(l>>>16)&65535)<<16)),d-=4,++m;switch(d){case 3:p^=(255&r.charCodeAt(m+2))<<16;case 2:p^=(255&r.charCodeAt(m+1))<<8;case 1:p=1540483477*(65535&(p^=255&r.charCodeAt(m)))+((1540483477*(p>>>16)&65535)<<16)}return p=1540483477*(65535&(p^=p>>>13))+((1540483477*(p>>>16)&65535)<<16),(p^=p>>>15)>>>0}),ot.exports);return at.exports=n,at.exports.murmur3=n,at.exports.murmur2=t,at.exports}(),Lt=Pi(Kt);class Bt{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,r,s,l){this.ids.push(ci(t)),this.positions.push(r,s,l)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const r=ci(t);let s=0,l=this.ids.length-1;for(;s<l;){const p=s+l>>1;this.ids[p]>=r?l=p:s=p+1}const d=[];for(;this.ids[s]===r;)d.push({index:this.positions[3*s],start:this.positions[3*s+1],end:this.positions[3*s+2]}),s++;return d}static serialize(t,r){const s=new Float64Array(t.ids),l=new Uint32Array(t.positions);return lr(s,l,0,s.length-1),r&&r.push(s.buffer,l.buffer),{ids:s,positions:l}}static deserialize(t){const r=new Bt;return r.ids=t.ids,r.positions=t.positions,r.indexed=!0,r}}function ci(n){const t=+n;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:Lt(String(n))}function lr(n,t,r,s){for(;r<s;){const l=n[r+s>>1];let d=r-1,p=s+1;for(;;){do d++;while(n[d]<l);do p--;while(n[p]>l);if(d>=p)break;Yi(n,d,p),Yi(t,3*d,3*p),Yi(t,3*d+1,3*p+1),Yi(t,3*d+2,3*p+2)}p-r<s-p?(lr(n,t,r,p),r=p+1):(lr(n,t,p+1,s),s=p)}}function Yi(n,t,r){const s=n[t];n[t]=n[r],n[r]=s}Ae("FeaturePositionMap",Bt);class yi{constructor(t,r){this.gl=t.gl,this.location=r}}class cr extends yi{constructor(t,r){super(t,r),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class Is extends yi{constructor(t,r){super(t,r),this.current=[0,0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}}class Cs extends yi{constructor(t,r){super(t,r),this.current=Xe.transparent}set(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}}const Un=new Float32Array(16);function di(n){return[$e(255*n.r,255*n.g),$e(255*n.b,255*n.a)]}class ki{constructor(t,r,s){this.value=t,this.uniformNames=r.map(l=>`u_${l}`),this.type=s}setUniform(t,r,s){t.set(s.constantOr(this.value))}getBinding(t,r,s){return this.type==="color"?new Cs(t,r):new cr(t,r)}}class Di{constructor(t,r){this.uniformNames=r.map(s=>`u_${s}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=t.tlbr}setUniform(t,r,s,l){const d=l==="u_pattern_to"?this.patternTo:l==="u_pattern_from"?this.patternFrom:l==="u_pixel_ratio_to"?this.pixelRatioTo:l==="u_pixel_ratio_from"?this.pixelRatioFrom:null;d&&t.set(d)}getBinding(t,r,s){return s.substr(0,9)==="u_pattern"?new Is(t,r):new cr(t,r)}}class xi{constructor(t,r,s,l){this.expression=t,this.type=s,this.maxValue=0,this.paintVertexAttributes=r.map(d=>({name:`a_${d}`,type:"Float32",components:s==="color"?2:1,offset:0})),this.paintVertexArray=new l}populatePaintArray(t,r,s,l,d){const p=this.paintVertexArray.length,m=this.expression.evaluate(new yt(0),r,{},l,[],d);this.paintVertexArray.resize(t),this._setPaintValue(p,t,m)}updatePaintArray(t,r,s,l){const d=this.expression.evaluate({zoom:0},s,l);this._setPaintValue(t,r,d)}_setPaintValue(t,r,s){if(this.type==="color"){const l=di(s);for(let d=t;d<r;d++)this.paintVertexArray.emplace(d,l[0],l[1])}else{for(let l=t;l<r;l++)this.paintVertexArray.emplace(l,s);this.maxValue=Math.max(this.maxValue,Math.abs(s))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class lt{constructor(t,r,s,l,d,p){this.expression=t,this.uniformNames=r.map(m=>`u_${m}_t`),this.type=s,this.useIntegerZoom=l,this.zoom=d,this.maxValue=0,this.paintVertexAttributes=r.map(m=>({name:`a_${m}`,type:"Float32",components:s==="color"?4:2,offset:0})),this.paintVertexArray=new p}populatePaintArray(t,r,s,l,d){const p=this.expression.evaluate(new yt(this.zoom),r,{},l,[],d),m=this.expression.evaluate(new yt(this.zoom+1),r,{},l,[],d),g=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(g,t,p,m)}updatePaintArray(t,r,s,l){const d=this.expression.evaluate({zoom:this.zoom},s,l),p=this.expression.evaluate({zoom:this.zoom+1},s,l);this._setPaintValue(t,r,d,p)}_setPaintValue(t,r,s,l){if(this.type==="color"){const d=di(s),p=di(l);for(let m=t;m<r;m++)this.paintVertexArray.emplace(m,d[0],d[1],p[0],p[1])}else{for(let d=t;d<r;d++)this.paintVertexArray.emplace(d,s,l);this.maxValue=Math.max(this.maxValue,Math.abs(s),Math.abs(l))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,r){const s=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,l=Li(this.expression.interpolationFactor(s,this.zoom,this.zoom+1),0,1);t.set(l)}getBinding(t,r,s){return new cr(t,r)}}class bt{constructor(t,r,s,l,d,p){this.expression=t,this.type=r,this.useIntegerZoom=s,this.zoom=l,this.layerId=p,this.zoomInPaintVertexArray=new d,this.zoomOutPaintVertexArray=new d}populatePaintArray(t,r,s){const l=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(l,t,r.patterns&&r.patterns[this.layerId],s)}updatePaintArray(t,r,s,l,d){this._setPaintValues(t,r,s.patterns&&s.patterns[this.layerId],d)}_setPaintValues(t,r,s,l){if(!l||!s)return;const{min:d,mid:p,max:m}=s,g=l[d],x=l[p],b=l[m];if(g&&x&&b)for(let w=t;w<r;w++)this.zoomInPaintVertexArray.emplace(w,x.tl[0],x.tl[1],x.br[0],x.br[1],g.tl[0],g.tl[1],g.br[0],g.br[1],x.pixelRatio,g.pixelRatio),this.zoomOutPaintVertexArray.emplace(w,x.tl[0],x.tl[1],x.br[0],x.br[1],b.tl[0],b.tl[1],b.br[0],b.br[1],x.pixelRatio,b.pixelRatio)}upload(t){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,et.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,et.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class vi{constructor(t,r,s){this.binders={},this._buffers=[];const l=[];for(const d in t.paint._values){if(!s(d))continue;const p=t.paint.get(d);if(!(p instanceof Wi&&An(p.property.specification)))continue;const m=Gc(d,t.type),g=p.value,x=p.property.specification.type,b=p.property.useIntegerZoom,w=p.property.specification["property-type"],M=w==="cross-faded"||w==="cross-faded-data-driven";if(g.kind==="constant")this.binders[d]=M?new Di(g.value,m):new ki(g.value,m,x),l.push(`/u_${d}`);else if(g.kind==="source"||M){const C=tc(d,x,"source");this.binders[d]=M?new bt(g,x,b,r,C,t.id):new xi(g,m,x,C),l.push(`/a_${d}`)}else{const C=tc(d,x,"composite");this.binders[d]=new lt(g,m,x,b,r,C),l.push(`/z_${d}`)}}this.cacheKey=l.sort().join("")}getMaxValue(t){const r=this.binders[t];return r instanceof xi||r instanceof lt?r.maxValue:0}populatePaintArrays(t,r,s,l,d){for(const p in this.binders){const m=this.binders[p];(m instanceof xi||m instanceof lt||m instanceof bt)&&m.populatePaintArray(t,r,s,l,d)}}setConstantPatternPositions(t,r){for(const s in this.binders){const l=this.binders[s];l instanceof Di&&l.setConstantPatternPositions(t,r)}}updatePaintArrays(t,r,s,l,d){let p=!1;for(const m in t){const g=r.getPositions(m);for(const x of g){const b=s.feature(x.index);for(const w in this.binders){const M=this.binders[w];if((M instanceof xi||M instanceof lt||M instanceof bt)&&M.expression.isStateDependent===!0){const C=l.paint.get(w);M.expression=C.value,M.updatePaintArray(x.start,x.end,b,t[m],d),p=!0}}}}return p}defines(){const t=[];for(const r in this.binders){const s=this.binders[r];(s instanceof ki||s instanceof Di)&&t.push(...s.uniformNames.map(l=>`#define HAS_UNIFORM_${l}`))}return t}getBinderAttributes(){const t=[];for(const r in this.binders){const s=this.binders[r];if(s instanceof xi||s instanceof lt)for(let l=0;l<s.paintVertexAttributes.length;l++)t.push(s.paintVertexAttributes[l].name);else if(s instanceof bt)for(let l=0;l<et.members.length;l++)t.push(et.members[l].name)}return t}getBinderUniforms(){const t=[];for(const r in this.binders){const s=this.binders[r];if(s instanceof ki||s instanceof Di||s instanceof lt)for(const l of s.uniformNames)t.push(l)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,r){const s=[];for(const l in this.binders){const d=this.binders[l];if(d instanceof ki||d instanceof Di||d instanceof lt){for(const p of d.uniformNames)if(r[p]){const m=d.getBinding(t,r[p],p);s.push({name:p,property:l,binding:m})}}}return s}setUniforms(t,r,s,l){for(const{name:d,property:p,binding:m}of r)this.binders[p].setUniform(m,l,s.get(p),d)}updatePaintBuffers(t){this._buffers=[];for(const r in this.binders){const s=this.binders[r];if(t&&s instanceof bt){const l=t.fromScale===2?s.zoomInPaintVertexBuffer:s.zoomOutPaintVertexBuffer;l&&this._buffers.push(l)}else(s instanceof xi||s instanceof lt)&&s.paintVertexBuffer&&this._buffers.push(s.paintVertexBuffer)}}upload(t){for(const r in this.binders){const s=this.binders[r];(s instanceof xi||s instanceof lt||s instanceof bt)&&s.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const r=this.binders[t];(r instanceof xi||r instanceof lt||r instanceof bt)&&r.destroy()}}}class Tt{constructor(t,r,s=()=>!0){this.programConfigurations={};for(const l of t)this.programConfigurations[l.id]=new vi(l,r,s);this.needsUpload=!1,this._featureMap=new Bt,this._bufferOffset=0}populatePaintArrays(t,r,s,l,d,p){for(const m in this.programConfigurations)this.programConfigurations[m].populatePaintArrays(t,r,l,d,p);r.id!==void 0&&this._featureMap.add(r.id,s,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,r,s,l){for(const d of s)this.needsUpload=this.programConfigurations[d.id].updatePaintArrays(t,this._featureMap,r,d,l)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}function Gc(n,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[n]||[n.replace(`${t}-`,"").replace(/-/g,"_")]}function tc(n,t,r){const s={color:{source:Nn,composite:a},number:{source:Ss,composite:Nn}},l=function(d){return{"line-pattern":{source:Q,composite:Q},"fill-pattern":{source:Q,composite:Q},"fill-extrusion-pattern":{source:Q,composite:Q}}[d]}(n);return l&&l[r]||s[t][r]}Ae("ConstantBinder",ki),Ae("CrossFadedConstantBinder",Di),Ae("SourceExpressionBinder",xi),Ae("CrossFadedCompositeBinder",bt),Ae("CompositeExpressionBinder",lt),Ae("ProgramConfiguration",vi,{omit:["_buffers"]}),Ae("ProgramConfigurationSet",Tt);const Ro=Math.pow(2,14)-1,ic=-Ro-1;function mn(n){const t=rt/n.extent,r=n.loadGeometry();for(let s=0;s<r.length;s++){const l=r[s];for(let d=0;d<l.length;d++){const p=l[d],m=Math.round(p.x*t),g=Math.round(p.y*t);p.x=Li(m,ic,Ro),p.y=Li(g,ic,Ro),(m<p.x||m>p.x+1||g<p.y||g>p.y+1)&&ti("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function _n(n,t){return{type:n.type,id:n.id,properties:n.properties,geometry:t?mn(n):[]}}const zr=-32768;function rc(n,t,r,s,l){n.emplaceBack(zr+8*t+s,zr+8*r+l)}class xa{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new U,this.indexArray=new de,this.segments=new Ee,this.programConfigurations=new Tt(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,s){const l=this.layers[0],d=[];let p=null,m=!1,g=l.type==="heatmap";if(l.type==="circle"){const b=l;p=b.layout.get("circle-sort-key"),m=!p.isConstant(),g=g||b.paint.get("circle-pitch-alignment")==="map"}const x=g?r.subdivisionGranularity.circle:1;for(const{feature:b,id:w,index:M,sourceLayerIndex:C}of t){const E=this.layers[0]._featureFilter.needGeometry,k=_n(b,E);if(!this.layers[0]._featureFilter.filter(new yt(this.zoom),k,s))continue;const O=m?p.evaluate(k,{},s):void 0,Z={id:w,properties:b.properties,type:b.type,sourceLayerIndex:C,index:M,geometry:E?k.geometry:mn(b),patterns:{},sortKey:O};d.push(Z)}m&&d.sort((b,w)=>b.sortKey-w.sortKey);for(const b of d){const{geometry:w,index:M,sourceLayerIndex:C}=b,E=t[M].feature;this.addFeature(b,w,M,s,x),r.featureIndex.insert(E,w,M,C,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ve),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,r,s,l,d=1){let p;switch(d){case 1:p=[0,7];break;case 3:p=[0,2,5,7];break;case 5:p=[0,1,3,4,6,7];break;case 7:p=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${d}; valid values are 1, 3, 5, 7.`)}const m=p.length;for(const g of r)for(const x of g){const b=x.x,w=x.y;if(b<0||b>=rt||w<0||w>=rt)continue;const M=this.segments.prepareSegment(m*m,this.layoutVertexArray,this.indexArray,t.sortKey),C=M.vertexLength;for(let E=0;E<m;E++)for(let k=0;k<m;k++)rc(this.layoutVertexArray,b,w,p[k],p[E]);for(let E=0;E<m-1;E++)for(let k=0;k<m-1;k++){const O=C+E*m+k,Z=C+(E+1)*m+k;this.indexArray.emplaceBack(O,Z+1,O+1),this.indexArray.emplaceBack(O,Z,Z+1)}M.vertexLength+=m*m,M.primitiveLength+=(m-1)*(m-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{},l)}}function Lo(n,t){for(let r=0;r<n.length;r++)if(va(t,n[r]))return!0;for(let r=0;r<t.length;r++)if(va(n,t[r]))return!0;return!!$c(n,t)}function Bo(n,t,r){return!!va(n,t)||!!qc(t,n,r)}function Fo(n,t){if(n.length===1)return Rh(t,n[0]);for(let r=0;r<t.length;r++){const s=t[r];for(let l=0;l<s.length;l++)if(va(n,s[l]))return!0}for(let r=0;r<n.length;r++)if(Rh(t,n[r]))return!0;for(let r=0;r<t.length;r++)if($c(n,t[r]))return!0;return!1}function Oo(n,t,r){if(n.length>1){if($c(n,t))return!0;for(let s=0;s<t.length;s++)if(qc(t[s],n,r))return!0}for(let s=0;s<n.length;s++)if(qc(n[s],t,r))return!0;return!1}function $c(n,t){if(n.length===0||t.length===0)return!1;for(let r=0;r<n.length-1;r++){const s=n[r],l=n[r+1];for(let d=0;d<t.length-1;d++)if(gd(s,l,t[d],t[d+1]))return!0}return!1}function gd(n,t,r,s){return Ot(n,r,s)!==Ot(t,r,s)&&Ot(n,t,r)!==Ot(n,t,s)}function qc(n,t,r){const s=r*r;if(t.length===1)return n.distSqr(t[0])<s;for(let l=1;l<t.length;l++)if(Dh(n,t[l-1],t[l])<s)return!0;return!1}function Dh(n,t,r){const s=t.distSqr(r);if(s===0)return n.distSqr(t);const l=((n.x-t.x)*(r.x-t.x)+(n.y-t.y)*(r.y-t.y))/s;return n.distSqr(l<0?t:l>1?r:r.sub(t)._mult(l)._add(t))}function Rh(n,t){let r,s,l,d=!1;for(let p=0;p<n.length;p++){r=n[p];for(let m=0,g=r.length-1;m<r.length;g=m++)s=r[m],l=r[g],s.y>t.y!=l.y>t.y&&t.x<(l.x-s.x)*(t.y-s.y)/(l.y-s.y)+s.x&&(d=!d)}return d}function va(n,t){let r=!1;for(let s=0,l=n.length-1;s<n.length;l=s++){const d=n[s],p=n[l];d.y>t.y!=p.y>t.y&&t.x<(p.x-d.x)*(t.y-d.y)/(p.y-d.y)+d.x&&(r=!r)}return r}function yd(n,t,r){const s=r[0],l=r[2];if(n.x<s.x&&t.x<s.x||n.x>l.x&&t.x>l.x||n.y<s.y&&t.y<s.y||n.y>l.y&&t.y>l.y)return!1;const d=Ot(n,t,r[0]);return d!==Ot(n,t,r[1])||d!==Ot(n,t,r[2])||d!==Ot(n,t,r[3])}function jo(n,t,r){const s=t.paint.get(n).value;return s.kind==="constant"?s.value:r.programConfigurations.get(t.id).getMaxValue(n)}function nc(n){return Math.sqrt(n[0]*n[0]+n[1]*n[1])}function sc(n,t,r,s,l){if(!t[0]&&!t[1])return n;const d=Oe.convert(t)._mult(l);r==="viewport"&&d._rotate(-s);const p=[];for(let m=0;m<n.length;m++)p.push(n[m].sub(d));return p}let Lh,Bh;Ae("CircleBucket",xa,{omit:["layers"]});var xd={get paint(){return Bh=Bh||new ui({"circle-radius":new Ne(j.paint_circle["circle-radius"]),"circle-color":new Ne(j.paint_circle["circle-color"]),"circle-blur":new Ne(j.paint_circle["circle-blur"]),"circle-opacity":new Ne(j.paint_circle["circle-opacity"]),"circle-translate":new Le(j.paint_circle["circle-translate"]),"circle-translate-anchor":new Le(j.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Le(j.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Le(j.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Ne(j.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Ne(j.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Ne(j.paint_circle["circle-stroke-opacity"])})},get layout(){return Lh=Lh||new ui({"circle-sort-key":new Ne(j.layout_circle["circle-sort-key"])})}};class vd extends Ki{constructor(t){super(t,xd)}createBucket(t){return new xa(t)}queryRadius(t){const r=t;return jo("circle-radius",this,r)+jo("circle-stroke-width",this,r)+nc(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:t,feature:r,featureState:s,geometry:l,transform:d,pixelsToTileUnits:p,pixelPosMatrix:m}){const g=sc(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-d.bearingInRadians,p),x=this.paint.get("circle-radius").evaluate(r,s)+this.paint.get("circle-stroke-width").evaluate(r,s),b=this.paint.get("circle-pitch-alignment")==="map",w=b?g:function(C,E){return C.map(k=>Fh(k,E))}(g,m),M=b?x*p:x;for(const C of l)for(const E of C){const k=b?E:Fh(E,m);let O=M;const Z=Ji([],[E.x,E.y,0,1],m);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?O*=Z[3]/d.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(O*=d.cameraToCenterDistance/Z[3]),Bo(w,k,O))return!0}return!1}}function Fh(n,t){const r=Ji([],[n.x,n.y,0,1],t);return new Oe(r[0]/r[3],r[1]/r[3])}class Oh extends xa{}let jh;Ae("HeatmapBucket",Oh,{omit:["layers"]});var bd={get paint(){return jh=jh||new ui({"heatmap-radius":new Ne(j.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Ne(j.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Le(j.paint_heatmap["heatmap-intensity"]),"heatmap-color":new _a(j.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Le(j.paint_heatmap["heatmap-opacity"])})}};function Hc(n,{width:t,height:r},s,l){if(l){if(l instanceof Uint8ClampedArray)l=new Uint8Array(l.buffer);else if(l.length!==t*r*s)throw new RangeError(`mismatched image size. expected: ${l.length} but got: ${t*r*s}`)}else l=new Uint8Array(t*r*s);return n.width=t,n.height=r,n.data=l,n}function Nh(n,{width:t,height:r},s){if(t===n.width&&r===n.height)return;const l=Hc({},{width:t,height:r},s);Xc(n,l,{x:0,y:0},{x:0,y:0},{width:Math.min(n.width,t),height:Math.min(n.height,r)},s),n.width=t,n.height=r,n.data=l.data}function Xc(n,t,r,s,l,d){if(l.width===0||l.height===0)return t;if(l.width>n.width||l.height>n.height||r.x>n.width-l.width||r.y>n.height-l.height)throw new RangeError("out of range source coordinates for image copy");if(l.width>t.width||l.height>t.height||s.x>t.width-l.width||s.y>t.height-l.height)throw new RangeError("out of range destination coordinates for image copy");const p=n.data,m=t.data;if(p===m)throw new Error("srcData equals dstData, so image is already copied");for(let g=0;g<l.height;g++){const x=((r.y+g)*n.width+r.x)*d,b=((s.y+g)*t.width+s.x)*d;for(let w=0;w<l.width*d;w++)m[b+w]=p[x+w]}return t}class No{constructor(t,r){Hc(this,t,1,r)}resize(t){Nh(this,t,1)}clone(){return new No({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,r,s,l,d){Xc(t,r,s,l,d,1)}}class Ni{constructor(t,r){Hc(this,t,4,r)}resize(t){Nh(this,t,4)}replace(t,r){r?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new Ni({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,r,s,l,d){Xc(t,r,s,l,d,4)}}function Vh(n){const t={},r=n.resolution||256,s=n.clips?n.clips.length:1,l=n.image||new Ni({width:r,height:s});if(Math.log(r)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${r}`);const d=(p,m,g)=>{t[n.evaluationKey]=g;const x=n.expression.evaluate(t);l.data[p+m+0]=Math.floor(255*x.r/x.a),l.data[p+m+1]=Math.floor(255*x.g/x.a),l.data[p+m+2]=Math.floor(255*x.b/x.a),l.data[p+m+3]=Math.floor(255*x.a)};if(n.clips)for(let p=0,m=0;p<s;++p,m+=4*r)for(let g=0,x=0;g<r;g++,x+=4){const b=g/(r-1),{start:w,end:M}=n.clips[p];d(m,x,w*(1-b)+M*b)}else for(let p=0,m=0;p<r;p++,m+=4)d(0,m,p/(r-1));return l}Ae("AlphaImage",No),Ae("RGBAImage",Ni);const Wc="big-fb";class wd extends Ki{createBucket(t){return new Oh(t)}constructor(t){super(t,bd),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Vh({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(Wc)&&this.heatmapFbos.delete(Wc)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}}let Uh;var Td={get paint(){return Uh=Uh||new ui({"hillshade-illumination-direction":new Le(j.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new Le(j.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Le(j.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Le(j.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Le(j.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Le(j.paint_hillshade["hillshade-accent-color"])})}};class Pd extends Ki{constructor(t){super(t,Td)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}}const Md=kt([{name:"a_pos",components:2,type:"Int16"}],4),{members:Sd}=Md;function Kc(n,t,r){const s=r.patternDependencies;let l=!1;for(const d of t){const p=d.paint.get(`${n}-pattern`);p.isConstant()||(l=!0);const m=p.constantOr(null);m&&(l=!0,s[m.to]=!0,s[m.from]=!0)}return l}function Yc(n,t,r,s,l){const d=l.patternDependencies;for(const p of t){const m=p.paint.get(`${n}-pattern`).value;if(m.kind!=="constant"){let g=m.evaluate({zoom:s-1},r,{},l.availableImages),x=m.evaluate({zoom:s},r,{},l.availableImages),b=m.evaluate({zoom:s+1},r,{},l.availableImages);g=g&&g.name?g.name:g,x=x&&x.name?x.name:x,b=b&&b.name?b.name:b,d[g]=!0,d[x]=!0,d[b]=!0,r.patterns[p.id]={min:g,mid:x,max:b}}}return r}function Zh(n,t,r,s,l){let d;if(l===function(p,m,g,x){let b=0;for(let w=m,M=g-x;w<g;w+=x)b+=(p[M]-p[w])*(p[w+1]+p[M+1]),M=w;return b}(n,t,r,s)>0)for(let p=t;p<r;p+=s)d=Hh(p/s|0,n[p],n[p+1],d);else for(let p=r-s;p>=t;p-=s)d=Hh(p/s|0,n[p],n[p+1],d);return d&&ba(d,d.next)&&(Go(d),d=d.next),d}function Es(n,t){if(!n)return n;t||(t=n);let r,s=n;do if(r=!1,s.steiner||!ba(s,s.next)&&Dt(s.prev,s,s.next)!==0)s=s.next;else{if(Go(s),s=t=s.prev,s===s.next)break;r=!0}while(r||s!==t);return t}function Vo(n,t,r,s,l,d,p){if(!n)return;!p&&d&&function(g,x,b,w){let M=g;do M.z===0&&(M.z=Jc(M.x,M.y,x,b,w)),M.prevZ=M.prev,M.nextZ=M.next,M=M.next;while(M!==g);M.prevZ.nextZ=null,M.prevZ=null,function(C){let E,k=1;do{let O,Z=C;C=null;let ee=null;for(E=0;Z;){E++;let q=Z,I=0;for(let H=0;H<k&&(I++,q=q.nextZ,q);H++);let F=k;for(;I>0||F>0&&q;)I!==0&&(F===0||!q||Z.z<=q.z)?(O=Z,Z=Z.nextZ,I--):(O=q,q=q.nextZ,F--),ee?ee.nextZ=O:C=O,O.prevZ=ee,ee=O;Z=q}ee.nextZ=null,k*=2}while(E>1)}(M)}(n,s,l,d);let m=n;for(;n.prev!==n.next;){const g=n.prev,x=n.next;if(d?Cd(n,s,l,d):Id(n))t.push(g.i,n.i,x.i),Go(n),n=x.next,m=x.next;else if((n=x)===m){p?p===1?Vo(n=Ed(Es(n),t),t,r,s,l,d,2):p===2&&Ad(n,t,r,s,l,d):Vo(Es(n),t,r,s,l,d,1);break}}}function Id(n){const t=n.prev,r=n,s=n.next;if(Dt(t,r,s)>=0)return!1;const l=t.x,d=r.x,p=s.x,m=t.y,g=r.y,x=s.y,b=Math.min(l,d,p),w=Math.min(m,g,x),M=Math.max(l,d,p),C=Math.max(m,g,x);let E=s.next;for(;E!==t;){if(E.x>=b&&E.x<=M&&E.y>=w&&E.y<=C&&Uo(l,m,d,g,p,x,E.x,E.y)&&Dt(E.prev,E,E.next)>=0)return!1;E=E.next}return!0}function Cd(n,t,r,s){const l=n.prev,d=n,p=n.next;if(Dt(l,d,p)>=0)return!1;const m=l.x,g=d.x,x=p.x,b=l.y,w=d.y,M=p.y,C=Math.min(m,g,x),E=Math.min(b,w,M),k=Math.max(m,g,x),O=Math.max(b,w,M),Z=Jc(C,E,t,r,s),ee=Jc(k,O,t,r,s);let q=n.prevZ,I=n.nextZ;for(;q&&q.z>=Z&&I&&I.z<=ee;){if(q.x>=C&&q.x<=k&&q.y>=E&&q.y<=O&&q!==l&&q!==p&&Uo(m,b,g,w,x,M,q.x,q.y)&&Dt(q.prev,q,q.next)>=0||(q=q.prevZ,I.x>=C&&I.x<=k&&I.y>=E&&I.y<=O&&I!==l&&I!==p&&Uo(m,b,g,w,x,M,I.x,I.y)&&Dt(I.prev,I,I.next)>=0))return!1;I=I.nextZ}for(;q&&q.z>=Z;){if(q.x>=C&&q.x<=k&&q.y>=E&&q.y<=O&&q!==l&&q!==p&&Uo(m,b,g,w,x,M,q.x,q.y)&&Dt(q.prev,q,q.next)>=0)return!1;q=q.prevZ}for(;I&&I.z<=ee;){if(I.x>=C&&I.x<=k&&I.y>=E&&I.y<=O&&I!==l&&I!==p&&Uo(m,b,g,w,x,M,I.x,I.y)&&Dt(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function Ed(n,t){let r=n;do{const s=r.prev,l=r.next.next;!ba(s,l)&&$h(s,r,r.next,l)&&Zo(s,l)&&Zo(l,s)&&(t.push(s.i,r.i,l.i),Go(r),Go(r.next),r=n=l),r=r.next}while(r!==n);return Es(r)}function Ad(n,t,r,s,l,d){let p=n;do{let m=p.next.next;for(;m!==p.prev;){if(p.i!==m.i&&Ld(p,m)){let g=qh(p,m);return p=Es(p,p.next),g=Es(g,g.next),Vo(p,t,r,s,l,d,0),void Vo(g,t,r,s,l,d,0)}m=m.next}p=p.next}while(p!==n)}function zd(n,t){let r=n.x-t.x;return r===0&&(r=n.y-t.y,r===0)&&(r=(n.next.y-n.y)/(n.next.x-n.x)-(t.next.y-t.y)/(t.next.x-t.x)),r}function kd(n,t){const r=function(l,d){let p=d;const m=l.x,g=l.y;let x,b=-1/0;if(ba(l,p))return p;do{if(ba(l,p.next))return p.next;if(g<=p.y&&g>=p.next.y&&p.next.y!==p.y){const k=p.x+(g-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(k<=m&&k>b&&(b=k,x=p.x<p.next.x?p:p.next,k===m))return x}p=p.next}while(p!==d);if(!x)return null;const w=x,M=x.x,C=x.y;let E=1/0;p=x;do{if(m>=p.x&&p.x>=M&&m!==p.x&&Gh(g<C?m:b,g,M,C,g<C?b:m,g,p.x,p.y)){const k=Math.abs(g-p.y)/(m-p.x);Zo(p,l)&&(k<E||k===E&&(p.x>x.x||p.x===x.x&&Dd(x,p)))&&(x=p,E=k)}p=p.next}while(p!==w);return x}(n,t);if(!r)return t;const s=qh(r,n);return Es(s,s.next),Es(r,r.next)}function Dd(n,t){return Dt(n.prev,n,t.prev)<0&&Dt(t.next,n,n.next)<0}function Jc(n,t,r,s,l){return(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-r)*l|0)|n<<8))|n<<4))|n<<2))|n<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-s)*l|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Rd(n){let t=n,r=n;do(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next;while(t!==n);return r}function Gh(n,t,r,s,l,d,p,m){return(l-p)*(t-m)>=(n-p)*(d-m)&&(n-p)*(s-m)>=(r-p)*(t-m)&&(r-p)*(d-m)>=(l-p)*(s-m)}function Uo(n,t,r,s,l,d,p,m){return!(n===p&&t===m)&&Gh(n,t,r,s,l,d,p,m)}function Ld(n,t){return n.next.i!==t.i&&n.prev.i!==t.i&&!function(r,s){let l=r;do{if(l.i!==r.i&&l.next.i!==r.i&&l.i!==s.i&&l.next.i!==s.i&&$h(l,l.next,r,s))return!0;l=l.next}while(l!==r);return!1}(n,t)&&(Zo(n,t)&&Zo(t,n)&&function(r,s){let l=r,d=!1;const p=(r.x+s.x)/2,m=(r.y+s.y)/2;do l.y>m!=l.next.y>m&&l.next.y!==l.y&&p<(l.next.x-l.x)*(m-l.y)/(l.next.y-l.y)+l.x&&(d=!d),l=l.next;while(l!==r);return d}(n,t)&&(Dt(n.prev,n,t.prev)||Dt(n,t.prev,t))||ba(n,t)&&Dt(n.prev,n,n.next)>0&&Dt(t.prev,t,t.next)>0)}function Dt(n,t,r){return(t.y-n.y)*(r.x-t.x)-(t.x-n.x)*(r.y-t.y)}function ba(n,t){return n.x===t.x&&n.y===t.y}function $h(n,t,r,s){const l=oc(Dt(n,t,r)),d=oc(Dt(n,t,s)),p=oc(Dt(r,s,n)),m=oc(Dt(r,s,t));return l!==d&&p!==m||!(l!==0||!ac(n,r,t))||!(d!==0||!ac(n,s,t))||!(p!==0||!ac(r,n,s))||!(m!==0||!ac(r,t,s))}function ac(n,t,r){return t.x<=Math.max(n.x,r.x)&&t.x>=Math.min(n.x,r.x)&&t.y<=Math.max(n.y,r.y)&&t.y>=Math.min(n.y,r.y)}function oc(n){return n>0?1:n<0?-1:0}function Zo(n,t){return Dt(n.prev,n,n.next)<0?Dt(n,t,n.next)>=0&&Dt(n,n.prev,t)>=0:Dt(n,t,n.prev)<0||Dt(n,n.next,t)<0}function qh(n,t){const r=Qc(n.i,n.x,n.y),s=Qc(t.i,t.x,t.y),l=n.next,d=t.prev;return n.next=t,t.prev=n,r.next=l,l.prev=r,s.next=r,r.prev=s,d.next=s,s.prev=d,s}function Hh(n,t,r,s){const l=Qc(n,t,r);return s?(l.next=s.next,l.prev=s,s.next.prev=l,s.next=l):(l.prev=l,l.next=l),l}function Go(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Qc(n,t,r){return{i:n,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class wa{constructor(t,r){if(r>t)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=r}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<<t)),this._minGranularity,1)}}class lc{constructor(t){this.fill=t.fill,this.line=t.line,this.tile=t.tile,this.stencil=t.stencil,this.circle=t.circle}}lc.noSubdivision=new lc({fill:new wa(0,0),line:new wa(0,0),tile:new wa(0,0),stencil:new wa(0,0),circle:1}),Ae("SubdivisionGranularityExpression",wa),Ae("SubdivisionGranularitySetting",lc);const Ta=-32768,$o=32767;class Bd{constructor(t,r){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=rt/t,this._canonical=r}_getKey(t,r){return(t+=32768)<<16|(r+=32768)<<0}_vertexToIndex(t,r){if(t<-32768||r<-32768||t>32767||r>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const s=0|Math.round(t),l=0|Math.round(r),d=this._getKey(s,l);if(this._vertexDictionary.has(d))return this._vertexDictionary.get(d);const p=this._vertexBuffer.length/2;return this._vertexDictionary.set(d,p),this._vertexBuffer.push(s,l),p}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(l,d){const p=[];for(let m=0;m<d.length;m+=3){const g=d[m],x=d[m+1],b=d[m+2],w=l[2*g],M=l[2*g+1];(l[2*x]-w)*(l[2*b+1]-M)-(l[2*x+1]-M)*(l[2*b]-w)>0?(p.push(g),p.push(b),p.push(x)):(p.push(g),p.push(x),p.push(b))}return p}(this._vertexBuffer,t);const r=[],s=t.length;for(let l=0;l<s;l+=3){const d=[t[l+0],t[l+1],t[l+2]],p=[this._vertexBuffer[2*t[l+0]+0],this._vertexBuffer[2*t[l+0]+1],this._vertexBuffer[2*t[l+1]+0],this._vertexBuffer[2*t[l+1]+1],this._vertexBuffer[2*t[l+2]+0],this._vertexBuffer[2*t[l+2]+1]];let m=1/0,g=1/0,x=-1/0,b=-1/0;for(let k=0;k<3;k++){const O=p[2*k],Z=p[2*k+1];m=Math.min(m,O),x=Math.max(x,O),g=Math.min(g,Z),b=Math.max(b,Z)}if(m===x||g===b)continue;const w=Math.floor(m/this._granularityCellSize),M=Math.ceil(x/this._granularityCellSize),C=Math.floor(g/this._granularityCellSize),E=Math.ceil(b/this._granularityCellSize);if(w!==M||C!==E)for(let k=C;k<E;k++){const O=this._scanlineGenerateVertexRingForCellRow(k,p,d);Fd(this._vertexBuffer,O,r)}else r.push(...d)}return r}_scanlineGenerateVertexRingForCellRow(t,r,s){const l=t*this._granularityCellSize,d=l+this._granularityCellSize,p=[];for(let m=0;m<3;m++){const g=r[2*m],x=r[2*m+1],b=r[2*(m+1)%6],w=r[(2*(m+1)+1)%6],M=r[2*(m+2)%6],C=r[(2*(m+2)+1)%6],E=b-g,k=w-x,O=E===0,Z=k===0,ee=(l-x)/k,q=(d-x)/k,I=Math.min(ee,q),F=Math.max(ee,q);if(!Z&&(I>=1||F<=0)||Z&&(x<l||x>d)){w>=l&&w<=d&&p.push(s[(m+1)%3]);continue}!Z&&I>0&&p.push(this._vertexToIndex(g+E*I,x+k*I));const H=g+E*Math.max(I,0),ae=g+E*Math.min(F,1);O||this._generateIntraEdgeVertices(p,g,x,b,w,H,ae),!Z&&F<1&&p.push(this._vertexToIndex(g+E*F,x+k*F)),(Z||w>=l&&w<=d)&&p.push(s[(m+1)%3]),!Z&&(w<=l||w>=d)&&this._generateInterEdgeVertices(p,g,x,b,w,M,C,ae,l,d)}return p}_generateIntraEdgeVertices(t,r,s,l,d,p,m){const g=l-r,x=d-s,b=x===0,w=b?Math.min(r,l):Math.min(p,m),M=b?Math.max(r,l):Math.max(p,m),C=Math.floor(w/this._granularityCellSize)+1,E=Math.ceil(M/this._granularityCellSize)-1;if(b?r<l:p<m)for(let k=C;k<=E;k++){const O=k*this._granularityCellSize;t.push(this._vertexToIndex(O,s+x*(O-r)/g))}else for(let k=E;k>=C;k--){const O=k*this._granularityCellSize;t.push(this._vertexToIndex(O,s+x*(O-r)/g))}}_generateInterEdgeVertices(t,r,s,l,d,p,m,g,x,b){const w=d-s,M=p-l,C=m-d,E=(x-d)/C,k=(b-d)/C,O=Math.min(E,k),Z=Math.max(E,k),ee=l+M*O;let q=Math.floor(Math.min(ee,g)/this._granularityCellSize)+1,I=Math.ceil(Math.max(ee,g)/this._granularityCellSize)-1,F=g<ee;const H=C===0;if(H&&(m===x||m===b))return;if(H||O>=1||Z<=0){const xe=s-m,ce=p+(r-p)*Math.min((x-m)/xe,(b-m)/xe);q=Math.floor(Math.min(ce,g)/this._granularityCellSize)+1,I=Math.ceil(Math.max(ce,g)/this._granularityCellSize)-1,F=g<ce}const ae=w>0?b:x;if(F)for(let xe=q;xe<=I;xe++)t.push(this._vertexToIndex(xe*this._granularityCellSize,ae));else for(let xe=I;xe>=q;xe--)t.push(this._vertexToIndex(xe*this._granularityCellSize,ae))}_generateOutline(t){const r=[];for(const s of t){const l=As(s,this._granularity,!0),d=this._pointArrayToIndices(l),p=[];for(let m=1;m<d.length;m++)p.push(d[m-1]),p.push(d[m]);r.push(p)}return r}_handlePoles(t){let r=!1,s=!1;this._canonical&&(this._canonical.y===0&&(r=!0),this._canonical.y===(1<<this._canonical.z)-1&&(s=!0)),(r||s)&&this._fillPoles(t,r,s)}_ensureNoPoleVertices(){const t=this._vertexBuffer;for(let r=0;r<t.length;r+=2){const s=t[r+1];s===Ta&&(t[r+1]=-32767),s===$o&&(t[r+1]=32766)}}_generatePoleQuad(t,r,s,l,d,p){l>d!=(p===Ta)?(t.push(r),t.push(s),t.push(this._vertexToIndex(l,p)),t.push(s),t.push(this._vertexToIndex(d,p)),t.push(this._vertexToIndex(l,p))):(t.push(s),t.push(r),t.push(this._vertexToIndex(l,p)),t.push(this._vertexToIndex(d,p)),t.push(s),t.push(this._vertexToIndex(l,p)))}_fillPoles(t,r,s){const l=this._vertexBuffer,d=rt,p=t.length;for(let m=2;m<p;m+=3){const g=t[m-2],x=t[m-1],b=t[m],w=l[2*g],M=l[2*g+1],C=l[2*x],E=l[2*x+1],k=l[2*b],O=l[2*b+1];r&&(M===0&&E===0&&this._generatePoleQuad(t,g,x,w,C,Ta),E===0&&O===0&&this._generatePoleQuad(t,x,b,C,k,Ta),O===0&&M===0&&this._generatePoleQuad(t,b,g,k,w,Ta)),s&&(M===d&&E===d&&this._generatePoleQuad(t,g,x,w,C,$o),E===d&&O===d&&this._generatePoleQuad(t,x,b,C,k,$o),O===d&&M===d&&this._generatePoleQuad(t,b,g,k,w,$o))}}_initializeVertices(t){for(let r=0;r<t.length;r+=2)this._vertexToIndex(t[r],t[r+1])}subdividePolygonInternal(t,r){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:s,holeIndices:l}=function(m){const g=[],x=[];for(const b of m)if(b.length!==0){b!==m[0]&&g.push(x.length/2);for(let w=0;w<b.length;w++)x.push(b[w].x),x.push(b[w].y)}return{flattened:x,holeIndices:g}}(t);let d;this._initializeVertices(s);try{const m=function(x,b,w=2){const M=b&&b.length,C=M?b[0]*w:x.length;let E=Zh(x,0,C,w,!0);const k=[];if(!E||E.next===E.prev)return k;let O,Z,ee;if(M&&(E=function(q,I,F,H){const ae=[];for(let xe=0,ce=I.length;xe<ce;xe++){const pe=Zh(q,I[xe]*H,xe<ce-1?I[xe+1]*H:q.length,H,!1);pe===pe.next&&(pe.steiner=!0),ae.push(Rd(pe))}ae.sort(zd);for(let xe=0;xe<ae.length;xe++)F=kd(ae[xe],F);return F}(x,b,E,w)),x.length>80*w){O=1/0,Z=1/0;let q=-1/0,I=-1/0;for(let F=w;F<C;F+=w){const H=x[F],ae=x[F+1];H<O&&(O=H),ae<Z&&(Z=ae),H>q&&(q=H),ae>I&&(I=ae)}ee=Math.max(q-O,I-Z),ee=ee!==0?32767/ee:0}return Vo(E,k,w,O,Z,ee,0),k}(s,l),g=this._convertIndices(s,m);d=this._subdivideTrianglesScanline(g)}catch(m){console.error(m)}let p=[];return r&&(p=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(d),{verticesFlattened:this._vertexBuffer,indicesTriangles:d,indicesLineList:p}}_convertIndices(t,r){const s=[];for(let l=0;l<r.length;l++)s.push(this._vertexToIndex(t[2*r[l]],t[2*r[l]+1]));return s}_pointArrayToIndices(t){const r=[];for(let s=0;s<t.length;s++){const l=t[s];r.push(this._vertexToIndex(l.x,l.y))}return r}}function Xh(n,t,r,s=!0){return new Bd(r,t).subdividePolygonInternal(n,s)}function As(n,t,r=!1){if(!n||n.length<1)return[];if(n.length<2)return[];const s=n[0],l=n[n.length-1],d=r&&(s.x!==l.x||s.y!==l.y);if(t<2)return d?[...n,n[0]]:[...n];const p=Math.floor(rt/t),m=[];m.push(new Oe(n[0].x,n[0].y));const g=n.length,x=d?g:g-1;for(let b=0;b<x;b++){const w=n[b],M=b<g-1?n[b+1]:n[0],C=w.x,E=w.y,k=M.x,O=M.y,Z=C!==k,ee=E!==O;if(!Z&&!ee)continue;const q=k-C,I=O-E,F=Math.abs(q),H=Math.abs(I);let ae=C,xe=E;for(;;){const pe=q>0?(Math.floor(ae/p)+1)*p:(Math.ceil(ae/p)-1)*p,we=I>0?(Math.floor(xe/p)+1)*p:(Math.ceil(xe/p)-1)*p,be=Math.abs(ae-pe),Te=Math.abs(xe-we),_e=Math.abs(ae-k),ke=Math.abs(xe-O),Fe=Z?be/F:Number.POSITIVE_INFINITY,Be=ee?Te/H:Number.POSITIVE_INFINITY;if((_e<=be||!Z)&&(ke<=Te||!ee))break;if(Fe<Be&&Z||!ee){ae=pe,xe+=I*Fe;const Re=new Oe(ae,Math.round(xe));m[m.length-1].x===Re.x&&m[m.length-1].y===Re.y||m.push(Re)}else{ae+=q*Be,xe=we;const Re=new Oe(Math.round(ae),xe);m[m.length-1].x===Re.x&&m[m.length-1].y===Re.y||m.push(Re)}}const ce=new Oe(k,O);m[m.length-1].x===ce.x&&m[m.length-1].y===ce.y||m.push(ce)}return m}function Fd(n,t,r){if(t.length===0)throw new Error("Subdivision vertex ring is empty.");let s=0,l=n[2*t[0]];for(let g=1;g<t.length;g++){const x=n[2*t[g]];x<l&&(l=x,s=g)}const d=t.length;let p=s,m=(p+1)%d;for(;;){const g=p-1>=0?p-1:d-1,x=(m+1)%d,b=n[2*t[g]],w=n[2*t[x]],M=n[2*t[p]],C=n[2*t[p]+1],E=n[2*t[m]+1];let k=!1;if(b<w)k=!0;else if(b>w)k=!1;else{const O=E-C,Z=-(n[2*t[m]]-M),ee=C<E?1:-1;((b-M)*O+(n[2*t[g]+1]-C)*Z)*ee>((w-M)*O+(n[2*t[x]+1]-C)*Z)*ee&&(k=!0)}if(k){const O=t[g],Z=t[p],ee=t[m];O!==Z&&O!==ee&&Z!==ee&&r.push(ee,Z,O),p--,p<0&&(p=d-1)}else{const O=t[x],Z=t[p],ee=t[m];O!==Z&&O!==ee&&Z!==ee&&r.push(ee,Z,O),m++,m>=d&&(m=0)}if(g===x)break}}function Wh(n,t,r,s,l,d,p,m,g){const x=l.length/2,b=p&&m&&g;if(x<Ee.MAX_VERTEX_ARRAY_LENGTH){const w=t.prepareSegment(x,r,s),M=w.vertexLength;for(let k=0;k<d.length;k+=3)s.emplaceBack(M+d[k],M+d[k+1],M+d[k+2]);let C,E;w.vertexLength+=x,w.primitiveLength+=d.length/3,b&&(E=p.prepareSegment(x,r,m),C=E.vertexLength,E.vertexLength+=x);for(let k=0;k<l.length;k+=2)n(l[k],l[k+1]);if(b)for(let k=0;k<g.length;k++){const O=g[k];for(let Z=1;Z<O.length;Z+=2)m.emplaceBack(C+O[Z-1],C+O[Z]);E.primitiveLength+=O.length/2}}else(function(w,M,C,E,k,O){const Z=[];for(let H=0;H<E.length/2;H++)Z.push(-1);const ee={count:0};let q=0,I=w.getOrCreateLatestSegment(M,C),F=I.vertexLength;for(let H=2;H<k.length;H+=3){const ae=k[H-2],xe=k[H-1],ce=k[H];let pe=Z[ae]<q,we=Z[xe]<q,be=Z[ce]<q;I.vertexLength+((pe?1:0)+(we?1:0)+(be?1:0))>Ee.MAX_VERTEX_ARRAY_LENGTH&&(I=w.createNewSegment(M,C),q=ee.count,pe=!0,we=!0,be=!0,F=0);const Te=qo(Z,E,O,ee,ae,pe,I),_e=qo(Z,E,O,ee,xe,we,I),ke=qo(Z,E,O,ee,ce,be,I);C.emplaceBack(F+Te-q,F+_e-q,F+ke-q),I.primitiveLength++}})(t,r,s,l,d,n),b&&function(w,M,C,E,k,O){const Z=[];for(let H=0;H<E.length/2;H++)Z.push(-1);const ee={count:0};let q=0,I=w.getOrCreateLatestSegment(M,C),F=I.vertexLength;for(let H=0;H<k.length;H++){const ae=k[H];for(let xe=1;xe<k[H].length;xe+=2){const ce=ae[xe-1],pe=ae[xe];let we=Z[ce]<q,be=Z[pe]<q;I.vertexLength+((we?1:0)+(be?1:0))>Ee.MAX_VERTEX_ARRAY_LENGTH&&(I=w.createNewSegment(M,C),q=ee.count,we=!0,be=!0,F=0);const Te=qo(Z,E,O,ee,ce,we,I),_e=qo(Z,E,O,ee,pe,be,I);C.emplaceBack(F+Te-q,F+_e-q),I.primitiveLength++}}}(p,r,m,l,g,n),t.forceNewSegmentOnNextPrepare(),p==null||p.forceNewSegmentOnNextPrepare()}function qo(n,t,r,s,l,d,p){if(d){const m=s.count;return r(t[2*l],t[2*l+1]),n[l]=s.count,s.count++,p.vertexLength++,m}return n[l]}class eh{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new G,this.indexArray=new de,this.indexArray2=new Se,this.programConfigurations=new Tt(t.layers,t.zoom),this.segments=new Ee,this.segments2=new Ee,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,s){this.hasPattern=Kc("fill",this.layers,r);const l=this.layers[0].layout.get("fill-sort-key"),d=!l.isConstant(),p=[];for(const{feature:m,id:g,index:x,sourceLayerIndex:b}of t){const w=this.layers[0]._featureFilter.needGeometry,M=_n(m,w);if(!this.layers[0]._featureFilter.filter(new yt(this.zoom),M,s))continue;const C=d?l.evaluate(M,{},s,r.availableImages):void 0,E={id:g,properties:m.properties,type:m.type,sourceLayerIndex:b,index:x,geometry:w?M.geometry:mn(m),patterns:{},sortKey:C};p.push(E)}d&&p.sort((m,g)=>m.sortKey-g.sortKey);for(const m of p){const{geometry:g,index:x,sourceLayerIndex:b}=m;if(this.hasPattern){const w=Yc("fill",this.layers,m,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature(m,g,x,s,{},r.subdivisionGranularity);r.featureIndex.insert(t[x].feature,g,x,b,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}addFeatures(t,r,s){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,s,t.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Sd),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,r,s,l,d,p){for(const m of Us(r,500)){const g=Xh(m,l,p.fill.getGranularityForZoomLevel(l.z)),x=this.layoutVertexArray;Wh((b,w)=>{x.emplaceBack(b,w)},this.segments,this.layoutVertexArray,this.indexArray,g.verticesFlattened,g.indicesTriangles,this.segments2,this.indexArray2,g.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,d,l)}}let Kh,Yh;Ae("FillBucket",eh,{omit:["layers","patternFeatures"]});var Od={get paint(){return Yh=Yh||new ui({"fill-antialias":new Le(j.paint_fill["fill-antialias"]),"fill-opacity":new Ne(j.paint_fill["fill-opacity"]),"fill-color":new Ne(j.paint_fill["fill-color"]),"fill-outline-color":new Ne(j.paint_fill["fill-outline-color"]),"fill-translate":new Le(j.paint_fill["fill-translate"]),"fill-translate-anchor":new Le(j.paint_fill["fill-translate-anchor"]),"fill-pattern":new vs(j.paint_fill["fill-pattern"])})},get layout(){return Kh=Kh||new ui({"fill-sort-key":new Ne(j.layout_fill["fill-sort-key"])})}};class jd extends Ki{constructor(t){super(t,Od)}recalculate(t,r){super.recalculate(t,r);const s=this.paint._values["fill-outline-color"];s.value.kind==="constant"&&s.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new eh(t)}queryRadius(){return nc(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:r,transform:s,pixelsToTileUnits:l}){return Fo(sc(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-s.bearingInRadians,l),r)}isTileClipped(){return!0}}const Nd=kt([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Vd=kt([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Ud}=Nd;var th,Jh,ih,Qh,rh,eu,tu,cc={};function iu(){if(Jh)return th;Jh=1;var n=mr();function t(l,d,p,m,g){this.properties={},this.extent=p,this.type=0,this._pbf=l,this._geometry=-1,this._keys=m,this._values=g,l.readFields(r,this,d)}function r(l,d,p){l==1?d.id=p.readVarint():l==2?function(m,g){for(var x=m.readVarint()+m.pos;m.pos<x;){var b=g._keys[m.readVarint()],w=g._values[m.readVarint()];g.properties[b]=w}}(p,d):l==3?d.type=p.readVarint():l==4&&(d._geometry=p.pos)}function s(l){for(var d,p,m=0,g=0,x=l.length,b=x-1;g<x;b=g++)m+=((p=l[b]).x-(d=l[g]).x)*(d.y+p.y);return m}return th=t,t.types=["Unknown","Point","LineString","Polygon"],t.prototype.loadGeometry=function(){var l=this._pbf;l.pos=this._geometry;for(var d,p=l.readVarint()+l.pos,m=1,g=0,x=0,b=0,w=[];l.pos<p;){if(g<=0){var M=l.readVarint();m=7&M,g=M>>3}if(g--,m===1||m===2)x+=l.readSVarint(),b+=l.readSVarint(),m===1&&(d&&w.push(d),d=[]),d.push(new n(x,b));else{if(m!==7)throw new Error("unknown command "+m);d&&d.push(d[0].clone())}}return d&&w.push(d),w},t.prototype.bbox=function(){var l=this._pbf;l.pos=this._geometry;for(var d=l.readVarint()+l.pos,p=1,m=0,g=0,x=0,b=1/0,w=-1/0,M=1/0,C=-1/0;l.pos<d;){if(m<=0){var E=l.readVarint();p=7&E,m=E>>3}if(m--,p===1||p===2)(g+=l.readSVarint())<b&&(b=g),g>w&&(w=g),(x+=l.readSVarint())<M&&(M=x),x>C&&(C=x);else if(p!==7)throw new Error("unknown command "+p)}return[b,M,w,C]},t.prototype.toGeoJSON=function(l,d,p){var m,g,x=this.extent*Math.pow(2,p),b=this.extent*l,w=this.extent*d,M=this.loadGeometry(),C=t.types[this.type];function E(Z){for(var ee=0;ee<Z.length;ee++){var q=Z[ee];Z[ee]=[360*(q.x+b)/x-180,360/Math.PI*Math.atan(Math.exp((180-360*(q.y+w)/x)*Math.PI/180))-90]}}switch(this.type){case 1:var k=[];for(m=0;m<M.length;m++)k[m]=M[m][0];E(M=k);break;case 2:for(m=0;m<M.length;m++)E(M[m]);break;case 3:for(M=function(Z){var ee=Z.length;if(ee<=1)return[Z];for(var q,I,F=[],H=0;H<ee;H++){var ae=s(Z[H]);ae!==0&&(I===void 0&&(I=ae<0),I===ae<0?(q&&F.push(q),q=[Z[H]]):q.push(Z[H]))}return q&&F.push(q),F}(M),m=0;m<M.length;m++)for(g=0;g<M[m].length;g++)E(M[m][g])}M.length===1?M=M[0]:C="Multi"+C;var O={type:"Feature",geometry:{type:C,coordinates:M},properties:this.properties};return"id"in this&&(O.id=this.id),O},th}function ru(){if(Qh)return ih;Qh=1;var n=iu();function t(s,l){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=s,this._keys=[],this._values=[],this._features=[],s.readFields(r,this,l),this.length=this._features.length}function r(s,l,d){s===15?l.version=d.readVarint():s===1?l.name=d.readString():s===5?l.extent=d.readVarint():s===2?l._features.push(d.pos):s===3?l._keys.push(d.readString()):s===4&&l._values.push(function(p){for(var m=null,g=p.readVarint()+p.pos;p.pos<g;){var x=p.readVarint()>>3;m=x===1?p.readString():x===2?p.readFloat():x===3?p.readDouble():x===4?p.readVarint64():x===5?p.readVarint():x===6?p.readSVarint():x===7?p.readBoolean():null}return m}(d))}return ih=t,t.prototype.feature=function(s){if(s<0||s>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[s];var l=this._pbf.readVarint()+this._pbf.pos;return new n(this._pbf,l,this.extent,this._keys,this._values)},ih}function nu(){return tu||(tu=1,cc.VectorTile=function(){if(eu)return rh;eu=1;var n=ru();function t(r,s,l){if(r===3){var d=new n(l,l.readVarint()+l.pos);d.length&&(s[d.name]=d)}}return rh=function(r,s){this.layers=r.readFields(t,{},s)},rh}(),cc.VectorTileFeature=iu(),cc.VectorTileLayer=ru()),cc}var Ho=Pi(nu());const Zd=Ho.VectorTileFeature.types,nh=Math.pow(2,13);function Xo(n,t,r,s,l,d,p,m){n.emplaceBack(t,r,2*Math.floor(s*nh)+p,l*nh*2,d*nh*2,Math.round(m))}class sh{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new X,this.centroidVertexArray=new N,this.indexArray=new de,this.programConfigurations=new Tt(t.layers,t.zoom),this.segments=new Ee,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,s){this.features=[],this.hasPattern=Kc("fill-extrusion",this.layers,r);for(const{feature:l,id:d,index:p,sourceLayerIndex:m}of t){const g=this.layers[0]._featureFilter.needGeometry,x=_n(l,g);if(!this.layers[0]._featureFilter.filter(new yt(this.zoom),x,s))continue;const b={id:d,sourceLayerIndex:m,index:p,geometry:g?x.geometry:mn(l),properties:l.properties,type:l.type,patterns:{}};this.hasPattern?this.features.push(Yc("fill-extrusion",this.layers,b,this.zoom,r)):this.addFeature(b,b.geometry,p,s,{},r.subdivisionGranularity),r.featureIndex.insert(l,b.geometry,p,m,this.index,!0)}}addFeatures(t,r,s){for(const l of this.features){const{geometry:d}=l;this.addFeature(l,d,l.index,r,s,t.subdivisionGranularity)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ud),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Vd.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,r,s,l,d,p){for(const m of Us(r,500)){const g={x:0,y:0,sampleCount:0},x=this.layoutVertexArray.length;this.processPolygon(g,l,t,m,p);const b=this.layoutVertexArray.length-x,w=Math.floor(g.x/g.sampleCount),M=Math.floor(g.y/g.sampleCount);for(let C=0;C<b;C++)this.centroidVertexArray.emplaceBack(w,M)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,d,l)}processPolygon(t,r,s,l,d){if(l.length<1||su(l[0]))return;for(const w of l)w.length!==0&&Gd(t,w);const p={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},m=d.fill.getGranularityForZoomLevel(r.z),g=Zd[s.type]==="Polygon";for(const w of l){if(w.length===0||su(w))continue;const M=As(w,m,g);this._generateSideFaces(M,p)}if(!g)return;const x=Xh(l,r,m,!1),b=this.layoutVertexArray;Wh((w,M)=>{Xo(b,w,M,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,x.verticesFlattened,x.indicesTriangles)}_generateSideFaces(t,r){let s=0;for(let l=1;l<t.length;l++){const d=t[l],p=t[l-1];if($d(d,p))continue;r.segment.vertexLength+4>Ee.MAX_VERTEX_ARRAY_LENGTH&&(r.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const m=d.sub(p)._perp()._unit(),g=p.dist(d);s+g>32768&&(s=0),Xo(this.layoutVertexArray,d.x,d.y,m.x,m.y,0,0,s),Xo(this.layoutVertexArray,d.x,d.y,m.x,m.y,0,1,s),s+=g,Xo(this.layoutVertexArray,p.x,p.y,m.x,m.y,0,0,s),Xo(this.layoutVertexArray,p.x,p.y,m.x,m.y,0,1,s);const x=r.segment.vertexLength;this.indexArray.emplaceBack(x,x+2,x+1),this.indexArray.emplaceBack(x+1,x+2,x+3),r.segment.vertexLength+=4,r.segment.primitiveLength+=2}}}function Gd(n,t){for(let r=0;r<t.length;r++){const s=t[r];r===t.length-1&&t[0].x===s.x&&t[0].y===s.y||(n.x+=s.x,n.y+=s.y,n.sampleCount++)}}function $d(n,t){return n.x===t.x&&(n.x<0||n.x>rt)||n.y===t.y&&(n.y<0||n.y>rt)}function su(n){return n.every(t=>t.x<0)||n.every(t=>t.x>rt)||n.every(t=>t.y<0)||n.every(t=>t.y>rt)}let au;Ae("FillExtrusionBucket",sh,{omit:["layers","features"]});var qd={get paint(){return au=au||new ui({"fill-extrusion-opacity":new Le(j["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Ne(j["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Le(j["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Le(j["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new vs(j["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Ne(j["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Ne(j["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Le(j["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Hd extends Ki{constructor(t){super(t,qd)}createBucket(t){return new sh(t)}queryRadius(){return nc(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:t,feature:r,featureState:s,geometry:l,transform:d,pixelsToTileUnits:p,pixelPosMatrix:m}){const g=sc(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-d.bearingInRadians,p),x=this.paint.get("fill-extrusion-height").evaluate(r,s),b=this.paint.get("fill-extrusion-base").evaluate(r,s),w=function(C,E,k){const O=[];for(const Z of C){const ee=[Z.x,Z.y,0,1];Ji(ee,ee,E),O.push(new Oe(ee[0]/ee[3],ee[1]/ee[3]))}return O}(g,m),M=function(C,E,k,O){const Z=[],ee=[],q=O[8]*E,I=O[9]*E,F=O[10]*E,H=O[11]*E,ae=O[8]*k,xe=O[9]*k,ce=O[10]*k,pe=O[11]*k;for(const we of C){const be=[],Te=[];for(const _e of we){const ke=_e.x,Fe=_e.y,Be=O[0]*ke+O[4]*Fe+O[12],Re=O[1]*ke+O[5]*Fe+O[13],Ke=O[2]*ke+O[6]*Fe+O[14],It=O[3]*ke+O[7]*Fe+O[15],Zt=Ke+F,ai=It+H,Ui=Be+ae,wi=Re+xe,Yt=Ke+ce,Pt=It+pe,$t=new Oe((Be+q)/ai,(Re+I)/ai);$t.z=Zt/ai,be.push($t);const Jt=new Oe(Ui/Pt,wi/Pt);Jt.z=Yt/Pt,Te.push(Jt)}Z.push(be),ee.push(Te)}return[Z,ee]}(l,b,x,m);return function(C,E,k){let O=1/0;Fo(k,E)&&(O=ou(k,E[0]));for(let Z=0;Z<E.length;Z++){const ee=E[Z],q=C[Z];for(let I=0;I<ee.length-1;I++){const F=ee[I],H=[F,ee[I+1],q[I+1],q[I],F];Lo(k,H)&&(O=Math.min(O,ou(k,H)))}}return O!==1/0&&O}(M[0],M[1],w)}}function Wo(n,t){return n.x*t.x+n.y*t.y}function ou(n,t){if(n.length===1){let r=0;const s=t[r++];let l;for(;!l||s.equals(l);)if(l=t[r++],!l)return 1/0;for(;r<t.length;r++){const d=t[r],p=n[0],m=l.sub(s),g=d.sub(s),x=p.sub(s),b=Wo(m,m),w=Wo(m,g),M=Wo(g,g),C=Wo(x,m),E=Wo(x,g),k=b*M-w*w,O=(M*C-w*E)/k,Z=(b*E-w*C)/k,ee=s.z*(1-O-Z)+l.z*O+d.z*Z;if(isFinite(ee))return ee}return 1/0}{let r=1/0;for(const s of t)r=Math.min(r,s.z);return r}}const Xd=kt([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:Wd}=Xd,Kd=kt([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:Yd}=Kd,Jd=Ho.VectorTileFeature.types,Qd=Math.cos(Math.PI/180*37.5),lu=Math.pow(2,14)/.5;class ah{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(r=>{this.gradients[r.id]={}}),this.layoutVertexArray=new W,this.layoutVertexArray2=new K,this.indexArray=new de,this.programConfigurations=new Tt(t.layers,t.zoom),this.segments=new Ee,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,s){this.hasPattern=Kc("line",this.layers,r);const l=this.layers[0].layout.get("line-sort-key"),d=!l.isConstant(),p=[];for(const{feature:m,id:g,index:x,sourceLayerIndex:b}of t){const w=this.layers[0]._featureFilter.needGeometry,M=_n(m,w);if(!this.layers[0]._featureFilter.filter(new yt(this.zoom),M,s))continue;const C=d?l.evaluate(M,{},s):void 0,E={id:g,properties:m.properties,type:m.type,sourceLayerIndex:b,index:x,geometry:w?M.geometry:mn(m),patterns:{},sortKey:C};p.push(E)}d&&p.sort((m,g)=>m.sortKey-g.sortKey);for(const m of p){const{geometry:g,index:x,sourceLayerIndex:b}=m;if(this.hasPattern){const w=Yc("line",this.layers,m,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature(m,g,x,s,{},r.subdivisionGranularity);r.featureIndex.insert(t[x].feature,g,x,b,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}addFeatures(t,r,s){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,s,t.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Yd)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Wd),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,r,s,l,d,p){const m=this.layers[0].layout,g=m.get("line-join").evaluate(t,{}),x=m.get("line-cap"),b=m.get("line-miter-limit"),w=m.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const M of r)this.addLine(M,t,g,x,b,w,l,p);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,d,l)}addLine(t,r,s,l,d,p,m,g){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=As(t,m?g.line.getGranularityForZoomLevel(m.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let q=0;q<t.length-1;q++)this.totalDistance+=t[q].dist(t[q+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const x=Jd[r.type]==="Polygon";let b=t.length;for(;b>=2&&t[b-1].equals(t[b-2]);)b--;let w=0;for(;w<b-1&&t[w].equals(t[w+1]);)w++;if(b<(x?3:2))return;s==="bevel"&&(d=1.05);const M=this.overscaling<=16?15*rt/(512*this.overscaling):0,C=this.segments.prepareSegment(10*b,this.layoutVertexArray,this.indexArray);let E,k,O,Z,ee;this.e1=this.e2=-1,x&&(E=t[b-2],ee=t[w].sub(E)._unit()._perp());for(let q=w;q<b;q++){if(O=q===b-1?x?t[w+1]:void 0:t[q+1],O&&t[q].equals(O))continue;ee&&(Z=ee),E&&(k=E),E=t[q],ee=O?O.sub(E)._unit()._perp():Z,Z=Z||ee;let I=Z.add(ee);I.x===0&&I.y===0||I._unit();const F=Z.x*ee.x+Z.y*ee.y,H=I.x*ee.x+I.y*ee.y,ae=H!==0?1/H:1/0,xe=2*Math.sqrt(2-2*H),ce=H<Qd&&k&&O,pe=Z.x*ee.y-Z.y*ee.x>0;if(ce&&q>w){const Te=E.dist(k);if(Te>2*M){const _e=E.sub(E.sub(k)._mult(M/Te)._round());this.updateDistance(k,_e),this.addCurrentVertex(_e,Z,0,0,C),k=_e}}const we=k&&O;let be=we?s:x?"butt":l;if(we&&be==="round"&&(ae<p?be="miter":ae<=2&&(be="fakeround")),be==="miter"&&ae>d&&(be="bevel"),be==="bevel"&&(ae>2&&(be="flipbevel"),ae<d&&(be="miter")),k&&this.updateDistance(k,E),be==="miter")I._mult(ae),this.addCurrentVertex(E,I,0,0,C);else if(be==="flipbevel"){if(ae>100)I=ee.mult(-1);else{const Te=ae*Z.add(ee).mag()/Z.sub(ee).mag();I._perp()._mult(Te*(pe?-1:1))}this.addCurrentVertex(E,I,0,0,C),this.addCurrentVertex(E,I.mult(-1),0,0,C)}else if(be==="bevel"||be==="fakeround"){const Te=-Math.sqrt(ae*ae-1),_e=pe?Te:0,ke=pe?0:Te;if(k&&this.addCurrentVertex(E,Z,_e,ke,C),be==="fakeround"){const Fe=Math.round(180*xe/Math.PI/20);for(let Be=1;Be<Fe;Be++){let Re=Be/Fe;if(Re!==.5){const It=Re-.5;Re+=Re*It*(Re-1)*((1.0904+F*(F*(3.55645-1.43519*F)-3.2452))*It*It+(.848013+F*(.215638*F-1.06021)))}const Ke=ee.sub(Z)._mult(Re)._add(Z)._unit()._mult(pe?-1:1);this.addHalfVertex(E,Ke.x,Ke.y,!1,pe,0,C)}}O&&this.addCurrentVertex(E,ee,-_e,-ke,C)}else if(be==="butt")this.addCurrentVertex(E,I,0,0,C);else if(be==="square"){const Te=k?1:-1;this.addCurrentVertex(E,I,Te,Te,C)}else be==="round"&&(k&&(this.addCurrentVertex(E,Z,0,0,C),this.addCurrentVertex(E,Z,1,1,C,!0)),O&&(this.addCurrentVertex(E,ee,-1,-1,C,!0),this.addCurrentVertex(E,ee,0,0,C)));if(ce&&q<b-1){const Te=E.dist(O);if(Te>2*M){const _e=E.add(O.sub(E)._mult(M/Te)._round());this.updateDistance(E,_e),this.addCurrentVertex(_e,ee,0,0,C),E=_e}}}}addCurrentVertex(t,r,s,l,d,p=!1){const m=r.y*l-r.x,g=-r.y-r.x*l;this.addHalfVertex(t,r.x+r.y*s,r.y-r.x*s,p,!1,s,d),this.addHalfVertex(t,m,g,p,!0,-l,d),this.distance>lu/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,r,s,l,d,p))}addHalfVertex({x:t,y:r},s,l,d,p,m,g){const x=.5*(this.lineClips?this.scaledDistance*(lu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(d?1:0),(r<<1)+(p?1:0),Math.round(63*s)+128,Math.round(63*l)+128,1+(m===0?0:m<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=g.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,b,this.e2),g.primitiveLength++),p?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(t,r){this.distance+=t.dist(r),this.updateScaledDistance()}}let cu,hu;Ae("LineBucket",ah,{omit:["layers","patternFeatures"]});var uu={get paint(){return hu=hu||new ui({"line-opacity":new Ne(j.paint_line["line-opacity"]),"line-color":new Ne(j.paint_line["line-color"]),"line-translate":new Le(j.paint_line["line-translate"]),"line-translate-anchor":new Le(j.paint_line["line-translate-anchor"]),"line-width":new Ne(j.paint_line["line-width"]),"line-gap-width":new Ne(j.paint_line["line-gap-width"]),"line-offset":new Ne(j.paint_line["line-offset"]),"line-blur":new Ne(j.paint_line["line-blur"]),"line-dasharray":new ma(j.paint_line["line-dasharray"]),"line-pattern":new vs(j.paint_line["line-pattern"]),"line-gradient":new _a(j.paint_line["line-gradient"])})},get layout(){return cu=cu||new ui({"line-cap":new Le(j.layout_line["line-cap"]),"line-join":new Ne(j.layout_line["line-join"]),"line-miter-limit":new Le(j.layout_line["line-miter-limit"]),"line-round-limit":new Le(j.layout_line["line-round-limit"]),"line-sort-key":new Ne(j.layout_line["line-sort-key"])})}};class ep extends Ne{possiblyEvaluate(t,r){return r=new yt(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(t,r)}evaluate(t,r,s,l){return r=Wt({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(t,r,s,l)}}let hc;class tp extends Ki{constructor(t){super(t,uu),this.gradientVersion=0,hc||(hc=new ep(uu.paint.properties["line-width"].specification),hc.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if(t==="line-gradient"){const r=this.gradientExpression();this.stepInterpolant=!!function(s){return s._styleExpression!==void 0}(r)&&r._styleExpression.expression instanceof nn,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,r){super.recalculate(t,r),this.paint._values["line-floorwidth"]=hc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new ah(t)}queryRadius(t){const r=t,s=du(jo("line-width",this,r),jo("line-gap-width",this,r)),l=jo("line-offset",this,r);return s/2+Math.abs(l)+nc(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:r,featureState:s,geometry:l,transform:d,pixelsToTileUnits:p}){const m=sc(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-d.bearingInRadians,p),g=p/2*du(this.paint.get("line-width").evaluate(r,s),this.paint.get("line-gap-width").evaluate(r,s)),x=this.paint.get("line-offset").evaluate(r,s);return x&&(l=function(b,w){const M=[];for(let C=0;C<b.length;C++){const E=b[C],k=[];for(let O=0;O<E.length;O++){const Z=E[O-1],ee=E[O],q=E[O+1],I=O===0?new Oe(0,0):ee.sub(Z)._unit()._perp(),F=O===E.length-1?new Oe(0,0):q.sub(ee)._unit()._perp(),H=I._add(F)._unit(),ae=H.x*F.x+H.y*F.y;ae!==0&&H._mult(1/ae),k.push(H._mult(w)._add(ee))}M.push(k)}return M}(l,x*p)),function(b,w,M){for(let C=0;C<w.length;C++){const E=w[C];if(b.length>=3){for(let k=0;k<E.length;k++)if(va(b,E[k]))return!0}if(Oo(b,E,M))return!0}return!1}(m,l,g)}isTileClipped(){return!0}}function du(n,t){return t>0?t+2*n:n}const ip=kt([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),rp=kt([{name:"a_projected_pos",components:3,type:"Float32"}],4);kt([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const np=kt([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);kt([{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 pu=kt([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),sp=kt([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function ap(n,t,r){return n.sections.forEach(s=>{s.text=function(l,d,p){const m=d.layout.get("text-transform").evaluate(p,{});return m==="uppercase"?l=l.toLocaleUpperCase():m==="lowercase"&&(l=l.toLocaleLowerCase()),ar.applyArabicShaping&&(l=ar.applyArabicShaping(l)),l}(s.text,t,r)}),n}kt([{name:"triangle",components:3,type:"Uint16"}]),kt([{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"}]),kt([{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"}]),kt([{type:"Float32",name:"offsetX"}]),kt([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),kt([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Ko={"!":"︕","#":"",$:"","%":"","&":"","(":"︵",")":"︶","*":"","+":"",",":"︐","-":"︲",".":"・","/":"",":":"︓",";":"︔","<":"︿","=":"",">":"﹀","?":"︖","@":"","[":"﹇","\\":"","]":"﹈","^":"",_:"︳","`":"","{":"︷","|":"―","}":"︸","~":"","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","":"︲","—":"︱","":"﹃","":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","":"︹","":"︺","〖":"︗","〗":"︘","":"︕","":"︵","":"︶","":"︐","":"︲","":"・","":"︓","":"︔","":"︿","":"﹀","":"︖","":"﹇","":"﹈","_":"︳","":"︷","":"―","":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var fu,oh,mu,Ut=24,lh={};function op(){return fu||(fu=1,lh.read=function(n,t,r,s,l){var d,p,m=8*l-s-1,g=(1<<m)-1,x=g>>1,b=-7,w=r?l-1:0,M=r?-1:1,C=n[t+w];for(w+=M,d=C&(1<<-b)-1,C>>=-b,b+=m;b>0;d=256*d+n[t+w],w+=M,b-=8);for(p=d&(1<<-b)-1,d>>=-b,b+=s;b>0;p=256*p+n[t+w],w+=M,b-=8);if(d===0)d=1-x;else{if(d===g)return p?NaN:1/0*(C?-1:1);p+=Math.pow(2,s),d-=x}return(C?-1:1)*p*Math.pow(2,d-s)},lh.write=function(n,t,r,s,l,d){var p,m,g,x=8*d-l-1,b=(1<<x)-1,w=b>>1,M=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,C=s?0:d-1,E=s?1:-1,k=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(m=isNaN(t)?1:0,p=b):(p=Math.floor(Math.log(t)/Math.LN2),t*(g=Math.pow(2,-p))<1&&(p--,g*=2),(t+=p+w>=1?M/g:M*Math.pow(2,1-w))*g>=2&&(p++,g/=2),p+w>=b?(m=0,p=b):p+w>=1?(m=(t*g-1)*Math.pow(2,l),p+=w):(m=t*Math.pow(2,w-1)*Math.pow(2,l),p=0));l>=8;n[r+C]=255&m,C+=E,m/=256,l-=8);for(p=p<<l|m,x+=l;x>0;n[r+C]=255&p,C+=E,p/=256,x-=8);n[r+C-E]|=128*k}),lh}function _u(){if(mu)return oh;mu=1,oh=t;var n=op();function t(I){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(I)?I:new Uint8Array(I||0),this.pos=0,this.type=0,this.length=this.buf.length}t.Varint=0,t.Fixed64=1,t.Bytes=2,t.Fixed32=5;var r=4294967296,s=1/r,l=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function d(I){return I.type===t.Bytes?I.readVarint()+I.pos:I.pos+1}function p(I,F,H){return H?4294967296*F+(I>>>0):4294967296*(F>>>0)+(I>>>0)}function m(I,F,H){var ae=F<=16383?1:F<=2097151?2:F<=268435455?3:Math.floor(Math.log(F)/(7*Math.LN2));H.realloc(ae);for(var xe=H.pos-1;xe>=I;xe--)H.buf[xe+ae]=H.buf[xe]}function g(I,F){for(var H=0;H<I.length;H++)F.writeVarint(I[H])}function x(I,F){for(var H=0;H<I.length;H++)F.writeSVarint(I[H])}function b(I,F){for(var H=0;H<I.length;H++)F.writeFloat(I[H])}function w(I,F){for(var H=0;H<I.length;H++)F.writeDouble(I[H])}function M(I,F){for(var H=0;H<I.length;H++)F.writeBoolean(I[H])}function C(I,F){for(var H=0;H<I.length;H++)F.writeFixed32(I[H])}function E(I,F){for(var H=0;H<I.length;H++)F.writeSFixed32(I[H])}function k(I,F){for(var H=0;H<I.length;H++)F.writeFixed64(I[H])}function O(I,F){for(var H=0;H<I.length;H++)F.writeSFixed64(I[H])}function Z(I,F){return(I[F]|I[F+1]<<8|I[F+2]<<16)+16777216*I[F+3]}function ee(I,F,H){I[H]=F,I[H+1]=F>>>8,I[H+2]=F>>>16,I[H+3]=F>>>24}function q(I,F){return(I[F]|I[F+1]<<8|I[F+2]<<16)+(I[F+3]<<24)}return t.prototype={destroy:function(){this.buf=null},readFields:function(I,F,H){for(H=H||this.length;this.pos<H;){var ae=this.readVarint(),xe=ae>>3,ce=this.pos;this.type=7&ae,I(xe,F,this),this.pos===ce&&this.skip(ae)}return F},readMessage:function(I,F){return this.readFields(I,F,this.readVarint()+this.pos)},readFixed32:function(){var I=Z(this.buf,this.pos);return this.pos+=4,I},readSFixed32:function(){var I=q(this.buf,this.pos);return this.pos+=4,I},readFixed64:function(){var I=Z(this.buf,this.pos)+Z(this.buf,this.pos+4)*r;return this.pos+=8,I},readSFixed64:function(){var I=Z(this.buf,this.pos)+q(this.buf,this.pos+4)*r;return this.pos+=8,I},readFloat:function(){var I=n.read(this.buf,this.pos,!0,23,4);return this.pos+=4,I},readDouble:function(){var I=n.read(this.buf,this.pos,!0,52,8);return this.pos+=8,I},readVarint:function(I){var F,H,ae=this.buf;return F=127&(H=ae[this.pos++]),H<128?F:(F|=(127&(H=ae[this.pos++]))<<7,H<128?F:(F|=(127&(H=ae[this.pos++]))<<14,H<128?F:(F|=(127&(H=ae[this.pos++]))<<21,H<128?F:function(xe,ce,pe){var we,be,Te=pe.buf;if(we=(112&(be=Te[pe.pos++]))>>4,be<128||(we|=(127&(be=Te[pe.pos++]))<<3,be<128)||(we|=(127&(be=Te[pe.pos++]))<<10,be<128)||(we|=(127&(be=Te[pe.pos++]))<<17,be<128)||(we|=(127&(be=Te[pe.pos++]))<<24,be<128)||(we|=(1&(be=Te[pe.pos++]))<<31,be<128))return p(xe,we,ce);throw new Error("Expected varint not more than 10 bytes")}(F|=(15&(H=ae[this.pos]))<<28,I,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var I=this.readVarint();return I%2==1?(I+1)/-2:I/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var I=this.readVarint()+this.pos,F=this.pos;return this.pos=I,I-F>=12&&l?function(H,ae,xe){return l.decode(H.subarray(ae,xe))}(this.buf,F,I):function(H,ae,xe){for(var ce="",pe=ae;pe<xe;){var we,be,Te,_e=H[pe],ke=null,Fe=_e>239?4:_e>223?3:_e>191?2:1;if(pe+Fe>xe)break;Fe===1?_e<128&&(ke=_e):Fe===2?(192&(we=H[pe+1]))==128&&(ke=(31&_e)<<6|63&we)<=127&&(ke=null):Fe===3?(be=H[pe+2],(192&(we=H[pe+1]))==128&&(192&be)==128&&((ke=(15&_e)<<12|(63&we)<<6|63&be)<=2047||ke>=55296&&ke<=57343)&&(ke=null)):Fe===4&&(be=H[pe+2],Te=H[pe+3],(192&(we=H[pe+1]))==128&&(192&be)==128&&(192&Te)==128&&((ke=(15&_e)<<18|(63&we)<<12|(63&be)<<6|63&Te)<=65535||ke>=1114112)&&(ke=null)),ke===null?(ke=65533,Fe=1):ke>65535&&(ke-=65536,ce+=String.fromCharCode(ke>>>10&1023|55296),ke=56320|1023&ke),ce+=String.fromCharCode(ke),pe+=Fe}return ce}(this.buf,F,I)},readBytes:function(){var I=this.readVarint()+this.pos,F=this.buf.subarray(this.pos,I);return this.pos=I,F},readPackedVarint:function(I,F){if(this.type!==t.Bytes)return I.push(this.readVarint(F));var H=d(this);for(I=I||[];this.pos<H;)I.push(this.readVarint(F));return I},readPackedSVarint:function(I){if(this.type!==t.Bytes)return I.push(this.readSVarint());var F=d(this);for(I=I||[];this.pos<F;)I.push(this.readSVarint());return I},readPackedBoolean:function(I){if(this.type!==t.Bytes)return I.push(this.readBoolean());var F=d(this);for(I=I||[];this.pos<F;)I.push(this.readBoolean());return I},readPackedFloat:function(I){if(this.type!==t.Bytes)return I.push(this.readFloat());var F=d(this);for(I=I||[];this.pos<F;)I.push(this.readFloat());return I},readPackedDouble:function(I){if(this.type!==t.Bytes)return I.push(this.readDouble());var F=d(this);for(I=I||[];this.pos<F;)I.push(this.readDouble());return I},readPackedFixed32:function(I){if(this.type!==t.Bytes)return I.push(this.readFixed32());var F=d(this);for(I=I||[];this.pos<F;)I.push(this.readFixed32());return I},readPackedSFixed32:function(I){if(this.type!==t.Bytes)return I.push(this.readSFixed32());var F=d(this);for(I=I||[];this.pos<F;)I.push(this.readSFixed32());return I},readPackedFixed64:function(I){if(this.type!==t.Bytes)return I.push(this.readFixed64());var F=d(this);for(I=I||[];this.pos<F;)I.push(this.readFixed64());return I},readPackedSFixed64:function(I){if(this.type!==t.Bytes)return I.push(this.readSFixed64());var F=d(this);for(I=I||[];this.pos<F;)I.push(this.readSFixed64());return I},skip:function(I){var F=7&I;if(F===t.Varint)for(;this.buf[this.pos++]>127;);else if(F===t.Bytes)this.pos=this.readVarint()+this.pos;else if(F===t.Fixed32)this.pos+=4;else{if(F!==t.Fixed64)throw new Error("Unimplemented type: "+F);this.pos+=8}},writeTag:function(I,F){this.writeVarint(I<<3|F)},realloc:function(I){for(var F=this.length||16;F<this.pos+I;)F*=2;if(F!==this.length){var H=new Uint8Array(F);H.set(this.buf),this.buf=H,this.length=F}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(I){this.realloc(4),ee(this.buf,I,this.pos),this.pos+=4},writeSFixed32:function(I){this.realloc(4),ee(this.buf,I,this.pos),this.pos+=4},writeFixed64:function(I){this.realloc(8),ee(this.buf,-1&I,this.pos),ee(this.buf,Math.floor(I*s),this.pos+4),this.pos+=8},writeSFixed64:function(I){this.realloc(8),ee(this.buf,-1&I,this.pos),ee(this.buf,Math.floor(I*s),this.pos+4),this.pos+=8},writeVarint:function(I){(I=+I||0)>268435455||I<0?function(F,H){var ae,xe;if(F>=0?(ae=F%4294967296|0,xe=F/4294967296|0):(xe=~(-F/4294967296),4294967295^(ae=~(-F%4294967296))?ae=ae+1|0:(ae=0,xe=xe+1|0)),F>=18446744073709552e3||F<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");H.realloc(10),function(ce,pe,we){we.buf[we.pos++]=127&ce|128,ce>>>=7,we.buf[we.pos++]=127&ce|128,ce>>>=7,we.buf[we.pos++]=127&ce|128,ce>>>=7,we.buf[we.pos++]=127&ce|128,we.buf[we.pos]=127&(ce>>>=7)}(ae,0,H),function(ce,pe){var we=(7&ce)<<4;pe.buf[pe.pos++]|=we|((ce>>>=3)?128:0),ce&&(pe.buf[pe.pos++]=127&ce|((ce>>>=7)?128:0),ce&&(pe.buf[pe.pos++]=127&ce|((ce>>>=7)?128:0),ce&&(pe.buf[pe.pos++]=127&ce|((ce>>>=7)?128:0),ce&&(pe.buf[pe.pos++]=127&ce|((ce>>>=7)?128:0),ce&&(pe.buf[pe.pos++]=127&ce)))))}(xe,H)}(I,this):(this.realloc(4),this.buf[this.pos++]=127&I|(I>127?128:0),I<=127||(this.buf[this.pos++]=127&(I>>>=7)|(I>127?128:0),I<=127||(this.buf[this.pos++]=127&(I>>>=7)|(I>127?128:0),I<=127||(this.buf[this.pos++]=I>>>7&127))))},writeSVarint:function(I){this.writeVarint(I<0?2*-I-1:2*I)},writeBoolean:function(I){this.writeVarint(!!I)},writeString:function(I){I=String(I),this.realloc(4*I.length),this.pos++;var F=this.pos;this.pos=function(ae,xe,ce){for(var pe,we,be=0;be<xe.length;be++){if((pe=xe.charCodeAt(be))>55295&&pe<57344){if(!we){pe>56319||be+1===xe.length?(ae[ce++]=239,ae[ce++]=191,ae[ce++]=189):we=pe;continue}if(pe<56320){ae[ce++]=239,ae[ce++]=191,ae[ce++]=189,we=pe;continue}pe=we-55296<<10|pe-56320|65536,we=null}else we&&(ae[ce++]=239,ae[ce++]=191,ae[ce++]=189,we=null);pe<128?ae[ce++]=pe:(pe<2048?ae[ce++]=pe>>6|192:(pe<65536?ae[ce++]=pe>>12|224:(ae[ce++]=pe>>18|240,ae[ce++]=pe>>12&63|128),ae[ce++]=pe>>6&63|128),ae[ce++]=63&pe|128)}return ce}(this.buf,I,this.pos);var H=this.pos-F;H>=128&&m(F,H,this),this.pos=F-1,this.writeVarint(H),this.pos+=H},writeFloat:function(I){this.realloc(4),n.write(this.buf,I,this.pos,!0,23,4),this.pos+=4},writeDouble:function(I){this.realloc(8),n.write(this.buf,I,this.pos,!0,52,8),this.pos+=8},writeBytes:function(I){var F=I.length;this.writeVarint(F),this.realloc(F);for(var H=0;H<F;H++)this.buf[this.pos++]=I[H]},writeRawMessage:function(I,F){this.pos++;var H=this.pos;I(F,this);var ae=this.pos-H;ae>=128&&m(H,ae,this),this.pos=H-1,this.writeVarint(ae),this.pos+=ae},writeMessage:function(I,F,H){this.writeTag(I,t.Bytes),this.writeRawMessage(F,H)},writePackedVarint:function(I,F){F.length&&this.writeMessage(I,g,F)},writePackedSVarint:function(I,F){F.length&&this.writeMessage(I,x,F)},writePackedBoolean:function(I,F){F.length&&this.writeMessage(I,M,F)},writePackedFloat:function(I,F){F.length&&this.writeMessage(I,b,F)},writePackedDouble:function(I,F){F.length&&this.writeMessage(I,w,F)},writePackedFixed32:function(I,F){F.length&&this.writeMessage(I,C,F)},writePackedSFixed32:function(I,F){F.length&&this.writeMessage(I,E,F)},writePackedFixed64:function(I,F){F.length&&this.writeMessage(I,k,F)},writePackedSFixed64:function(I,F){F.length&&this.writeMessage(I,O,F)},writeBytesField:function(I,F){this.writeTag(I,t.Bytes),this.writeBytes(F)},writeFixed32Field:function(I,F){this.writeTag(I,t.Fixed32),this.writeFixed32(F)},writeSFixed32Field:function(I,F){this.writeTag(I,t.Fixed32),this.writeSFixed32(F)},writeFixed64Field:function(I,F){this.writeTag(I,t.Fixed64),this.writeFixed64(F)},writeSFixed64Field:function(I,F){this.writeTag(I,t.Fixed64),this.writeSFixed64(F)},writeVarintField:function(I,F){this.writeTag(I,t.Varint),this.writeVarint(F)},writeSVarintField:function(I,F){this.writeTag(I,t.Varint),this.writeSVarint(F)},writeStringField:function(I,F){this.writeTag(I,t.Bytes),this.writeString(F)},writeFloatField:function(I,F){this.writeTag(I,t.Fixed32),this.writeFloat(F)},writeDoubleField:function(I,F){this.writeTag(I,t.Fixed64),this.writeDouble(F)},writeBooleanField:function(I,F){this.writeVarintField(I,!!F)}},oh}var ch=Pi(_u());const hh=3;function lp(n,t,r){n===1&&r.readMessage(cp,t)}function cp(n,t,r){if(n===3){const{id:s,bitmap:l,width:d,height:p,left:m,top:g,advance:x}=r.readMessage(hp,{});t.push({id:s,bitmap:new No({width:d+2*hh,height:p+2*hh},l),metrics:{width:d,height:p,left:m,top:g,advance:x}})}}function hp(n,t,r){n===1?t.id=r.readVarint():n===2?t.bitmap=r.readBytes():n===3?t.width=r.readVarint():n===4?t.height=r.readVarint():n===5?t.left=r.readSVarint():n===6?t.top=r.readSVarint():n===7&&(t.advance=r.readVarint())}const up=hh;function gu(n){let t=0,r=0;for(const p of n)t+=p.w*p.h,r=Math.max(r,p.w);n.sort((p,m)=>m.h-p.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),r),h:1/0}];let l=0,d=0;for(const p of n)for(let m=s.length-1;m>=0;m--){const g=s[m];if(!(p.w>g.w||p.h>g.h)){if(p.x=g.x,p.y=g.y,d=Math.max(d,p.y+p.h),l=Math.max(l,p.x+p.w),p.w===g.w&&p.h===g.h){const x=s.pop();m<s.length&&(s[m]=x)}else p.h===g.h?(g.x+=p.w,g.w-=p.w):p.w===g.w?(g.y+=p.h,g.h-=p.h):(s.push({x:g.x+p.w,y:g.y,w:g.w-p.w,h:p.h}),g.y+=p.h,g.h-=p.h);break}}return{w:l,h:d,fill:t/(l*d)||0}}const bi=1;class uh{constructor(t,{pixelRatio:r,version:s,stretchX:l,stretchY:d,content:p,textFitWidth:m,textFitHeight:g}){this.paddedRect=t,this.pixelRatio=r,this.stretchX=l,this.stretchY=d,this.content=p,this.version=s,this.textFitWidth=m,this.textFitHeight=g}get tl(){return[this.paddedRect.x+bi,this.paddedRect.y+bi]}get br(){return[this.paddedRect.x+this.paddedRect.w-bi,this.paddedRect.y+this.paddedRect.h-bi]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2*bi)/this.pixelRatio,(this.paddedRect.h-2*bi)/this.pixelRatio]}}class yu{constructor(t,r){const s={},l={};this.haveRenderCallbacks=[];const d=[];this.addImages(t,s,d),this.addImages(r,l,d);const{w:p,h:m}=gu(d),g=new Ni({width:p||1,height:m||1});for(const x in t){const b=t[x],w=s[x].paddedRect;Ni.copy(b.data,g,{x:0,y:0},{x:w.x+bi,y:w.y+bi},b.data)}for(const x in r){const b=r[x],w=l[x].paddedRect,M=w.x+bi,C=w.y+bi,E=b.data.width,k=b.data.height;Ni.copy(b.data,g,{x:0,y:0},{x:M,y:C},b.data),Ni.copy(b.data,g,{x:0,y:k-1},{x:M,y:C-1},{width:E,height:1}),Ni.copy(b.data,g,{x:0,y:0},{x:M,y:C+k},{width:E,height:1}),Ni.copy(b.data,g,{x:E-1,y:0},{x:M-1,y:C},{width:1,height:k}),Ni.copy(b.data,g,{x:0,y:0},{x:M+E,y:C},{width:1,height:k})}this.image=g,this.iconPositions=s,this.patternPositions=l}addImages(t,r,s){for(const l in t){const d=t[l],p={x:0,y:0,w:d.data.width+2*bi,h:d.data.height+2*bi};s.push(p),r[l]=new uh(p,d),d.hasRenderCallback&&this.haveRenderCallbacks.push(l)}}patchUpdatedImages(t,r){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const s in t.updatedImages)this.patchUpdatedImage(this.iconPositions[s],t.getImage(s),r),this.patchUpdatedImage(this.patternPositions[s],t.getImage(s),r)}patchUpdatedImage(t,r,s){if(!t||!r||t.version===r.version)return;t.version=r.version;const[l,d]=t.tl;s.update(r.data,void 0,{x:l,y:d})}}var Zn;Ae("ImagePosition",uh),Ae("ImageAtlas",yu),z.ai=void 0,(Zn=z.ai||(z.ai={}))[Zn.none=0]="none",Zn[Zn.horizontal=1]="horizontal",Zn[Zn.vertical=2]="vertical",Zn[Zn.horizontalOnly=3]="horizontalOnly";const uc=-17;class Yo{constructor(){this.scale=1,this.fontStack="",this.imageName=null,this.verticalAlign="bottom"}static forText(t,r,s){const l=new Yo;return l.scale=t||1,l.fontStack=r,l.verticalAlign=s||"bottom",l}static forImage(t,r){const s=new Yo;return s.imageName=t,s.verticalAlign=r||"bottom",s}}class Pa{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,r){const s=new Pa;for(let l=0;l<t.sections.length;l++){const d=t.sections[l];d.image?s.addImageSection(d):s.addTextSection(d,r)}return s}length(){return this.text.length}getSection(t){return this.sections[this.sectionIndex[t]]}getSectionIndex(t){return this.sectionIndex[t]}getCharCode(t){return this.text.charCodeAt(t)}verticalizePunctuation(){this.text=function(t){let r="";for(let s=0;s<t.length;s++){const l=t.charCodeAt(s+1)||null,d=t.charCodeAt(s-1)||null;r+=l&&Xl(l)&&!Ko[t[s+1]]||d&&Xl(d)&&!Ko[t[s-1]]||!Ko[t[s]]?t[s]:Ko[t[s]]}return r}(this.text)}trim(){let t=0;for(let s=0;s<this.text.length&&pc[this.text.charCodeAt(s)];s++)t++;let r=this.text.length;for(let s=this.text.length-1;s>=0&&s>=t&&pc[this.text.charCodeAt(s)];s--)r--;this.text=this.text.substring(t,r),this.sectionIndex=this.sectionIndex.slice(t,r)}substring(t,r){const s=new Pa;return s.text=this.text.substring(t,r),s.sectionIndex=this.sectionIndex.slice(t,r),s.sections=this.sections,s}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((t,r)=>Math.max(t,this.sections[r].scale),0)}getMaxImageSize(t){let r=0,s=0;for(let l=0;l<this.length();l++){const d=this.getSection(l);if(d.imageName){const p=t[d.imageName];if(!p)continue;const m=p.displaySize;r=Math.max(r,m[0]),s=Math.max(s,m[1])}}return{maxImageWidth:r,maxImageHeight:s}}addTextSection(t,r){this.text+=t.text,this.sections.push(Yo.forText(t.scale,t.fontStack||r,t.verticalAlign));const s=this.sections.length-1;for(let l=0;l<t.text.length;++l)this.sectionIndex.push(s)}addImageSection(t){const r=t.image?t.image.name:"";if(r.length===0)return void ti("Can't add FormattedSection with an empty image.");const s=this.getNextImageSectionCharCode();s?(this.text+=String.fromCharCode(s),this.sections.push(Yo.forImage(r,t.verticalAlign)),this.sectionIndex.push(this.sections.length-1)):ti("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function dc(n,t,r,s,l,d,p,m,g,x,b,w,M,C,E){const k=Pa.fromFeature(n,l);let O;w===z.ai.vertical&&k.verticalizePunctuation();const{processBidirectionalText:Z,processStyledBidirectionalText:ee}=ar;if(Z&&k.sections.length===1){O=[];const F=Z(k.toString(),dh(k,x,d,t,s,C));for(const H of F){const ae=new Pa;ae.text=H,ae.sections=k.sections;for(let xe=0;xe<H.length;xe++)ae.sectionIndex.push(0);O.push(ae)}}else if(ee){O=[];const F=ee(k.text,k.sectionIndex,dh(k,x,d,t,s,C));for(const H of F){const ae=new Pa;ae.text=H[0],ae.sectionIndex=H[1],ae.sections=k.sections,O.push(ae)}}else O=function(F,H){const ae=[],xe=F.text;let ce=0;for(const pe of H)ae.push(F.substring(ce,pe)),ce=pe;return ce<xe.length&&ae.push(F.substring(ce,xe.length)),ae}(k,dh(k,x,d,t,s,C));const q=[],I={positionedLines:q,text:k.toString(),top:b[1],bottom:b[1],left:b[0],right:b[0],writingMode:w,iconsInText:!1,verticalizable:!1};return function(F,H,ae,xe,ce,pe,we,be,Te,_e,ke,Fe){let Be=0,Re=0,Ke=0,It=0;const Zt=be==="right"?1:be==="left"?0:.5,ai=Ut/Fe;let Ui=0;for(const Pt of ce){Pt.trim();const $t=Pt.getMaxScale(),Jt={positionedGlyphs:[],lineOffset:0};F.positionedLines[Ui]=Jt;const Qt=Jt.positionedGlyphs;let pi=0;if(!Pt.length()){Re+=pe,++Ui;continue}const Zi=mp(xe,Pt,ai);for(let Ti=0;Ti<Pt.length();Ti++){const Gt=Pt.getSection(Ti),Ht=Pt.getSectionIndex(Ti),Xt=Pt.getCharCode(Ti),Ft=_p(Te,ke,Xt);let pt;if(Gt.imageName){if(F.iconsInText=!0,Gt.scale=Gt.scale*ai,pt=yp(Gt,Ft,$t,Zi,xe),!pt)continue;pi=Math.max(pi,pt.imageOffset)}else if(pt=gp(Gt,Xt,Ft,Zi,H,ae),!pt)continue;const{rect:hr,metrics:Ca,baselineOffset:ur}=pt;Qt.push({glyph:Xt,imageName:Gt.imageName,x:Be,y:Re+ur+uc,vertical:Ft,scale:Gt.scale,fontStack:Gt.fontStack,sectionIndex:Ht,metrics:Ca,rect:hr}),Ft?(F.verticalizable=!0,Be+=(Gt.imageName?Ca.advance:Ut)*Gt.scale+_e):Be+=Ca.advance*Gt.scale+_e}Qt.length!==0&&(Ke=Math.max(Be-_e,Ke),xp(Qt,0,Qt.length-1,Zt)),Be=0,Jt.lineOffset=Math.max(pi,($t-1)*Ut);const qt=pe*$t+pi;Re+=qt,It=Math.max(qt,It),++Ui}const{horizontalAlign:wi,verticalAlign:Yt}=ph(we);(function(Pt,$t,Jt,Qt,pi,Zi,qt,Ti,Gt){const Ht=($t-Jt)*pi;let Xt=0;Xt=Zi!==qt?-Ti*Qt-uc:-Qt*Gt*qt+.5*qt;for(const Ft of Pt)for(const pt of Ft.positionedGlyphs)pt.x+=Ht,pt.y+=Xt})(F.positionedLines,Zt,wi,Yt,Ke,It,pe,Re,ce.length),F.top+=-Yt*Re,F.bottom=F.top+Re,F.left+=-wi*Ke,F.right=F.left+Ke}(I,t,r,s,O,p,m,g,w,x,M,E),!function(F){for(const H of F)if(H.positionedGlyphs.length!==0)return!1;return!0}(q)&&I}const pc={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},dp={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},pp={40:!0};function xu(n,t,r,s,l,d){if(t.imageName){const p=s[t.imageName];return p?p.displaySize[0]*t.scale*Ut/d+l:0}{const p=r[t.fontStack],m=p&&p[n];return m?m.metrics.advance*t.scale+l:0}}function vu(n,t,r,s){const l=Math.pow(n-t,2);return s?n<t?l/2:2*l:l+Math.abs(r)*r}function fp(n,t,r){let s=0;return n===10&&(s-=1e4),r&&(s+=150),n!==40&&n!==65288||(s+=50),t!==41&&t!==65289||(s+=50),s}function bu(n,t,r,s,l,d){let p=null,m=vu(t,r,l,d);for(const g of s){const x=vu(t-g.x,r,l,d)+g.badness;x<=m&&(p=g,m=x)}return{index:n,x:t,priorBreak:p,badness:m}}function wu(n){return n?wu(n.priorBreak).concat(n.index):[]}function dh(n,t,r,s,l,d){if(!n)return[];const p=[],m=function(w,M,C,E,k,O){let Z=0;for(let ee=0;ee<w.length();ee++){const q=w.getSection(ee);Z+=xu(w.getCharCode(ee),q,E,k,M,O)}return Z/Math.max(1,Math.ceil(Z/C))}(n,t,r,s,l,d),g=n.text.indexOf("")>=0;let x=0;for(let w=0;w<n.length();w++){const M=n.getSection(w),C=n.getCharCode(w);if(pc[C]||(x+=xu(C,M,s,l,t,d)),w<n.length()-1){const E=!((b=C)<11904)&&(!!We["CJK Compatibility Forms"](b)||!!We["CJK Compatibility"](b)||!!We["CJK Strokes"](b)||!!We["CJK Symbols and Punctuation"](b)||!!We["Enclosed CJK Letters and Months"](b)||!!We["Halfwidth and Fullwidth Forms"](b)||!!We["Ideographic Description Characters"](b)||!!We["Vertical Forms"](b)||ha.test(String.fromCodePoint(b)));(dp[C]||E||M.imageName||w!==n.length()-2&&pp[n.getCharCode(w+1)])&&p.push(bu(w+1,x,m,p,fp(C,n.getCharCode(w+1),E&&g),!1))}}var b;return wu(bu(n.length(),x,m,p,0,!0))}function ph(n){let t=.5,r=.5;switch(n){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(n){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:t,verticalAlign:r}}function mp(n,t,r){const s=t.getMaxScale()*Ut,{maxImageWidth:l,maxImageHeight:d}=t.getMaxImageSize(n),p=Math.max(s,d*r);return{verticalLineContentWidth:Math.max(s,l*r),horizontalLineContentHeight:p}}function Tu(n){switch(n){case"top":return 0;case"center":return .5;default:return 1}}function _p(n,t,r){return!(n===z.ai.horizontal||!t&&!ua(r)||t&&(pc[r]||(s=r,new RegExp("\\p{sc=Arab}","u").test(String.fromCodePoint(s)))));var s}function gp(n,t,r,s,l,d){const p=d[n.fontStack],m=function(x,b,w,M){if(x&&x.rect)return x;const C=b[w.fontStack],E=C&&C[M];return E?{rect:null,metrics:E.metrics}:null}(p&&p[t],l,n,t);if(m===null)return null;let g;if(r)g=s.verticalLineContentWidth-n.scale*Ut;else{const x=Tu(n.verticalAlign);g=(s.horizontalLineContentHeight-n.scale*Ut)*x}return{rect:m.rect,metrics:m.metrics,baselineOffset:g}}function yp(n,t,r,s,l){const d=l[n.imageName];if(!d)return null;const p=d.paddedRect,m=d.displaySize,g={width:m[0],height:m[1],left:bi,top:-3,advance:t?m[1]:m[0]};let x;if(t)x=s.verticalLineContentWidth-m[1]*n.scale;else{const b=Tu(n.verticalAlign);x=(s.horizontalLineContentHeight-m[1]*n.scale)*b}return{rect:p,metrics:g,baselineOffset:x,imageOffset:(t?m[0]:m[1])*n.scale-Ut*r}}function xp(n,t,r,s){if(s===0)return;const l=n[r],d=(n[r].x+l.metrics.advance*l.scale)*s;for(let p=t;p<=r;p++)n[p].x-=d}function vp(n,t,r){const{horizontalAlign:s,verticalAlign:l}=ph(r),d=t[0]-n.displaySize[0]*s,p=t[1]-n.displaySize[1]*l;return{image:n,top:p,bottom:p+n.displaySize[1],left:d,right:d+n.displaySize[0]}}function Pu(n){var t,r;let s=n.left,l=n.top,d=n.right-s,p=n.bottom-l;const m=(t=n.image.textFitWidth)!==null&&t!==void 0?t:"stretchOrShrink",g=(r=n.image.textFitHeight)!==null&&r!==void 0?r:"stretchOrShrink",x=(n.image.content[2]-n.image.content[0])/(n.image.content[3]-n.image.content[1]);if(g==="proportional"){if(m==="stretchOnly"&&d/p<x||m==="proportional"){const b=Math.ceil(p*x);s*=b/d,d=b}}else if(m==="proportional"&&g==="stretchOnly"&&x!==0&&d/p>x){const b=Math.ceil(d/x);l*=b/p,p=b}return{x1:s,y1:l,x2:s+d,y2:l+p}}function Mu(n,t,r,s,l,d){const p=n.image;let m;if(p.content){const O=p.content,Z=p.pixelRatio||1;m=[O[0]/Z,O[1]/Z,p.displaySize[0]-O[2]/Z,p.displaySize[1]-O[3]/Z]}const g=t.left*d,x=t.right*d;let b,w,M,C;r==="width"||r==="both"?(C=l[0]+g-s[3],w=l[0]+x+s[1]):(C=l[0]+(g+x-p.displaySize[0])/2,w=C+p.displaySize[0]);const E=t.top*d,k=t.bottom*d;return r==="height"||r==="both"?(b=l[1]+E-s[0],M=l[1]+k+s[2]):(b=l[1]+(E+k-p.displaySize[1])/2,M=b+p.displaySize[1]),{image:p,top:b,right:w,bottom:M,left:C,collisionPadding:m}}const Jo=255,kr=128,Gn=Jo*kr;function Su(n,t){const{expression:r}=t;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new yt(n+1))};if(r.kind==="source")return{kind:"source"};{const{zoomStops:s,interpolationType:l}=r;let d=0;for(;d<s.length&&s[d]<=n;)d++;d=Math.max(0,d-1);let p=d;for(;p<s.length&&s[p]<n+1;)p++;p=Math.min(s.length-1,p);const m=s[d],g=s[p];return r.kind==="composite"?{kind:"composite",minZoom:m,maxZoom:g,interpolationType:l}:{kind:"camera",minZoom:m,maxZoom:g,minSize:r.evaluate(new yt(m)),maxSize:r.evaluate(new yt(g)),interpolationType:l}}}function fh(n,t,r){let s="never";const l=n.get(t);return l?s=l:n.get(r)&&(s="always"),s}const bp=Ho.VectorTileFeature.types,wp=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function fc(n,t,r,s,l,d,p,m,g,x,b,w,M){const C=m?Math.min(Gn,Math.round(m[0])):0,E=m?Math.min(Gn,Math.round(m[1])):0;n.emplaceBack(t,r,Math.round(32*s),Math.round(32*l),d,p,(C<<1)+(g?1:0),E,16*x,16*b,256*w,256*M)}function mh(n,t,r){n.emplaceBack(t.x,t.y,r),n.emplaceBack(t.x,t.y,r),n.emplaceBack(t.x,t.y,r),n.emplaceBack(t.x,t.y,r)}function Tp(n){for(const t of n.sections)if(Jl(t.text))return!0;return!1}class _h{constructor(t){this.layoutVertexArray=new J,this.indexArray=new de,this.programConfigurations=t,this.segments=new Ee,this.dynamicLayoutVertexArray=new se,this.opacityVertexArray=new oe,this.hasVisibleVertices=!1,this.placedSymbolArray=new _}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(t,r,s,l){this.isEmpty()||(s&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ip.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,rp.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,wp,!0),this.opacityVertexBuffer.itemSize=1),(s||l)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}Ae("SymbolBuffers",_h);class gh{constructor(t,r,s){this.layoutVertexArray=new t,this.layoutAttributes=r,this.indexArray=new s,this.segments=new Ee,this.collisionVertexArray=new ye}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,np.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}Ae("CollisionBuffers",gh);class Ma{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(p=>p.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Su(this.zoom,r["text-size"]),this.iconSizeData=Su(this.zoom,r["icon-size"]);const s=this.layers[0].layout,l=s.get("symbol-sort-key"),d=s.get("symbol-z-order");this.canOverlap=fh(s,"text-overlap","text-allow-overlap")!=="never"||fh(s,"icon-overlap","icon-allow-overlap")!=="never"||s.get("text-ignore-placement")||s.get("icon-ignore-placement"),this.sortFeaturesByKey=d!=="viewport-y"&&!l.isConstant(),this.sortFeaturesByY=(d==="viewport-y"||d==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,s.get("symbol-placement")==="point"&&(this.writingModes=s.get("text-writing-mode").map(p=>z.ai[p])),this.stateDependentLayerIds=this.layers.filter(p=>p.isStateDependent()).map(p=>p.id),this.sourceID=t.sourceID}createArrays(){this.text=new _h(new Tt(this.layers,this.zoom,t=>/^text/.test(t))),this.icon=new _h(new Tt(this.layers,this.zoom,t=>/^icon/.test(t))),this.glyphOffsetArray=new T,this.lineVertexArray=new P,this.symbolInstances=new v,this.textAnchorOffsets=new A}calculateGlyphDependencies(t,r,s,l,d){for(let p=0;p<t.length;p++)if(r[t.charCodeAt(p)]=!0,(s||l)&&d){const m=Ko[t.charAt(p)];m&&(r[m.charCodeAt(0)]=!0)}}populate(t,r,s){const l=this.layers[0],d=l.layout,p=d.get("text-font"),m=d.get("text-field"),g=d.get("icon-image"),x=(m.value.kind!=="constant"||m.value.value instanceof Et&&!m.value.value.isEmpty()||m.value.value.toString().length>0)&&(p.value.kind!=="constant"||p.value.value.length>0),b=g.value.kind!=="constant"||!!g.value.value||Object.keys(g.parameters).length>0,w=d.get("symbol-sort-key");if(this.features=[],!x&&!b)return;const M=r.iconDependencies,C=r.glyphDependencies,E=r.availableImages,k=new yt(this.zoom);for(const{feature:O,id:Z,index:ee,sourceLayerIndex:q}of t){const I=l._featureFilter.needGeometry,F=_n(O,I);if(!l._featureFilter.filter(k,F,s))continue;let H,ae;if(I||(F.geometry=mn(O)),x){const ce=l.getValueAndResolveTokens("text-field",F,s,E),pe=Et.factory(ce),we=this.hasRTLText=this.hasRTLText||Tp(pe);(!we||ar.getRTLTextPluginStatus()==="unavailable"||we&&ar.isParsed())&&(H=ap(pe,l,F))}if(b){const ce=l.getValueAndResolveTokens("icon-image",F,s,E);ae=ce instanceof ri?ce:ri.fromString(ce)}if(!H&&!ae)continue;const xe=this.sortFeaturesByKey?w.evaluate(F,{},s):void 0;if(this.features.push({id:Z,text:H,icon:ae,index:ee,sourceLayerIndex:q,geometry:F.geometry,properties:O.properties,type:bp[O.type],sortKey:xe}),ae&&(M[ae.name]=!0),H){const ce=p.evaluate(F,{},s).join(","),pe=d.get("text-rotation-alignment")!=="viewport"&&d.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(z.ai.vertical)>=0;for(const we of H.sections)if(we.image)M[we.image.name]=!0;else{const be=On(H.toString()),Te=we.fontStack||ce,_e=C[Te]=C[Te]||{};this.calculateGlyphDependencies(we.text,_e,pe,this.allowVerticalPlacement,be)}}}d.get("symbol-placement")==="line"&&(this.features=function(O){const Z={},ee={},q=[];let I=0;function F(ce){q.push(O[ce]),I++}function H(ce,pe,we){const be=ee[ce];return delete ee[ce],ee[pe]=be,q[be].geometry[0].pop(),q[be].geometry[0]=q[be].geometry[0].concat(we[0]),be}function ae(ce,pe,we){const be=Z[pe];return delete Z[pe],Z[ce]=be,q[be].geometry[0].shift(),q[be].geometry[0]=we[0].concat(q[be].geometry[0]),be}function xe(ce,pe,we){const be=we?pe[0][pe[0].length-1]:pe[0][0];return`${ce}:${be.x}:${be.y}`}for(let ce=0;ce<O.length;ce++){const pe=O[ce],we=pe.geometry,be=pe.text?pe.text.toString():null;if(!be){F(ce);continue}const Te=xe(be,we),_e=xe(be,we,!0);if(Te in ee&&_e in Z&&ee[Te]!==Z[_e]){const ke=ae(Te,_e,we),Fe=H(Te,_e,q[ke].geometry);delete Z[Te],delete ee[_e],ee[xe(be,q[Fe].geometry,!0)]=Fe,q[ke].geometry=null}else Te in ee?H(Te,_e,we):_e in Z?ae(Te,_e,we):(F(ce),Z[Te]=I-1,ee[_e]=I-1)}return q.filter(ce=>ce.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((O,Z)=>O.sortKey-Z.sortKey)}update(t,r,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,r,this.layers,s),this.icon.programConfigurations.updatePaintArrays(t,r,this.layers,s))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,r){const s=this.lineVertexArray.length;if(t.segment!==void 0){let l=t.dist(r[t.segment+1]),d=t.dist(r[t.segment]);const p={};for(let m=t.segment+1;m<r.length;m++)p[m]={x:r[m].x,y:r[m].y,tileUnitDistanceFromAnchor:l},m<r.length-1&&(l+=r[m+1].dist(r[m]));for(let m=t.segment||0;m>=0;m--)p[m]={x:r[m].x,y:r[m].y,tileUnitDistanceFromAnchor:d},m>0&&(d+=r[m-1].dist(r[m]));for(let m=0;m<r.length;m++){const g=p[m];this.lineVertexArray.emplaceBack(g.x,g.y,g.tileUnitDistanceFromAnchor)}}return{lineStartIndex:s,lineLength:this.lineVertexArray.length-s}}addSymbols(t,r,s,l,d,p,m,g,x,b,w,M){const C=t.indexArray,E=t.layoutVertexArray,k=t.segments.prepareSegment(4*r.length,E,C,this.canOverlap?p.sortKey:void 0),O=this.glyphOffsetArray.length,Z=k.vertexLength,ee=this.allowVerticalPlacement&&m===z.ai.vertical?Math.PI/2:0,q=p.text&&p.text.sections;for(let I=0;I<r.length;I++){const{tl:F,tr:H,bl:ae,br:xe,tex:ce,pixelOffsetTL:pe,pixelOffsetBR:we,minFontScaleX:be,minFontScaleY:Te,glyphOffset:_e,isSDF:ke,sectionIndex:Fe}=r[I],Be=k.vertexLength,Re=_e[1];fc(E,g.x,g.y,F.x,Re+F.y,ce.x,ce.y,s,ke,pe.x,pe.y,be,Te),fc(E,g.x,g.y,H.x,Re+H.y,ce.x+ce.w,ce.y,s,ke,we.x,pe.y,be,Te),fc(E,g.x,g.y,ae.x,Re+ae.y,ce.x,ce.y+ce.h,s,ke,pe.x,we.y,be,Te),fc(E,g.x,g.y,xe.x,Re+xe.y,ce.x+ce.w,ce.y+ce.h,s,ke,we.x,we.y,be,Te),mh(t.dynamicLayoutVertexArray,g,ee),C.emplaceBack(Be,Be+2,Be+1),C.emplaceBack(Be+1,Be+2,Be+3),k.vertexLength+=4,k.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(_e[0]),I!==r.length-1&&Fe===r[I+1].sectionIndex||t.programConfigurations.populatePaintArrays(E.length,p,p.index,{},M,q&&q[Fe])}t.placedSymbolArray.emplaceBack(g.x,g.y,O,this.glyphOffsetArray.length-O,Z,x,b,g.segment,s?s[0]:0,s?s[1]:0,l[0],l[1],m,0,!1,0,w)}_addCollisionDebugVertex(t,r,s,l,d,p){return r.emplaceBack(0,0),t.emplaceBack(s.x,s.y,l,d,Math.round(p.x),Math.round(p.y))}addCollisionDebugVertices(t,r,s,l,d,p,m){const g=d.segments.prepareSegment(4,d.layoutVertexArray,d.indexArray),x=g.vertexLength,b=d.layoutVertexArray,w=d.collisionVertexArray,M=m.anchorX,C=m.anchorY;this._addCollisionDebugVertex(b,w,p,M,C,new Oe(t,r)),this._addCollisionDebugVertex(b,w,p,M,C,new Oe(s,r)),this._addCollisionDebugVertex(b,w,p,M,C,new Oe(s,l)),this._addCollisionDebugVertex(b,w,p,M,C,new Oe(t,l)),g.vertexLength+=4;const E=d.indexArray;E.emplaceBack(x,x+1),E.emplaceBack(x+1,x+2),E.emplaceBack(x+2,x+3),E.emplaceBack(x+3,x),g.primitiveLength+=4}addDebugCollisionBoxes(t,r,s,l){for(let d=t;d<r;d++){const p=this.collisionBoxArray.get(d);this.addCollisionDebugVertices(p.x1,p.y1,p.x2,p.y2,l?this.textCollisionBox:this.iconCollisionBox,p.anchorPoint,s)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new gh(me,pu.members,Se),this.iconCollisionBox=new gh(me,pu.members,Se);for(let t=0;t<this.symbolInstances.length;t++){const r=this.symbolInstances.get(t);this.addDebugCollisionBoxes(r.textBoxStartIndex,r.textBoxEndIndex,r,!0),this.addDebugCollisionBoxes(r.verticalTextBoxStartIndex,r.verticalTextBoxEndIndex,r,!0),this.addDebugCollisionBoxes(r.iconBoxStartIndex,r.iconBoxEndIndex,r,!1),this.addDebugCollisionBoxes(r.verticalIconBoxStartIndex,r.verticalIconBoxEndIndex,r,!1)}}_deserializeCollisionBoxesForSymbol(t,r,s,l,d,p,m,g,x){const b={};for(let w=r;w<s;w++){const M=t.get(w);b.textBox={x1:M.x1,y1:M.y1,x2:M.x2,y2:M.y2,anchorPointX:M.anchorPointX,anchorPointY:M.anchorPointY},b.textFeatureIndex=M.featureIndex;break}for(let w=l;w<d;w++){const M=t.get(w);b.verticalTextBox={x1:M.x1,y1:M.y1,x2:M.x2,y2:M.y2,anchorPointX:M.anchorPointX,anchorPointY:M.anchorPointY},b.verticalTextFeatureIndex=M.featureIndex;break}for(let w=p;w<m;w++){const M=t.get(w);b.iconBox={x1:M.x1,y1:M.y1,x2:M.x2,y2:M.y2,anchorPointX:M.anchorPointX,anchorPointY:M.anchorPointY},b.iconFeatureIndex=M.featureIndex;break}for(let w=g;w<x;w++){const M=t.get(w);b.verticalIconBox={x1:M.x1,y1:M.y1,x2:M.x2,y2:M.y2,anchorPointX:M.anchorPointX,anchorPointY:M.anchorPointY},b.verticalIconFeatureIndex=M.featureIndex;break}return b}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let r=0;r<this.symbolInstances.length;r++){const s=this.symbolInstances.get(r);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,s.textBoxStartIndex,s.textBoxEndIndex,s.verticalTextBoxStartIndex,s.verticalTextBoxEndIndex,s.iconBoxStartIndex,s.iconBoxEndIndex,s.verticalIconBoxStartIndex,s.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,r){const s=t.placedSymbolArray.get(r),l=s.vertexStartIndex+4*s.numGlyphs;for(let d=s.vertexStartIndex;d<l;d+=4)t.indexArray.emplaceBack(d,d+2,d+1),t.indexArray.emplaceBack(d+1,d+2,d+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const r=Math.sin(t),s=Math.cos(t),l=[],d=[],p=[];for(let m=0;m<this.symbolInstances.length;++m){p.push(m);const g=this.symbolInstances.get(m);l.push(0|Math.round(r*g.anchorX+s*g.anchorY)),d.push(g.featureIndex)}return p.sort((m,g)=>l[m]-l[g]||d[g]-d[m]),p}addToSortKeyRanges(t,r){const s=this.sortKeyRanges[this.sortKeyRanges.length-1];s&&s.sortKey===r?s.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const r of this.symbolInstanceIndexes){const s=this.symbolInstances.get(r);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach((l,d,p)=>{l>=0&&p.indexOf(l)===d&&this.addIndicesForPlacedSymbol(this.text,l)}),s.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,s.verticalPlacedTextSymbolIndex),s.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.placedIconSymbolIndex),s.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Iu,Cu;Ae("SymbolBucket",Ma,{omit:["layers","collisionBoxArray","features","compareText"]}),Ma.MAX_GLYPHS=65535,Ma.addDynamicAttributes=mh;var yh={get paint(){return Cu=Cu||new ui({"icon-opacity":new Ne(j.paint_symbol["icon-opacity"]),"icon-color":new Ne(j.paint_symbol["icon-color"]),"icon-halo-color":new Ne(j.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ne(j.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ne(j.paint_symbol["icon-halo-blur"]),"icon-translate":new Le(j.paint_symbol["icon-translate"]),"icon-translate-anchor":new Le(j.paint_symbol["icon-translate-anchor"]),"text-opacity":new Ne(j.paint_symbol["text-opacity"]),"text-color":new Ne(j.paint_symbol["text-color"],{runtimeType:qe,getOverride:n=>n.textColor,hasOverride:n=>!!n.textColor}),"text-halo-color":new Ne(j.paint_symbol["text-halo-color"]),"text-halo-width":new Ne(j.paint_symbol["text-halo-width"]),"text-halo-blur":new Ne(j.paint_symbol["text-halo-blur"]),"text-translate":new Le(j.paint_symbol["text-translate"]),"text-translate-anchor":new Le(j.paint_symbol["text-translate-anchor"])})},get layout(){return Iu=Iu||new ui({"symbol-placement":new Le(j.layout_symbol["symbol-placement"]),"symbol-spacing":new Le(j.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Le(j.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ne(j.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Le(j.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Le(j.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Le(j.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Le(j.layout_symbol["icon-ignore-placement"]),"icon-optional":new Le(j.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Le(j.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ne(j.layout_symbol["icon-size"]),"icon-text-fit":new Le(j.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Le(j.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ne(j.layout_symbol["icon-image"]),"icon-rotate":new Ne(j.layout_symbol["icon-rotate"]),"icon-padding":new Ne(j.layout_symbol["icon-padding"]),"icon-keep-upright":new Le(j.layout_symbol["icon-keep-upright"]),"icon-offset":new Ne(j.layout_symbol["icon-offset"]),"icon-anchor":new Ne(j.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Le(j.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Le(j.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Le(j.layout_symbol["text-rotation-alignment"]),"text-field":new Ne(j.layout_symbol["text-field"]),"text-font":new Ne(j.layout_symbol["text-font"]),"text-size":new Ne(j.layout_symbol["text-size"]),"text-max-width":new Ne(j.layout_symbol["text-max-width"]),"text-line-height":new Le(j.layout_symbol["text-line-height"]),"text-letter-spacing":new Ne(j.layout_symbol["text-letter-spacing"]),"text-justify":new Ne(j.layout_symbol["text-justify"]),"text-radial-offset":new Ne(j.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Le(j.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Ne(j.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Ne(j.layout_symbol["text-anchor"]),"text-max-angle":new Le(j.layout_symbol["text-max-angle"]),"text-writing-mode":new Le(j.layout_symbol["text-writing-mode"]),"text-rotate":new Ne(j.layout_symbol["text-rotate"]),"text-padding":new Le(j.layout_symbol["text-padding"]),"text-keep-upright":new Le(j.layout_symbol["text-keep-upright"]),"text-transform":new Ne(j.layout_symbol["text-transform"]),"text-offset":new Ne(j.layout_symbol["text-offset"]),"text-allow-overlap":new Le(j.layout_symbol["text-allow-overlap"]),"text-overlap":new Le(j.layout_symbol["text-overlap"]),"text-ignore-placement":new Le(j.layout_symbol["text-ignore-placement"]),"text-optional":new Le(j.layout_symbol["text-optional"])})}};class Eu{constructor(t){if(t.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:Ue,this.defaultValue=t}evaluate(t){if(t.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(t.formattedSection))return r.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Ae("FormatSectionOverride",Eu,{omit:["defaultValue"]});class mc extends Ki{constructor(t){super(t,yh)}recalculate(t,r){if(super.recalculate(t,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const s=this.layout.get("text-writing-mode");if(s){const l=[];for(const d of s)l.indexOf(d)<0&&l.push(d);this.layout._values["text-writing-mode"]=l}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,r,s,l){const d=this.layout.get(t).evaluate(r,{},s,l),p=this._unevaluatedLayout._values[t];return p.isDataDriven()||Js(p.value)||!d?d:function(m,g){return g.replace(/{([^{}]+)}/g,(x,b)=>m&&b in m?String(m[b]):"")}(r.properties,d)}createBucket(t){return new Ma(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of yh.paint.overridableProperties){if(!mc.hasPaintOverride(this.layout,t))continue;const r=this.paint.get(t),s=new Eu(r),l=new Ys(s,r.property.specification);let d=null;d=r.value.kind==="constant"||r.value.kind==="source"?new zn("source",l):new ea("composite",l,r.value.zoomStops),this.paint._values[t]=new Wi(r.property,d,r.parameters)}}_handleOverridablePaintPropertyUpdate(t,r,s){return!(!this.layout||r.isDataDriven()||s.isDataDriven())&&mc.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,r){const s=t.get("text-field"),l=yh.paint.properties[r];let d=!1;const p=m=>{for(const g of m)if(l.overrides&&l.overrides.hasOverride(g))return void(d=!0)};if(s.value.kind==="constant"&&s.value.value instanceof Et)p(s.value.value.sections);else if(s.value.kind==="source"){const m=x=>{d||(x instanceof Xi&&ut(x.value)===Mr?p(x.value.sections):x instanceof ls?p(x.sections):x.eachChild(m))},g=s.value;g._styleExpression&&m(g._styleExpression.expression)}return d}}let Au;var Pp={get paint(){return Au=Au||new ui({"background-color":new Le(j.paint_background["background-color"]),"background-pattern":new ma(j.paint_background["background-pattern"]),"background-opacity":new Le(j.paint_background["background-opacity"])})}};class Mp extends Ki{constructor(t){super(t,Pp)}}let zu;var Sp={get paint(){return zu=zu||new ui({"raster-opacity":new Le(j.paint_raster["raster-opacity"]),"raster-hue-rotate":new Le(j.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Le(j.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Le(j.paint_raster["raster-brightness-max"]),"raster-saturation":new Le(j.paint_raster["raster-saturation"]),"raster-contrast":new Le(j.paint_raster["raster-contrast"]),"raster-resampling":new Le(j.paint_raster["raster-resampling"]),"raster-fade-duration":new Le(j.paint_raster["raster-fade-duration"])})}};class Ip extends Ki{constructor(t){super(t,Sp)}}class Cp extends Ki{constructor(t){super(t,{}),this.onAdd=r=>{this.implementation.onAdd&&this.implementation.onAdd(r,r.painter.context.gl)},this.onRemove=r=>{this.implementation.onRemove&&this.implementation.onRemove(r,r.painter.context.gl)},this.implementation=t}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Ep{constructor(t){this._methodToThrottle=t,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._methodToThrottle()},0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const xh=63710088e-1;class $n{constructor(t,r){if(isNaN(t)||isNaN(r))throw new Error(`Invalid LngLat object: (${t}, ${r})`);if(this.lng=+t,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new $n(Ii(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const r=Math.PI/180,s=this.lat*r,l=t.lat*r,d=Math.sin(s)*Math.sin(l)+Math.cos(s)*Math.cos(l)*Math.cos((t.lng-this.lng)*r);return xh*Math.acos(Math.min(d,1))}static convert(t){if(t instanceof $n)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new $n(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t!==null)return new $n(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const ku=2*Math.PI*xh;function Du(n){return ku*Math.cos(n*Math.PI/180)}function Ru(n){return(180+n)/360}function Lu(n){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+n*Math.PI/360)))/360}function Bu(n,t){return n/Du(t)}function vh(n){return 360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90}function Fu(n,t){return n*Du(vh(t))}class Qo{constructor(t,r,s=0){this.x=+t,this.y=+r,this.z=+s}static fromLngLat(t,r=0){const s=$n.convert(t);return new Qo(Ru(s.lng),Lu(s.lat),Bu(r,s.lat))}toLngLat(){return new $n(360*this.x-180,vh(this.y))}toAltitude(){return Fu(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/ku*(t=vh(this.y),1/Math.cos(t*Math.PI/180));var t}}function Ou(n,t,r){var s=2*Math.PI*6378137/256/Math.pow(2,r);return[n*s-2*Math.PI*6378137/2,t*s-2*Math.PI*6378137/2]}class bh{constructor(t,r,s){if(!function(l,d,p){return!(l<0||l>25||p<0||p>=Math.pow(2,l)||d<0||d>=Math.pow(2,l))}(t,r,s))throw new Error(`x=${r}, y=${s}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=r,this.y=s,this.key=Sa(0,t,t,r,s)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,r,s){const l=(p=this.y,m=this.z,g=Ou(256*(d=this.x),256*(p=Math.pow(2,m)-p-1),m),x=Ou(256*(d+1),256*(p+1),m),g[0]+","+g[1]+","+x[0]+","+x[1]);var d,p,m,g,x;const b=function(w,M,C){let E,k="";for(let O=w;O>0;O--)E=1<<O-1,k+=(M&E?1:0)+(C&E?2:0);return k}(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(s==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,r>1?"@2x":"").replace(/{quadkey}/g,b).replace(/{bbox-epsg-3857}/g,l)}isChildOf(t){const r=this.z-t.z;return r>0&&t.x===this.x>>r&&t.y===this.y>>r}getTilePoint(t){const r=Math.pow(2,this.z);return new Oe((t.x*r-this.x)*rt,(t.y*r-this.y)*rt)}toString(){return`${this.z}/${this.x}/${this.y}`}}class ju{constructor(t,r){this.wrap=t,this.canonical=r,this.key=Sa(t,r.z,r.z,r.x,r.y)}}class Vi{constructor(t,r,s,l,d){if(this.terrainRttPosMatrix32f=null,t<s)throw new Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${s}`);this.overscaledZ=t,this.wrap=r,this.canonical=new bh(s,+l,+d),this.key=Sa(r,t,s,l,d)}clone(){return new Vi(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-t;return t>this.canonical.z?new Vi(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Vi(t,this.wrap,t,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(t,r){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const s=this.canonical.z-t;return t>this.canonical.z?Sa(this.wrap*+r,t,this.canonical.z,this.canonical.x,this.canonical.y):Sa(this.wrap*+r,t,t,this.canonical.x>>s,this.canonical.y>>s)}isChildOf(t){if(t.wrap!==this.wrap)return!1;const r=this.canonical.z-t.canonical.z;return t.overscaledZ===0||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>r&&t.canonical.y===this.canonical.y>>r}children(t){if(this.overscaledZ>=t)return[new Vi(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,s=2*this.canonical.x,l=2*this.canonical.y;return[new Vi(r,this.wrap,r,s,l),new Vi(r,this.wrap,r,s+1,l),new Vi(r,this.wrap,r,s,l+1),new Vi(r,this.wrap,r,s+1,l+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new Vi(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new Vi(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new ju(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new Qo(t.x-this.wrap,t.y))}}function Sa(n,t,r,s,l){(n*=2)<0&&(n=-1*n-1);const d=1<<r;return(d*d*n+d*l+s).toString(36)+r.toString(36)+t.toString(36)}Ae("CanonicalTileID",bh),Ae("OverscaledTileID",Vi,{omit:["terrainRttPosMatrix32f"]});class Nu{constructor(t,r,s,l=1,d=1,p=1,m=0){if(this.uid=t,r.height!==r.width)throw new RangeError("DEM tiles must be square");if(s&&!["mapbox","terrarium","custom"].includes(s))return void ti(`"${s}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=r.height;const g=this.dim=r.height-2;switch(this.data=new Uint32Array(r.data.buffer),s){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=l,this.greenFactor=d,this.blueFactor=p,this.baseShift=m;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let x=0;x<g;x++)this.data[this._idx(-1,x)]=this.data[this._idx(0,x)],this.data[this._idx(g,x)]=this.data[this._idx(g-1,x)],this.data[this._idx(x,-1)]=this.data[this._idx(x,0)],this.data[this._idx(x,g)]=this.data[this._idx(x,g-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(g,-1)]=this.data[this._idx(g-1,0)],this.data[this._idx(-1,g)]=this.data[this._idx(0,g-1)],this.data[this._idx(g,g)]=this.data[this._idx(g-1,g-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let x=0;x<g;x++)for(let b=0;b<g;b++){const w=this.get(x,b);w>this.max&&(this.max=w),w<this.min&&(this.min=w)}}get(t,r){const s=new Uint8Array(this.data.buffer),l=4*this._idx(t,r);return this.unpack(s[l],s[l+1],s[l+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(t,r){if(t<-1||t>=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(t+1)}unpack(t,r,s){return t*this.redFactor+r*this.greenFactor+s*this.blueFactor-this.baseShift}getPixels(){return new Ni({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,r,s){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let l=r*this.dim,d=r*this.dim+this.dim,p=s*this.dim,m=s*this.dim+this.dim;switch(r){case-1:l=d-1;break;case 1:d=l+1}switch(s){case-1:p=m-1;break;case 1:m=p+1}const g=-r*this.dim,x=-s*this.dim;for(let b=p;b<m;b++)for(let w=l;w<d;w++)this.data[this._idx(w,b)]=t.data[this._idx(w+g,b+x)]}}Ae("DEMData",Nu);class Vu{constructor(t){this._stringToNumber={},this._numberToString=[];for(let r=0;r<t.length;r++){const s=t[r];this._stringToNumber[s]=r,this._numberToString[r]=s}}encode(t){return this._stringToNumber[t]}decode(t){if(t>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class Uu{constructor(t,r,s,l,d){this.type="Feature",this._vectorTileFeature=t,t._z=r,t._x=s,t._y=l,this.properties=t.properties,this.id=d}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const r in this)r!=="_geometry"&&r!=="_vectorTileFeature"&&(t[r]=this[r]);return t}}class Zu{constructor(t,r){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new dn(rt,16,0),this.grid3D=new dn(rt,16,0),this.featureIndexArray=new V,this.promoteId=r}insert(t,r,s,l,d,p){const m=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(s,l,d);const g=p?this.grid3D:this.grid;for(let x=0;x<r.length;x++){const b=r[x],w=[1/0,1/0,-1/0,-1/0];for(let M=0;M<b.length;M++){const C=b[M];w[0]=Math.min(w[0],C.x),w[1]=Math.min(w[1],C.y),w[2]=Math.max(w[2],C.x),w[3]=Math.max(w[3],C.y)}w[0]<rt&&w[1]<rt&&w[2]>=0&&w[3]>=0&&g.insert(m,w[0],w[1],w[2],w[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Ho.VectorTile(new ch(this.rawTileData)).layers,this.sourceLayerCoder=new Vu(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,r,s,l){this.loadVTLayers();const d=t.params,p=rt/t.tileSize/t.scale,m=ra(d.filter),g=t.queryGeometry,x=t.queryPadding*p,b=$u(g),w=this.grid.query(b.minX-x,b.minY-x,b.maxX+x,b.maxY+x),M=$u(t.cameraQueryGeometry),C=this.grid3D.query(M.minX-x,M.minY-x,M.maxX+x,M.maxY+x,(O,Z,ee,q)=>function(I,F,H,ae,xe){for(const pe of I)if(F<=pe.x&&H<=pe.y&&ae>=pe.x&&xe>=pe.y)return!0;const ce=[new Oe(F,H),new Oe(F,xe),new Oe(ae,xe),new Oe(ae,H)];if(I.length>2){for(const pe of ce)if(va(I,pe))return!0}for(let pe=0;pe<I.length-1;pe++)if(yd(I[pe],I[pe+1],ce))return!0;return!1}(t.cameraQueryGeometry,O-x,Z-x,ee+x,q+x));for(const O of C)w.push(O);w.sort(Ap);const E={};let k;for(let O=0;O<w.length;O++){const Z=w[O];if(Z===k)continue;k=Z;const ee=this.featureIndexArray.get(Z);let q=null;this.loadMatchingFeature(E,ee.bucketIndex,ee.sourceLayerIndex,ee.featureIndex,m,d.layers,d.availableImages,r,s,l,(I,F,H)=>(q||(q=mn(I)),F.queryIntersectsFeature({queryGeometry:g,feature:I,featureState:H,geometry:q,zoom:this.z,transform:t.transform,pixelsToTileUnits:p,pixelPosMatrix:t.pixelPosMatrix})))}return E}loadMatchingFeature(t,r,s,l,d,p,m,g,x,b,w){const M=this.bucketLayerIDs[r];if(p&&!M.some(O=>p.has(O)))return;const C=this.sourceLayerCoder.decode(s),E=this.vtLayers[C].feature(l);if(d.needGeometry){const O=_n(E,!0);if(!d.filter(new yt(this.tileID.overscaledZ),O,this.tileID.canonical))return}else if(!d.filter(new yt(this.tileID.overscaledZ),E))return;const k=this.getId(E,C);for(let O=0;O<M.length;O++){const Z=M[O];if(p&&!p.has(Z))continue;const ee=g[Z];if(!ee)continue;let q={};k&&b&&(q=b.getState(ee.sourceLayer||"_geojsonTileLayer",k));const I=Wt({},x[Z]);I.paint=Gu(I.paint,ee.paint,E,q,m),I.layout=Gu(I.layout,ee.layout,E,q,m);const F=!w||w(E,ee,q);if(!F)continue;const H=new Uu(E,this.z,this.x,this.y,k);H.layer=I;let ae=t[Z];ae===void 0&&(ae=t[Z]=[]),ae.push({featureIndex:l,feature:H,intersectionZ:F})}}lookupSymbolFeatures(t,r,s,l,d,p,m,g){const x={};this.loadVTLayers();const b=ra(d);for(const w of t)this.loadMatchingFeature(x,s,l,w,b,p,m,g,r);return x}hasLayer(t){for(const r of this.bucketLayerIDs)for(const s of r)if(t===s)return!0;return!1}getId(t,r){var s;let l=t.id;return this.promoteId&&(l=t.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[r]],typeof l=="boolean"&&(l=Number(l)),l===void 0&&(!((s=t.properties)===null||s===void 0)&&s.cluster)&&this.promoteId&&(l=Number(t.properties.cluster_id))),l}}function Gu(n,t,r,s,l){return Ur(n,(d,p)=>{const m=t instanceof jn?t.get(p):null;return m&&m.evaluate?m.evaluate(r,s,l):m})}function $u(n){let t=1/0,r=1/0,s=-1/0,l=-1/0;for(const d of n)t=Math.min(t,d.x),r=Math.min(r,d.y),s=Math.max(s,d.x),l=Math.max(l,d.y);return{minX:t,minY:r,maxX:s,maxY:l}}function Ap(n,t){return t-n}function qu(n,t,r,s,l){const d=[];for(let p=0;p<n.length;p++){const m=n[p];let g;for(let x=0;x<m.length-1;x++){let b=m[x],w=m[x+1];b.x<t&&w.x<t||(b.x<t?b=new Oe(t,b.y+(t-b.x)/(w.x-b.x)*(w.y-b.y))._round():w.x<t&&(w=new Oe(t,b.y+(t-b.x)/(w.x-b.x)*(w.y-b.y))._round()),b.y<r&&w.y<r||(b.y<r?b=new Oe(b.x+(r-b.y)/(w.y-b.y)*(w.x-b.x),r)._round():w.y<r&&(w=new Oe(b.x+(r-b.y)/(w.y-b.y)*(w.x-b.x),r)._round()),b.x>=s&&w.x>=s||(b.x>=s?b=new Oe(s,b.y+(s-b.x)/(w.x-b.x)*(w.y-b.y))._round():w.x>=s&&(w=new Oe(s,b.y+(s-b.x)/(w.x-b.x)*(w.y-b.y))._round()),b.y>=l&&w.y>=l||(b.y>=l?b=new Oe(b.x+(l-b.y)/(w.y-b.y)*(w.x-b.x),l)._round():w.y>=l&&(w=new Oe(b.x+(l-b.y)/(w.y-b.y)*(w.x-b.x),l)._round()),g&&b.equals(g[g.length-1])||(g=[b],d.push(g)),g.push(w)))))}}return d}Ae("FeatureIndex",Zu,{omit:["rawTileData","sourceLayerCoder"]});class qn extends Oe{constructor(t,r,s,l){super(t,r),this.angle=s,l!==void 0&&(this.segment=l)}clone(){return new qn(this.x,this.y,this.angle,this.segment)}}function Hu(n,t,r,s,l){if(t.segment===void 0||r===0)return!0;let d=t,p=t.segment+1,m=0;for(;m>-r/2;){if(p--,p<0)return!1;m-=n[p].dist(d),d=n[p]}m+=n[p].dist(n[p+1]),p++;const g=[];let x=0;for(;m<r/2;){const b=n[p],w=n[p+1];if(!w)return!1;let M=n[p-1].angleTo(b)-b.angleTo(w);for(M=Math.abs((M+3*Math.PI)%(2*Math.PI)-Math.PI),g.push({distance:m,angleDelta:M}),x+=M;m-g[0].distance>s;)x-=g.shift().angleDelta;if(x>l)return!1;p++,m+=b.dist(w)}return!0}function Xu(n){let t=0;for(let r=0;r<n.length-1;r++)t+=n[r].dist(n[r+1]);return t}function Wu(n,t,r){return n?.6*t*r:0}function Ku(n,t){return Math.max(n?n.right-n.left:0,t?t.right-t.left:0)}function zp(n,t,r,s,l,d){const p=Wu(r,l,d),m=Ku(r,s)*d;let g=0;const x=Xu(n)/2;for(let b=0;b<n.length-1;b++){const w=n[b],M=n[b+1],C=w.dist(M);if(g+C>x){const E=(x-g)/C,k=Oi.number(w.x,M.x,E),O=Oi.number(w.y,M.y,E),Z=new qn(k,O,M.angleTo(w),b);return Z._round(),!p||Hu(n,Z,m,p,t)?Z:void 0}g+=C}}function kp(n,t,r,s,l,d,p,m,g){const x=Wu(s,d,p),b=Ku(s,l),w=b*p,M=n[0].x===0||n[0].x===g||n[0].y===0||n[0].y===g;return t-w<t/4&&(t=w+t/4),Yu(n,M?t/2*m%t:(b/2+2*d)*p*m%t,t,x,r,w,M,!1,g)}function Yu(n,t,r,s,l,d,p,m,g){const x=d/2,b=Xu(n);let w=0,M=t-r,C=[];for(let E=0;E<n.length-1;E++){const k=n[E],O=n[E+1],Z=k.dist(O),ee=O.angleTo(k);for(;M+r<w+Z;){M+=r;const q=(M-w)/Z,I=Oi.number(k.x,O.x,q),F=Oi.number(k.y,O.y,q);if(I>=0&&I<g&&F>=0&&F<g&&M-x>=0&&M+x<=b){const H=new qn(I,F,ee,E);H._round(),s&&!Hu(n,H,d,s,l)||C.push(H)}}w+=Z}return m||C.length||p||(C=Yu(n,w/2,r,s,l,d,p,!0,g)),C}Ae("Anchor",qn);const el=bi;function Ju(n,t,r,s){const l=[],d=n.image,p=d.pixelRatio,m=d.paddedRect.w-2*el,g=d.paddedRect.h-2*el;let x={x1:n.left,y1:n.top,x2:n.right,y2:n.bottom};const b=d.stretchX||[[0,m]],w=d.stretchY||[[0,g]],M=(_e,ke)=>_e+ke[1]-ke[0],C=b.reduce(M,0),E=w.reduce(M,0),k=m-C,O=g-E;let Z=0,ee=C,q=0,I=E,F=0,H=k,ae=0,xe=O;if(d.content&&s){const _e=d.content,ke=_e[2]-_e[0],Fe=_e[3]-_e[1];(d.textFitWidth||d.textFitHeight)&&(x=Pu(n)),Z=_c(b,0,_e[0]),q=_c(w,0,_e[1]),ee=_c(b,_e[0],_e[2]),I=_c(w,_e[1],_e[3]),F=_e[0]-Z,ae=_e[1]-q,H=ke-ee,xe=Fe-I}const ce=x.x1,pe=x.y1,we=x.x2-ce,be=x.y2-pe,Te=(_e,ke,Fe,Be)=>{const Re=gc(_e.stretch-Z,ee,we,ce),Ke=yc(_e.fixed-F,H,_e.stretch,C),It=gc(ke.stretch-q,I,be,pe),Zt=yc(ke.fixed-ae,xe,ke.stretch,E),ai=gc(Fe.stretch-Z,ee,we,ce),Ui=yc(Fe.fixed-F,H,Fe.stretch,C),wi=gc(Be.stretch-q,I,be,pe),Yt=yc(Be.fixed-ae,xe,Be.stretch,E),Pt=new Oe(Re,It),$t=new Oe(ai,It),Jt=new Oe(ai,wi),Qt=new Oe(Re,wi),pi=new Oe(Ke/p,Zt/p),Zi=new Oe(Ui/p,Yt/p),qt=t*Math.PI/180;if(qt){const Ht=Math.sin(qt),Xt=Math.cos(qt),Ft=[Xt,-Ht,Ht,Xt];Pt._matMult(Ft),$t._matMult(Ft),Qt._matMult(Ft),Jt._matMult(Ft)}const Ti=_e.stretch+_e.fixed,Gt=ke.stretch+ke.fixed;return{tl:Pt,tr:$t,bl:Qt,br:Jt,tex:{x:d.paddedRect.x+el+Ti,y:d.paddedRect.y+el+Gt,w:Fe.stretch+Fe.fixed-Ti,h:Be.stretch+Be.fixed-Gt},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:pi,pixelOffsetBR:Zi,minFontScaleX:H/p/we,minFontScaleY:xe/p/be,isSDF:r}};if(s&&(d.stretchX||d.stretchY)){const _e=Qu(b,k,C),ke=Qu(w,O,E);for(let Fe=0;Fe<_e.length-1;Fe++){const Be=_e[Fe],Re=_e[Fe+1];for(let Ke=0;Ke<ke.length-1;Ke++)l.push(Te(Be,ke[Ke],Re,ke[Ke+1]))}}else l.push(Te({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:m+1},{fixed:0,stretch:g+1}));return l}function _c(n,t,r){let s=0;for(const l of n)s+=Math.max(t,Math.min(r,l[1]))-Math.max(t,Math.min(r,l[0]));return s}function Qu(n,t,r){const s=[{fixed:-1,stretch:0}];for(const[l,d]of n){const p=s[s.length-1];s.push({fixed:l-p.stretch,stretch:p.stretch}),s.push({fixed:l-p.stretch,stretch:p.stretch+(d-l)})}return s.push({fixed:t+el,stretch:r}),s}function gc(n,t,r,s){return n/t*r+s}function yc(n,t,r,s){return n-t*r/s}class xc{constructor(t,r,s,l,d,p,m,g,x,b){var w;if(this.boxStartIndex=t.length,x){let M=p.top,C=p.bottom;const E=p.collisionPadding;E&&(M-=E[1],C+=E[3]);let k=C-M;k>0&&(k=Math.max(10,k),this.circleDiameter=k)}else{const M=!((w=p.image)===null||w===void 0)&&w.content&&(p.image.textFitWidth||p.image.textFitHeight)?Pu(p):{x1:p.left,y1:p.top,x2:p.right,y2:p.bottom};M.y1=M.y1*m-g[0],M.y2=M.y2*m+g[2],M.x1=M.x1*m-g[3],M.x2=M.x2*m+g[1];const C=p.collisionPadding;if(C&&(M.x1-=C[0]*m,M.y1-=C[1]*m,M.x2+=C[2]*m,M.y2+=C[3]*m),b){const E=new Oe(M.x1,M.y1),k=new Oe(M.x2,M.y1),O=new Oe(M.x1,M.y2),Z=new Oe(M.x2,M.y2),ee=b*Math.PI/180;E._rotate(ee),k._rotate(ee),O._rotate(ee),Z._rotate(ee),M.x1=Math.min(E.x,k.x,O.x,Z.x),M.x2=Math.max(E.x,k.x,O.x,Z.x),M.y1=Math.min(E.y,k.y,O.y,Z.y),M.y2=Math.max(E.y,k.y,O.y,Z.y)}t.emplaceBack(r.x,r.y,M.x1,M.y1,M.x2,M.y2,s,l,d)}this.boxEndIndex=t.length}}class Dp{constructor(t=[],r=(s,l)=>s<l?-1:s>l?1:0){if(this.data=t,this.length=this.data.length,this.compare=r,this.length>0)for(let s=(this.length>>1)-1;s>=0;s--)this._down(s)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;const t=this.data[0],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:r,compare:s}=this,l=r[t];for(;t>0;){const d=t-1>>1,p=r[d];if(s(l,p)>=0)break;r[t]=p,t=d}r[t]=l}_down(t){const{data:r,compare:s}=this,l=this.length>>1,d=r[t];for(;t<l;){let p=1+(t<<1);const m=p+1;if(m<this.length&&s(r[m],r[p])<0&&(p=m),s(r[p],d)>=0)break;r[t]=r[p],t=p}r[t]=d}}function Rp(n,t=1,r=!1){let s=1/0,l=1/0,d=-1/0,p=-1/0;const m=n[0];for(let C=0;C<m.length;C++){const E=m[C];(!C||E.x<s)&&(s=E.x),(!C||E.y<l)&&(l=E.y),(!C||E.x>d)&&(d=E.x),(!C||E.y>p)&&(p=E.y)}const g=Math.min(d-s,p-l);let x=g/2;const b=new Dp([],Lp);if(g===0)return new Oe(s,l);for(let C=s;C<d;C+=g)for(let E=l;E<p;E+=g)b.push(new Ia(C+x,E+x,x,n));let w=function(C){let E=0,k=0,O=0;const Z=C[0];for(let ee=0,q=Z.length,I=q-1;ee<q;I=ee++){const F=Z[ee],H=Z[I],ae=F.x*H.y-H.x*F.y;k+=(F.x+H.x)*ae,O+=(F.y+H.y)*ae,E+=3*ae}return new Ia(k/E,O/E,0,C)}(n),M=b.length;for(;b.length;){const C=b.pop();(C.d>w.d||!w.d)&&(w=C,r&&console.log("found best %d after %d probes",Math.round(1e4*C.d)/1e4,M)),C.max-w.d<=t||(x=C.h/2,b.push(new Ia(C.p.x-x,C.p.y-x,x,n)),b.push(new Ia(C.p.x+x,C.p.y-x,x,n)),b.push(new Ia(C.p.x-x,C.p.y+x,x,n)),b.push(new Ia(C.p.x+x,C.p.y+x,x,n)),M+=4)}return r&&(console.log(`num probes: ${M}`),console.log(`best distance: ${w.d}`)),w.p}function Lp(n,t){return t.max-n.max}function Ia(n,t,r,s){this.p=new Oe(n,t),this.h=r,this.d=function(l,d){let p=!1,m=1/0;for(let g=0;g<d.length;g++){const x=d[g];for(let b=0,w=x.length,M=w-1;b<w;M=b++){const C=x[b],E=x[M];C.y>l.y!=E.y>l.y&&l.x<(E.x-C.x)*(l.y-C.y)/(E.y-C.y)+C.x&&(p=!p),m=Math.min(m,Dh(l,C,E))}}return(p?1:-1)*Math.sqrt(m)}(this.p,s),this.max=this.d+this.h*Math.SQRT2}var si;z.av=void 0,(si=z.av||(z.av={}))[si.center=1]="center",si[si.left=2]="left",si[si.right=3]="right",si[si.top=4]="top",si[si.bottom=5]="bottom",si[si["top-left"]=6]="top-left",si[si["top-right"]=7]="top-right",si[si["bottom-left"]=8]="bottom-left",si[si["bottom-right"]=9]="bottom-right";const Hn=7,wh=Number.POSITIVE_INFINITY;function ed(n,t){return t[1]!==wh?function(r,s,l){let d=0,p=0;switch(s=Math.abs(s),l=Math.abs(l),r){case"top-right":case"top-left":case"top":p=l-Hn;break;case"bottom-right":case"bottom-left":case"bottom":p=-l+Hn}switch(r){case"top-right":case"bottom-right":case"right":d=-s;break;case"top-left":case"bottom-left":case"left":d=s}return[d,p]}(n,t[0],t[1]):function(r,s){let l=0,d=0;s<0&&(s=0);const p=s/Math.SQRT2;switch(r){case"top-right":case"top-left":d=p-Hn;break;case"bottom-right":case"bottom-left":d=-p+Hn;break;case"bottom":d=-s+Hn;break;case"top":d=s-Hn}switch(r){case"top-right":case"bottom-right":l=-p;break;case"top-left":case"bottom-left":l=p;break;case"left":l=s;break;case"right":l=-s}return[l,d]}(n,t[0])}function td(n,t,r){var s;const l=n.layout,d=(s=l.get("text-variable-anchor-offset"))===null||s===void 0?void 0:s.evaluate(t,{},r);if(d){const m=d.values,g=[];for(let x=0;x<m.length;x+=2){const b=g[x]=m[x],w=m[x+1].map(M=>M*Ut);b.startsWith("top")?w[1]-=Hn:b.startsWith("bottom")&&(w[1]+=Hn),g[x+1]=w}return new ii(g)}const p=l.get("text-variable-anchor");if(p){let m;m=n._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[l.get("text-radial-offset").evaluate(t,{},r)*Ut,wh]:l.get("text-offset").evaluate(t,{},r).map(x=>x*Ut);const g=[];for(const x of p)g.push(x,ed(x,m));return new ii(g)}return null}function Th(n){switch(n){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Bp(n,t,r,s,l,d,p,m,g,x,b,w){let M=d.textMaxSize.evaluate(t,{});M===void 0&&(M=p);const C=n.layers[0].layout,E=C.get("icon-offset").evaluate(t,{},b),k=rd(r.horizontal),O=p/24,Z=n.tilePixelRatio*O,ee=n.tilePixelRatio*M/24,q=n.tilePixelRatio*m,I=n.tilePixelRatio*C.get("symbol-spacing"),F=C.get("text-padding")*n.tilePixelRatio,H=function(Fe,Be,Re,Ke=1){const It=Fe.get("icon-padding").evaluate(Be,{},Re),Zt=It&&It.values;return[Zt[0]*Ke,Zt[1]*Ke,Zt[2]*Ke,Zt[3]*Ke]}(C,t,b,n.tilePixelRatio),ae=C.get("text-max-angle")/180*Math.PI,xe=C.get("text-rotation-alignment")!=="viewport"&&C.get("symbol-placement")!=="point",ce=C.get("icon-rotation-alignment")==="map"&&C.get("symbol-placement")!=="point",pe=C.get("symbol-placement"),we=I/2,be=C.get("icon-text-fit");let Te;s&&be!=="none"&&(n.allowVerticalPlacement&&r.vertical&&(Te=Mu(s,r.vertical,be,C.get("icon-text-fit-padding"),E,O)),k&&(s=Mu(s,k,be,C.get("icon-text-fit-padding"),E,O)));const _e=b?w.line.getGranularityForZoomLevel(b.z):1,ke=(Fe,Be)=>{Be.x<0||Be.x>=rt||Be.y<0||Be.y>=rt||function(Re,Ke,It,Zt,ai,Ui,wi,Yt,Pt,$t,Jt,Qt,pi,Zi,qt,Ti,Gt,Ht,Xt,Ft,pt,hr,Ca,ur,jp){const Ea=Re.addToLineVertexArray(Ke,It);let zs,Aa,za,ka,od=0,ld=0,cd=0,hd=0,zh=-1,kh=-1;const gn={};let ud=Lt("");if(Re.allowVerticalPlacement&&Zt.vertical){const hi=Yt.layout.get("text-rotate").evaluate(pt,{},ur)+90;za=new xc(Pt,Ke,$t,Jt,Qt,Zt.vertical,pi,Zi,qt,hi),wi&&(ka=new xc(Pt,Ke,$t,Jt,Qt,wi,Gt,Ht,qt,hi))}if(ai){const hi=Yt.layout.get("icon-rotate").evaluate(pt,{}),Gi=Yt.layout.get("icon-text-fit")!=="none",ks=Ju(ai,hi,Ca,Gi),pr=wi?Ju(wi,hi,Ca,Gi):void 0;Aa=new xc(Pt,Ke,$t,Jt,Qt,ai,Gt,Ht,!1,hi),od=4*ks.length;const Ds=Re.iconSizeData;let Dr=null;Ds.kind==="source"?(Dr=[kr*Yt.layout.get("icon-size").evaluate(pt,{})],Dr[0]>Gn&&ti(`${Re.layerIds[0]}: Value for "icon-size" is >= ${Jo}. Reduce your "icon-size".`)):Ds.kind==="composite"&&(Dr=[kr*hr.compositeIconSizes[0].evaluate(pt,{},ur),kr*hr.compositeIconSizes[1].evaluate(pt,{},ur)],(Dr[0]>Gn||Dr[1]>Gn)&&ti(`${Re.layerIds[0]}: Value for "icon-size" is >= ${Jo}. Reduce your "icon-size".`)),Re.addSymbols(Re.icon,ks,Dr,Ft,Xt,pt,z.ai.none,Ke,Ea.lineStartIndex,Ea.lineLength,-1,ur),zh=Re.icon.placedSymbolArray.length-1,pr&&(ld=4*pr.length,Re.addSymbols(Re.icon,pr,Dr,Ft,Xt,pt,z.ai.vertical,Ke,Ea.lineStartIndex,Ea.lineLength,-1,ur),kh=Re.icon.placedSymbolArray.length-1)}const dd=Object.keys(Zt.horizontal);for(const hi of dd){const Gi=Zt.horizontal[hi];if(!zs){ud=Lt(Gi.text);const pr=Yt.layout.get("text-rotate").evaluate(pt,{},ur);zs=new xc(Pt,Ke,$t,Jt,Qt,Gi,pi,Zi,qt,pr)}const ks=Gi.positionedLines.length===1;if(cd+=id(Re,Ke,Gi,Ui,Yt,qt,pt,Ti,Ea,Zt.vertical?z.ai.horizontal:z.ai.horizontalOnly,ks?dd:[hi],gn,zh,hr,ur),ks)break}Zt.vertical&&(hd+=id(Re,Ke,Zt.vertical,Ui,Yt,qt,pt,Ti,Ea,z.ai.vertical,["vertical"],gn,kh,hr,ur));const Np=zs?zs.boxStartIndex:Re.collisionBoxArray.length,Vp=zs?zs.boxEndIndex:Re.collisionBoxArray.length,Up=za?za.boxStartIndex:Re.collisionBoxArray.length,Zp=za?za.boxEndIndex:Re.collisionBoxArray.length,Gp=Aa?Aa.boxStartIndex:Re.collisionBoxArray.length,$p=Aa?Aa.boxEndIndex:Re.collisionBoxArray.length,qp=ka?ka.boxStartIndex:Re.collisionBoxArray.length,Hp=ka?ka.boxEndIndex:Re.collisionBoxArray.length;let dr=-1;const bc=(hi,Gi)=>hi&&hi.circleDiameter?Math.max(hi.circleDiameter,Gi):Gi;dr=bc(zs,dr),dr=bc(za,dr),dr=bc(Aa,dr),dr=bc(ka,dr);const pd=dr>-1?1:0;pd&&(dr*=jp/Ut),Re.glyphOffsetArray.length>=Ma.MAX_GLYPHS&&ti("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),pt.sortKey!==void 0&&Re.addToSortKeyRanges(Re.symbolInstances.length,pt.sortKey);const Xp=td(Yt,pt,ur),[Wp,Kp]=function(hi,Gi){const ks=hi.length,pr=Gi==null?void 0:Gi.values;if((pr==null?void 0:pr.length)>0)for(let Ds=0;Ds<pr.length;Ds+=2){const Dr=pr[Ds+1];hi.emplaceBack(z.av[pr[Ds]],Dr[0],Dr[1])}return[ks,hi.length]}(Re.textAnchorOffsets,Xp);Re.symbolInstances.emplaceBack(Ke.x,Ke.y,gn.right>=0?gn.right:-1,gn.center>=0?gn.center:-1,gn.left>=0?gn.left:-1,gn.vertical||-1,zh,kh,ud,Np,Vp,Up,Zp,Gp,$p,qp,Hp,$t,cd,hd,od,ld,pd,0,pi,dr,Wp,Kp)}(n,Be,Fe,r,s,l,Te,n.layers[0],n.collisionBoxArray,t.index,t.sourceLayerIndex,n.index,Z,[F,F,F,F],xe,g,q,H,ce,E,t,d,x,b,p)};if(pe==="line")for(const Fe of qu(t.geometry,0,0,rt,rt)){const Be=As(Fe,_e),Re=kp(Be,I,ae,r.vertical||k,s,24,ee,n.overscaling,rt);for(const Ke of Re)k&&Fp(n,k.text,we,Ke)||ke(Be,Ke)}else if(pe==="line-center"){for(const Fe of t.geometry)if(Fe.length>1){const Be=As(Fe,_e),Re=zp(Be,ae,r.vertical||k,s,24,ee);Re&&ke(Be,Re)}}else if(t.type==="Polygon")for(const Fe of Us(t.geometry,0)){const Be=Rp(Fe,16);ke(As(Fe[0],_e,!0),new qn(Be.x,Be.y,0))}else if(t.type==="LineString")for(const Fe of t.geometry){const Be=As(Fe,_e);ke(Be,new qn(Be[0].x,Be[0].y,0))}else if(t.type==="Point")for(const Fe of t.geometry)for(const Be of Fe)ke([Be],new qn(Be.x,Be.y,0))}function id(n,t,r,s,l,d,p,m,g,x,b,w,M,C,E){const k=function(ee,q,I,F,H,ae,xe,ce){const pe=F.layout.get("text-rotate").evaluate(ae,{})*Math.PI/180,we=[];for(const be of q.positionedLines)for(const Te of be.positionedGlyphs){if(!Te.rect)continue;const _e=Te.rect||{};let ke=up+1,Fe=!0,Be=1,Re=0;const Ke=(H||ce)&&Te.vertical,It=Te.metrics.advance*Te.scale/2;if(ce&&q.verticalizable&&(Re=be.lineOffset/2-(Te.imageName?-(Ut-Te.metrics.width*Te.scale)/2:(Te.scale-1)*Ut)),Te.imageName){const Ht=xe[Te.imageName];Fe=Ht.sdf,Be=Ht.pixelRatio,ke=bi/Be}const Zt=H?[Te.x+It,Te.y]:[0,0];let ai=H?[0,0]:[Te.x+It+I[0],Te.y+I[1]-Re],Ui=[0,0];Ke&&(Ui=ai,ai=[0,0]);const wi=Te.metrics.isDoubleResolution?2:1,Yt=(Te.metrics.left-ke)*Te.scale-It+ai[0],Pt=(-Te.metrics.top-ke)*Te.scale+ai[1],$t=Yt+_e.w/wi*Te.scale/Be,Jt=Pt+_e.h/wi*Te.scale/Be,Qt=new Oe(Yt,Pt),pi=new Oe($t,Pt),Zi=new Oe(Yt,Jt),qt=new Oe($t,Jt);if(Ke){const Ht=new Oe(-It,It-uc),Xt=-Math.PI/2,Ft=Ut/2-It,pt=new Oe(5-uc-Ft,-(Te.imageName?Ft:0)),hr=new Oe(...Ui);Qt._rotateAround(Xt,Ht)._add(pt)._add(hr),pi._rotateAround(Xt,Ht)._add(pt)._add(hr),Zi._rotateAround(Xt,Ht)._add(pt)._add(hr),qt._rotateAround(Xt,Ht)._add(pt)._add(hr)}if(pe){const Ht=Math.sin(pe),Xt=Math.cos(pe),Ft=[Xt,-Ht,Ht,Xt];Qt._matMult(Ft),pi._matMult(Ft),Zi._matMult(Ft),qt._matMult(Ft)}const Ti=new Oe(0,0),Gt=new Oe(0,0);we.push({tl:Qt,tr:pi,bl:Zi,br:qt,tex:_e,writingMode:q.writingMode,glyphOffset:Zt,sectionIndex:Te.sectionIndex,isSDF:Fe,pixelOffsetTL:Ti,pixelOffsetBR:Gt,minFontScaleX:0,minFontScaleY:0})}return we}(0,r,m,l,d,p,s,n.allowVerticalPlacement),O=n.textSizeData;let Z=null;O.kind==="source"?(Z=[kr*l.layout.get("text-size").evaluate(p,{})],Z[0]>Gn&&ti(`${n.layerIds[0]}: Value for "text-size" is >= ${Jo}. Reduce your "text-size".`)):O.kind==="composite"&&(Z=[kr*C.compositeTextSizes[0].evaluate(p,{},E),kr*C.compositeTextSizes[1].evaluate(p,{},E)],(Z[0]>Gn||Z[1]>Gn)&&ti(`${n.layerIds[0]}: Value for "text-size" is >= ${Jo}. Reduce your "text-size".`)),n.addSymbols(n.text,k,Z,m,d,p,x,t,g.lineStartIndex,g.lineLength,M,E);for(const ee of b)w[ee]=n.text.placedSymbolArray.length-1;return 4*k.length}function rd(n){for(const t in n)return n[t];return null}function Fp(n,t,r,s){const l=n.compareText;if(t in l){const d=l[t];for(let p=d.length-1;p>=0;p--)if(s.dist(d[p])<r)return!0}else l[t]=[];return l[t].push(s),!1}const nd=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Ph{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[r,s]=new Uint8Array(t,0,2);if(r!==219)throw new Error("Data does not appear to be in a KDBush format.");const l=s>>4;if(l!==1)throw new Error(`Got v${l} data when expected v1.`);const d=nd[15&s];if(!d)throw new Error("Unrecognized array type.");const[p]=new Uint16Array(t,2,1),[m]=new Uint32Array(t,4,1);return new Ph(m,p,d,t)}constructor(t,r=64,s=Float64Array,l){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=s,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const d=nd.indexOf(this.ArrayType),p=2*t*this.ArrayType.BYTES_PER_ELEMENT,m=t*this.IndexArrayType.BYTES_PER_ELEMENT,g=(8-m%8)%8;if(d<0)throw new Error(`Unexpected typed array class: ${s}.`);l&&l instanceof ArrayBuffer?(this.data=l,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+m+g,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+p+m+g),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+m+g,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+d]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=t)}add(t,r){const s=this._pos>>1;return this.ids[s]=s,this.coords[this._pos++]=t,this.coords[this._pos++]=r,s}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Mh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,r,s,l){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:d,coords:p,nodeSize:m}=this,g=[0,d.length-1,0],x=[];for(;g.length;){const b=g.pop()||0,w=g.pop()||0,M=g.pop()||0;if(w-M<=m){for(let O=M;O<=w;O++){const Z=p[2*O],ee=p[2*O+1];Z>=t&&Z<=s&&ee>=r&&ee<=l&&x.push(d[O])}continue}const C=M+w>>1,E=p[2*C],k=p[2*C+1];E>=t&&E<=s&&k>=r&&k<=l&&x.push(d[C]),(b===0?t<=E:r<=k)&&(g.push(M),g.push(C-1),g.push(1-b)),(b===0?s>=E:l>=k)&&(g.push(C+1),g.push(w),g.push(1-b))}return x}within(t,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:l,coords:d,nodeSize:p}=this,m=[0,l.length-1,0],g=[],x=s*s;for(;m.length;){const b=m.pop()||0,w=m.pop()||0,M=m.pop()||0;if(w-M<=p){for(let O=M;O<=w;O++)ad(d[2*O],d[2*O+1],t,r)<=x&&g.push(l[O]);continue}const C=M+w>>1,E=d[2*C],k=d[2*C+1];ad(E,k,t,r)<=x&&g.push(l[C]),(b===0?t-s<=E:r-s<=k)&&(m.push(M),m.push(C-1),m.push(1-b)),(b===0?t+s>=E:r+s>=k)&&(m.push(C+1),m.push(w),m.push(1-b))}return g}}function Mh(n,t,r,s,l,d){if(l-s<=r)return;const p=s+l>>1;sd(n,t,p,s,l,d),Mh(n,t,r,s,p-1,1-d),Mh(n,t,r,p+1,l,1-d)}function sd(n,t,r,s,l,d){for(;l>s;){if(l-s>600){const x=l-s+1,b=r-s+1,w=Math.log(x),M=.5*Math.exp(2*w/3),C=.5*Math.sqrt(w*M*(x-M)/x)*(b-x/2<0?-1:1);sd(n,t,r,Math.max(s,Math.floor(r-b*M/x+C)),Math.min(l,Math.floor(r+(x-b)*M/x+C)),d)}const p=t[2*r+d];let m=s,g=l;for(tl(n,t,s,r),t[2*l+d]>p&&tl(n,t,s,l);m<g;){for(tl(n,t,m,g),m++,g--;t[2*m+d]<p;)m++;for(;t[2*g+d]>p;)g--}t[2*s+d]===p?tl(n,t,s,g):(g++,tl(n,t,g,l)),g<=r&&(s=g+1),r<=g&&(l=g-1)}}function tl(n,t,r,s){Sh(n,r,s),Sh(t,2*r,2*s),Sh(t,2*r+1,2*s+1)}function Sh(n,t,r){const s=n[t];n[t]=n[r],n[r]=s}function ad(n,t,r,s){const l=n-r,d=t-s;return l*l+d*d}var Ih;z.ce=void 0,(Ih=z.ce||(z.ce={})).create="create",Ih.load="load",Ih.fullLoad="fullLoad";let vc=null,il=[];const Ch=1e3/60,Eh="loadTime",Ah="fullLoadTime",Op={mark(n){performance.mark(n)},frame(n){const t=n;vc!=null&&il.push(t-vc),vc=t},clearMetrics(){vc=null,il=[],performance.clearMeasures(Eh),performance.clearMeasures(Ah);for(const n in z.ce)performance.clearMarks(z.ce[n])},getPerformanceMetrics(){performance.measure(Eh,z.ce.create,z.ce.load),performance.measure(Ah,z.ce.create,z.ce.fullLoad);const n=performance.getEntriesByName(Eh)[0].duration,t=performance.getEntriesByName(Ah)[0].duration,r=il.length,s=1/(il.reduce((d,p)=>d+p,0)/r/1e3),l=il.filter(d=>d>Ch).reduce((d,p)=>d+(p-Ch)/Ch,0);return{loadTime:n,fullLoadTime:t,fps:s,percentDroppedFrames:l/(r+l)*100,totalFrames:r}}};z.$=te,z.A=ft,z.B=ys,z.C=function(n){if(zt==null){const t=n.navigator?n.navigator.userAgent:null;zt=!!n.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return zt},z.D=Le,z.E=Pr,z.F=class{constructor(n,t){this.target=n,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Ep(()=>this.process()),this.subscription=function(r,s,l,d){return r.addEventListener(s,l,!1),{unsubscribe:()=>{r.removeEventListener(s,l,!1)}}}(this.target,"message",r=>this.receive(r)),this.globalScope=Qi(self)?n:window}registerMessageHandler(n,t){this.messageHandlers[n]=t}sendAsync(n,t){return new Promise((r,s)=>{const l=Math.round(1e18*Math.random()).toString(36).substring(0,10);this.resolveRejects[l]={resolve:r,reject:s},t&&t.signal.addEventListener("abort",()=>{delete this.resolveRejects[l];const m={id:l,type:"<cancel>",origin:location.origin,targetMapId:n.targetMapId,sourceMapId:this.mapId};this.target.postMessage(m)},{once:!0});const d=[],p=Object.assign(Object.assign({},n),{id:l,sourceMapId:this.mapId,origin:location.origin,data:xs(n.data,d)});this.target.postMessage(p,{transfer:d})})}receive(n){const t=n.data,r=t.id;if(!(t.origin!=="file://"&&location.origin!=="file://"&&t.origin!=="resource://android"&&location.origin!=="resource://android"&&t.origin!==location.origin||t.targetMapId&&this.mapId!==t.targetMapId)){if(t.type==="<cancel>"){delete this.tasks[r];const s=this.abortControllers[r];return delete this.abortControllers[r],void(s&&s.abort())}if(Qi(self)||t.mustQueue)return this.tasks[r]=t,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,t)}}process(){if(this.taskQueue.length===0)return;const n=this.taskQueue.shift(),t=this.tasks[n];delete this.tasks[n],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(n,t)}processTask(n,t){return c(this,void 0,void 0,function*(){if(t.type==="<response>"){const l=this.resolveRejects[n];return delete this.resolveRejects[n],l?void(t.error?l.reject(Er(t.error)):l.resolve(Er(t.data))):void 0}if(!this.messageHandlers[t.type])return void this.completeTask(n,new Error(`Could not find a registered handler for ${t.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const r=Er(t.data),s=new AbortController;this.abortControllers[n]=s;try{const l=yield this.messageHandlers[t.type](t.sourceMapId,r,s);this.completeTask(n,null,l)}catch(l){this.completeTask(n,l)}})}completeTask(n,t,r){const s=[];delete this.abortControllers[n];const l={id:n,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:t?xs(t):null,data:xs(r,s)};this.target.postMessage(l,{transfer:s})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},z.G=Xr,z.H=function(){var n=new ft(16);return ft!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0),n[0]=1,n[5]=1,n[10]=1,n[15]=1,n},z.I=uh,z.J=function(n,t,r){var s,l,d,p,m,g,x,b,w,M,C,E,k=r[0],O=r[1],Z=r[2];return t===n?(n[12]=t[0]*k+t[4]*O+t[8]*Z+t[12],n[13]=t[1]*k+t[5]*O+t[9]*Z+t[13],n[14]=t[2]*k+t[6]*O+t[10]*Z+t[14],n[15]=t[3]*k+t[7]*O+t[11]*Z+t[15]):(l=t[1],d=t[2],p=t[3],m=t[4],g=t[5],x=t[6],b=t[7],w=t[8],M=t[9],C=t[10],E=t[11],n[0]=s=t[0],n[1]=l,n[2]=d,n[3]=p,n[4]=m,n[5]=g,n[6]=x,n[7]=b,n[8]=w,n[9]=M,n[10]=C,n[11]=E,n[12]=s*k+m*O+w*Z+t[12],n[13]=l*k+g*O+M*Z+t[13],n[14]=d*k+x*O+C*Z+t[14],n[15]=p*k+b*O+E*Z+t[15]),n},z.K=function(n,t,r){var s=r[0],l=r[1],d=r[2];return n[0]=t[0]*s,n[1]=t[1]*s,n[2]=t[2]*s,n[3]=t[3]*s,n[4]=t[4]*l,n[5]=t[5]*l,n[6]=t[6]*l,n[7]=t[7]*l,n[8]=t[8]*d,n[9]=t[9]*d,n[10]=t[10]*d,n[11]=t[11]*d,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n},z.L=function(n,t,r){var s=t[0],l=t[1],d=t[2],p=t[3],m=t[4],g=t[5],x=t[6],b=t[7],w=t[8],M=t[9],C=t[10],E=t[11],k=t[12],O=t[13],Z=t[14],ee=t[15],q=r[0],I=r[1],F=r[2],H=r[3];return n[0]=q*s+I*m+F*w+H*k,n[1]=q*l+I*g+F*M+H*O,n[2]=q*d+I*x+F*C+H*Z,n[3]=q*p+I*b+F*E+H*ee,n[4]=(q=r[4])*s+(I=r[5])*m+(F=r[6])*w+(H=r[7])*k,n[5]=q*l+I*g+F*M+H*O,n[6]=q*d+I*x+F*C+H*Z,n[7]=q*p+I*b+F*E+H*ee,n[8]=(q=r[8])*s+(I=r[9])*m+(F=r[10])*w+(H=r[11])*k,n[9]=q*l+I*g+F*M+H*O,n[10]=q*d+I*x+F*C+H*Z,n[11]=q*p+I*b+F*E+H*ee,n[12]=(q=r[12])*s+(I=r[13])*m+(F=r[14])*w+(H=r[15])*k,n[13]=q*l+I*g+F*M+H*O,n[14]=q*d+I*x+F*C+H*Z,n[15]=q*p+I*b+F*E+H*ee,n},z.M=function(n,t){const r={};for(let s=0;s<t.length;s++){const l=t[s];l in n&&(r[l]=n[l])}return r},z.N=$n,z.O=Ru,z.P=Oe,z.Q=Lu,z.R=Ni,z.S=Vi,z.T=Po,z.U=Xn,z.V=oi,z.W=Bi,z.X=rt,z.Y=Qo,z.Z=bh,z._=c,z.a=wr,z.a$=function(){return new Float64Array(16)},z.a0=n=>{const t=window.document.createElement("video");return t.muted=!0,new Promise(r=>{t.onloadstart=()=>{r(t)};for(const s of n){const l=window.document.createElement("source");Kr(s)||(t.crossOrigin="Anonymous"),l.src=s,t.appendChild(l)}})},z.a1=function(){return Vr++},z.a2=u,z.a3=Ma,z.a4=ra,z.a5=_n,z.a6=Uu,z.a7=function(n){const t={};if(n.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(r,s,l,d)=>{const p=l||d;return t[s]=!p||p.toLowerCase(),""}),t["max-age"]){const r=parseInt(t["max-age"],10);isNaN(r)?delete t["max-age"]:t["max-age"]=r}return t},z.a8=function(n){return Math.log(n)/Math.LN2},z.a9=function(n){var t=n[0],r=n[1];return t*t+r*r},z.aA=kt,z.aB=lc,z.aC=N,z.aD=Ee,z.aE=de,z.aF=85.051129,z.aG=function(n){return Math.pow(2,n)},z.aH=Bu,z.aI=Ii,z.aJ=mi,z.aK=Fu,z.aL=function(n,t,r){return n[0]=t[0]*r,n[1]=t[1]*r,n[2]=t[2]*r,n},z.aM=function(n,t,r){return n[0]=t[0]+r[0],n[1]=t[1]+r[1],n[2]=t[2]+r[2],n},z.aN=function(n){var t=new ft(3);return t[0]=n[0],t[1]=n[1],t[2]=n[2],t},z.aO=function(n,t,r){return n[0]=t[0]*r[0],n[1]=t[1]*r[1],n[2]=t[2]*r[2],n[3]=t[3]*r[3],n},z.aP=function(n,t,r){return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[2]-r[2],n},z.aQ=function(n,t){var r=t[0],s=t[1],l=t[2],d=r*r+s*s+l*l;return d>0&&(d=1/Math.sqrt(d)),n[0]=t[0]*d,n[1]=t[1]*d,n[2]=t[2]*d,n},z.aR=function(n,t,r){var s=t[0],l=t[1],d=t[2],p=r[0],m=r[1],g=r[2];return n[0]=l*g-d*m,n[1]=d*p-s*g,n[2]=s*m-l*p,n},z.aS=function(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]},z.aT=ju,z.aU=Sa,z.aV=function(n,t,r,s,l){var d,p=1/Math.tan(t/2);return n[0]=p/r,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=p,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,l!=null&&l!==1/0?(n[10]=(l+s)*(d=1/(s-l)),n[14]=2*l*s*d):(n[10]=-1,n[14]=-2*s),n},z.aW=function(n){var t=new ft(16);return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],t},z.aX=function(n,t,r){var s=Math.sin(r),l=Math.cos(r),d=t[0],p=t[1],m=t[2],g=t[3],x=t[4],b=t[5],w=t[6],M=t[7];return t!==n&&(n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[0]=d*l+x*s,n[1]=p*l+b*s,n[2]=m*l+w*s,n[3]=g*l+M*s,n[4]=x*l-d*s,n[5]=b*l-p*s,n[6]=w*l-m*s,n[7]=M*l-g*s,n},z.aY=function(n,t,r){var s=Math.sin(r),l=Math.cos(r),d=t[4],p=t[5],m=t[6],g=t[7],x=t[8],b=t[9],w=t[10],M=t[11];return t!==n&&(n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[4]=d*l+x*s,n[5]=p*l+b*s,n[6]=m*l+w*s,n[7]=g*l+M*s,n[8]=x*l-d*s,n[9]=b*l-p*s,n[10]=w*l-m*s,n[11]=M*l-g*s,n},z.aZ=function(){const n=new Float32Array(16);return Wn(n),n},z.a_=function(){const n=new Float64Array(16);return Wn(n),n},z.aa=function(n){return n*Math.PI/180},z.ab=Li,z.ac=function(n,t){const r=[];for(const s in n)s in t||r.push(s);return r},z.ad=ei,z.ae=function(n){return Math.hypot(n[0],n[1])},z.af=function(n){return n[0]=0,n[1]=0,n},z.ag=function(n,t,r){return n[0]=t[0]*r,n[1]=t[1]*r,n},z.ah=function(n,t){let r=0,s=0;if(n.kind==="constant")s=n.layoutSize;else if(n.kind!=="source"){const{interpolationType:l,minZoom:d,maxZoom:p}=n,m=l?Li(ct.interpolationFactor(l,t,d,p),0,1):0;n.kind==="camera"?s=Oi.number(n.minSize,n.maxSize,m):r=m}return{uSizeT:r,uSize:s}},z.aj=function(n,{uSize:t,uSizeT:r},{lowerSize:s,upperSize:l}){return n.kind==="source"?s/kr:n.kind==="composite"?Oi.number(s/kr,l/kr,r):t},z.ak=mh,z.al=Ji,z.am=function(n,t,r,s){const l=t.y-n.y,d=t.x-n.x,p=s.y-r.y,m=s.x-r.x,g=p*d-m*l;if(g===0)return null;const x=(m*(n.y-r.y)-p*(n.x-r.x))/g;return new Oe(n.x+x*d,n.y+x*l)},z.an=function(n,t){var r=t[0],s=t[1],l=t[2],d=t[3],p=t[4],m=t[5],g=t[6],x=t[7],b=t[8],w=t[9],M=t[10],C=t[11],E=t[12],k=t[13],O=t[14],Z=t[15],ee=r*m-s*p,q=r*g-l*p,I=r*x-d*p,F=s*g-l*m,H=s*x-d*m,ae=l*x-d*g,xe=b*k-w*E,ce=b*O-M*E,pe=b*Z-C*E,we=w*O-M*k,be=w*Z-C*k,Te=M*Z-C*O,_e=ee*Te-q*be+I*we+F*pe-H*ce+ae*xe;return _e?(n[0]=(m*Te-g*be+x*we)*(_e=1/_e),n[1]=(l*be-s*Te-d*we)*_e,n[2]=(k*ae-O*H+Z*F)*_e,n[3]=(M*H-w*ae-C*F)*_e,n[4]=(g*pe-p*Te-x*ce)*_e,n[5]=(r*Te-l*pe+d*ce)*_e,n[6]=(O*I-E*ae-Z*q)*_e,n[7]=(b*ae-M*I+C*q)*_e,n[8]=(p*be-m*pe+x*xe)*_e,n[9]=(s*pe-r*be-d*xe)*_e,n[10]=(E*H-k*I+Z*ee)*_e,n[11]=(w*I-b*H-C*ee)*_e,n[12]=(m*ce-p*we-g*xe)*_e,n[13]=(r*we-s*ce+l*xe)*_e,n[14]=(k*q-E*F-O*ee)*_e,n[15]=(b*F-w*q+M*ee)*_e,n):null},z.ao=qu,z.ap=Lo,z.aq=Wn,z.ar=function(n){let t=1/0,r=1/0,s=-1/0,l=-1/0;for(const d of n)t=Math.min(t,d.x),r=Math.min(r,d.y),s=Math.max(s,d.x),l=Math.max(l,d.y);return[t,r,s,l]},z.as=Ut,z.at=yn,z.au=function(n,t,r,s,l=!1){if(!r[0]&&!r[1])return[0,0];const d=l?s==="map"?-n.bearingInRadians:0:s==="viewport"?n.bearingInRadians:0;if(d){const p=Math.sin(d),m=Math.cos(d);r=[r[0]*m-r[1]*p,r[0]*p+r[1]*m]}return[l?r[0]:yn(t,r[0],n.zoom),l?r[1]:yn(t,r[1],n.zoom)]},z.aw=fh,z.ax=Th,z.ay=ph,z.az=Ph,z.b=Gr,z.b$=n=>n.type==="line",z.b0=function(n,t,r){const s=new Float64Array(4);return function(l,d,p,m){var g=.5*Math.PI/180;d*=g,p*=g,m*=g;var x=Math.sin(d),b=Math.cos(d),w=Math.sin(p),M=Math.cos(p),C=Math.sin(m),E=Math.cos(m);l[0]=x*M*E-b*w*C,l[1]=b*w*E+x*M*C,l[2]=b*M*C-x*w*E,l[3]=b*M*E+x*w*C}(s,n,t-90,r),s},z.b1=function(n,t,r,s){var l,d,p,m,g,x=t[0],b=t[1],w=t[2],M=t[3],C=r[0],E=r[1],k=r[2],O=r[3];return(d=x*C+b*E+w*k+M*O)<0&&(d=-d,C=-C,E=-E,k=-k,O=-O),1-d>Mt?(l=Math.acos(d),p=Math.sin(l),m=Math.sin((1-s)*l)/p,g=Math.sin(s*l)/p):(m=1-s,g=s),n[0]=m*x+g*C,n[1]=m*b+g*E,n[2]=m*w+g*k,n[3]=m*M+g*O,n},z.b2=function(n){const t=new Float64Array(9);var r,s,l,d,p,m,g,x,b,w,M,C,E,k,O,Z,ee,q;w=(l=(s=n)[0])*(g=l+l),M=(d=s[1])*g,E=(p=s[2])*g,k=p*(x=d+d),Z=(m=s[3])*g,ee=m*x,q=m*(b=p+p),(r=t)[0]=1-(C=d*x)-(O=p*b),r[3]=M-q,r[6]=E+ee,r[1]=M+q,r[4]=1-w-O,r[7]=k-Z,r[2]=E-ee,r[5]=k+Z,r[8]=1-w-C;const I=mi(-Math.asin(Li(t[2],-1,1)));let F,H;return Math.hypot(t[5],t[8])<.001?(F=0,H=-mi(Math.atan2(t[3],t[4]))):(F=mi(t[5]===0&&t[8]===0?0:Math.atan2(t[5],t[8])),H=mi(t[1]===0&&t[0]===0?0:Math.atan2(t[1],t[0]))),{roll:F,pitch:I+90,bearing:H}},z.b3=function(n,t){return n.roll==t.roll&&n.pitch==t.pitch&&n.bearing==t.bearing},z.b4=Xe,z.b5=cr,z.b6=Ta,z.b7=$o,z.b8=wa,z.b9=jr,z.bA=Ur,z.bB=Zr,z.bC=class extends yi{constructor(n,t){super(n,t),this.current=0}set(n){this.current!==n&&(this.current=n,this.gl.uniform1i(this.location,n))}},z.bD=class extends yi{constructor(n,t){super(n,t),this.current=Un}set(n){if(n[12]!==this.current[12]||n[0]!==this.current[0])return this.current=n,void this.gl.uniformMatrix4fv(this.location,!1,n);for(let t=1;t<16;t++)if(n[t]!==this.current[t]){this.current=n,this.gl.uniformMatrix4fv(this.location,!1,n);break}}},z.bE=Is,z.bF=Cs,z.bG=class extends yi{constructor(n,t){super(n,t),this.current=[0,0,0]}set(n){n[0]===this.current[0]&&n[1]===this.current[1]&&n[2]===this.current[2]||(this.current=n,this.gl.uniform3f(this.location,n[0],n[1],n[2]))}},z.bH=class extends yi{constructor(n,t){super(n,t),this.current=[0,0]}set(n){n[0]===this.current[0]&&n[1]===this.current[1]||(this.current=n,this.gl.uniform2f(this.location,n[0],n[1]))}},z.bI=Ct,z.bJ=function(n,t){var r=Math.sin(t),s=Math.cos(t);return n[0]=s,n[1]=r,n[2]=0,n[3]=-r,n[4]=s,n[5]=0,n[6]=0,n[7]=0,n[8]=1,n},z.bK=function(n,t,r){var s=t[0],l=t[1],d=t[2];return n[0]=s*r[0]+l*r[3]+d*r[6],n[1]=s*r[1]+l*r[4]+d*r[7],n[2]=s*r[2]+l*r[5]+d*r[8],n},z.bL=function(n,t,r,s,l,d,p){var m=1/(t-r),g=1/(s-l),x=1/(d-p);return n[0]=-2*m,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*g,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*x,n[11]=0,n[12]=(t+r)*m,n[13]=(l+s)*g,n[14]=(p+d)*x,n[15]=1,n},z.bM=class extends Ao{},z.bN=sp,z.bO=class extends Ar{},z.bP=Wc,z.bQ=function(n){return n<=1?1:Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))},z.bR=Vh,z.bS=function(n,t,r){var s=t[0],l=t[1],d=t[2],p=r[3]*s+r[7]*l+r[11]*d+r[15];return n[0]=(r[0]*s+r[4]*l+r[8]*d+r[12])/(p=p||1),n[1]=(r[1]*s+r[5]*l+r[9]*d+r[13])/p,n[2]=(r[2]*s+r[6]*l+r[10]*d+r[14])/p,n},z.bT=class extends Io{},z.bU=class extends i{},z.bV=function(n,t){return n[0]===t[0]&&n[1]===t[1]&&n[2]===t[2]&&n[3]===t[3]&&n[4]===t[4]&&n[5]===t[5]&&n[6]===t[6]&&n[7]===t[7]&&n[8]===t[8]&&n[9]===t[9]&&n[10]===t[10]&&n[11]===t[11]&&n[12]===t[12]&&n[13]===t[13]&&n[14]===t[14]&&n[15]===t[15]},z.bW=function(n,t){var r=n[0],s=n[1],l=n[2],d=n[3],p=n[4],m=n[5],g=n[6],x=n[7],b=n[8],w=n[9],M=n[10],C=n[11],E=n[12],k=n[13],O=n[14],Z=n[15],ee=t[0],q=t[1],I=t[2],F=t[3],H=t[4],ae=t[5],xe=t[6],ce=t[7],pe=t[8],we=t[9],be=t[10],Te=t[11],_e=t[12],ke=t[13],Fe=t[14],Be=t[15];return Math.abs(r-ee)<=Mt*Math.max(1,Math.abs(r),Math.abs(ee))&&Math.abs(s-q)<=Mt*Math.max(1,Math.abs(s),Math.abs(q))&&Math.abs(l-I)<=Mt*Math.max(1,Math.abs(l),Math.abs(I))&&Math.abs(d-F)<=Mt*Math.max(1,Math.abs(d),Math.abs(F))&&Math.abs(p-H)<=Mt*Math.max(1,Math.abs(p),Math.abs(H))&&Math.abs(m-ae)<=Mt*Math.max(1,Math.abs(m),Math.abs(ae))&&Math.abs(g-xe)<=Mt*Math.max(1,Math.abs(g),Math.abs(xe))&&Math.abs(x-ce)<=Mt*Math.max(1,Math.abs(x),Math.abs(ce))&&Math.abs(b-pe)<=Mt*Math.max(1,Math.abs(b),Math.abs(pe))&&Math.abs(w-we)<=Mt*Math.max(1,Math.abs(w),Math.abs(we))&&Math.abs(M-be)<=Mt*Math.max(1,Math.abs(M),Math.abs(be))&&Math.abs(C-Te)<=Mt*Math.max(1,Math.abs(C),Math.abs(Te))&&Math.abs(E-_e)<=Mt*Math.max(1,Math.abs(E),Math.abs(_e))&&Math.abs(k-ke)<=Mt*Math.max(1,Math.abs(k),Math.abs(ke))&&Math.abs(O-Fe)<=Mt*Math.max(1,Math.abs(O),Math.abs(Fe))&&Math.abs(Z-Be)<=Mt*Math.max(1,Math.abs(Z),Math.abs(Be))},z.bX=function(n,t){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n},z.bY=n=>n.type==="symbol",z.bZ=n=>n.type==="circle",z.b_=n=>n.type==="heatmap",z.ba=Nr,z.bb=ni,z.bc=function(n,t,r,s,l){return jr(s,l,Li((n-t)/(r-t),0,1))},z.bd=xr,z.be=function(){return new Float64Array(4)},z.bf=function(){return new Float64Array(3)},z.bg=function(n,t,r,s){var l=[],d=[];return l[0]=t[0]-r[0],l[1]=t[1]-r[1],l[2]=t[2]-r[2],d[0]=l[0]*Math.cos(s)-l[1]*Math.sin(s),d[1]=l[0]*Math.sin(s)+l[1]*Math.cos(s),d[2]=l[2],n[0]=d[0]+r[0],n[1]=d[1]+r[1],n[2]=d[2]+r[2],n},z.bh=function(n,t,r,s){var l=[],d=[];return l[0]=t[0]-r[0],l[1]=t[1]-r[1],l[2]=t[2]-r[2],d[0]=l[0],d[1]=l[1]*Math.cos(s)-l[2]*Math.sin(s),d[2]=l[1]*Math.sin(s)+l[2]*Math.cos(s),n[0]=d[0]+r[0],n[1]=d[1]+r[1],n[2]=d[2]+r[2],n},z.bi=function(n,t,r,s){var l=[],d=[];return l[0]=t[0]-r[0],l[1]=t[1]-r[1],l[2]=t[2]-r[2],d[0]=l[2]*Math.sin(s)+l[0]*Math.cos(s),d[1]=l[1],d[2]=l[2]*Math.cos(s)-l[0]*Math.sin(s),n[0]=d[0]+r[0],n[1]=d[1]+r[1],n[2]=d[2]+r[2],n},z.bj=function(n,t,r){var s=Math.sin(r),l=Math.cos(r),d=t[0],p=t[1],m=t[2],g=t[3],x=t[8],b=t[9],w=t[10],M=t[11];return t!==n&&(n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[0]=d*l-x*s,n[1]=p*l-b*s,n[2]=m*l-w*s,n[3]=g*l-M*s,n[8]=d*s+x*l,n[9]=p*s+b*l,n[10]=m*s+w*l,n[11]=g*s+M*l,n},z.bk=function(n,t){const r=xr(n,360),s=xr(t,360),l=s-r,d=s>r?l-360:l+360;return Math.abs(l)<Math.abs(d)?l:d},z.bl=function(n){return n[0]=0,n[1]=0,n[2]=0,n},z.bm=function(n,t,r,s){const l=Math.sqrt(n*n+t*t),d=Math.sqrt(r*r+s*s);n/=l,t/=l,r/=d,s/=d;const p=Math.acos(n*r+t*s);return-t*r+n*s>0?p:-p},z.bn=function(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]},z.bo=xh,z.bp=function(n,t){const r=xr(n,2*Math.PI),s=xr(t,2*Math.PI);return Math.min(Math.abs(r-s),Math.abs(r-s+2*Math.PI),Math.abs(r-s-2*Math.PI))},z.bq=function(n){return Math.hypot(n[0],n[1],n[2])},z.br=function(){const n={},t=j.$version;for(const r in j.$root){const s=j.$root[r];if(s.required){let l=null;l=r==="version"?t:s.type==="array"?[]:{},l!=null&&(n[r]=l)}}return n},z.bs=Gl,z.bt=Wr,z.bu=function(n){n=n.slice();const t=Object.create(null);for(let r=0;r<n.length;r++)t[n[r].id]=n[r];for(let r=0;r<n.length;r++)"ref"in n[r]&&(n[r]=L(n[r],t[n[r].ref]));return n},z.bv=function(n){if(n.type==="custom")return new Cp(n);switch(n.type){case"background":return new Mp(n);case"circle":return new vd(n);case"fill":return new jd(n);case"fill-extrusion":return new Hd(n);case"heatmap":return new wd(n);case"hillshade":return new Pd(n);case"line":return new tp(n);case"raster":return new Ip(n);case"symbol":return new mc(n)}},z.bw=fi,z.bx=function(n,t){if(!n)return[{command:"setStyle",args:[t]}];let r=[];try{if(!B(n.version,t.version))return[{command:"setStyle",args:[t]}];B(n.center,t.center)||r.push({command:"setCenter",args:[t.center]}),B(n.centerAltitude,t.centerAltitude)||r.push({command:"setCenterAltitude",args:[t.centerAltitude]}),B(n.zoom,t.zoom)||r.push({command:"setZoom",args:[t.zoom]}),B(n.bearing,t.bearing)||r.push({command:"setBearing",args:[t.bearing]}),B(n.pitch,t.pitch)||r.push({command:"setPitch",args:[t.pitch]}),B(n.roll,t.roll)||r.push({command:"setRoll",args:[t.roll]}),B(n.sprite,t.sprite)||r.push({command:"setSprite",args:[t.sprite]}),B(n.glyphs,t.glyphs)||r.push({command:"setGlyphs",args:[t.glyphs]}),B(n.transition,t.transition)||r.push({command:"setTransition",args:[t.transition]}),B(n.light,t.light)||r.push({command:"setLight",args:[t.light]}),B(n.terrain,t.terrain)||r.push({command:"setTerrain",args:[t.terrain]}),B(n.sky,t.sky)||r.push({command:"setSky",args:[t.sky]}),B(n.projection,t.projection)||r.push({command:"setProjection",args:[t.projection]});const s={},l=[];(function(p,m,g,x){let b;for(b in m=m||{},p=p||{})Object.prototype.hasOwnProperty.call(p,b)&&(Object.prototype.hasOwnProperty.call(m,b)||re(b,g,x));for(b in m)Object.prototype.hasOwnProperty.call(m,b)&&(Object.prototype.hasOwnProperty.call(p,b)?B(p[b],m[b])||(p[b].type==="geojson"&&m[b].type==="geojson"&&ie(p,m,b)?$(g,{command:"setGeoJSONSourceData",args:[b,m[b].data]}):le(b,m,g,x)):Y(b,m,g))})(n.sources,t.sources,l,s);const d=[];n.layers&&n.layers.forEach(p=>{"source"in p&&s[p.source]?r.push({command:"removeLayer",args:[p.id]}):d.push(p)}),r=r.concat(l),function(p,m,g){m=m||[];const x=(p=p||[]).map(he),b=m.map(he),w=p.reduce(ne,{}),M=m.reduce(ne,{}),C=x.slice(),E=Object.create(null);let k,O,Z,ee,q;for(let I=0,F=0;I<x.length;I++)k=x[I],Object.prototype.hasOwnProperty.call(M,k)?F++:($(g,{command:"removeLayer",args:[k]}),C.splice(C.indexOf(k,F),1));for(let I=0,F=0;I<b.length;I++)k=b[b.length-1-I],C[C.length-1-I]!==k&&(Object.prototype.hasOwnProperty.call(w,k)?($(g,{command:"removeLayer",args:[k]}),C.splice(C.lastIndexOf(k,C.length-F),1)):F++,ee=C[C.length-I],$(g,{command:"addLayer",args:[M[k],ee]}),C.splice(C.length-I,0,k),E[k]=!0);for(let I=0;I<b.length;I++)if(k=b[I],O=w[k],Z=M[k],!E[k]&&!B(O,Z))if(B(O.source,Z.source)&&B(O["source-layer"],Z["source-layer"])&&B(O.type,Z.type)){for(q in fe(O.layout,Z.layout,g,k,null,"setLayoutProperty"),fe(O.paint,Z.paint,g,k,null,"setPaintProperty"),B(O.filter,Z.filter)||$(g,{command:"setFilter",args:[k,Z.filter]}),B(O.minzoom,Z.minzoom)&&B(O.maxzoom,Z.maxzoom)||$(g,{command:"setLayerZoomRange",args:[k,Z.minzoom,Z.maxzoom]}),O)Object.prototype.hasOwnProperty.call(O,q)&&q!=="layout"&&q!=="paint"&&q!=="filter"&&q!=="metadata"&&q!=="minzoom"&&q!=="maxzoom"&&(q.indexOf("paint.")===0?fe(O[q],Z[q],g,k,q.slice(6),"setPaintProperty"):B(O[q],Z[q])||$(g,{command:"setLayerProperty",args:[k,q,Z[q]]}));for(q in Z)Object.prototype.hasOwnProperty.call(Z,q)&&!Object.prototype.hasOwnProperty.call(O,q)&&q!=="layout"&&q!=="paint"&&q!=="filter"&&q!=="metadata"&&q!=="minzoom"&&q!=="maxzoom"&&(q.indexOf("paint.")===0?fe(O[q],Z[q],g,k,q.slice(6),"setPaintProperty"):B(O[q],Z[q])||$(g,{command:"setLayerProperty",args:[k,q,Z[q]]}))}else $(g,{command:"removeLayer",args:[k]}),ee=C[C.lastIndexOf(k)+1],$(g,{command:"addLayer",args:[Z,ee]})}(d,t.layers,r)}catch(s){console.warn("Unable to compute style diff:",s),r=[{command:"setStyle",args:[t]}]}return r},z.by=function(n){const t=[],r=n.id;return r===void 0&&t.push({message:`layers.${r}: missing required property "id"`}),n.render===void 0&&t.push({message:`layers.${r}: missing required method "render"`}),n.renderingMode&&n.renderingMode!=="2d"&&n.renderingMode!=="3d"&&t.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),t},z.bz=function n(t,r){if(Array.isArray(t)){if(!Array.isArray(r)||t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(!n(t[s],r[s]))return!1;return!0}if(typeof t=="object"&&t!==null&&r!==null){if(typeof r!="object"||Object.keys(t).length!==Object.keys(r).length)return!1;for(const s in t)if(!n(t[s],r[s]))return!1;return!0}return t===r},z.c=Hr,z.c0=n=>n.type==="fill",z.c1=n=>n.type==="fill-extrusion",z.c2=n=>n.type==="hillshade",z.c3=n=>n.type==="raster",z.c4=n=>n.type==="background",z.c5=n=>n.type==="custom",z.c6=xn,z.c7=function(n,t,r){const s=Kn(t.x-r.x,t.y-r.y),l=Kn(n.x-r.x,n.y-r.y);var d,p;return mi(Math.atan2(s[0]*l[1]-s[1]*l[0],(d=s)[0]*(p=l)[0]+d[1]*p[1]))},z.c8=$i,z.c9=function(n,t,r){var s=t[0],l=t[1];return n[0]=r[0]*s+r[4]*l+r[12],n[1]=r[1]*s+r[5]*l+r[13],n},z.cA=_u,z.cB=Qs,z.cC=ar,z.ca=function(n,t){const{x:r,y:s}=Qo.fromLngLat(t);return!(n<0||n>25||s<0||s>=1||r<0||r>=1)},z.cb=function(n,t){return n[0]=t[0],n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=t[1],n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=t[2],n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n},z.cc=class extends Ts{},z.cd=Op,z.cf=function(n){return n.message===qr},z.cg=er,z.ch=function(n,t){wr.REGISTERED_PROTOCOLS[n]=t},z.ci=function(n){delete wr.REGISTERED_PROTOCOLS[n]},z.cj=function(n,t){const r={};for(let l=0;l<n.length;l++){const d=t&&t[n[l].id]||go(n[l]);t&&(t[n[l].id]=d);let p=r[d];p||(p=r[d]=[]),p.push(n[l])}const s=[];for(const l in r)s.push(r[l]);return s},z.ck=Ae,z.cl=Vu,z.cm=Zu,z.cn=yu,z.co=function(n){n.bucket.createArrays(),n.bucket.tilePixelRatio=rt/(512*n.bucket.overscaling),n.bucket.compareText={},n.bucket.iconsNeedLinear=!1;const t=n.bucket.layers[0],r=t.layout,s=t._unevaluatedLayout._values,l={layoutIconSize:s["icon-size"].possiblyEvaluate(new yt(n.bucket.zoom+1),n.canonical),layoutTextSize:s["text-size"].possiblyEvaluate(new yt(n.bucket.zoom+1),n.canonical),textMaxSize:s["text-size"].possiblyEvaluate(new yt(18))};if(n.bucket.textSizeData.kind==="composite"){const{minZoom:x,maxZoom:b}=n.bucket.textSizeData;l.compositeTextSizes=[s["text-size"].possiblyEvaluate(new yt(x),n.canonical),s["text-size"].possiblyEvaluate(new yt(b),n.canonical)]}if(n.bucket.iconSizeData.kind==="composite"){const{minZoom:x,maxZoom:b}=n.bucket.iconSizeData;l.compositeIconSizes=[s["icon-size"].possiblyEvaluate(new yt(x),n.canonical),s["icon-size"].possiblyEvaluate(new yt(b),n.canonical)]}const d=r.get("text-line-height")*Ut,p=r.get("text-rotation-alignment")!=="viewport"&&r.get("symbol-placement")!=="point",m=r.get("text-keep-upright"),g=r.get("text-size");for(const x of n.bucket.features){const b=r.get("text-font").evaluate(x,{},n.canonical).join(","),w=g.evaluate(x,{},n.canonical),M=l.layoutTextSize.evaluate(x,{},n.canonical),C=l.layoutIconSize.evaluate(x,{},n.canonical),E={horizontal:{},vertical:void 0},k=x.text;let O,Z=[0,0];if(k){const I=k.toString(),F=r.get("text-letter-spacing").evaluate(x,{},n.canonical)*Ut,H=$l(I)?F:0,ae=r.get("text-anchor").evaluate(x,{},n.canonical),xe=td(t,x,n.canonical);if(!xe){const be=r.get("text-radial-offset").evaluate(x,{},n.canonical);Z=be?ed(ae,[be*Ut,wh]):r.get("text-offset").evaluate(x,{},n.canonical).map(Te=>Te*Ut)}let ce=p?"center":r.get("text-justify").evaluate(x,{},n.canonical);const pe=r.get("symbol-placement")==="point"?r.get("text-max-width").evaluate(x,{},n.canonical)*Ut:1/0,we=()=>{n.bucket.allowVerticalPlacement&&On(I)&&(E.vertical=dc(k,n.glyphMap,n.glyphPositions,n.imagePositions,b,pe,d,ae,"left",H,Z,z.ai.vertical,!0,M,w))};if(!p&&xe){const be=new Set;if(ce==="auto")for(let _e=0;_e<xe.values.length;_e+=2)be.add(Th(xe.values[_e]));else be.add(ce);let Te=!1;for(const _e of be)if(!E.horizontal[_e])if(Te)E.horizontal[_e]=E.horizontal[0];else{const ke=dc(k,n.glyphMap,n.glyphPositions,n.imagePositions,b,pe,d,"center",_e,H,Z,z.ai.horizontal,!1,M,w);ke&&(E.horizontal[_e]=ke,Te=ke.positionedLines.length===1)}we()}else{ce==="auto"&&(ce=Th(ae));const be=dc(k,n.glyphMap,n.glyphPositions,n.imagePositions,b,pe,d,ae,ce,H,Z,z.ai.horizontal,!1,M,w);be&&(E.horizontal[ce]=be),we(),On(I)&&p&&m&&(E.vertical=dc(k,n.glyphMap,n.glyphPositions,n.imagePositions,b,pe,d,ae,ce,H,Z,z.ai.vertical,!1,M,w))}}let ee=!1;if(x.icon&&x.icon.name){const I=n.imageMap[x.icon.name];I&&(O=vp(n.imagePositions[x.icon.name],r.get("icon-offset").evaluate(x,{},n.canonical),r.get("icon-anchor").evaluate(x,{},n.canonical)),ee=!!I.sdf,n.bucket.sdfIcons===void 0?n.bucket.sdfIcons=ee:n.bucket.sdfIcons!==ee&&ti("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(I.pixelRatio!==n.bucket.pixelRatio||r.get("icon-rotate").constantOr(1)!==0)&&(n.bucket.iconsNeedLinear=!0))}const q=rd(E.horizontal)||E.vertical;n.bucket.iconsInText=!!q&&q.iconsInText,(q||O)&&Bp(n.bucket,x,E,O,n.imageMap,l,M,C,Z,ee,n.canonical,n.subdivisionGranularity)}n.showCollisionBoxes&&n.bucket.generateCollisionDebugBuffers()},z.cp=ah,z.cq=eh,z.cr=sh,z.cs=Ho,z.ct=ch,z.cu=class{constructor(n){this._marks={start:[n.url,"start"].join("#"),end:[n.url,"end"].join("#"),measure:n.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let n=performance.getEntriesByName(this._marks.measure);return n.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),n=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),n}},z.cv=function(n,t,r,s,l){return c(this,void 0,void 0,function*(){if(oi())try{return yield Bi(n,t,r,s,l)}catch{}return function(d,p,m,g,x){const b=d.width,w=d.height;vr&&br||(vr=new OffscreenCanvas(b,w),br=vr.getContext("2d",{willReadFrequently:!0})),vr.width=b,vr.height=w,br.drawImage(d,0,0,b,w);const M=br.getImageData(p,m,g,x);return br.clearRect(0,0,b,w),M.data}(n,t,r,s,l)})},z.cw=Nu,z.cx=Pi,z.cy=mr,z.cz=nu,z.d=n=>c(void 0,void 0,void 0,function*(){if(n.byteLength===0)return createImageBitmap(new ImageData(1,1));const t=new Blob([new Uint8Array(n)],{type:"image/png"});try{return createImageBitmap(t)}catch(r){throw new Error(`Could not load image because of ${r.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),z.e=Wt,z.f=n=>new Promise((t,r)=>{const s=new Image;s.onload=()=>{t(s),URL.revokeObjectURL(s.src),s.onload=null,window.requestAnimationFrame(()=>{s.src=$r})},s.onerror=()=>r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const l=new Blob([new Uint8Array(n)],{type:"image/png"});s.src=n.byteLength?URL.createObjectURL(l):$r}),z.g=Jn,z.h=(n,t)=>tr(Wt(n,{type:"json"}),t),z.i=Qi,z.j=Qn,z.k=bn,z.l=(n,t)=>tr(Wt(n,{type:"arrayBuffer"}),t),z.m=tr,z.n=function(n){return new ch(n).readFields(lp,[])},z.o=No,z.p=gu,z.q=ui,z.r=Uc,z.s=Kr,z.t=Vl,z.u=Fn,z.v=j,z.w=ti,z.x=function([n,t,r]){return t+=90,t*=Math.PI/180,r*=Math.PI/180,{x:n*Math.cos(t)*Math.sin(r),y:n*Math.sin(t)*Math.sin(r),z:n*Math.cos(r)}},z.y=Oi,z.z=yt}),Lr("worker",["./shared"],function(z){class c{constructor(D){this.keyCache={},D&&this.replace(D)}replace(D){this._layerConfigs={},this._layers={},this.update(D,[])}update(D,L){for(const $ of D){this._layerConfigs[$.id]=$;const Y=this._layers[$.id]=z.bv($);Y._featureFilter=z.a4(Y.filter),this.keyCache[$.id]&&delete this.keyCache[$.id]}for(const $ of L)delete this.keyCache[$],delete this._layerConfigs[$],delete this._layers[$];this.familiesBySource={};const B=z.cj(Object.values(this._layerConfigs),this.keyCache);for(const $ of B){const Y=$.map(ne=>this._layers[ne.id]),re=Y[0];if(re.visibility==="none")continue;const le=re.source||"";let ie=this.familiesBySource[le];ie||(ie=this.familiesBySource[le]={});const fe=re.sourceLayer||"_geojsonTileLayer";let he=ie[fe];he||(he=ie[fe]=[]),he.push(Y)}}}class Pi{constructor(D){const L={},B=[];for(const le in D){const ie=D[le],fe=L[le]={};for(const he in ie){const ne=ie[+he];if(!ne||ne.bitmap.width===0||ne.bitmap.height===0)continue;const te={x:0,y:0,w:ne.bitmap.width+2,h:ne.bitmap.height+2};B.push(te),fe[he]={rect:te,metrics:ne.metrics}}}const{w:$,h:Y}=z.p(B),re=new z.o({width:$||1,height:Y||1});for(const le in D){const ie=D[le];for(const fe in ie){const he=ie[+fe];if(!he||he.bitmap.width===0||he.bitmap.height===0)continue;const ne=L[le][fe].rect;z.o.copy(he.bitmap,re,{x:0,y:0},{x:ne.x+1,y:ne.y+1},he.bitmap)}}this.image=re,this.positions=L}}z.ck("GlyphAtlas",Pi);class fr{constructor(D){this.tileID=new z.S(D.tileID.overscaledZ,D.tileID.wrap,D.tileID.canonical.z,D.tileID.canonical.x,D.tileID.canonical.y),this.uid=D.uid,this.zoom=D.zoom,this.pixelRatio=D.pixelRatio,this.tileSize=D.tileSize,this.source=D.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=D.showCollisionBoxes,this.collectResourceTiming=!!D.collectResourceTiming,this.returnDependencies=!!D.returnDependencies,this.promoteId=D.promoteId,this.inFlightDependencies=[]}parse(D,L,B,$,Y){return z._(this,void 0,void 0,function*(){this.status="parsing",this.data=D,this.collisionBoxArray=new z.a2;const re=new z.cl(Object.keys(D.layers).sort()),le=new z.cm(this.tileID,this.promoteId);le.bucketLayerIDs=[];const ie={},fe={featureIndex:le,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:B,subdivisionGranularity:Y},he=L.familiesBySource[this.source];for(const Ve in he){const ze=D.layers[Ve];if(!ze)continue;ze.version===1&&z.w(`Vector tile source "${this.source}" layer "${Ve}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const St=re.encode(Ve),Mr=[];for(let jt=0;jt<ze.length;jt++){const Rt=ze.feature(jt),mt=le.getId(Rt,Ve);Mr.push({feature:Rt,id:mt,index:jt,sourceLayerIndex:St})}for(const jt of he[Ve]){const Rt=jt[0];Rt.source!==this.source&&z.w(`layer.source = ${Rt.source} does not equal this.source = ${this.source}`),Rt.minzoom&&this.zoom<Math.floor(Rt.minzoom)||Rt.maxzoom&&this.zoom>=Rt.maxzoom||Rt.visibility!=="none"&&(Mi(jt,this.zoom,B),(ie[Rt.id]=Rt.createBucket({index:le.bucketLayerIDs.length,layers:jt,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:St,sourceID:this.source})).populate(Mr,fe,this.tileID.canonical),le.bucketLayerIDs.push(jt.map(mt=>mt.id)))}}const ne=z.bA(fe.glyphDependencies,Ve=>Object.keys(Ve).map(Number));this.inFlightDependencies.forEach(Ve=>Ve==null?void 0:Ve.abort()),this.inFlightDependencies=[];let te=Promise.resolve({});if(Object.keys(ne).length){const Ve=new AbortController;this.inFlightDependencies.push(Ve),te=$.sendAsync({type:"GG",data:{stacks:ne,source:this.source,tileID:this.tileID,type:"glyphs"}},Ve)}const Ie=Object.keys(fe.iconDependencies);let Me=Promise.resolve({});if(Ie.length){const Ve=new AbortController;this.inFlightDependencies.push(Ve),Me=$.sendAsync({type:"GI",data:{icons:Ie,source:this.source,tileID:this.tileID,type:"icons"}},Ve)}const je=Object.keys(fe.patternDependencies);let Ue=Promise.resolve({});if(je.length){const Ve=new AbortController;this.inFlightDependencies.push(Ve),Ue=$.sendAsync({type:"GI",data:{icons:je,source:this.source,tileID:this.tileID,type:"patterns"}},Ve)}const[ge,Ce,De]=yield Promise.all([te,Me,Ue]),qe=new Pi(ge),Je=new z.cn(Ce,De);for(const Ve in ie){const ze=ie[Ve];ze instanceof z.a3?(Mi(ze.layers,this.zoom,B),z.co({bucket:ze,glyphMap:ge,glyphPositions:qe.positions,imageMap:Ce,imagePositions:Je.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:fe.subdivisionGranularity})):ze.hasPattern&&(ze instanceof z.cp||ze instanceof z.cq||ze instanceof z.cr)&&(Mi(ze.layers,this.zoom,B),ze.addFeatures(fe,this.tileID.canonical,Je.patternPositions))}return this.status="done",{buckets:Object.values(ie).filter(Ve=>!Ve.isEmpty()),featureIndex:le,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:qe.image,imageAtlas:Je,glyphMap:this.returnDependencies?ge:null,iconMap:this.returnDependencies?Ce:null,glyphPositions:this.returnDependencies?qe.positions:null}})}}function Mi(j,D,L){const B=new z.z(D);for(const $ of j)$.recalculate(B,L)}class mr{constructor(D,L,B){this.actor=D,this.layerIndex=L,this.availableImages=B,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(D,L){return z._(this,void 0,void 0,function*(){const B=yield z.l(D.request,L);try{return{vectorTile:new z.cs.VectorTile(new z.ct(B.data)),rawData:B.data,cacheControl:B.cacheControl,expires:B.expires}}catch($){const Y=new Uint8Array(B.data);let re=`Unable to parse the tile at ${D.request.url}, `;throw re+=Y[0]===31&&Y[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${$.message}`,new Error(re)}})}loadTile(D){return z._(this,void 0,void 0,function*(){const L=D.uid,B=!!(D&&D.request&&D.request.collectResourceTiming)&&new z.cu(D.request),$=new fr(D);this.loading[L]=$;const Y=new AbortController;$.abort=Y;try{const re=yield this.loadVectorTile(D,Y);if(delete this.loading[L],!re)return null;const le=re.rawData,ie={};re.expires&&(ie.expires=re.expires),re.cacheControl&&(ie.cacheControl=re.cacheControl);const fe={};if(B){const ne=B.finish();ne&&(fe.resourceTiming=JSON.parse(JSON.stringify(ne)))}$.vectorTile=re.vectorTile;const he=$.parse(re.vectorTile,this.layerIndex,this.availableImages,this.actor,D.subdivisionGranularity);this.loaded[L]=$,this.fetching[L]={rawTileData:le,cacheControl:ie,resourceTiming:fe};try{const ne=yield he;return z.e({rawTileData:le.slice(0)},ne,ie,fe)}finally{delete this.fetching[L]}}catch(re){throw delete this.loading[L],$.status="done",this.loaded[L]=$,re}})}reloadTile(D){return z._(this,void 0,void 0,function*(){const L=D.uid;if(!this.loaded||!this.loaded[L])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const B=this.loaded[L];if(B.showCollisionBoxes=D.showCollisionBoxes,B.status==="parsing"){const $=yield B.parse(B.vectorTile,this.layerIndex,this.availableImages,this.actor,D.subdivisionGranularity);let Y;if(this.fetching[L]){const{rawTileData:re,cacheControl:le,resourceTiming:ie}=this.fetching[L];delete this.fetching[L],Y=z.e({rawTileData:re.slice(0)},$,le,ie)}else Y=$;return Y}if(B.status==="done"&&B.vectorTile)return B.parse(B.vectorTile,this.layerIndex,this.availableImages,this.actor,D.subdivisionGranularity)})}abortTile(D){return z._(this,void 0,void 0,function*(){const L=this.loading,B=D.uid;L&&L[B]&&L[B].abort&&(L[B].abort.abort(),delete L[B])})}removeTile(D){return z._(this,void 0,void 0,function*(){this.loaded&&this.loaded[D.uid]&&delete this.loaded[D.uid]})}}class Ze{constructor(){this.loaded={}}loadTile(D){return z._(this,void 0,void 0,function*(){const{uid:L,encoding:B,rawImageData:$,redFactor:Y,greenFactor:re,blueFactor:le,baseShift:ie}=D,fe=$.width+2,he=$.height+2,ne=z.b($)?new z.R({width:fe,height:he},yield z.cv($,-1,-1,fe,he)):$,te=new z.cw(L,ne,B,Y,re,le,ie);return this.loaded=this.loaded||{},this.loaded[L]=te,te})}removeTile(D){const L=this.loaded,B=D.uid;L&&L[B]&&delete L[B]}}var ue,Oe,Br=function(){if(Oe)return ue;function j(L,B){if(L.length!==0){D(L[0],B);for(var $=1;$<L.length;$++)D(L[$],!B)}}function D(L,B){for(var $=0,Y=0,re=0,le=L.length,ie=le-1;re<le;ie=re++){var fe=(L[re][0]-L[ie][0])*(L[ie][1]+L[re][1]),he=$+fe;Y+=Math.abs($)>=Math.abs(fe)?$-he+fe:fe-he+$,$=he}$+Y>=0!=!!B&&L.reverse()}return Oe=1,ue=function L(B,$){var Y,re=B&&B.type;if(re==="FeatureCollection")for(Y=0;Y<B.features.length;Y++)L(B.features[Y],$);else if(re==="GeometryCollection")for(Y=0;Y<B.geometries.length;Y++)L(B.geometries[Y],$);else if(re==="Feature")L(B.geometry,$);else if(re==="Polygon")j(B.coordinates,$);else if(re==="MultiPolygon")for(Y=0;Y<B.coordinates.length;Y++)j(B.coordinates[Y],$);return B}}(),_r=z.cx(Br);const Fr=z.cs.VectorTileFeature.prototype.toGeoJSON;class Or{constructor(D){this._feature=D,this.extent=z.X,this.type=D.type,this.properties=D.tags,"id"in D&&!isNaN(D.id)&&(this.id=parseInt(D.id,10))}loadGeometry(){if(this._feature.type===1){const D=[];for(const L of this._feature.geometry)D.push([new z.P(L[0],L[1])]);return D}{const D=[];for(const L of this._feature.geometry){const B=[];for(const $ of L)B.push(new z.P($[0],$[1]));D.push(B)}return D}}toGeoJSON(D,L,B){return Fr.call(this,D,L,B)}}class Xn{constructor(D){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=z.X,this.length=D.length,this._features=D}feature(D){return new Or(this._features[D])}}var oi,gr,Mt,ft={exports:{}},Ct=function(){if(Mt)return ft.exports;Mt=1;var j=z.cA(),D=function(){if(gr)return oi;gr=1;var he=z.cy(),ne=z.cz().VectorTileFeature;function te(Me,je){this.options=je||{},this.features=Me,this.length=Me.length}function Ie(Me,je){this.id=typeof Me.id=="number"?Me.id:void 0,this.type=Me.type,this.rawGeometry=Me.type===1?[Me.geometry]:Me.geometry,this.properties=Me.tags,this.extent=je||4096}return oi=te,te.prototype.feature=function(Me){return new Ie(this.features[Me],this.options.extent)},Ie.prototype.loadGeometry=function(){var Me=this.rawGeometry;this.geometry=[];for(var je=0;je<Me.length;je++){for(var Ue=Me[je],ge=[],Ce=0;Ce<Ue.length;Ce++)ge.push(new he(Ue[Ce][0],Ue[Ce][1]));this.geometry.push(ge)}return this.geometry},Ie.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var Me=this.geometry,je=1/0,Ue=-1/0,ge=1/0,Ce=-1/0,De=0;De<Me.length;De++)for(var qe=Me[De],Je=0;Je<qe.length;Je++){var Ve=qe[Je];je=Math.min(je,Ve.x),Ue=Math.max(Ue,Ve.x),ge=Math.min(ge,Ve.y),Ce=Math.max(Ce,Ve.y)}return[je,ge,Ue,Ce]},Ie.prototype.toGeoJSON=ne.prototype.toGeoJSON,oi}();function L(he){var ne=new j;return function(te,Ie){for(var Me in te.layers)Ie.writeMessage(3,B,te.layers[Me])}(he,ne),ne.finish()}function B(he,ne){var te;ne.writeVarintField(15,he.version||1),ne.writeStringField(1,he.name||""),ne.writeVarintField(5,he.extent||4096);var Ie={keys:[],values:[],keycache:{},valuecache:{}};for(te=0;te<he.length;te++)Ie.feature=he.feature(te),ne.writeMessage(2,$,Ie);var Me=Ie.keys;for(te=0;te<Me.length;te++)ne.writeStringField(3,Me[te]);var je=Ie.values;for(te=0;te<je.length;te++)ne.writeMessage(4,fe,je[te])}function $(he,ne){var te=he.feature;te.id!==void 0&&ne.writeVarintField(1,te.id),ne.writeMessage(2,Y,he),ne.writeVarintField(3,te.type),ne.writeMessage(4,ie,te)}function Y(he,ne){var te=he.feature,Ie=he.keys,Me=he.values,je=he.keycache,Ue=he.valuecache;for(var ge in te.properties){var Ce=te.properties[ge],De=je[ge];if(Ce!==null){De===void 0&&(Ie.push(ge),je[ge]=De=Ie.length-1),ne.writeVarint(De);var qe=typeof Ce;qe!=="string"&&qe!=="boolean"&&qe!=="number"&&(Ce=JSON.stringify(Ce));var Je=qe+":"+Ce,Ve=Ue[Je];Ve===void 0&&(Me.push(Ce),Ue[Je]=Ve=Me.length-1),ne.writeVarint(Ve)}}}function re(he,ne){return(ne<<3)+(7&he)}function le(he){return he<<1^he>>31}function ie(he,ne){for(var te=he.loadGeometry(),Ie=he.type,Me=0,je=0,Ue=te.length,ge=0;ge<Ue;ge++){var Ce=te[ge],De=1;Ie===1&&(De=Ce.length),ne.writeVarint(re(1,De));for(var qe=Ie===3?Ce.length-1:Ce.length,Je=0;Je<qe;Je++){Je===1&&Ie!==1&&ne.writeVarint(re(2,qe-1));var Ve=Ce[Je].x-Me,ze=Ce[Je].y-je;ne.writeVarint(le(Ve)),ne.writeVarint(le(ze)),Me+=Ve,je+=ze}Ie===3&&ne.writeVarint(re(7,1))}}function fe(he,ne){var te=typeof he;te==="string"?ne.writeStringField(1,he):te==="boolean"?ne.writeBooleanField(7,he):te==="number"&&(he%1!=0?ne.writeDoubleField(3,he):he<0?ne.writeSVarintField(6,he):ne.writeVarintField(5,he))}return ft.exports=L,ft.exports.fromVectorTileJs=L,ft.exports.fromGeojsonVt=function(he,ne){ne=ne||{};var te={};for(var Ie in he)te[Ie]=new D(he[Ie].features,ne),te[Ie].name=Ie,te[Ie].version=ne.version,te[Ie].extent=ne.extent;return L({layers:te})},ft.exports.GeoJSONWrapper=D,ft.exports}(),Wn=z.cx(Ct);const Rs={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:j=>j},yr=Math.fround||(Ji=new Float32Array(1),j=>(Ji[0]=+j,Ji[0]));var Ji;const Si=3,ei=5,Kn=6;class rt{constructor(D){this.options=Object.assign(Object.create(Rs),D),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(D){const{log:L,minZoom:B,maxZoom:$}=this.options;L&&console.time("total time");const Y=`prepare ${D.length} points`;L&&console.time(Y),this.points=D;const re=[];for(let ie=0;ie<D.length;ie++){const fe=D[ie];if(!fe.geometry)continue;const[he,ne]=fe.geometry.coordinates,te=yr(jr(he)),Ie=yr(Nr(ne));re.push(te,Ie,1/0,ie,-1,1),this.options.reduce&&re.push(0)}let le=this.trees[$+1]=this._createTree(re);L&&console.timeEnd(Y);for(let ie=$;ie>=B;ie--){const fe=+Date.now();le=this.trees[ie]=this._createTree(this._cluster(le,ie)),L&&console.log("z%d: %d clusters in %dms",ie,le.numItems,+Date.now()-fe)}return L&&console.timeEnd("total time"),this}getClusters(D,L){let B=((D[0]+180)%360+360)%360-180;const $=Math.max(-90,Math.min(90,D[1]));let Y=D[2]===180?180:((D[2]+180)%360+360)%360-180;const re=Math.max(-90,Math.min(90,D[3]));if(D[2]-D[0]>=360)B=-180,Y=180;else if(B>Y){const ne=this.getClusters([B,$,180,re],L),te=this.getClusters([-180,$,Y,re],L);return ne.concat(te)}const le=this.trees[this._limitZoom(L)],ie=le.range(jr(B),Nr(re),jr(Y),Nr($)),fe=le.data,he=[];for(const ne of ie){const te=this.stride*ne;he.push(fe[te+ei]>1?yn(fe,te,this.clusterProps):this.points[fe[te+Si]])}return he}getChildren(D){const L=this._getOriginId(D),B=this._getOriginZoom(D),$="No cluster with the specified id.",Y=this.trees[B];if(!Y)throw new Error($);const re=Y.data;if(L*this.stride>=re.length)throw new Error($);const le=this.options.radius/(this.options.extent*Math.pow(2,B-1)),ie=Y.within(re[L*this.stride],re[L*this.stride+1],le),fe=[];for(const he of ie){const ne=he*this.stride;re[ne+4]===D&&fe.push(re[ne+ei]>1?yn(re,ne,this.clusterProps):this.points[re[ne+Si]])}if(fe.length===0)throw new Error($);return fe}getLeaves(D,L,B){const $=[];return this._appendLeaves($,D,L=L||10,B=B||0,0),$}getTile(D,L,B){const $=this.trees[this._limitZoom(D)],Y=Math.pow(2,D),{extent:re,radius:le}=this.options,ie=le/re,fe=(B-ie)/Y,he=(B+1+ie)/Y,ne={features:[]};return this._addTileFeatures($.range((L-ie)/Y,fe,(L+1+ie)/Y,he),$.data,L,B,Y,ne),L===0&&this._addTileFeatures($.range(1-ie/Y,fe,1,he),$.data,Y,B,Y,ne),L===Y-1&&this._addTileFeatures($.range(0,fe,ie/Y,he),$.data,-1,B,Y,ne),ne.features.length?ne:null}getClusterExpansionZoom(D){let L=this._getOriginZoom(D)-1;for(;L<=this.options.maxZoom;){const B=this.getChildren(D);if(L++,B.length!==1)break;D=B[0].properties.cluster_id}return L}_appendLeaves(D,L,B,$,Y){const re=this.getChildren(L);for(const le of re){const ie=le.properties;if(ie&&ie.cluster?Y+ie.point_count<=$?Y+=ie.point_count:Y=this._appendLeaves(D,ie.cluster_id,B,$,Y):Y<$?Y++:D.push(le),D.length===B)break}return Y}_createTree(D){const L=new z.az(D.length/this.stride|0,this.options.nodeSize,Float32Array);for(let B=0;B<D.length;B+=this.stride)L.add(D[B],D[B+1]);return L.finish(),L.data=D,L}_addTileFeatures(D,L,B,$,Y,re){for(const le of D){const ie=le*this.stride,fe=L[ie+ei]>1;let he,ne,te;if(fe)he=xr(L,ie,this.clusterProps),ne=L[ie],te=L[ie+1];else{const je=this.points[L[ie+Si]];he=je.properties;const[Ue,ge]=je.geometry.coordinates;ne=jr(Ue),te=Nr(ge)}const Ie={type:1,geometry:[[Math.round(this.options.extent*(ne*Y-B)),Math.round(this.options.extent*(te*Y-$))]],tags:he};let Me;Me=fe||this.options.generateId?L[ie+Si]:this.points[L[ie+Si]].id,Me!==void 0&&(Ie.id=Me),re.features.push(Ie)}}_limitZoom(D){return Math.max(this.options.minZoom,Math.min(Math.floor(+D),this.options.maxZoom+1))}_cluster(D,L){const{radius:B,extent:$,reduce:Y,minPoints:re}=this.options,le=B/($*Math.pow(2,L)),ie=D.data,fe=[],he=this.stride;for(let ne=0;ne<ie.length;ne+=he){if(ie[ne+2]<=L)continue;ie[ne+2]=L;const te=ie[ne],Ie=ie[ne+1],Me=D.within(ie[ne],ie[ne+1],le),je=ie[ne+ei];let Ue=je;for(const ge of Me){const Ce=ge*he;ie[Ce+2]>L&&(Ue+=ie[Ce+ei])}if(Ue>je&&Ue>=re){let ge,Ce=te*je,De=Ie*je,qe=-1;const Je=((ne/he|0)<<5)+(L+1)+this.points.length;for(const Ve of Me){const ze=Ve*he;if(ie[ze+2]<=L)continue;ie[ze+2]=L;const St=ie[ze+ei];Ce+=ie[ze]*St,De+=ie[ze+1]*St,ie[ze+4]=Je,Y&&(ge||(ge=this._map(ie,ne,!0),qe=this.clusterProps.length,this.clusterProps.push(ge)),Y(ge,this._map(ie,ze)))}ie[ne+4]=Je,fe.push(Ce/Ue,De/Ue,1/0,Je,-1,Ue),Y&&fe.push(qe)}else{for(let ge=0;ge<he;ge++)fe.push(ie[ne+ge]);if(Ue>1)for(const ge of Me){const Ce=ge*he;if(!(ie[Ce+2]<=L)){ie[Ce+2]=L;for(let De=0;De<he;De++)fe.push(ie[Ce+De])}}}}return fe}_getOriginId(D){return D-this.points.length>>5}_getOriginZoom(D){return(D-this.points.length)%32}_map(D,L,B){if(D[L+ei]>1){const re=this.clusterProps[D[L+Kn]];return B?Object.assign({},re):re}const $=this.points[D[L+Si]].properties,Y=this.options.map($);return B&&Y===$?Object.assign({},Y):Y}}function yn(j,D,L){return{type:"Feature",id:j[D+Si],properties:xr(j,D,L),geometry:{type:"Point",coordinates:[(B=j[D],360*(B-.5)),xn(j[D+1])]}};var B}function xr(j,D,L){const B=j[D+ei],$=B>=1e4?`${Math.round(B/1e3)}k`:B>=1e3?Math.round(B/100)/10+"k":B,Y=j[D+Kn],re=Y===-1?{}:Object.assign({},L[Y]);return Object.assign(re,{cluster:!0,cluster_id:j[D+Si],point_count:B,point_count_abbreviated:$})}function jr(j){return j/360+.5}function Nr(j){const D=Math.sin(j*Math.PI/180),L=.5-.25*Math.log((1+D)/(1-D))/Math.PI;return L<0?0:L>1?1:L}function xn(j){const D=(180-360*j)*Math.PI/180;return 360*Math.atan(Math.exp(D))/Math.PI-90}function $i(j,D,L,B){let $=B;const Y=D+(L-D>>1);let re,le=L-D;const ie=j[D],fe=j[D+1],he=j[L],ne=j[L+1];for(let te=D+3;te<L;te+=3){const Ie=Li(j[te],j[te+1],ie,fe,he,ne);if(Ie>$)re=te,$=Ie;else if(Ie===$){const Me=Math.abs(te-Y);Me<le&&(re=te,le=Me)}}$>B&&(re-D>3&&$i(j,D,re,B),j[re+2]=$,L-re>3&&$i(j,re,L,B))}function Li(j,D,L,B,$,Y){let re=$-L,le=Y-B;if(re!==0||le!==0){const ie=((j-L)*re+(D-B)*le)/(re*re+le*le);ie>1?(L=$,B=Y):ie>0&&(L+=re*ie,B+=le*ie)}return re=j-L,le=D-B,re*re+le*le}function Ii(j,D,L,B){const $={id:j??null,type:D,geometry:L,tags:B,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(D==="Point"||D==="MultiPoint"||D==="LineString")Wt($,L);else if(D==="Polygon")Wt($,L[0]);else if(D==="MultiLineString")for(const Y of L)Wt($,Y);else if(D==="MultiPolygon")for(const Y of L)Wt($,Y[0]);return $}function Wt(j,D){for(let L=0;L<D.length;L+=3)j.minX=Math.min(j.minX,D[L]),j.minY=Math.min(j.minY,D[L+1]),j.maxX=Math.max(j.maxX,D[L]),j.maxY=Math.max(j.maxY,D[L+1])}function Vr(j,D,L,B){if(!D.geometry)return;const $=D.geometry.coordinates;if($&&$.length===0)return;const Y=D.geometry.type,re=Math.pow(L.tolerance/((1<<L.maxZoom)*L.extent),2);let le=[],ie=D.id;if(L.promoteId?ie=D.properties[L.promoteId]:L.generateId&&(ie=B||0),Y==="Point")Ur($,le);else if(Y==="MultiPoint")for(const fe of $)Ur(fe,le);else if(Y==="LineString")Zr($,le,re,!1);else if(Y==="MultiLineString"){if(L.lineMetrics){for(const fe of $)le=[],Zr(fe,le,re,!1),j.push(Ii(ie,"LineString",le,D.properties));return}fi($,le,re,!1)}else if(Y==="Polygon")fi($,le,re,!0);else{if(Y!=="MultiPolygon"){if(Y==="GeometryCollection"){for(const fe of D.geometry.geometries)Vr(j,{id:ie,geometry:fe,properties:D.properties},L,B);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const fe of $){const he=[];fi(fe,he,re,!0),le.push(he)}}j.push(Ii(ie,Y,le,D.properties))}function Ur(j,D){D.push(Yn(j[0]),ti(j[1]),0)}function Zr(j,D,L,B){let $,Y,re=0;for(let ie=0;ie<j.length;ie++){const fe=Yn(j[ie][0]),he=ti(j[ie][1]);D.push(fe,he,0),ie>0&&(re+=B?($*he-fe*Y)/2:Math.sqrt(Math.pow(fe-$,2)+Math.pow(he-Y,2))),$=fe,Y=he}const le=D.length-3;D[2]=1,$i(D,0,le,L),D[le+2]=1,D.size=Math.abs(re),D.start=0,D.end=D.size}function fi(j,D,L,B){for(let $=0;$<j.length;$++){const Y=[];Zr(j[$],Y,L,B),D.push(Y)}}function Yn(j){return j/360+.5}function ti(j){const D=Math.sin(j*Math.PI/180),L=.5-.25*Math.log((1+D)/(1-D))/Math.PI;return L<0?0:L>1?1:L}function Ot(j,D,L,B,$,Y,re,le){if(B/=D,Y>=(L/=D)&&re<B)return j;if(re<L||Y>=B)return null;const ie=[];for(const fe of j){const he=fe.geometry;let ne=fe.type;const te=$===0?fe.minX:fe.minY,Ie=$===0?fe.maxX:fe.maxY;if(te>=L&&Ie<B){ie.push(fe);continue}if(Ie<L||te>=B)continue;let Me=[];if(ne==="Point"||ne==="MultiPoint")Qi(he,Me,L,B,$);else if(ne==="LineString")zt(he,Me,L,B,$,!1,le.lineMetrics);else if(ne==="MultiLineString")$r(he,Me,L,B,$,!1);else if(ne==="Polygon")$r(he,Me,L,B,$,!0);else if(ne==="MultiPolygon")for(const je of he){const Ue=[];$r(je,Ue,L,B,$,!0),Ue.length&&Me.push(Ue)}if(Me.length){if(le.lineMetrics&&ne==="LineString"){for(const je of Me)ie.push(Ii(fe.id,ne,je,fe.tags));continue}ne!=="LineString"&&ne!=="MultiLineString"||(Me.length===1?(ne="LineString",Me=Me[0]):ne="MultiLineString"),ne!=="Point"&&ne!=="MultiPoint"||(ne=Me.length===3?"Point":"MultiPoint"),ie.push(Ii(fe.id,ne,Me,fe.tags))}}return ie.length?ie:null}function Qi(j,D,L,B,$){for(let Y=0;Y<j.length;Y+=3){const re=j[Y+$];re>=L&&re<=B&&Bi(D,j[Y],j[Y+1],j[Y+2])}}function zt(j,D,L,B,$,Y,re){let le=Gr(j);const ie=$===0?vr:br;let fe,he,ne=j.start;for(let Ue=0;Ue<j.length-3;Ue+=3){const ge=j[Ue],Ce=j[Ue+1],De=j[Ue+2],qe=j[Ue+3],Je=j[Ue+4],Ve=$===0?ge:Ce,ze=$===0?qe:Je;let St=!1;re&&(fe=Math.sqrt(Math.pow(ge-qe,2)+Math.pow(Ce-Je,2))),Ve<L?ze>L&&(he=ie(le,ge,Ce,qe,Je,L),re&&(le.start=ne+fe*he)):Ve>B?ze<B&&(he=ie(le,ge,Ce,qe,Je,B),re&&(le.start=ne+fe*he)):Bi(le,ge,Ce,De),ze<L&&Ve>=L&&(he=ie(le,ge,Ce,qe,Je,L),St=!0),ze>B&&Ve<=B&&(he=ie(le,ge,Ce,qe,Je,B),St=!0),!Y&&St&&(re&&(le.end=ne+fe*he),D.push(le),le=Gr(j)),re&&(ne+=fe)}let te=j.length-3;const Ie=j[te],Me=j[te+1],je=$===0?Ie:Me;je>=L&&je<=B&&Bi(le,Ie,Me,j[te+2]),te=le.length-3,Y&&te>=3&&(le[te]!==le[0]||le[te+1]!==le[1])&&Bi(le,le[0],le[1],le[2]),le.length&&D.push(le)}function Gr(j){const D=[];return D.size=j.size,D.start=j.start,D.end=j.end,D}function $r(j,D,L,B,$,Y){for(const re of j)zt(re,D,L,B,$,Y,!1)}function Bi(j,D,L,B){j.push(D,L,B)}function vr(j,D,L,B,$,Y){const re=(Y-D)/(B-D);return Bi(j,Y,L+($-L)*re,1),re}function br(j,D,L,B,$,Y){const re=(Y-L)/($-L);return Bi(j,D+(B-D)*re,Y,1),re}function mi(j,D){const L=[];for(let B=0;B<j.length;B++){const $=j[B],Y=$.type;let re;if(Y==="Point"||Y==="MultiPoint"||Y==="LineString")re=qr($.geometry,D);else if(Y==="MultiLineString"||Y==="Polygon"){re=[];for(const le of $.geometry)re.push(qr(le,D))}else if(Y==="MultiPolygon"){re=[];for(const le of $.geometry){const ie=[];for(const fe of le)ie.push(qr(fe,D));re.push(ie)}}L.push(Ii($.id,Y,re,$.tags))}return L}function qr(j,D){const L=[];L.size=j.size,j.start!==void 0&&(L.start=j.start,L.end=j.end);for(let B=0;B<j.length;B+=3)L.push(j[B]+D,j[B+1],j[B+2]);return L}function Hr(j,D){if(j.transformed)return j;const L=1<<j.z,B=j.x,$=j.y;for(const Y of j.features){const re=Y.geometry,le=Y.type;if(Y.geometry=[],le===1)for(let ie=0;ie<re.length;ie+=2)Y.geometry.push(wr(re[ie],re[ie+1],D,L,B,$));else for(let ie=0;ie<re.length;ie++){const fe=[];for(let he=0;he<re[ie].length;he+=2)fe.push(wr(re[ie][he],re[ie][he+1],D,L,B,$));Y.geometry.push(fe)}}return j.transformed=!0,j}function wr(j,D,L,B,$,Y){return[Math.round(L*(j*B-$)),Math.round(L*(D*B-Y))]}function Jn(j,D,L,B,$){const Y=D===$.maxZoom?0:$.tolerance/((1<<D)*$.extent),re={features:[],numPoints:0,numSimplified:0,numFeatures:j.length,source:null,x:L,y:B,z:D,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const le of j)Xr(re,le,Y,$);return re}function Xr(j,D,L,B){const $=D.geometry,Y=D.type,re=[];if(j.minX=Math.min(j.minX,D.minX),j.minY=Math.min(j.minY,D.minY),j.maxX=Math.max(j.maxX,D.maxX),j.maxY=Math.max(j.maxY,D.maxY),Y==="Point"||Y==="MultiPoint")for(let le=0;le<$.length;le+=3)re.push($[le],$[le+1]),j.numPoints++,j.numSimplified++;else if(Y==="LineString")er(re,$,j,L,!1,!1);else if(Y==="MultiLineString"||Y==="Polygon")for(let le=0;le<$.length;le++)er(re,$[le],j,L,Y==="Polygon",le===0);else if(Y==="MultiPolygon")for(let le=0;le<$.length;le++){const ie=$[le];for(let fe=0;fe<ie.length;fe++)er(re,ie[fe],j,L,!0,fe===0)}if(re.length){let le=D.tags||null;if(Y==="LineString"&&B.lineMetrics){le={};for(const fe in D.tags)le[fe]=D.tags[fe];le.mapbox_clip_start=$.start/$.size,le.mapbox_clip_end=$.end/$.size}const ie={geometry:re,type:Y==="Polygon"||Y==="MultiPolygon"?3:Y==="LineString"||Y==="MultiLineString"?2:1,tags:le};D.id!==null&&(ie.id=D.id),j.features.push(ie)}}function er(j,D,L,B,$,Y){const re=B*B;if(B>0&&D.size<($?re:B))return void(L.numPoints+=D.length/3);const le=[];for(let ie=0;ie<D.length;ie+=3)(B===0||D[ie+2]>re)&&(L.numSimplified++,le.push(D[ie],D[ie+1])),L.numPoints++;$&&function(ie,fe){let he=0;for(let ne=0,te=ie.length,Ie=te-2;ne<te;Ie=ne,ne+=2)he+=(ie[ne]-ie[Ie])*(ie[ne+1]+ie[Ie+1]);if(he>0===fe)for(let ne=0,te=ie.length;ne<te/2;ne+=2){const Ie=ie[ne],Me=ie[ne+1];ie[ne]=ie[te-2-ne],ie[ne+1]=ie[te-1-ne],ie[te-2-ne]=Ie,ie[te-1-ne]=Me}}(le,Y),j.push(le)}const Wr={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class tr{constructor(D,L){const B=(L=this.options=function(Y,re){for(const le in re)Y[le]=re[le];return Y}(Object.create(Wr),L)).debug;if(B&&console.time("preprocess data"),L.maxZoom<0||L.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(L.promoteId&&L.generateId)throw new Error("promoteId and generateId cannot be used together.");let $=function(Y,re){const le=[];if(Y.type==="FeatureCollection")for(let ie=0;ie<Y.features.length;ie++)Vr(le,Y.features[ie],re,ie);else Vr(le,Y.type==="Feature"?Y:{geometry:Y},re);return le}(D,L);this.tiles={},this.tileCoords=[],B&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",L.indexMaxZoom,L.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),$=function(Y,re){const le=re.buffer/re.extent;let ie=Y;const fe=Ot(Y,1,-1-le,le,0,-1,2,re),he=Ot(Y,1,1-le,2+le,0,-1,2,re);return(fe||he)&&(ie=Ot(Y,1,-le,1+le,0,-1,2,re)||[],fe&&(ie=mi(fe,1).concat(ie)),he&&(ie=ie.concat(mi(he,-1)))),ie}($,L),$.length&&this.splitTile($,0,0,0),B&&($.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(D,L,B,$,Y,re,le){const ie=[D,L,B,$],fe=this.options,he=fe.debug;for(;ie.length;){$=ie.pop(),B=ie.pop(),L=ie.pop(),D=ie.pop();const ne=1<<L,te=Kr(L,B,$);let Ie=this.tiles[te];if(!Ie&&(he>1&&console.time("creation"),Ie=this.tiles[te]=Jn(D,L,B,$,fe),this.tileCoords.push({z:L,x:B,y:$}),he)){he>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",L,B,$,Ie.numFeatures,Ie.numPoints,Ie.numSimplified),console.timeEnd("creation"));const St=`z${L}`;this.stats[St]=(this.stats[St]||0)+1,this.total++}if(Ie.source=D,Y==null){if(L===fe.indexMaxZoom||Ie.numPoints<=fe.indexMaxPoints)continue}else{if(L===fe.maxZoom||L===Y)continue;if(Y!=null){const St=Y-L;if(B!==re>>St||$!==le>>St)continue}}if(Ie.source=null,D.length===0)continue;he>1&&console.time("clipping");const Me=.5*fe.buffer/fe.extent,je=.5-Me,Ue=.5+Me,ge=1+Me;let Ce=null,De=null,qe=null,Je=null,Ve=Ot(D,ne,B-Me,B+Ue,0,Ie.minX,Ie.maxX,fe),ze=Ot(D,ne,B+je,B+ge,0,Ie.minX,Ie.maxX,fe);D=null,Ve&&(Ce=Ot(Ve,ne,$-Me,$+Ue,1,Ie.minY,Ie.maxY,fe),De=Ot(Ve,ne,$+je,$+ge,1,Ie.minY,Ie.maxY,fe),Ve=null),ze&&(qe=Ot(ze,ne,$-Me,$+Ue,1,Ie.minY,Ie.maxY,fe),Je=Ot(ze,ne,$+je,$+ge,1,Ie.minY,Ie.maxY,fe),ze=null),he>1&&console.timeEnd("clipping"),ie.push(Ce||[],L+1,2*B,2*$),ie.push(De||[],L+1,2*B,2*$+1),ie.push(qe||[],L+1,2*B+1,2*$),ie.push(Je||[],L+1,2*B+1,2*$+1)}}getTile(D,L,B){D=+D,L=+L,B=+B;const $=this.options,{extent:Y,debug:re}=$;if(D<0||D>24)return null;const le=1<<D,ie=Kr(D,L=L+le&le-1,B);if(this.tiles[ie])return Hr(this.tiles[ie],Y);re>1&&console.log("drilling down to z%d-%d-%d",D,L,B);let fe,he=D,ne=L,te=B;for(;!fe&&he>0;)he--,ne>>=1,te>>=1,fe=this.tiles[Kr(he,ne,te)];return fe&&fe.source?(re>1&&(console.log("found parent tile z%d-%d-%d",he,ne,te),console.time("drilling down")),this.splitTile(fe.source,he,ne,te,D,L,B),re>1&&console.timeEnd("drilling down"),this.tiles[ie]?Hr(this.tiles[ie],Y):null):null}}function Kr(j,D,L){return 32*((1<<j)*L+D)+j}function Tr(j,D){return D?j.properties[D]:j.id}function vn(j,D){if(j==null)return!0;if(j.type==="Feature")return Tr(j,D)!=null;if(j.type==="FeatureCollection"){const L=new Set;for(const B of j.features){const $=Tr(B,D);if($==null||L.has($))return!1;L.add($)}return!0}return!1}function bn(j,D){const L=new Map;if(j!=null)if(j.type==="Feature")L.set(Tr(j,D),j);else for(const B of j.features)L.set(Tr(B,D),B);return L}class Qn extends mr{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(D,L){return z._(this,void 0,void 0,function*(){const B=D.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const $=this._geoJSONIndex.getTile(B.z,B.x,B.y);if(!$)return null;const Y=new Xn($.features);let re=Wn(Y);return re.byteOffset===0&&re.byteLength===re.buffer.byteLength||(re=new Uint8Array(re)),{vectorTile:Y,rawData:re.buffer}})}loadData(D){return z._(this,void 0,void 0,function*(){var L;(L=this._pendingRequest)===null||L===void 0||L.abort();const B=!!(D&&D.request&&D.request.collectResourceTiming)&&new z.cu(D.request);this._pendingRequest=new AbortController;try{this._pendingData=this.loadAndProcessGeoJSON(D,this._pendingRequest),this._geoJSONIndex=D.cluster?new rt(function({superclusterOptions:re,clusterProperties:le}){if(!le||!re)return re;const ie={},fe={},he={accumulated:null,zoom:0},ne={properties:null},te=Object.keys(le);for(const Ie of te){const[Me,je]=le[Ie],Ue=z.cB(je),ge=z.cB(typeof Me=="string"?[Me,["accumulated"],["get",Ie]]:Me);ie[Ie]=Ue.value,fe[Ie]=ge.value}return re.map=Ie=>{ne.properties=Ie;const Me={};for(const je of te)Me[je]=ie[je].evaluate(he,ne);return Me},re.reduce=(Ie,Me)=>{ne.properties=Me;for(const je of te)he.accumulated=Ie[je],Ie[je]=fe[je].evaluate(he,ne)},re}(D)).load((yield this._pendingData).features):($=yield this._pendingData,new tr($,D.geojsonVtOptions)),this.loaded={};const Y={};if(B){const re=B.finish();re&&(Y.resourceTiming={},Y.resourceTiming[D.source]=JSON.parse(JSON.stringify(re)))}return Y}catch(Y){if(delete this._pendingRequest,z.cf(Y))return{abandoned:!0};throw Y}var $})}getData(){return z._(this,void 0,void 0,function*(){return this._pendingData})}reloadTile(D){const L=this.loaded;return L&&L[D.uid]?super.reloadTile(D):this.loadTile(D)}loadAndProcessGeoJSON(D,L){return z._(this,void 0,void 0,function*(){let B=yield this.loadGeoJSON(D,L);if(delete this._pendingRequest,typeof B!="object")throw new Error(`Input data given to '${D.source}' is not a valid GeoJSON object.`);if(_r(B,!0),D.filter){const $=z.cB(D.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if($.result==="error")throw new Error($.value.map(re=>`${re.key}: ${re.message}`).join(", "));B={type:"FeatureCollection",features:B.features.filter(re=>$.value.evaluate({zoom:0},re))}}return B})}loadGeoJSON(D,L){return z._(this,void 0,void 0,function*(){const{promoteId:B}=D;if(D.request){const $=yield z.h(D.request,L);return this._dataUpdateable=vn($.data,B)?bn($.data,B):void 0,$.data}if(typeof D.data=="string")try{const $=JSON.parse(D.data);return this._dataUpdateable=vn($,B)?bn($,B):void 0,$}catch{throw new Error(`Input data given to '${D.source}' is not a valid GeoJSON object.`)}if(!D.dataDiff)throw new Error(`Input data given to '${D.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${D.source}`);return function($,Y,re){var le,ie,fe,he;if(Y.removeAll&&$.clear(),Y.remove)for(const ne of Y.remove)$.delete(ne);if(Y.add)for(const ne of Y.add){const te=Tr(ne,re);te!=null&&$.set(te,ne)}if(Y.update)for(const ne of Y.update){let te=$.get(ne.id);if(te==null)continue;const Ie=!ne.removeAllProperties&&(((le=ne.removeProperties)===null||le===void 0?void 0:le.length)>0||((ie=ne.addOrUpdateProperties)===null||ie===void 0?void 0:ie.length)>0);if((ne.newGeometry||ne.removeAllProperties||Ie)&&(te=Object.assign({},te),$.set(ne.id,te),Ie&&(te.properties=Object.assign({},te.properties))),ne.newGeometry&&(te.geometry=ne.newGeometry),ne.removeAllProperties)te.properties={};else if(((fe=ne.removeProperties)===null||fe===void 0?void 0:fe.length)>0)for(const Me of ne.removeProperties)Object.prototype.hasOwnProperty.call(te.properties,Me)&&delete te.properties[Me];if(((he=ne.addOrUpdateProperties)===null||he===void 0?void 0:he.length)>0)for(const{key:Me,value:je}of ne.addOrUpdateProperties)te.properties[Me]=je}}(this._dataUpdateable,D.dataDiff,B),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}})}removeSource(D){return z._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(D){return this._geoJSONIndex.getClusterExpansionZoom(D.clusterId)}getClusterChildren(D){return this._geoJSONIndex.getChildren(D.clusterId)}getClusterLeaves(D){return this._geoJSONIndex.getLeaves(D.clusterId,D.limit,D.offset)}}class Pr{constructor(D){this.self=D,this.actor=new z.F(D),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(L,B)=>{if(this.externalWorkerSourceTypes[L])throw new Error(`Worker source with name "${L}" already registered.`);this.externalWorkerSourceTypes[L]=B},this.self.addProtocol=z.ch,this.self.removeProtocol=z.ci,this.self.registerRTLTextPlugin=L=>{z.cC.setMethods(L)},this.actor.registerMessageHandler("LDT",(L,B)=>this._getDEMWorkerSource(L,B.source).loadTile(B)),this.actor.registerMessageHandler("RDT",(L,B)=>z._(this,void 0,void 0,function*(){this._getDEMWorkerSource(L,B.source).removeTile(B)})),this.actor.registerMessageHandler("GCEZ",(L,B)=>z._(this,void 0,void 0,function*(){return this._getWorkerSource(L,B.type,B.source).getClusterExpansionZoom(B)})),this.actor.registerMessageHandler("GCC",(L,B)=>z._(this,void 0,void 0,function*(){return this._getWorkerSource(L,B.type,B.source).getClusterChildren(B)})),this.actor.registerMessageHandler("GCL",(L,B)=>z._(this,void 0,void 0,function*(){return this._getWorkerSource(L,B.type,B.source).getClusterLeaves(B)})),this.actor.registerMessageHandler("LD",(L,B)=>this._getWorkerSource(L,B.type,B.source).loadData(B)),this.actor.registerMessageHandler("GD",(L,B)=>this._getWorkerSource(L,B.type,B.source).getData()),this.actor.registerMessageHandler("LT",(L,B)=>this._getWorkerSource(L,B.type,B.source).loadTile(B)),this.actor.registerMessageHandler("RT",(L,B)=>this._getWorkerSource(L,B.type,B.source).reloadTile(B)),this.actor.registerMessageHandler("AT",(L,B)=>this._getWorkerSource(L,B.type,B.source).abortTile(B)),this.actor.registerMessageHandler("RMT",(L,B)=>this._getWorkerSource(L,B.type,B.source).removeTile(B)),this.actor.registerMessageHandler("RS",(L,B)=>z._(this,void 0,void 0,function*(){if(!this.workerSources[L]||!this.workerSources[L][B.type]||!this.workerSources[L][B.type][B.source])return;const $=this.workerSources[L][B.type][B.source];delete this.workerSources[L][B.type][B.source],$.removeSource!==void 0&&$.removeSource(B)})),this.actor.registerMessageHandler("RM",L=>z._(this,void 0,void 0,function*(){delete this.layerIndexes[L],delete this.availableImages[L],delete this.workerSources[L],delete this.demWorkerSources[L]})),this.actor.registerMessageHandler("SR",(L,B)=>z._(this,void 0,void 0,function*(){this.referrer=B})),this.actor.registerMessageHandler("SRPS",(L,B)=>this._syncRTLPluginState(L,B)),this.actor.registerMessageHandler("IS",(L,B)=>z._(this,void 0,void 0,function*(){this.self.importScripts(B)})),this.actor.registerMessageHandler("SI",(L,B)=>this._setImages(L,B)),this.actor.registerMessageHandler("UL",(L,B)=>z._(this,void 0,void 0,function*(){this._getLayerIndex(L).update(B.layers,B.removedIds)})),this.actor.registerMessageHandler("SL",(L,B)=>z._(this,void 0,void 0,function*(){this._getLayerIndex(L).replace(B)}))}_setImages(D,L){return z._(this,void 0,void 0,function*(){this.availableImages[D]=L;for(const B in this.workerSources[D]){const $=this.workerSources[D][B];for(const Y in $)$[Y].availableImages=L}})}_syncRTLPluginState(D,L){return z._(this,void 0,void 0,function*(){return yield z.cC.syncState(L,this.self.importScripts)})}_getAvailableImages(D){let L=this.availableImages[D];return L||(L=[]),L}_getLayerIndex(D){let L=this.layerIndexes[D];return L||(L=this.layerIndexes[D]=new c),L}_getWorkerSource(D,L,B){if(this.workerSources[D]||(this.workerSources[D]={}),this.workerSources[D][L]||(this.workerSources[D][L]={}),!this.workerSources[D][L][B]){const $={sendAsync:(Y,re)=>(Y.targetMapId=D,this.actor.sendAsync(Y,re))};switch(L){case"vector":this.workerSources[D][L][B]=new mr($,this._getLayerIndex(D),this._getAvailableImages(D));break;case"geojson":this.workerSources[D][L][B]=new Qn($,this._getLayerIndex(D),this._getAvailableImages(D));break;default:this.workerSources[D][L][B]=new this.externalWorkerSourceTypes[L]($,this._getLayerIndex(D),this._getAvailableImages(D))}}return this.workerSources[D][L][B]}_getDEMWorkerSource(D,L){return this.demWorkerSources[D]||(this.demWorkerSources[D]={}),this.demWorkerSources[D][L]||(this.demWorkerSources[D][L]=new Ze),this.demWorkerSources[D][L]}}return z.i(self)&&(self.worker=new Pr(self)),Pr}),Lr("index",["exports","./shared"],function(z,c){var Pi="5.1.0";function fr(){var h=new c.A(4);return c.A!=Float32Array&&(h[1]=0,h[2]=0),h[0]=1,h[3]=1,h}let Mi,mr;const Ze={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(h,e,i){const a=requestAnimationFrame(e);h.signal.addEventListener("abort",()=>{cancelAnimationFrame(a),i(c.c())})},frameAsync(h){return new Promise((e,i)=>{this.frame(h,e,i)})},getImageData(h,e=0){return this.getImageCanvasContext(h).getImageData(-e,-e,h.width+2*e,h.height+2*e)},getImageCanvasContext(h){const e=window.document.createElement("canvas"),i=e.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return e.width=h.width,e.height=h.height,i.drawImage(h,0,0,h.width,h.height),i},resolveURL:h=>(Mi||(Mi=document.createElement("a")),Mi.href=h,Mi.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(mr==null&&(mr=matchMedia("(prefers-reduced-motion: reduce)")),mr.matches)}};class ue{static testProp(e){if(!ue.docStyle)return e[0];for(let i=0;i<e.length;i++)if(e[i]in ue.docStyle)return e[i];return e[0]}static create(e,i,a){const o=window.document.createElement(e);return i!==void 0&&(o.className=i),a&&a.appendChild(o),o}static createNS(e,i){return window.document.createElementNS(e,i)}static disableDrag(){ue.docStyle&&ue.selectProp&&(ue.userSelect=ue.docStyle[ue.selectProp],ue.docStyle[ue.selectProp]="none")}static enableDrag(){ue.docStyle&&ue.selectProp&&(ue.docStyle[ue.selectProp]=ue.userSelect)}static setTransform(e,i){e.style[ue.transformProp]=i}static addEventListener(e,i,a,o={}){e.addEventListener(i,a,"passive"in o?o:o.capture)}static removeEventListener(e,i,a,o={}){e.removeEventListener(i,a,"passive"in o?o:o.capture)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",ue.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",ue.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",ue.suppressClickInternal,!0)},0)}static getScale(e){const i=e.getBoundingClientRect();return{x:i.width/e.offsetWidth||1,y:i.height/e.offsetHeight||1,boundingClientRect:i}}static getPoint(e,i,a){const o=i.boundingClientRect;return new c.P((a.clientX-o.left)/i.x-e.clientLeft,(a.clientY-o.top)/i.y-e.clientTop)}static mousePos(e,i){const a=ue.getScale(e);return ue.getPoint(e,a,i)}static touchPos(e,i){const a=[],o=ue.getScale(e);for(let u=0;u<i.length;u++)a.push(ue.getPoint(e,o,i[u]));return a}static mouseButton(e){return e.button}static remove(e){e.parentNode&&e.parentNode.removeChild(e)}static sanitize(e){const i=new DOMParser().parseFromString(e,"text/html").body||document.createElement("body"),a=i.querySelectorAll("script");for(const o of a)o.remove();return ue.clean(i),i.innerHTML}static isPossiblyDangerous(e,i){const a=i.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(e)||!a.includes("javascript:")&&!a.includes("data:"))||!!e.startsWith("on")||void 0}static clean(e){const i=e.children;for(const a of i)ue.removeAttributes(a),ue.clean(a)}static removeAttributes(e){for(const{name:i,value:a}of e.attributes)ue.isPossiblyDangerous(i,a)&&e.removeAttribute(i)}}ue.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,ue.selectProp=ue.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),ue.transformProp=ue.testProp(["transform","WebkitTransform"]);const Oe={supported:!1,testSupport:function(h){!Fr&&_r&&(Or?Xn(h):Br=h)}};let Br,_r,Fr=!1,Or=!1;function Xn(h){const e=h.createTexture();h.bindTexture(h.TEXTURE_2D,e);try{if(h.texImage2D(h.TEXTURE_2D,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,_r),h.isContextLost())return;Oe.supported=!0}catch{}h.deleteTexture(e),Fr=!0}var oi;typeof document<"u"&&(_r=document.createElement("img"),_r.onload=()=>{Br&&Xn(Br),Br=null,Or=!0},_r.onerror=()=>{Fr=!0,Br=null},_r.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(h){let e,i,a,o;h.resetRequestQueue=()=>{e=[],i=0,a=0,o={}},h.addThrottleControl=y=>{const v=a++;return o[v]=y,v},h.removeThrottleControl=y=>{delete o[y],f()},h.getImage=(y,v,T=!0)=>new Promise((P,S)=>{Oe.supported&&(y.headers||(y.headers={}),y.headers.accept="image/webp,*/*"),c.e(y,{type:"image"}),e.push({abortController:v,requestParameters:y,supportImageRefresh:T,state:"queued",onError:A=>{S(A)},onSuccess:A=>{P(A)}}),f()});const u=y=>c._(this,void 0,void 0,function*(){y.state="running";const{requestParameters:v,supportImageRefresh:T,onError:P,onSuccess:S,abortController:A}=y,R=T===!1&&!c.i(self)&&!c.g(v.url)&&(!v.headers||Object.keys(v.headers).reduce((U,G)=>U&&G==="accept",!0));i++;const V=R?_(v,A):c.m(v,A);try{const U=yield V;delete y.abortController,y.state="completed",U.data instanceof HTMLImageElement||c.b(U.data)?S(U):U.data&&S({data:yield(N=U.data,typeof createImageBitmap=="function"?c.d(N):c.f(N)),cacheControl:U.cacheControl,expires:U.expires})}catch(U){delete y.abortController,P(U)}finally{i--,f()}var N}),f=()=>{const y=(()=>{for(const v of Object.keys(o))if(o[v]())return!0;return!1})()?c.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:c.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let v=i;v<y&&e.length>0;v++){const T=e.shift();T.abortController.signal.aborted?v--:u(T)}},_=(y,v)=>new Promise((T,P)=>{const S=new Image,A=y.url,R=y.credentials;R&&R==="include"?S.crossOrigin="use-credentials":(R&&R==="same-origin"||!c.s(A))&&(S.crossOrigin="anonymous"),v.signal.addEventListener("abort",()=>{S.src="",P(c.c())}),S.fetchPriority="high",S.onload=()=>{S.onerror=S.onload=null,T({data:S})},S.onerror=()=>{S.onerror=S.onload=null,v.signal.aborted||P(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."))},S.src=A})}(oi||(oi={})),oi.resetRequestQueue();class gr{constructor(e){this._transformRequestFn=e}transformRequest(e,i){return this._transformRequestFn&&this._transformRequestFn(e,i)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function Mt(h){const e=[];if(typeof h=="string")e.push({id:"default",url:h});else if(h&&h.length>0){const i=[];for(const{id:a,url:o}of h){const u=`${a}${o}`;i.indexOf(u)===-1&&(i.push(u),e.push({id:a,url:o}))}}return e}function ft(h,e,i){try{const a=new URL(h);return a.pathname+=`${e}${i}`,a.toString()}catch{throw new Error(`Invalid sprite URL "${h}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}class Ct{constructor(e,i,a,o){this.context=e,this.format=a,this.texture=e.gl.createTexture(),this.update(i,o)}update(e,i,a){const{width:o,height:u}=e,f=!(this.size&&this.size[0]===o&&this.size[1]===u||a),{context:_}=this,{gl:y}=_;if(this.useMipmap=!!(i&&i.useMipmap),y.bindTexture(y.TEXTURE_2D,this.texture),_.pixelStoreUnpackFlipY.set(!1),_.pixelStoreUnpack.set(1),_.pixelStoreUnpackPremultiplyAlpha.set(this.format===y.RGBA&&(!i||i.premultiply!==!1)),f)this.size=[o,u],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||c.b(e)?y.texImage2D(y.TEXTURE_2D,0,this.format,this.format,y.UNSIGNED_BYTE,e):y.texImage2D(y.TEXTURE_2D,0,this.format,o,u,0,this.format,y.UNSIGNED_BYTE,e.data);else{const{x:v,y:T}=a||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||c.b(e)?y.texSubImage2D(y.TEXTURE_2D,0,v,T,y.RGBA,y.UNSIGNED_BYTE,e):y.texSubImage2D(y.TEXTURE_2D,0,v,T,o,u,y.RGBA,y.UNSIGNED_BYTE,e.data)}this.useMipmap&&this.isSizePowerOfTwo()&&y.generateMipmap(y.TEXTURE_2D)}bind(e,i,a){const{context:o}=this,{gl:u}=o;u.bindTexture(u.TEXTURE_2D,this.texture),a!==u.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(a=u.LINEAR),e!==this.filter&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,e),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,a||e),this.filter=e),i!==this.wrap&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,i),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,i),this.wrap=i)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}function Wn(h){const{userImage:e}=h;return!!(e&&e.render&&e.render())&&(h.data.replace(new Uint8Array(e.data.buffer)),!0)}class Rs extends c.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new c.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:i,promiseResolve:a}of this.requestors)a(this._getImagesForIds(i));this.requestors=[]}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const a=i.spriteData;i.data=new c.R({width:a.width,height:a.height},a.context.getImageData(a.x,a.y,a.width,a.height).data),i.spriteData=null}return i}addImage(e,i){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,i)&&(this.images[e]=i)}_validate(e,i){let a=!0;const o=i.data||i.spriteData;return this._validateStretch(i.stretchX,o&&o.width)||(this.fire(new c.j(new Error(`Image "${e}" has invalid "stretchX" value`))),a=!1),this._validateStretch(i.stretchY,o&&o.height)||(this.fire(new c.j(new Error(`Image "${e}" has invalid "stretchY" value`))),a=!1),this._validateContent(i.content,i)||(this.fire(new c.j(new Error(`Image "${e}" has invalid "content" value`))),a=!1),a}_validateStretch(e,i){if(!e)return!0;let a=0;for(const o of e){if(o[0]<a||o[1]<o[0]||i<o[1])return!1;a=o[1]}return!0}_validateContent(e,i){if(!e)return!0;if(e.length!==4)return!1;const a=i.spriteData,o=a&&a.width||i.data.width,u=a&&a.height||i.data.height;return!(e[0]<0||o<e[0]||e[1]<0||u<e[1]||e[2]<0||o<e[2]||e[3]<0||u<e[3]||e[2]<e[0]||e[3]<e[1])}updateImage(e,i,a=!0){const o=this.getImage(e);if(a&&(o.data.width!==i.data.width||o.data.height!==i.data.height))throw new Error(`size mismatch between old image (${o.data.width}x${o.data.height}) and new image (${i.data.width}x${i.data.height}).`);i.version=o.version+1,this.images[e]=i,this.updatedImages[e]=!0}removeImage(e){const i=this.images[e];delete this.images[e],delete this.patterns[e],i.userImage&&i.userImage.onRemove&&i.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(e){return new Promise((i,a)=>{let o=!0;if(!this.isLoaded())for(const u of e)this.images[u]||(o=!1);this.isLoaded()||o?i(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:i})})}_getImagesForIds(e){const i={};for(const a of e){let o=this.getImage(a);o||(this.fire(new c.k("styleimagemissing",{id:a})),o=this.getImage(a)),o?i[a]={data:o.data.clone(),pixelRatio:o.pixelRatio,sdf:o.sdf,version:o.version,stretchX:o.stretchX,stretchY:o.stretchY,content:o.content,textFitWidth:o.textFitWidth,textFitHeight:o.textFitHeight,hasRenderCallback:!!(o.userImage&&o.userImage.render)}:c.w(`Image "${a}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return i}getPixelSize(){const{width:e,height:i}=this.atlasImage;return{width:e,height:i}}getPattern(e){const i=this.patterns[e],a=this.getImage(e);if(!a)return null;if(i&&i.position.version===a.version)return i.position;if(i)i.position.version=a.version;else{const o={w:a.data.width+2,h:a.data.height+2,x:0,y:0},u=new c.I(o,a);this.patterns[e]={bin:o,position:u}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const i=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new Ct(e,this.atlasImage,i.RGBA),this.atlasTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const u in this.patterns)e.push(this.patterns[u].bin);const{w:i,h:a}=c.p(e),o=this.atlasImage;o.resize({width:i||1,height:a||1});for(const u in this.patterns){const{bin:f}=this.patterns[u],_=f.x+1,y=f.y+1,v=this.getImage(u).data,T=v.width,P=v.height;c.R.copy(v,o,{x:0,y:0},{x:_,y},{width:T,height:P}),c.R.copy(v,o,{x:0,y:P-1},{x:_,y:y-1},{width:T,height:1}),c.R.copy(v,o,{x:0,y:0},{x:_,y:y+P},{width:T,height:1}),c.R.copy(v,o,{x:T-1,y:0},{x:_-1,y},{width:1,height:P}),c.R.copy(v,o,{x:0,y:0},{x:_+T,y},{width:1,height:P})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const a=this.getImage(i);a||c.w(`Image with ID: "${i}" was not found`),Wn(a)&&this.updateImage(i,a)}}}const yr=1e20;function Ji(h,e,i,a,o,u,f,_,y){for(let v=e;v<e+a;v++)Si(h,i*u+v,u,o,f,_,y);for(let v=i;v<i+o;v++)Si(h,v*u+e,1,a,f,_,y)}function Si(h,e,i,a,o,u,f){u[0]=0,f[0]=-1e20,f[1]=yr,o[0]=h[e];for(let _=1,y=0,v=0;_<a;_++){o[_]=h[e+_*i];const T=_*_;do{const P=u[y];v=(o[_]-o[P]+T-P*P)/(_-P)/2}while(v<=f[y]&&--y>-1);y++,u[y]=_,f[y]=v,f[y+1]=yr}for(let _=0,y=0;_<a;_++){for(;f[y+1]<_;)y++;const v=u[y],T=_-v;h[e+_*i]=o[v]+T*T}}class ei{constructor(e,i){this.requestManager=e,this.localIdeographFontFamily=i,this.entries={}}setURL(e){this.url=e}getGlyphs(e){return c._(this,void 0,void 0,function*(){const i=[];for(const u in e)for(const f of e[u])i.push(this._getAndCacheGlyphsPromise(u,f));const a=yield Promise.all(i),o={};for(const{stack:u,id:f,glyph:_}of a)o[u]||(o[u]={}),o[u][f]=_&&{id:_.id,bitmap:_.bitmap.clone(),metrics:_.metrics};return o})}_getAndCacheGlyphsPromise(e,i){return c._(this,void 0,void 0,function*(){let a=this.entries[e];a||(a=this.entries[e]={glyphs:{},requests:{},ranges:{}});let o=a.glyphs[i];if(o!==void 0)return{stack:e,id:i,glyph:o};if(o=this._tinySDF(a,e,i),o)return a.glyphs[i]=o,{stack:e,id:i,glyph:o};const u=Math.floor(i/256);if(256*u>65535)throw new Error("glyphs > 65535 not supported");if(a.ranges[u])return{stack:e,id:i,glyph:o};if(!this.url)throw new Error("glyphsUrl is not set");if(!a.requests[u]){const _=ei.loadGlyphRange(e,u,this.url,this.requestManager);a.requests[u]=_}const f=yield a.requests[u];for(const _ in f)this._doesCharSupportLocalGlyph(+_)||(a.glyphs[+_]=f[+_]);return a.ranges[u]=!0,{stack:e,id:i,glyph:f[i]||null}})}_doesCharSupportLocalGlyph(e){return!!this.localIdeographFontFamily&&new RegExp("\\p{Ideo}|\\p{sc=Hang}|\\p{sc=Hira}|\\p{sc=Kana}","u").test(String.fromCodePoint(e))}_tinySDF(e,i,a){const o=this.localIdeographFontFamily;if(!o||!this._doesCharSupportLocalGlyph(a))return;let u=e.tinySDF;if(!u){let _="400";/bold/i.test(i)?_="900":/medium/i.test(i)?_="500":/light/i.test(i)&&(_="200"),u=e.tinySDF=new ei.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:o,fontWeight:_})}const f=u.draw(String.fromCharCode(a));return{id:a,bitmap:new c.o({width:f.width||60,height:f.height||60},f.data),metrics:{width:f.glyphWidth/2||24,height:f.glyphHeight/2||24,left:f.glyphLeft/2+.5||0,top:f.glyphTop/2-27.5||-8,advance:f.glyphAdvance/2||24,isDoubleResolution:!0}}}}ei.loadGlyphRange=function(h,e,i,a){return c._(this,void 0,void 0,function*(){const o=256*e,u=o+255,f=a.transformRequest(i.replace("{fontstack}",h).replace("{range}",`${o}-${u}`),"Glyphs"),_=yield c.l(f,new AbortController);if(!_||!_.data)throw new Error(`Could not load glyph range. range: ${e}, ${o}-${u}`);const y={};for(const v of c.n(_.data))y[v.id]=v;return y})},ei.TinySDF=class{constructor({fontSize:h=24,buffer:e=3,radius:i=8,cutoff:a=.25,fontFamily:o="sans-serif",fontWeight:u="normal",fontStyle:f="normal"}={}){this.buffer=e,this.cutoff=a,this.radius=i;const _=this.size=h+4*e,y=this._createCanvas(_),v=this.ctx=y.getContext("2d",{willReadFrequently:!0});v.font=`${f} ${u} ${h}px ${o}`,v.textBaseline="alphabetic",v.textAlign="left",v.fillStyle="black",this.gridOuter=new Float64Array(_*_),this.gridInner=new Float64Array(_*_),this.f=new Float64Array(_),this.z=new Float64Array(_+1),this.v=new Uint16Array(_)}_createCanvas(h){const e=document.createElement("canvas");return e.width=e.height=h,e}draw(h){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:a,actualBoundingBoxLeft:o,actualBoundingBoxRight:u}=this.ctx.measureText(h),f=Math.ceil(i),_=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(u-o))),y=Math.min(this.size-this.buffer,f+Math.ceil(a)),v=_+2*this.buffer,T=y+2*this.buffer,P=Math.max(v*T,0),S=new Uint8ClampedArray(P),A={data:S,width:v,height:T,glyphWidth:_,glyphHeight:y,glyphTop:f,glyphLeft:0,glyphAdvance:e};if(_===0||y===0)return A;const{ctx:R,buffer:V,gridInner:N,gridOuter:U}=this;R.clearRect(V,V,_,y),R.fillText(h,V,V+f);const G=R.getImageData(V,V,_,y);U.fill(yr,0,P),N.fill(0,0,P);for(let X=0;X<y;X++)for(let W=0;W<_;W++){const K=G.data[4*(X*_+W)+3]/255;if(K===0)continue;const Q=(X+V)*v+W+V;if(K===1)U[Q]=0,N[Q]=yr;else{const J=.5-K;U[Q]=J>0?J*J:0,N[Q]=J<0?J*J:0}}Ji(U,0,0,v,T,v,this.f,this.v,this.z),Ji(N,V,V,_,y,v,this.f,this.v,this.z);for(let X=0;X<P;X++){const W=Math.sqrt(U[X])-Math.sqrt(N[X]);S[X]=Math.round(255-255*(W/this.radius+this.cutoff))}return A}};class Kn{constructor(){this.specification=c.v.light.position}possiblyEvaluate(e,i){return c.x(e.expression.evaluate(i))}interpolate(e,i,a){return{x:c.y.number(e.x,i.x,a),y:c.y.number(e.y,i.y,a),z:c.y.number(e.z,i.z,a)}}}let rt;class yn extends c.E{constructor(e){super(),rt=rt||new c.q({anchor:new c.D(c.v.light.anchor),position:new Kn,color:new c.D(c.v.light.color),intensity:new c.D(c.v.light.intensity)}),this._transitionable=new c.T(rt),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,i={}){if(!this._validate(c.r,e,i))for(const a in e){const o=e[a];a.endsWith("-transition")?this._transitionable.setTransition(a.slice(0,-11),o):this._transitionable.setValue(a,o)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,i,a){return(!a||a.validate!==!1)&&c.t(this,e.call(c.u,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:c.v}))}}const xr=new c.q({"sky-color":new c.D(c.v.sky["sky-color"]),"horizon-color":new c.D(c.v.sky["horizon-color"]),"fog-color":new c.D(c.v.sky["fog-color"]),"fog-ground-blend":new c.D(c.v.sky["fog-ground-blend"]),"horizon-fog-blend":new c.D(c.v.sky["horizon-fog-blend"]),"sky-horizon-blend":new c.D(c.v.sky["sky-horizon-blend"]),"atmosphere-blend":new c.D(c.v.sky["atmosphere-blend"])});class jr extends c.E{constructor(e){super(),this._transitionable=new c.T(xr),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new c.z(0))}setSky(e,i={}){if(!this._validate(c.B,e,i)){e||(e={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const a in e){const o=e[a];a.endsWith("-transition")?this._transitionable.setTransition(a.slice(0,-11),o):this._transitionable.setValue(a,o)}}}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,i,a={}){return(a==null?void 0:a.validate)!==!1&&c.t(this,e.call(c.u,c.e({value:i,style:{glyphs:!0,sprite:!0},styleSpec:c.v})))}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}}class Nr{constructor(e,i){this.width=e,this.height=i,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(e,i){const a=e.join(",")+String(i);return this.dashEntry[a]||(this.dashEntry[a]=this.addDash(e,i)),this.dashEntry[a]}getDashRanges(e,i,a){const o=[];let u=e.length%2==1?-e[e.length-1]*a:0,f=e[0]*a,_=!0;o.push({left:u,right:f,isDash:_,zeroLength:e[0]===0});let y=e[0];for(let v=1;v<e.length;v++){_=!_;const T=e[v];u=y*a,y+=T,f=y*a,o.push({left:u,right:f,isDash:_,zeroLength:T===0})}return o}addRoundDash(e,i,a){const o=i/2;for(let u=-a;u<=a;u++){const f=this.width*(this.nextRow+a+u);let _=0,y=e[_];for(let v=0;v<this.width;v++){v/y.right>1&&(y=e[++_]);const T=Math.abs(v-y.left),P=Math.abs(v-y.right),S=Math.min(T,P);let A;const R=u/a*(o+1);if(y.isDash){const V=o-Math.abs(R);A=Math.sqrt(S*S+V*V)}else A=o-Math.sqrt(S*S+R*R);this.data[f+v]=Math.max(0,Math.min(255,A+128))}}}addRegularDash(e){for(let _=e.length-1;_>=0;--_){const y=e[_],v=e[_+1];y.zeroLength?e.splice(_,1):v&&v.isDash===y.isDash&&(v.left=y.left,e.splice(_,1))}const i=e[0],a=e[e.length-1];i.isDash===a.isDash&&(i.left=a.left-this.width,a.right=i.right+this.width);const o=this.width*this.nextRow;let u=0,f=e[u];for(let _=0;_<this.width;_++){_/f.right>1&&(f=e[++u]);const y=Math.abs(_-f.left),v=Math.abs(_-f.right),T=Math.min(y,v);this.data[o+_]=Math.max(0,Math.min(255,(f.isDash?T:-T)+128))}}addDash(e,i){const a=i?7:0,o=2*a+1;if(this.nextRow+o>this.height)return c.w("LineAtlas out of space"),null;let u=0;for(let _=0;_<e.length;_++)u+=e[_];if(u!==0){const _=this.width/u,y=this.getDashRanges(e,this.width,_);i?this.addRoundDash(y,_,a):this.addRegularDash(y)}const f={y:(this.nextRow+a+.5)/this.height,height:2*a/this.height,width:u};return this.nextRow+=o,this.dirty=!0,f}bind(e){const i=e.gl;this.texture?(i.bindTexture(i.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,i.texSubImage2D(i.TEXTURE_2D,0,0,0,this.width,this.height,i.ALPHA,i.UNSIGNED_BYTE,this.data))):(this.texture=i.createTexture(),i.bindTexture(i.TEXTURE_2D,this.texture),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.REPEAT),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.REPEAT),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.ALPHA,this.width,this.height,0,i.ALPHA,i.UNSIGNED_BYTE,this.data))}}const xn="maplibre_preloaded_worker_pool";class $i{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<$i.workerCount;)this.workers.push(new Worker(c.a.WORKER_URL));return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],this.numActive()===0&&(this.workers.forEach(i=>{i.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[xn]}numActive(){return Object.keys(this.active).length}}const Li=Math.floor(Ze.hardwareConcurrency/2);let Ii,Wt;function Vr(){return Ii||(Ii=new $i),Ii}$i.workerCount=c.C(globalThis)?Math.max(Math.min(Li,3),1):1;class Ur{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=i;const a=this.workerPool.acquire(i);for(let o=0;o<a.length;o++){const u=new c.F(a[o],i);u.name=`Worker ${o}`,this.actors.push(u)}if(!this.actors.length)throw new Error("No actors found")}broadcast(e,i){const a=[];for(const o of this.actors)a.push(o.sendAsync({type:e,data:i}));return Promise.all(a)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){this.actors.forEach(i=>{i.remove()}),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,i){for(const a of this.actors)a.registerMessageHandler(e,i)}}function Zr(){return Wt||(Wt=new Ur(Vr(),c.G),Wt.registerMessageHandler("GR",(h,e,i)=>c.m(e,i))),Wt}function fi(h,e){const i=c.H();return c.J(i,i,[1,1,0]),c.K(i,i,[.5*h.width,.5*h.height,1]),h.calculatePosMatrix?c.L(i,i,h.calculatePosMatrix(e.toUnwrapped())):i}function Yn(h,e,i,a,o,u){var f;const _=function(P,S,A){if(P)for(const R of P){const V=S[R];if(V&&V.source===A&&V.type==="fill-extrusion")return!0}else for(const R in S){const V=S[R];if(V.source===A&&V.type==="fill-extrusion")return!0}return!1}((f=o==null?void 0:o.layers)!==null&&f!==void 0?f:null,e,h.id),y=u.maxPitchScaleFactor(),v=h.tilesIn(a,y,_);v.sort(ti);const T=[];for(const P of v)T.push({wrappedTileID:P.tileID.wrapped().key,queryResults:P.tile.queryRenderedFeatures(e,i,h._state,P.queryGeometry,P.cameraQueryGeometry,P.scale,o,u,y,fi(h.transform,P.tileID))});return function(P,S){for(const A in P)for(const R of P[A])Ot(R,S);return P}(function(P){const S={},A={};for(const R of P){const V=R.queryResults,N=R.wrappedTileID,U=A[N]=A[N]||{};for(const G in V){const X=V[G],W=U[G]=U[G]||{},K=S[G]=S[G]||[];for(const Q of X)W[Q.featureIndex]||(W[Q.featureIndex]=!0,K.push(Q))}}return S}(T),h)}function ti(h,e){const i=h.tileID,a=e.tileID;return i.overscaledZ-a.overscaledZ||i.canonical.y-a.canonical.y||i.wrap-a.wrap||i.canonical.x-a.canonical.x}function Ot(h,e){const i=h.feature,a=e.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=a}function Qi(h,e,i){return c._(this,void 0,void 0,function*(){let a=h;if(h.url?a=(yield c.h(e.transformRequest(h.url,"Source"),i)).data:yield Ze.frameAsync(i),!a)return null;const o=c.M(c.e(a,h),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in a&&a.vector_layers&&(o.vectorLayerIds=a.vector_layers.map(u=>u.id)),o})}class zt{constructor(e,i){e&&(i?this.setSouthWest(e).setNorthEast(i):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 c.N?new c.N(e.lng,e.lat):c.N.convert(e),this}setSouthWest(e){return this._sw=e instanceof c.N?new c.N(e.lng,e.lat):c.N.convert(e),this}extend(e){const i=this._sw,a=this._ne;let o,u;if(e instanceof c.N)o=e,u=e;else{if(!(e instanceof zt))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(zt.convert(e)):this.extend(c.N.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(c.N.convert(e)):this;if(o=e._sw,u=e._ne,!o||!u)return this}return i||a?(i.lng=Math.min(o.lng,i.lng),i.lat=Math.min(o.lat,i.lat),a.lng=Math.max(u.lng,a.lng),a.lat=Math.max(u.lat,a.lat)):(this._sw=new c.N(o.lng,o.lat),this._ne=new c.N(u.lng,u.lat)),this}getCenter(){return new c.N((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new c.N(this.getWest(),this.getNorth())}getSouthEast(){return new c.N(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:i,lat:a}=c.N.convert(e);let o=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=a&&a<=this._ne.lat&&o}static convert(e){return e instanceof zt?e:e&&new zt(e)}static fromLngLat(e,i=0){const a=360*i/40075017,o=a/Math.cos(Math.PI/180*e.lat);return new zt(new c.N(e.lng-o,e.lat-a),new c.N(e.lng+o,e.lat+a))}adjustAntiMeridian(){const e=new c.N(this._sw.lng,this._sw.lat),i=new c.N(this._ne.lng,this._ne.lat);return new zt(e,e.lng>i.lng?new c.N(i.lng+360,i.lat):i)}}class Gr{constructor(e,i,a){this.bounds=zt.convert(this.validateBounds(e)),this.minzoom=i||0,this.maxzoom=a||24}validateBounds(e){return Array.isArray(e)&&e.length===4?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),a=Math.floor(c.O(this.bounds.getWest())*i),o=Math.floor(c.Q(this.bounds.getNorth())*i),u=Math.ceil(c.O(this.bounds.getEast())*i),f=Math.ceil(c.Q(this.bounds.getSouth())*i);return e.x>=a&&e.x<u&&e.y>=o&&e.y<f}}class $r extends c.E{constructor(e,i,a,o){if(super(),this.id=e,this.dispatcher=a,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,c.e(this,c.M(i,["url","scheme","tileSize","promoteId"])),this._options=c.e({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(o)}load(){return c._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new c.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const e=yield Qi(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),e&&(c.e(this,e),e.bounds&&(this.tileBounds=new Gr(e.bounds,this.minzoom,this.maxzoom)),this.fire(new c.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new c.k("data",{dataType:"source",sourceDataType:"content"})))}catch(e){this._tileJSONRequest=null,this.fire(new c.j(e))}})}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.abort(),e(),this.load()}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return c.e({},this._options)}loadTile(e){return c._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a={request:this.map._requestManager.transformRequest(i,"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};a.request.collectResourceTiming=this._collectResourceTiming;let o="RT";if(e.actor&&e.state!=="expired"){if(e.state==="loading")return new Promise((u,f)=>{e.reloadPromise={resolve:u,reject:f}})}else e.actor=this.dispatcher.getActor(),o="LT";e.abortController=new AbortController;try{const u=yield e.actor.sendAsync({type:o,data:a},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,u)}catch(u){if(delete e.abortController,e.aborted)return;if(u&&u.status!==404)throw u;this._afterTileLoadWorkerResponse(e,null)}})}_afterTileLoadWorkerResponse(e,i){if(i&&i.resourceTiming&&(e.resourceTiming=i.resourceTiming),i&&this.map._refreshExpiredTiles&&e.setExpiryData(i),e.loadVectorData(i,this.map.painter),e.reloadPromise){const a=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(a.resolve).catch(a.reject)}}abortTile(e){return c._(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 c._(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 Bi extends c.E{constructor(e,i,a,o){super(),this.id=e,this.dispatcher=a,this.setEventedParent(o),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=c.e({type:"raster"},i),c.e(this,c.M(i,["url","scheme","tileSize"]))}load(){return c._(this,arguments,void 0,function*(e=!1){this._loaded=!1,this.fire(new c.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield Qi(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,i&&(c.e(this,i),i.bounds&&(this.tileBounds=new Gr(i.bounds,this.minzoom,this.maxzoom)),this.fire(new c.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new c.k("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(i){this._tileJSONRequest=null,this.fire(new c.j(i))}})}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 c.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return c._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const a=yield oi.getImage(this.map._requestManager.transformRequest(i,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(a&&a.data){this.map._refreshExpiredTiles&&a.cacheControl&&a.expires&&e.setExpiryData({cacheControl:a.cacheControl,expires:a.expires});const o=this.map.painter.context,u=o.gl,f=a.data;e.texture=this.map.painter.getTileTexture(f.width),e.texture?e.texture.update(f,{useMipmap:!0}):(e.texture=new Ct(o,f,u.RGBA,{useMipmap:!0}),e.texture.bind(u.LINEAR,u.CLAMP_TO_EDGE,u.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(a){if(delete e.abortController,e.aborted)e.state="unloaded";else if(a)throw e.state="errored",a}})}abortTile(e){return c._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)})}unloadTile(e){return c._(this,void 0,void 0,function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)})}hasTransition(){return!1}}class vr extends Bi{constructor(e,i,a,o){super(e,i,a,o),this.type="raster-dem",this.maxzoom=22,this._options=c.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift}loadTile(e){return c._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a=this.map._requestManager.transformRequest(i,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const o=yield oi.getImage(a,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(o&&o.data){const u=o.data;this.map._refreshExpiredTiles&&o.cacheControl&&o.expires&&e.setExpiryData({cacheControl:o.cacheControl,expires:o.expires});const f=c.b(u)&&c.U()?u:yield this.readImageNow(u),_={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||e.state==="expired"){e.actor=this.dispatcher.getActor();const y=yield e.actor.sendAsync({type:"LDT",data:_});e.dem=y,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(o){if(delete e.abortController,e.aborted)e.state="unloaded";else if(o)throw e.state="errored",o}})}readImageNow(e){return c._(this,void 0,void 0,function*(){if(typeof VideoFrame<"u"&&c.V()){const i=e.width+2,a=e.height+2;try{return new c.R({width:i,height:a},yield c.W(e,-1,-1,i,a))}catch{}}return Ze.getImageData(e,1)})}_getNeighboringTiles(e){const i=e.canonical,a=Math.pow(2,i.z),o=(i.x-1+a)%a,u=i.x===0?e.wrap-1:e.wrap,f=(i.x+1+a)%a,_=i.x+1===a?e.wrap+1:e.wrap,y={};return y[new c.S(e.overscaledZ,u,i.z,o,i.y).key]={backfilled:!1},y[new c.S(e.overscaledZ,_,i.z,f,i.y).key]={backfilled:!1},i.y>0&&(y[new c.S(e.overscaledZ,u,i.z,o,i.y-1).key]={backfilled:!1},y[new c.S(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},y[new c.S(e.overscaledZ,_,i.z,f,i.y-1).key]={backfilled:!1}),i.y+1<a&&(y[new c.S(e.overscaledZ,u,i.z,o,i.y+1).key]={backfilled:!1},y[new c.S(e.overscaledZ,e.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},y[new c.S(e.overscaledZ,_,i.z,f,i.y+1).key]={backfilled:!1}),y}unloadTile(e){return c._(this,void 0,void 0,function*(){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded",e.actor&&(yield e.actor.sendAsync({type:"RDT",data:{type:this.type,uid:e.uid,source:this.id}}))})}}class br extends c.E{constructor(e,i,a,o){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._pendingLoads=0,this.actor=a.getActor(),this.setEventedParent(o),this._data=i.data,this._options=c.e({},i),this._collectResourceTiming=i.collectResourceTiming,i.maxzoom!==void 0&&(this.maxzoom=i.maxzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId,i.clusterMaxZoom!==void 0&&this.maxzoom<=i.clusterMaxZoom&&c.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${i.clusterMaxZoom}".`),this.workerOptions=c.e({source:this.id,cluster:i.cluster||!1,geojsonVtOptions:{buffer:this._pixelsToTileUnits(i.buffer!==void 0?i.buffer:128),tolerance:this._pixelsToTileUnits(i.tolerance!==void 0?i.tolerance:.375),extent:c.X,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1},superclusterOptions:{maxZoom:i.clusterMaxZoom!==void 0?i.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,i.clusterMinPoints||2),extent:c.X,radius:this._pixelsToTileUnits(i.clusterRadius||50),log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter},i.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}_pixelsToTileUnits(e){return e*(c.X/this.tileSize)}load(){return c._(this,void 0,void 0,function*(){yield this._updateWorkerData()})}onAdd(e){this.map=e,this.load()}setData(e){return this._data=e,this._updateWorkerData(),this}updateData(e){return this._updateWorkerData(e),this}getData(){return c._(this,void 0,void 0,function*(){const e=c.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:e})})}setClusterOptions(e){return this.workerOptions.cluster=e.cluster,e&&(e.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),e.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=e.clusterMaxZoom)),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,i,a){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:i,offset:a}})}_updateWorkerData(e){return c._(this,void 0,void 0,function*(){const i=c.e({type:this.type},this.workerOptions);e?i.dataDiff=e:typeof this._data=="string"?(i.request=this.map._requestManager.transformRequest(Ze.resolveURL(this._data),"Source"),i.request.collectResourceTiming=this._collectResourceTiming):i.data=JSON.stringify(this._data),this._pendingLoads++,this.fire(new c.k("dataloading",{dataType:"source"}));try{const a=yield this.actor.sendAsync({type:"LD",data:i});if(this._pendingLoads--,this._removed||a.abandoned)return void this.fire(new c.k("dataabort",{dataType:"source"}));let o=null;a.resourceTiming&&a.resourceTiming[this.id]&&(o=a.resourceTiming[this.id].slice(0));const u={dataType:"source"};this._collectResourceTiming&&o&&o.length>0&&c.e(u,{resourceTiming:o}),this.fire(new c.k("data",Object.assign(Object.assign({},u),{sourceDataType:"metadata"}))),this.fire(new c.k("data",Object.assign(Object.assign({},u),{sourceDataType:"content"})))}catch(a){if(this._pendingLoads--,this._removed)return void this.fire(new c.k("dataabort",{dataType:"source"}));this.fire(new c.j(a))}})}loaded(){return this._pendingLoads===0}loadTile(e){return c._(this,void 0,void 0,function*(){const i=e.actor?"RT":"LT";e.actor=this.actor;const a={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;const o=yield this.actor.sendAsync({type:i,data:a},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(o,this.map.painter,i==="RT")})}abortTile(e){return c._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0})}unloadTile(e){return c._(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 c.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}class mi extends c.E{constructor(e,i,a,o){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=a,this.coordinates=i.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=i}load(e){return c._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new c.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const i=yield oi.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,i&&i.data&&(this.image=i.data,e&&(this.coordinates=e),this._finishLoading())}catch(i){this._request=null,this._loaded=!0,this.fire(new c.j(i))}})}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 c.k("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const i=e.map(c.Y.fromLngLat);var a;return this.tileID=function(o){let u=1/0,f=1/0,_=-1/0,y=-1/0;for(const S of o)u=Math.min(u,S.x),f=Math.min(f,S.y),_=Math.max(_,S.x),y=Math.max(y,S.y);const v=Math.max(_-u,y-f),T=Math.max(0,Math.floor(-Math.log(v)/Math.LN2)),P=Math.pow(2,T);return new c.Z(T,Math.floor((u+_)/2*P),Math.floor((f+y)/2*P))}(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map(o=>this.tileID.getTilePoint(o)._round()),this.flippedWindingOrder=((a=this.tileCoords)[1].x-a[0].x)*(a[2].y-a[0].y)-(a[1].y-a[0].y)*(a[2].x-a[0].x)<0,this.fire(new c.k("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture||(this.texture=new Ct(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let a=!1;for(const o in this.tiles){const u=this.tiles[o];u.state!=="loaded"&&(u.state="loaded",u.texture=this.texture,a=!0)}a&&this.fire(new c.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return c._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class qr extends mi{constructor(e,i,a,o){super(e,i,a,o),this.roundZoom=!0,this.type="video",this.options=i}load(){return c._(this,void 0,void 0,function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const i of e.urls)this.urls.push(this.map._requestManager.transformRequest(i,"Source").url);try{const i=yield c.a0(this.urls);if(this._loaded=!0,!i)return;this.video=i,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(i){this.fire(new c.j(i))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const i=this.video.seekable;e<i.start(0)||e>i.end(0)?this.fire(new c.j(new c.$(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new Ct(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let a=!1;for(const o in this.tiles){const u=this.tiles[o];u.state!=="loaded"&&(u.state="loaded",u.texture=this.texture,a=!0)}a&&this.fire(new c.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class Hr extends mi{constructor(e,i,a,o){super(e,i,a,o),i.coordinates?Array.isArray(i.coordinates)&&i.coordinates.length===4&&!i.coordinates.some(u=>!Array.isArray(u)||u.length!==2||u.some(f=>typeof f!="number"))||this.fire(new c.j(new c.$(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new c.j(new c.$(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&typeof i.animate!="boolean"&&this.fire(new c.j(new c.$(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?typeof i.canvas=="string"||i.canvas instanceof HTMLCanvasElement||this.fire(new c.j(new c.$(`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 c.j(new c.$(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=i.animate===void 0||i.animate}load(){return c._(this,void 0,void 0,function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new c.j(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())})}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const i=this.map.painter.context,a=i.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new Ct(i,this.canvas,a.RGBA,{premultiply:!0});let o=!1;for(const u in this.tiles){const f=this.tiles[u];f.state!=="loaded"&&(f.state="loaded",f.texture=this.texture,o=!0)}o&&this.fire(new c.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"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 wr={},Jn=h=>{switch(h){case"geojson":return br;case"image":return mi;case"raster":return Bi;case"raster-dem":return vr;case"vector":return $r;case"video":return qr;case"canvas":return Hr}return wr[h]},Xr="RTLPluginLoaded";class er extends c.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=Zr()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(i=>{throw this.status="error",i})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return c._(this,arguments,void 0,function*(i,a=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=Ze.resolveURL(i),!this.url)throw new Error(`requested url ${i} is invalid`);if(this.status==="unavailable"){if(!a)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if(this.status==="requested")return this._requestImport()})}_requestImport(){return c._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new c.k(Xr))})}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let Wr=null;function tr(){return Wr||(Wr=new er),Wr}class Kr{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=c.a1(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(e){const i=e+this.timeAdded;i<this.fadeEndTime||(this.fadeEndTime=i)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,i,a){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.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(o,u){const f={};if(!u)return f;for(const _ of o){const y=_.layerIds.map(v=>u.getLayer(v)).filter(Boolean);if(y.length!==0){_.layers=y,_.stateDependentLayerIds&&(_.stateDependentLayers=_.stateDependentLayerIds.map(v=>y.filter(T=>T.id===v)[0]));for(const v of y)f[v.id]=_}}return f}(e.buckets,i==null?void 0:i.style),this.hasSymbolBuckets=!1;for(const o in this.buckets){const u=this.buckets[o];if(u instanceof c.a3){if(this.hasSymbolBuckets=!0,!a)break;u.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const o in this.buckets){const u=this.buckets[o];if(u instanceof c.a3&&u.hasRTLText){this.hasRTLText=!0,tr().lazyLoad();break}}this.queryPadding=0;for(const o in this.buckets){const u=this.buckets[o];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(o).queryRadius(u))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage)}else this.collisionBoxArray=new c.a2}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.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const a in this.buckets){const o=this.buckets[a];o.uploadPending()&&o.upload(e)}const i=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Ct(e,this.imageAtlas.image,i.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Ct(e,this.glyphAtlasImage,i.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,i,a,o,u,f,_,y,v,T){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:o,cameraQueryGeometry:u,scale:f,tileSize:this.tileSize,pixelPosMatrix:T,transform:y,params:_,queryPadding:this.queryPadding*v},e,i,a):{}}querySourceFeatures(e,i){const a=this.latestFeatureIndex;if(!a||!a.rawTileData)return;const o=a.loadVTLayers(),u=i&&i.sourceLayer?i.sourceLayer:"",f=o._geojsonTileLayer||o[u];if(!f)return;const _=c.a4(i&&i.filter),{z:y,x:v,y:T}=this.tileID.canonical,P={z:y,x:v,y:T};for(let S=0;S<f.length;S++){const A=f.feature(S);if(_.needGeometry){const N=c.a5(A,!0);if(!_.filter(new c.z(this.tileID.overscaledZ),N,this.tileID.canonical))continue}else if(!_.filter(new c.z(this.tileID.overscaledZ),A))continue;const R=a.getId(A,u),V=new c.a6(A,y,v,T,R);V.tile=P,e.push(V)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const i=this.expirationTime;if(e.cacheControl){const a=c.a7(e.cacheControl);a["max-age"]&&(this.expirationTime=Date.now()+1e3*a["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const a=Date.now();let o=!1;if(this.expirationTime>a)o=!1;else if(i)if(this.expirationTime<i)o=!0;else{const u=this.expirationTime-i;u?this.expirationTime=a+Math.max(u,3e4):o=!0}else o=!0;o?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(e,i){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(e).length===0)return;const a=this.latestFeatureIndex.loadVTLayers();for(const o in this.buckets){if(!i.style.hasLayer(o))continue;const u=this.buckets[o],f=u.layers[0].sourceLayer||"_geojsonTileLayer",_=a[f],y=e[f];if(!_||!y||Object.keys(y).length===0)continue;u.update(y,_,this.imageAtlas&&this.imageAtlas.patternPositions||{});const v=i&&i.style&&i.style.getLayer(o);v&&(this.queryPadding=Math.max(this.queryPadding,v.queryRadius(u)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Ze.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=Ze.now()+e}setDependencies(e,i){const a={};for(const o of i)a[o]=!0;this.dependencies[e]=a}hasDependency(e,i){for(const a of e){const o=this.dependencies[a];if(o){for(const u of i)if(o[u])return!0}}return!1}}class Tr{constructor(e,i){this.max=e,this.onRemove=i,this.reset()}reset(){for(const e in this.data)for(const i of this.data[e])i.timeout&&clearTimeout(i.timeout),this.onRemove(i.value);return this.data={},this.order=[],this}add(e,i,a){const o=e.wrapped().key;this.data[o]===void 0&&(this.data[o]=[]);const u={value:i,timeout:void 0};if(a!==void 0&&(u.timeout=setTimeout(()=>{this.remove(e,u)},a)),this.data[o].push(u),this.order.push(o),this.order.length>this.max){const f=this._getAndRemoveByKey(this.order[0]);f&&this.onRemove(f)}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 i=this.data[e].shift();return i.timeout&&clearTimeout(i.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),i.value}getByKey(e){const i=this.data[e];return i?i[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,i){if(!this.has(e))return this;const a=e.wrapped().key,o=i===void 0?0:this.data[a].indexOf(i),u=this.data[a][o];return this.data[a].splice(o,1),u.timeout&&clearTimeout(u.timeout),this.data[a].length===0&&delete this.data[a],this.onRemove(u.value),this.order.splice(this.order.indexOf(a),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const i=this._getAndRemoveByKey(this.order[0]);i&&this.onRemove(i)}return this}filter(e){const i=[];for(const a in this.data)for(const o of this.data[a])e(o.value)||i.push(o);for(const a of i)this.remove(a.value.tileID,a)}}class vn{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,i,a){const o=String(i);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][o]=this.stateChanges[e][o]||{},c.e(this.stateChanges[e][o],a),this.deletedStates[e]===null){this.deletedStates[e]={};for(const u in this.state[e])u!==o&&(this.deletedStates[e][u]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][o]===null){this.deletedStates[e][o]={};for(const u in this.state[e][o])a[u]||(this.deletedStates[e][o][u]=null)}else for(const u in a)this.deletedStates[e]&&this.deletedStates[e][o]&&this.deletedStates[e][o][u]===null&&delete this.deletedStates[e][o][u]}removeFeatureState(e,i,a){if(this.deletedStates[e]===null)return;const o=String(i);if(this.deletedStates[e]=this.deletedStates[e]||{},a&&i!==void 0)this.deletedStates[e][o]!==null&&(this.deletedStates[e][o]=this.deletedStates[e][o]||{},this.deletedStates[e][o][a]=null);else if(i!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][o])for(a in this.deletedStates[e][o]={},this.stateChanges[e][o])this.deletedStates[e][o][a]=null;else this.deletedStates[e][o]=null;else this.deletedStates[e]=null}getState(e,i){const a=String(i),o=c.e({},(this.state[e]||{})[a],(this.stateChanges[e]||{})[a]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){const u=this.deletedStates[e][i];if(u===null)return{};for(const f in u)delete o[f]}return o}initializeTileState(e,i){e.setFeatureState(this.state,i)}coalesceChanges(e,i){const a={};for(const o in this.stateChanges){this.state[o]=this.state[o]||{};const u={};for(const f in this.stateChanges[o])this.state[o][f]||(this.state[o][f]={}),c.e(this.state[o][f],this.stateChanges[o][f]),u[f]=this.state[o][f];a[o]=u}for(const o in this.deletedStates){this.state[o]=this.state[o]||{};const u={};if(this.deletedStates[o]===null)for(const f in this.state[o])u[f]={},this.state[o][f]={};else for(const f in this.deletedStates[o]){if(this.deletedStates[o][f]===null)this.state[o][f]={};else for(const _ of Object.keys(this.deletedStates[o][f]))delete this.state[o][f][_];u[f]=this.state[o][f]}a[o]=a[o]||{},c.e(a[o],u)}if(this.stateChanges={},this.deletedStates={},Object.keys(a).length!==0)for(const o in e)e[o].setFeatureState(a,i)}}function bn(h,e,i){const a=e.intersectsFrustum(h);if(!i)return a;const o=e.intersectsPlane(i);return a===0||o===0?0:a===2&&o===2?2:1}function Qn(h,e,i,a,o){let u=h;const f=Math.atan(e/i),_=Math.hypot(e,i);return u=h+c.a8(a/_/Math.max(.5,Math.cos(c.aa(o/2)))),u+=1*c.a8(Math.cos(f))/2,u+=c.ab(h-u,-0,0),u}function Pr(h,e){const i=(e.roundZoom?Math.round:Math.floor)(h.zoom+c.a8(h.tileSize/e.tileSize));return Math.max(0,i)}function j(h,e){const i=h.getCameraFrustum(),a=h.getClippingPlane(),o=h.screenPointToMercatorCoordinate(h.getCameraPoint()),u=c.Y.fromLngLat(h.center,h.elevation);o.z=u.z+Math.cos(h.pitchInRadians)*h.cameraToCenterDistance/h.worldSize;const f=h.getCoveringTilesDetailsProvider(),_=f.allowVariableZoom(h,e),y=Pr(h,e),v=e.minzoom||0,T=e.maxzoom!==void 0?e.maxzoom:h.maxZoom,P=Math.min(Math.max(0,y),T),S=Math.pow(2,P),A=[S*o.x,S*o.y,0],R=[S*u.x,S*u.y,0],V=Math.hypot(u.x-o.x,u.y-o.y),N=Math.abs(u.z-o.z),U=Math.hypot(V,N),G=K=>({zoom:0,x:0,y:0,wrap:K,fullyVisible:!1}),X=[],W=[];if(h.renderWorldCopies&&f.allowWorldCopies())for(let K=1;K<=3;K++)X.push(G(-K)),X.push(G(K));for(X.push(G(0));X.length>0;){const K=X.pop(),Q=K.x,J=K.y;let se=K.fullyVisible;const oe={x:Q,y:J,z:K.zoom},me=f.getTileAABB(oe,K.wrap,h.elevation,e);if(!se){const Pe=bn(i,me,a);if(Pe===0)continue;se=Pe===2}const ye=f.distanceToTile2d(o.x,o.y,oe,me);let de=y;_&&(de=(e.calculateTileZoom||Qn)(h.zoom+c.a8(h.tileSize/e.tileSize),ye,N,U,h.fov)),de=(e.roundZoom?Math.round:Math.floor)(de),de=Math.max(0,de);const Se=Math.min(de,T);if(K.wrap=f.getWrap(u,oe,K.wrap),K.zoom>=Se){if(K.zoom<v)continue;const Pe=P-K.zoom,ve=A[0]-.5-(Q<<Pe),Ee=A[1]-.5-(J<<Pe),$e=e.reparseOverscaled?Math.max(K.zoom,de):K.zoom;W.push({tileID:new c.S(K.zoom===T?$e:K.zoom,K.wrap,K.zoom,Q,J),distanceSq:c.a9([R[0]-.5-Q,R[1]-.5-J]),tileDistanceToCamera:Math.sqrt(ve*ve+Ee*Ee)})}else for(let Pe=0;Pe<4;Pe++)X.push({zoom:K.zoom+1,x:(Q<<1)+Pe%2,y:(J<<1)+(Pe>>1),wrap:K.wrap,fullyVisible:se})}return W.sort((K,Q)=>K.distanceSq-Q.distanceSq).map(K=>K.tileID)}class D extends c.E{constructor(e,i,a){super(),this.id=e,this.dispatcher=a,this.on("data",o=>this._dataHandler(o)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((o,u,f,_)=>{const y=new(Jn(u.type))(o,u,f,_);if(y.id!==o)throw new Error(`Expected Source id to be ${o} instead of ${y.id}`);return y})(e,i,a,this),this._tiles={},this._cache=new Tr(0,o=>this._unloadTile(o)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new vn,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e in this._tiles){const i=this._tiles[e];if(i.state!=="loaded"&&i.state!=="errored")return!1}return!0}getSource(){return this._source}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,i,a){return c._(this,void 0,void 0,function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,i,a)}catch(o){e.state="errored",o.status!==404?this._source.fire(new c.j(o,{tile:e})):this.update(this.transform,this.terrain)}})}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new c.k("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const i in this._tiles){const a=this._tiles[i];a.upload(e),a.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(L).map(e=>e.key)}getRenderableIds(e){const i=[];for(const a in this._tiles)this._isIdRenderable(a,e)&&i.push(this._tiles[a]);return e?i.sort((a,o)=>{const u=a.tileID,f=o.tileID,_=new c.P(u.canonical.x,u.canonical.y)._rotate(-this.transform.bearingInRadians),y=new c.P(f.canonical.x,f.canonical.y)._rotate(-this.transform.bearingInRadians);return u.overscaledZ-f.overscaledZ||y.y-_.y||y.x-_.x}).map(a=>a.tileID.key):i.map(a=>a.tileID).sort(L).map(a=>a.key)}hasRenderableParent(e){const i=this.findLoadedParent(e,0);return!!i&&this._isIdRenderable(i.tileID.key)}_isIdRenderable(e,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(i||!this._tiles[e].holdingForFade())}reload(e){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const i in this._tiles)(e||this._tiles[i].state!=="errored")&&this._reloadTile(i,"reloading")}}_reloadTile(e,i){return c._(this,void 0,void 0,function*(){const a=this._tiles[e];a&&(a.state!=="loading"&&(a.state=i),yield this._loadTile(a,e,i))})}_tileLoaded(e,i,a){e.timeAdded=Ze.now(),a==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),this.getSource().type==="raster-dem"&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new c.k("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){const i=this.getRenderableIds();for(let o=0;o<i.length;o++){const u=i[o];if(e.neighboringTiles&&e.neighboringTiles[u]){const f=this.getTileByID(u);a(e,f),a(f,e)}}function a(o,u){o.needsHillshadePrepare=!0,o.needsTerrainPrepare=!0;let f=u.tileID.canonical.x-o.tileID.canonical.x;const _=u.tileID.canonical.y-o.tileID.canonical.y,y=Math.pow(2,o.tileID.canonical.z),v=u.tileID.key;f===0&&_===0||Math.abs(_)>1||(Math.abs(f)>1&&(Math.abs(f+y)===1?f+=y:Math.abs(f-y)===1&&(f-=y)),u.dem&&o.dem&&(o.dem.backfillBorder(u.dem,f,_),o.neighboringTiles&&o.neighboringTiles[v]&&(o.neighboringTiles[v].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,i,a,o){for(const u in this._tiles){let f=this._tiles[u];if(o[u]||!f.hasData()||f.tileID.overscaledZ<=i||f.tileID.overscaledZ>a)continue;let _=f.tileID;for(;f&&f.tileID.overscaledZ>i+1;){const v=f.tileID.scaledTo(f.tileID.overscaledZ-1);f=this._tiles[v.key],f&&f.hasData()&&(_=v)}let y=_;for(;y.overscaledZ>i;)if(y=y.scaledTo(y.overscaledZ-1),e[y.key]||e[y.canonical.key]){o[_.key]=_;break}}}findLoadedParent(e,i){if(e.key in this._loadedParentTiles){const a=this._loadedParentTiles[e.key];return a&&a.tileID.overscaledZ>=i?a:null}for(let a=e.overscaledZ-1;a>=i;a--){const o=e.scaledTo(a),u=this._getLoadedTile(o);if(u)return u}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){const i=this._tiles[e.key];return i&&i.hasData()?i:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,a=Math.ceil(e.height/this._source.tileSize)+1,o=Math.floor(i*a*(this._maxTileCacheZoomLevels===null?c.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),u=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(u)}handleWrapJump(e){const i=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,i){const a={};for(const o in this._tiles){const u=this._tiles[o];u.tileID=u.tileID.unwrapTo(u.tileID.wrap+i),a[u.tileID.key]=u}this._tiles=a;for(const o in this._timers)clearTimeout(this._timers[o]),delete this._timers[o];for(const o in this._tiles)this._setTileReloadTimer(o,this._tiles[o])}}_updateCoveredAndRetainedTiles(e,i,a,o,u,f){const _={},y={},v=Object.keys(e),T=Ze.now();for(const P of v){const S=e[P],A=this._tiles[P];if(!A||A.fadeEndTime!==0&&A.fadeEndTime<=T)continue;const R=this.findLoadedParent(S,i),V=this.findLoadedSibling(S),N=R||V||null;N&&(this._addTile(N.tileID),_[N.tileID.key]=N.tileID),y[P]=S}this._retainLoadedChildren(y,o,a,e);for(const P in _)e[P]||(this._coveredTiles[P]=!0,e[P]=_[P]);if(f){const P={},S={};for(const A of u)this._tiles[A.key].hasData()?P[A.key]=A:S[A.key]=A;for(const A in S){const R=S[A].children(this._source.maxzoom);this._tiles[R[0].key]&&this._tiles[R[1].key]&&this._tiles[R[2].key]&&this._tiles[R[3].key]&&(P[R[0].key]=e[R[0].key]=R[0],P[R[1].key]=e[R[1].key]=R[1],P[R[2].key]=e[R[2].key]=R[2],P[R[3].key]=e[R[3].key]=R[3],delete S[A])}for(const A in S){const R=S[A],V=this.findLoadedParent(R,this._source.minzoom),N=this.findLoadedSibling(R),U=V||N||null;if(U){P[U.tileID.key]=e[U.tileID.key]=U.tileID;for(const G in P)P[G].isChildOf(U.tileID)&&delete P[G]}}for(const A in this._tiles)P[A]||(this._coveredTiles[A]=!0)}}update(e,i){if(!this._sourceLoaded||this._paused)return;let a;this.transform=e,this.terrain=i,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?a=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(T=>new c.S(T.canonical.z,T.wrap,T.canonical.z,T.canonical.x,T.canonical.y)):(a=j(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(a=a.filter(T=>this._source.hasTile(T)))):a=[];const o=Pr(e,this._source),u=Math.max(o-D.maxOverzooming,this._source.minzoom),f=Math.max(o+D.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const T={};for(const P of a)if(P.canonical.z>this._source.minzoom){const S=P.scaledTo(P.canonical.z-1);T[S.key]=S;const A=P.scaledTo(Math.max(this._source.minzoom,Math.min(P.canonical.z,5)));T[A.key]=A}a=a.concat(Object.values(T))}const _=a.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,_&&this.fire(new c.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const y=this._updateRetainedTiles(a,o);B(this._source.type)&&this._updateCoveredAndRetainedTiles(y,u,f,o,a,i);for(const T in y)this._tiles[T].clearFadeHold();const v=c.ac(this._tiles,y);for(const T of v){const P=this._tiles[T];P.hasSymbolBuckets&&!P.holdingForFade()?P.setHoldDuration(this.map._fadeDuration):P.hasSymbolBuckets&&!P.symbolFadeFinished()||this._removeTile(T)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e)}_updateRetainedTiles(e,i){var a;const o={},u={},f=Math.max(i-D.maxOverzooming,this._source.minzoom),_=Math.max(i+D.maxUnderzooming,this._source.minzoom),y={};for(const v of e){const T=this._addTile(v);o[v.key]=v,T.hasData()||i<this._source.maxzoom&&(y[v.key]=v)}this._retainLoadedChildren(y,i,_,o);for(const v of e){let T=this._tiles[v.key];if(T.hasData())continue;if(i+1>this._source.maxzoom){const S=v.children(this._source.maxzoom)[0],A=this.getTile(S);if(A&&A.hasData()){o[S.key]=S;continue}}else{const S=v.children(this._source.maxzoom);if(o[S[0].key]&&o[S[1].key]&&o[S[2].key]&&o[S[3].key])continue}let P=T.wasRequested();for(let S=v.overscaledZ-1;S>=f;--S){const A=v.scaledTo(S);if(u[A.key])break;if(u[A.key]=!0,T=this.getTile(A),!T&&P&&(T=this._addTile(A)),T){const R=T.hasData();if((R||!(!((a=this.map)===null||a===void 0)&&a.cancelPendingTileRequestsWhileZooming)||P)&&(o[A.key]=A),P=T.wasRequested(),R)break}}}return o}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const i=[];let a,o=this._tiles[e].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){a=this._loadedParentTiles[o.key];break}i.push(o.key);const u=o.scaledTo(o.overscaledZ-1);if(a=this._getLoadedTile(u),a)break;o=u}for(const u of i)this._loadedParentTiles[u]=a}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const e in this._tiles){const i=this._tiles[e].tileID,a=this._getLoadedTile(i);this._loadedSiblingTiles[i.key]=a}}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,i)));const a=i;return i||(i=new Kr(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,e.key,i.state)),i.uses++,this._tiles[e.key]=i,a||this._source.fire(new c.k("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,i){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const a=i.getExpiryTimeout();a&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},a))}_removeTile(e){const i=this._tiles[e];i&&(i.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),i.uses>0||(i.hasData()&&i.state!=="reloading"?this._cache.add(i.tileID,i,i.getExpiryTimeout()):(i.aborted=!0,this._abortTile(i),this._unloadTile(i))))}_dataHandler(e){const i=e.sourceDataType;e.dataType==="source"&&i==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&e.dataType==="source"&&i==="content"&&(this.reload(e.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,i,a){const o=[],u=this.transform;if(!u)return o;const f=a?u.getCameraQueryGeometry(e):e,_=e.map(R=>u.screenPointToMercatorCoordinate(R,this.terrain)),y=f.map(R=>u.screenPointToMercatorCoordinate(R,this.terrain)),v=this.getIds();let T=1/0,P=1/0,S=-1/0,A=-1/0;for(const R of y)T=Math.min(T,R.x),P=Math.min(P,R.y),S=Math.max(S,R.x),A=Math.max(A,R.y);for(let R=0;R<v.length;R++){const V=this._tiles[v[R]];if(V.holdingForFade())continue;const N=V.tileID,U=Math.pow(2,u.zoom-V.tileID.overscaledZ),G=i*V.queryPadding*c.X/V.tileSize/U,X=[N.getTilePoint(new c.Y(T,P)),N.getTilePoint(new c.Y(S,A))];if(X[0].x-G<c.X&&X[0].y-G<c.X&&X[1].x+G>=0&&X[1].y+G>=0){const W=_.map(Q=>N.getTilePoint(Q)),K=y.map(Q=>N.getTilePoint(Q));o.push({tile:V,tileID:N,queryGeometry:W,cameraQueryGeometry:K,scale:U})}}return o}getVisibleCoordinates(e){const i=this.getRenderableIds(e).map(a=>this._tiles[a].tileID);return this.transform&&this.transform.populateCache(i),i}hasTransition(){if(this._source.hasTransition())return!0;if(B(this._source.type)){const e=Ze.now();for(const i in this._tiles)if(this._tiles[i].fadeEndTime>=e)return!0}return!1}setFeatureState(e,i,a){this._state.updateState(e=e||"_geojsonTileLayer",i,a)}removeFeatureState(e,i,a){this._state.removeFeatureState(e=e||"_geojsonTileLayer",i,a)}getFeatureState(e,i){return this._state.getState(e=e||"_geojsonTileLayer",i)}setDependencies(e,i,a){const o=this._tiles[e];o&&o.setDependencies(i,a)}reloadTilesForDependencies(e,i){for(const a in this._tiles)this._tiles[a].hasDependency(e,i)&&this._reloadTile(a,"reloading");this._cache.filter(a=>!a.hasDependency(e,i))}}function L(h,e){const i=Math.abs(2*h.wrap)-+(h.wrap<0),a=Math.abs(2*e.wrap)-+(e.wrap<0);return h.overscaledZ-e.overscaledZ||a-i||e.canonical.y-h.canonical.y||e.canonical.x-h.canonical.x}function B(h){return h==="raster"||h==="image"||h==="video"}D.maxOverzooming=10,D.maxUnderzooming=3;class ${constructor(e,i){this.reset(e,i)}reset(e,i){this.points=e||[],this._distances=[0];for(let a=1;a<this.points.length;a++)this._distances[a]=this._distances[a-1]+this.points[a].dist(this.points[a-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(i||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(this.points.length===1)return this.points[0];e=c.ab(e,0,1);let i=1,a=this._distances[i];const o=e*this.paddedLength+this.padding;for(;a<o&&i<this._distances.length;)a=this._distances[++i];const u=i-1,f=this._distances[u],_=a-f,y=_>0?(o-f)/_:0;return this.points[u].mult(1-y).add(this.points[i].mult(y))}}function Y(h,e){let i=!0;return h==="always"||h!=="never"&&e!=="never"||(i=!1),i}class re{constructor(e,i,a){const o=this.boxCells=[],u=this.circleCells=[];this.xCellCount=Math.ceil(e/a),this.yCellCount=Math.ceil(i/a);for(let f=0;f<this.xCellCount*this.yCellCount;f++)o.push([]),u.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=i,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/i,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,i,a,o,u){this._forEachCell(i,a,o,u,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(i),this.bboxes.push(a),this.bboxes.push(o),this.bboxes.push(u)}insertCircle(e,i,a,o){this._forEachCell(i-o,a-o,i+o,a+o,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(i),this.circles.push(a),this.circles.push(o)}_insertBoxCell(e,i,a,o,u,f){this.boxCells[u].push(f)}_insertCircleCell(e,i,a,o,u,f){this.circleCells[u].push(f)}_query(e,i,a,o,u,f,_){if(a<0||e>this.width||o<0||i>this.height)return[];const y=[];if(e<=0&&i<=0&&this.width<=a&&this.height<=o){if(u)return[{key:null,x1:e,y1:i,x2:a,y2:o}];for(let v=0;v<this.boxKeys.length;v++)y.push({key:this.boxKeys[v],x1:this.bboxes[4*v],y1:this.bboxes[4*v+1],x2:this.bboxes[4*v+2],y2:this.bboxes[4*v+3]});for(let v=0;v<this.circleKeys.length;v++){const T=this.circles[3*v],P=this.circles[3*v+1],S=this.circles[3*v+2];y.push({key:this.circleKeys[v],x1:T-S,y1:P-S,x2:T+S,y2:P+S})}}else this._forEachCell(e,i,a,o,this._queryCell,y,{hitTest:u,overlapMode:f,seenUids:{box:{},circle:{}}},_);return y}query(e,i,a,o){return this._query(e,i,a,o,!1,null)}hitTest(e,i,a,o,u,f){return this._query(e,i,a,o,!0,u,f).length>0}hitTestCircle(e,i,a,o,u){const f=e-a,_=e+a,y=i-a,v=i+a;if(_<0||f>this.width||v<0||y>this.height)return!1;const T=[];return this._forEachCell(f,y,_,v,this._queryCellCircle,T,{hitTest:!0,overlapMode:o,circle:{x:e,y:i,radius:a},seenUids:{box:{},circle:{}}},u),T.length>0}_queryCell(e,i,a,o,u,f,_,y){const{seenUids:v,hitTest:T,overlapMode:P}=_,S=this.boxCells[u];if(S!==null){const R=this.bboxes;for(const V of S)if(!v.box[V]){v.box[V]=!0;const N=4*V,U=this.boxKeys[V];if(e<=R[N+2]&&i<=R[N+3]&&a>=R[N+0]&&o>=R[N+1]&&(!y||y(U))&&(!T||!Y(P,U.overlapMode))&&(f.push({key:U,x1:R[N],y1:R[N+1],x2:R[N+2],y2:R[N+3]}),T))return!0}}const A=this.circleCells[u];if(A!==null){const R=this.circles;for(const V of A)if(!v.circle[V]){v.circle[V]=!0;const N=3*V,U=this.circleKeys[V];if(this._circleAndRectCollide(R[N],R[N+1],R[N+2],e,i,a,o)&&(!y||y(U))&&(!T||!Y(P,U.overlapMode))){const G=R[N],X=R[N+1],W=R[N+2];if(f.push({key:U,x1:G-W,y1:X-W,x2:G+W,y2:X+W}),T)return!0}}}return!1}_queryCellCircle(e,i,a,o,u,f,_,y){const{circle:v,seenUids:T,overlapMode:P}=_,S=this.boxCells[u];if(S!==null){const R=this.bboxes;for(const V of S)if(!T.box[V]){T.box[V]=!0;const N=4*V,U=this.boxKeys[V];if(this._circleAndRectCollide(v.x,v.y,v.radius,R[N+0],R[N+1],R[N+2],R[N+3])&&(!y||y(U))&&!Y(P,U.overlapMode))return f.push(!0),!0}}const A=this.circleCells[u];if(A!==null){const R=this.circles;for(const V of A)if(!T.circle[V]){T.circle[V]=!0;const N=3*V,U=this.circleKeys[V];if(this._circlesCollide(R[N],R[N+1],R[N+2],v.x,v.y,v.radius)&&(!y||y(U))&&!Y(P,U.overlapMode))return f.push(!0),!0}}}_forEachCell(e,i,a,o,u,f,_,y){const v=this._convertToXCellCoord(e),T=this._convertToYCellCoord(i),P=this._convertToXCellCoord(a),S=this._convertToYCellCoord(o);for(let A=v;A<=P;A++)for(let R=T;R<=S;R++)if(u.call(this,e,i,a,o,this.xCellCount*R+A,f,_,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,i,a,o,u,f){const _=o-e,y=u-i,v=a+f;return v*v>_*_+y*y}_circleAndRectCollide(e,i,a,o,u,f,_){const y=(f-o)/2,v=Math.abs(e-(o+y));if(v>y+a)return!1;const T=(_-u)/2,P=Math.abs(i-(u+T));if(P>T+a)return!1;if(v<=y||P<=T)return!0;const S=v-y,A=P-T;return S*S+A*A<=a*a}}function le(h,e,i){const a=c.H();if(!h){const{vecSouth:P,vecEast:S}=fe(e),A=fr();A[0]=S[0],A[1]=S[1],A[2]=P[0],A[3]=P[1],o=A,(T=(f=(u=A)[0])*(v=u[3])-(y=u[2])*(_=u[1]))&&(o[0]=v*(T=1/T),o[1]=-_*T,o[2]=-y*T,o[3]=f*T),a[0]=A[0],a[1]=A[1],a[4]=A[2],a[5]=A[3]}var o,u,f,_,y,v,T;return c.K(a,a,[1/i,1/i,1]),a}function ie(h,e,i,a){if(h){const o=c.H();if(!e){const{vecSouth:u,vecEast:f}=fe(i);o[0]=f[0],o[1]=f[1],o[4]=u[0],o[5]=u[1]}return c.K(o,o,[a,a,1]),o}return i.pixelsToClipSpaceMatrix}function fe(h){const e=Math.cos(h.rollInRadians),i=Math.sin(h.rollInRadians),a=Math.cos(h.pitchInRadians),o=Math.cos(h.bearingInRadians),u=Math.sin(h.bearingInRadians),f=c.ad();f[0]=-o*a*i-u*e,f[1]=-u*a*i+o*e;const _=c.ae(f);_<1e-9?c.af(f):c.ag(f,f,1/_);const y=c.ad();y[0]=o*a*e-u*i,y[1]=u*a*e+o*i;const v=c.ae(y);return v<1e-9?c.af(y):c.ag(y,y,1/v),{vecEast:y,vecSouth:f}}function he(h,e,i,a){let o;a?(o=[h,e,a(h,e),1],c.al(o,o,i)):(o=[h,e,0,1],Rt(o,o,i));const u=o[3];return{point:new c.P(o[0]/u,o[1]/u),signedDistanceFromCamera:u,isOccluded:!1}}function ne(h,e){return .5+h/e*.5}function te(h,e){return h.x>=-e[0]&&h.x<=e[0]&&h.y>=-e[1]&&h.y<=e[1]}function Ie(h,e,i,a,o,u,f,_,y,v,T,P,S){const A=i?h.textSizeData:h.iconSizeData,R=c.ah(A,e.transform.zoom),V=[256/e.width*2+1,256/e.height*2+1],N=i?h.text.dynamicLayoutVertexArray:h.icon.dynamicLayoutVertexArray;N.clear();const U=h.lineVertexArray,G=i?h.text.placedSymbolArray:h.icon.placedSymbolArray,X=e.transform.width/e.transform.height;let W=!1;for(let K=0;K<G.length;K++){const Q=G.get(K);if(Q.hidden||Q.writingMode===c.ai.vertical&&!W){jt(Q.numGlyphs,N);continue}W=!1;const J=new c.P(Q.anchorX,Q.anchorY),se={getElevation:S,pitchedLabelPlaneMatrix:a,lineVertexArray:U,pitchWithMap:u,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:e.transform,tileAnchorPoint:J,unwrappedTileID:y,width:v,height:T,translation:P},oe=Je(Q.anchorX,Q.anchorY,se);if(!te(oe.point,V)){jt(Q.numGlyphs,N);continue}const me=ne(e.transform.cameraToCenterDistance,oe.signedDistanceFromCamera),ye=c.aj(A,R,Q),de=u?ye*e.transform.getPitchedTextCorrection(Q.anchorX,Q.anchorY,y)/me:ye*me,Se=Ue({projectionContext:se,pitchedLabelPlaneMatrixInverse:o,symbol:Q,fontSize:de,flip:!1,keepUpright:f,glyphOffsetArray:h.glyphOffsetArray,dynamicLayoutVertexArray:N,aspectRatio:X,rotateToLine:_});W=Se.useVertical,(Se.notEnoughRoom||W||Se.needsFlipping&&Ue({projectionContext:se,pitchedLabelPlaneMatrixInverse:o,symbol:Q,fontSize:de,flip:!0,keepUpright:f,glyphOffsetArray:h.glyphOffsetArray,dynamicLayoutVertexArray:N,aspectRatio:X,rotateToLine:_}).notEnoughRoom)&&jt(Q.numGlyphs,N)}i?h.text.dynamicLayoutVertexBuffer.updateData(N):h.icon.dynamicLayoutVertexBuffer.updateData(N)}function Me(h,e,i,a,o,u,f,_){const y=u.glyphStartIndex+u.numGlyphs,v=u.lineStartIndex,T=u.lineStartIndex+u.lineLength,P=e.getoffsetX(u.glyphStartIndex),S=e.getoffsetX(y-1),A=St(h*P,i,a,o,u.segment,v,T,_,f);if(!A)return null;const R=St(h*S,i,a,o,u.segment,v,T,_,f);return R?_.projectionCache.anyProjectionOccluded?null:{first:A,last:R}:null}function je(h,e,i,a){return h===c.ai.horizontal&&Math.abs(i.y-e.y)>Math.abs(i.x-e.x)*a?{useVertical:!0}:(h===c.ai.vertical?e.y<i.y:e.x>i.x)?{needsFlipping:!0}:null}function Ue(h){const{projectionContext:e,pitchedLabelPlaneMatrixInverse:i,symbol:a,fontSize:o,flip:u,keepUpright:f,glyphOffsetArray:_,dynamicLayoutVertexArray:y,aspectRatio:v,rotateToLine:T}=h,P=o/24,S=a.lineOffsetX*P,A=a.lineOffsetY*P;let R;if(a.numGlyphs>1){const V=a.glyphStartIndex+a.numGlyphs,N=a.lineStartIndex,U=a.lineStartIndex+a.lineLength,G=Me(P,_,S,A,u,a,T,e);if(!G)return{notEnoughRoom:!0};const X=qe(G.first.point.x,G.first.point.y,e,i),W=qe(G.last.point.x,G.last.point.y,e,i);if(f&&!u){const K=je(a.writingMode,X,W,v);if(K)return K}R=[G.first];for(let K=a.glyphStartIndex+1;K<V-1;K++)R.push(St(P*_.getoffsetX(K),S,A,u,a.segment,N,U,e,T));R.push(G.last)}else{if(f&&!u){const N=De(e.tileAnchorPoint.x,e.tileAnchorPoint.y,e).point,U=a.lineStartIndex+a.segment+1,G=new c.P(e.lineVertexArray.getx(U),e.lineVertexArray.gety(U)),X=De(G.x,G.y,e),W=X.signedDistanceFromCamera>0?X.point:ge(e.tileAnchorPoint,G,N,1,e),K=qe(N.x,N.y,e,i),Q=qe(W.x,W.y,e,i),J=je(a.writingMode,K,Q,v);if(J)return J}const V=St(P*_.getoffsetX(a.glyphStartIndex),S,A,u,a.segment,a.lineStartIndex,a.lineStartIndex+a.lineLength,e,T);if(!V||e.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};R=[V]}for(const V of R)c.ak(y,V.point,V.angle);return{}}function ge(h,e,i,a,o){const u=h.add(h.sub(e)._unit()),f=De(u.x,u.y,o).point,_=i.sub(f);return i.add(_._mult(a/_.mag()))}function Ce(h,e,i){const a=e.projectionCache;if(a.projections[h])return a.projections[h];const o=new c.P(e.lineVertexArray.getx(h),e.lineVertexArray.gety(h)),u=De(o.x,o.y,e);if(u.signedDistanceFromCamera>0)return a.projections[h]=u.point,a.anyProjectionOccluded=a.anyProjectionOccluded||u.isOccluded,u.point;const f=h-i.direction;return ge(i.distanceFromAnchor===0?e.tileAnchorPoint:new c.P(e.lineVertexArray.getx(f),e.lineVertexArray.gety(f)),o,i.previousVertex,i.absOffsetX-i.distanceFromAnchor+1,e)}function De(h,e,i){const a=h+i.translation[0],o=e+i.translation[1];let u;return i.pitchWithMap?(u=he(a,o,i.pitchedLabelPlaneMatrix,i.getElevation),u.isOccluded=!1):(u=i.transform.projectTileCoordinates(a,o,i.unwrappedTileID,i.getElevation),u.point.x=(.5*u.point.x+.5)*i.width,u.point.y=(.5*-u.point.y+.5)*i.height),u}function qe(h,e,i,a){if(i.pitchWithMap){const o=[h,e,0,1];return c.al(o,o,a),i.transform.projectTileCoordinates(o[0]/o[3],o[1]/o[3],i.unwrappedTileID,i.getElevation).point}return{x:h/i.width*2-1,y:e/i.height*2-1}}function Je(h,e,i){return i.transform.projectTileCoordinates(h,e,i.unwrappedTileID,i.getElevation)}function Ve(h,e,i){return h._unit()._perp()._mult(e*i)}function ze(h,e,i,a,o,u,f,_,y){if(_.projectionCache.offsets[h])return _.projectionCache.offsets[h];const v=i.add(e);if(h+y.direction<a||h+y.direction>=o)return _.projectionCache.offsets[h]=v,v;const T=Ce(h+y.direction,_,y),P=Ve(T.sub(i),f,y.direction),S=i.add(P),A=T.add(P);return _.projectionCache.offsets[h]=c.am(u,v,S,A)||v,_.projectionCache.offsets[h]}function St(h,e,i,a,o,u,f,_,y){const v=a?h-e:h+e;let T=v>0?1:-1,P=0;a&&(T*=-1,P=Math.PI),T<0&&(P+=Math.PI);let S,A=T>0?u+o:u+o+1;_.projectionCache.cachedAnchorPoint?S=_.projectionCache.cachedAnchorPoint:(S=De(_.tileAnchorPoint.x,_.tileAnchorPoint.y,_).point,_.projectionCache.cachedAnchorPoint=S);let R,V,N=S,U=S,G=0,X=0;const W=Math.abs(v),K=[];let Q;for(;G+X<=W;){if(A+=T,A<u||A>=f)return null;G+=X,U=N,V=R;const oe={absOffsetX:W,direction:T,distanceFromAnchor:G,previousVertex:U};if(N=Ce(A,_,oe),i===0)K.push(U),Q=N.sub(U);else{let me;const ye=N.sub(U);me=ye.mag()===0?Ve(Ce(A+T,_,oe).sub(N),i,T):Ve(ye,i,T),V||(V=U.add(me)),R=ze(A,me,N,u,f,V,i,_,oe),K.push(V),Q=R.sub(V)}X=Q.mag()}const J=Q._mult((W-G)/X)._add(V||U),se=P+Math.atan2(N.y-U.y,N.x-U.x);return K.push(J),{point:J,angle:y?se:0,path:K}}const Mr=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function jt(h,e){for(let i=0;i<h;i++){const a=e.length;e.resize(a+4),e.float32.set(Mr,3*a)}}function Rt(h,e,i){const a=e[0],o=e[1];return h[0]=i[0]*a+i[4]*o+i[12],h[1]=i[1]*a+i[5]*o+i[13],h[3]=i[3]*a+i[7]*o+i[15],h}const mt=100;class _i{constructor(e,i=new re(e.width+200,e.height+200,25),a=new re(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=a,this.pitchFactor=Math.cos(e.pitch*Math.PI/180)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+mt,this.screenBottomBoundary=e.height+mt,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,i,a,o,u,f,_,y,v,T,P,S){const A=this.projectAndGetPerspectiveRatio(e.anchorPointX+y[0],e.anchorPointY+y[1],u,T,S),R=a*A.perspectiveRatio;let V;if(f||_)V=this._projectCollisionBox(e,R,o,u,f,_,y,A,T,P,S);else{const Q=A.x+(P?P.x*R:0),J=A.y+(P?P.y*R:0);V={allPointsOccluded:!1,box:[Q+e.x1*R,J+e.y1*R,Q+e.x2*R,J+e.y2*R]}}const[N,U,G,X]=V.box,W=f?V.allPointsOccluded:A.isOccluded;let K=W;return K||(K=A.perspectiveRatio<this.perspectiveRatioCutoff),K||(K=!this.isInsideGrid(N,U,G,X)),K||i!=="always"&&this.grid.hitTest(N,U,G,X,i,v)?{box:[N,U,G,X],placeable:!1,offscreen:!1,occluded:W}:{box:[N,U,G,X],placeable:!0,offscreen:this.isOffscreen(N,U,G,X),occluded:W}}placeCollisionCircles(e,i,a,o,u,f,_,y,v,T,P,S,A,R){const V=[],N=new c.P(i.anchorX,i.anchorY),U=this.getPerspectiveRatio(N.x,N.y,f,R),G=(v?u*this.transform.getPitchedTextCorrection(i.anchorX,i.anchorY,f)/U:u*U)/c.as,X={getElevation:R,pitchedLabelPlaneMatrix:_,lineVertexArray:a,pitchWithMap:v,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:N,unwrappedTileID:f,width:this.transform.width,height:this.transform.height,translation:A},W=Me(G,o,i.lineOffsetX*G,i.lineOffsetY*G,!1,i,!1,X);let K=!1,Q=!1,J=!0;if(W){const se=.5*P*U+S,oe=new c.P(-100,-100),me=new c.P(this.screenRightBoundary,this.screenBottomBoundary),ye=new $,de=W.first,Se=W.last;let Pe=[];for(let $e=de.path.length-1;$e>=1;$e--)Pe.push(de.path[$e]);for(let $e=1;$e<Se.path.length;$e++)Pe.push(Se.path[$e]);const ve=2.5*se;if(v){const $e=this.projectPathToScreenSpace(Pe,X);Pe=$e.some(et=>et.signedDistanceFromCamera<=0)?[]:$e.map(et=>et.point)}let Ee=[];if(Pe.length>0){const $e=Pe[0].clone(),et=Pe[0].clone();for(let xt=1;xt<Pe.length;xt++)$e.x=Math.min($e.x,Pe[xt].x),$e.y=Math.min($e.y,Pe[xt].y),et.x=Math.max(et.x,Pe[xt].x),et.y=Math.max(et.y,Pe[xt].y);Ee=$e.x>=oe.x&&et.x<=me.x&&$e.y>=oe.y&&et.y<=me.y?[Pe]:et.x<oe.x||$e.x>me.x||et.y<oe.y||$e.y>me.y?[]:c.ao([Pe],oe.x,oe.y,me.x,me.y)}for(const $e of Ee){ye.reset($e,.25*se);let et=0;et=ye.length<=.5*se?1:Math.ceil(ye.paddedLength/ve)+1;for(let xt=0;xt<et;xt++){const st=xt/Math.max(et-1,1),vt=ye.lerp(st),at=vt.x+mt,nt=vt.y+mt;V.push(at,nt,se,0);const ot=at-se,Kt=nt-se,Lt=at+se,Bt=nt+se;if(J=J&&this.isOffscreen(ot,Kt,Lt,Bt),Q=Q||this.isInsideGrid(ot,Kt,Lt,Bt),e!=="always"&&this.grid.hitTestCircle(at,nt,se,e,T)&&(K=!0,!y))return{circles:[],offscreen:!1,collisionDetected:K}}}}return{circles:!y&&K||!Q||U<this.perspectiveRatioCutoff?[]:V,offscreen:J,collisionDetected:K}}projectPathToScreenSpace(e,i){const a=function(o,u){const f=c.H();return c.an(f,u.pitchedLabelPlaneMatrix),o.map(_=>{const y=he(_.x,_.y,f,u.getElevation),v=u.transform.projectTileCoordinates(y.point.x,y.point.y,u.unwrappedTileID,u.getElevation);return v.point.x=(.5*v.point.x+.5)*u.width,v.point.y=(.5*-v.point.y+.5)*u.height,v})}(e,i);return function(o){let u=0,f=0,_=0,y=0;for(let v=0;v<o.length;v++)o[v].isOccluded?(_=v+1,y=0):(y++,y>f&&(f=y,u=_));return o.slice(u,u+f)}(a)}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const i=[];let a=1/0,o=1/0,u=-1/0,f=-1/0;for(const T of e){const P=new c.P(T.x+mt,T.y+mt);a=Math.min(a,P.x),o=Math.min(o,P.y),u=Math.max(u,P.x),f=Math.max(f,P.y),i.push(P)}const _=this.grid.query(a,o,u,f).concat(this.ignoredGrid.query(a,o,u,f)),y={},v={};for(const T of _){const P=T.key;if(y[P.bucketInstanceId]===void 0&&(y[P.bucketInstanceId]={}),y[P.bucketInstanceId][P.featureIndex])continue;const S=[new c.P(T.x1,T.y1),new c.P(T.x2,T.y1),new c.P(T.x2,T.y2),new c.P(T.x1,T.y2)];c.ap(i,S)&&(y[P.bucketInstanceId][P.featureIndex]=!0,v[P.bucketInstanceId]===void 0&&(v[P.bucketInstanceId]=[]),v[P.bucketInstanceId].push(P.featureIndex))}return v}insertCollisionBox(e,i,a,o,u,f){(a?this.ignoredGrid:this.grid).insert({bucketInstanceId:o,featureIndex:u,collisionGroupID:f,overlapMode:i},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,i,a,o,u,f){const _=a?this.ignoredGrid:this.grid,y={bucketInstanceId:o,featureIndex:u,collisionGroupID:f,overlapMode:i};for(let v=0;v<e.length;v+=4)_.insertCircle(y,e[v],e[v+1],e[v+2])}projectAndGetPerspectiveRatio(e,i,a,o,u){if(u){let f;o?(f=[e,i,o(e,i),1],c.al(f,f,u)):(f=[e,i,0,1],Rt(f,f,u));const _=f[3];return{x:(f[0]/_+1)/2*this.transform.width+mt,y:(-f[1]/_+1)/2*this.transform.height+mt,perspectiveRatio:.5+this.transform.cameraToCenterDistance/_*.5,isOccluded:!1,signedDistanceFromCamera:_}}{const f=this.transform.projectTileCoordinates(e,i,a,o);return{x:(f.point.x+1)/2*this.transform.width+mt,y:(1-f.point.y)/2*this.transform.height+mt,perspectiveRatio:.5+this.transform.cameraToCenterDistance/f.signedDistanceFromCamera*.5,isOccluded:f.isOccluded,signedDistanceFromCamera:f.signedDistanceFromCamera}}}getPerspectiveRatio(e,i,a,o){const u=this.transform.projectTileCoordinates(e,i,a,o);return .5+this.transform.cameraToCenterDistance/u.signedDistanceFromCamera*.5}isOffscreen(e,i,a,o){return a<mt||e>=this.screenRightBoundary||o<mt||i>this.screenBottomBoundary}isInsideGrid(e,i,a,o){return a>=0&&e<this.gridRightBoundary&&o>=0&&i<this.gridBottomBoundary}getViewportMatrix(){const e=c.aq([]);return c.J(e,e,[-100,-100,0]),e}_projectCollisionBox(e,i,a,o,u,f,_,y,v,T,P){let S=1,A=0,R=0,V=1;const N=e.anchorPointX+_[0],U=e.anchorPointY+_[1];if(f&&!u){const Pe=this.projectAndGetPerspectiveRatio(N+1,U,o,v,P),ve=Pe.x-y.x,Ee=Math.atan((Pe.y-y.y)/ve)+(ve<0?Math.PI:0),$e=Math.sin(Ee),et=Math.cos(Ee);S=et,A=$e,R=-$e,V=et}else if(!f&&u){const Pe=fe(this.transform);S=Pe.vecEast[0],A=Pe.vecEast[1],R=Pe.vecSouth[0],V=Pe.vecSouth[1]}let G=y.x,X=y.y,W=i;u&&(G=N,X=U,W=Math.pow(2,-(this.transform.zoom-a.overscaledZ)),W*=this.transform.getPitchedTextCorrection(N,U,o),T||(W*=c.ab(.5+y.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),T&&(G+=S*T.x*W+R*T.y*W,X+=A*T.x*W+V*T.y*W);const K=e.x1*W,Q=e.x2*W,J=(K+Q)/2,se=e.y1*W,oe=e.y2*W,me=(se+oe)/2,ye=[{offsetX:K,offsetY:se},{offsetX:J,offsetY:se},{offsetX:Q,offsetY:se},{offsetX:Q,offsetY:me},{offsetX:Q,offsetY:oe},{offsetX:J,offsetY:oe},{offsetX:K,offsetY:oe},{offsetX:K,offsetY:me}];let de=[];for(const{offsetX:Pe,offsetY:ve}of ye)de.push(new c.P(G+S*Pe+R*ve,X+A*Pe+V*ve));let Se=!1;if(u){const Pe=de.map(ve=>this.projectAndGetPerspectiveRatio(ve.x,ve.y,o,v,P));Se=Pe.some(ve=>!ve.isOccluded),de=Pe.map(ve=>new c.P(ve.x,ve.y))}else Se=!0;return{box:c.ar(de),allPointsOccluded:!Se}}}class _t{constructor(e,i,a,o){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?i:-i))):o&&a?1:0,this.placed=a}isHidden(){return this.opacity===0&&!this.placed}}class es{constructor(e,i,a,o,u){this.text=new _t(e?e.text:null,i,a,u),this.icon=new _t(e?e.icon:null,i,o,u)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class wn{constructor(e,i,a){this.text=e,this.icon=i,this.skipFade=a}}class La{constructor(e,i,a,o,u){this.bucketInstanceId=e,this.featureIndex=i,this.sourceLayerIndex=a,this.bucketIndex=o,this.tileID=u}}class Yr{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 i=++this.maxGroupID;this.collisionGroups[e]={ID:i,predicate:a=>a.collisionGroupID===i}}return this.collisionGroups[e]}}function Jr(h,e,i,a,o){const{horizontalAlign:u,verticalAlign:f}=c.ay(h);return new c.P(-(u-.5)*e+a[0]*o,-(f-.5)*i+a[1]*o)}class rl{constructor(e,i,a,o,u){this.transform=e.clone(),this.terrain=i,this.collisionIndex=new _i(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=a,this.retainedQueryData={},this.collisionGroups=new Yr(o),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=u,u&&(u.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const i=this.terrain;return i?(a,o)=>i.getElevation(e,a,o):null}getBucketParts(e,i,a,o){const u=a.getBucket(i),f=a.latestFeatureIndex;if(!u||!f||i.id!==u.layerIds[0])return;const _=a.collisionBoxArray,y=u.layers[0].layout,v=u.layers[0].paint,T=Math.pow(2,this.transform.zoom-a.tileID.overscaledZ),P=a.tileSize/c.X,S=a.tileID.toUnwrapped(),A=y.get("text-rotation-alignment")==="map",R=c.at(a,1,this.transform.zoom),V=c.au(this.collisionIndex.transform,a,v.get("text-translate"),v.get("text-translate-anchor")),N=c.au(this.collisionIndex.transform,a,v.get("icon-translate"),v.get("icon-translate-anchor")),U=le(A,this.transform,R);this.retainedQueryData[u.bucketInstanceId]=new La(u.bucketInstanceId,f,u.sourceLayerIndex,u.index,a.tileID);const G={bucket:u,layout:y,translationText:V,translationIcon:N,unwrappedTileID:S,pitchedLabelPlaneMatrix:U,scale:T,textPixelRatio:P,holdingForFade:a.holdingForFade(),collisionBoxArray:_,partiallyEvaluatedTextSize:c.ah(u.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(u.sourceID)};if(o)for(const X of u.sortKeyRanges){const{sortKey:W,symbolInstanceStart:K,symbolInstanceEnd:Q}=X;e.push({sortKey:W,symbolInstanceStart:K,symbolInstanceEnd:Q,parameters:G})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:u.symbolInstances.length,parameters:G})}attemptAnchorPlacement(e,i,a,o,u,f,_,y,v,T,P,S,A,R,V,N,U,G,X,W){const K=c.av[e.textAnchor],Q=[e.textOffset0,e.textOffset1],J=Jr(K,a,o,Q,u),se=this.collisionIndex.placeCollisionBox(i,S,y,v,T,_,f,N,P.predicate,X,J,W);if((!G||this.collisionIndex.placeCollisionBox(G,S,y,v,T,_,f,U,P.predicate,X,J,W).placeable)&&se.placeable){let oe;if(this.prevPlacement&&this.prevPlacement.variableOffsets[A.crossTileID]&&this.prevPlacement.placements[A.crossTileID]&&this.prevPlacement.placements[A.crossTileID].text&&(oe=this.prevPlacement.variableOffsets[A.crossTileID].anchor),A.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[A.crossTileID]={textOffset:Q,width:a,height:o,anchor:K,textBoxScale:u,prevAnchor:oe},this.markUsedJustification(R,K,A,V),R.allowVerticalPlacement&&(this.markUsedOrientation(R,V,A),this.placedOrientations[A.crossTileID]=V),{shift:J,placedGlyphBoxes:se}}}placeLayerBucketPart(e,i,a){const{bucket:o,layout:u,translationText:f,translationIcon:_,unwrappedTileID:y,pitchedLabelPlaneMatrix:v,textPixelRatio:T,holdingForFade:P,collisionBoxArray:S,partiallyEvaluatedTextSize:A,collisionGroup:R}=e.parameters,V=u.get("text-optional"),N=u.get("icon-optional"),U=c.aw(u,"text-overlap","text-allow-overlap"),G=U==="always",X=c.aw(u,"icon-overlap","icon-allow-overlap"),W=X==="always",K=u.get("text-rotation-alignment")==="map",Q=u.get("text-pitch-alignment")==="map",J=u.get("icon-text-fit")!=="none",se=u.get("symbol-z-order")==="viewport-y",oe=G&&(W||!o.hasIconData()||N),me=W&&(G||!o.hasTextData()||V);!o.collisionArrays&&S&&o.deserializeCollisionBoxes(S);const ye=this.retainedQueryData[o.bucketInstanceId].tileID,de=this._getTerrainElevationFunc(ye),Se=this.transform.getFastPathSimpleProjectionMatrix(ye),Pe=(ve,Ee,$e)=>{var et,xt;if(i[ve.crossTileID])return;if(P)return void(this.placements[ve.crossTileID]=new wn(!1,!1,!1));let st=!1,vt=!1,at=!0,nt=null,ot={box:null,placeable:!1,offscreen:null,occluded:!1},Kt={placeable:!1},Lt=null,Bt=null,ci=null,lr=0,Yi=0,yi=0;Ee.textFeatureIndex?lr=Ee.textFeatureIndex:ve.useRuntimeCollisionCircles&&(lr=ve.featureIndex),Ee.verticalTextFeatureIndex&&(Yi=Ee.verticalTextFeatureIndex);const cr=Ee.textBox;if(cr){const di=lt=>{let bt=c.ai.horizontal;if(o.allowVerticalPlacement&&!lt&&this.prevPlacement){const vi=this.prevPlacement.placedOrientations[ve.crossTileID];vi&&(this.placedOrientations[ve.crossTileID]=vi,bt=vi,this.markUsedOrientation(o,bt,ve))}return bt},ki=(lt,bt)=>{if(o.allowVerticalPlacement&&ve.numVerticalGlyphVertices>0&&Ee.verticalTextBox){for(const vi of o.writingModes)if(vi===c.ai.vertical?(ot=bt(),Kt=ot):ot=lt(),ot&&ot.placeable)break}else ot=lt()},Di=ve.textAnchorOffsetStartIndex,xi=ve.textAnchorOffsetEndIndex;if(xi===Di){const lt=(bt,vi)=>{const Tt=this.collisionIndex.placeCollisionBox(bt,U,T,ye,y,Q,K,f,R.predicate,de,void 0,Se);return Tt&&Tt.placeable&&(this.markUsedOrientation(o,vi,ve),this.placedOrientations[ve.crossTileID]=vi),Tt};ki(()=>lt(cr,c.ai.horizontal),()=>{const bt=Ee.verticalTextBox;return o.allowVerticalPlacement&&ve.numVerticalGlyphVertices>0&&bt?lt(bt,c.ai.vertical):{box:null,offscreen:null}}),di(ot&&ot.placeable)}else{let lt=c.av[(xt=(et=this.prevPlacement)===null||et===void 0?void 0:et.variableOffsets[ve.crossTileID])===null||xt===void 0?void 0:xt.anchor];const bt=(Tt,Gc,tc)=>{const Ro=Tt.x2-Tt.x1,ic=Tt.y2-Tt.y1,mn=ve.textBoxScale,_n=J&&X==="never"?Gc:null;let zr=null,rc=U==="never"?1:2,xa="never";lt&&rc++;for(let Lo=0;Lo<rc;Lo++){for(let Bo=Di;Bo<xi;Bo++){const Fo=o.textAnchorOffsets.get(Bo);if(lt&&Fo.textAnchor!==lt)continue;const Oo=this.attemptAnchorPlacement(Fo,Tt,Ro,ic,mn,K,Q,T,ye,y,R,xa,ve,o,tc,f,_,_n,de);if(Oo&&(zr=Oo.placedGlyphBoxes,zr&&zr.placeable))return st=!0,nt=Oo.shift,zr}lt?lt=null:xa=U}return a&&!zr&&(zr={box:this.collisionIndex.placeCollisionBox(cr,"always",T,ye,y,Q,K,f,R.predicate,de,void 0,Se).box,offscreen:!1,placeable:!1,occluded:!1}),zr};ki(()=>bt(cr,Ee.iconBox,c.ai.horizontal),()=>{const Tt=Ee.verticalTextBox;return o.allowVerticalPlacement&&(!ot||!ot.placeable)&&ve.numVerticalGlyphVertices>0&&Tt?bt(Tt,Ee.verticalIconBox,c.ai.vertical):{box:null,occluded:!0,offscreen:null}}),ot&&(st=ot.placeable,at=ot.offscreen);const vi=di(ot&&ot.placeable);if(!st&&this.prevPlacement){const Tt=this.prevPlacement.variableOffsets[ve.crossTileID];Tt&&(this.variableOffsets[ve.crossTileID]=Tt,this.markUsedJustification(o,Tt.anchor,ve,vi))}}}if(Lt=ot,st=Lt&&Lt.placeable,at=Lt&&Lt.offscreen,ve.useRuntimeCollisionCircles){const di=o.text.placedSymbolArray.get(ve.centerJustifiedTextSymbolIndex),ki=c.aj(o.textSizeData,A,di),Di=u.get("text-padding");Bt=this.collisionIndex.placeCollisionCircles(U,di,o.lineVertexArray,o.glyphOffsetArray,ki,y,v,a,Q,R.predicate,ve.collisionCircleDiameter,Di,f,de),Bt.circles.length&&Bt.collisionDetected&&!a&&c.w("Collisions detected, but collision boxes are not shown"),st=G||Bt.circles.length>0&&!Bt.collisionDetected,at=at&&Bt.offscreen}if(Ee.iconFeatureIndex&&(yi=Ee.iconFeatureIndex),Ee.iconBox){const di=ki=>this.collisionIndex.placeCollisionBox(ki,X,T,ye,y,Q,K,_,R.predicate,de,J&&nt?nt:void 0,Se);Kt&&Kt.placeable&&Ee.verticalIconBox?(ci=di(Ee.verticalIconBox),vt=ci.placeable):(ci=di(Ee.iconBox),vt=ci.placeable),at=at&&ci.offscreen}const Is=V||ve.numHorizontalGlyphVertices===0&&ve.numVerticalGlyphVertices===0,Cs=N||ve.numIconVertices===0;Is||Cs?Cs?Is||(vt=vt&&st):st=vt&&st:vt=st=vt&&st;const Un=vt&&ci.placeable;if(st&&Lt.placeable&&this.collisionIndex.insertCollisionBox(Lt.box,U,u.get("text-ignore-placement"),o.bucketInstanceId,Kt&&Kt.placeable&&Yi?Yi:lr,R.ID),Un&&this.collisionIndex.insertCollisionBox(ci.box,X,u.get("icon-ignore-placement"),o.bucketInstanceId,yi,R.ID),Bt&&st&&this.collisionIndex.insertCollisionCircles(Bt.circles,U,u.get("text-ignore-placement"),o.bucketInstanceId,lr,R.ID),a&&this.storeCollisionData(o.bucketInstanceId,$e,Ee,Lt,ci,Bt),ve.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(o.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[ve.crossTileID]=new wn((st||oe)&&!(Lt!=null&&Lt.occluded),(vt||me)&&!(ci!=null&&ci.occluded),at||o.justReloaded),i[ve.crossTileID]=!0};if(se){if(e.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const ve=o.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let Ee=ve.length-1;Ee>=0;--Ee){const $e=ve[Ee];Pe(o.symbolInstances.get($e),o.collisionArrays[$e],$e)}}else for(let ve=e.symbolInstanceStart;ve<e.symbolInstanceEnd;ve++)Pe(o.symbolInstances.get(ve),o.collisionArrays[ve],ve);o.justReloaded=!1}storeCollisionData(e,i,a,o,u,f){if(a.textBox||a.iconBox){let _,y;this.collisionBoxArrays.has(e)?_=this.collisionBoxArrays.get(e):(_=new Map,this.collisionBoxArrays.set(e,_)),_.has(i)?y=_.get(i):(y={text:null,icon:null},_.set(i,y)),a.textBox&&(y.text=o.box),a.iconBox&&(y.icon=u.box)}if(f){let _=this.collisionCircleArrays[e];_===void 0&&(_=this.collisionCircleArrays[e]=[]);for(let y=0;y<f.circles.length;y+=4)_.push(f.circles[y+0]-mt),_.push(f.circles[y+1]-mt),_.push(f.circles[y+2]),_.push(f.collisionDetected?1:0)}}markUsedJustification(e,i,a,o){let u;u=o===c.ai.vertical?a.verticalPlacedTextSymbolIndex:{left:a.leftJustifiedTextSymbolIndex,center:a.centerJustifiedTextSymbolIndex,right:a.rightJustifiedTextSymbolIndex}[c.ax(i)];const f=[a.leftJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.rightJustifiedTextSymbolIndex,a.verticalPlacedTextSymbolIndex];for(const _ of f)_>=0&&(e.text.placedSymbolArray.get(_).crossTileID=u>=0&&_!==u?0:a.crossTileID)}markUsedOrientation(e,i,a){const o=i===c.ai.horizontal||i===c.ai.horizontalOnly?i:0,u=i===c.ai.vertical?i:0,f=[a.leftJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.rightJustifiedTextSymbolIndex];for(const _ of f)e.text.placedSymbolArray.get(_).placedOrientation=o;a.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(a.verticalPlacedTextSymbolIndex).placedOrientation=u)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const i=this.prevPlacement;let a=!1;this.prevZoomAdjustment=i?i.zoomAdjustment(this.transform.zoom):0;const o=i?i.symbolFadeChange(e):1,u=i?i.opacities:{},f=i?i.variableOffsets:{},_=i?i.placedOrientations:{};for(const y in this.placements){const v=this.placements[y],T=u[y];T?(this.opacities[y]=new es(T,o,v.text,v.icon),a=a||v.text!==T.text.placed||v.icon!==T.icon.placed):(this.opacities[y]=new es(null,o,v.text,v.icon,v.skipFade),a=a||v.text||v.icon)}for(const y in u){const v=u[y];if(!this.opacities[y]){const T=new es(v,o,!1,!1);T.isHidden()||(this.opacities[y]=T,a=a||v.text.placed||v.icon.placed)}}for(const y in f)this.variableOffsets[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.variableOffsets[y]=f[y]);for(const y in _)this.placedOrientations[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.placedOrientations[y]=_[y]);if(i&&i.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");a?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=i?i.lastPlacementChangeTime:e)}updateLayerOpacities(e,i){const a={};for(const o of i){const u=o.getBucket(e);u&&o.latestFeatureIndex&&e.id===u.layerIds[0]&&this.updateBucketOpacities(u,o.tileID,a,o.collisionBoxArray)}}updateBucketOpacities(e,i,a,o){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const u=e.layers[0],f=u.layout,_=new es(null,0,!1,!1,!0),y=f.get("text-allow-overlap"),v=f.get("icon-allow-overlap"),T=u._unevaluatedLayout.hasValue("text-variable-anchor")||u._unevaluatedLayout.hasValue("text-variable-anchor-offset"),P=f.get("text-rotation-alignment")==="map",S=f.get("text-pitch-alignment")==="map",A=f.get("icon-text-fit")!=="none",R=new es(null,0,y&&(v||!e.hasIconData()||f.get("icon-optional")),v&&(y||!e.hasTextData()||f.get("text-optional")),!0);!e.collisionArrays&&o&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(o);const V=(U,G,X)=>{for(let W=0;W<G/4;W++)U.opacityVertexArray.emplaceBack(X);U.hasVisibleVertices=U.hasVisibleVertices||X!==Qr},N=this.collisionBoxArrays.get(e.bucketInstanceId);for(let U=0;U<e.symbolInstances.length;U++){const G=e.symbolInstances.get(U),{numHorizontalGlyphVertices:X,numVerticalGlyphVertices:W,crossTileID:K}=G;let Q=this.opacities[K];a[K]?Q=_:Q||(Q=R,this.opacities[K]=Q),a[K]=!0;const J=G.numIconVertices>0,se=this.placedOrientations[G.crossTileID],oe=se===c.ai.vertical,me=se===c.ai.horizontal||se===c.ai.horizontalOnly;if(X>0||W>0){const de=Fa(Q.text);V(e.text,X,oe?Qr:de),V(e.text,W,me?Qr:de);const Se=Q.text.isHidden();[G.rightJustifiedTextSymbolIndex,G.centerJustifiedTextSymbolIndex,G.leftJustifiedTextSymbolIndex].forEach(Ee=>{Ee>=0&&(e.text.placedSymbolArray.get(Ee).hidden=Se||oe?1:0)}),G.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(G.verticalPlacedTextSymbolIndex).hidden=Se||me?1:0);const Pe=this.variableOffsets[G.crossTileID];Pe&&this.markUsedJustification(e,Pe.anchor,G,se);const ve=this.placedOrientations[G.crossTileID];ve&&(this.markUsedJustification(e,"left",G,ve),this.markUsedOrientation(e,ve,G))}if(J){const de=Fa(Q.icon),Se=!(A&&G.verticalPlacedIconSymbolIndex&&oe);G.placedIconSymbolIndex>=0&&(V(e.icon,G.numIconVertices,Se?de:Qr),e.icon.placedSymbolArray.get(G.placedIconSymbolIndex).hidden=Q.icon.isHidden()),G.verticalPlacedIconSymbolIndex>=0&&(V(e.icon,G.numVerticalIconVertices,Se?Qr:de),e.icon.placedSymbolArray.get(G.verticalPlacedIconSymbolIndex).hidden=Q.icon.isHidden())}const ye=N&&N.has(U)?N.get(U):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const de=e.collisionArrays[U];if(de){let Se=new c.P(0,0);if(de.textBox||de.verticalTextBox){let Pe=!0;if(T){const ve=this.variableOffsets[K];ve?(Se=Jr(ve.anchor,ve.width,ve.height,ve.textOffset,ve.textBoxScale),P&&Se._rotate(S?-this.transform.bearingInRadians:this.transform.bearingInRadians)):Pe=!1}if(de.textBox||de.verticalTextBox){let ve;de.textBox&&(ve=oe),de.verticalTextBox&&(ve=me),Ba(e.textCollisionBox.collisionVertexArray,Q.text.placed,!Pe||ve,ye.text,Se.x,Se.y)}}if(de.iconBox||de.verticalIconBox){const Pe=!!(!me&&de.verticalIconBox);let ve;de.iconBox&&(ve=Pe),de.verticalIconBox&&(ve=!Pe),Ba(e.iconCollisionBox.collisionVertexArray,Q.icon.placed,ve,ye.icon,A?Se.x:0,A?Se.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 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.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,i){const a=this.zoomAtLastRecencyCheck===i?1-this.zoomAdjustment(i):1;return this.zoomAtLastRecencyCheck=i,this.commitTime+this.fadeDuration*a>e}setStale(){this.stale=!0}}function Ba(h,e,i,a,o,u){a&&a.length!==0||(a=[0,0,0,0]);const f=a[0]-mt,_=a[1]-mt,y=a[2]-mt,v=a[3]-mt;h.emplaceBack(e?1:0,i?1:0,o||0,u||0,f,_),h.emplaceBack(e?1:0,i?1:0,o||0,u||0,y,_),h.emplaceBack(e?1:0,i?1:0,o||0,u||0,y,v),h.emplaceBack(e?1:0,i?1:0,o||0,u||0,f,v)}const nl=Math.pow(2,25),Tn=Math.pow(2,24),sl=Math.pow(2,17),Pc=Math.pow(2,16),Mc=Math.pow(2,9),Sc=Math.pow(2,8),al=Math.pow(2,1);function Fa(h){if(h.opacity===0&&!h.placed)return 0;if(h.opacity===1&&h.placed)return 4294967295;const e=h.placed?1:0,i=Math.floor(127*h.opacity);return i*nl+e*Tn+i*sl+e*Pc+i*Mc+e*Sc+i*al+e}const Qr=0;class Oa{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,i,a,o,u){const f=this._bucketParts;for(;this._currentTileIndex<e.length;)if(i.getBucketParts(f,o,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,u())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,f.sort((_,y)=>_.sortKey-y.sortKey));this._currentPartIndex<f.length;)if(i.placeLayerBucketPart(f[this._currentPartIndex],this._seenCrossTileIDs,a),this._currentPartIndex++,u())return!0;return!1}}class ol{constructor(e,i,a,o,u,f,_,y){this.placement=new rl(e,i,f,_,y),this._currentPlacementIndex=a.length-1,this._forceFullPlacement=o,this._showCollisionBoxes=u,this._done=!1}isDone(){return this._done}continuePlacement(e,i,a){const o=Ze.now(),u=()=>!this._forceFullPlacement&&Ze.now()-o>2;for(;this._currentPlacementIndex>=0;){const f=i[e[this._currentPlacementIndex]],_=this.placement.collisionIndex.transform.zoom;if(f.type==="symbol"&&(!f.minzoom||f.minzoom<=_)&&(!f.maxzoom||f.maxzoom>_)){if(this._inProgressLayer||(this._inProgressLayer=new Oa(f)),this._inProgressLayer.continuePlacement(a[f.source],this.placement,this._showCollisionBoxes,f,u))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const en=512/c.X/2;class ja{constructor(e,i,a){this.tileID=e,this.bucketInstanceId=a,this._symbolsByKey={};const o=new Map;for(let u=0;u<i.length;u++){const f=i.get(u),_=f.key,y=o.get(_);y?y.push(f):o.set(_,[f])}for(const[u,f]of o){const _={positions:f.map(y=>({x:Math.floor(y.anchorX*en),y:Math.floor(y.anchorY*en)})),crossTileIDs:f.map(y=>y.crossTileID)};if(_.positions.length>128){const y=new c.az(_.positions.length,16,Uint16Array);for(const{x:v,y:T}of _.positions)y.add(v,T);y.finish(),delete _.positions,_.index=y}this._symbolsByKey[u]=_}}getScaledCoordinates(e,i){const{x:a,y:o,z:u}=this.tileID.canonical,{x:f,y:_,z:y}=i.canonical,v=en/Math.pow(2,y-u),T=(_*c.X+e.anchorY)*v,P=o*c.X*en;return{x:Math.floor((f*c.X+e.anchorX)*v-a*c.X*en),y:Math.floor(T-P)}}findMatches(e,i,a){const o=this.tileID.canonical.z<i.canonical.z?1:Math.pow(2,this.tileID.canonical.z-i.canonical.z);for(let u=0;u<e.length;u++){const f=e.get(u);if(f.crossTileID)continue;const _=this._symbolsByKey[f.key];if(!_)continue;const y=this.getScaledCoordinates(f,i);if(_.index){const v=_.index.range(y.x-o,y.y-o,y.x+o,y.y+o).sort();for(const T of v){const P=_.crossTileIDs[T];if(!a[P]){a[P]=!0,f.crossTileID=P;break}}}else if(_.positions)for(let v=0;v<_.positions.length;v++){const T=_.positions[v],P=_.crossTileIDs[v];if(Math.abs(T.x-y.x)<=o&&Math.abs(T.y-y.y)<=o&&!a[P]){a[P]=!0,f.crossTileID=P;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:e})=>e)}}class Ls{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ll{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const i=Math.round((e-this.lng)/360);if(i!==0)for(const a in this.indexes){const o=this.indexes[a],u={};for(const f in o){const _=o[f];_.tileID=_.tileID.unwrapTo(_.tileID.wrap+i),u[_.tileID.key]=_}this.indexes[a]=u}this.lng=e}addBucket(e,i,a){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===i.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let u=0;u<i.symbolInstances.length;u++)i.symbolInstances.get(u).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]={});const o=this.usedCrossTileIDs[e.overscaledZ];for(const u in this.indexes){const f=this.indexes[u];if(Number(u)>e.overscaledZ)for(const _ in f){const y=f[_];y.tileID.isChildOf(e)&&y.findMatches(i.symbolInstances,e,o)}else{const _=f[e.scaledTo(Number(u)).key];_&&_.findMatches(i.symbolInstances,e,o)}}for(let u=0;u<i.symbolInstances.length;u++){const f=i.symbolInstances.get(u);f.crossTileID||(f.crossTileID=a.generate(),o[f.crossTileID]=!0)}return this.indexes[e.overscaledZ]===void 0&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new ja(e,i.symbolInstances,i.bucketInstanceId),!0}removeBucketCrossTileIDs(e,i){for(const a of i.getCrossTileIDsLists())for(const o of a)delete this.usedCrossTileIDs[e][o]}removeStaleBuckets(e){let i=!1;for(const a in this.indexes){const o=this.indexes[a];for(const u in o)e[o[u].bucketInstanceId]||(this.removeBucketCrossTileIDs(a,o[u]),delete o[u],i=!0)}return i}}class tn{constructor(){this.layerIndexes={},this.crossTileIDs=new Ls,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,i,a){let o=this.layerIndexes[e.id];o===void 0&&(o=this.layerIndexes[e.id]=new ll);let u=!1;const f={};o.handleWrapJump(a);for(const _ of i){const y=_.getBucket(e);y&&e.id===y.layerIds[0]&&(y.bucketInstanceId||(y.bucketInstanceId=++this.maxBucketInstanceId),o.addBucket(_.tileID,y,this.crossTileIDs)&&(u=!0),f[y.bucketInstanceId]=!0)}return o.removeStaleBuckets(f)&&(u=!0),u}pruneUnusedLayers(e){const i={};e.forEach(a=>{i[a]=!0});for(const a in this.layerIndexes)i[a]||delete this.layerIndexes[a]}}var Na="void main() {fragColor=vec4(1.0);}";const qi={prelude:He(`#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:He("","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:He("",`#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:He(`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:He(`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:He(`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:He(Na,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:He(`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:He(`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:He("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:He("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);}"),debug:He("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:He(Na,`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:He(`#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:He(`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:He(`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:He(`#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:He(`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:He(`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:He(`#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)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));fragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);
#ifdef OVERDRAW_INSPECTOR
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:He(`uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;
#define PI 3.141592653589793
void main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;
#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:He(`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:He(`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:He(`#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:He(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;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
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump float width
#pragma mapbox: initialize lowp float floorwidth
float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=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);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_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_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;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
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump float gapwidth
#pragma mapbox: initialize lowp float offset
#pragma mapbox: initialize mediump float width
#pragma mapbox: initialize lowp float floorwidth
float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);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_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}`),raster:He(`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:He(`uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize lowp float opacity
lowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;
#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_fade_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);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;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:He(`#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 opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
void main() {
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=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);
#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;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
camera_to_anchor_distance/u_camera_to_center_distance :
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
#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*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:He(`#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 opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
void main() {
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;
#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*opacity*fade_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);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;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:He("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:He("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:He("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:He("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:He(`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:He("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 He(h,e){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,a=e.match(/in ([\w]+) ([\w]+)/g),o=h.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),u=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),f=u?u.concat(o):o,_={};return{fragmentSource:h=h.replace(i,(y,v,T,P,S)=>(_[S]=!0,v==="define"?`
#ifndef HAS_UNIFORM_u_${S}
in ${T} ${P} ${S};
#else
uniform ${T} ${P} u_${S};
#endif
`:`
#ifdef HAS_UNIFORM_u_${S}
${T} ${P} ${S} = u_${S};
#endif
`)),vertexSource:e=e.replace(i,(y,v,T,P,S)=>{const A=P==="float"?"vec2":"vec4",R=S.match(/color/)?"color":A;return _[S]?v==="define"?`
#ifndef HAS_UNIFORM_u_${S}
uniform lowp float u_${S}_t;
in ${T} ${A} a_${S};
out ${T} ${P} ${S};
#else
uniform ${T} ${P} u_${S};
#endif
`:R==="vec4"?`
#ifndef HAS_UNIFORM_u_${S}
${S} = a_${S};
#else
${T} ${P} ${S} = u_${S};
#endif
`:`
#ifndef HAS_UNIFORM_u_${S}
${S} = unpack_mix_${R}(a_${S}, u_${S}_t);
#else
${T} ${P} ${S} = u_${S};
#endif
`:v==="define"?`
#ifndef HAS_UNIFORM_u_${S}
uniform lowp float u_${S}_t;
in ${T} ${A} a_${S};
#else
uniform ${T} ${P} u_${S};
#endif
`:R==="vec4"?`
#ifndef HAS_UNIFORM_u_${S}
${T} ${P} ${S} = a_${S};
#else
${T} ${P} ${S} = u_${S};
#endif
`:`
#ifndef HAS_UNIFORM_u_${S}
${T} ${P} ${S} = unpack_mix_${R}(a_${S}, u_${S}_t);
#else
${T} ${P} ${S} = u_${S};
#endif
`}),staticAttributes:a,staticUniforms:f}}class Hi{constructor(e,i,a){this.vertexBuffer=e,this.indexBuffer=i,this.segments=a}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Xe=c.aA([{name:"a_pos",type:"Int16",components:2}]);const Bs="#define PROJECTION_MERCATOR",cl="mercator";class ts{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return cl}get shaderDefine(){return Bs}get shaderPreludeCode(){return qi.projectionMercator}get vertexShaderPreludeCode(){return qi.projectionMercator.vertexSource}get subdivisionGranularity(){return c.aB.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,i,a,o,u){if(this._cachedMesh)return this._cachedMesh;const f=new c.aC;f.emplaceBack(0,0),f.emplaceBack(c.X,0),f.emplaceBack(0,c.X),f.emplaceBack(c.X,c.X);const _=e.createVertexBuffer(f,Xe.members),y=c.aD.simpleSegment(0,0,4,2),v=new c.aE;v.emplaceBack(1,0,2),v.emplaceBack(1,2,3);const T=e.createIndexBuffer(v);return this._cachedMesh=new Hi(_,T,y),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}function Et(h,e){const i=c.ab(e.lat,-85.051129,c.aF);return new c.P(c.O(e.lng)*h,c.Q(i)*h)}function Nt(h,e){return new c.Y(e.x/h,e.y/h).toLngLat()}function wt(h){return h.cameraToCenterDistance*Math.min(.85*Math.tan(c.aa(90-h.pitch)),Math.tan(c.aa(89.25-h.pitch)))}function Va(h,e){const i=h.canonical,a=e/c.aG(i.z),o=i.x+Math.pow(2,i.z)*h.wrap,u=c.aq(new Float64Array(16));return c.J(u,u,[o*a,i.y*a,0]),c.K(u,u,[a/c.X,a/c.X,1]),u}function ii(h,e,i,a,o){const u=c.Y.fromLngLat(h,e),f=o*c.aH(1,h.lat),_=f*Math.cos(c.aa(i)),y=Math.sqrt(f*f-_*_),v=y*Math.sin(c.aa(-a)),T=y*Math.cos(c.aa(-a));return new c.Y(u.x+v,u.y+T,u.z+_)}class ri{constructor(e=0,i=0,a=0,o=0){if(isNaN(e)||e<0||isNaN(i)||i<0||isNaN(a)||a<0||isNaN(o)||o<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=i,this.left=a,this.right=o}interpolate(e,i,a){return i.top!=null&&e.top!=null&&(this.top=c.y.number(e.top,i.top,a)),i.bottom!=null&&e.bottom!=null&&(this.bottom=c.y.number(e.bottom,i.bottom,a)),i.left!=null&&e.left!=null&&(this.left=c.y.number(e.left,i.left,a)),i.right!=null&&e.right!=null&&(this.right=c.y.number(e.right,i.right,a)),this}getCenter(e,i){const a=c.ab((this.left+e-this.right)/2,0,e),o=c.ab((this.top+i-this.bottom)/2,0,i);return new c.P(a,o)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new ri(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function ni(h,e){if(!h.renderWorldCopies||h.lngRange)return;const i=e.lng-h.center.lng;e.lng+=i>180?-360:i<-180?360:0}function Ua(h){return Math.max(0,Math.floor(h))}class rn{constructor(e,i,a,o,u,f){this._callbacks=e,this._tileSize=512,this._renderWorldCopies=f===void 0||!!f,this._minZoom=i||0,this._maxZoom=a||22,this._minPitch=o??0,this._maxPitch=u??60,this.setMaxBounds(),this._width=0,this._height=0,this._center=new c.N(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Ua(this._zoom),this._scale=c.aG(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new ri,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,i,a){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=Ua(this._zoom),this._scale=c.aG(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 ri(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=!a&&e.autoCalculateNearFarZ,i&&this._constrain(),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.getConstrained(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.getConstrained(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 worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new c.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const i=c.aI(e,-180,180)*Math.PI/180;var a,o,u,f,_,y,v,T,P;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=fr(),a=this._rotationMatrix,u=-this._bearingInRadians,f=(o=this._rotationMatrix)[0],_=o[1],y=o[2],v=o[3],T=Math.sin(u),P=Math.cos(u),a[0]=f*P+y*T,a[1]=_*P+v*T,a[2]=f*-T+y*P,a[3]=_*-T+v*P)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const i=c.ab(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const i=e/180*Math.PI;this._rollInRadians!==i&&(this._unmodified=!1,this._rollInRadians=i,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return c.aJ(this._fovInRadians)}setFov(e){e=c.ab(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=c.aa(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const i=this.getConstrained(this._center,e).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=c.aG(i),this._constrain(),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._constrain(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),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,i){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=i,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,i,a){this._unmodified=!1,this._edgeInsets.interpolate(e,i,a),this._constrain(),this._calcMatrices()}resize(e,i,a=!0){this._width=e,this._height=i,a&&this._constrain(),this._calcMatrices()}getMaxBounds(){return this._latRange&&this._latRange.length===2&&this._lngRange&&this._lngRange.length===2?new zt([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._constrain()):(this._lngRange=null,this._latRange=[-85.051129,c.aF])}getConstrained(e,i){return this._callbacks.getConstrained(e,i)}getCameraQueryGeometry(e,i){if(i.length===1)return[i[0],e];{let a=e.x,o=e.y,u=e.x,f=e.y;for(const _ of i)a=Math.min(a,_.x),o=Math.min(o,_.y),u=Math.max(u,_.x),f=Math.max(f,_.y);return[new c.P(a,o),new c.P(u,o),new c.P(u,f),new c.P(a,f),new c.P(a,o)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:i,zoom:a}=this.getConstrained(this.center,this.zoom);this.setCenter(i),this.setZoom(a),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=c.aq(new Float64Array(16));c.K(e,e,[this._width/2,-this._height/2,1]),c.J(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=c.aq(new Float64Array(16)),c.K(e,e,[1,-1,1]),c.J(e,e,[-1,-1,0]),c.K(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,i,a,o){const u=a!==void 0?a:this.bearing,f=o=o!==void 0?o:this.pitch,_=c.Y.fromLngLat(e,i),y=-Math.cos(c.aa(f)),v=Math.sin(c.aa(f)),T=v*Math.sin(c.aa(u)),P=-v*Math.cos(c.aa(u));let S=this.elevation;const A=i-S;let R;y*A>=0||Math.abs(y)<.1?(R=1e4,S=i+R*y):R=-A/y;let V,N,U=c.aK(1,_.y),G=0;do{if(G+=1,G>10)break;N=R/U,V=new c.Y(_.x+T*N,_.y+P*N),U=1/V.meterInMercatorCoordinateUnits()}while(Math.abs(R-N*U)>1e-12);return{center:V.toLngLat(),elevation:S,zoom:c.a8(this.height/2/Math.tan(this.fovInRadians/2)/N/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const i=c.aH(1,this.center.lat)*this.worldSize,a=this.cameraToCenterDistance/i,o=c.Y.fromLngLat(this.center,this.elevation),u=ii(this.center,this.elevation,this.pitch,this.bearing,a);this._elevation=e;const f=this.calculateCenterFromCameraLngLatAlt(u.toLngLat(),c.aK(u.z,o.y),this.bearing,this.pitch);this._elevation=f.elevation,this._center=f.center,this.setZoom(f.zoom)}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new c.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=c.aH(1,this.center.lat)*this.worldSize;return ii(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const i=e.canonical.z>=0?1<<e.canonical.z:Math.pow(2,e.canonical.z);return[e.canonical.x/i,e.canonical.y/i,1/i/c.X,1/i/c.X]}}class ut{constructor(e,i){this.min=e,this.max=i,this.center=c.aL([],c.aM([],this.min,this.max),.5)}quadrant(e){const i=[e%2==0,e<2],a=c.aN(this.min),o=c.aN(this.max);for(let u=0;u<i.length;u++)a[u]=i[u]?this.min[u]:this.center[u],o[u]=i[u]?this.center[u]:this.max[u];return o[2]=this.max[2],new ut(a,o)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}intersectsFrustum(e){let i=!0;for(let a=0;a<e.planes.length;a++){const o=this.intersectsPlane(e.planes[a]);if(o===0)return 0;o===1&&(i=!1)}return i?2:e.aabb.min[0]>this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]<this.min[0]||e.aabb.max[1]<this.min[1]||e.aabb.max[2]<this.min[2]?0:1}intersectsPlane(e){let i=e[3],a=e[3];for(let o=0;o<3;o++)e[o]>0?(i+=e[o]*this.min[o],a+=e[o]*this.max[o]):(a+=e[o]*this.min[o],i+=e[o]*this.max[o]);return i>=0?2:a<0?0:1}}class is{distanceToTile2d(e,i,a,o){const u=o.distanceX([e,i]),f=o.distanceY([e,i]);return Math.hypot(u,f)}getWrap(e,i,a){return a}getTileAABB(e,i,a,o){var u,f;let _=a,y=a;if(o.terrain){const T=new c.S(e.z,i,e.z,e.x,e.y),P=o.terrain.getMinMaxElevation(T);_=(u=P.minElevation)!==null&&u!==void 0?u:a,y=(f=P.maxElevation)!==null&&f!==void 0?f:a}const v=1<<e.z;return new ut([i+e.x/v,e.y/v,_],[i+(e.x+1)/v,(e.y+1)/v,y])}allowVariableZoom(e,i){const a=e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height,o=c.ab(78.5-a/2,0,60);return!!i.terrain||e.pitch>o||e.padding.top>=.1}allowWorldCopies(){return!0}recalculateCache(){}}class Xi{constructor(e,i,a){this.points=e,this.planes=i,this.aabb=a}static fromInvProjectionMatrix(e,i=1,a=0){const o=Math.pow(2,a),u=[[-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=>{const T=1/(v=c.al([],v,e))[3]/i*o;return c.aO(v,v,[T,T,1/v[3],T])}),f=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(v=>{const T=c.aP([],u[v[0]],u[v[1]]),P=c.aP([],u[v[2]],u[v[1]]),S=c.aQ([],c.aR([],T,P)),A=-c.aS(S,u[v[1]]);return S.concat(A)}),_=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],y=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const v of u)for(let T=0;T<3;T++)_[T]=Math.min(_[T],v[T]),y[T]=Math.max(y[T],v[T]);return new Xi(u,f,new ut(_,y))}}class ir{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,i,a){return this._helper.interpolatePadding(e,i,a)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,i,a=!0){this._helper.resize(e,i,a)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,i){this._helper.overrideNearFarZ(e,i)}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 nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,i){}constructor(e,i,a,o,u){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new rn({calcMatrices:()=>{this._calcMatrices()},getConstrained:(f,_)=>this.getConstrained(f,_)},e,i,a,o,u),this._coveringTilesDetailsProvider=new is}clone(){const e=new ir;return e.apply(this),e}apply(e,i,a){this._helper.apply(e,i,a)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const i=[new c.aT(0,e)];if(this._helper._renderWorldCopies){const a=this.screenPointToMercatorCoordinate(new c.P(0,0)),o=this.screenPointToMercatorCoordinate(new c.P(this._helper._width,0)),u=this.screenPointToMercatorCoordinate(new c.P(this._helper._width,this._helper._height)),f=this.screenPointToMercatorCoordinate(new c.P(0,this._helper._height)),_=Math.floor(Math.min(a.x,o.x,u.x,f.x)),y=Math.floor(Math.max(a.x,o.x,u.x,f.x)),v=1;for(let T=_-v;T<=y+v;T++)T!==0&&i.push(new c.aT(T,e))}return i}getCameraFrustum(){return Xi.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const i=this.screenPointToLocation(this.centerPoint,e),a=e?e.getElevationForLngLatZoom(i,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(a)}setLocationAtPoint(e,i){const a=c.aH(this.elevation,this.center.lat),o=this.screenPointToMercatorCoordinateAtZ(i,a),u=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,a),f=c.Y.fromLngLat(e),_=new c.Y(f.x-(o.x-u.x),f.y-(o.y-u.y));this.setCenter(_==null?void 0:_.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,i){return i?this.coordinatePoint(c.Y.fromLngLat(e),i.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(c.Y.fromLngLat(e))}screenPointToLocation(e,i){var a;return(a=this.screenPointToMercatorCoordinate(e,i))===null||a===void 0?void 0:a.toLngLat()}screenPointToMercatorCoordinate(e,i){if(i){const a=i.pointCoordinate(e);if(a!=null)return a}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,i){const a=i||0,o=[e.x,e.y,0,1],u=[e.x,e.y,1,1];c.al(o,o,this._pixelMatrixInverse),c.al(u,u,this._pixelMatrixInverse);const f=o[3],_=u[3],y=o[1]/f,v=u[1]/_,T=o[2]/f,P=u[2]/_,S=T===P?0:(a-T)/(P-T);return new c.Y(c.y.number(o[0]/f,u[0]/_,S)/this.worldSize,c.y.number(y,v,S)/this.worldSize,a)}coordinatePoint(e,i=0,a=this._pixelMatrix){const o=[e.x*this.worldSize,e.y*this.worldSize,i,1];return c.al(o,o,a),new c.P(o[0]/o[3],o[1]/o[3])}getBounds(){const e=Math.max(0,this._helper._height/2-wt(this));return new zt().extend(this.screenPointToLocation(new c.P(0,e))).extend(this.screenPointToLocation(new c.P(this._helper._width,e))).extend(this.screenPointToLocation(new c.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new c.P(0,this._helper._height)))}isPointOnMapSurface(e,i){return i?i.pointCoordinate(e)!=null:e.y>this.height/2-wt(this)}calculatePosMatrix(e,i=!1,a){var o;const u=(o=e.key)!==null&&o!==void 0?o:c.aU(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),f=i?this._alignedPosMatrixCache:this._posMatrixCache;if(f.has(u)){const v=f.get(u);return a?v.f32:v.f64}const _=Va(e,this.worldSize);c.L(_,i?this._alignedProjMatrix:this._viewProjMatrix,_);const y={f64:_,f32:new Float32Array(_)};return f.set(u,y),a?y.f32:y.f64}calculateFogMatrix(e){const i=e.key,a=this._fogMatrixCacheF32;if(a.has(i))return a.get(i);const o=Va(e,this.worldSize);return c.L(o,this._fogMatrix,o),a.set(i,new Float32Array(o)),a.get(i)}getConstrained(e,i){i=c.ab(+i,this.minZoom,this.maxZoom);const a={center:new c.N(e.lng,e.lat),zoom:i};let o=this._helper._lngRange;this._helper._renderWorldCopies||o!==null||(o=[-179.9999999999,180-1e-10]);const u=this.tileSize*c.aG(a.zoom);let f=0,_=u,y=0,v=u,T=0,P=0;const{x:S,y:A}=this.size;if(this._helper._latRange){const X=this._helper._latRange;f=c.Q(X[1])*u,_=c.Q(X[0])*u,_-f<A&&(T=A/(_-f))}o&&(y=c.aI(c.O(o[0])*u,0,u),v=c.aI(c.O(o[1])*u,0,u),v<y&&(v+=u),v-y<S&&(P=S/(v-y)));const{x:R,y:V}=Et(u,e);let N,U;const G=Math.max(P||0,T||0);if(G){const X=new c.P(P?(v+y)/2:R,T?(_+f)/2:V);return a.center=Nt(u,X).wrap(),a.zoom+=c.a8(G),a}if(this._helper._latRange){const X=A/2;V-X<f&&(U=f+X),V+X>_&&(U=_-X)}if(o){const X=(y+v)/2;let W=R;this._helper._renderWorldCopies&&(W=c.aI(R,X-u/2,X+u/2));const K=S/2;W-K<y&&(N=y+K),W+K>v&&(N=v-K)}if(N!==void 0||U!==void 0){const X=new c.P(N??R,U??V);a.center=Nt(u,X).wrap()}return a}calculateCenterFromCameraLngLatAlt(e,i,a,o){return this._helper.calculateCenterFromCameraLngLatAlt(e,i,a,o)}_calculateNearFarZIfNeeded(e,i,a){if(!this._helper.autoCalculateNearFarZ)return;const o=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),u=e-o*this._helper._pixelPerMeter/Math.cos(i),f=o<0?u:e,_=Math.PI/2+this.pitchInRadians,y=c.aa(this.fov)*(Math.abs(Math.cos(c.aa(this.roll)))*this.height+Math.abs(Math.sin(c.aa(this.roll)))*this.width)/this.height*(.5+a.y/this.height),v=Math.sin(y)*f/Math.sin(c.ab(Math.PI-_-y,.01,Math.PI-.01)),T=wt(this),P=Math.atan(T/this._helper.cameraToCenterDistance),S=c.aa(.75),A=P>S?2*P*(.5+a.y/(2*T)):S,R=Math.sin(A)*f/Math.sin(c.ab(Math.PI-_-A,.01,Math.PI-.01)),V=Math.min(v,R);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*V+f),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,i=Et(this.worldSize,this.center),a=i.x,o=i.y;this._helper._pixelPerMeter=c.aH(1,this.center.lat)*this.worldSize;const u=c.aa(Math.min(this.pitch,89.25)),f=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(u));let _;this._calculateNearFarZIfNeeded(f,u,e),_=new Float64Array(16),c.aV(_,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),c.an(this._invProjMatrix,_),_[8]=2*-e.x/this._helper._width,_[9]=2*e.y/this._helper._height,this._projectionMatrix=c.aW(_),c.K(_,_,[1,-1,1]),c.J(_,_,[0,0,-this._helper.cameraToCenterDistance]),c.aX(_,_,-this.rollInRadians),c.aY(_,_,this.pitchInRadians),c.aX(_,_,-this.bearingInRadians),c.J(_,_,[-a,-o,0]),this._mercatorMatrix=c.K([],_,[this.worldSize,this.worldSize,this.worldSize]),c.K(_,_,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=c.L(new Float64Array(16),this.clipSpaceToPixelsMatrix,_),c.J(_,_,[0,0,-this.elevation]),this._viewProjMatrix=_,this._invViewProjMatrix=c.an([],_);const y=[0,0,-1,1];c.al(y,y,this._invViewProjMatrix),this._cameraPosition=[y[0]/y[3],y[1]/y[3],y[2]/y[3]],this._fogMatrix=new Float64Array(16),c.aV(this._fogMatrix,this.fovInRadians,this.width/this.height,f,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,c.K(this._fogMatrix,this._fogMatrix,[1,-1,1]),c.J(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),c.aX(this._fogMatrix,this._fogMatrix,-this.rollInRadians),c.aY(this._fogMatrix,this._fogMatrix,this.pitchInRadians),c.aX(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),c.J(this._fogMatrix,this._fogMatrix,[-a,-o,0]),c.K(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),c.J(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=c.L(new Float64Array(16),this.clipSpaceToPixelsMatrix,_);const v=this._helper._width%2/2,T=this._helper._height%2/2,P=Math.cos(this.bearingInRadians),S=Math.sin(-this.bearingInRadians),A=a-Math.round(a)+P*v+S*T,R=o-Math.round(o)+P*T+S*v,V=new Float64Array(_);if(c.J(V,V,[A>.5?A-1:A,R>.5?R-1:R,0]),this._alignedProjMatrix=V,_=c.an(new Float64Array(16),this._pixelMatrix),!_)throw new Error("failed to invert matrix");this._pixelMatrixInverse=_,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new c.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return c.al(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=c.aH(1,this.center.lat)*this.worldSize;return ii(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,i){const a=c.Y.fromLngLat(e),o=[a.x*this.worldSize,a.y*this.worldSize,i,1];return c.al(o,o,this._viewProjMatrix),o[2]/o[3]}getProjectionData(e){const{overscaledTileID:i,aligned:a,applyTerrainMatrix:o}=e,u=this._helper.getMercatorTileCoordinates(i),f=i?this.calculatePosMatrix(i,a,!0):null;let _;return _=i&&i.terrainRttPosMatrix32f&&o?i.terrainRttPosMatrix32f:f||c.aZ(),{mainMatrix:_,tileMercatorCoords:u,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:_}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,i,a){return 1}transformLightDirection(e){return c.aN(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,i,a,o){const u=this.calculatePosMatrix(a);let f;o?(f=[e,i,o(e,i),1],c.al(f,f,u)):(f=[e,i,0,1],Rt(f,f,u));const _=f[3];return{point:new c.P(f[0]/_,f[1]/_),signedDistanceFromCamera:_,isOccluded:!1}}populateCache(e){for(const i of e)this.calculatePosMatrix(i)}getMatrixForModel(e,i){const a=c.Y.fromLngLat(e,i),o=a.meterInMercatorCoordinateUnits(),u=c.a_();return c.J(u,u,[a.x,a.y,a.z]),c.aX(u,u,Math.PI),c.aY(u,u,Math.PI/2),c.K(u,u,[-o,o,o]),u}getProjectionDataForCustomLayer(e=!0){const i=new c.S(0,0,0,0,0),a=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:e}),o=Va(i,this.worldSize);c.L(o,this._viewProjMatrix,o),a.tileMercatorCoords=[0,0,1,1];const u=[c.X,c.X,this.worldSize/this._helper.pixelsPerMeter],f=c.a$();return c.K(f,o,u),a.fallbackMatrix=f,a.mainMatrix=f,a}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function Ci(){c.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Za(h){if(h.useSlerp)if(h.k<1){const e=c.b0(h.startEulerAngles.roll,h.startEulerAngles.pitch,h.startEulerAngles.bearing),i=c.b0(h.endEulerAngles.roll,h.endEulerAngles.pitch,h.endEulerAngles.bearing),a=new Float64Array(4);c.b1(a,e,i,h.k);const o=c.b2(a);h.tr.setRoll(o.roll),h.tr.setPitch(o.pitch),h.tr.setBearing(o.bearing)}else h.tr.setRoll(h.endEulerAngles.roll),h.tr.setPitch(h.endEulerAngles.pitch),h.tr.setBearing(h.endEulerAngles.bearing);else h.tr.setRoll(c.y.number(h.startEulerAngles.roll,h.endEulerAngles.roll,h.k)),h.tr.setPitch(c.y.number(h.startEulerAngles.pitch,h.endEulerAngles.pitch,h.k)),h.tr.setBearing(c.y.number(h.startEulerAngles.bearing,h.endEulerAngles.bearing,h.k))}function rr(h,e,i,a,o){const u=o.padding,f=Et(o.worldSize,i.getNorthWest()),_=Et(o.worldSize,i.getNorthEast()),y=Et(o.worldSize,i.getSouthEast()),v=Et(o.worldSize,i.getSouthWest()),T=c.aa(-a),P=f.rotate(T),S=_.rotate(T),A=y.rotate(T),R=v.rotate(T),V=new c.P(Math.max(P.x,S.x,R.x,A.x),Math.max(P.y,S.y,R.y,A.y)),N=new c.P(Math.min(P.x,S.x,R.x,A.x),Math.min(P.y,S.y,R.y,A.y)),U=V.sub(N),G=(o.width-(u.left+u.right+e.left+e.right))/U.x,X=(o.height-(u.top+u.bottom+e.top+e.bottom))/U.y;if(X<0||G<0)return void Ci();const W=Math.min(c.a8(o.scale*Math.min(G,X)),h.maxZoom),K=c.P.convert(h.offset),Q=new c.P((e.left-e.right)/2,(e.top-e.bottom)/2).rotate(c.aa(a)),J=K.add(Q).mult(o.scale/c.aG(W));return{center:Nt(o.worldSize,f.add(y).div(2).sub(J)),zoom:W,bearing:a}}class Fs{get useGlobeControls(){return!1}handlePanInertia(e,i){return{easingOffset:e,easingCenter:i.center}}handleMapControlsRollPitchBearingZoom(e,i){e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta),e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta)}handleMapControlsPan(e,i,a){e.around.distSqr(i.centerPoint)<.01||i.setLocationAtPoint(a,e.around)}cameraForBoxAndBearing(e,i,a,o,u){return rr(e,i,a,o,u)}handleJumpToCenterZoom(e,i){e.zoom!==(i.zoom!==void 0?+i.zoom:e.zoom)&&e.setZoom(+i.zoom),i.center!==void 0&&e.setCenter(c.N.convert(i.center))}handleEaseTo(e,i){const a=e.zoom,o=e.padding,u={roll:e.roll,pitch:e.pitch,bearing:e.bearing},f={roll:i.roll===void 0?e.roll:i.roll,pitch:i.pitch===void 0?e.pitch:i.pitch,bearing:i.bearing===void 0?e.bearing:i.bearing},_=i.zoom!==void 0,y=!e.isPaddingEqual(i.padding);let v=!1;const T=_?+i.zoom:e.zoom;let P=e.centerPoint.add(i.offsetAsPoint);const S=e.screenPointToLocation(P),{center:A,zoom:R}=e.getConstrained(c.N.convert(i.center||S),T??a);ni(e,A);const V=Et(e.worldSize,S),N=Et(e.worldSize,A).sub(V),U=c.aG(R-a);return v=R!==a,{easeFunc:G=>{if(v&&e.setZoom(c.y.number(a,R,G)),c.b3(u,f)||Za({startEulerAngles:u,endEulerAngles:f,tr:e,k:G,useSlerp:u.roll!=f.roll}),y&&(e.interpolatePadding(o,i.padding,G),P=e.centerPoint.add(i.offsetAsPoint)),i.around)e.setLocationAtPoint(i.around,i.aroundPoint);else{const X=c.aG(e.zoom-a),W=R>a?Math.min(2,U):Math.max(.5,U),K=Math.pow(W,1-G),Q=Nt(e.worldSize,V.add(N.mult(G*K)).mult(X));e.setLocationAtPoint(e.renderWorldCopies?Q.wrap():Q,P)}},isZooming:v,elevationCenter:A}}handleFlyTo(e,i){const a=i.zoom!==void 0,o=e.zoom,u=e.getConstrained(c.N.convert(i.center||i.locationAtOffset),a?+i.zoom:o),f=u.center,_=u.zoom;ni(e,f);const y=Et(e.worldSize,i.locationAtOffset),v=Et(e.worldSize,f).sub(y),T=v.mag(),P=c.aG(_-o);let S;if(i.minZoom!==void 0){const A=Math.min(+i.minZoom,o,_),R=e.getConstrained(f,A).zoom;S=c.aG(R-o)}return{easeFunc:(A,R,V,N)=>{e.setZoom(A===1?_:o+c.a8(R));const U=A===1?f:Nt(e.worldSize,y.add(v.mult(V)).mult(R));e.setLocationAtPoint(e.renderWorldCopies?U.wrap():U,N)},scaleOfZoom:P,targetCenter:f,scaleOfMinZoom:S,pixelPathLength:T}}}class dt{constructor(e,i,a){this.blendFunction=e,this.blendColor=i,this.mask=a}}dt.Replace=[1,0],dt.disabled=new dt(dt.Replace,c.b4.transparent,[!1,!1,!1,!1]),dt.unblended=new dt(dt.Replace,c.b4.transparent,[!0,!0,!0,!0]),dt.alphaBlended=new dt([1,771],c.b4.transparent,[!0,!0,!0,!0]);const Pn=2305;class Ye{constructor(e,i,a){this.enable=e,this.mode=i,this.frontFace=a}}Ye.disabled=new Ye(!1,1029,Pn),Ye.backCCW=new Ye(!0,1029,Pn),Ye.frontCCW=new Ye(!0,1028,Pn);class Ge{constructor(e,i,a){this.func=e,this.mask=i,this.range=a}}Ge.ReadOnly=!1,Ge.ReadWrite=!0,Ge.disabled=new Ge(519,Ge.ReadOnly,[0,1]);const rs=7680;class Qe{constructor(e,i,a,o,u,f){this.test=e,this.ref=i,this.mask=a,this.fail=o,this.depthFail=u,this.pass=f}}Qe.disabled=new Qe({func:519,mask:0},0,0,rs,rs,rs);const Mn=new WeakMap;function Fi(h){var e;if(Mn.has(h))return Mn.get(h);{const i=(e=h.getParameter(h.VERSION))===null||e===void 0?void 0:e.startsWith("WebGL 2.0");return Mn.set(h,i),i}}class ns{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 i=e.context,a=i.gl;this._texFormat=a.RGBA,this._texType=a.UNSIGNED_BYTE;const o=new c.aC;o.emplaceBack(-1,-1),o.emplaceBack(2,-1),o.emplaceBack(-1,2);const u=new c.aE;u.emplaceBack(0,1,2),this._fullscreenTriangle=new Hi(i.createVertexBuffer(o,Xe.members),i.createIndexBuffer(u),c.aD.simpleSegment(0,0,o.length,u.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(a.TEXTURE1);const f=a.createTexture();a.bindTexture(a.TEXTURE_2D,f),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST),a.texImage2D(a.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(f),Fi(a)&&(this._pbo=a.createBuffer(),a.bindBuffer(a.PIXEL_PACK_BUFFER,this._pbo),a.bufferData(a.PIXEL_PACK_BUFFER,4,a.STREAM_READ),a.bindBuffer(a.PIXEL_PACK_BUFFER,null))}destroy(){const 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,i){const a=this._updateCount;return this._readbackQueue?a>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():a>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,i),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,i=e.gl;e.activeTexture.set(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,i){const a=this._cachedRenderContext.context,o=a.gl;if(this._bindFramebuffer(),a.viewport.set([0,0,this._texWidth,this._texHeight]),a.clear({color:c.b4.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(a,o.TRIANGLES,Ge.disabled,Qe.disabled,dt.unblended,Ye.disabled,((u,f)=>({u_input:u,u_output_expected:f}))(e,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Fi(o)){o.bindBuffer(o.PIXEL_PACK_BUFFER,this._pbo),o.readBuffer(o.COLOR_ATTACHMENT0),o.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null);const u=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0);o.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:u}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Fi(e)){const i=e.clientWaitSync(this._readbackQueue.sync,0,0);if(i===e.WAIT_FAILED)return c.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===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=ns._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let i=0;return i+=e[0]/256,i+=e[1]/65536,i+=e[2]/16777216,e[3]<127&&(i=-i),i/128}}const ss=c.X/128;function as(h,e){const i=h.granularity!==void 0?Math.max(h.granularity,1):1,a=i+(h.generateBorders?2:0),o=i+(h.extendToNorthPole||h.generateBorders?1:0)+(h.extendToSouthPole||h.generateBorders?1:0),u=a+1,f=o+1,_=h.generateBorders?-1:0,y=h.generateBorders||h.extendToNorthPole?-1:0,v=i+(h.generateBorders?1:0),T=i+(h.generateBorders||h.extendToSouthPole?1:0),P=u*f,S=a*o*6,A=u*f>65536;if(A&&e==="16bit")throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const R=A||e==="32bit",V=new Int16Array(2*P);let N=0;for(let X=y;X<=T;X++)for(let W=_;W<=v;W++){let K=W/i*c.X;W===-1&&(K=-64),W===i+1&&(K=c.X+ss);let Q=X/i*c.X;X===-1&&(Q=h.extendToNorthPole?c.b6:-64),X===i+1&&(Q=h.extendToSouthPole?c.b7:c.X+ss),V[N++]=K,V[N++]=Q}const U=R?new Uint32Array(S):new Uint16Array(S);let G=0;for(let X=0;X<o;X++)for(let W=0;W<a;W++){const K=W+1+X*u,Q=W+(X+1)*u,J=W+1+(X+1)*u;U[G++]=W+X*u,U[G++]=Q,U[G++]=K,U[G++]=K,U[G++]=Q,U[G++]=J}return{vertices:V.buffer.slice(0),indices:U.buffer.slice(0),uses32bitIndices:R}}const nn=new c.aB({fill:new c.b8(128,2),line:new c.b8(512,0),tile:new c.b8(128,32),stencil:new c.b8(128,1),circle:3});class hl{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return qi.projectionGlobe}get vertexShaderPreludeCode(){return qi.projectionMercator.vertexSource}get subdivisionGranularity(){return nn}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(e){this._errorMeasurement||(this._errorMeasurement=new ns(e));const i=c.Q(this._errorQueryLatitudeDegrees),a=2*Math.atan(Math.exp(Math.PI-i*Math.PI*2))-.5*Math.PI,o=this._errorMeasurement.updateErrorLoop(i,a),u=Ze.now();o!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=o,this._errorMeasurementLastChangeTime=u);const f=Math.min(Math.max((u-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=c.b9(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,c.ba(f))}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,i,a,o,u){const f=(u==="stencil"?nn.stencil:nn.tile).getGranularityForZoomLevel(i.z);return this._getMesh(e,{granularity:f,generateBorders:a,extendToNorthPole:i.y===0&&o,extendToSouthPole:i.y===(1<<i.z)-1&&o})}_getMesh(e,i){const a=this._getMeshKey(i);if(a in this._tileMeshCache)return this._tileMeshCache[a];const o=function(u,f){const _=as(f,"16bit"),y=c.aC.deserialize({arrayBuffer:_.vertices,length:_.vertices.byteLength/2/2}),v=c.aE.deserialize({arrayBuffer:_.indices,length:_.indices.byteLength/2/3});return new Hi(u.createVertexBuffer(y,Xe.members),u.createIndexBuffer(v),c.aD.simpleSegment(0,0,y.length,v.length))}(e,i);return this._tileMeshCache[a]=o,o}recalculate(e){}hasTransition(){const e=Ze.now();let i=!1;return i=i||(e-this._errorMeasurementLastChangeTime)/1e3<.7,i=i||this._errorMeasurement&&this._errorMeasurement.awaitingQuery,i}setErrorQueryLatitudeDegrees(e){this._errorQueryLatitudeDegrees=e}}const Ga=new c.q({type:new c.D(c.v.projection.type)});class $a extends c.E{constructor(e){super(),this._transitionable=new c.T(Ga),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new c.z(0)),this._mercatorProjection=new ts,this._verticalPerspectiveProjection=new hl}get transitionState(){const e=this.properties.get("type");if(typeof e=="string"&&e==="mercator")return 0;if(typeof e=="string"&&e==="vertical-perspective")return 1;if(e instanceof c.bb){if(e.from==="vertical-perspective"&&e.to==="mercator")return 1-e.transition;if(e.from==="mercator"&&e.to==="vertical-perspective")return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,i,a,o,u){return this.currentProjection.getMeshFromTileID(e,i,a,o,u)}setProjection(e){this._transitionable.setValue("type",(e==null?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 ul(h){const e=Sn(h.worldSize,h.center.lat);return 2*Math.PI*e}function os(h,e,i,a,o){const u=1/(1<<o),f=e/c.X*u+a*u,_=c.bd((h/c.X*u+i*u)*Math.PI*2+Math.PI,2*Math.PI),y=2*Math.atan(Math.exp(Math.PI-f*Math.PI*2))-.5*Math.PI,v=Math.cos(y),T=new Float64Array(3);return T[0]=Math.sin(_)*v,T[1]=Math.sin(y),T[2]=Math.cos(_)*v,T}function ct(h){return function(e,i){const a=Math.cos(i),o=new Float64Array(3);return o[0]=Math.sin(e)*a,o[1]=Math.sin(i),o[2]=Math.cos(e)*a,o}(h.lng*Math.PI/180,h.lat*Math.PI/180)}function Sn(h,e){return h/(2*Math.PI)/Math.cos(e*Math.PI/180)}function Oi(h){const e=Math.asin(h[1])/Math.PI*180,i=Math.sqrt(h[0]*h[0]+h[2]*h[2]);if(i>1e-6){const a=h[0]/i,o=Math.acos(h[2]/i),u=(a>0?o:-o)/Math.PI*180;return new c.N(c.aI(u,-180,180),e)}return new c.N(0,e)}function sn(h){return Math.cos(h*Math.PI/180)}function Vt(h,e){const i=sn(h),a=sn(e);return c.a8(a/i)}function qa(h,e){const i=h.rotate(e.bearingInRadians),a=e.zoom+Vt(e.center.lat,0),o=c.b9(1/sn(e.center.lat),1/sn(Math.min(Math.abs(e.center.lat),60)),c.bc(a,7,3,0,1)),u=360/ul({worldSize:e.worldSize,center:{lat:e.center.lat}});return new c.N(e.center.lng-i.x*u*o,c.ab(e.center.lat+i.y*u,-85.051129,c.aF))}function Sr(h){const e=.5*h,i=Math.sin(e),a=Math.cos(e);return Math.log(i+a)-Math.log(a-i)}function dl(h,e,i,a){const o=h.lat+i*a;if(Math.abs(i)>1){const u=(Math.sign(h.lat+i)!==Math.sign(h.lat)?-Math.abs(h.lat):Math.abs(h.lat))*Math.PI/180,f=Math.abs(h.lat+i)*Math.PI/180,_=Sr(u+a*(f-u)),y=Sr(u),v=Sr(f);return new c.N(h.lng+e*((_-y)/(v-y)),o)}return new c.N(h.lng+e*a,o)}class Ic{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._aabbFactory=e}recalculateCache(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileAABB(e,i,a,o){const u=`${e.z}_${e.x}_${e.y}`,f=this._cache.get(u);if(f)return f;const _=this._cachePrevious.get(u);if(_)return this._cache.set(u,_),_;const y=this._aabbFactory(e,i,a,o);return this._cache.set(u,y),this._hadAnyChanges=!0,y}}function Os(h,e,i){const a=h-e;return a<0?-a:Math.max(0,a-i)}function Ha(h,e,i,a,o){const u=h-i;let f;return f=u<0?Math.min(-u,1+u-o):u>1?Math.min(Math.max(u-o,0),1-u):0,Math.max(f,Os(e,a,o))}class Cc{constructor(){this._aabbCache=new Ic(this._computeTileAABB)}recalculateCache(){this._aabbCache.recalculateCache()}distanceToTile2d(e,i,a,o){const u=1<<a.z,f=1/u,_=a.x/u,y=a.y/u;let v=2;return v=Math.min(v,Ha(e,i,_,y,f)),v=Math.min(v,Ha(e,i,_+.5,-y-f,f)),v=Math.min(v,Ha(e,i,_+.5,2-y-f,f)),v}getWrap(e,i,a){const o=1<<i.z,u=1/o,f=i.x/o,_=Os(e.x,f,u),y=Os(e.x,f-1,u),v=Os(e.x,f+1,u),T=Math.min(_,y,v);return T===v?1:T===y?-1:0}allowVariableZoom(e,i){return Pr(e,i)>4}allowWorldCopies(){return!1}getTileAABB(e,i,a,o){return this._aabbCache.getTileAABB(e,i,a,o)}_computeTileAABB(e,i,a,o){if(e.z<=0)return new ut([-1,-1,-1],[1,1,1]);if(e.z===1)return new ut([e.x===0?-1:0,e.y===0?0:-1,-1],[e.x===0?0:1,e.y===0?1:0,1]);{const u=[os(0,0,e.x,e.y,e.z),os(c.X,0,e.x,e.y,e.z),os(c.X,c.X,e.x,e.y,e.z),os(0,c.X,e.x,e.y,e.z)],f=[1,1,1],_=[-1,-1,-1];for(const y of u)for(let v=0;v<3;v++)f[v]=Math.min(f[v],y[v]),_[v]=Math.max(_[v],y[v]);if(e.y===0||e.y===(1<<e.z)-1){const y=[0,e.y===0?1:-1,0];for(let v=0;v<3;v++)f[v]=Math.min(f[v],y[v]),_[v]=Math.max(_[v],y[v])}return new ut(f,_)}}}class js{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,i,a){return this._helper.interpolatePadding(e,i,a)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,i){this._helper.resize(e,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,i){this._helper.overrideNearFarZ(e,i)}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 nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e){}constructor(){this._cachedClippingPlane=c.be(),this._projectionMatrix=c.a_(),this._globeViewProjMatrix32f=c.aZ(),this._globeViewProjMatrixNoCorrection=c.a_(),this._globeViewProjMatrixNoCorrectionInverted=c.a_(),this._globeProjMatrixInverted=c.a_(),this._cameraPosition=c.bf(),this._globeLatitudeErrorCorrectionRadians=0,this._helper=new rn({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,i)=>this.getConstrained(e,i)}),this._coveringTilesDetailsProvider=new Cc}clone(){const e=new js;return e.apply(this),e}apply(e,i){this._globeLatitudeErrorCorrectionRadians=i||0,this._helper.apply(e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=c.bf();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:i,applyGlobeMatrix:a}=e,o=this._helper.getMercatorTileCoordinates(i);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:o,clippingPlane:this._cachedClippingPlane,projectionTransition:a?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const i=this.pitchInRadians,a=this.cameraToCenterDistance/e,o=Math.sin(i)*a,u=Math.cos(i)*a+1,f=1/Math.sqrt(o*o+u*u)*1;let _=-o,y=u;const v=Math.sqrt(_*_+y*y);_/=v,y/=v;const T=[0,_,y];return c.bg(T,T,[0,0,0],-this.bearingInRadians),c.bh(T,T,[0,0,0],-1*this.center.lat*Math.PI/180),c.bi(T,T,[0,0,0],this.center.lng*Math.PI/180),c.aL(T,T,.25),[...T,.25*-f]}isLocationOccluded(e){return!this.isSurfacePointVisible(ct(e))}transformLightDirection(e){const i=this._helper._center.lng*Math.PI/180,a=this._helper._center.lat*Math.PI/180,o=Math.cos(a),u=[Math.sin(i)*o,Math.sin(a),Math.cos(i)*o],f=[u[2],0,-u[0]],_=[0,0,0];c.aR(_,f,u),c.aQ(f,f),c.aQ(_,_);const y=[0,0,0];return c.aQ(y,[f[0]*e[0]+_[0]*e[1]+u[0]*e[2],f[1]*e[0]+_[1]*e[1]+u[1]*e[2],f[2]*e[0]+_[2]*e[1]+u[2]*e[2]]),y}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,i,a){const o=function(_,y,v){const T=1/(1<<v.z);return new c.Y(_/c.X*T+v.x*T,y/c.X*T+v.y*T)}(e,i,a.canonical),u=(f=o.y,[c.bd(o.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-f*Math.PI*2))-.5*Math.PI]);var f;return this.getCircleRadiusCorrection()/Math.cos(u[1])}projectTileCoordinates(e,i,a,o){const u=a.canonical,f=os(e,i,u.x,u.y,u.z),_=1+(o?o(e,i):0)/c.bo,y=[f[0]*_,f[1]*_,f[2]*_,1];c.al(y,y,this._globeViewProjMatrixNoCorrection);const v=this._cachedClippingPlane,T=v[0]*f[0]+v[1]*f[1]+v[2]*f[2]+v[3]<0;return{point:new c.P(y[0]/y[3],y[1]/y[3]),signedDistanceFromCamera:y[3],isOccluded:T}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const e=Sn(this.worldSize,this.center.lat),i=c.a$(),a=c.a$();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*e),c.aV(i,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);const o=this.centerOffset;i[8]=2*-o.x/this._helper._width,i[9]=2*o.y/this._helper._height,this._projectionMatrix=c.aW(i),this._globeProjMatrixInverted=c.a$(),c.an(this._globeProjMatrixInverted,i),c.J(i,i,[0,0,-this.cameraToCenterDistance]),c.aX(i,i,this.rollInRadians),c.aY(i,i,-this.pitchInRadians),c.aX(i,i,this.bearingInRadians),c.J(i,i,[0,0,-e]);const u=c.bf();u[0]=e,u[1]=e,u[2]=e,c.aY(a,i,this.center.lat*Math.PI/180),c.bj(a,a,-this.center.lng*Math.PI/180),c.K(a,a,u),this._globeViewProjMatrixNoCorrection=a,c.aY(i,i,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),c.bj(i,i,-this.center.lng*Math.PI/180),c.K(i,i,u),this._globeViewProjMatrix32f=new Float32Array(i),this._globeViewProjMatrixNoCorrectionInverted=c.a$(),c.an(this._globeViewProjMatrixNoCorrectionInverted,a);const f=c.bf();this._cameraPosition=c.bf(),this._cameraPosition[2]=this.cameraToCenterDistance/e,c.bg(this._cameraPosition,this._cameraPosition,f,-this.rollInRadians),c.bh(this._cameraPosition,this._cameraPosition,f,this.pitchInRadians),c.bg(this._cameraPosition,this._cameraPosition,f,-this.bearingInRadians),c.aM(this._cameraPosition,this._cameraPosition,[0,0,1]),c.bh(this._cameraPosition,this._cameraPosition,f,-this.center.lat*Math.PI/180),c.bi(this._cameraPosition,this._cameraPosition,f,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);const _=c.aW(this._globeViewProjMatrixNoCorrectionInverted);c.K(_,_,[1,1,-1]),this._cachedFrustum=Xi.fromInvProjectionMatrix(_)}calculateFogMatrix(e){c.w("calculateFogMatrix is not supported on globe projection.");const i=c.a$();return c.aq(i),i}getVisibleUnwrappedCoordinates(e){return[new c.aT(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e&&c.w("terrain is not fully supported on vertical perspective projection."),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,i){if(!this._globeViewProjMatrixNoCorrection)return 1;const a=ct(e);c.aL(a,a,1+i/c.bo);const o=c.be();return c.al(o,[a[0],a[1],a[2],1],this._globeViewProjMatrixNoCorrection),o[2]/o[3]}populateCache(e){}getBounds(){const e=.5*this.width,i=.5*this.height,a=[new c.P(0,0),new c.P(e,0),new c.P(this.width,0),new c.P(this.width,i),new c.P(this.width,this.height),new c.P(e,this.height),new c.P(0,this.height),new c.P(0,i)],o=[];for(const P of a)o.push(this.unprojectScreenPoint(P));let u=0,f=0,_=0,y=0;const v=this.center;for(const P of o){const S=c.bk(v.lng,P.lng),A=c.bk(v.lat,P.lat);S<f&&(f=S),S>u&&(u=S),A<y&&(y=A),A>_&&(_=A)}const T=[v.lng+f,v.lat+y,v.lng+u,v.lat+_];return this.isSurfacePointOnScreen([0,1,0])&&(T[3]=90,T[0]=-180,T[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(T[1]=-90,T[0]=-180,T[2]=180),new zt(T)}getConstrained(e,i){const a=c.ab(e.lat,-85.051129,c.aF),o=c.ab(+i,this.minZoom+Vt(0,a),this.maxZoom);return{center:new c.N(e.lng,a),zoom:o}}calculateCenterFromCameraLngLatAlt(e,i,a,o){return this._helper.calculateCenterFromCameraLngLatAlt(e,i,a,o)}setLocationAtPoint(e,i){const a=ct(this.unprojectScreenPoint(i)),o=ct(e),u=c.bf();c.bl(u);const f=c.bf();c.bi(f,a,u,-this.center.lng*Math.PI/180),c.bh(f,f,u,this.center.lat*Math.PI/180);const _=o[0]*o[0]+o[2]*o[2],y=f[0]*f[0];if(_<y)return;const v=Math.sqrt(_-y),T=-v,P=c.bm(o[0],o[2],f[0],v),S=c.bm(o[0],o[2],f[0],T),A=c.bf();c.bi(A,o,u,-P);const R=c.bm(A[1],A[2],f[1],f[2]),V=c.bf();c.bi(V,o,u,-S);const N=c.bm(V[1],V[2],f[1],f[2]),U=.5*Math.PI,G=R>=-U&&R<=U,X=N>=-U&&N<=U;let W,K;if(G&&X){const oe=this.center.lng*Math.PI/180,me=this.center.lat*Math.PI/180;c.bp(P,oe)+c.bp(R,me)<c.bp(S,oe)+c.bp(N,me)?(W=P,K=R):(W=S,K=N)}else if(G)W=P,K=R;else{if(!X)return;W=S,K=N}const Q=W/Math.PI*180,J=K/Math.PI*180,se=this.center.lat;this.setCenter(new c.N(Q,c.ab(J,-90,90))),this.setZoom(this.zoom+Vt(se,this.center.lat))}locationToScreenPoint(e,i){const a=ct(e);if(i){const o=i.getElevationForLngLatZoom(e,this._helper._tileZoom);c.aL(a,a,1+o/c.bo)}return this._projectSurfacePointToScreen(a)}_projectSurfacePointToScreen(e){const i=c.be();return c.al(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],new c.P((.5*i[0]+.5)*this.width,(.5*-i[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,i){if(i){const a=i.pointCoordinate(e);if(a)return a}return c.Y.fromLngLat(this.unprojectScreenPoint(e))}screenPointToLocation(e,i){var a;return(a=this.screenPointToMercatorCoordinate(e,i))===null||a===void 0?void 0:a.toLngLat()}isPointOnMapSurface(e,i){const a=this._cameraPosition,o=this.getRayDirectionFromPixel(e);return!!this.rayPlanetIntersection(a,o)}getRayDirectionFromPixel(e){const i=c.be();i[0]=e.x/this.width*2-1,i[1]=-1*(e.y/this.height*2-1),i[2]=1,i[3]=1,c.al(i,i,this._globeViewProjMatrixNoCorrectionInverted),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3];const a=c.bf();a[0]=i[0]-this._cameraPosition[0],a[1]=i[1]-this._cameraPosition[1],a[2]=i[2]-this._cameraPosition[2];const o=c.bf();return c.aQ(o,a),o}isSurfacePointVisible(e){const i=this._cachedClippingPlane;return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]+i[3]>=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const i=c.be();return c.al(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(e,i){const a=c.aS(e,i),o=c.bf(),u=c.bf();c.aL(u,i,a),c.aP(o,e,u);const f=1-c.aS(o,o);if(f<0)return null;const _=c.aS(e,e)-1,y=-a+(a<0?1:-1)*Math.sqrt(f),v=_/y,T=y;return{tMin:Math.min(v,T),tMax:Math.max(v,T)}}unprojectScreenPoint(e){const i=this._cameraPosition,a=this.getRayDirectionFromPixel(e),o=this.rayPlanetIntersection(i,a);if(o){const v=c.bf();c.aM(v,i,[a[0]*o.tMin,a[1]*o.tMin,a[2]*o.tMin]);const T=c.bf();return c.aQ(T,v),Oi(T)}const u=this._cachedClippingPlane[0]*a[0]+this._cachedClippingPlane[1]*a[1]+this._cachedClippingPlane[2]*a[2],f=-c.bn(this._cachedClippingPlane,i)/u,_=c.bf();if(f>0)c.aM(_,i,[a[0]*f,a[1]*f,a[2]*f]);else{const v=c.bf();c.aM(v,i,[2*a[0],2*a[1],2*a[2]]);const T=c.bn(this._cachedClippingPlane,v);c.aP(_,v,[this._cachedClippingPlane[0]*T,this._cachedClippingPlane[1]*T,this._cachedClippingPlane[2]*T])}const y=c.bf();return c.aQ(y,_),Oi(y)}getMatrixForModel(e,i){const a=c.N.convert(e),o=1/c.bo,u=c.a_();return c.bj(u,u,a.lng/180*Math.PI),c.aY(u,u,-a.lat/180*Math.PI),c.J(u,u,[0,0,1+i/c.bo]),c.aY(u,u,.5*Math.PI),c.K(u,u,[o,o,o]),u}getProjectionDataForCustomLayer(e=!0){const i=this.getProjectionData({overscaledTileID:new c.S(0,0,0,0,0),applyGlobeMatrix:e});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(e){}}class an{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,i,a){return this._helper.interpolatePadding(e,i,a)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,i,a=!0){this._helper.resize(e,i,a)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,i){this._helper.overrideNearFarZ(e,i)}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 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,i){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=i,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().recalculateCache(),this._mercatorTransform.getCoveringTilesDetailsProvider().recalculateCache()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new rn({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,i)=>this.getConstrained(e,i)}),this._globeness=1,this._mercatorTransform=new ir,this._verticalPerspectiveTransform=new js}clone(){const e=new an;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const i=this._mercatorTransform.getProjectionData(e),a=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?a.mainMatrix:i.mainMatrix,clippingPlane:a.clippingPlane,tileMercatorCoords:a.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:i.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return c.b9(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return c.b9(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,i,a){const o=this._mercatorTransform.getPitchedTextCorrection(e,i,a),u=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,i,a);return c.b9(o,u,this._globeness)}projectTileCoordinates(e,i,a,o){return this.currentTransform.projectTileCoordinates(e,i,a,o)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,i){return this.currentTransform.lngLatToCameraDepth(e,i)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}getConstrained(e,i){return this.currentTransform.getConstrained(e,i)}calculateCenterFromCameraLngLatAlt(e,i,a,o){return this._helper.calculateCenterFromCameraLngLatAlt(e,i,a,o)}setLocationAtPoint(e,i){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,i),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,i),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(e,i){return this.currentTransform.locationToScreenPoint(e,i)}screenPointToMercatorCoordinate(e,i){return this.currentTransform.screenPointToMercatorCoordinate(e,i)}screenPointToLocation(e,i){return this.currentTransform.screenPointToLocation(e,i)}isPointOnMapSurface(e,i){return this.currentTransform.isPointOnMapSurface(e,i)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,i){return this.currentTransform.getMatrixForModel(e,i)}getProjectionDataForCustomLayer(e=!0){const i=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return i;const a=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return a.fallbackMatrix=i.mainMatrix,a}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class gi{get useGlobeControls(){return!0}handlePanInertia(e,i){const a=qa(e,i);return Math.abs(a.lng-i.center.lng)>180&&(a.lng=i.center.lng+179.5*Math.sign(a.lng-i.center.lng)),{easingCenter:a,easingOffset:new c.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,i){const a=e.around,o=i.screenPointToLocation(a);e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta);const u=i.zoom;e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta);const f=i.zoom-u;if(f===0)return;const _=c.bk(i.center.lng,o.lng),y=_/(Math.abs(_/180)+1),v=c.bk(i.center.lat,o.lat),T=i.getRayDirectionFromPixel(a),P=i.cameraPosition,S=-1*c.aS(P,T),A=c.bf();c.aM(A,P,[T[0]*S,T[1]*S,T[2]*S]);const R=c.bq(A)-1,V=Math.exp(.5*-Math.max(R-.3,0)),N=Sn(i.worldSize,i.center.lat)/Math.min(i.width,i.height),U=c.bc(N,.9,.5,1,.25),G=(1-c.aG(-f))*Math.min(V,U),X=i.center.lat,W=i.zoom,K=new c.N(i.center.lng+y*G,c.ab(i.center.lat+v*G,-85.051129,c.aF));i.setLocationAtPoint(o,a);const Q=i.center,J=c.bc(Math.abs(_),45,85,0,1),se=c.bc(N,.75,.35,0,1),oe=Math.pow(Math.max(J,se),.25),me=c.bk(Q.lng,K.lng),ye=c.bk(Q.lat,K.lat);i.setCenter(new c.N(Q.lng+me*oe,Q.lat+ye*oe).wrap()),i.setZoom(W+Vt(X,i.center.lat))}handleMapControlsPan(e,i,a){if(!e.panDelta)return;const o=i.center.lat,u=i.zoom;i.setCenter(qa(e.panDelta,i).wrap()),i.setZoom(u+Vt(o,i.center.lat))}cameraForBoxAndBearing(e,i,a,o,u){const f=rr(e,i,a,o,u),_=i.left/u.width*2-1,y=(u.width-i.right)/u.width*2-1,v=i.top/u.height*-2+1,T=(u.height-i.bottom)/u.height*-2+1,P=c.bk(a.getWest(),a.getEast())<0,S=P?a.getEast():a.getWest(),A=P?a.getWest():a.getEast(),R=Math.max(a.getNorth(),a.getSouth()),V=Math.min(a.getNorth(),a.getSouth()),N=S+.5*c.bk(S,A),U=R+.5*c.bk(R,V),G=u.clone();G.setCenter(f.center),G.setBearing(f.bearing),G.setPitch(0),G.setRoll(0),G.setZoom(f.zoom);const X=G.modelViewProjectionMatrix,W=[ct(a.getNorthWest()),ct(a.getNorthEast()),ct(a.getSouthWest()),ct(a.getSouthEast()),ct(new c.N(A,U)),ct(new c.N(S,U)),ct(new c.N(N,R)),ct(new c.N(N,V))],K=ct(f.center);let Q=Number.POSITIVE_INFINITY;for(const J of W)_<0&&(Q=gi.getLesserNonNegativeNonNull(Q,gi.solveVectorScale(J,K,X,"x",_))),y>0&&(Q=gi.getLesserNonNegativeNonNull(Q,gi.solveVectorScale(J,K,X,"x",y))),v>0&&(Q=gi.getLesserNonNegativeNonNull(Q,gi.solveVectorScale(J,K,X,"y",v))),T<0&&(Q=gi.getLesserNonNegativeNonNull(Q,gi.solveVectorScale(J,K,X,"y",T)));if(Number.isFinite(Q)&&Q!==0)return f.zoom=G.zoom+c.a8(Q),f;Ci()}handleJumpToCenterZoom(e,i){const a=e.center.lat,o=e.getConstrained(i.center?c.N.convert(i.center):e.center,e.zoom).center;e.setCenter(o.wrap());const u=i.zoom!==void 0?+i.zoom:e.zoom+Vt(a,o.lat);e.zoom!==u&&e.setZoom(u)}handleEaseTo(e,i){const a=e.zoom,o=e.center,u=e.padding,f={roll:e.roll,pitch:e.pitch,bearing:e.bearing},_={roll:i.roll===void 0?e.roll:i.roll,pitch:i.pitch===void 0?e.pitch:i.pitch,bearing:i.bearing===void 0?e.bearing:i.bearing},y=i.zoom!==void 0,v=!e.isPaddingEqual(i.padding);let T=!1;const P=i.center?c.N.convert(i.center):o,S=e.getConstrained(P,a).center;ni(e,S);const A=e.clone();A.setCenter(S),A.setZoom(y?+i.zoom:a+Vt(o.lat,P.lat)),A.setBearing(i.bearing);const R=new c.P(c.ab(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),c.ab(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));A.setLocationAtPoint(S,R);const V=(i.offset&&i.offsetAsPoint.mag())>0?A.center:S,N=y?+i.zoom:a+Vt(o.lat,V.lat),U=a+Vt(o.lat,0),G=N+Vt(V.lat,0),X=c.bk(o.lng,V.lng),W=c.bk(o.lat,V.lat),K=c.aG(G-U);return T=N!==a,{easeFunc:Q=>{if(c.b3(f,_)||Za({startEulerAngles:f,endEulerAngles:_,tr:e,k:Q,useSlerp:f.roll!=_.roll}),v&&e.interpolatePadding(u,i.padding,Q),i.around)c.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(i.around,i.aroundPoint);else{const J=G>U?Math.min(2,K):Math.max(.5,K),se=Math.pow(J,1-Q),oe=dl(o,X,W,Q*se);e.setCenter(oe.wrap())}if(T){const J=c.y.number(U,G,Q)+Vt(0,e.center.lat);e.setZoom(J)}},isZooming:T,elevationCenter:V}}handleFlyTo(e,i){const a=i.zoom!==void 0,o=e.center,u=e.zoom,f=!e.isPaddingEqual(i.padding),_=e.getConstrained(c.N.convert(i.center||i.locationAtOffset),u).center,y=a?+i.zoom:e.zoom+Vt(e.center.lat,_.lat),v=e.clone();v.setCenter(_),f&&v.setPadding(i.padding),v.setZoom(y),v.setBearing(i.bearing);const T=new c.P(c.ab(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),c.ab(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));v.setLocationAtPoint(_,T);const P=v.center;ni(e,P);const S=function(X,W,K){const Q=ct(W),J=ct(K),se=c.aS(Q,J),oe=Math.acos(se),me=ul(X);return oe/(2*Math.PI)*me}(e,o,P),A=u+Vt(o.lat,0),R=y+Vt(P.lat,0),V=c.aG(R-A);let N;if(typeof i.minZoom=="number"){const X=+i.minZoom+Vt(P.lat,0),W=Math.min(X,A,R)+Vt(0,P.lat),K=e.getConstrained(P,W).zoom+Vt(P.lat,0);N=c.aG(K-A)}const U=c.bk(o.lng,P.lng),G=c.bk(o.lat,P.lat);return{easeFunc:(X,W,K,Q)=>{const J=dl(o,U,G,K),se=X===1?P:J;e.setCenter(se.wrap());const oe=A+c.a8(W);e.setZoom(X===1?y:oe+Vt(0,se.lat))},scaleOfZoom:V,targetCenter:P,scaleOfMinZoom:N,pixelPathLength:S}}static solveVectorScale(e,i,a,o,u){const f=o==="x"?[a[0],a[4],a[8],a[12]]:[a[1],a[5],a[9],a[13]],_=[a[3],a[7],a[11],a[15]],y=e[0]*f[0]+e[1]*f[1]+e[2]*f[2],v=e[0]*_[0]+e[1]*_[1]+e[2]*_[2],T=i[0]*f[0]+i[1]*f[1]+i[2]*f[2],P=i[0]*_[0]+i[1]*_[1]+i[2]*_[2];return T+u*v===y+u*P||_[3]*(y-T)+f[3]*(P-v)+y*P==T*v?null:(T+f[3]-u*P-u*_[3])/(T-y-u*P+u*v)}static getLesserNonNegativeNonNull(e,i){return i!==null&&i>=0&&i<e?i:e}}class ls{constructor(e){this._globe=e,this._mercatorCameraHelper=new Fs,this._verticalPerspectiveCameraHelper=new gi}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(e,i){return this.currentHelper.handlePanInertia(e,i)}handleMapControlsRollPitchBearingZoom(e,i){return this.currentHelper.handleMapControlsRollPitchBearingZoom(e,i)}handleMapControlsPan(e,i,a){this.currentHelper.handleMapControlsPan(e,i,a)}cameraForBoxAndBearing(e,i,a,o,u){return this.currentHelper.cameraForBoxAndBearing(e,i,a,o,u)}handleJumpToCenterZoom(e,i){this.currentHelper.handleJumpToCenterZoom(e,i)}handleEaseTo(e,i){return this.currentHelper.handleEaseTo(e,i)}handleFlyTo(e,i){return this.currentHelper.handleFlyTo(e,i)}}const In=(h,e)=>c.t(h,e&&e.filter(i=>i.identifier!=="source.canvas")),Xa=c.br();class Ei extends c.E{constructor(e,i={}){super(),this._rtlPluginLoaded=()=>{for(const a in this.sourceCaches){const o=this.sourceCaches[a].getSource().type;o!=="vector"&&o!=="geojson"||this.sourceCaches[a].reload()}},this.map=e,this.dispatcher=new Ur(Vr(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(a,o)=>this.getGlyphs(a,o)),this.dispatcher.registerMessageHandler("GI",(a,o)=>this.getImages(a,o)),this.imageManager=new Rs,this.imageManager.setEventedParent(this),this.glyphManager=new ei(e._requestManager,i.localIdeographFontFamily),this.lineAtlas=new Nr(256,512),this.crossTileSymbolIndex=new tn,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new c.bs,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",c.bt()),tr().on(Xr,this._rtlPluginLoaded),this.on("data",a=>{if(a.dataType!=="source"||a.sourceDataType!=="metadata")return;const o=this.sourceCaches[a.sourceId];if(!o)return;const u=o.getSource();if(u&&u.vectorLayerIds)for(const f in this._layers){const _=this._layers[f];_.source===u.id&&this._validateLayer(_)}})}loadURL(e,i={},a){this.fire(new c.k("dataloading",{dataType:"style"})),i.validate=typeof i.validate!="boolean"||i.validate;const o=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const u=this._loadStyleRequest;c.h(o,this._loadStyleRequest).then(f=>{this._loadStyleRequest=null,this._load(f.data,i,a)}).catch(f=>{this._loadStyleRequest=null,f&&!u.signal.aborted&&this.fire(new c.j(f))})}loadJSON(e,i={},a){this.fire(new c.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,Ze.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,i.validate=i.validate!==!1,this._load(e,i,a)}).catch(()=>{})}loadEmpty(){this.fire(new c.k("dataloading",{dataType:"style"})),this._load(Xa,{validate:!1})}_load(e,i,a){var o,u;const f=i.transformStyle?i.transformStyle(a,e):e;if(!i.validate||!In(this,c.u(f))){this._loaded=!0,this.stylesheet=f;for(const _ in f.sources)this.addSource(_,f.sources[_],{validate:!1});f.sprite?this._loadSprite(f.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(f.glyphs),this._createLayers(),this.light=new yn(this.stylesheet.light),this._setProjectionInternal(((o=this.stylesheet.projection)===null||o===void 0?void 0:o.type)||"mercator"),this.sky=new jr(this.stylesheet.sky),this.map.setTerrain((u=this.stylesheet.terrain)!==null&&u!==void 0?u:null),this.fire(new c.k("data",{dataType:"style"})),this.fire(new c.k("style.load"))}}_createLayers(){const e=c.bu(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map(i=>i.id),this._layers={},this._serializedLayers=null;for(const i of e){const a=c.bv(i);a.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=a}}_loadSprite(e,i=!1,a=void 0){let o;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(u,f,_,y){return c._(this,void 0,void 0,function*(){const v=Mt(u),T=_>1?"@2x":"",P={},S={};for(const{id:A,url:R}of v){const V=f.transformRequest(ft(R,T,".json"),"SpriteJSON");P[A]=c.h(V,y);const N=f.transformRequest(ft(R,T,".png"),"SpriteImage");S[A]=oi.getImage(N,y)}return yield Promise.all([...Object.values(P),...Object.values(S)]),function(A,R){return c._(this,void 0,void 0,function*(){const V={};for(const N in A){V[N]={};const U=Ze.getImageCanvasContext((yield R[N]).data),G=(yield A[N]).data;for(const X in G){const{width:W,height:K,x:Q,y:J,sdf:se,pixelRatio:oe,stretchX:me,stretchY:ye,content:de,textFitWidth:Se,textFitHeight:Pe}=G[X];V[N][X]={data:null,pixelRatio:oe,sdf:se,stretchX:me,stretchY:ye,content:de,textFitWidth:Se,textFitHeight:Pe,spriteData:{width:W,height:K,x:Q,y:J,context:U}}}}return V})}(P,S)})}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(u=>{if(this._spriteRequest=null,u)for(const f in u){this._spritesImagesIds[f]=[];const _=this._spritesImagesIds[f]?this._spritesImagesIds[f].filter(y=>!(y in u)):[];for(const y of _)this.imageManager.removeImage(y),this._changedImages[y]=!0;for(const y in u[f]){const v=f==="default"?y:`${f}:${y}`;this._spritesImagesIds[f].push(v),v in this.imageManager.images?this.imageManager.updateImage(v,u[f][y],!1):this.imageManager.addImage(v,u[f][y]),i&&(this._changedImages[v]=!0)}}}).catch(u=>{this._spriteRequest=null,o=u,this.fire(new c.j(o))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new c.k("data",{dataType:"style"})),a&&a(o)})}_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 c.k("data",{dataType:"style"}))}_validateLayer(e){const i=this.sourceCaches[e.source];if(!i)return;const a=e.sourceLayer;if(!a)return;const o=i.getSource();(o.type==="geojson"||o.vectorLayerIds&&o.vectorLayerIds.indexOf(a)===-1)&&this.fire(new c.j(new Error(`Source layer "${a}" does not exist on source "${o.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,i=!1){const a=this._serializedAllLayers();if(!e||e.length===0)return Object.values(i?c.bw(a):a);const o=[];for(const u of e)if(a[u]){const f=i?c.bw(a[u]):a[u];o.push(f)}return o}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const i=Object.keys(this._layers);for(const a of i){const o=this._layers[a];o.type!=="custom"&&(e[a]=o.serialize())}return e}hasTransitions(){var e,i,a;if(!((e=this.light)===null||e===void 0)&&e.hasTransition()||!((i=this.sky)===null||i===void 0)&&i.hasTransition()||!((a=this.projection)===null||a===void 0)&&a.hasTransition())return!0;for(const o in this.sourceCaches)if(this.sourceCaches[o].hasTransition())return!0;for(const o in this._layers)if(this._layers[o].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(i){const o=Object.keys(this._updatedLayers),u=Object.keys(this._removedLayers);(o.length||u.length)&&this._updateWorkerLayers(o,u);for(const f in this._updatedSources){const _=this._updatedSources[f];if(_==="reload")this._reloadSource(f);else{if(_!=="clear")throw new Error(`Invalid action ${_}`);this._clearSource(f)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const f in this._updatedPaintProps)this._layers[f].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const a={};for(const o in this.sourceCaches){const u=this.sourceCaches[o];a[o]=u.used,u.used=!1}for(const o of this._order){const u=this._layers[o];u.recalculate(e,this._availableImages),!u.isHidden(e.zoom)&&u.source&&(this.sourceCaches[u.source].used=!0)}for(const o in a){const u=this.sourceCaches[o];!!a[o]!=!!u.used&&u.fire(new c.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:o}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,i&&this.fire(new c.k("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const i in this.sourceCaches)this.sourceCaches[i].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,i){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:i})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,i={}){var a;this._checkLoaded();const o=this.serialize();if(e=i.transformStyle?i.transformStyle(o,e):e,((a=i.validate)===null||a===void 0||a)&&In(this,c.u(e)))return!1;(e=c.bw(e)).layers=c.bu(e.layers);const u=c.bx(o,e),f=this._getOperationsToPerform(u);if(f.unimplemented.length>0)throw new Error(`Unimplemented: ${f.unimplemented.join(", ")}.`);if(f.operations.length===0)return!1;for(const _ of f.operations)_();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const i=[],a=[];for(const o of e)switch(o.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":i.push(()=>this.addLayer.apply(this,o.args));break;case"removeLayer":i.push(()=>this.removeLayer.apply(this,o.args));break;case"setPaintProperty":i.push(()=>this.setPaintProperty.apply(this,o.args));break;case"setLayoutProperty":i.push(()=>this.setLayoutProperty.apply(this,o.args));break;case"setFilter":i.push(()=>this.setFilter.apply(this,o.args));break;case"addSource":i.push(()=>this.addSource.apply(this,o.args));break;case"removeSource":i.push(()=>this.removeSource.apply(this,o.args));break;case"setLayerZoomRange":i.push(()=>this.setLayerZoomRange.apply(this,o.args));break;case"setLight":i.push(()=>this.setLight.apply(this,o.args));break;case"setGeoJSONSourceData":i.push(()=>this.setGeoJSONSourceData.apply(this,o.args));break;case"setGlyphs":i.push(()=>this.setGlyphs.apply(this,o.args));break;case"setSprite":i.push(()=>this.setSprite.apply(this,o.args));break;case"setTerrain":i.push(()=>this.map.setTerrain.apply(this,o.args));break;case"setSky":i.push(()=>this.setSky.apply(this,o.args));break;case"setProjection":this.setProjection.apply(this,o.args);break;case"setTransition":i.push(()=>{});break;default:a.push(o.command)}return{operations:i,unimplemented:a}}addImage(e,i){if(this.getImage(e))return this.fire(new c.j(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e)}updateImage(e,i){this.imageManager.updateImage(e,i)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new c.j(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new c.k("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,a={}){if(this._checkLoaded(),this.sourceCaches[e]!==void 0)throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(c.u.source,`sources.${e}`,i,null,a))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const o=this.sourceCaches[e]=new D(e,i,this.dispatcher);o.style=this,o.setEventedParent(this,()=>({isSourceLoaded:o.loaded(),source:o.serialize(),sourceId:e})),o.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error("There is no source with this ID");for(const a in this._layers)if(this._layers[a].source===e)return this.fire(new c.j(new Error(`Source "${e}" cannot be removed while layer "${a}" is using it.`)));const i=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],i.fire(new c.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,i){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error(`There is no source with this ID=${e}`);const a=this.sourceCaches[e].getSource();if(a.type!=="geojson")throw new Error(`geojsonSource.type is ${a.type}, which is !== 'geojson`);a.setData(i),this._changed=!0}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,i,a={}){this._checkLoaded();const o=e.id;if(this.getLayer(o))return void this.fire(new c.j(new Error(`Layer "${o}" already exists on this map.`)));let u;if(e.type==="custom"){if(In(this,c.by(e)))return;u=c.bv(e)}else{if("source"in e&&typeof e.source=="object"&&(this.addSource(o,e.source),e=c.bw(e),e=c.e(e,{source:o})),this._validate(c.u.layer,`layers.${o}`,e,{arrayIndex:-1},a))return;u=c.bv(e),this._validateLayer(u),u.setEventedParent(this,{layer:{id:o}})}const f=i?this._order.indexOf(i):this._order.length;if(i&&f===-1)this.fire(new c.j(new Error(`Cannot add layer "${o}" before non-existing layer "${i}".`)));else{if(this._order.splice(f,0,o),this._layerOrderChanged=!0,this._layers[o]=u,this._removedLayers[o]&&u.source&&u.type!=="custom"){const _=this._removedLayers[o];delete this._removedLayers[o],_.type!==u.type?this._updatedSources[u.source]="clear":(this._updatedSources[u.source]="reload",this.sourceCaches[u.source].pause())}this._updateLayer(u),u.onAdd&&u.onAdd(this.map)}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new c.j(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const a=this._order.indexOf(e);this._order.splice(a,1);const o=i?this._order.indexOf(i):this._order.length;i&&o===-1?this.fire(new c.j(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(o,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new c.j(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const a=this._order.indexOf(e);this._order.splice(a,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,i,a){this._checkLoaded();const o=this.getLayer(e);o?o.minzoom===i&&o.maxzoom===a||(i!=null&&(o.minzoom=i),a!=null&&(o.maxzoom=a),this._updateLayer(o)):this.fire(new c.j(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,i,a={}){this._checkLoaded();const o=this.getLayer(e);if(o){if(!c.bz(o.filter,i))return i==null?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(c.u.filter,`layers.${o.id}.filter`,i,null,a)||(o.filter=c.bw(i),this._updateLayer(o)))}else this.fire(new c.j(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return c.bw(this.getLayer(e).filter)}setLayoutProperty(e,i,a,o={}){this._checkLoaded();const u=this.getLayer(e);u?c.bz(u.getLayoutProperty(i),a)||(u.setLayoutProperty(i,a,o),this._updateLayer(u)):this.fire(new c.j(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,i){const a=this.getLayer(e);if(a)return a.getLayoutProperty(i);this.fire(new c.j(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,i,a,o={}){this._checkLoaded();const u=this.getLayer(e);u?c.bz(u.getPaintProperty(i),a)||(u.setPaintProperty(i,a,o)&&this._updateLayer(u),this._changed=!0,this._updatedPaintProps[e]=!0,this._serializedLayers=null):this.fire(new c.j(new Error(`Cannot style non-existing layer "${e}".`)))}getPaintProperty(e,i){return this.getLayer(e).getPaintProperty(i)}setFeatureState(e,i){this._checkLoaded();const a=e.source,o=e.sourceLayer,u=this.sourceCaches[a];if(u===void 0)return void this.fire(new c.j(new Error(`The source '${a}' does not exist in the map's style.`)));const f=u.getSource().type;f==="geojson"&&o?this.fire(new c.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):f!=="vector"||o?(e.id===void 0&&this.fire(new c.j(new Error("The feature id parameter must be provided."))),u.setFeatureState(o,e.id,i)):this.fire(new c.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,i){this._checkLoaded();const a=e.source,o=this.sourceCaches[a];if(o===void 0)return void this.fire(new c.j(new Error(`The source '${a}' does not exist in the map's style.`)));const u=o.getSource().type,f=u==="vector"?e.sourceLayer:void 0;u!=="vector"||f?i&&typeof e.id!="string"&&typeof e.id!="number"?this.fire(new c.j(new Error("A feature id is required to remove its specific state property."))):o.removeFeatureState(f,e.id,i):this.fire(new c.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const i=e.source,a=e.sourceLayer,o=this.sourceCaches[i];if(o!==void 0)return o.getSource().type!=="vector"||a?(e.id===void 0&&this.fire(new c.j(new Error("The feature id parameter must be provided."))),o.getFeatureState(a,e.id)):void this.fire(new c.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new c.j(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return c.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=c.bA(this.sourceCaches,u=>u.serialize()),i=this._serializeByIds(this._order,!0),a=this.map.getTerrain()||void 0,o=this.stylesheet;return c.bB({version:o.version,name:o.name,metadata:o.metadata,light:o.light,sky:o.sky,center:o.center,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,sprite:o.sprite,glyphs:o.glyphs,transition:o.transition,projection:o.projection,sources:e,layers:i,terrain:a},u=>u!==void 0)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.sourceCaches[e.source].getSource().type!=="raster"&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const i=f=>this._layers[f].type==="fill-extrusion",a={},o=[];for(let f=this._order.length-1;f>=0;f--){const _=this._order[f];if(i(_)){a[_]=f;for(const y of e){const v=y[_];if(v)for(const T of v)o.push(T)}}}o.sort((f,_)=>_.intersectionZ-f.intersectionZ);const u=[];for(let f=this._order.length-1;f>=0;f--){const _=this._order[f];if(i(_))for(let y=o.length-1;y>=0;y--){const v=o[y].feature;if(a[v.layer.id]<f)break;u.push(v),o.pop()}else for(const y of e){const v=y[_];if(v)for(const T of v)u.push(T.feature)}}return u}queryRenderedFeatures(e,i,a){i&&i.filter&&this._validate(c.u.filter,"queryRenderedFeatures.filter",i.filter,null,i);const o={};if(i&&i.layers){if(!(Array.isArray(i.layers)||i.layers instanceof Set))return this.fire(new c.j(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const v of i.layers){const T=this._layers[v];if(!T)return this.fire(new c.j(new Error(`The layer '${v}' does not exist in the map's style and cannot be queried for features.`))),[];o[T.source]=!0}}const u=[];i.availableImages=this._availableImages;const f=this._serializedAllLayers(),_=i.layers instanceof Set?i.layers:Array.isArray(i.layers)?new Set(i.layers):null,y=Object.assign(Object.assign({},i),{layers:_});for(const v in this.sourceCaches)i.layers&&!o[v]||u.push(Yn(this.sourceCaches[v],this._layers,f,e,y,a));return this.placement&&u.push(function(v,T,P,S,A,R,V){const N={},U=R.queryRenderedSymbols(S),G=[];for(const X of Object.keys(U).map(Number))G.push(V[X]);G.sort(ti);for(const X of G){const W=X.featureIndex.lookupSymbolFeatures(U[X.bucketInstanceId],T,X.bucketIndex,X.sourceLayerIndex,A.filter,A.layers,A.availableImages,v);for(const K in W){const Q=N[K]=N[K]||[],J=W[K];J.sort((se,oe)=>{const me=X.featureSortOrder;if(me){const ye=me.indexOf(se.featureIndex);return me.indexOf(oe.featureIndex)-ye}return oe.featureIndex-se.featureIndex});for(const se of J)Q.push(se)}}return function(X,W,K){for(const Q in X)for(const J of X[Q])Ot(J,K[W[Q].source]);return X}(N,v,P)}(this._layers,f,this.sourceCaches,e,y,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(u)}querySourceFeatures(e,i){i&&i.filter&&this._validate(c.u.filter,"querySourceFeatures.filter",i.filter,null,i);const a=this.sourceCaches[e];return a?function(o,u){const f=o.getRenderableIds().map(v=>o.getTileByID(v)),_=[],y={};for(let v=0;v<f.length;v++){const T=f[v],P=T.tileID.canonical.key;y[P]||(y[P]=!0,T.querySourceFeatures(_,u))}return _}(a,i):[]}getLight(){return this.light.getLight()}setLight(e,i={}){this._checkLoaded();const a=this.light.getLight();let o=!1;for(const f in e)if(!c.bz(e[f],a[f])){o=!0;break}if(!o)return;const u={now:Ze.now(),transition:c.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,i),this.light.updateTransitions(u)}getProjection(){var e;return(e=this.stylesheet)===null||e===void 0?void 0:e.projection}setProjection(e){if(this._checkLoaded(),this.projection){if(this.projection.name===e.type)return;this.projection.destroy(),delete this.projection}this.stylesheet.projection=e,this._setProjectionInternal(e.type)}getSky(){var e;return(e=this.stylesheet)===null||e===void 0?void 0:e.sky}setSky(e,i={}){this._checkLoaded();const a=this.getSky();let o=!1;if(!e&&!a)return;if(e&&!a)o=!0;else if(!e&&a)o=!0;else for(const f in e)if(!c.bz(e[f],a[f])){o=!0;break}if(!o)return;const u={now:Ze.now(),transition:c.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,i),this.sky.updateTransitions(u)}_setProjectionInternal(e){const i=function(a){if(Array.isArray(a)){const o=new $a({type:a});return{projection:o,transform:new an,cameraHelper:new ls(o)}}switch(a){case"mercator":return{projection:new ts,transform:new ir,cameraHelper:new Fs};case"globe":{const o=new $a({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:o,transform:new an,cameraHelper:new ls(o)}}case"vertical-perspective":return{projection:new hl,transform:new js,cameraHelper:new gi};default:return c.w(`Unknown projection name: ${a}. Falling back to mercator projection.`),{projection:new ts,transform:new ir,cameraHelper:new Fs}}}(e);this.projection=i.projection,this.map.migrateProjection(i.transform,i.cameraHelper);for(const a in this.sourceCaches)this.sourceCaches[a].reload()}_validate(e,i,a,o,u={}){return(!u||u.validate!==!1)&&In(this,e.call(c.u,c.e({key:i,style:this.serialize(),value:a,styleSpec:c.v},o)))}_remove(e=!0){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),tr().off(Xr,this._rtlPluginLoaded);for(const i in this._layers)this._layers[i].setEventedParent(null);for(const i in this.sourceCaches){const a=this.sourceCaches[i];a.setEventedParent(null),a.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(e)}_clearSource(e){this.sourceCaches[e].clearTiles()}_reloadSource(e){this.sourceCaches[e].resume(),this.sourceCaches[e].reload()}_updateSources(e){for(const i in this.sourceCaches)this.sourceCaches[i].update(e,this.map.terrain)}_generateCollisionBoxes(){for(const e in this.sourceCaches)this._reloadSource(e)}_updatePlacement(e,i,a,o,u=!1){let f=!1,_=!1;const y={};for(const v of this._order){const T=this._layers[v];if(T.type!=="symbol")continue;if(!y[T.source]){const S=this.sourceCaches[T.source];y[T.source]=S.getRenderableIds(!0).map(A=>S.getTileByID(A)).sort((A,R)=>R.tileID.overscaledZ-A.tileID.overscaledZ||(A.tileID.isLessThan(R.tileID)?-1:1))}const P=this.crossTileSymbolIndex.addLayer(T,y[T.source],e.center.lng);f=f||P}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((u=u||this._layerOrderChanged||a===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(Ze.now(),e.zoom))&&(this.pauseablePlacement=new ol(e,this.map.terrain,this._order,u,i,a,o,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,y),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(Ze.now()),_=!0),f&&this.pauseablePlacement.placement.setStale()),_||f)for(const v of this._order){const T=this._layers[v];T.type==="symbol"&&this.placement.updateLayerOpacities(T,y[T.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(Ze.now())}_releaseSymbolFadeTiles(){for(const e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,i){return c._(this,void 0,void 0,function*(){const a=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const o=this.sourceCaches[i.source];return o&&o.setDependencies(i.tileID.key,i.type,i.icons),a})}getGlyphs(e,i){return c._(this,void 0,void 0,function*(){const a=yield this.glyphManager.getGlyphs(i.stacks),o=this.sourceCaches[i.source];return o&&o.setDependencies(i.tileID.key,i.type,[""]),a})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(c.u.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}addSprite(e,i,a={},o){this._checkLoaded();const u=[{id:e,url:i}],f=[...Mt(this.stylesheet.sprite),...u];this._validate(c.u.sprite,"sprite",f,null,a)||(this.stylesheet.sprite=f,this._loadSprite(u,!0,o))}removeSprite(e){this._checkLoaded();const i=Mt(this.stylesheet.sprite);if(i.find(a=>a.id===e)){if(this._spritesImagesIds[e])for(const a of this._spritesImagesIds[e])this.imageManager.removeImage(a),this._changedImages[a]=!0;i.splice(i.findIndex(a=>a.id===e),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new c.k("data",{dataType:"style"}))}else this.fire(new c.j(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return Mt(this.stylesheet.sprite)}setSprite(e,i={},a){this._checkLoaded(),e&&this._validate(c.u.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,a):(this._unloadSprite(),a&&a(null)))}}var Ec=c.aA([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Wa{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,i,a,o,u,f,_,y,v){this.context=e;let T=this.boundPaintVertexBuffers.length!==o.length;for(let P=0;!T&&P<o.length;P++)this.boundPaintVertexBuffers[P]!==o[P]&&(T=!0);!this.vao||this.boundProgram!==i||this.boundLayoutVertexBuffer!==a||T||this.boundIndexBuffer!==u||this.boundVertexOffset!==f||this.boundDynamicVertexBuffer!==_||this.boundDynamicVertexBuffer2!==y||this.boundDynamicVertexBuffer3!==v?this.freshBind(i,a,o,u,f,_,y,v):(e.bindVertexArray.set(this.vao),_&&_.bind(),u&&u.dynamicDraw&&u.bind(),y&&y.bind(),v&&v.bind())}freshBind(e,i,a,o,u,f,_,y){const v=e.numAttributes,T=this.context,P=T.gl;this.vao&&this.destroy(),this.vao=T.createVertexArray(),T.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=i,this.boundPaintVertexBuffers=a,this.boundIndexBuffer=o,this.boundVertexOffset=u,this.boundDynamicVertexBuffer=f,this.boundDynamicVertexBuffer2=_,this.boundDynamicVertexBuffer3=y,i.enableAttributes(P,e);for(const S of a)S.enableAttributes(P,e);f&&f.enableAttributes(P,e),_&&_.enableAttributes(P,e),y&&y.enableAttributes(P,e),i.bind(),i.setVertexAttribPointers(P,e,u);for(const S of a)S.bind(),S.setVertexAttribPointers(P,e,u);f&&(f.bind(),f.setVertexAttribPointers(P,e,u)),o&&o.bind(),_&&(_.bind(),_.setVertexAttribPointers(P,e,u)),y&&(y.bind(),y.setVertexAttribPointers(P,e,u)),T.currentNumAttributes=v}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const cs=(h,e,i,a,o)=>({u_texture:0,u_ele_delta:h,u_fog_matrix:e,u_fog_color:i?i.properties.get("fog-color"):c.b4.white,u_fog_ground_blend:i?i.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:o?0:i?i.calculateFogBlendOpacity(a):0,u_horizon_color:i?i.properties.get("horizon-color"):c.b4.white,u_horizon_fog_blend:i?i.properties.get("horizon-fog-blend"):1,u_is_globe_mode:o?1:0}),hs={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 Ns(h){const e=[];for(let i=0;i<h.length;i++){if(h[i]===null)continue;const a=h[i].split(" ");e.push(a.pop())}return e}class Vs{constructor(e,i,a,o,u,f,_,y){const v=e.gl;this.program=v.createProgram();const T=Ns(i.staticAttributes),P=a?a.getBinderAttributes():[],S=T.concat(P),A=qi.prelude.staticUniforms?Ns(qi.prelude.staticUniforms):[],R=_.staticUniforms?Ns(_.staticUniforms):[],V=i.staticUniforms?Ns(i.staticUniforms):[],N=a?a.getBinderUniforms():[],U=A.concat(R).concat(V).concat(N),G=[];for(const oe of U)G.indexOf(oe)<0&&G.push(oe);const X=a?a.defines():[];Fi(v)&&X.unshift("#version 300 es"),u&&X.push("#define OVERDRAW_INSPECTOR;"),f&&X.push("#define TERRAIN3D;"),y&&X.push(y);let W=X.concat(qi.prelude.fragmentSource,_.fragmentSource,i.fragmentSource).join(`
`),K=X.concat(qi.prelude.vertexSource,_.vertexSource,i.vertexSource).join(`
`);Fi(v)||(W=function(oe){return oe.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")}(W),K=function(oe){return oe.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")}(K));const Q=v.createShader(v.FRAGMENT_SHADER);if(v.isContextLost())return void(this.failedToCreate=!0);if(v.shaderSource(Q,W),v.compileShader(Q),!v.getShaderParameter(Q,v.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${v.getShaderInfoLog(Q)}`);v.attachShader(this.program,Q);const J=v.createShader(v.VERTEX_SHADER);if(v.isContextLost())return void(this.failedToCreate=!0);if(v.shaderSource(J,K),v.compileShader(J),!v.getShaderParameter(J,v.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${v.getShaderInfoLog(J)}`);v.attachShader(this.program,J),this.attributes={};const se={};this.numAttributes=S.length;for(let oe=0;oe<this.numAttributes;oe++)S[oe]&&(v.bindAttribLocation(this.program,oe,S[oe]),this.attributes[S[oe]]=oe);if(v.linkProgram(this.program),!v.getProgramParameter(this.program,v.LINK_STATUS))throw new Error(`Program failed to link: ${v.getProgramInfoLog(this.program)}`);v.deleteShader(J),v.deleteShader(Q);for(let oe=0;oe<G.length;oe++){const me=G[oe];if(me&&!se[me]){const ye=v.getUniformLocation(this.program,me);ye&&(se[me]=ye)}}this.fixedUniforms=o(e,se),this.terrainUniforms=((oe,me)=>({u_depth:new c.bC(oe,me.u_depth),u_terrain:new c.bC(oe,me.u_terrain),u_terrain_dim:new c.b5(oe,me.u_terrain_dim),u_terrain_matrix:new c.bD(oe,me.u_terrain_matrix),u_terrain_unpack:new c.bE(oe,me.u_terrain_unpack),u_terrain_exaggeration:new c.b5(oe,me.u_terrain_exaggeration)}))(e,se),this.projectionUniforms=((oe,me)=>({u_projection_matrix:new c.bD(oe,me.u_projection_matrix),u_projection_tile_mercator_coords:new c.bE(oe,me.u_projection_tile_mercator_coords),u_projection_clipping_plane:new c.bE(oe,me.u_projection_clipping_plane),u_projection_transition:new c.b5(oe,me.u_projection_transition),u_projection_fallback_matrix:new c.bD(oe,me.u_projection_fallback_matrix)}))(e,se),this.binderUniforms=a?a.getUniforms(e,se):[]}draw(e,i,a,o,u,f,_,y,v,T,P,S,A,R,V,N,U,G,X){const W=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(a),e.setStencilMode(o),e.setColorMode(u),e.setCullFace(f),y){e.activeTexture.set(W.TEXTURE2),W.bindTexture(W.TEXTURE_2D,y.depthTexture),e.activeTexture.set(W.TEXTURE3),W.bindTexture(W.TEXTURE_2D,y.texture);for(const Q in this.terrainUniforms)this.terrainUniforms[Q].set(y[Q])}if(v)for(const Q in v)this.projectionUniforms[hs[Q]].set(v[Q]);if(_)for(const Q in this.fixedUniforms)this.fixedUniforms[Q].set(_[Q]);N&&N.setUniforms(e,this.binderUniforms,R,{zoom:V});let K=0;switch(i){case W.LINES:K=2;break;case W.TRIANGLES:K=3;break;case W.LINE_STRIP:K=1}for(const Q of A.get()){const J=Q.vaos||(Q.vaos={});(J[T]||(J[T]=new Wa)).bind(e,this,P,N?N.getPaintVertexBuffers():[],S,Q.vertexOffset,U,G,X),W.drawElements(i,Q.primitiveLength*K,W.UNSIGNED_SHORT,Q.primitiveOffset*K*2)}}}function pl(h,e,i){const a=1/c.at(i,1,e.transform.tileZoom),o=Math.pow(2,i.tileID.overscaledZ),u=i.tileSize*Math.pow(2,e.transform.tileZoom)/o,f=u*(i.tileID.canonical.x+i.tileID.wrap*o),_=u*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[a,h.fromScale,h.toScale],u_fade:h.t,u_pixel_coord_upper:[f>>16,_>>16],u_pixel_coord_lower:[65535&f,65535&_]}}const on=(h,e,i,a)=>{const o=h.style.light,u=o.properties.get("position"),f=[u.x,u.y,u.z],_=c.bI();o.properties.get("anchor")==="viewport"&&c.bJ(_,h.transform.bearingInRadians),c.bK(f,f,_);const y=h.transform.transformLightDirection(f),v=o.properties.get("color");return{u_lightpos:f,u_lightpos_globe:y,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[v.r,v.g,v.b],u_vertical_gradient:+e,u_opacity:i,u_fill_translate:a}},Ac=(h,e,i,a,o,u,f)=>c.e(on(h,e,i,a),pl(u,h,f),{u_height_factor:-Math.pow(2,o.overscaledZ)/f.tileSize/8}),Ka=(h,e,i,a)=>c.e(pl(e,h,i),{u_fill_translate:a}),zc=(h,e)=>({u_world:h,u_fill_translate:e}),fl=(h,e,i,a,o)=>c.e(Ka(h,e,i,o),{u_world:a}),Ya=(h,e,i,a,o)=>{const u=h.transform;let f,_,y=0;if(i.paint.get("circle-pitch-alignment")==="map"){const v=c.at(e,1,u.zoom);f=!0,_=[v,v],y=v/(c.X*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*o}else f=!1,_=u.pixelsToGLUnits;return{u_camera_to_center_distance:u.cameraToCenterDistance,u_scale_with_map:+(i.paint.get("circle-pitch-scale")==="map"),u_pitch_with_map:+f,u_device_pixel_ratio:h.pixelRatio,u_extrude_scale:_,u_globe_extrude_scale:y,u_translate:a}},ml=h=>({u_pixel_extrude_scale:[1/h.width,1/h.height]}),_l=h=>({u_viewport_size:[h.width,h.height]}),Ja=(h,e=1)=>({u_color:h,u_overlay:0,u_overlay_scale:e}),Qa=(h,e,i,a)=>{const o=c.at(h,1,e)/(c.X*Math.pow(2,h.tileID.overscaledZ))*2*Math.PI*a;return{u_extrude_scale:c.at(h,1,e),u_intensity:i,u_globe_extrude_scale:o}},Ir=(h,e,i,a)=>{const o=c.H();c.bL(o,0,h.width,h.height,0,0,1);const u=h.context.gl;return{u_matrix:o,u_world:[u.drawingBufferWidth,u.drawingBufferHeight],u_image:i,u_color_ramp:a,u_opacity:e.paint.get("heatmap-opacity")}},gl=(h,e,i)=>{const a=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),u=i.paint.get("hillshade-accent-color");let f=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);return i.paint.get("hillshade-illumination-anchor")==="viewport"&&(f+=h.transform.bearingInRadians),{u_image:0,u_latrange:us(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),f],u_shadow:a,u_highlight:o,u_accent:u}},yl=(h,e)=>{const i=e.stride,a=c.H();return c.bL(a,0,c.X,-8192,0,0,1),c.J(a,a,[0,-8192,0]),{u_matrix:a,u_image:1,u_dimension:[i,i],u_zoom:h.overscaledZ,u_unpack:e.getUnpackVector()}};function us(h,e){const i=Math.pow(2,e.canonical.z),a=e.canonical.y;return[new c.Y(0,a/i).toLngLat().lat,new c.Y(0,(a+1)/i).toLngLat().lat]}const eo=(h,e,i,a)=>{const o=h.transform;return{u_translation:io(h,e,i),u_ratio:a/c.at(e,1,o.zoom),u_device_pixel_ratio:h.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},Us=(h,e,i,a,o)=>c.e(eo(h,e,i,a),{u_image:0,u_image_height:o}),kc=(h,e,i,a,o)=>{const u=h.transform,f=to(e,u);return{u_translation:io(h,e,i),u_texsize:e.imageAtlasTexture.size,u_ratio:a/c.at(e,1,u.zoom),u_device_pixel_ratio:h.pixelRatio,u_image:0,u_scale:[f,o.fromScale,o.toScale],u_fade:o.t,u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]]}},Dc=(h,e,i,a,o,u)=>{const f=h.lineAtlas,_=to(e,h.transform),y=i.layout.get("line-cap")==="round",v=f.getDash(o.from,y),T=f.getDash(o.to,y),P=v.width*u.fromScale,S=T.width*u.toScale;return c.e(eo(h,e,i,a),{u_patternscale_a:[_/P,-v.height/2],u_patternscale_b:[_/S,-T.height/2],u_sdfgamma:f.width/(256*Math.min(P,S)*h.pixelRatio)/2,u_image:0,u_tex_y_a:v.y,u_tex_y_b:T.y,u_mix:u.t})};function to(h,e){return 1/c.at(h,1,e.tileZoom)}function io(h,e,i){return c.au(h.transform,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const xl=(h,e,i,a,o)=>{return{u_tl_parent:h,u_scale_parent:e,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*a.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:a.paint.get("raster-brightness-min"),u_brightness_high:a.paint.get("raster-brightness-max"),u_saturation_factor:(f=a.paint.get("raster-saturation"),f>0?1-1/(1.001-f):-f),u_contrast_factor:(u=a.paint.get("raster-contrast"),u>0?1/(1-u):1+u),u_spin_weights:ro(a.paint.get("raster-hue-rotate")),u_coords_top:[o[0].x,o[0].y,o[1].x,o[1].y],u_coords_bottom:[o[3].x,o[3].y,o[2].x,o[2].y]};var u,f};function ro(h){h*=Math.PI/180;const e=Math.sin(h),i=Math.cos(h);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const no=(h,e,i,a,o,u,f,_,y,v,T,P,S)=>{const A=f.transform;return{u_is_size_zoom_constant:+(h==="constant"||h==="source"),u_is_size_feature_constant:+(h==="constant"||h==="camera"),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:A.cameraToCenterDistance,u_pitch:A.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:A.width/A.height,u_fade_change:f.options.fadeDuration?f.symbolFadeChange:1,u_label_plane_matrix:_,u_coord_matrix:y,u_is_text:+T,u_pitch_with_map:+a,u_is_along_line:o,u_is_variable_anchor:u,u_texsize:P,u_texture:0,u_translation:v,u_pitched_scale:S}},ds=(h,e,i,a,o,u,f,_,y,v,T,P,S,A)=>{const R=f.transform;return c.e(no(h,e,i,a,o,u,f,_,y,v,T,P,A),{u_gamma_scale:a?Math.cos(R.pitch*Math.PI/180)*R.cameraToCenterDistance:1,u_device_pixel_ratio:f.pixelRatio,u_is_halo:1})},nr=(h,e,i,a,o,u,f,_,y,v,T,P,S)=>c.e(ds(h,e,i,a,o,u,f,_,y,v,!0,T,0,S),{u_texsize_icon:P,u_texture_icon:1}),so=(h,e)=>({u_opacity:h,u_color:e}),ao=(h,e,i,a,o)=>c.e(function(u,f,_,y){const v=_.imageManager.getPattern(u.from.toString()),T=_.imageManager.getPattern(u.to.toString()),{width:P,height:S}=_.imageManager.getPixelSize(),A=Math.pow(2,y.tileID.overscaledZ),R=y.tileSize*Math.pow(2,_.transform.tileZoom)/A,V=R*(y.tileID.canonical.x+y.tileID.wrap*A),N=R*y.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:v.tl,u_pattern_br_a:v.br,u_pattern_tl_b:T.tl,u_pattern_br_b:T.br,u_texsize:[P,S],u_mix:f.t,u_pattern_size_a:v.displaySize,u_pattern_size_b:T.displaySize,u_scale_a:f.fromScale,u_scale_b:f.toScale,u_tile_units_to_pixels:1/c.at(y,1,_.transform.tileZoom),u_pixel_coord_upper:[V>>16,N>>16],u_pixel_coord_lower:[65535&V,65535&N]}}(i,o,e,a),{u_opacity:h}),Zs=(h,e)=>{},vl={fillExtrusion:(h,e)=>({u_lightpos:new c.bG(h,e.u_lightpos),u_lightpos_globe:new c.bG(h,e.u_lightpos_globe),u_lightintensity:new c.b5(h,e.u_lightintensity),u_lightcolor:new c.bG(h,e.u_lightcolor),u_vertical_gradient:new c.b5(h,e.u_vertical_gradient),u_opacity:new c.b5(h,e.u_opacity),u_fill_translate:new c.bH(h,e.u_fill_translate)}),fillExtrusionPattern:(h,e)=>({u_lightpos:new c.bG(h,e.u_lightpos),u_lightpos_globe:new c.bG(h,e.u_lightpos_globe),u_lightintensity:new c.b5(h,e.u_lightintensity),u_lightcolor:new c.bG(h,e.u_lightcolor),u_vertical_gradient:new c.b5(h,e.u_vertical_gradient),u_height_factor:new c.b5(h,e.u_height_factor),u_opacity:new c.b5(h,e.u_opacity),u_fill_translate:new c.bH(h,e.u_fill_translate),u_image:new c.bC(h,e.u_image),u_texsize:new c.bH(h,e.u_texsize),u_pixel_coord_upper:new c.bH(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new c.bH(h,e.u_pixel_coord_lower),u_scale:new c.bG(h,e.u_scale),u_fade:new c.b5(h,e.u_fade)}),fill:(h,e)=>({u_fill_translate:new c.bH(h,e.u_fill_translate)}),fillPattern:(h,e)=>({u_image:new c.bC(h,e.u_image),u_texsize:new c.bH(h,e.u_texsize),u_pixel_coord_upper:new c.bH(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new c.bH(h,e.u_pixel_coord_lower),u_scale:new c.bG(h,e.u_scale),u_fade:new c.b5(h,e.u_fade),u_fill_translate:new c.bH(h,e.u_fill_translate)}),fillOutline:(h,e)=>({u_world:new c.bH(h,e.u_world),u_fill_translate:new c.bH(h,e.u_fill_translate)}),fillOutlinePattern:(h,e)=>({u_world:new c.bH(h,e.u_world),u_image:new c.bC(h,e.u_image),u_texsize:new c.bH(h,e.u_texsize),u_pixel_coord_upper:new c.bH(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new c.bH(h,e.u_pixel_coord_lower),u_scale:new c.bG(h,e.u_scale),u_fade:new c.b5(h,e.u_fade),u_fill_translate:new c.bH(h,e.u_fill_translate)}),circle:(h,e)=>({u_camera_to_center_distance:new c.b5(h,e.u_camera_to_center_distance),u_scale_with_map:new c.bC(h,e.u_scale_with_map),u_pitch_with_map:new c.bC(h,e.u_pitch_with_map),u_extrude_scale:new c.bH(h,e.u_extrude_scale),u_device_pixel_ratio:new c.b5(h,e.u_device_pixel_ratio),u_globe_extrude_scale:new c.b5(h,e.u_globe_extrude_scale),u_translate:new c.bH(h,e.u_translate)}),collisionBox:(h,e)=>({u_pixel_extrude_scale:new c.bH(h,e.u_pixel_extrude_scale)}),collisionCircle:(h,e)=>({u_viewport_size:new c.bH(h,e.u_viewport_size)}),debug:(h,e)=>({u_color:new c.bF(h,e.u_color),u_overlay:new c.bC(h,e.u_overlay),u_overlay_scale:new c.b5(h,e.u_overlay_scale)}),depth:Zs,clippingMask:Zs,heatmap:(h,e)=>({u_extrude_scale:new c.b5(h,e.u_extrude_scale),u_intensity:new c.b5(h,e.u_intensity),u_globe_extrude_scale:new c.b5(h,e.u_globe_extrude_scale)}),heatmapTexture:(h,e)=>({u_matrix:new c.bD(h,e.u_matrix),u_world:new c.bH(h,e.u_world),u_image:new c.bC(h,e.u_image),u_color_ramp:new c.bC(h,e.u_color_ramp),u_opacity:new c.b5(h,e.u_opacity)}),hillshade:(h,e)=>({u_image:new c.bC(h,e.u_image),u_latrange:new c.bH(h,e.u_latrange),u_light:new c.bH(h,e.u_light),u_shadow:new c.bF(h,e.u_shadow),u_highlight:new c.bF(h,e.u_highlight),u_accent:new c.bF(h,e.u_accent)}),hillshadePrepare:(h,e)=>({u_matrix:new c.bD(h,e.u_matrix),u_image:new c.bC(h,e.u_image),u_dimension:new c.bH(h,e.u_dimension),u_zoom:new c.b5(h,e.u_zoom),u_unpack:new c.bE(h,e.u_unpack)}),line:(h,e)=>({u_translation:new c.bH(h,e.u_translation),u_ratio:new c.b5(h,e.u_ratio),u_device_pixel_ratio:new c.b5(h,e.u_device_pixel_ratio),u_units_to_pixels:new c.bH(h,e.u_units_to_pixels)}),lineGradient:(h,e)=>({u_translation:new c.bH(h,e.u_translation),u_ratio:new c.b5(h,e.u_ratio),u_device_pixel_ratio:new c.b5(h,e.u_device_pixel_ratio),u_units_to_pixels:new c.bH(h,e.u_units_to_pixels),u_image:new c.bC(h,e.u_image),u_image_height:new c.b5(h,e.u_image_height)}),linePattern:(h,e)=>({u_translation:new c.bH(h,e.u_translation),u_texsize:new c.bH(h,e.u_texsize),u_ratio:new c.b5(h,e.u_ratio),u_device_pixel_ratio:new c.b5(h,e.u_device_pixel_ratio),u_image:new c.bC(h,e.u_image),u_units_to_pixels:new c.bH(h,e.u_units_to_pixels),u_scale:new c.bG(h,e.u_scale),u_fade:new c.b5(h,e.u_fade)}),lineSDF:(h,e)=>({u_translation:new c.bH(h,e.u_translation),u_ratio:new c.b5(h,e.u_ratio),u_device_pixel_ratio:new c.b5(h,e.u_device_pixel_ratio),u_units_to_pixels:new c.bH(h,e.u_units_to_pixels),u_patternscale_a:new c.bH(h,e.u_patternscale_a),u_patternscale_b:new c.bH(h,e.u_patternscale_b),u_sdfgamma:new c.b5(h,e.u_sdfgamma),u_image:new c.bC(h,e.u_image),u_tex_y_a:new c.b5(h,e.u_tex_y_a),u_tex_y_b:new c.b5(h,e.u_tex_y_b),u_mix:new c.b5(h,e.u_mix)}),raster:(h,e)=>({u_tl_parent:new c.bH(h,e.u_tl_parent),u_scale_parent:new c.b5(h,e.u_scale_parent),u_buffer_scale:new c.b5(h,e.u_buffer_scale),u_fade_t:new c.b5(h,e.u_fade_t),u_opacity:new c.b5(h,e.u_opacity),u_image0:new c.bC(h,e.u_image0),u_image1:new c.bC(h,e.u_image1),u_brightness_low:new c.b5(h,e.u_brightness_low),u_brightness_high:new c.b5(h,e.u_brightness_high),u_saturation_factor:new c.b5(h,e.u_saturation_factor),u_contrast_factor:new c.b5(h,e.u_contrast_factor),u_spin_weights:new c.bG(h,e.u_spin_weights),u_coords_top:new c.bE(h,e.u_coords_top),u_coords_bottom:new c.bE(h,e.u_coords_bottom)}),symbolIcon:(h,e)=>({u_is_size_zoom_constant:new c.bC(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new c.bC(h,e.u_is_size_feature_constant),u_size_t:new c.b5(h,e.u_size_t),u_size:new c.b5(h,e.u_size),u_camera_to_center_distance:new c.b5(h,e.u_camera_to_center_distance),u_pitch:new c.b5(h,e.u_pitch),u_rotate_symbol:new c.bC(h,e.u_rotate_symbol),u_aspect_ratio:new c.b5(h,e.u_aspect_ratio),u_fade_change:new c.b5(h,e.u_fade_change),u_label_plane_matrix:new c.bD(h,e.u_label_plane_matrix),u_coord_matrix:new c.bD(h,e.u_coord_matrix),u_is_text:new c.bC(h,e.u_is_text),u_pitch_with_map:new c.bC(h,e.u_pitch_with_map),u_is_along_line:new c.bC(h,e.u_is_along_line),u_is_variable_anchor:new c.bC(h,e.u_is_variable_anchor),u_texsize:new c.bH(h,e.u_texsize),u_texture:new c.bC(h,e.u_texture),u_translation:new c.bH(h,e.u_translation),u_pitched_scale:new c.b5(h,e.u_pitched_scale)}),symbolSDF:(h,e)=>({u_is_size_zoom_constant:new c.bC(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new c.bC(h,e.u_is_size_feature_constant),u_size_t:new c.b5(h,e.u_size_t),u_size:new c.b5(h,e.u_size),u_camera_to_center_distance:new c.b5(h,e.u_camera_to_center_distance),u_pitch:new c.b5(h,e.u_pitch),u_rotate_symbol:new c.bC(h,e.u_rotate_symbol),u_aspect_ratio:new c.b5(h,e.u_aspect_ratio),u_fade_change:new c.b5(h,e.u_fade_change),u_label_plane_matrix:new c.bD(h,e.u_label_plane_matrix),u_coord_matrix:new c.bD(h,e.u_coord_matrix),u_is_text:new c.bC(h,e.u_is_text),u_pitch_with_map:new c.bC(h,e.u_pitch_with_map),u_is_along_line:new c.bC(h,e.u_is_along_line),u_is_variable_anchor:new c.bC(h,e.u_is_variable_anchor),u_texsize:new c.bH(h,e.u_texsize),u_texture:new c.bC(h,e.u_texture),u_gamma_scale:new c.b5(h,e.u_gamma_scale),u_device_pixel_ratio:new c.b5(h,e.u_device_pixel_ratio),u_is_halo:new c.bC(h,e.u_is_halo),u_translation:new c.bH(h,e.u_translation),u_pitched_scale:new c.b5(h,e.u_pitched_scale)}),symbolTextAndIcon:(h,e)=>({u_is_size_zoom_constant:new c.bC(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new c.bC(h,e.u_is_size_feature_constant),u_size_t:new c.b5(h,e.u_size_t),u_size:new c.b5(h,e.u_size),u_camera_to_center_distance:new c.b5(h,e.u_camera_to_center_distance),u_pitch:new c.b5(h,e.u_pitch),u_rotate_symbol:new c.bC(h,e.u_rotate_symbol),u_aspect_ratio:new c.b5(h,e.u_aspect_ratio),u_fade_change:new c.b5(h,e.u_fade_change),u_label_plane_matrix:new c.bD(h,e.u_label_plane_matrix),u_coord_matrix:new c.bD(h,e.u_coord_matrix),u_is_text:new c.bC(h,e.u_is_text),u_pitch_with_map:new c.bC(h,e.u_pitch_with_map),u_is_along_line:new c.bC(h,e.u_is_along_line),u_is_variable_anchor:new c.bC(h,e.u_is_variable_anchor),u_texsize:new c.bH(h,e.u_texsize),u_texsize_icon:new c.bH(h,e.u_texsize_icon),u_texture:new c.bC(h,e.u_texture),u_texture_icon:new c.bC(h,e.u_texture_icon),u_gamma_scale:new c.b5(h,e.u_gamma_scale),u_device_pixel_ratio:new c.b5(h,e.u_device_pixel_ratio),u_is_halo:new c.bC(h,e.u_is_halo),u_translation:new c.bH(h,e.u_translation),u_pitched_scale:new c.b5(h,e.u_pitched_scale)}),background:(h,e)=>({u_opacity:new c.b5(h,e.u_opacity),u_color:new c.bF(h,e.u_color)}),backgroundPattern:(h,e)=>({u_opacity:new c.b5(h,e.u_opacity),u_image:new c.bC(h,e.u_image),u_pattern_tl_a:new c.bH(h,e.u_pattern_tl_a),u_pattern_br_a:new c.bH(h,e.u_pattern_br_a),u_pattern_tl_b:new c.bH(h,e.u_pattern_tl_b),u_pattern_br_b:new c.bH(h,e.u_pattern_br_b),u_texsize:new c.bH(h,e.u_texsize),u_mix:new c.b5(h,e.u_mix),u_pattern_size_a:new c.bH(h,e.u_pattern_size_a),u_pattern_size_b:new c.bH(h,e.u_pattern_size_b),u_scale_a:new c.b5(h,e.u_scale_a),u_scale_b:new c.b5(h,e.u_scale_b),u_pixel_coord_upper:new c.bH(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new c.bH(h,e.u_pixel_coord_lower),u_tile_units_to_pixels:new c.b5(h,e.u_tile_units_to_pixels)}),terrain:(h,e)=>({u_texture:new c.bC(h,e.u_texture),u_ele_delta:new c.b5(h,e.u_ele_delta),u_fog_matrix:new c.bD(h,e.u_fog_matrix),u_fog_color:new c.bF(h,e.u_fog_color),u_fog_ground_blend:new c.b5(h,e.u_fog_ground_blend),u_fog_ground_blend_opacity:new c.b5(h,e.u_fog_ground_blend_opacity),u_horizon_color:new c.bF(h,e.u_horizon_color),u_horizon_fog_blend:new c.b5(h,e.u_horizon_fog_blend),u_is_globe_mode:new c.b5(h,e.u_is_globe_mode)}),terrainDepth:(h,e)=>({u_ele_delta:new c.b5(h,e.u_ele_delta)}),terrainCoords:(h,e)=>({u_texture:new c.bC(h,e.u_texture),u_terrain_coords_id:new c.b5(h,e.u_terrain_coords_id),u_ele_delta:new c.b5(h,e.u_ele_delta)}),projectionErrorMeasurement:(h,e)=>({u_input:new c.b5(h,e.u_input),u_output_expected:new c.b5(h,e.u_output_expected)}),atmosphere:(h,e)=>({u_sun_pos:new c.bG(h,e.u_sun_pos),u_atmosphere_blend:new c.b5(h,e.u_atmosphere_blend),u_globe_position:new c.bG(h,e.u_globe_position),u_globe_radius:new c.b5(h,e.u_globe_radius),u_inv_proj_matrix:new c.bD(h,e.u_inv_proj_matrix)}),sky:(h,e)=>({u_sky_color:new c.bF(h,e.u_sky_color),u_horizon_color:new c.bF(h,e.u_horizon_color),u_horizon:new c.bH(h,e.u_horizon),u_horizon_normal:new c.bH(h,e.u_horizon_normal),u_sky_horizon_blend:new c.b5(h,e.u_sky_horizon_blend),u_sky_blend:new c.b5(h,e.u_sky_blend)})};class oo{constructor(e,i,a){this.context=e;const o=e.gl;this.buffer=o.createBuffer(),this.dynamicDraw=!!a,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,i.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete i.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const i=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),i.bufferSubData(i.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const ln={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class lo{constructor(e,i,a,o){this.length=i.length,this.attributes=a,this.itemSize=i.bytesPerElement,this.dynamicDraw=o,this.context=e;const u=e.gl;this.buffer=u.createBuffer(),e.bindVertexBuffer.set(this.buffer),u.bufferData(u.ARRAY_BUFFER,i.arrayBuffer,this.dynamicDraw?u.DYNAMIC_DRAW:u.STATIC_DRAW),this.dynamicDraw||delete i.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 i=this.context.gl;this.bind(),i.bufferSubData(i.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,i){for(let a=0;a<this.attributes.length;a++){const o=i.attributes[this.attributes[a].name];o!==void 0&&e.enableVertexAttribArray(o)}}setVertexAttribPointers(e,i,a){for(let o=0;o<this.attributes.length;o++){const u=this.attributes[o],f=i.attributes[u.name];f!==void 0&&e.vertexAttribPointer(f,u.components,e[ln[u.type]],!1,this.itemSize,u.offset+this.itemSize*(a||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class it{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Rc extends it{getDefault(){return c.b4.transparent}set(e){const i=this.current;(e.r!==i.r||e.g!==i.g||e.b!==i.b||e.a!==i.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class Lc extends it{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class Bc extends it{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class bl extends it{getDefault(){return[!0,!0,!0,!0]}set(e){const i=this.current;(e[0]!==i[0]||e[1]!==i[1]||e[2]!==i[2]||e[3]!==i[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class Fc extends it{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class wl extends it{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class Gs extends it{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const i=this.current;(e.func!==i.func||e.ref!==i.ref||e.mask!==i.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class $s extends it{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const i=this.current;(e[0]!==i[0]||e[1]!==i[1]||e[2]!==i[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class qs extends it{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const i=this.gl;e?i.enable(i.STENCIL_TEST):i.disable(i.STENCIL_TEST),this.current=e,this.dirty=!1}}class co extends it{getDefault(){return[0,1]}set(e){const i=this.current;(e[0]!==i[0]||e[1]!==i[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class cn extends it{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const i=this.gl;e?i.enable(i.DEPTH_TEST):i.disable(i.DEPTH_TEST),this.current=e,this.dirty=!1}}class Cn extends it{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class Ai extends it{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const i=this.gl;e?i.enable(i.BLEND):i.disable(i.BLEND),this.current=e,this.dirty=!1}}class Tl extends it{getDefault(){const e=this.gl;return[e.ONE,e.ZERO]}set(e){const i=this.current;(e[0]!==i[0]||e[1]!==i[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}}class Pl extends it{getDefault(){return c.b4.transparent}set(e){const i=this.current;(e.r!==i.r||e.g!==i.g||e.b!==i.b||e.a!==i.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class ho extends it{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class hn extends it{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const i=this.gl;e?i.enable(i.CULL_FACE):i.disable(i.CULL_FACE),this.current=e,this.dirty=!1}}class Hs extends it{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class Xs extends it{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class ps extends it{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class Ws extends it{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class Ml extends it{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const i=this.current;(e[0]!==i[0]||e[1]!==i[1]||e[2]!==i[2]||e[3]!==i[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class En extends it{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const i=this.gl;i.bindFramebuffer(i.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class An extends it{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const i=this.gl;i.bindRenderbuffer(i.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Sl extends it{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const i=this.gl;i.bindTexture(i.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class uo extends it{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const i=this.gl;i.bindBuffer(i.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class tt extends it{getDefault(){return null}set(e){const i=this.gl;i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Ks extends it{getDefault(){return null}set(e){var i;if(e===this.current&&!this.dirty)return;const a=this.gl;Fi(a)?a.bindVertexArray(e):(i=a.getExtension("OES_vertex_array_object"))===null||i===void 0||i.bindVertexArrayOES(e),this.current=e,this.dirty=!1}}class Oc extends it{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const i=this.gl;i.pixelStorei(i.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class Il extends it{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const i=this.gl;i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class fs extends it{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const i=this.gl;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class po extends it{constructor(e,i){super(e),this.context=e,this.parent=i}getDefault(){return null}}class jc extends po{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const i=this.gl;i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Cl extends po{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const i=this.gl;i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Nc extends po{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const i=this.gl;i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e),this.current=e,this.dirty=!1}}const Ys="Framebuffer is not complete";class Js{constructor(e,i,a,o,u){this.context=e,this.width=i,this.height=a;const f=e.gl,_=this.framebuffer=f.createFramebuffer();if(this.colorAttachment=new jc(e,_),o)this.depthAttachment=u?new Nc(e,_):new Cl(e,_);else if(u)throw new Error("Stencil cannot be set without depth");if(f.checkFramebufferStatus(f.FRAMEBUFFER)!==f.FRAMEBUFFER_COMPLETE)throw new Error(Ys)}destroy(){const e=this.context.gl,i=this.colorAttachment.get();if(i&&e.deleteTexture(i),this.depthAttachment){const a=this.depthAttachment.get();a&&e.deleteRenderbuffer(a)}e.deleteFramebuffer(this.framebuffer)}}class Qs{constructor(e){var i,a;if(this.gl=e,this.clearColor=new Rc(this),this.clearDepth=new Lc(this),this.clearStencil=new Bc(this),this.colorMask=new bl(this),this.depthMask=new Fc(this),this.stencilMask=new wl(this),this.stencilFunc=new Gs(this),this.stencilOp=new $s(this),this.stencilTest=new qs(this),this.depthRange=new co(this),this.depthTest=new cn(this),this.depthFunc=new Cn(this),this.blend=new Ai(this),this.blendFunc=new Tl(this),this.blendColor=new Pl(this),this.blendEquation=new ho(this),this.cullFace=new hn(this),this.cullFaceSide=new Hs(this),this.frontFace=new Xs(this),this.program=new ps(this),this.activeTexture=new Ws(this),this.viewport=new Ml(this),this.bindFramebuffer=new En(this),this.bindRenderbuffer=new An(this),this.bindTexture=new Sl(this),this.bindVertexBuffer=new uo(this),this.bindElementBuffer=new tt(this),this.bindVertexArray=new Ks(this),this.pixelStoreUnpack=new Oc(this),this.pixelStoreUnpackPremultiplyAlpha=new Il(this),this.pixelStoreUnpackFlipY=new fs(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),Fi(e)){this.HALF_FLOAT=e.HALF_FLOAT;const o=e.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(i=e.RGBA16F)!==null&&i!==void 0?i:o==null?void 0:o.RGBA16F_EXT,this.RGB16F=(a=e.RGB16F)!==null&&a!==void 0?a:o==null?void 0:o.RGB16F_EXT,e.getExtension("EXT_color_buffer_float")}else{e.getExtension("EXT_color_buffer_half_float"),e.getExtension("OES_texture_half_float_linear");const o=e.getExtension("OES_texture_half_float");this.HALF_FLOAT=o==null?void 0:o.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,i){return new oo(this,e,i)}createVertexBuffer(e,i,a){return new lo(this,e,i,a)}createRenderbuffer(e,i,a){const o=this.gl,u=o.createRenderbuffer();return this.bindRenderbuffer.set(u),o.renderbufferStorage(o.RENDERBUFFER,e,i,a),this.bindRenderbuffer.set(null),u}createFramebuffer(e,i,a,o){return new Js(this,e,i,a,o)}clear({color:e,depth:i,stencil:a}){const o=this.gl;let u=0;e&&(u|=o.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),i!==void 0&&(u|=o.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(i),this.depthMask.set(!0)),a!==void 0&&(u|=o.STENCIL_BUFFER_BIT,this.clearStencil.set(a),this.stencilMask.set(255)),o.clear(u)}setCullFace(e){e.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){c.bz(e.blendFunction,dt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}createVertexArray(){var e;return Fi(this.gl)?this.gl.createVertexArray():(e=this.gl.getExtension("OES_vertex_array_object"))===null||e===void 0?void 0:e.createVertexArrayOES()}deleteVertexArray(e){var i;return Fi(this.gl)?this.gl.deleteVertexArray(e):(i=this.gl.getExtension("OES_vertex_array_object"))===null||i===void 0?void 0:i.deleteVertexArrayOES(e)}unbindVAO(){this.bindVertexArray.set(null)}}let zn;function ea(h,e,i,a,o){const u=h.context,f=h.transform,_=u.gl,y=h.useProgram("collisionBox"),v=[];let T=0,P=0;for(let U=0;U<a.length;U++){const G=a[U],X=e.getTile(G).getBucket(i);if(!X)continue;const W=o?X.textCollisionBox:X.iconCollisionBox,K=X.collisionCircleArray;K.length>0&&(v.push({circleArray:K,circleOffset:P,coord:G}),T+=K.length/4,P=T),W&&y.draw(u,_.LINES,Ge.disabled,Qe.disabled,h.colorModeForRenderPass(),Ye.disabled,ml(h.transform),h.style.map.terrain&&h.style.map.terrain.getTerrainData(G),f.getProjectionData({overscaledTileID:G,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),i.id,W.layoutVertexBuffer,W.indexBuffer,W.segments,null,h.transform.zoom,null,null,W.collisionVertexBuffer)}if(!o||!v.length)return;const S=h.useProgram("collisionCircle"),A=new c.bM;A.resize(4*T),A._trim();let R=0;for(const U of v)for(let G=0;G<U.circleArray.length/4;G++){const X=4*G,W=U.circleArray[X+0],K=U.circleArray[X+1],Q=U.circleArray[X+2],J=U.circleArray[X+3];A.emplace(R++,W,K,Q,J,0),A.emplace(R++,W,K,Q,J,1),A.emplace(R++,W,K,Q,J,2),A.emplace(R++,W,K,Q,J,3)}(!zn||zn.length<2*T)&&(zn=function(U){const G=2*U,X=new c.bO;X.resize(G),X._trim();for(let W=0;W<G;W++){const K=6*W;X.uint16[K+0]=4*W+0,X.uint16[K+1]=4*W+1,X.uint16[K+2]=4*W+2,X.uint16[K+3]=4*W+2,X.uint16[K+4]=4*W+3,X.uint16[K+5]=4*W+0}return X}(T));const V=u.createIndexBuffer(zn,!0),N=u.createVertexBuffer(A,c.bN.members,!0);for(const U of v){const G=_l(h.transform);S.draw(u,_.TRIANGLES,Ge.disabled,Qe.disabled,h.colorModeForRenderPass(),Ye.disabled,G,h.style.map.terrain&&h.style.map.terrain.getTerrainData(U.coord),null,i.id,N,V,c.aD.simpleSegment(0,2*U.circleOffset,U.circleArray.length,U.circleArray.length/2),null,h.transform.zoom,null,null,null)}N.destroy(),V.destroy()}const El=c.aq(new Float32Array(16));function ta(h,e,i,a,o,u){const{horizontalAlign:f,verticalAlign:_}=c.ay(h);return new c.P((-(f-.5)*e/o+a[0])*u,(-(_-.5)*i/o+a[1])*u)}function ia(h,e,i,a,o,u){const f=e.tileAnchorPoint.add(new c.P(e.translation[0],e.translation[1]));if(e.pitchWithMap){let _=a.mult(u);i||(_=_.rotate(-o));const y=f.add(_);return he(y.x,y.y,e.pitchedLabelPlaneMatrix,e.getElevation).point}if(i){const _=De(e.tileAnchorPoint.x+1,e.tileAnchorPoint.y,e).point.sub(h),y=Math.atan(_.y/_.x)+(_.x<0?Math.PI:0);return h.add(a.rotate(y))}return h.add(a)}function fo(h,e,i,a,o,u,f,_,y,v,T,P){const S=h.text.placedSymbolArray,A=h.text.dynamicLayoutVertexArray,R=h.icon.dynamicLayoutVertexArray,V={};A.clear();for(let N=0;N<S.length;N++){const U=S.get(N),G=U.hidden||!U.crossTileID||h.allowVerticalPlacement&&!U.placedOrientation?null:a[U.crossTileID];if(G){const X=new c.P(U.anchorX,U.anchorY),W={getElevation:P,width:o.width,height:o.height,pitchedLabelPlaneMatrix:u,pitchWithMap:i,transform:o,tileAnchorPoint:X,translation:v,unwrappedTileID:T},K=i?Je(X.x,X.y,W):De(X.x,X.y,W),Q=ne(o.cameraToCenterDistance,K.signedDistanceFromCamera);let J=c.aj(h.textSizeData,_,U)*Q/c.as;i&&(J*=h.tilePixelRatio/f);const{width:se,height:oe,anchor:me,textOffset:ye,textBoxScale:de}=G,Se=ta(me,se,oe,ye,de,J),Pe=o.getPitchedTextCorrection(X.x+v[0],X.y+v[1],T),ve=ia(K.point,W,e,Se,-o.bearingInRadians,Pe),Ee=h.allowVerticalPlacement&&U.placedOrientation===c.ai.vertical?Math.PI/2:0;for(let $e=0;$e<U.numGlyphs;$e++)c.ak(A,ve,Ee);y&&U.associatedIconIndex>=0&&(V[U.associatedIconIndex]={shiftedAnchor:ve,angle:Ee})}else jt(U.numGlyphs,A)}if(y){R.clear();const N=h.icon.placedSymbolArray;for(let U=0;U<N.length;U++){const G=N.get(U);if(G.hidden)jt(G.numGlyphs,R);else{const X=V[U];if(X)for(let W=0;W<G.numGlyphs;W++)c.ak(R,X.shiftedAnchor,X.angle);else jt(G.numGlyphs,R)}}h.icon.dynamicLayoutVertexBuffer.updateData(R)}h.text.dynamicLayoutVertexBuffer.updateData(A)}function Vc(h,e,i){return i.iconsInText&&e?"symbolTextAndIcon":h?"symbolSDF":"symbolIcon"}function ra(h,e,i,a,o,u,f,_,y,v,T,P,S){const A=h.context,R=A.gl,V=h.transform,N=_==="map",U=y==="map",G=_!=="viewport"&&i.layout.get("symbol-placement")!=="point",X=N&&!U&&!G,W=!i.layout.get("symbol-sort-key").isConstant();let K=!1;const Q=h.getDepthModeForSublayer(0,Ge.ReadOnly),J=i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"),se=[],oe=V.getCircleRadiusCorrection();for(const me of a){const ye=e.getTile(me),de=ye.getBucket(i);if(!de)continue;const Se=o?de.text:de.icon;if(!Se||!Se.segments.get().length||!Se.hasVisibleVertices)continue;const Pe=Se.programConfigurations.get(i.id),ve=o||de.sdfIcons,Ee=o?de.textSizeData:de.iconSizeData,$e=U||V.pitch!==0,et=h.useProgram(Vc(ve,o,de),Pe),xt=c.ah(Ee,V.zoom),st=h.style.map.terrain&&h.style.map.terrain.getTerrainData(me);let vt,at,nt,ot,Kt=[0,0],Lt=null;if(o)at=ye.glyphAtlasTexture,nt=R.LINEAR,vt=ye.glyphAtlasTexture.size,de.iconsInText&&(Kt=ye.imageAtlasTexture.size,Lt=ye.imageAtlasTexture,ot=$e||h.options.rotating||h.options.zooming||Ee.kind==="composite"||Ee.kind==="camera"?R.LINEAR:R.NEAREST);else{const lt=i.layout.get("icon-size").constantOr(0)!==1||de.iconsNeedLinear;at=ye.imageAtlasTexture,nt=ve||h.options.rotating||h.options.zooming||lt||$e?R.LINEAR:R.NEAREST,vt=ye.imageAtlasTexture.size}const Bt=c.at(ye,1,h.transform.zoom),ci=le(N,h.transform,Bt),lr=c.H();c.an(lr,ci);const Yi=ie(U,N,h.transform,Bt),yi=c.au(V,ye,u,f),cr=V.getProjectionData({overscaledTileID:me,applyGlobeMatrix:!S,applyTerrainMatrix:!0}),Is=J&&de.hasTextData(),Cs=i.layout.get("icon-text-fit")!=="none"&&Is&&de.hasIconData();if(G){const lt=h.style.map.terrain?(vi,Tt)=>h.style.map.terrain.getElevation(me,vi,Tt):null,bt=i.layout.get("text-rotation-alignment")==="map";Ie(de,h,o,ci,lr,U,v,bt,me.toUnwrapped(),V.width,V.height,yi,lt)}const Un=o&&J||Cs,di=G||Un?El:U?ci:h.transform.clipSpaceToPixelsMatrix,ki=ve&&i.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Di;Di=ve?de.iconsInText?nr(Ee.kind,xt,X,U,G,Un,h,di,Yi,yi,vt,Kt,oe):ds(Ee.kind,xt,X,U,G,Un,h,di,Yi,yi,o,vt,0,oe):no(Ee.kind,xt,X,U,G,Un,h,di,Yi,yi,o,vt,oe);const xi={program:et,buffers:Se,uniformValues:Di,projectionData:cr,atlasTexture:at,atlasTextureIcon:Lt,atlasInterpolation:nt,atlasInterpolationIcon:ot,isSDF:ve,hasHalo:ki};if(W&&de.canOverlap){K=!0;const lt=Se.segments.get();for(const bt of lt)se.push({segments:new c.aD([bt]),sortKey:bt.sortKey,state:xi,terrainData:st})}else se.push({segments:Se.segments,sortKey:0,state:xi,terrainData:st})}K&&se.sort((me,ye)=>me.sortKey-ye.sortKey);for(const me of se){const ye=me.state;if(A.activeTexture.set(R.TEXTURE0),ye.atlasTexture.bind(ye.atlasInterpolation,R.CLAMP_TO_EDGE),ye.atlasTextureIcon&&(A.activeTexture.set(R.TEXTURE1),ye.atlasTextureIcon&&ye.atlasTextureIcon.bind(ye.atlasInterpolationIcon,R.CLAMP_TO_EDGE)),ye.isSDF){const de=ye.uniformValues;ye.hasHalo&&(de.u_is_halo=1,Al(ye.buffers,me.segments,i,h,ye.program,Q,T,P,de,ye.projectionData,me.terrainData)),de.u_is_halo=0}Al(ye.buffers,me.segments,i,h,ye.program,Q,T,P,ye.uniformValues,ye.projectionData,me.terrainData)}}function Al(h,e,i,a,o,u,f,_,y,v,T){const P=a.context;o.draw(P,P.gl.TRIANGLES,u,f,_,Ye.backCCW,y,T,v,i.id,h.layoutVertexBuffer,h.indexBuffer,e,i.paint,a.transform.zoom,h.programConfigurations.get(i.id),h.dynamicLayoutVertexBuffer,h.opacityVertexBuffer)}function zl(h,e,i,a,o){const u=h.context,f=u.gl,_=Qe.disabled,y=new dt([f.ONE,f.ONE],c.b4.transparent,[!0,!0,!0,!0]),v=e.getBucket(i);if(!v)return;const T=a.key;let P=i.heatmapFbos.get(T);P||(P=sa(u,e.tileSize,e.tileSize),i.heatmapFbos.set(T,P)),u.bindFramebuffer.set(P.framebuffer),u.viewport.set([0,0,e.tileSize,e.tileSize]),u.clear({color:c.b4.transparent});const S=v.programConfigurations.get(i.id),A=h.useProgram("heatmap",S,!o),R=h.transform.getProjectionData({overscaledTileID:e.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),V=h.style.map.terrain.getTerrainData(a);A.draw(u,f.TRIANGLES,Ge.disabled,_,y,Ye.disabled,Qa(e,h.transform.zoom,i.paint.get("heatmap-intensity"),1),V,R,i.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,i.paint,h.transform.zoom,S)}function na(h,e,i,a,o){const u=h.context,f=u.gl,_=h.transform;u.setColorMode(h.colorModeForRenderPass());const y=mo(u,e),v=i.key,T=e.heatmapFbos.get(v);if(!T)return;u.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,T.colorAttachment.get()),u.activeTexture.set(f.TEXTURE1),y.bind(f.LINEAR,f.CLAMP_TO_EDGE);const P=_.getProjectionData({overscaledTileID:i,applyTerrainMatrix:o,applyGlobeMatrix:!a});h.useProgram("heatmapTexture").draw(u,f.TRIANGLES,Ge.disabled,Qe.disabled,h.colorModeForRenderPass(),Ye.disabled,Ir(h,e,0,1),null,P,e.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments,e.paint,_.zoom),T.destroy(),e.heatmapFbos.delete(v)}function sa(h,e,i){var a,o;const u=h.gl,f=u.createTexture();u.bindTexture(u.TEXTURE_2D,f),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,u.LINEAR),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,u.LINEAR);const _=(a=h.HALF_FLOAT)!==null&&a!==void 0?a:u.UNSIGNED_BYTE,y=(o=h.RGBA16F)!==null&&o!==void 0?o:u.RGBA;u.texImage2D(u.TEXTURE_2D,0,y,e,i,0,u.RGBA,_,null);const v=h.createFramebuffer(e,i,!1,!1);return v.colorAttachment.set(f),v}function mo(h,e){return e.colorRampTexture||(e.colorRampTexture=new Ct(h,e.colorRamp,h.gl.RGBA)),e.colorRampTexture}function _o(h,e,i,a,o){if(!i||!a||!a.imageAtlas)return;const u=a.imageAtlas.patternPositions;let f=u[i.to.toString()],_=u[i.from.toString()];if(!f&&_&&(f=_),!_&&f&&(_=f),!f||!_){const y=o.getPaintProperty(e);f=u[y],_=u[y]}f&&_&&h.setConstantPatternPositions(f,_)}function ms(h,e,i,a,o,u,f,_){const y=h.context.gl,v="fill-pattern",T=i.paint.get(v),P=T&&T.constantOr(1),S=i.getCrossfadeParameters();let A,R,V,N,U;const G=h.transform,X=i.paint.get("fill-translate"),W=i.paint.get("fill-translate-anchor");f?(R=P&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",A=y.LINES):(R=P?"fillPattern":"fill",A=y.TRIANGLES);const K=T.constantOr(null);for(const Q of a){const J=e.getTile(Q);if(P&&!J.patternsLoaded())continue;const se=J.getBucket(i);if(!se)continue;const oe=se.programConfigurations.get(i.id),me=h.useProgram(R,oe),ye=h.style.map.terrain&&h.style.map.terrain.getTerrainData(Q);P&&(h.context.activeTexture.set(y.TEXTURE0),J.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),oe.updatePaintBuffers(S)),_o(oe,v,K,J,i);const de=G.getProjectionData({overscaledTileID:Q,applyGlobeMatrix:!_,applyTerrainMatrix:!0}),Se=c.au(G,J,X,W);if(f){N=se.indexBuffer2,U=se.segments2;const ve=[y.drawingBufferWidth,y.drawingBufferHeight];V=R==="fillOutlinePattern"&&P?fl(h,S,J,ve,Se):zc(ve,Se)}else N=se.indexBuffer,U=se.segments,V=P?Ka(h,S,J,Se):{u_fill_translate:Se};let Pe;if(h.renderPass==="translucent"&&_){const[ve]=h.getStencilConfigForOverlapAndUpdateStencilID(a);Pe=ve[Q.overscaledZ]}else Pe=h.stencilModeForClipping(Q);me.draw(h.context,A,o,Pe,u,Ye.backCCW,V,ye,de,i.id,se.layoutVertexBuffer,N,U,i.paint,h.transform.zoom,oe)}}function _s(h,e,i,a,o,u,f,_){const y=h.context,v=y.gl,T="fill-extrusion-pattern",P=i.paint.get(T),S=P.constantOr(1),A=i.getCrossfadeParameters(),R=i.paint.get("fill-extrusion-opacity"),V=P.constantOr(null),N=h.transform;for(const U of a){const G=e.getTile(U),X=G.getBucket(i);if(!X)continue;const W=h.style.map.terrain&&h.style.map.terrain.getTerrainData(U),K=X.programConfigurations.get(i.id),Q=h.useProgram(S?"fillExtrusionPattern":"fillExtrusion",K);S&&(h.context.activeTexture.set(v.TEXTURE0),G.imageAtlasTexture.bind(v.LINEAR,v.CLAMP_TO_EDGE),K.updatePaintBuffers(A));const J=N.getProjectionData({overscaledTileID:U,applyGlobeMatrix:!_,applyTerrainMatrix:!0});_o(K,T,V,G,i);const se=c.au(N,G,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),oe=i.paint.get("fill-extrusion-vertical-gradient"),me=S?Ac(h,oe,R,se,U,A,G):on(h,oe,R,se);Q.draw(y,y.gl.TRIANGLES,o,u,f,Ye.backCCW,me,W,J,i.id,X.layoutVertexBuffer,X.indexBuffer,X.segments,i.paint,h.transform.zoom,K,h.style.map.terrain&&X.centroidVertexBuffer)}}function go(h,e,i,a,o,u,f,_,y){var v;const T=h.style.projection,P=h.context,S=h.transform,A=P.gl,R=h.useProgram("hillshade"),V=!h.options.moving;for(const N of a){const U=e.getTile(N),G=U.fbo;if(!G)continue;const X=T.getMeshFromTileID(P,N.canonical,_,!0,"raster"),W=(v=h.style.map.terrain)===null||v===void 0?void 0:v.getTerrainData(N);P.activeTexture.set(A.TEXTURE0),A.bindTexture(A.TEXTURE_2D,G.colorAttachment.get());const K=S.getProjectionData({overscaledTileID:N,aligned:V,applyGlobeMatrix:!y,applyTerrainMatrix:!0});R.draw(P,A.TRIANGLES,u,o[N.overscaledZ],f,Ye.backCCW,gl(h,U,i),W,K,i.id,X.vertexBuffer,X.indexBuffer,X.segments)}}const aa=[new c.P(0,0),new c.P(c.X,0),new c.P(c.X,c.X),new c.P(0,c.X)];function gt(h,e,i,a,o,u,f,_,y=!1,v=!1){const T=a[a.length-1].overscaledZ,P=h.context,S=P.gl,A=h.useProgram("raster"),R=h.transform,V=h.style.projection,N=h.colorModeForRenderPass(),U=!h.options.moving;for(const G of a){const X=h.getDepthModeForSublayer(G.overscaledZ-T,i.paint.get("raster-opacity")===1?Ge.ReadWrite:Ge.ReadOnly,S.LESS),W=e.getTile(G);W.registerFadeDuration(i.paint.get("raster-fade-duration"));const K=e.findLoadedParent(G,0),Q=e.findLoadedSibling(G),J=un(W,K||Q||null,e,i,h.transform,h.style.map.terrain);let se,oe;const me=i.paint.get("raster-resampling")==="nearest"?S.NEAREST:S.LINEAR;P.activeTexture.set(S.TEXTURE0),W.texture.bind(me,S.CLAMP_TO_EDGE,S.LINEAR_MIPMAP_NEAREST),P.activeTexture.set(S.TEXTURE1),K?(K.texture.bind(me,S.CLAMP_TO_EDGE,S.LINEAR_MIPMAP_NEAREST),se=Math.pow(2,K.tileID.overscaledZ-W.tileID.overscaledZ),oe=[W.tileID.canonical.x*se%1,W.tileID.canonical.y*se%1]):W.texture.bind(me,S.CLAMP_TO_EDGE,S.LINEAR_MIPMAP_NEAREST),W.texture.useMipmap&&P.extTextureFilterAnisotropic&&h.transform.pitch>20&&S.texParameterf(S.TEXTURE_2D,P.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,P.extTextureFilterAnisotropicMax);const ye=h.style.map.terrain&&h.style.map.terrain.getTerrainData(G),de=R.getProjectionData({overscaledTileID:G,aligned:U,applyGlobeMatrix:!v,applyTerrainMatrix:!0}),Se=xl(oe||[0,0],se||1,J,i,_),Pe=V.getMeshFromTileID(P,G.canonical,u,f,"raster");A.draw(P,S.TRIANGLES,X,o?o[G.overscaledZ]:Qe.disabled,N,y?Ye.frontCCW:Ye.backCCW,Se,ye,de,i.id,Pe.vertexBuffer,Pe.indexBuffer,Pe.segments)}}function un(h,e,i,a,o,u){const f=a.paint.get("raster-fade-duration");if(!u&&f>0){const _=Ze.now(),y=(_-h.timeAdded)/f,v=e?(_-e.timeAdded)/f:-1,T=i.getSource(),P=Pr(o,{tileSize:T.tileSize,roundZoom:T.roundZoom}),S=!e||Math.abs(e.tileID.overscaledZ-P)>Math.abs(h.tileID.overscaledZ-P),A=S&&h.refreshedUponExpiration?1:c.ab(S?y:1-v,0,1);return h.refreshedUponExpiration&&y>=1&&(h.refreshedUponExpiration=!1),e?{opacity:1,mix:1-A}:{opacity:A,mix:0}}return{opacity:1,mix:0}}const zi=new c.b4(1,0,0,1),yo=new c.b4(0,1,0,1),xo=new c.b4(0,0,1,1),kl=new c.b4(1,0,1,1),kn=new c.b4(0,1,1,1);function Dn(h,e,i,a){gs(h,0,e+i/2,h.transform.width,i,a)}function oa(h,e,i,a){gs(h,e-i/2,0,i,h.transform.height,a)}function gs(h,e,i,a,o,u){const f=h.context,_=f.gl;_.enable(_.SCISSOR_TEST),_.scissor(e*h.pixelRatio,i*h.pixelRatio,a*h.pixelRatio,o*h.pixelRatio),f.clear({color:u}),_.disable(_.SCISSOR_TEST)}function Dl(h,e,i){const a=h.context,o=a.gl,u=h.useProgram("debug"),f=Ge.disabled,_=Qe.disabled,y=h.colorModeForRenderPass(),v="$debug",T=h.style.map.terrain&&h.style.map.terrain.getTerrainData(i);a.activeTexture.set(o.TEXTURE0);const P=e.getTileByID(i.key).latestRawTileData,S=Math.floor((P&&P.byteLength||0)/1024),A=e.getTile(i).tileSize,R=512/Math.min(A,512)*(i.overscaledZ/h.transform.zoom)*.5;let V=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(V+=` => ${i.overscaledZ}`),function(U,G){U.initDebugOverlayCanvas();const X=U.debugOverlayCanvas,W=U.context.gl,K=U.debugOverlayCanvas.getContext("2d");K.clearRect(0,0,X.width,X.height),K.shadowColor="white",K.shadowBlur=2,K.lineWidth=1.5,K.strokeStyle="white",K.textBaseline="top",K.font="bold 36px Open Sans, sans-serif",K.fillText(G,5,5),K.strokeText(G,5,5),U.debugOverlayTexture.update(X),U.debugOverlayTexture.bind(W.LINEAR,W.CLAMP_TO_EDGE)}(h,`${V} ${S}kB`);const N=h.transform.getProjectionData({overscaledTileID:i,applyGlobeMatrix:!0,applyTerrainMatrix:!0});u.draw(a,o.TRIANGLES,f,_,dt.alphaBlended,Ye.disabled,Ja(c.b4.transparent,R),null,N,v,h.debugBuffer,h.quadTriangleIndexBuffer,h.debugSegments),u.draw(a,o.LINE_STRIP,f,_,y,Ye.disabled,Ja(c.b4.red),T,N,v,h.debugBuffer,h.tileBorderIndexBuffer,h.debugSegments)}function vo(h,e,i,a){const{isRenderingGlobe:o}=a,u=h.context,f=u.gl,_=h.transform,y=h.colorModeForRenderPass(),v=h.getDepthModeFor3D(),T=h.useProgram("terrain");u.bindFramebuffer.set(null),u.viewport.set([0,0,h.width,h.height]);for(const P of i){const S=e.getTerrainMesh(P.tileID),A=h.renderToTexture.getTexture(P),R=e.getTerrainData(P.tileID);u.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,A.texture);const V=e.getMeshFrameDelta(_.zoom),N=_.calculateFogMatrix(P.tileID.toUnwrapped()),U=cs(V,N,h.style.sky,_.pitch,o),G=_.getProjectionData({overscaledTileID:P.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});T.draw(u,f.TRIANGLES,v,Qe.disabled,y,Ye.backCCW,U,R,G,"terrain",S.vertexBuffer,S.indexBuffer,S.segments)}}function bo(h,e){if(!e.mesh){const i=new c.aC;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1);const a=new c.aE;a.emplaceBack(0,1,2),a.emplaceBack(0,2,3),e.mesh=new Hi(h.createVertexBuffer(i,Xe.members),h.createIndexBuffer(a),c.aD.simpleSegment(0,0,i.length,a.length))}return e.mesh}class Rl{constructor(e,i){this.context=new Qs(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:c.aq(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=D.maxUnderzooming+D.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new tn}resize(e,i,a){if(this.width=Math.floor(e*a),this.height=Math.floor(i*a),this.pixelRatio=a,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const o of this.style._order)this.style._layers[o].resize()}setup(){const e=this.context,i=new c.aC;i.emplaceBack(0,0),i.emplaceBack(c.X,0),i.emplaceBack(0,c.X),i.emplaceBack(c.X,c.X),this.tileExtentBuffer=e.createVertexBuffer(i,Xe.members),this.tileExtentSegments=c.aD.simpleSegment(0,0,4,2);const a=new c.aC;a.emplaceBack(0,0),a.emplaceBack(c.X,0),a.emplaceBack(0,c.X),a.emplaceBack(c.X,c.X),this.debugBuffer=e.createVertexBuffer(a,Xe.members),this.debugSegments=c.aD.simpleSegment(0,0,4,5);const o=new c.bT;o.emplaceBack(0,0,0,0),o.emplaceBack(c.X,0,c.X,0),o.emplaceBack(0,c.X,0,c.X),o.emplaceBack(c.X,c.X,c.X,c.X),this.rasterBoundsBuffer=e.createVertexBuffer(o,Ec.members),this.rasterBoundsSegments=c.aD.simpleSegment(0,0,4,2);const u=new c.aC;u.emplaceBack(0,0),u.emplaceBack(c.X,0),u.emplaceBack(0,c.X),u.emplaceBack(c.X,c.X),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(u,Xe.members),this.rasterBoundsSegmentsPosOnly=c.aD.simpleSegment(0,0,4,5);const f=new c.aC;f.emplaceBack(0,0),f.emplaceBack(1,0),f.emplaceBack(0,1),f.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(f,Xe.members),this.viewportSegments=c.aD.simpleSegment(0,0,4,2);const _=new c.bU;_.emplaceBack(0),_.emplaceBack(1),_.emplaceBack(3),_.emplaceBack(2),_.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(_);const y=new c.aE;y.emplaceBack(1,0,2),y.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(y);const v=this.context.gl;this.stencilClearMode=new Qe({func:v.ALWAYS,mask:0},0,255,v.ZERO,v.ZERO,v.ZERO),this.tileExtentMesh=new Hi(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const a=c.H();c.bL(a,0,this.width,this.height,0,0,1),c.K(a,a,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const o={mainMatrix:a,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:a};this.useProgram("clippingMask",null,!0).draw(e,i.TRIANGLES,Ge.disabled,this.stencilClearMode,dt.disabled,Ye.disabled,null,null,o,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,i,a){if(this.currentStencilSource===e.source||!e.isTileClipped()||!i||!i.length)return;this.currentStencilSource=e.source,this.nextStencilID+i.length>256&&this.clearStencil();const o=this.context;o.setColorMode(dt.disabled),o.setDepthMode(Ge.disabled);const u={};for(const f of i)u[f.key]=this.nextStencilID++;this._renderTileMasks(u,i,a,!0),this._renderTileMasks(u,i,a,!1),this._tileClippingMaskIDs=u}_renderTileMasks(e,i,a,o){const u=this.context,f=u.gl,_=this.style.projection,y=this.transform,v=this.useProgram("clippingMask");for(const T of i){const P=e[T.key],S=this.style.map.terrain&&this.style.map.terrain.getTerrainData(T),A=_.getMeshFromTileID(this.context,T.canonical,o,!0,"stencil"),R=y.getProjectionData({overscaledTileID:T,applyGlobeMatrix:!0,applyTerrainMatrix:!0});v.draw(u,f.TRIANGLES,Ge.disabled,new Qe({func:f.ALWAYS,mask:0},P,255,f.KEEP,f.KEEP,f.REPLACE),dt.disabled,a?Ye.disabled:Ye.backCCW,null,S,R,"$clipping",A.vertexBuffer,A.indexBuffer,A.segments)}}_renderTilesDepthBuffer(){const e=this.context,i=e.gl,a=this.style.projection,o=this.transform,u=this.useProgram("depth"),f=this.getDepthModeFor3D(),_=j(o,{tileSize:o.tileSize});for(const y of _){const v=this.style.map.terrain&&this.style.map.terrain.getTerrainData(y),T=a.getMeshFromTileID(this.context,y.canonical,!0,!0,"raster"),P=o.getProjectionData({overscaledTileID:y,applyGlobeMatrix:!0,applyTerrainMatrix:!0});u.draw(e,i.TRIANGLES,f,Qe.disabled,dt.disabled,Ye.backCCW,null,v,P,"$clipping",T.vertexBuffer,T.indexBuffer,T.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,i=this.context.gl;return new Qe({func:i.NOTEQUAL,mask:255},e,255,i.KEEP,i.KEEP,i.REPLACE)}stencilModeForClipping(e){const i=this.context.gl;return new Qe({func:i.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,i.KEEP,i.KEEP,i.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const i=this.context.gl,a=e.sort((f,_)=>_.overscaledZ-f.overscaledZ),o=a[a.length-1].overscaledZ,u=a[0].overscaledZ-o+1;if(u>1){this.currentStencilSource=void 0,this.nextStencilID+u>256&&this.clearStencil();const f={};for(let _=0;_<u;_++)f[_+o]=new Qe({func:i.GEQUAL,mask:255},_+this.nextStencilID,255,i.KEEP,i.KEEP,i.REPLACE);return this.nextStencilID+=u,[f,a]}return[{[o]:Qe.disabled},a]}stencilConfigForOverlapTwoPass(e){const i=this.context.gl,a=e.sort((f,_)=>_.overscaledZ-f.overscaledZ),o=a[a.length-1].overscaledZ,u=a[0].overscaledZ-o+1;if(this.clearStencil(),u>1){const f={},_={};for(let y=0;y<u;y++)f[y+o]=new Qe({func:i.GREATER,mask:255},u+1+y,255,i.KEEP,i.KEEP,i.REPLACE),_[y+o]=new Qe({func:i.GREATER,mask:255},1+y,255,i.KEEP,i.KEEP,i.REPLACE);return this.nextStencilID=2*u+1,[f,_,a]}return this.nextStencilID=3,[{[o]:new Qe({func:i.GREATER,mask:255},2,255,i.KEEP,i.KEEP,i.REPLACE)},{[o]:new Qe({func:i.GREATER,mask:255},1,255,i.KEEP,i.KEEP,i.REPLACE)},a]}colorModeForRenderPass(){const e=this.context.gl;return this._showOverdrawInspector?new dt([e.CONSTANT_COLOR,e.ONE],new c.b4(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?dt.unblended:dt.alphaBlended}getDepthModeForSublayer(e,i,a){if(!this.opaquePassEnabledForLayer())return Ge.disabled;const o=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Ge(a||this.context.gl.LEQUAL,i,[o,o])}getDepthModeFor3D(){return new Ge(this.context.gl.LEQUAL,Ge.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,i){var a,o;this.style=e,this.options=i,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(Ze.now()),this.imageManager.beginFrame();const u=this.style._order,f=this.style.sourceCaches,_={},y={},v={},T={isRenderingToTexture:!1,isRenderingGlobe:((a=e.projection)===null||a===void 0?void 0:a.transitionState)>0};for(const S in f){const A=f[S];A.used&&A.prepare(this.context),_[S]=A.getVisibleCoordinates(!1),y[S]=_[S].slice().reverse(),v[S]=A.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let S=0;S<u.length;S++)if(this.style._layers[u[S]].is3D()){this.opaquePassCutoff=S;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const S of u){const A=this.style._layers[S];if(!A.hasOffscreenPass()||A.isHidden(this.transform.zoom))continue;const R=y[A.source];(A.type==="custom"||R.length)&&this.renderLayer(this,f[A.source],A,R,T)}if((o=this.style.projection)===null||o===void 0||o.updateGPUdependent({context:this.context,useProgram:S=>this.useProgram(S)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?c.b4.black:c.b4.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(S,A){const R=S.context,V=R.gl,N=((Q,J,se)=>{const oe=Math.cos(J.rollInRadians),me=Math.sin(J.rollInRadians),ye=wt(J),de=J.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:Q.properties.get("sky-color"),u_horizon_color:Q.properties.get("horizon-color"),u_horizon:[(J.width/2-ye*me)*se,(J.height/2+ye*oe)*se],u_horizon_normal:[-me,oe],u_sky_horizon_blend:Q.properties.get("sky-horizon-blend")*J.height/2*se,u_sky_blend:de}})(A,S.style.map.transform,S.pixelRatio),U=new Ge(V.LEQUAL,Ge.ReadWrite,[0,1]),G=Qe.disabled,X=S.colorModeForRenderPass(),W=S.useProgram("sky"),K=bo(R,A);W.draw(R,V.TRIANGLES,U,G,X,Ye.disabled,N,null,void 0,"sky",K.vertexBuffer,K.indexBuffer,K.segments)}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=u.length-1;this.currentLayer>=0;this.currentLayer--){const S=this.style._layers[u[this.currentLayer]],A=f[S.source],R=_[S.source];this._renderTileClippingMasks(S,R,!1),this.renderLayer(this,A,S,R,T)}this.renderPass="translucent";let P=!1;for(this.currentLayer=0;this.currentLayer<u.length;this.currentLayer++){const S=this.style._layers[u[this.currentLayer]],A=f[S.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(S,T))continue;this.opaquePassEnabledForLayer()||P||(P=!0,T.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const R=(S.type==="symbol"?v:y)[S.source];this._renderTileClippingMasks(S,_[S.source],!1),this.renderLayer(this,A,S,R,T)}if(T.isRenderingGlobe&&function(S,A,R){const V=S.context,N=V.gl,U=S.useProgram("atmosphere"),G=new Ge(N.LEQUAL,Ge.ReadOnly,[0,1]),X=S.transform,W=function(de,Se){const Pe=de.properties.get("position"),ve=[-Pe.x,-Pe.y,-Pe.z],Ee=c.aq(new Float64Array(16));return de.properties.get("anchor")==="map"&&(c.aX(Ee,Ee,Se.rollInRadians),c.aY(Ee,Ee,-Se.pitchInRadians),c.aX(Ee,Ee,Se.bearingInRadians),c.aY(Ee,Ee,Se.center.lat*Math.PI/180),c.bj(Ee,Ee,-Se.center.lng*Math.PI/180)),c.bS(ve,ve,Ee),ve}(R,S.transform),K=X.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),Q=A.properties.get("atmosphere-blend")*K.projectionTransition;if(Q===0)return;const J=Sn(X.worldSize,X.center.lat),se=X.inverseProjectionMatrix,oe=new Float64Array(4);oe[3]=1,c.al(oe,oe,X.modelViewProjectionMatrix),oe[0]/=oe[3],oe[1]/=oe[3],oe[2]/=oe[3],oe[3]=1,c.al(oe,oe,se),oe[0]/=oe[3],oe[1]/=oe[3],oe[2]/=oe[3],oe[3]=1;const me=((de,Se,Pe,ve,Ee)=>({u_sun_pos:de,u_atmosphere_blend:Se,u_globe_position:Pe,u_globe_radius:ve,u_inv_proj_matrix:Ee}))(W,Q,[oe[0],oe[1],oe[2]],J,se),ye=bo(V,A);U.draw(V,N.TRIANGLES,G,Qe.disabled,dt.alphaBlended,Ye.disabled,me,null,null,"atmosphere",ye.vertexBuffer,ye.indexBuffer,ye.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const S=function(A,R){let V=null;const N=Object.values(A._layers).flatMap(W=>W.source&&!W.isHidden(R)?[A.sourceCaches[W.source]]:[]),U=N.filter(W=>W.getSource().type==="vector"),G=N.filter(W=>W.getSource().type!=="vector"),X=W=>{(!V||V.getSource().maxzoom<W.getSource().maxzoom)&&(V=W)};return U.forEach(W=>X(W)),V||G.forEach(W=>X(W)),V}(this.style,this.transform.zoom);S&&function(A,R,V){for(let N=0;N<V.length;N++)Dl(A,R,V[N])}(this,S,S.getVisibleCoordinates())}this.options.showPadding&&function(S){const A=S.transform.padding;Dn(S,S.transform.height-(A.top||0),3,zi),Dn(S,A.bottom||0,3,yo),oa(S,A.left||0,3,xo),oa(S,S.transform.width-(A.right||0),3,kl);const R=S.transform.centerPoint;(function(V,N,U,G){gs(V,N-1,U-10,2,20,G),gs(V,N-10,U-1,20,2,G)})(S,R.x,S.transform.height-R.y,kn)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(e){if(!this.style||!this.style.map||!this.style.map.terrain)return;const i=this.terrainFacilitator.matrix,a=this.transform.modelViewProjectionMatrix;let o=this.terrainFacilitator.dirty;o||(o=e?!c.bV(i,a):!c.bW(i,a)),o||(o=this.style.map.terrain.sourceCache.anyTilesAfterTime(this.terrainFacilitator.renderTime)),o&&(c.bX(i,a),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(u,f){const _=u.context,y=_.gl,v=u.transform,T=dt.unblended,P=new Ge(y.LEQUAL,Ge.ReadWrite,[0,1]),S=f.sourceCache.getRenderableTiles(),A=u.useProgram("terrainDepth");_.bindFramebuffer.set(f.getFramebuffer("depth").framebuffer),_.viewport.set([0,0,u.width/devicePixelRatio,u.height/devicePixelRatio]),_.clear({color:c.b4.transparent,depth:1});for(const R of S){const V=f.getTerrainMesh(R.tileID),N=f.getTerrainData(R.tileID),U=v.getProjectionData({overscaledTileID:R.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),G={u_ele_delta:f.getMeshFrameDelta(v.zoom)};A.draw(_,y.TRIANGLES,P,Qe.disabled,T,Ye.backCCW,G,N,U,"terrain",V.vertexBuffer,V.indexBuffer,V.segments)}_.bindFramebuffer.set(null),_.viewport.set([0,0,u.width,u.height])}(this,this.style.map.terrain),function(u,f){const _=u.context,y=_.gl,v=u.transform,T=dt.unblended,P=new Ge(y.LEQUAL,Ge.ReadWrite,[0,1]),S=f.getCoordsTexture(),A=f.sourceCache.getRenderableTiles(),R=u.useProgram("terrainCoords");_.bindFramebuffer.set(f.getFramebuffer("coords").framebuffer),_.viewport.set([0,0,u.width/devicePixelRatio,u.height/devicePixelRatio]),_.clear({color:c.b4.transparent,depth:1}),f.coordsIndex=[];for(const V of A){const N=f.getTerrainMesh(V.tileID),U=f.getTerrainData(V.tileID);_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,S.texture);const G={u_terrain_coords_id:(255-f.coordsIndex.length)/255,u_texture:0,u_ele_delta:f.getMeshFrameDelta(v.zoom)},X=v.getProjectionData({overscaledTileID:V.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});R.draw(_,y.TRIANGLES,P,Qe.disabled,T,Ye.backCCW,G,U,X,"terrain",N.vertexBuffer,N.indexBuffer,N.segments),f.coordsIndex.push(V.tileID.key)}_.bindFramebuffer.set(null),_.viewport.set([0,0,u.width,u.height])}(this,this.style.map.terrain))}renderLayer(e,i,a,o,u){a.isHidden(this.transform.zoom)||(a.type==="background"||a.type==="custom"||(o||[]).length)&&(this.id=a.id,c.bY(a)?function(f,_,y,v,T,P){if(f.renderPass!=="translucent")return;const{isRenderingToTexture:S}=P,A=Qe.disabled,R=f.colorModeForRenderPass();(y._unevaluatedLayout.hasValue("text-variable-anchor")||y._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(V,N,U,G,X,W,K,Q,J){const se=N.transform,oe=N.style.map.terrain,me=X==="map",ye=W==="map";for(const de of V){const Se=G.getTile(de),Pe=Se.getBucket(U);if(!Pe||!Pe.text||!Pe.text.segments.get().length)continue;const ve=c.ah(Pe.textSizeData,se.zoom),Ee=c.at(Se,1,N.transform.zoom),$e=le(me,N.transform,Ee),et=U.layout.get("icon-text-fit")!=="none"&&Pe.hasIconData();{const xt=Math.pow(2,se.zoom-Se.tileID.overscaledZ),st=oe?(vt,at)=>oe.getElevation(de,vt,at):null;fo(Pe,me,ye,J,se,$e,xt,ve,et,c.au(se,Se,K,Q),de.toUnwrapped(),st)}}}(v,f,y,_,y.layout.get("text-rotation-alignment"),y.layout.get("text-pitch-alignment"),y.paint.get("text-translate"),y.paint.get("text-translate-anchor"),T),y.paint.get("icon-opacity").constantOr(1)!==0&&ra(f,_,y,v,!1,y.paint.get("icon-translate"),y.paint.get("icon-translate-anchor"),y.layout.get("icon-rotation-alignment"),y.layout.get("icon-pitch-alignment"),y.layout.get("icon-keep-upright"),A,R,S),y.paint.get("text-opacity").constantOr(1)!==0&&ra(f,_,y,v,!0,y.paint.get("text-translate"),y.paint.get("text-translate-anchor"),y.layout.get("text-rotation-alignment"),y.layout.get("text-pitch-alignment"),y.layout.get("text-keep-upright"),A,R,S),_.map.showCollisionBoxes&&(ea(f,_,y,v,!0),ea(f,_,y,v,!1))}(e,i,a,o,this.style.placement.variableOffsets,u):c.bZ(a)?function(f,_,y,v,T){if(f.renderPass!=="translucent")return;const{isRenderingToTexture:P}=T,S=y.paint.get("circle-opacity"),A=y.paint.get("circle-stroke-width"),R=y.paint.get("circle-stroke-opacity"),V=!y.layout.get("circle-sort-key").isConstant();if(S.constantOr(1)===0&&(A.constantOr(1)===0||R.constantOr(1)===0))return;const N=f.context,U=N.gl,G=f.transform,X=f.getDepthModeForSublayer(0,Ge.ReadOnly),W=Qe.disabled,K=f.colorModeForRenderPass(),Q=[],J=G.getCircleRadiusCorrection();for(let se=0;se<v.length;se++){const oe=v[se],me=_.getTile(oe),ye=me.getBucket(y);if(!ye)continue;const de=y.paint.get("circle-translate"),Se=y.paint.get("circle-translate-anchor"),Pe=c.au(G,me,de,Se),ve=ye.programConfigurations.get(y.id),Ee=f.useProgram("circle",ve),$e=ye.layoutVertexBuffer,et=ye.indexBuffer,xt=f.style.map.terrain&&f.style.map.terrain.getTerrainData(oe),st={programConfiguration:ve,program:Ee,layoutVertexBuffer:$e,indexBuffer:et,uniformValues:Ya(f,me,y,Pe,J),terrainData:xt,projectionData:G.getProjectionData({overscaledTileID:oe,applyGlobeMatrix:!P,applyTerrainMatrix:!0})};if(V){const vt=ye.segments.get();for(const at of vt)Q.push({segments:new c.aD([at]),sortKey:at.sortKey,state:st})}else Q.push({segments:ye.segments,sortKey:0,state:st})}V&&Q.sort((se,oe)=>se.sortKey-oe.sortKey);for(const se of Q){const{programConfiguration:oe,program:me,layoutVertexBuffer:ye,indexBuffer:de,uniformValues:Se,terrainData:Pe,projectionData:ve}=se.state;me.draw(N,U.TRIANGLES,X,W,K,Ye.backCCW,Se,Pe,ve,y.id,ye,de,se.segments,y.paint,f.transform.zoom,oe)}}(e,i,a,o,u):c.b_(a)?function(f,_,y,v,T){if(y.paint.get("heatmap-opacity")===0)return;const P=f.context,{isRenderingToTexture:S,isRenderingGlobe:A}=T;if(f.style.map.terrain){for(const R of v){const V=_.getTile(R);_.hasRenderableParent(R)||(f.renderPass==="offscreen"?zl(f,V,y,R,A):f.renderPass==="translucent"&&na(f,y,R,S,A))}P.viewport.set([0,0,f.width,f.height])}else f.renderPass==="offscreen"?function(R,V,N,U){const G=R.context,X=G.gl,W=R.transform,K=Qe.disabled,Q=new dt([X.ONE,X.ONE],c.b4.transparent,[!0,!0,!0,!0]);(function(J,se,oe){const me=J.gl;J.activeTexture.set(me.TEXTURE1),J.viewport.set([0,0,se.width/4,se.height/4]);let ye=oe.heatmapFbos.get(c.bP);ye?(me.bindTexture(me.TEXTURE_2D,ye.colorAttachment.get()),J.bindFramebuffer.set(ye.framebuffer)):(ye=sa(J,se.width/4,se.height/4),oe.heatmapFbos.set(c.bP,ye))})(G,R,N),G.clear({color:c.b4.transparent});for(let J=0;J<U.length;J++){const se=U[J];if(V.hasRenderableParent(se))continue;const oe=V.getTile(se),me=oe.getBucket(N);if(!me)continue;const ye=me.programConfigurations.get(N.id),de=R.useProgram("heatmap",ye),Se=W.getProjectionData({overscaledTileID:se,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),Pe=W.getCircleRadiusCorrection();de.draw(G,X.TRIANGLES,Ge.disabled,K,Q,Ye.backCCW,Qa(oe,W.zoom,N.paint.get("heatmap-intensity"),Pe),null,Se,N.id,me.layoutVertexBuffer,me.indexBuffer,me.segments,N.paint,W.zoom,ye)}G.viewport.set([0,0,R.width,R.height])}(f,_,y,v):f.renderPass==="translucent"&&function(R,V){const N=R.context,U=N.gl;N.setColorMode(R.colorModeForRenderPass());const G=V.heatmapFbos.get(c.bP);G&&(N.activeTexture.set(U.TEXTURE0),U.bindTexture(U.TEXTURE_2D,G.colorAttachment.get()),N.activeTexture.set(U.TEXTURE1),mo(N,V).bind(U.LINEAR,U.CLAMP_TO_EDGE),R.useProgram("heatmapTexture").draw(N,U.TRIANGLES,Ge.disabled,Qe.disabled,R.colorModeForRenderPass(),Ye.disabled,Ir(R,V,0,1),null,null,V.id,R.viewportBuffer,R.quadTriangleIndexBuffer,R.viewportSegments,V.paint,R.transform.zoom))}(f,y)}(e,i,a,o,u):c.b$(a)?function(f,_,y,v,T){if(f.renderPass!=="translucent")return;const{isRenderingToTexture:P}=T,S=y.paint.get("line-opacity"),A=y.paint.get("line-width");if(S.constantOr(1)===0||A.constantOr(1)===0)return;const R=f.getDepthModeForSublayer(0,Ge.ReadOnly),V=f.colorModeForRenderPass(),N=y.paint.get("line-dasharray"),U=y.paint.get("line-pattern"),G=U.constantOr(1),X=y.paint.get("line-gradient"),W=y.getCrossfadeParameters(),K=G?"linePattern":N?"lineSDF":X?"lineGradient":"line",Q=f.context,J=Q.gl,se=f.transform;let oe=!0;for(const me of v){const ye=_.getTile(me);if(G&&!ye.patternsLoaded())continue;const de=ye.getBucket(y);if(!de)continue;const Se=de.programConfigurations.get(y.id),Pe=f.context.program.get(),ve=f.useProgram(K,Se),Ee=oe||ve.program!==Pe,$e=f.style.map.terrain&&f.style.map.terrain.getTerrainData(me),et=U.constantOr(null);if(et&&ye.imageAtlas){const nt=ye.imageAtlas,ot=nt.patternPositions[et.to.toString()],Kt=nt.patternPositions[et.from.toString()];ot&&Kt&&Se.setConstantPatternPositions(ot,Kt)}const xt=se.getProjectionData({overscaledTileID:me,applyGlobeMatrix:!P,applyTerrainMatrix:!0}),st=se.getPixelScale(),vt=G?kc(f,ye,y,st,W):N?Dc(f,ye,y,st,N,W):X?Us(f,ye,y,st,de.lineClipsArray.length):eo(f,ye,y,st);if(G)Q.activeTexture.set(J.TEXTURE0),ye.imageAtlasTexture.bind(J.LINEAR,J.CLAMP_TO_EDGE),Se.updatePaintBuffers(W);else if(N&&(Ee||f.lineAtlas.dirty))Q.activeTexture.set(J.TEXTURE0),f.lineAtlas.bind(Q);else if(X){const nt=de.gradients[y.id];let ot=nt.texture;if(y.gradientVersion!==nt.version){let Kt=256;if(y.stepInterpolant){const Lt=_.getSource().maxzoom,Bt=me.canonical.z===Lt?Math.ceil(1<<f.transform.maxZoom-me.canonical.z):1;Kt=c.ab(c.bQ(de.maxLineLength/c.X*1024*Bt),256,Q.maxTextureSize)}nt.gradient=c.bR({expression:y.gradientExpression(),evaluationKey:"lineProgress",resolution:Kt,image:nt.gradient||void 0,clips:de.lineClipsArray}),nt.texture?nt.texture.update(nt.gradient):nt.texture=new Ct(Q,nt.gradient,J.RGBA),nt.version=y.gradientVersion,ot=nt.texture}Q.activeTexture.set(J.TEXTURE0),ot.bind(y.stepInterpolant?J.NEAREST:J.LINEAR,J.CLAMP_TO_EDGE)}let at;if(P){const[nt]=f.getStencilConfigForOverlapAndUpdateStencilID(v);at=nt[me.overscaledZ]}else at=f.stencilModeForClipping(me);ve.draw(Q,J.TRIANGLES,R,at,V,Ye.disabled,vt,$e,xt,y.id,de.layoutVertexBuffer,de.indexBuffer,de.segments,y.paint,f.transform.zoom,Se,de.layoutVertexBuffer2),oe=!1}}(e,i,a,o,u):c.c0(a)?function(f,_,y,v,T){const P=y.paint.get("fill-color"),S=y.paint.get("fill-opacity");if(S.constantOr(1)===0)return;const{isRenderingToTexture:A}=T,R=f.colorModeForRenderPass(),V=y.paint.get("fill-pattern"),N=f.opaquePassEnabledForLayer()&&!V.constantOr(1)&&P.constantOr(c.b4.transparent).a===1&&S.constantOr(0)===1?"opaque":"translucent";if(f.renderPass===N){const U=f.getDepthModeForSublayer(1,f.renderPass==="opaque"?Ge.ReadWrite:Ge.ReadOnly);ms(f,_,y,v,U,R,!1,A)}if(f.renderPass==="translucent"&&y.paint.get("fill-antialias")){const U=f.getDepthModeForSublayer(y.getPaintProperty("fill-outline-color")?2:0,Ge.ReadOnly);ms(f,_,y,v,U,R,!0,A)}}(e,i,a,o,u):c.c1(a)?function(f,_,y,v,T){const P=y.paint.get("fill-extrusion-opacity");if(P===0)return;const{isRenderingToTexture:S}=T;if(f.renderPass==="translucent"){const A=new Ge(f.context.gl.LEQUAL,Ge.ReadWrite,f.depthRangeFor3D);if(P!==1||y.paint.get("fill-extrusion-pattern").constantOr(1))_s(f,_,y,v,A,Qe.disabled,dt.disabled,S),_s(f,_,y,v,A,f.stencilModeFor3D(),f.colorModeForRenderPass(),S);else{const R=f.colorModeForRenderPass();_s(f,_,y,v,A,Qe.disabled,R,S)}}}(e,i,a,o,u):c.c2(a)?function(f,_,y,v,T){if(f.renderPass!=="offscreen"&&f.renderPass!=="translucent")return;const{isRenderingToTexture:P}=T,S=f.context,A=f.style.projection.useSubdivision,R=f.getDepthModeForSublayer(0,Ge.ReadOnly),V=f.colorModeForRenderPass();if(f.renderPass==="offscreen")(function(N,U,G,X,W,K,Q){const J=N.context,se=J.gl;for(const oe of G){const me=U.getTile(oe),ye=me.dem;if(!ye||!ye.data||!me.needsHillshadePrepare)continue;const de=ye.dim,Se=ye.stride,Pe=ye.getPixels();if(J.activeTexture.set(se.TEXTURE1),J.pixelStoreUnpackPremultiplyAlpha.set(!1),me.demTexture=me.demTexture||N.getTileTexture(Se),me.demTexture){const Ee=me.demTexture;Ee.update(Pe,{premultiply:!1}),Ee.bind(se.NEAREST,se.CLAMP_TO_EDGE)}else me.demTexture=new Ct(J,Pe,se.RGBA,{premultiply:!1}),me.demTexture.bind(se.NEAREST,se.CLAMP_TO_EDGE);J.activeTexture.set(se.TEXTURE0);let ve=me.fbo;if(!ve){const Ee=new Ct(J,{width:de,height:de,data:null},se.RGBA);Ee.bind(se.LINEAR,se.CLAMP_TO_EDGE),ve=me.fbo=J.createFramebuffer(de,de,!0,!1),ve.colorAttachment.set(Ee.texture)}J.bindFramebuffer.set(ve.framebuffer),J.viewport.set([0,0,de,de]),N.useProgram("hillshadePrepare").draw(J,se.TRIANGLES,W,K,Q,Ye.disabled,yl(me.tileID,ye),null,null,X.id,N.rasterBoundsBuffer,N.quadTriangleIndexBuffer,N.rasterBoundsSegments),me.needsHillshadePrepare=!1}})(f,_,v,y,R,Qe.disabled,V),S.viewport.set([0,0,f.width,f.height]);else if(f.renderPass==="translucent")if(A){const[N,U,G]=f.stencilConfigForOverlapTwoPass(v);go(f,_,y,G,N,R,V,!1,P),go(f,_,y,G,U,R,V,!0,P)}else{const[N,U]=f.getStencilConfigForOverlapAndUpdateStencilID(v);go(f,_,y,U,N,R,V,!1,P)}}(e,i,a,o,u):c.c3(a)?function(f,_,y,v,T){if(f.renderPass!=="translucent"||y.paint.get("raster-opacity")===0||!v.length)return;const{isRenderingToTexture:P}=T,S=_.getSource(),A=f.style.projection.useSubdivision;if(S instanceof mi)gt(f,_,y,v,null,!1,!1,S.tileCoords,S.flippedWindingOrder,P);else if(A){const[R,V,N]=f.stencilConfigForOverlapTwoPass(v);gt(f,_,y,N,R,!1,!0,aa,!1,P),gt(f,_,y,N,V,!0,!0,aa,!1,P)}else{const[R,V]=f.getStencilConfigForOverlapAndUpdateStencilID(v);gt(f,_,y,V,R,!1,!0,aa,!1,P)}}(e,i,a,o,u):c.c4(a)?function(f,_,y,v,T){const P=y.paint.get("background-color"),S=y.paint.get("background-opacity");if(S===0)return;const{isRenderingToTexture:A}=T,R=f.context,V=R.gl,N=f.style.projection,U=f.transform,G=U.tileSize,X=y.paint.get("background-pattern");if(f.isPatternMissing(X))return;const W=!X&&P.a===1&&S===1&&f.opaquePassEnabledForLayer()?"opaque":"translucent";if(f.renderPass!==W)return;const K=Qe.disabled,Q=f.getDepthModeForSublayer(0,W==="opaque"?Ge.ReadWrite:Ge.ReadOnly),J=f.colorModeForRenderPass(),se=f.useProgram(X?"backgroundPattern":"background"),oe=v||j(U,{tileSize:G,terrain:f.style.map.terrain});X&&(R.activeTexture.set(V.TEXTURE0),f.imageManager.bind(f.context));const me=y.getCrossfadeParameters();for(const ye of oe){const de=U.getProjectionData({overscaledTileID:ye,applyGlobeMatrix:!A,applyTerrainMatrix:!0}),Se=X?ao(S,f,X,{tileID:ye,tileSize:G},me):so(S,P),Pe=f.style.map.terrain&&f.style.map.terrain.getTerrainData(ye),ve=N.getMeshFromTileID(R,ye.canonical,!1,!0,"raster");se.draw(R,V.TRIANGLES,Q,K,J,Ye.backCCW,Se,Pe,de,y.id,ve.vertexBuffer,ve.indexBuffer,ve.segments)}}(e,0,a,o,u):c.c5(a)&&function(f,_,y,v){const{isRenderingGlobe:T}=v,P=f.context,S=y.implementation,A=f.style.projection,R=f.transform,V=R.getProjectionDataForCustomLayer(T),N={farZ:R.farZ,nearZ:R.nearZ,fov:R.fov*Math.PI/180,modelViewProjectionMatrix:R.modelViewProjectionMatrix,projectionMatrix:R.projectionMatrix,shaderData:{variantName:A.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;
uniform mat4 u_projection_matrix;
${A.shaderPreludeCode.vertexSource}`,define:A.shaderDefine},defaultProjectionData:V},U=S.renderingMode?S.renderingMode:"2d";if(f.renderPass==="offscreen"){const G=S.prerender;G&&(f.setCustomLayerDefaults(),P.setColorMode(f.colorModeForRenderPass()),G.call(S,P.gl,N),P.setDirty(),f.setBaseState())}else if(f.renderPass==="translucent"){f.setCustomLayerDefaults(),P.setColorMode(f.colorModeForRenderPass()),P.setStencilMode(Qe.disabled);const G=U==="3d"?f.getDepthModeFor3D():f.getDepthModeForSublayer(0,Ge.ReadOnly);P.setDepthMode(G),S.render(P.gl,N),P.setDirty(),f.setBaseState(),P.bindFramebuffer.set(null)}}(e,0,a,u))}saveTileTexture(e){const i=this._tileTextures[e.size[0]];i?i.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const i=this._tileTextures[e];return i&&i.length>0?i.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const i=this.imageManager.getPattern(e.from.toString()),a=this.imageManager.getPattern(e.to.toString());return!i||!a}useProgram(e,i,a=!1){this.cache=this.cache||{};const o=!!this.style.map.terrain,u=this.style.projection,f=e+(i?i.cacheKey:"")+`/${a?cl:u.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(o?"/terrain":"");return this.cache[f]||(this.cache[f]=new Vs(this.context,qi[e],i,vl[e],this._showOverdrawInspector,o,a?qi.projectionMercator:u.shaderPreludeCode,a?Bs:u.shaderDefine)),this.cache[f]}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(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new Ct(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:i}=this.context.gl;return this.width!==e||this.height!==i}}function Cr(h,e){let i,a=!1,o=null,u=null;const f=()=>{o=null,a&&(h.apply(u,i),o=setTimeout(f,e),a=!1)};return(..._)=>(a=!0,u=this,i=_,o||f(),o)}class wo{constructor(e){this._getCurrentHash=()=>{const i=window.location.hash.replace("#","");if(this._hashName){let a;return i.split("&").map(o=>o.split("=")).forEach(o=>{o[0]===this._hashName&&(a=o)}),(a&&a[1]||"").split("/")}return i.split("/")},this._onHashChange=()=>{const i=this._getCurrentHash();if(!this._isValidHash(i))return!1;const a=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(i[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+i[2],+i[1]],zoom:+i[0],bearing:a,pitch:+(i[4]||0)}),!0},this._updateHashUnthrottled=()=>{const i=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,i)},this._removeHash=()=>{const i=this._getCurrentHash();if(i.length===0)return;const a=i.join("/");let o=a;o.split("&").length>0&&(o=o.split("&")[0]),this._hashName&&(o=`${this._hashName}=${a}`);let u=window.location.hash.replace(o,"");u.startsWith("#&")?u=u.slice(0,1)+u.slice(2):u==="#"&&(u="");let f=window.location.href.replace(/(#.+)?$/,u);f=f.replace("&&","&"),window.history.replaceState(window.history.state,null,f)},this._updateHash=Cr(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 i=this._map.getCenter(),a=Math.round(100*this._map.getZoom())/100,o=Math.ceil((a*Math.LN2+Math.log(512/360/.5))/Math.LN10),u=Math.pow(10,o),f=Math.round(i.lng*u)/u,_=Math.round(i.lat*u)/u,y=this._map.getBearing(),v=this._map.getPitch();let T="";if(T+=e?`/${f}/${_}/${a}`:`${a}/${_}/${f}`,(y||v)&&(T+="/"+Math.round(10*y)/10),v&&(T+=`/${Math.round(v)}`),this._hashName){const P=this._hashName;let S=!1;const A=window.location.hash.slice(1).split("&").map(R=>{const V=R.split("=")[0];return V===P?(S=!0,`${V}=${T}`):R}).filter(R=>R);return S||A.push(`${P}=${T}`),`#${A.join("&")}`}return`#${T}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new c.N(+e[2],+e[1])}catch{return!1}const i=+e[0],a=+(e[3]||0),o=+(e[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&a>=0&&a<=180&&o>=this._map.getMinPitch()&&o<=this._map.getMaxPitch()}}const Rn={linearity:.3,easing:c.c6(0,0,.3,1)},Ll=c.e({deceleration:2500,maxSpeed:1400},Rn),Bl=c.e({deceleration:20,maxSpeed:1400},Rn),Fl=c.e({deceleration:1e3,maxSpeed:360},Rn),Ol=c.e({deceleration:1e3,maxSpeed:90},Rn),jl=c.e({deceleration:1e3,maxSpeed:360},Rn);class la{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:Ze.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,i=Ze.now();for(;e.length>0&&i-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new c.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:u}of this._inertiaBuffer)i.zoom+=u.zoomDelta||0,i.bearing+=u.bearingDelta||0,i.pitch+=u.pitchDelta||0,i.roll+=u.rollDelta||0,u.panDelta&&i.pan._add(u.panDelta),u.around&&(i.around=u.around),u.pinchAround&&(i.pinchAround=u.pinchAround);const a=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(i.pan.mag()){const u=li(i.pan.mag(),a,c.e({},Ll,e||{})),f=i.pan.mult(u.amount/i.pan.mag()),_=this._map.cameraHelper.handlePanInertia(f,this._map.transform);o.center=_.easingCenter,o.offset=_.easingOffset,Ln(o,u)}if(i.zoom){const u=li(i.zoom,a,Bl);o.zoom=this._map.transform.zoom+u.amount,Ln(o,u)}if(i.bearing){const u=li(i.bearing,a,Fl);o.bearing=this._map.transform.bearing+c.ab(u.amount,-179,179),Ln(o,u)}if(i.pitch){const u=li(i.pitch,a,Ol);o.pitch=this._map.transform.pitch+u.amount,Ln(o,u)}if(i.roll){const u=li(i.roll,a,jl);o.roll=this._map.transform.roll+c.ab(u.amount,-179,179),Ln(o,u)}if(o.zoom||o.bearing){const u=i.pinchAround===void 0?i.around:i.pinchAround;o.around=u?this._map.unproject(u):this._map.getCenter()}return this.clear(),c.e(o,{noMoveStart:!0})}}function Ln(h,e){(!h.duration||h.duration<e.duration)&&(h.duration=e.duration,h.easing=e.easing)}function li(h,e,i){const{maxSpeed:a,linearity:o,deceleration:u}=i,f=c.ab(h*o/(e/1e3),-a,a),_=Math.abs(f)/(u*o);return{easing:i.easing,duration:1e3*_,amount:f*(_/2)}}class At extends c.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,i,a,o={}){const u=ue.mousePos(i.getCanvas(),a),f=i.unproject(u);super(e,c.e({point:u,lngLat:f,originalEvent:a},o)),this._defaultPrevented=!1,this.target=i}}class Bn extends c.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,i,a){const o=e==="touchend"?a.changedTouches:a.touches,u=ue.touchPos(i.getCanvasContainer(),o),f=u.map(y=>i.unproject(y)),_=u.reduce((y,v,T,P)=>y.add(v.div(P.length)),new c.P(0,0));super(e,{points:u,point:_,lngLats:f,lngLat:i.unproject(_),originalEvent:a}),this._defaultPrevented=!1}}class ji extends c.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,i,a){super(e,{originalEvent:a}),this._defaultPrevented=!1}}class Fn{constructor(e,i){this._map=e,this._clickTolerance=i.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new ji(e.type,this._map,e))}mousedown(e,i){return this._mousedownPos=i,this._firePreventable(new At(e.type,this._map,e))}mouseup(e){this._map.fire(new At(e.type,this._map,e))}click(e,i){this._mousedownPos&&this._mousedownPos.dist(i)>=this._clickTolerance||this._map.fire(new At(e.type,this._map,e))}dblclick(e){return this._firePreventable(new At(e.type,this._map,e))}mouseover(e){this._map.fire(new At(e.type,this._map,e))}mouseout(e){this._map.fire(new At(e.type,this._map,e))}touchstart(e){return this._firePreventable(new Bn(e.type,this._map,e))}touchmove(e){this._map.fire(new Bn(e.type,this._map,e))}touchend(e){this._map.fire(new Bn(e.type,this._map,e))}touchcancel(e){this._map.fire(new Bn(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Uc{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new At(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new At("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new At(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ys{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(c.P.convert(e),this._map.terrain)}}class Nl{constructor(e,i){this._map=e,this._tr=new ys(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=i.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,i){this.isEnabled()&&e.shiftKey&&e.button===0&&(ue.disableDrag(),this._startPos=this._lastPos=i,this._active=!0)}mousemoveWindow(e,i){if(!this._active)return;const a=i;if(this._lastPos.equals(a)||!this._box&&a.dist(this._startPos)<this._clickTolerance)return;const o=this._startPos;this._lastPos=a,this._box||(this._box=ue.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));const u=Math.min(o.x,a.x),f=Math.max(o.x,a.x),_=Math.min(o.y,a.y),y=Math.max(o.y,a.y);ue.setTransform(this._box,`translate(${u}px,${_}px)`),this._box.style.width=f-u+"px",this._box.style.height=y-_+"px"}mouseupWindow(e,i){if(!this._active||e.button!==0)return;const a=this._startPos,o=i;if(this.reset(),ue.suppressClick(),a.x!==o.x||a.y!==o.y)return this._map.fire(new c.k("boxzoomend",{originalEvent:e})),{cameraAnimation:u=>u.fitScreenCoordinates(a,o,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(ue.remove(this._box),this._box=null),ue.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,i){return this._map.fire(new c.k(e,{originalEvent:i}))}}function To(h,e){if(h.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${h.length}, points ${e.length}`);const i={};for(let a=0;a<h.length;a++)i[h[a].identifier]=e[a];return i}class Vl{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,i,a){(this.centroid||a.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),a.length===this.numTouches&&(this.centroid=function(o){const u=new c.P(0,0);for(const f of o)u._add(f);return u.div(o.length)}(i),this.touches=To(a,i)))}touchmove(e,i,a){if(this.aborted||!this.centroid)return;const o=To(a,i);for(const u in this.touches){const f=o[u];(!f||f.dist(this.touches[u])>30)&&(this.aborted=!0)}}touchend(e,i,a){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),a.length===0){const o=!this.aborted&&this.centroid;if(this.reset(),o)return o}}}class dn{constructor(e){this.singleTap=new Vl(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,i,a){this.singleTap.touchstart(e,i,a)}touchmove(e,i,a){this.singleTap.touchmove(e,i,a)}touchend(e,i,a){const o=this.singleTap.touchend(e,i,a);if(o){const u=e.timeStamp-this.lastTime<500,f=!this.lastTap||this.lastTap.dist(o)<30;if(u&&f||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class sr{constructor(e){this._tr=new ys(e),this._zoomIn=new dn({numTouches:1,numTaps:2}),this._zoomOut=new dn({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,i,a){this._zoomIn.touchstart(e,i,a),this._zoomOut.touchstart(e,i,a)}touchmove(e,i,a){this._zoomIn.touchmove(e,i,a),this._zoomOut.touchmove(e,i,a)}touchend(e,i,a){const o=this._zoomIn.touchend(e,i,a),u=this._zoomOut.touchend(e,i,a),f=this._tr;return o?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:f.zoom+1,around:f.unproject(o)},{originalEvent:e})}):u?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:f.zoom-1,around:f.unproject(u)},{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 Ae{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 i=this._moveFunction(...e);if(i.bearingDelta||i.pitchDelta||i.rollDelta||i.around||i.panDelta)return this._active=!0,i}dragStart(e,i){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(i)?i[0]:i,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,i){if(!this.isEnabled())return;const a=this._lastPoint;if(!a)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const o=Array.isArray(i)?i[0]:i;return!this._moved&&o.dist(a)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=o,this._move(a,o))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&ue.suppressClick(),this.reset(e))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const Ul={0:1,2:2};class pn{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){const i=ue.mouseButton(e);this._eventButton=i}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!function(i,a){const o=Ul[a];return i.buttons===void 0||(i.buttons&o)!==o}(e,this._eventButton)}isValidEndEvent(e){return ue.mouseButton(e)===this._eventButton}}class Zl{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return e.targetTouches.length===1}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier}endMove(e){delete this._firstTouch}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}}class xs{constructor(e=new pn({checkCorrectEvent:()=>!0}),i=new Zl){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=i}_executeRelevantHandler(e,i,a){return e instanceof MouseEvent?i(e):typeof TouchEvent<"u"&&e instanceof TouchEvent?a(e):void 0}startMove(e){this._executeRelevantHandler(e,i=>this.mouseMoveStateManager.startMove(i),i=>this.oneFingerTouchMoveStateManager.startMove(i))}endMove(e){this._executeRelevantHandler(e,i=>this.mouseMoveStateManager.endMove(i),i=>this.oneFingerTouchMoveStateManager.endMove(i))}isValidStartEvent(e){return this._executeRelevantHandler(e,i=>this.mouseMoveStateManager.isValidStartEvent(i),i=>this.oneFingerTouchMoveStateManager.isValidStartEvent(i))}isValidMoveEvent(e){return this._executeRelevantHandler(e,i=>this.mouseMoveStateManager.isValidMoveEvent(i),i=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(i))}isValidEndEvent(e){return this._executeRelevantHandler(e,i=>this.mouseMoveStateManager.isValidEndEvent(i),i=>this.oneFingerTouchMoveStateManager.isValidEndEvent(i))}}const Er=h=>{h.mousedown=h.dragStart,h.mousemoveWindow=h.dragMove,h.mouseup=h.dragEnd,h.contextmenu=e=>{e.preventDefault()}};class Gl{constructor(e,i){this._clickTolerance=e.clickTolerance||1,this._map=i,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new c.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,i,a){return this._calculateTransform(e,i,a)}touchmove(e,i,a){if(this._active){if(!this._shouldBePrevented(a.length))return e.preventDefault(),this._calculateTransform(e,i,a);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,i,a){this._calculateTransform(e,i,a),this._active&&this._shouldBePrevented(a.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,i,a){a.length>0&&(this._active=!0);const o=To(a,i),u=new c.P(0,0),f=new c.P(0,0);let _=0;for(const v in o){const T=o[v],P=this._touches[v];P&&(u._add(T),f._add(T.sub(P)),_++,o[v]=T)}if(this._touches=o,this._shouldBePrevented(_)||!f.mag())return;const y=f.div(_);return this._sum._add(y),this._sum.mag()<this._clickTolerance?void 0:{around:u.div(_),panDelta:y}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class We{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,i,a){this._firstTwoTouches||a.length<2||(this._firstTwoTouches=[a[0].identifier,a[1].identifier],this._start([i[0],i[1]]))}touchmove(e,i,a){if(!this._firstTwoTouches)return;e.preventDefault();const[o,u]=this._firstTwoTouches,f=On(a,i,o),_=On(a,i,u);if(!f||!_)return;const y=this._aroundCenter?null:f.add(_).div(2);return this._move([f,_],y,e)}touchend(e,i,a){if(!this._firstTwoTouches)return;const[o,u]=this._firstTwoTouches,f=On(a,i,o),_=On(a,i,u);f&&_||(this._active&&ue.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&e.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function On(h,e,i){for(let a=0;a<h.length;a++)if(h[a].identifier===i)return e[a]}function $l(h,e){return Math.log(h/e)/Math.LN2}class ca extends We{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,i){const a=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs($l(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:$l(this._distance,a),pinchAround:i}}}function ql(h,e){return 180*h.angleWith(e)/Math.PI}class Hl extends We{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,i,a){const o=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:ql(this._vector,o),pinchAround:i}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const i=25/(Math.PI*this._minDiameter)*360,a=ql(e,this._startVector);return Math.abs(a)<i}}function ha(h){return Math.abs(h.y)>Math.abs(h.x)}class ua extends We{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,i,a){super.touchstart(e,i,a),this._currentTouchCount=a.length}_start(e){this._lastPoints=e,ha(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,i,a){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const o=e[0].sub(this._lastPoints[0]),u=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(o,u,a.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(o.y+u.y)/2*-.5}):void 0}gestureBeginsVertically(e,i,a){if(this._valid!==void 0)return this._valid;const o=e.mag()>=2,u=i.mag()>=2;if(!o&&!u)return;if(!o||!u)return this._firstMove===void 0&&(this._firstMove=a),a-this._firstMove<100&&void 0;const f=e.y>0==i.y>0;return ha(e)&&ha(i)&&f}}const Xl={panStep:100,bearingStep:15,pitchStep:10};class Wl{constructor(e){this._tr=new ys(e);const i=Xl;this._panStep=i.panStep,this._bearingStep=i.bearingStep,this._pitchStep=i.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let i=0,a=0,o=0,u=0,f=0;switch(e.keyCode){case 61:case 107:case 171:case 187:i=1;break;case 189:case 109:case 173:i=-1;break;case 37:e.shiftKey?a=-1:(e.preventDefault(),u=-1);break;case 39:e.shiftKey?a=1:(e.preventDefault(),u=1);break;case 38:e.shiftKey?o=1:(e.preventDefault(),f=-1);break;case 40:e.shiftKey?o=-1:(e.preventDefault(),f=1);break;default:return}return this._rotationDisabled&&(a=0,o=0),{cameraAnimation:_=>{const y=this._tr;_.easeTo({duration:300,easeId:"keyboardHandler",easing:Kl,zoom:i?Math.round(y.zoom)+i*(e.shiftKey?2:1):y.zoom,bearing:y.bearing+a*this._bearingStep,pitch:y.pitch+o*this._pitchStep,offset:[-u*this._panStep,-f*this._panStep],center:y.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Kl(h){return h*(2-h)}const Yl=4.000244140625;class Jl{constructor(e,i){this._onTimeout=a=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)},this._map=e,this._tr=new ys(e),this._triggerRenderFrame=i,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 i=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const a=Ze.now(),o=a-(this._lastWheelEventTime||0);this._lastWheelEventTime=a,i!==0&&i%Yl==0?this._type="wheel":i!==0&&Math.abs(i)<4?this._type="trackpad":o>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(o*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),e.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=e,this._delta-=i,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 i=ue.mousePos(this._map.getCanvas(),e),a=this._tr;this._aroundPoint=this._aroundCenter?a.transform.locationToScreenPoint(c.N.convert(a.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const e=this._tr.transform;if(typeof this._lastExpectedZoom=="number"){const _=e.zoom-this._lastExpectedZoom;typeof this._startZoom=="number"&&(this._startZoom+=_),typeof this._targetZoom=="number"&&(this._targetZoom+=_)}if(this._delta!==0){const _=this._type==="wheel"&&Math.abs(this._delta)>Yl?this._wheelZoomRate:this._defaultZoomRate;let y=2/(1+Math.exp(-Math.abs(this._delta*_)));this._delta<0&&y!==0&&(y=1/y);const v=typeof this._targetZoom!="number"?e.scale:c.aG(this._targetZoom);this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,c.a8(v*y))),this._type==="wheel"&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const i=typeof this._targetZoom!="number"?e.zoom:this._targetZoom,a=this._startZoom,o=this._easing;let u,f=!1;if(this._type==="wheel"&&a&&o){const _=Ze.now()-this._lastWheelEventTime,y=Math.min((_+5)/200,1),v=o(y);u=c.y.number(a,i,v),y<1?this._frameId||(this._frameId=!0):f=!0}else u=i,f=!0;return this._active=!0,f&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=u,{noInertia:!0,needsRenderFrame:!f,zoomDelta:u-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=c.c8;if(this._prevEase){const a=this._prevEase,o=(Ze.now()-a.start)/a.duration,u=a.easing(o+.01)-a.easing(o),f=.27/Math.sqrt(u*u+1e-4)*.01,_=Math.sqrt(.0729-f*f);i=c.c6(f,_,.25,1)}return this._prevEase={start:Ze.now(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class ar{constructor(e,i){this._clickZoom=e,this._tapZoom=i}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 yt{constructor(e){this._tr=new ys(e),this.reset()}reset(){this._active=!1}dblclick(e,i){return e.preventDefault(),{cameraAnimation:a=>{a.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(i)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class da{constructor(){this._tap=new dn({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,i,a){if(!this._swipePoint)if(this._tapTime){const o=i[0],u=e.timeStamp-this._tapTime<500,f=this._tapPoint.dist(o)<30;u&&f?a.length>0&&(this._swipePoint=o,this._swipeTouch=a[0].identifier):this.reset()}else this._tap.touchstart(e,i,a)}touchmove(e,i,a){if(this._tapTime){if(this._swipePoint){if(a[0].identifier!==this._swipeTouch)return;const o=i[0],u=o.y-this._swipePoint.y;return this._swipePoint=o,e.preventDefault(),this._active=!0,{zoomDelta:u/128}}}else this._tap.touchmove(e,i,a)}touchend(e,i,a){if(this._tapTime)this._swipePoint&&a.length===0&&this.reset();else{const o=this._tap.touchend(e,i,a);o&&(this._tapTime=e.timeStamp,this._tapPoint=o)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class pa{constructor(e,i,a){this._el=e,this._mousePan=i,this._touchPan=a}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Po{constructor(e,i,a,o){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=i,this._mousePitch=a,this._mouseRoll=o}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 Mo{constructor(e,i,a,o){this._el=e,this._touchZoom=i,this._touchRotate=a,this._tapDragZoom=o,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class So{constructor(e,i){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=e,this._options=i,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=ue.create("div","maplibregl-cooperative-gesture-screen",e);let i=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(i=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const a=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),o=document.createElement("div");o.className="maplibregl-desktop-message",o.textContent=i,this._container.appendChild(o);const u=document.createElement("div");u.className="maplibregl-mobile-message",u.textContent=a,this._container.appendChild(u),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(ue.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,i){this._enabled&&(this._map.fire(new c.k("cooperativegestureprevented",{gestureType:e,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const fa=h=>h.zoom||h.drag||h.roll||h.pitch||h.rotate;class Wi extends c.k{}function jn(h){return h.panDelta&&h.panDelta.mag()||h.zoomDelta||h.bearingDelta||h.pitchDelta||h.rollDelta}class Le{constructor(e,i){this.handleWindowEvent=o=>{this.handleEvent(o,`${o.type}Window`)},this.handleEvent=(o,u)=>{if(o.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const f=o.type==="renderFrame"?void 0:o,_={needsRenderFrame:!1},y={},v={},T=o.touches,P=T?this._getMapTouches(T):void 0,S=P?ue.touchPos(this._map.getCanvas(),P):ue.mousePos(this._map.getCanvas(),o);for(const{handlerName:V,handler:N,allowed:U}of this._handlers){if(!N.isEnabled())continue;let G;this._blockedByActive(v,U,V)?N.reset():N[u||o.type]&&(G=N[u||o.type](o,S,P),this.mergeHandlerResult(_,y,G,V,f),G&&G.needsRenderFrame&&this._triggerRenderFrame()),(G||N.isActive())&&(v[V]=N)}const A={};for(const V in this._previousActiveHandlers)v[V]||(A[V]=f);this._previousActiveHandlers=v,(Object.keys(A).length||jn(_))&&(this._changes.push([_,y,A]),this._triggerRenderFrame()),(Object.keys(v).length||jn(_))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:R}=_;R&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],R(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new la(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const a=this._el;this._listeners=[[a,"touchstart",{passive:!0}],[a,"touchmove",{passive:!1}],[a,"touchend",void 0],[a,"touchcancel",void 0],[a,"mousedown",void 0],[a,"mousemove",void 0],[a,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[a,"mouseover",void 0],[a,"mouseout",void 0],[a,"dblclick",void 0],[a,"click",void 0],[a,"keydown",{capture:!1}],[a,"keyup",void 0],[a,"wheel",{passive:!1}],[a,"contextmenu",void 0],[window,"blur",void 0]];for(const[o,u,f]of this._listeners)ue.addEventListener(o,u,o===document?this.handleWindowEvent:this.handleEvent,f)}destroy(){for(const[e,i,a]of this._listeners)ue.removeEventListener(e,i,e===document?this.handleWindowEvent:this.handleEvent,a)}_addDefaultHandlers(e){const i=this._map,a=i.getCanvasContainer();this._add("mapEvent",new Fn(i,e));const o=i.boxZoom=new Nl(i,e);this._add("boxZoom",o),e.interactive&&e.boxZoom&&o.enable();const u=i.cooperativeGestures=new So(i,e.cooperativeGestures);this._add("cooperativeGestures",u),e.cooperativeGestures&&u.enable();const f=new sr(i),_=new yt(i);i.doubleClickZoom=new ar(_,f),this._add("tapZoom",f),this._add("clickZoom",_),e.interactive&&e.doubleClickZoom&&i.doubleClickZoom.enable();const y=new da;this._add("tapDragZoom",y);const v=i.touchPitch=new ua(i);this._add("touchPitch",v),e.interactive&&e.touchPitch&&i.touchPitch.enable(e.touchPitch);const T=()=>i.project(i.getCenter()),P=function({enable:W,clickTolerance:K,aroundCenter:Q=!0,minPixelCenterThreshold:J=100,rotateDegreesPerPixelMoved:se=.8},oe){const me=new pn({checkCorrectEvent:ye=>ue.mouseButton(ye)===0&&ye.ctrlKey||ue.mouseButton(ye)===2&&!ye.ctrlKey});return new Ae({clickTolerance:K,move:(ye,de)=>{const Se=oe();if(Q&&Math.abs(Se.y-ye.y)>J)return{bearingDelta:c.c7(new c.P(ye.x,de.y),de,Se)};let Pe=(de.x-ye.x)*se;return Q&&de.y<Se.y&&(Pe=-Pe),{bearingDelta:Pe}},moveStateManager:me,enable:W,assignEvents:Er})}(e,T),S=function({enable:W,clickTolerance:K,pitchDegreesPerPixelMoved:Q=-.5}){const J=new pn({checkCorrectEvent:se=>ue.mouseButton(se)===0&&se.ctrlKey||ue.mouseButton(se)===2});return new Ae({clickTolerance:K,move:(se,oe)=>({pitchDelta:(oe.y-se.y)*Q}),moveStateManager:J,enable:W,assignEvents:Er})}(e),A=function({enable:W,clickTolerance:K,rollDegreesPerPixelMoved:Q=.3},J){const se=new pn({checkCorrectEvent:oe=>ue.mouseButton(oe)===2&&oe.ctrlKey});return new Ae({clickTolerance:K,move:(oe,me)=>{const ye=J();let de=(me.x-oe.x)*Q;return me.y<ye.y&&(de=-de),{rollDelta:de}},moveStateManager:se,enable:W,assignEvents:Er})}(e,T);i.dragRotate=new Po(e,P,S,A),this._add("mouseRotate",P,["mousePitch"]),this._add("mousePitch",S,["mouseRotate","mouseRoll"]),this._add("mouseRoll",A,["mousePitch"]),e.interactive&&e.dragRotate&&i.dragRotate.enable();const R=function({enable:W,clickTolerance:K}){const Q=new pn({checkCorrectEvent:J=>ue.mouseButton(J)===0&&!J.ctrlKey});return new Ae({clickTolerance:K,move:(J,se)=>({around:se,panDelta:se.sub(J)}),activateOnStart:!0,moveStateManager:Q,enable:W,assignEvents:Er})}(e),V=new Gl(e,i);i.dragPan=new pa(a,R,V),this._add("mousePan",R),this._add("touchPan",V,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&i.dragPan.enable(e.dragPan);const N=new Hl,U=new ca;i.touchZoomRotate=new Mo(a,U,N,y),this._add("touchRotate",N,["touchPan","touchZoom"]),this._add("touchZoom",U,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&i.touchZoomRotate.enable(e.touchZoomRotate);const G=i.scrollZoom=new Jl(i,()=>this._triggerRenderFrame());this._add("scrollZoom",G,["mousePan"]),e.interactive&&e.scrollZoom&&i.scrollZoom.enable(e.scrollZoom);const X=i.keyboard=new Wl(i);this._add("keyboard",X),e.interactive&&e.keyboard&&i.keyboard.enable(),this._add("blockableMapEvent",new Uc(i))}_add(e,i,a){this._handlers.push({handlerName:e,handler:i,allowed:a}),this._handlersById[e]=i}stop(e){if(!this._updatingCamera){for(const{handler:i}of this._handlers)i.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!!fa(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,i,a){for(const o in e)if(o!==a&&(!i||i.indexOf(o)<0))return!0;return!1}_getMapTouches(e){const i=[];for(const a of e)this._el.contains(a.target)&&i.push(a);return i}mergeHandlerResult(e,i,a,o,u){if(!a)return;c.e(e,a);const f={handlerName:o,originalEvent:a.originalEvent||u};a.zoomDelta!==void 0&&(i.zoom=f),a.panDelta!==void 0&&(i.drag=f),a.rollDelta!==void 0&&(i.roll=f),a.pitchDelta!==void 0&&(i.pitch=f),a.bearingDelta!==void 0&&(i.rotate=f)}_applyChanges(){const e={},i={},a={};for(const[o,u,f]of this._changes)o.panDelta&&(e.panDelta=(e.panDelta||new c.P(0,0))._add(o.panDelta)),o.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+o.pitchDelta),o.rollDelta&&(e.rollDelta=(e.rollDelta||0)+o.rollDelta),o.around!==void 0&&(e.around=o.around),o.pinchAround!==void 0&&(e.pinchAround=o.pinchAround),o.noInertia&&(e.noInertia=o.noInertia),c.e(i,u),c.e(a,f);this._updateMapTransform(e,i,a),this._changes=[]}_updateMapTransform(e,i,a){const o=this._map,u=o._getTransformForUpdate(),f=o.terrain;if(!(jn(e)||f&&this._terrainMovement))return this._fireEvents(i,a,!0);o._stop(!0);let{panDelta:_,zoomDelta:y,bearingDelta:v,pitchDelta:T,rollDelta:P,around:S,pinchAround:A}=e;A!==void 0&&(S=A),S=S||o.transform.centerPoint,f&&!u.isPointOnMapSurface(S)&&(S=u.centerPoint);const R={panDelta:_,zoomDelta:y,rollDelta:P,pitchDelta:T,bearingDelta:v,around:S};this._map.cameraHelper.useGlobeControls&&!u.isPointOnMapSurface(S)&&(S=u.centerPoint);const V=S.distSqr(u.centerPoint)<.01?u.center:u.screenPointToLocation(_?S.sub(_):S);f?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(R,u),this._terrainMovement||!i.drag&&!i.zoom?i.drag&&this._terrainMovement?u.setCenter(u.screenPointToLocation(u.centerPoint.sub(_))):this._map.cameraHelper.handleMapControlsPan(R,u,V):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(R,u,V))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(R,u),this._map.cameraHelper.handleMapControlsPan(R,u,V)),o._applyUpdatedTransform(u),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(i,a,!0)}_fireEvents(e,i,a){const o=fa(this._eventsInProgress),u=fa(e),f={};for(const P in e){const{originalEvent:S}=e[P];this._eventsInProgress[P]||(f[`${P}start`]=S),this._eventsInProgress[P]=e[P]}!o&&u&&this._fireEvent("movestart",u.originalEvent);for(const P in f)this._fireEvent(P,f[P]);u&&this._fireEvent("move",u.originalEvent);for(const P in e){const{originalEvent:S}=e[P];this._fireEvent(P,S)}const _={};let y;for(const P in this._eventsInProgress){const{handlerName:S,originalEvent:A}=this._eventsInProgress[P];this._handlersById[S].isActive()||(delete this._eventsInProgress[P],y=i[S]||A,_[`${P}end`]=y)}for(const P in _)this._fireEvent(P,_[P]);const v=fa(this._eventsInProgress),T=(o||u)&&!v;if(T&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const P=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&P.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(P)}if(a&&T){this._updatingCamera=!0;const P=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),S=A=>A!==0&&-this._bearingSnap<A&&A<this._bearingSnap;!P||!P.essential&&Ze.prefersReducedMotion?(this._map.fire(new c.k("moveend",{originalEvent:y})),S(this._map.getBearing())&&this._map.resetNorth()):(S(P.bearing||this._map.getBearing())&&(P.bearing=0),P.freezeElevation=!0,this._map.easeTo(P,{originalEvent:y})),this._updatingCamera=!1}}_fireEvent(e,i){this._map.fire(new c.k(e,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{delete this._frameId,this.handleEvent(new Wi("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Ne extends c.E{constructor(e,i,a){super(),this._renderFrameCallback=()=>{const o=Math.min((Ze.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(o)),o<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=a.bearingSnap,this.cameraHelper=i,this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(e,i){e.apply(this.transform),this.transform=e,this.cameraHelper=i}getCenter(){return new c.N(this.transform.center.lng,this.transform.center.lat)}setCenter(e,i){return this.jumpTo({center:e},i)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,i){return this.jumpTo({elevation:e},i),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,i,a){return e=c.P.convert(e).mult(-1),this.panTo(this.transform.center,c.e({offset:e},i),a)}panTo(e,i,a){return this.easeTo(c.e({center:e},i),a)}getZoom(){return this.transform.zoom}setZoom(e,i){return this.jumpTo({zoom:e},i),this}zoomTo(e,i,a){return this.easeTo(c.e({zoom:e},i),a)}zoomIn(e,i){return this.zoomTo(this.getZoom()+1,e,i),this}zoomOut(e,i){return this.zoomTo(this.getZoom()-1,e,i),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,i){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new c.k("movestart",i)).fire(new c.k("move",i)).fire(new c.k("moveend",i))),this}getBearing(){return this.transform.bearing}setBearing(e,i){return this.jumpTo({bearing:e},i),this}getPadding(){return this.transform.padding}setPadding(e,i){return this.jumpTo({padding:e},i),this}rotateTo(e,i,a){return this.easeTo(c.e({bearing:e},i),a)}resetNorth(e,i){return this.rotateTo(0,c.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(c.e({bearing:0,pitch:0,roll:0,duration:1e3},e),i),this}snapToNorth(e,i){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,i):this}getPitch(){return this.transform.pitch}setPitch(e,i){return this.jumpTo({pitch:e},i),this}getRoll(){return this.transform.roll}setRoll(e,i){return this.jumpTo({roll:e},i),this}cameraForBounds(e,i){e=zt.convert(e).adjustAntiMeridian();const a=i&&i.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),a,i)}_cameraForBoxAndBearing(e,i,a,o){const u={top:0,bottom:0,right:0,left:0};if(typeof(o=c.e({padding:u,offset:[0,0],maxZoom:this.transform.maxZoom},o)).padding=="number"){const v=o.padding;o.padding={top:v,bottom:v,right:v,left:v}}const f=c.e(u,o.padding);o.padding=f;const _=this.transform,y=new zt(e,i);return this.cameraHelper.cameraForBoxAndBearing(o,f,y,a,_)}fitBounds(e,i,a){return this._fitInternal(this.cameraForBounds(e,i),i,a)}fitScreenCoordinates(e,i,a,o,u){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(c.P.convert(e)),this.transform.screenPointToLocation(c.P.convert(i)),a,o),o,u)}_fitInternal(e,i,a){return e?(delete(i=c.e(e,i)).padding,i.linear?this.easeTo(i,a):this.flyTo(i,a)):this}jumpTo(e,i){this.stop();const a=this._getTransformForUpdate();let o=!1,u=!1,f=!1;const _=a.zoom;this.cameraHelper.handleJumpToCenterZoom(a,e);const y=a.zoom!==_;return"elevation"in e&&a.elevation!==+e.elevation&&a.setElevation(+e.elevation),"bearing"in e&&a.bearing!==+e.bearing&&(o=!0,a.setBearing(+e.bearing)),"pitch"in e&&a.pitch!==+e.pitch&&(u=!0,a.setPitch(+e.pitch)),"roll"in e&&a.roll!==+e.roll&&(f=!0,a.setRoll(+e.roll)),e.padding==null||a.isPaddingEqual(e.padding)||a.setPadding(e.padding),this._applyUpdatedTransform(a),this.fire(new c.k("movestart",i)).fire(new c.k("move",i)),y&&this.fire(new c.k("zoomstart",i)).fire(new c.k("zoom",i)).fire(new c.k("zoomend",i)),o&&this.fire(new c.k("rotatestart",i)).fire(new c.k("rotate",i)).fire(new c.k("rotateend",i)),u&&this.fire(new c.k("pitchstart",i)).fire(new c.k("pitch",i)).fire(new c.k("pitchend",i)),f&&this.fire(new c.k("rollstart",i)).fire(new c.k("roll",i)).fire(new c.k("rollend",i)),this.fire(new c.k("moveend",i))}calculateCameraOptionsFromTo(e,i,a,o=0){const u=c.Y.fromLngLat(e,i),f=c.Y.fromLngLat(a,o),_=f.x-u.x,y=f.y-u.y,v=f.z-u.z,T=Math.hypot(_,y,v);if(T===0)throw new Error("Can't calculate camera options with same From and To");const P=Math.hypot(_,y),S=c.a8(this.transform.cameraToCenterDistance/T/this.transform.tileSize),A=180*Math.atan2(_,-y)/Math.PI;let R=180*Math.acos(P/T)/Math.PI;return R=v<0?90-R:90+R,{center:f.toLngLat(),elevation:o,zoom:S,pitch:R,bearing:A}}calculateCameraOptionsFromCameraLngLatAltRotation(e,i,a,o,u){const f=this.transform.calculateCenterFromCameraLngLatAlt(e,i,a,o);return{center:f.center,elevation:f.elevation,zoom:f.zoom,bearing:a,pitch:o,roll:u}}easeTo(e,i){this._stop(!1,e.easeId),((e=c.e({offset:[0,0],duration:500,easing:c.c8},e)).animate===!1||!e.essential&&Ze.prefersReducedMotion)&&(e.duration=0);const a=this._getTransformForUpdate(),o=this.getBearing(),u=a.pitch,f=a.roll,_="bearing"in e?this._normalizeBearing(e.bearing,o):o,y="pitch"in e?+e.pitch:u,v="roll"in e?this._normalizeBearing(e.roll,f):f,T="padding"in e?e.padding:a.padding,P=c.P.convert(e.offset);let S,A;e.around&&(S=c.N.convert(e.around),A=a.locationToScreenPoint(S));const R={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},V=this.cameraHelper.handleEaseTo(a,{bearing:_,pitch:y,roll:v,padding:T,around:S,aroundPoint:A,offsetAsPoint:P,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating=this._rotating||o!==_,this._pitching=this._pitching||y!==u,this._rolling=this._rolling||v!==f,this._padding=!a.isPaddingEqual(T),this._zooming=this._zooming||V.isZooming,this._easeId=e.easeId,this._prepareEase(i,e.noMoveStart,R),this.terrain&&this._prepareElevation(V.elevationCenter),this._ease(N=>{V.easeFunc(N),this.terrain&&!e.freezeElevation&&this._updateElevation(N),this._applyUpdatedTransform(a),this._fireMoveEvents(i)},N=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i,N)},e),this}_prepareEase(e,i,a={}){this._moving=!0,i||a.moving||this.fire(new c.k("movestart",e)),this._zooming&&!a.zooming&&this.fire(new c.k("zoomstart",e)),this._rotating&&!a.rotating&&this.fire(new c.k("rotatestart",e)),this._pitching&&!a.pitching&&this.fire(new c.k("pitchstart",e)),this._rolling&&!a.rolling&&this.fire(new c.k("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.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const a=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(a-(i-(a*e+this._elevationStart))/(1-e)),this._elevationTarget=i}this.transform.setElevation(c.y.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 i=e.getCameraLngLat(),a=e.getCameraAltitude(),o=this.terrain?this.terrain.getElevationForLngLatZoom(i,e.zoom):0;if(a<o){const u=this.calculateCameraOptionsFromTo(i,o,e.center,e.elevation);return{pitch:u.pitch,zoom:u.zoom}}return{}}_applyUpdatedTransform(e){const i=[];if(i.push(o=>this._elevateCameraIfInsideTerrain(o)),this.transformCameraUpdate&&i.push(o=>this.transformCameraUpdate(o)),!i.length)return;const a=e.clone();for(const o of i){const u=a.clone(),{center:f,zoom:_,roll:y,pitch:v,bearing:T,elevation:P}=o(u);f&&u.setCenter(f),P!==void 0&&u.setElevation(P),_!==void 0&&u.setZoom(_),y!==void 0&&u.setRoll(y),v!==void 0&&u.setPitch(v),T!==void 0&&u.setBearing(T),a.apply(u)}this.transform.apply(a)}_fireMoveEvents(e){this.fire(new c.k("move",e)),this._zooming&&this.fire(new c.k("zoom",e)),this._rotating&&this.fire(new c.k("rotate",e)),this._pitching&&this.fire(new c.k("pitch",e)),this._rolling&&this.fire(new c.k("roll",e))}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const a=this._zooming,o=this._rotating,u=this._pitching,f=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,a&&this.fire(new c.k("zoomend",e)),o&&this.fire(new c.k("rotateend",e)),u&&this.fire(new c.k("pitchend",e)),f&&this.fire(new c.k("rollend",e)),this.fire(new c.k("moveend",e))}flyTo(e,i){if(!e.essential&&Ze.prefersReducedMotion){const de=c.M(e,["center","zoom","bearing","pitch","roll","elevation"]);return this.jumpTo(de,i)}this.stop(),e=c.e({offset:[0,0],speed:1.2,curve:1.42,easing:c.c8},e);const a=this._getTransformForUpdate(),o=a.bearing,u=a.pitch,f=a.roll,_=a.padding,y="bearing"in e?this._normalizeBearing(e.bearing,o):o,v="pitch"in e?+e.pitch:u,T="roll"in e?this._normalizeBearing(e.roll,f):f,P="padding"in e?e.padding:a.padding,S=c.P.convert(e.offset);let A=a.centerPoint.add(S);const R=a.screenPointToLocation(A),V=this.cameraHelper.handleFlyTo(a,{bearing:y,pitch:v,roll:T,padding:P,locationAtOffset:R,offsetAsPoint:S,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let N=e.curve;const U=Math.max(a.width,a.height),G=U/V.scaleOfZoom,X=V.pixelPathLength;typeof V.scaleOfMinZoom=="number"&&(N=Math.sqrt(U/V.scaleOfMinZoom/X*2));const W=N*N;function K(de){const Se=(G*G-U*U+(de?-1:1)*W*W*X*X)/(2*(de?G:U)*W*X);return Math.log(Math.sqrt(Se*Se+1)-Se)}function Q(de){return(Math.exp(de)-Math.exp(-de))/2}function J(de){return(Math.exp(de)+Math.exp(-de))/2}const se=K(!1);let oe=function(de){return J(se)/J(se+N*de)},me=function(de){return U*((J(se)*(Q(Se=se+N*de)/J(Se))-Q(se))/W)/X;var Se},ye=(K(!0)-se)/N;if(Math.abs(X)<2e-6||!isFinite(ye)){if(Math.abs(U-G)<1e-6)return this.easeTo(e,i);const de=G<U?-1:1;ye=Math.abs(Math.log(G/U))/N,me=()=>0,oe=Se=>Math.exp(de*N*Se)}return e.duration="duration"in e?+e.duration:1e3*ye/("screenSpeed"in e?+e.screenSpeed/N:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=o!==y,this._pitching=v!==u,this._rolling=T!==f,this._padding=!a.isPaddingEqual(P),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(V.targetCenter),this._ease(de=>{const Se=de*ye,Pe=1/oe(Se),ve=me(Se);this._rotating&&a.setBearing(c.y.number(o,y,de)),this._pitching&&a.setPitch(c.y.number(u,v,de)),this._rolling&&a.setRoll(c.y.number(f,T,de)),this._padding&&(a.interpolatePadding(_,P,de),A=a.centerPoint.add(S)),V.easeFunc(de,Pe,ve,A),this.terrain&&!e.freezeElevation&&this._updateElevation(de),this._applyUpdatedTransform(a),this._fireMoveEvents(i)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i)},e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,i){var a;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const o=this._onEaseEnd;delete this._onEaseEnd,o.call(this,i)}return e||(a=this.handlers)===null||a===void 0||a.stop(!1),this}_ease(e,i,a){a.animate===!1||a.duration===0?(e(1),i()):(this._easeStart=Ze.now(),this._easeOptions=a,this._onEaseFrame=e,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,i){e=c.aI(e,-180,180);const a=Math.abs(e-i);return Math.abs(e-360-i)<a&&(e-=360),Math.abs(e+360-i)<a&&(e+=360),e}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLatZoom(c.N.convert(e),this.transform.tileZoom):null}}const vs={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class ma{constructor(e=vs){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=i=>{!i||i.sourceDataType!=="metadata"&&i.sourceDataType!=="visibility"&&i.dataType!=="style"&&i.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=ue.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=ue.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=ue.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(){ue.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._sanitizedAttributionHTML=void 0}_setElementTitle(e,i){const a=this._map._getUIString(`AttributionControl.${i}`);e.title=a,e.setAttribute("aria-label",a)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(o=>typeof o!="string"?"":o)):typeof this.options.customAttribution=="string"&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const o=this._map.style.stylesheet;this.styleOwner=o.owner,this.styleId=o.id}const i=this._map.style.sourceCaches;for(const o in i){const u=i[o];if(u.used||u.usedForTerrain){const f=u.getSource();f.attribution&&e.indexOf(f.attribution)<0&&e.push(f.attribution)}}e=e.filter(o=>String(o).trim()),e.sort((o,u)=>o.length-u.length),e=e.filter((o,u)=>{for(let f=u+1;f<e.length;f++)if(e[f].indexOf(o)>=0)return!1;return!0});const a=e.join(" | ");a!==this._sanitizedAttributionHTML&&(this._sanitizedAttributionHTML=ue.sanitize(a),e.length?(this._innerContainer.innerHTML=this._sanitizedAttributionHTML,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class _a{constructor(e={}){this._updateCompact=()=>{const i=this._container.children;if(i.length){const a=i[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&a.classList.add("maplibregl-compact"):a.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=ue.create("div","maplibregl-ctrl");const i=ue.create("a","maplibregl-ctrl-logo");return i.target="_blank",i.rel="noopener nofollow",i.href="https://maplibre.org/",i.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),i.setAttribute("rel","noopener nofollow"),this._container.appendChild(i),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){ue.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class ui{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const i=++this._id;return this._queue.push({callback:e,id:i,cancelled:!1}),i}remove(e){const i=this._currentlyRunning,a=i?this._queue.concat(i):this._queue;for(const o of a)if(o.id===e)return void(o.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const i=this._currentlyRunning=this._queue;this._queue=[];for(const a of i)if(!a.cancelled&&(a.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Ql=c.aA([{name:"a_pos3d",type:"Int16",components:3}]);class Ki extends c.E{constructor(e){super(),this._lastTilesetChange=Ze.now(),this.sourceCache=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.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(e,i){this.sourceCache.update(e,i),this._renderableTilesKeys=[];const a={};for(const o of j(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))a[o.key]=!0,this._renderableTilesKeys.push(o.key),this._tiles[o.key]||(o.terrainRttPosMatrix32f=new Float64Array(16),c.bL(o.terrainRttPosMatrix32f,0,c.X,c.X,0,0,1),this._tiles[o.key]=new Kr(o,this.tileSize),this._lastTilesetChange=Ze.now());for(const o in this._tiles)a[o]||delete this._tiles[o]}freeRtt(e){for(const i in this._tiles){const a=this._tiles[i];(!e||a.tileID.equals(e)||a.tileID.isChildOf(e)||e.isChildOf(a.tileID))&&(a.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e){const i={};for(const a of this._renderableTilesKeys){const o=this._tiles[a].tileID,u=e.clone(),f=c.a$();if(o.canonical.equals(e.canonical))c.bL(f,0,c.X,c.X,0,0,1);else if(o.canonical.isChildOf(e.canonical)){const _=o.canonical.z-e.canonical.z,y=o.canonical.x-(o.canonical.x>>_<<_),v=o.canonical.y-(o.canonical.y>>_<<_),T=c.X>>_;c.bL(f,0,T,T,0,0,1),c.J(f,f,[-y*T,-v*T,0])}else{if(!e.canonical.isChildOf(o.canonical))continue;{const _=e.canonical.z-o.canonical.z,y=e.canonical.x-(e.canonical.x>>_<<_),v=e.canonical.y-(e.canonical.y>>_<<_),T=c.X>>_;c.bL(f,0,c.X,c.X,0,0,1),c.J(f,f,[y*T,v*T,0]),c.K(f,f,[1/2**_,1/2**_,0])}}u.terrainRttPosMatrix32f=new Float32Array(f),i[a]=u}return i}getSourceTile(e,i){const a=this.sourceCache._source;let o=e.overscaledZ-this.deltaZoom;if(o>a.maxzoom&&(o=a.maxzoom),o<a.minzoom)return null;this._sourceTileCache[e.key]||(this._sourceTileCache[e.key]=e.scaledTo(o).key);let u=this.sourceCache.getTileByID(this._sourceTileCache[e.key]);if((!u||!u.dem)&&i)for(;o>=a.minzoom&&(!u||!u.dem);)u=this.sourceCache.getTileByID(e.scaledTo(o--).key);return u}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}}class Zc{constructor(e,i,a){this._meshCache={},this.painter=e,this.sourceCache=new Ki(i),this.options=a,this.exaggeration=typeof a.exaggeration=="number"?a.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,i,a,o=c.X){var u;if(!(i>=0&&i<o&&a>=0&&a<o))return 0;const f=this.getTerrainData(e),_=(u=f.tile)===null||u===void 0?void 0:u.dem;if(!_)return 0;const y=c.c9([],[i/o*c.X,a/o*c.X],f.u_terrain_matrix),v=[y[0]*_.dim,y[1]*_.dim],T=Math.floor(v[0]),P=Math.floor(v[1]),S=v[0]-T,A=v[1]-P;return _.get(T,P)*(1-S)*(1-A)+_.get(T+1,P)*S*(1-A)+_.get(T,P+1)*(1-S)*A+_.get(T+1,P+1)*S*A}getElevationForLngLatZoom(e,i){if(!c.ca(i,e.wrap()))return 0;const{tileID:a,mercatorX:o,mercatorY:u}=this._getOverscaledTileIDFromLngLatZoom(e,i);return this.getElevation(a,o%c.X,u%c.X,c.X)}getElevation(e,i,a,o=c.X){return this.getDEMElevation(e,i,a,o)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){const o=this.painter.context,u=new c.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new Ct(o,u,o.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Ct(o,new c.R({width:1,height:1}),o.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(o.gl.NEAREST,o.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=c.aq([])}const i=this.sourceCache.getSourceTile(e,!0);if(i&&i.dem&&(!i.demTexture||i.needsTerrainPrepare)){const o=this.painter.context;i.demTexture=this.painter.getTileTexture(i.dem.stride),i.demTexture?i.demTexture.update(i.dem.getPixels(),{premultiply:!1}):i.demTexture=new Ct(o,i.dem.getPixels(),o.gl.RGBA,{premultiply:!1}),i.demTexture.bind(o.gl.NEAREST,o.gl.CLAMP_TO_EDGE),i.needsTerrainPrepare=!1}const a=i&&i+i.tileID.key+e.key;if(a&&!this._demMatrixCache[a]){const o=this.sourceCache.sourceCache._source.maxzoom;let u=e.canonical.z-i.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=o?u=e.canonical.z-o:c.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const f=e.canonical.x-(e.canonical.x>>u<<u),_=e.canonical.y-(e.canonical.y>>u<<u),y=c.cb(new Float64Array(16),[1/(c.X<<u),1/(c.X<<u),0]);c.J(y,y,[f*c.X,_*c.X,0]),this._demMatrixCache[e.key]={matrix:y,coord:e}}return{u_depth:2,u_terrain:3,u_terrain_dim:i&&i.dem&&i.dem.dim||1,u_terrain_matrix:a?this._demMatrixCache[e.key].matrix:this._emptyDemMatrix,u_terrain_unpack:i&&i.dem&&i.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(i&&i.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:i}}getFramebuffer(e){const i=this.painter,a=i.width/devicePixelRatio,o=i.height/devicePixelRatio;return!this._fbo||this._fbo.width===a&&this._fbo.height===o||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new Ct(i.context,{width:a,height:o,data:null},i.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(i.context.gl.NEAREST,i.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Ct(i.context,{width:a,height:o,data:null},i.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(i.context.gl.NEAREST,i.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=i.context.createFramebuffer(a,o,!0,!1),this._fbo.depthAttachment.set(i.context.createRenderbuffer(i.context.gl.DEPTH_COMPONENT16,a,o))),this._fbo.colorAttachment.set(e==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const e=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const i=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let u=0,f=0;u<this._coordsTextureSize;u++)for(let _=0;_<this._coordsTextureSize;_++,f+=4)i[f+0]=255&_,i[f+1]=255&u,i[f+2]=_>>8<<4|u>>8,i[f+3]=0;const a=new c.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),o=new Ct(e,a,e.gl.RGBA,{premultiply:!1});return o.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=o,o}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),a=this.painter.context,o=a.gl,u=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),f=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),_=Math.round(this.painter.height/devicePixelRatio);a.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),o.readPixels(u,_-f-1,1,1,o.RGBA,o.UNSIGNED_BYTE,i),a.bindFramebuffer.set(null);const y=i[0]+(i[2]>>4<<8),v=i[1]+((15&i[2])<<8),T=this.coordsIndex[255-i[3]],P=T&&this.sourceCache.getTileByID(T);if(!P)return null;const S=this._coordsTextureSize,A=(1<<P.tileID.canonical.z)*S;return new c.Y((P.tileID.canonical.x*S+y)/A+P.tileID.wrap,(P.tileID.canonical.y*S+v)/A,this.getElevation(P.tileID,y,v,S))}depthAtPoint(e){const i=new Uint8Array(4),a=this.painter.context,o=a.gl;return a.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),o.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,o.RGBA,o.UNSIGNED_BYTE,i),a.bindFramebuffer.set(null),(i[0]/16777216+i[1]/65536+i[2]/256+i[3])/256}getTerrainMesh(e){var i;const a=((i=this.painter.style.projection)===null||i===void 0?void 0:i.transitionState)>0,o=a&&e.canonical.y===0,u=a&&e.canonical.y===(1<<e.canonical.z)-1,f=`m_${o?"n":""}_${u?"s":""}`;if(this._meshCache[f])return this._meshCache[f];const _=this.painter.context,y=new c.cc,v=new c.aE,T=this.meshSize,P=c.X/T,S=T*T;for(let J=0;J<=T;J++)for(let se=0;se<=T;se++)y.emplaceBack(se*P,J*P,0);for(let J=0;J<S;J+=T+1)for(let se=0;se<T;se++)v.emplaceBack(se+J,T+se+J+1,T+se+J+2),v.emplaceBack(se+J,T+se+J+2,se+J+1);const A=y.length,R=A+(T+1),V=(T+1)*T,N=o?c.b6:0,U=o?0:1,G=u?c.b7:c.X,X=u?0:1;for(let J=0;J<=T;J++)y.emplaceBack(J*P,N,U);for(let J=0;J<=T;J++)y.emplaceBack(J*P,G,X);for(let J=0;J<T;J++)v.emplaceBack(V+J,R+J,R+J+1),v.emplaceBack(V+J,R+J+1,V+J+1),v.emplaceBack(0+J,A+J+1,A+J),v.emplaceBack(0+J,0+J+1,A+J+1);const W=y.length,K=W+2*(T+1);for(const J of[0,1])for(let se=0;se<=T;se++)for(const oe of[0,1])y.emplaceBack(J*c.X,se*P,oe);for(let J=0;J<2*T;J+=2)v.emplaceBack(W+J,W+J+1,W+J+3),v.emplaceBack(W+J,W+J+3,W+J+2),v.emplaceBack(K+J,K+J+3,K+J+1),v.emplaceBack(K+J,K+J+2,K+J+3);const Q=new Hi(_.createVertexBuffer(y,Ql.members),_.createIndexBuffer(v),c.aD.simpleSegment(0,0,y.length,v.length));return this._meshCache[f]=Q,Q}getMeshFrameDelta(e){return 2*Math.PI*c.bo/Math.pow(2,Math.max(e,0))/5}getMinTileElevationForLngLatZoom(e,i){var a;const{tileID:o}=this._getOverscaledTileIDFromLngLatZoom(e,i);return(a=this.getMinMaxElevation(o).minElevation)!==null&&a!==void 0?a:0}getMinMaxElevation(e){const i=this.getTerrainData(e).tile,a={minElevation:null,maxElevation:null};return i&&i.dem&&(a.minElevation=i.dem.min*this.exaggeration,a.maxElevation=i.dem.max*this.exaggeration),a}_getOverscaledTileIDFromLngLatZoom(e,i){const a=c.Y.fromLngLat(e.wrap()),o=(1<<i)*c.X,u=a.x*o,f=a.y*o,_=Math.floor(u/c.X),y=Math.floor(f/c.X);return{tileID:new c.S(i,0,i,_,y),mercatorX:u,mercatorY:f}}}class bs{constructor(e,i,a){this._context=e,this._size=i,this._tileSize=a,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const e of this._objects)e.texture.destroy(),e.fbo.destroy()}_createObject(e){const i=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),a=new Ct(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return a.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),i.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),i.colorAttachment.set(a.texture),{id:e,fbo:i,texture:a,stamp:-1,inUse:!1}}getObjectForId(e){return this._objects[e]}useObject(e){e.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(i=>e.id!==i),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const i of this._recentlyUsed)if(!this._objects[i].inUse)return this._objects[i];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length<this._size)&&this._objects.some(e=>!e.inUse)===!1}}const ht={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class kt{constructor(e,i){this.painter=e,this.terrain=i,this.pool=new bs(e.context,30,i.sourceCache.tileSize*i.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,i){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter(a=>!e._layers[a].isHidden(i)),this._coordsAscending={};for(const a in e.sourceCaches){this._coordsAscending[a]={};const o=e.sourceCaches[a].getVisibleCoordinates();for(const u of o){const f=this.terrain.sourceCache.getTerrainCoords(u);for(const _ in f)this._coordsAscending[a][_]||(this._coordsAscending[a][_]=[]),this._coordsAscending[a][_].push(f[_])}}this._coordsAscendingStr={};for(const a of e._order){const o=e._layers[a],u=o.source;if(ht[o.type]&&!this._coordsAscendingStr[u]){this._coordsAscendingStr[u]={};for(const f in this._coordsAscending[u])this._coordsAscendingStr[u][f]=this._coordsAscending[u][f].map(_=>_.key).sort().join()}}for(const a of this._renderableTiles)for(const o in this._coordsAscendingStr){const u=this._coordsAscendingStr[o][a.tileID.key];u&&u!==a.rttCoords[o]&&(a.rtt=[])}}renderLayer(e,i){if(e.isHidden(this.painter.transform.zoom))return!1;const a=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),o=e.type,u=this.painter,f=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(ht[o]&&(this._prevType&&ht[this._prevType]||this._stacks.push([]),this._prevType=o,this._stacks[this._stacks.length-1].push(e.id),!f))return!0;if(ht[this._prevType]||ht[o]&&f){this._prevType=o;const _=this._stacks.length-1,y=this._stacks[_]||[];for(const v of this._renderableTiles){if(this.pool.isFull()&&(vo(this.painter,this.terrain,this._rttTiles,a),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(v),v.rtt[_]){const P=this.pool.getObjectForId(v.rtt[_].id);if(P.stamp===v.rtt[_].stamp){this.pool.useObject(P);continue}}const T=this.pool.getOrCreateFreeObject();this.pool.useObject(T),this.pool.stampObject(T),v.rtt[_]={id:T.id,stamp:T.stamp},u.context.bindFramebuffer.set(T.fbo.framebuffer),u.context.clear({color:c.b4.transparent,stencil:0}),u.currentStencilSource=void 0;for(let P=0;P<y.length;P++){const S=u.style._layers[y[P]],A=S.source?this._coordsAscending[S.source][v.tileID.key]:[v.tileID];u.context.viewport.set([0,0,T.fbo.width,T.fbo.height]),u._renderTileClippingMasks(S,A,!0),u.renderLayer(u,u.style.sourceCaches[S.source],S,A,a),S.source&&(v.rttCoords[S.source]=this._coordsAscendingStr[S.source][v.tileID.key])}}return vo(this.painter,this.terrain,this._rttTiles,a),this._rttTiles=[],this.pool.freeAllObjects(),ht[o]}return!1}}const ec={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},ws=Pi,Ts={hash:!1,interactive:!0,bearingSnap:7,attributionControl:vs,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:c.a.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0},Io={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class Co{constructor(e,i,a=!1){this.mousedown=u=>{this.startMove(u,ue.mousePos(this.element,u)),ue.addEventListener(window,"mousemove",this.mousemove),ue.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=u=>{this.move(u,ue.mousePos(this.element,u))},this.mouseup=u=>{this._rotatePitchHanlder.dragEnd(u),this.offTemp()},this.touchstart=u=>{u.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=ue.touchPos(this.element,u.targetTouches)[0],this.startMove(u,this._startPos),ue.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),ue.addEventListener(window,"touchend",this.touchend))},this.touchmove=u=>{u.targetTouches.length!==1?this.reset():(this._lastPos=ue.touchPos(this.element,u.targetTouches)[0],this.move(u,this._lastPos))},this.touchend=u=>{u.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHanlder.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=i;const o=new xs;this._rotatePitchHanlder=new Ae({clickTolerance:3,move:(u,f)=>{const _=i.getBoundingClientRect(),y=new c.P((_.bottom-_.top)/2,(_.right-_.left)/2);return{bearingDelta:c.c7(new c.P(u.x,f.y),f,y),pitchDelta:a?-.5*(f.y-u.y):void 0}},moveStateManager:o,enable:!0,assignEvents:()=>{}}),this.map=e,ue.addEventListener(i,"mousedown",this.mousedown),ue.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),ue.addEventListener(i,"touchcancel",this.reset)}startMove(e,i){this._rotatePitchHanlder.dragStart(e,i),ue.disableDrag()}move(e,i){const a=this.map,{bearingDelta:o,pitchDelta:u}=this._rotatePitchHanlder.dragMove(e,i)||{};o&&a.setBearing(a.getBearing()+o),u&&a.setPitch(a.getPitch()+u)}off(){const e=this.element;ue.removeEventListener(e,"mousedown",this.mousedown),ue.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),ue.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),ue.removeEventListener(window,"touchend",this.touchend),ue.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){ue.enableDrag(),ue.removeEventListener(window,"mousemove",this.mousemove),ue.removeEventListener(window,"mouseup",this.mouseup),ue.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),ue.removeEventListener(window,"touchend",this.touchend)}}let or;function Nn(h,e,i){const a=new c.N(h.lng,h.lat);if(h=new c.N(h.lng,h.lat),e){const o=new c.N(h.lng-360,h.lat),u=new c.N(h.lng+360,h.lat),f=i.locationToScreenPoint(h).distSqr(e);i.locationToScreenPoint(o).distSqr(e)<f?h=o:i.locationToScreenPoint(u).distSqr(e)<f&&(h=u)}for(;Math.abs(h.lng-i.center.lng)>180;){const o=i.locationToScreenPoint(h);if(o.x>=0&&o.y>=0&&o.x<=i.width&&o.y<=i.height)break;h.lng>i.center.lng?h.lng-=360:h.lng+=360}return h.lng!==a.lng&&i.isPointOnMapSurface(i.locationToScreenPoint(h))?h:a}const Ps={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 ga(h,e,i){const a=h.classList;for(const o in Ps)a.remove(`maplibregl-${i}-anchor-${o}`);a.add(`maplibregl-${i}-anchor-${e}`)}class Ms extends c.E{constructor(e){if(super(),this._onKeyPress=i=>{const a=i.code,o=i.charCode||i.keyCode;a!=="Space"&&a!=="Enter"&&o!==32&&o!==13||this.togglePopup()},this._onMapClick=i=>{const a=i.originalEvent.target,o=this._element;this._popup&&(a===o||o.contains(a))&&this.togglePopup()},this._update=i=>{var a;if(!this._map)return;const o=this._map.loaded()&&!this._map.isMoving();((i==null?void 0:i.type)==="terrain"||(i==null?void 0:i.type)==="render"&&!o)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?Nn(this._lngLat,this._flatPos,this._map.transform):(a=this._lngLat)===null||a===void 0?void 0:a.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let u="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?u=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(u=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let f="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?f="rotateX(0deg)":this._pitchAlignment==="map"&&(f=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||i&&i.type!=="moveend"||(this._pos=this._pos.round()),ue.setTransform(this._element,`${Ps[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${f} ${u}`),Ze.frameAsync(new AbortController).then(()=>{this._updateOpacity(i&&i.type==="moveend")}).catch(()=>{})},this._onMove=i=>{if(!this._isDragging){const a=this._clickTolerance||this._map._clickTolerance;this._isDragging=i.point.dist(this._pointerdownPos)>=a}this._isDragging&&(this._pos=i.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new c.k("dragstart"))),this.fire(new c.k("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new c.k("dragend")),this._state="inactive"},this._addDragHandler=i=>{this._element.contains(i.originalEvent.target)&&(i.preventDefault(),this._positionDelta=i.point.sub(this._pos).add(this._offset),this._pointerdownPos=i.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment!=="auto"?e.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(e==null?void 0:e.opacity,e==null?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=c.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=ue.create("div");const i=ue.createNS("http://www.w3.org/2000/svg","svg"),a=41,o=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${a}px`),i.setAttributeNS(null,"width",`${o}px`),i.setAttributeNS(null,"viewBox",`0 0 ${o} ${a}`);const u=ue.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"stroke","none"),u.setAttributeNS(null,"stroke-width","1"),u.setAttributeNS(null,"fill","none"),u.setAttributeNS(null,"fill-rule","evenodd");const f=ue.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"fill-rule","nonzero");const _=ue.createNS("http://www.w3.org/2000/svg","g");_.setAttributeNS(null,"transform","translate(3.0, 29.0)"),_.setAttributeNS(null,"fill","#000000");const y=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const U of y){const G=ue.createNS("http://www.w3.org/2000/svg","ellipse");G.setAttributeNS(null,"opacity","0.04"),G.setAttributeNS(null,"cx","10.5"),G.setAttributeNS(null,"cy","5.80029008"),G.setAttributeNS(null,"rx",U.rx),G.setAttributeNS(null,"ry",U.ry),_.appendChild(G)}const v=ue.createNS("http://www.w3.org/2000/svg","g");v.setAttributeNS(null,"fill",this._color);const T=ue.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"),v.appendChild(T);const P=ue.createNS("http://www.w3.org/2000/svg","g");P.setAttributeNS(null,"opacity","0.25"),P.setAttributeNS(null,"fill","#000000");const S=ue.createNS("http://www.w3.org/2000/svg","path");S.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"),P.appendChild(S);const A=ue.createNS("http://www.w3.org/2000/svg","g");A.setAttributeNS(null,"transform","translate(6.0, 7.0)"),A.setAttributeNS(null,"fill","#FFFFFF");const R=ue.createNS("http://www.w3.org/2000/svg","g");R.setAttributeNS(null,"transform","translate(8.0, 8.0)");const V=ue.createNS("http://www.w3.org/2000/svg","circle");V.setAttributeNS(null,"fill","#000000"),V.setAttributeNS(null,"opacity","0.25"),V.setAttributeNS(null,"cx","5.5"),V.setAttributeNS(null,"cy","5.5"),V.setAttributeNS(null,"r","5.4999962");const N=ue.createNS("http://www.w3.org/2000/svg","circle");N.setAttributeNS(null,"fill","#FFFFFF"),N.setAttributeNS(null,"cx","5.5"),N.setAttributeNS(null,"cy","5.5"),N.setAttributeNS(null,"r","5.4999962"),R.appendChild(V),R.appendChild(N),f.appendChild(_),f.appendChild(v),f.appendChild(P),f.appendChild(A),f.appendChild(R),i.appendChild(f),i.setAttributeNS(null,"height",a*this._scale+"px"),i.setAttributeNS(null,"width",o*this._scale+"px"),this._element.appendChild(i),this._offset=c.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",i=>{i.preventDefault()}),this._element.addEventListener("mousedown",i=>{i.preventDefault()}),ga(this._element,this._anchor,"marker"),e&&e.className)for(const i of e.className.split(" "))this._element.classList.add(i);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),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),ue.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=c.N.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const o=Math.abs(13.5)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[o,-1*(38.1-13.5+o)],"bottom-right":[-o,-1*(38.1-13.5+o)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){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 i,a;if(!(!((i=this._map)===null||i===void 0)&&i.terrain)){const P=this._map.transform.isLocationOccluded(this._lngLat)?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==P&&(this._element.style.opacity=P))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const o=this._map,u=o.terrain.depthAtPoint(this._pos),f=o.terrain.getElevationForLngLatZoom(this._lngLat,o.transform.tileZoom);if(o.transform.lngLatToCameraDepth(this._lngLat,f)-u<.006)return void(this._element.style.opacity=this._opacity);const _=-this._offset.y/o.transform.pixelsPerMeter,y=Math.sin(o.getPitch()*Math.PI/180)*_,v=o.terrain.depthAtPoint(new c.P(this._pos.x,this._pos.y-this._offset.y)),T=o.transform.lngLatToCameraDepth(this._lngLat,f+y)-v>.006;!((a=this._popup)===null||a===void 0)&&a.isOpen()&&T&&this._popup.remove(),this._element.style.opacity=T?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=c.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,i){return e===void 0&&i===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),e!==void 0&&(this._opacity=e),i!==void 0&&(this._opacityWhenCovered=i),this._map&&this._updateOpacity(!0),this}}const Eo={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Vn=0,fn=!1;const Ao={maxWidth:100,unit:"metric"};function ya(h,e,i){const a=i&&i.maxWidth||100,o=h._container.clientHeight/2,u=h._container.clientWidth/2,f=h.unproject([u-a/2,o]),_=h.unproject([u+a/2,o]),y=Math.round(h.project(_).x-h.project(f).x),v=Math.min(a,y,h._container.clientWidth),T=f.distanceTo(_);if(i&&i.unit==="imperial"){const P=3.2808*T;P>5280?Ar(e,v,P/5280,h._getUIString("ScaleControl.Miles")):Ar(e,v,P,h._getUIString("ScaleControl.Feet"))}else i&&i.unit==="nautical"?Ar(e,v,T/1852,h._getUIString("ScaleControl.NauticalMiles")):T>=1e3?Ar(e,v,T/1e3,h._getUIString("ScaleControl.Kilometers")):Ar(e,v,T,h._getUIString("ScaleControl.Meters"))}function Ar(h,e,i,a){const o=function(u){const f=Math.pow(10,`${Math.floor(u)}`.length-1);let _=u/f;return _=_>=10?10:_>=5?5:_>=3?3:_>=2?2:_>=1?1:function(y){const v=Math.pow(10,Math.ceil(-Math.log(y)/Math.LN10));return Math.round(y*v)/v}(_),f*_}(i);h.style.width=e*(o/i)+"px",h.innerHTML=`${o}&nbsp;${a}`}const zo={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},ko=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Ss(h){if(h){if(typeof h=="number"){const e=Math.round(Math.abs(h)/Math.SQRT2);return{center:new c.P(0,0),top:new c.P(0,h),"top-left":new c.P(e,e),"top-right":new c.P(-e,e),bottom:new c.P(0,-h),"bottom-left":new c.P(e,-e),"bottom-right":new c.P(-e,-e),left:new c.P(h,0),right:new c.P(-h,0)}}if(h instanceof c.P||Array.isArray(h)){const e=c.P.convert(h);return{center:e,top:e,"top-left":e,"top-right":e,bottom:e,"bottom-left":e,"bottom-right":e,left:e,right:e}}return{center:c.P.convert(h.center||[0,0]),top:c.P.convert(h.top||[0,0]),"top-left":c.P.convert(h["top-left"]||[0,0]),"top-right":c.P.convert(h["top-right"]||[0,0]),bottom:c.P.convert(h.bottom||[0,0]),"bottom-left":c.P.convert(h["bottom-left"]||[0,0]),"bottom-right":c.P.convert(h["bottom-right"]||[0,0]),left:c.P.convert(h.left||[0,0]),right:c.P.convert(h.right||[0,0])}}return Ss(new c.P(0,0))}const Do=Pi;z.AJAXError=c.cg,z.Event=c.k,z.Evented=c.E,z.LngLat=c.N,z.MercatorCoordinate=c.Y,z.Point=c.P,z.addProtocol=c.ch,z.config=c.a,z.removeProtocol=c.ci,z.AttributionControl=ma,z.BoxZoomHandler=Nl,z.CanvasSource=Hr,z.CooperativeGesturesHandler=So,z.DoubleClickZoomHandler=ar,z.DragPanHandler=pa,z.DragRotateHandler=Po,z.EdgeInsets=ri,z.FullscreenControl=class extends c.E{constructor(h={}){super(),this._onFullscreenChange=()=>{var e;let i=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((e=i==null?void 0:i.shadowRoot)===null||e===void 0)&&e.fullscreenElement;)i=i.shadowRoot.fullscreenElement;i===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,h&&h.container&&(h.container instanceof HTMLElement?this._container=h.container:c.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(h){return this._map=h,this._container||(this._container=this._map.getContainer()),this._controlContainer=ue.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){ue.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const h=this._fullscreenButton=ue.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);ue.create("span","maplibregl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const h=this._getTitle();this._fullscreenButton.setAttribute("aria-label",h),this._fullscreenButton.title=h}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new c.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new c.k("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},z.GeoJSONSource=br,z.GeolocateControl=class extends c.E{constructor(h){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new c.k("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(e),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new c.k("geolocate",e)),this._finish()}},this._updateCamera=e=>{const i=new c.N(e.coords.longitude,e.coords.latitude),a=e.coords.accuracy,o=this._map.getBearing(),u=c.e({bearing:o},this.options.fitBoundsOptions),f=zt.fromLngLat(i,a);this._map.fitBounds(f,u,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const i=new c.N(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=e=>{if(this._map){if(this.options.trackUserLocation)if(e.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const i=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=i,this._geolocateButton.setAttribute("aria-label",i),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(e.code===3&&fn)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new c.k("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=ue.create("button","maplibregl-ctrl-geolocate",this._container),ue.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(e===!1){c.w("Geolocation support is not available so the GeolocateControl will be disabled.");const i=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=i,this._geolocateButton.setAttribute("aria-label",i)}else{const i=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=i,this._geolocateButton.setAttribute("aria-label",i)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=ue.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ms({element:this._dotElement}),this._circleElement=ue.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ms({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",i=>{i.geolocateSource||this._watchState!=="ACTIVE_LOCK"||i.originalEvent&&i.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new c.k("trackuserlocationend")),this.fire(new c.k("userlocationlostfocus")))})}},this.options=c.e({},Eo,h)}onAdd(h){return this._map=h,this._container=ue.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return c._(this,arguments,void 0,function*(e=!1){if(or!==void 0&&!e)return or;if(window.navigator.permissions===void 0)return or=!!window.navigator.geolocation,or;try{or=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{or=!!window.navigator.geolocation}return or})}().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(),ue.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Vn=0,fn=!1}_isOutOfMapMaxBounds(h){const e=this._map.getMaxBounds(),i=h.coords;return e&&(i.longitude<e.getWest()||i.longitude>e.getEast()||i.latitude<e.getSouth()||i.latitude>e.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const h=this._map.getBounds(),e=h.getSouthEast(),i=h.getNorthEast(),a=e.distanceTo(i),o=Math.ceil(this._accuracy/(a/this._map._container.clientHeight)*2);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`}trigger(){if(!this._setup)return c.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new c.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Vn--,fn=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new c.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new c.k("trackuserlocationstart")),this.fire(new c.k("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let h;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Vn++,Vn>1?(h={maximumAge:6e5,timeout:0},fn=!0):(h=this.options.positionOptions,fn=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,h)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},z.GlobeControl=class{constructor(){this._toggleProjection=()=>{var h;const e=(h=this._map.getProjection())===null||h===void 0?void 0:h.type;this._map.setProjection(e!=="mercator"&&e?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var h;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),((h=this._map.getProjection())===null||h===void 0?void 0:h.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(h){return this._map=h,this._container=ue.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=ue.create("button","maplibregl-ctrl-globe",this._container),ue.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){ue.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},z.Hash=wo,z.ImageSource=mi,z.KeyboardHandler=Wl,z.LngLatBounds=zt,z.LogoControl=_a,z.Map=class extends Ne{constructor(h){var e,i;c.cd.mark(c.ce.create);const a=Object.assign(Object.assign(Object.assign({},Ts),h),{canvasContextAttributes:Object.assign(Object.assign({},Ts.canvasContextAttributes),h.canvasContextAttributes)});if(a.minZoom!=null&&a.maxZoom!=null&&a.minZoom>a.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(a.minPitch!=null&&a.maxPitch!=null&&a.minPitch>a.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(a.minPitch!=null&&a.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(a.maxPitch!=null&&a.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const o=new ir,u=new Fs;if(a.minZoom!==void 0&&o.setMinZoom(a.minZoom),a.maxZoom!==void 0&&o.setMaxZoom(a.maxZoom),a.minPitch!==void 0&&o.setMinPitch(a.minPitch),a.maxPitch!==void 0&&o.setMaxPitch(a.maxPitch),a.renderWorldCopies!==void 0&&o.setRenderWorldCopies(a.renderWorldCopies),super(o,u,{bearingSnap:a.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new ui,this._controls=[],this._mapId=c.a1(),this._contextLost=_=>{_.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new c.k("webglcontextlost",{originalEvent:_}))},this._contextRestored=_=>{this._setupPainter(),this.resize(),this._update(),this.fire(new c.k("webglcontextrestored",{originalEvent:_}))},this._onMapScroll=_=>{if(_.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=a.interactive,this._maxTileCacheSize=a.maxTileCacheSize,this._maxTileCacheZoomLevels=a.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},a.canvasContextAttributes),this._trackResize=a.trackResize===!0,this._bearingSnap=a.bearingSnap,this._centerClampedToGround=a.centerClampedToGround,this._refreshExpiredTiles=a.refreshExpiredTiles===!0,this._fadeDuration=a.fadeDuration,this._crossSourceCollisions=a.crossSourceCollisions===!0,this._collectResourceTiming=a.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},ec),a.locale),this._clickTolerance=a.clickTolerance,this._overridePixelRatio=a.pixelRatio,this._maxCanvasSize=a.maxCanvasSize,this.transformCameraUpdate=a.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=a.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=oi.addThrottleControl(()=>this.isMoving()),this._requestManager=new gr(a.transformRequest),typeof a.container=="string"){if(this._container=document.getElementById(a.container),!this._container)throw new Error(`Container '${a.container}' not found.`)}else{if(!(a.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=a.container}if(a.maxBounds&&this.setMaxBounds(a.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let _=!1;const y=Cr(v=>{this._trackResize&&!this._removed&&(this.resize(v),this.redraw())},50);this._resizeObserver=new ResizeObserver(v=>{_?y(v):_=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Le(this,a),this._hash=a.hash&&new wo(typeof a.hash=="string"&&a.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:a.center,elevation:a.elevation,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch,roll:a.roll}),a.bounds&&(this.resize(),this.fitBounds(a.bounds,c.e({},a.fitBoundsOptions,{duration:0}))));const f=typeof a.style=="string"||((i=(e=a.style)===null||e===void 0?void 0:e.projection)===null||i===void 0?void 0:i.type)!=="globe";this.resize(null,f),this._localIdeographFontFamily=a.localIdeographFontFamily,this._validateStyle=a.validateStyle,a.style&&this.setStyle(a.style,{localIdeographFontFamily:a.localIdeographFontFamily}),a.attributionControl&&this.addControl(new ma(typeof a.attributionControl=="boolean"?void 0:a.attributionControl)),a.maplibreLogo&&this.addControl(new _a,a.logoPosition),this.on("style.load",()=>{if(f||this._resizeTransform(),this.transform.unmodified){const _=c.M(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(_)}}),this.on("data",_=>{this._update(_.dataType==="style"),this.fire(new c.k(`${_.dataType}data`,_))}),this.on("dataloading",_=>{this.fire(new c.k(`${_.dataType}dataloading`,_))}),this.on("dataabort",_=>{this.fire(new c.k("sourcedataabort",_))})}_getMapId(){return this._mapId}addControl(h,e){if(e===void 0&&(e=h.getDefaultPosition?h.getDefaultPosition():"top-right"),!h||!h.onAdd)return this.fire(new c.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const i=h.onAdd(this);this._controls.push(h);const a=this._controlPositions[e];return e.indexOf("bottom")!==-1?a.insertBefore(i,a.firstChild):a.appendChild(i),this}removeControl(h){if(!h||!h.onRemove)return this.fire(new c.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const e=this._controls.indexOf(h);return e>-1&&this._controls.splice(e,1),h.onRemove(this),this}hasControl(h){return this._controls.indexOf(h)>-1}calculateCameraOptionsFromTo(h,e,i,a){return a==null&&this.terrain&&(a=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(h,e,i,a)}resize(h,e=!0){const[i,a]=this._containerDimensions(),o=this._getClampedPixelRatio(i,a);if(this._resizeCanvas(i,a,o),this.painter.resize(i,a,o),this.painter.overLimit()){const f=this.painter.context.gl;this._maxCanvasSize=[f.drawingBufferWidth,f.drawingBufferHeight];const _=this._getClampedPixelRatio(i,a);this._resizeCanvas(i,a,_),this.painter.resize(i,a,_)}this._resizeTransform(e);const u=!this._moving;return u&&(this.stop(),this.fire(new c.k("movestart",h)).fire(new c.k("move",h))),this.fire(new c.k("resize",h)),u&&this.fire(new c.k("moveend",h)),this}_resizeTransform(h=!0){var e;const[i,a]=this._containerDimensions();this.transform.resize(i,a,h),(e=this._requestedCameraState)===null||e===void 0||e.resize(i,a,h)}_getClampedPixelRatio(h,e){const{0:i,1:a}=this._maxCanvasSize,o=this.getPixelRatio(),u=h*o,f=e*o;return Math.min(u>i?i/u:1,f>a?a/f:1)*o}getPixelRatio(){var h;return(h=this._overridePixelRatio)!==null&&h!==void 0?h:devicePixelRatio}setPixelRatio(h){this._overridePixelRatio=h,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(h){return this.transform.setMaxBounds(zt.convert(h)),this._update()}setMinZoom(h){if((h=h??-2)>=-2&&h<=this.transform.maxZoom)return this.transform.setMinZoom(h),this._update(),this.getZoom()<h&&this.setZoom(h),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(h){if((h=h??22)>=this.transform.minZoom)return this.transform.setMaxZoom(h),this._update(),this.getZoom()>h&&this.setZoom(h),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(h){if((h=h??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(h>=0&&h<=this.transform.maxPitch)return this.transform.setMinPitch(h),this._update(),this.getPitch()<h&&this.setPitch(h),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(h){if((h=h??60)>180)throw new Error("maxPitch must be less than or equal to 180");if(h>=this.transform.minPitch)return this.transform.setMaxPitch(h),this._update(),this.getPitch()>h&&this.setPitch(h),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(h){return this.transform.setRenderWorldCopies(h),this._update()}project(h){return this.transform.locationToScreenPoint(c.N.convert(h),this.style&&this.terrain)}unproject(h){return this.transform.screenPointToLocation(c.P.convert(h),this.terrain)}isMoving(){var h;return this._moving||((h=this.handlers)===null||h===void 0?void 0:h.isMoving())}isZooming(){var h;return this._zooming||((h=this.handlers)===null||h===void 0?void 0:h.isZooming())}isRotating(){var h;return this._rotating||((h=this.handlers)===null||h===void 0?void 0:h.isRotating())}_createDelegatedListener(h,e,i){if(h==="mouseenter"||h==="mouseover"){let a=!1;return{layers:e,listener:i,delegates:{mousemove:u=>{const f=e.filter(y=>this.getLayer(y)),_=f.length!==0?this.queryRenderedFeatures(u.point,{layers:f}):[];_.length?a||(a=!0,i.call(this,new At(h,this,u.originalEvent,{features:_}))):a=!1},mouseout:()=>{a=!1}}}}if(h==="mouseleave"||h==="mouseout"){let a=!1;return{layers:e,listener:i,delegates:{mousemove:f=>{const _=e.filter(y=>this.getLayer(y));(_.length!==0?this.queryRenderedFeatures(f.point,{layers:_}):[]).length?a=!0:a&&(a=!1,i.call(this,new At(h,this,f.originalEvent)))},mouseout:f=>{a&&(a=!1,i.call(this,new At(h,this,f.originalEvent)))}}}}{const a=o=>{const u=e.filter(_=>this.getLayer(_)),f=u.length!==0?this.queryRenderedFeatures(o.point,{layers:u}):[];f.length&&(o.features=f,i.call(this,o),delete o.features)};return{layers:e,listener:i,delegates:{[h]:a}}}}_saveDelegatedListener(h,e){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[h]=this._delegatedListeners[h]||[],this._delegatedListeners[h].push(e)}_removeDelegatedListener(h,e,i){if(!this._delegatedListeners||!this._delegatedListeners[h])return;const a=this._delegatedListeners[h];for(let o=0;o<a.length;o++){const u=a[o];if(u.listener===i&&u.layers.length===e.length&&u.layers.every(f=>e.includes(f))){for(const f in u.delegates)this.off(f,u.delegates[f]);return void a.splice(o,1)}}}on(h,e,i){if(i===void 0)return super.on(h,e);const a=typeof e=="string"?[e]:e,o=this._createDelegatedListener(h,a,i);this._saveDelegatedListener(h,o);for(const u in o.delegates)this.on(u,o.delegates[u]);return{unsubscribe:()=>{this._removeDelegatedListener(h,a,i)}}}once(h,e,i){if(i===void 0)return super.once(h,e);const a=typeof e=="string"?[e]:e,o=this._createDelegatedListener(h,a,i);for(const u in o.delegates){const f=o.delegates[u];o.delegates[u]=(..._)=>{this._removeDelegatedListener(h,a,i),f(..._)}}this._saveDelegatedListener(h,o);for(const u in o.delegates)this.once(u,o.delegates[u]);return this}off(h,e,i){return i===void 0?super.off(h,e):(this._removeDelegatedListener(h,typeof e=="string"?[e]:e,i),this)}queryRenderedFeatures(h,e){if(!this.style)return[];let i;const a=h instanceof c.P||Array.isArray(h),o=a?h:[[0,0],[this.transform.width,this.transform.height]];if(e=e||(a?{}:h)||{},o instanceof c.P||typeof o[0]=="number")i=[c.P.convert(o)];else{const u=c.P.convert(o[0]),f=c.P.convert(o[1]);i=[u,new c.P(f.x,u.y),f,new c.P(u.x,f.y),u]}return this.style.queryRenderedFeatures(i,e,this.transform)}querySourceFeatures(h,e){return this.style.querySourceFeatures(h,e)}setStyle(h,e){return(e=c.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},e)).diff!==!1&&e.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&h?(this._diffStyle(h,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._updateStyle(h,e))}setTransformRequest(h){return this._requestManager.setTransformRequest(h),this}_getUIString(h){const e=this._locale[h];if(e==null)throw new Error(`Missing UI string '${h}'`);return e}_updateStyle(h,e){var i,a;if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(h,e));const o=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!h)),h?(this.style=new Ei(this,e||{}),this.style.setEventedParent(this,{style:this.style}),typeof h=="string"?this.style.loadURL(h,e,o):this.style.loadJSON(h,e,o),this):((a=(i=this.style)===null||i===void 0?void 0:i.projection)===null||a===void 0||a.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Ei(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(h,e){if(typeof h=="string"){const i=this._requestManager.transformRequest(h,"Style");c.h(i,new AbortController).then(a=>{this._updateDiff(a.data,e)}).catch(a=>{a&&this.fire(new c.j(a))})}else typeof h=="object"&&this._updateDiff(h,e)}_updateDiff(h,e){try{this.style.setState(h,e)&&this._update(!0)}catch(i){c.w(`Unable to perform style diff: ${i.message||i.error||i}. Rebuilding the style from scratch.`),this._updateStyle(h,e)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():c.w("There is no style added to the map.")}addSource(h,e){return this._lazyInitEmptyStyle(),this.style.addSource(h,e),this._update(!0)}isSourceLoaded(h){const e=this.style&&this.style.sourceCaches[h];if(e!==void 0)return e.loaded();this.fire(new c.j(new Error(`There is no source with ID '${h}'`)))}setTerrain(h){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),h){const e=this.style.sourceCaches[h.source];if(!e)throw new Error(`cannot load terrain, because there exists no source with ID: ${h.source}`);this.terrain===null&&e.reload();for(const i in this.style._layers){const a=this.style._layers[i];a.type==="hillshade"&&a.source===h.source&&c.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Zc(this.painter,e,h),this.painter.renderToTexture=new kt(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=i=>{i.dataType==="style"?this.terrain.sourceCache.freeRtt():i.dataType==="source"&&i.tile&&(i.sourceId!==h.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))),this.terrain.sourceCache.freeRtt(i.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new c.k("terrain",{terrain:h})),this}getTerrain(){var h,e;return(e=(h=this.terrain)===null||h===void 0?void 0:h.options)!==null&&e!==void 0?e:null}areTilesLoaded(){const h=this.style&&this.style.sourceCaches;for(const e in h){const i=h[e]._tiles;for(const a in i){const o=i[a];if(o.state!=="loaded"&&o.state!=="errored")return!1}}return!0}removeSource(h){return this.style.removeSource(h),this._update(!0)}getSource(h){return this.style.getSource(h)}addImage(h,e,i={}){const{pixelRatio:a=1,sdf:o=!1,stretchX:u,stretchY:f,content:_,textFitWidth:y,textFitHeight:v}=i;if(this._lazyInitEmptyStyle(),!(e instanceof HTMLImageElement||c.b(e))){if(e.width===void 0||e.height===void 0)return this.fire(new c.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:T,height:P,data:S}=e,A=e;return this.style.addImage(h,{data:new c.R({width:T,height:P},new Uint8Array(S)),pixelRatio:a,stretchX:u,stretchY:f,content:_,textFitWidth:y,textFitHeight:v,sdf:o,version:0,userImage:A}),A.onAdd&&A.onAdd(this,h),this}}{const{width:T,height:P,data:S}=Ze.getImageData(e);this.style.addImage(h,{data:new c.R({width:T,height:P},S),pixelRatio:a,stretchX:u,stretchY:f,content:_,textFitWidth:y,textFitHeight:v,sdf:o,version:0})}}updateImage(h,e){const i=this.style.getImage(h);if(!i)return this.fire(new c.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const a=e instanceof HTMLImageElement||c.b(e)?Ze.getImageData(e):e,{width:o,height:u,data:f}=a;if(o===void 0||u===void 0)return this.fire(new c.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==i.data.width||u!==i.data.height)return this.fire(new c.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const _=!(e instanceof HTMLImageElement||c.b(e));return i.data.replace(f,_),this.style.updateImage(h,i),this}getImage(h){return this.style.getImage(h)}hasImage(h){return h?!!this.style.getImage(h):(this.fire(new c.j(new Error("Missing required image id"))),!1)}removeImage(h){this.style.removeImage(h)}loadImage(h){return oi.getImage(this._requestManager.transformRequest(h,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(h,e){return this._lazyInitEmptyStyle(),this.style.addLayer(h,e),this._update(!0)}moveLayer(h,e){return this.style.moveLayer(h,e),this._update(!0)}removeLayer(h){return this.style.removeLayer(h),this._update(!0)}getLayer(h){return this.style.getLayer(h)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(h,e,i){return this.style.setLayerZoomRange(h,e,i),this._update(!0)}setFilter(h,e,i={}){return this.style.setFilter(h,e,i),this._update(!0)}getFilter(h){return this.style.getFilter(h)}setPaintProperty(h,e,i,a={}){return this.style.setPaintProperty(h,e,i,a),this._update(!0)}getPaintProperty(h,e){return this.style.getPaintProperty(h,e)}setLayoutProperty(h,e,i,a={}){return this.style.setLayoutProperty(h,e,i,a),this._update(!0)}getLayoutProperty(h,e){return this.style.getLayoutProperty(h,e)}setGlyphs(h,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(h,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(h,e,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(h,e,i,a=>{a||this._update(!0)}),this}removeSprite(h){return this._lazyInitEmptyStyle(),this.style.removeSprite(h),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(h,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(h,e,i=>{i||this._update(!0)}),this}setLight(h,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(h,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(h,e={}){return this._lazyInitEmptyStyle(),this.style.setSky(h,e),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(h,e){return this.style.setFeatureState(h,e),this._update()}removeFeatureState(h,e){return this.style.removeFeatureState(h,e),this._update()}getFeatureState(h){return this.style.getFeatureState(h)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let h=0,e=0;return this._container&&(h=this._container.clientWidth||400,e=this._container.clientHeight||300),[h,e]}_setupContainer(){const h=this._container;h.classList.add("maplibregl-map");const e=this._canvasContainer=ue.create("div","maplibregl-canvas-container",h);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=ue.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),a=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],a);const o=this._controlContainer=ue.create("div","maplibregl-control-container",h),u=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(f=>{u[f]=ue.create("div",`maplibregl-ctrl-${f} `,o)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(h,e,i){this._canvas.width=Math.floor(i*h),this._canvas.height=Math.floor(i*e),this._canvas.style.width=`${h}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const h=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let e=null;this._canvas.addEventListener("webglcontextcreationerror",a=>{e={requestedAttributes:h},a&&(e.statusMessage=a.statusMessage,e.type=a.type)},{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,h):this._canvas.getContext("webgl2",h)||this._canvas.getContext("webgl",h),!i){const a="Failed to initialize WebGL";throw e?(e.message=a,new Error(JSON.stringify(e))):new Error(a)}this.painter=new Rl(i,this.transform),Oe.testSupport(i)}migrateProjection(h,e){super.migrateProjection(h,e),this.painter.transform=h,this.fire(new c.k("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(h){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||h,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(h){return this._update(),this._renderTaskQueue.add(h)}_cancelRenderFrame(h){this._renderTaskQueue.remove(h)}_render(h){var e,i,a,o,u;const f=this._idleTriggered?this._fadeDuration:0,_=((e=this.style.projection)===null||e===void 0?void 0:e.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(h),this._removed)return;let y=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const P=this.transform.zoom,S=Ze.now();this.style.zoomHistory.update(P,S);const A=new c.z(P,{now:S,fadeDuration:f,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),R=A.crossFadingFactor();R===1&&R===this._crossFadingFactor||(y=!0,this._crossFadingFactor=R),this.style.update(A)}const v=((i=this.style.projection)===null||i===void 0?void 0:i.transitionState)>0!==_;(a=this.style.projection)===null||a===void 0||a.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState((o=this.style.projection)===null||o===void 0?void 0:o.transitionState,(u=this.style.projection)===null||u===void 0?void 0:u.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||v)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,f,this._crossSourceCollisions,v),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:f,showPadding:this.showPadding}),this.fire(new c.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,c.cd.mark(c.ce.load),this.fire(new c.k("load"))),this.style&&(this.style.hasTransitions()||y)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const T=this._sourcesDirty||this._styleDirty||this._placementDirty;return T||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new c.k("idle")),!this._loaded||this._fullyLoaded||T||(this._fullyLoaded=!0,c.cd.mark(c.ce.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var h;this._hash&&this._hash.remove();for(const i of this._controls)i.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),oi.removeThrottleControl(this._imageQueueHandle),(h=this._resizeObserver)===null||h===void 0||h.disconnect();const e=this.painter.context.gl.getExtension("WEBGL_lose_context");e!=null&&e.loseContext&&e.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),ue.remove(this._canvasContainer),ue.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),c.cd.clearMetrics(),this._removed=!0,this.fire(new c.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,Ze.frame(this._frameRequest,h=>{c.cd.frame(h),this._frameRequest=null;try{this._render(h)}catch(e){if(!c.cf(e)&&!function(i){return i.message===Ys}(e))throw e}},()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(h){this._showTileBoundaries!==h&&(this._showTileBoundaries=h,this._update())}get showPadding(){return!!this._showPadding}set showPadding(h){this._showPadding!==h&&(this._showPadding=h,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(h){this._showCollisionBoxes!==h&&(this._showCollisionBoxes=h,h?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(h){this._showOverdrawInspector!==h&&(this._showOverdrawInspector=h,this._update())}get repaint(){return!!this._repaint}set repaint(h){this._repaint!==h&&(this._repaint=h,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(h){this._vertices=h,this._update()}get version(){return ws}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(h){return this._lazyInitEmptyStyle(),this.style.setProjection(h),this._update(!0)}},z.MapMouseEvent=At,z.MapTouchEvent=Bn,z.MapWheelEvent=ji,z.Marker=Ms,z.NavigationControl=class{constructor(h){this._updateZoomButtons=()=>{const e=this._map.getZoom(),i=e===this._map.getMaxZoom(),a=e===this._map.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=a,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",a.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,i)=>{const a=this._map._getUIString(`NavigationControl.${i}`);e.title=a,e.setAttribute("aria-label",a)},this.options=c.e({},Io,h),this._container=ue.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})),ue.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})),ue.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=ue.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(h){return this._map=h,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Co(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){ue.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(h,e){const i=ue.create("button",h,this._container);return i.type="button",i.addEventListener("click",e),i}},z.Popup=class extends c.E{constructor(h){super(),this.remove=()=>(this._content&&ue.remove(this._content),this._container&&(ue.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new c.k("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{var i;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=ue.create("div","maplibregl-popup",this._map.getContainer()),this._tip=ue.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const _ of this.options.className.split(" "))this._container.classList.add(_);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?Nn(this._lngLat,this._flatPos,this._map.transform):(i=this._lngLat)===null||i===void 0?void 0:i.wrap(),this._trackPointer&&!e)return;const a=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let o=this.options.anchor;const u=Ss(this.options.offset);if(!o){const _=this._container.offsetWidth,y=this._container.offsetHeight;let v;v=a.y+u.bottom.y<y?["top"]:a.y>this._map.transform.height-y?["bottom"]:[],a.x<_/2?v.push("left"):a.x>this._map.transform.width-_/2&&v.push("right"),o=v.length===0?"bottom":v.join("-")}let f=a.add(u[o]);this.options.subpixelPositioning||(f=f.round()),ue.setTransform(this._container,`${Ps[o]} translate(${f.x}px,${f.y}px)`),ga(this._container,o,"popup")},this._onClose=()=>{this.remove()},this.options=c.e(Object.create(zo),h)}addTo(h){return this._map&&this.remove(),this._map=h,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new c.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=c.N.convert(h),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(h){return this.setDOMContent(document.createTextNode(h))}setHTML(h){const e=document.createDocumentFragment(),i=document.createElement("body");let a;for(i.innerHTML=h;a=i.firstChild,a;)e.appendChild(a);return this.setDOMContent(e)}getMaxWidth(){var h;return(h=this._container)===null||h===void 0?void 0:h.style.maxWidth}setMaxWidth(h){return this.options.maxWidth=h,this._update(),this}setDOMContent(h){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=ue.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(h),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(h){return this._container&&this._container.classList.add(h),this}removeClassName(h){return this._container&&this._container.classList.remove(h),this}setOffset(h){return this.options.offset=h,this._update(),this}toggleClassName(h){if(this._container)return this._container.classList.toggle(h)}setSubpixelPositioning(h){this.options.subpixelPositioning=h}_createCloseButton(){this.options.closeButton&&(this._closeButton=ue.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const h=this._container.querySelector(ko);h&&h.focus()}},z.RasterDEMTileSource=vr,z.RasterTileSource=Bi,z.ScaleControl=class{constructor(h){this._onMove=()=>{ya(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,ya(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Ao),h)}getDefaultPosition(){return"bottom-left"}onAdd(h){return this._map=h,this._container=ue.create("div","maplibregl-ctrl maplibregl-ctrl-scale",h.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){ue.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},z.ScrollZoomHandler=Jl,z.Style=Ei,z.TerrainControl=class{constructor(h){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=h}onAdd(h){return this._map=h,this._container=ue.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=ue.create("button","maplibregl-ctrl-terrain",this._container),ue.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(){ue.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},z.TwoFingersTouchPitchHandler=ua,z.TwoFingersTouchRotateHandler=Hl,z.TwoFingersTouchZoomHandler=ca,z.TwoFingersTouchZoomRotateHandler=Mo,z.VectorTileSource=$r,z.VideoSource=qr,z.addSourceType=(h,e)=>c._(void 0,void 0,void 0,function*(){if(Jn(h))throw new Error(`A source type called "${h}" already exists.`);((i,a)=>{wr[i]=a})(h,e)}),z.clearPrewarmedResources=function(){const h=Ii;h&&(h.isPreloaded()&&h.numActive()===1?(h.release(xn),Ii=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()"))},z.createTileMesh=as,z.getMaxParallelImageRequests=function(){return c.a.MAX_PARALLEL_IMAGE_REQUESTS},z.getRTLTextPluginStatus=function(){return tr().getRTLTextPluginStatus()},z.getVersion=function(){return Do},z.getWorkerCount=function(){return $i.workerCount},z.getWorkerUrl=function(){return c.a.WORKER_URL},z.importScriptInWorkers=function(h){return Zr().broadcast("IS",h)},z.prewarm=function(){Vr().acquire(xn)},z.setMaxParallelImageRequests=function(h){c.a.MAX_PARALLEL_IMAGE_REQUESTS=h},z.setRTLTextPlugin=function(h,e){return tr().setRTLTextPlugin(h,e)},z.setWorkerCount=function(h){$i.workerCount=h},z.setWorkerUrl=function(h){c.a.WORKER_URL=h}});var Ra=Rr;return Ra})}(wc)),wc.exports}var _d=ef();const tf=Yp(_d),nf=Jp({__proto__:null,default:tf},[_d]);export{nf as m};