@maptiler/sdk 1.0.10 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- (function(Ve,os){typeof exports=="object"&&typeof module<"u"?os(exports):typeof define=="function"&&define.amd?define(["exports"],os):(Ve=typeof globalThis<"u"?globalThis:Ve||self,os(Ve.maptilersdk={}))})(this,function(Ve){"use strict";var os=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yc(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var Jc={exports:{}};(function(A,b){(function(z,W){A.exports=W()})(os,function(){var z,W,ie;function de(h,ve){if(!z)z=ve;else if(!W)W=ve;else{var Ge="var sharedChunk = {}; ("+z+")(sharedChunk); ("+W+")(sharedChunk);",et={};z(et),ie=ve(et),typeof window<"u"&&(ie.workerUrl=window.URL.createObjectURL(new Blob([Ge],{type:"text/javascript"})))}}de(["exports"],function(h){var ve=Ge;function Ge(i,e,r,a){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(a-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=e,this.p2x=r,this.p2y=a}function et(i,e,r,a){const c=new ve(i,e,r,a);return function(u){return c.solve(u)}}Ge.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,e){if(e===void 0&&(e=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,a=0;a<8;a++){var c=this.sampleCurveX(r)-i;if(Math.abs(c)<e)return r;var u=this.sampleCurveDerivativeX(r);if(Math.abs(u)<1e-6)break;r-=c/u}var p=0,f=1;for(r=i,a=0;a<20&&(c=this.sampleCurveX(r),!(Math.abs(c-i)<e));a++)i>c?p=r:f=r,r=.5*(f-p)+p;return r},solve:function(i,e){return this.sampleCurveY(this.solveCurveX(i,e))}};const Ye=et(.25,.1,.25,1);function pe(i,e,r){return Math.min(r,Math.max(e,i))}function ee(i,e,r){const a=r-e,c=((i-e)%a+a)%a+e;return c===e?r:c}function Be(i,...e){for(const r of e)for(const a in r)i[a]=r[a];return i}let Ct=1;function Ft(i,e){i.forEach(r=>{e[r]&&(e[r]=e[r].bind(e))})}function mr(i,e,r){const a={};for(const c in i)a[c]=e.call(r||this,i[c],c,i);return a}function dn(i,e,r){const a={};for(const c in i)e.call(r||this,i[c],c,i)&&(a[c]=i[c]);return a}function Ci(i){return Array.isArray(i)?i.map(Ci):typeof i=="object"&&i?mr(i,Ci):i}const Or={};function dt(i){Or[i]||(typeof console<"u"&&console.warn(i),Or[i]=!0)}function Qt(i,e,r){return(r.y-i.y)*(e.x-i.x)>(e.y-i.y)*(r.x-i.x)}function us(i){let e=0;for(let r,a,c=0,u=i.length,p=u-1;c<u;p=c++)r=i[c],a=i[p],e+=(a.x-r.x)*(r.y+a.y);return e}function Oi(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}let pn=null;function fr(i){if(pn==null){const e=i.navigator?i.navigator.userAgent:null;pn=!!i.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return pn}function gr(i){return typeof ImageBitmap<"u"&&i instanceof ImageBitmap}const da="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let nr,Mt;const pa={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(i){const e=requestAnimationFrame(i);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(i,e=0){return this.getImageCanvasContext(i).getImageData(-e,-e,i.width+2*e,i.height+2*e)},getImageCanvasContext(i){const e=window.document.createElement("canvas"),r=e.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("failed to create canvas 2d context");return e.width=i.width,e.height=i.height,r.drawImage(i,0,0,i.width,i.height),r},resolveURL:i=>(nr||(nr=document.createElement("a")),nr.href=i,nr.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(Mt==null&&(Mt=matchMedia("(prefers-reduced-motion: reduce)")),Mt.matches)}};var He=Ui;function Ui(i,e){this.x=i,this.y=e}Ui.prototype={clone:function(){return new Ui(this.x,this.y)},add:function(i){return this.clone()._add(i)},sub:function(i){return this.clone()._sub(i)},multByPoint:function(i){return this.clone()._multByPoint(i)},divByPoint:function(i){return this.clone()._divByPoint(i)},mult:function(i){return this.clone()._mult(i)},div:function(i){return this.clone()._div(i)},rotate:function(i){return this.clone()._rotate(i)},rotateAround:function(i,e){return this.clone()._rotateAround(i,e)},matMult:function(i){return this.clone()._matMult(i)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(i){return this.x===i.x&&this.y===i.y},dist:function(i){return Math.sqrt(this.distSqr(i))},distSqr:function(i){var e=i.x-this.x,r=i.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith:function(i){return this.angleWithSep(i.x,i.y)},angleWithSep:function(i,e){return Math.atan2(this.x*e-this.y*i,this.x*i+this.y*e)},_matMult:function(i){var e=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=e,this},_add:function(i){return this.x+=i.x,this.y+=i.y,this},_sub:function(i){return this.x-=i.x,this.y-=i.y,this},_mult:function(i){return this.x*=i,this.y*=i,this},_div:function(i){return this.x/=i,this.y/=i,this},_multByPoint:function(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint:function(i){return this.x/=i.x,this.y/=i.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var i=this.y;return this.y=this.x,this.x=-i,this},_rotate:function(i){var e=Math.cos(i),r=Math.sin(i),a=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=a,this},_rotateAround:function(i,e){var r=Math.cos(i),a=Math.sin(i),c=e.y+a*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-a*(this.y-e.y),this.y=c,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Ui.convert=function(i){return i instanceof Ui?i:Array.isArray(i)?new Ui(i[0],i[1]):i};const Ur={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,REGISTERED_PROTOCOLS:{}};class Er extends Error{constructor(e,r,a,c){super(`AJAXError: ${r} (${e}): ${a}`),this.status=e,this.statusText=r,this.url=a,this.body=c}}const ar=Oi()?()=>self.worker&&self.worker.referrer:()=>(window.location.protocol==="blob:"?window.parent:window).location.href;function ma(i,e){const r=new AbortController,a=new Request(i.url,{method:i.method||"GET",body:i.body,credentials:i.credentials,headers:i.headers,referrer:ar(),signal:r.signal});let c=!1,u=!1;return i.type==="json"&&a.headers.set("Accept","application/json"),u||fetch(a).then(p=>p.ok?(f=>{(i.type==="arrayBuffer"?f.arrayBuffer():i.type==="json"?f.json():f.text()).then(_=>{u||(c=!0,e(null,_,f.headers.get("Cache-Control"),f.headers.get("Expires")))}).catch(_=>{u||e(new Error(_.message))})})(p):p.blob().then(f=>e(new Er(p.status,p.statusText,i.url,f)))).catch(p=>{p.code!==20&&e(new Error(p.message))}),{cancel:()=>{u=!0,c||r.abort()}}}const mn=function(i,e){if(/:\/\//.test(i.url)&&!/^https?:|^file:/.test(i.url)){if(Oi()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",i,e);if(!Oi()){const a=i.url.substring(0,i.url.indexOf("://"));return(Ur.REGISTERED_PROTOCOLS[a]||ma)(i,e)}}if(!(/^file:/.test(r=i.url)||/^file:/.test(ar())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return ma(i,e);if(Oi()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",i,e,void 0,!0)}var r;return function(a,c){const u=new XMLHttpRequest;u.open(a.method||"GET",a.url,!0),a.type==="arrayBuffer"&&(u.responseType="arraybuffer");for(const p in a.headers)u.setRequestHeader(p,a.headers[p]);return a.type==="json"&&(u.responseType="text",u.setRequestHeader("Accept","application/json")),u.withCredentials=a.credentials==="include",u.onerror=()=>{c(new Error(u.statusText))},u.onload=()=>{if((u.status>=200&&u.status<300||u.status===0)&&u.response!==null){let p=u.response;if(a.type==="json")try{p=JSON.parse(u.response)}catch(f){return c(f)}c(null,p,u.getResponseHeader("Cache-Control"),u.getResponseHeader("Expires"))}else{const p=new Blob([u.response],{type:u.getResponseHeader("Content-Type")});c(new Er(u.status,u.statusText,a.url,p))}},u.send(a.body),{cancel:()=>u.abort()}}(i,e)},Vr=function(i,e){return mn(Be(i,{type:"arrayBuffer"}),e)};function $n(i){const e=window.document.createElement("a");return e.href=i,e.protocol===window.document.location.protocol&&e.host===window.document.location.host}function Nr(i,e,r){r[i]&&r[i].indexOf(e)!==-1||(r[i]=r[i]||[],r[i].push(e))}function fn(i,e,r){if(r&&r[i]){const a=r[i].indexOf(e);a!==-1&&r[i].splice(a,1)}}class $r{constructor(e,r={}){Be(this,r),this.type=e}}class Gr extends $r{constructor(e,r={}){super("error",Be({error:e},r))}}class Ir{on(e,r){return this._listeners=this._listeners||{},Nr(e,r,this._listeners),this}off(e,r){return fn(e,r,this._listeners),fn(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},Nr(e,r,this._oneTimeListeners),this):new Promise(a=>this.once(e,a))}fire(e,r){typeof e=="string"&&(e=new $r(e,r||{}));const a=e.type;if(this.listens(a)){e.target=this;const c=this._listeners&&this._listeners[a]?this._listeners[a].slice():[];for(const f of c)f.call(this,e);const u=this._oneTimeListeners&&this._oneTimeListeners[a]?this._oneTimeListeners[a].slice():[];for(const f of u)fn(a,f,this._oneTimeListeners),f.call(this,e);const p=this._eventedParent;p&&(Be(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),p.fire(e))}else e instanceof Gr&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,r){return this._eventedParent=e,this._eventedParentData=r,this}}var le={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},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:{}},default:"mapbox"},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-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":{},within:{}}},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}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},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"}}};class Se{constructor(e,r,a,c){this.message=(e?`${e}: `:"")+a,c&&(this.identifier=c),r!=null&&r.__line__&&(this.line=r.__line__)}}function Gn(i){const e=i.value;return e?[new Se(i.key,e,"constants have been deprecated as of v8")]:[]}function di(i,...e){for(const r of e)for(const a in r)i[a]=r[a];return i}function bt(i){return i instanceof Number||i instanceof String||i instanceof Boolean?i.valueOf():i}function Wi(i){if(Array.isArray(i))return i.map(Wi);if(i instanceof Object&&!(i instanceof Number||i instanceof String||i instanceof Boolean)){const e={};for(const r in i)e[r]=Wi(i[r]);return e}return bt(i)}class pi extends Error{constructor(e,r){super(r),this.message=r,this.key=e}}class jr{constructor(e,r=[]){this.parent=e,this.bindings={};for(const[a,c]of r)this.bindings[a]=c}concat(e){return new jr(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const Hi={kind:"null"},Ee={kind:"number"},Qe={kind:"string"},Je={kind:"boolean"},Ti={kind:"color"},sr={kind:"object"},Xe={kind:"value"},Ar={kind:"collator"},ri={kind:"formatted"},qr={kind:"padding"},Mi={kind:"resolvedImage"};function mi(i,e){return{kind:"array",itemType:i,N:e}}function yt(i){if(i.kind==="array"){const e=yt(i.itemType);return typeof i.N=="number"?`array<${e}, ${i.N}>`:i.itemType.kind==="value"?"array":`array<${e}>`}return i.kind}const gn=[Hi,Ee,Qe,Je,Ti,ri,sr,mi(Xe),qr,Mi];function Zr(i,e){if(e.kind==="error")return null;if(i.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!Zr(i.itemType,e.itemType))&&(typeof i.N!="number"||i.N===e.N))return null}else{if(i.kind===e.kind)return null;if(i.kind==="value"){for(const r of gn)if(!Zr(r,e))return null}}return`Expected ${yt(i)} but found ${yt(e)} instead.`}function _n(i,e){return e.some(r=>r.kind===i.kind)}function lt(i,e){return e.some(r=>r==="null"?i===null:r==="array"?Array.isArray(i):r==="object"?i&&!Array.isArray(i)&&typeof i=="object":r===typeof i)}var Cr,yn={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function Xr(i){return(i=Math.round(i))<0?0:i>255?255:i}function jn(i){return Xr(i[i.length-1]==="%"?parseFloat(i)/100*255:parseInt(i))}function _r(i){return(e=i[i.length-1]==="%"?parseFloat(i)/100:parseFloat(i))<0?0:e>1?1:e;var e}function Mr(i,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?i+(e-i)*r*6:2*r<1?e:3*r<2?i+(e-i)*(2/3-r)*6:i}try{Cr={}.parseCSSColor=function(i){var e,r=i.replace(/ /g,"").toLowerCase();if(r in yn)return yn[r].slice();if(r[0]==="#")return r.length===4?(e=parseInt(r.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:r.length===7&&(e=parseInt(r.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var a=r.indexOf("("),c=r.indexOf(")");if(a!==-1&&c+1===r.length){var u=r.substr(0,a),p=r.substr(a+1,c-(a+1)).split(","),f=1;switch(u){case"rgba":if(p.length!==4)return null;f=_r(p.pop());case"rgb":return p.length!==3?null:[jn(p[0]),jn(p[1]),jn(p[2]),f];case"hsla":if(p.length!==4)return null;f=_r(p.pop());case"hsl":if(p.length!==3)return null;var _=(parseFloat(p[0])%360+360)%360/360,v=_r(p[1]),w=_r(p[2]),E=w<=.5?w*(v+1):w+v-w*v,P=2*w-E;return[Xr(255*Mr(P,E,_+1/3)),Xr(255*Mr(P,E,_)),Xr(255*Mr(P,E,_-1/3)),f];default:return null}}return null}}catch{}class ut{constructor(e,r,a,c=1){this.r=e,this.g=r,this.b=a,this.a=c}static parse(e){if(!e)return;if(e instanceof ut)return e;if(typeof e!="string")return;const r=Cr(e);return r?new ut(r[0]/255*r[3],r[1]/255*r[3],r[2]/255*r[3],r[3]):void 0}toString(){const[e,r,a,c]=this.toArray();return`rgba(${Math.round(e)},${Math.round(r)},${Math.round(a)},${c})`}toArray(){const{r:e,g:r,b:a,a:c}=this;return c===0?[0,0,0,0]:[255*e/c,255*r/c,255*a/c,c]}}ut.black=new ut(0,0,0,1),ut.white=new ut(1,1,1,1),ut.transparent=new ut(0,0,0,0),ut.red=new ut(1,0,0,1);class Wr{constructor(e,r,a){this.sensitivity=e?r?"variant":"case":r?"accent":"base",this.locale=a,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,r){return this.collator.compare(e,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Vi{constructor(e,r,a,c,u){this.text=e,this.image=r,this.scale=a,this.fontStack=c,this.textColor=u}}class ei{constructor(e){this.sections=e}static fromString(e){return new ei([new Vi(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||e.image&&e.image.name.length!==0)}static factory(e){return e instanceof ei?e:ei.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}}class Yt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Yt)return e;if(typeof e=="number")return new Yt([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const r of e)if(typeof r!="number")return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Yt(e)}}toString(){return JSON.stringify(this.values)}}class fi{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new fi({name:e,available:!1}):null}}function gi(i,e,r,a){return typeof i=="number"&&i>=0&&i<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof r=="number"&&r>=0&&r<=255?a===void 0||typeof a=="number"&&a>=0&&a<=1?null:`Invalid rgba value [${[i,e,r,a].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof a=="number"?[i,e,r,a]:[i,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function yr(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof ut||i instanceof Wr||i instanceof ei||i instanceof Yt||i instanceof fi)return!0;if(Array.isArray(i)){for(const e of i)if(!yr(e))return!1;return!0}if(typeof i=="object"){for(const e in i)if(!yr(i[e]))return!1;return!0}return!1}function B(i){if(i===null)return Hi;if(typeof i=="string")return Qe;if(typeof i=="boolean")return Je;if(typeof i=="number")return Ee;if(i instanceof ut)return Ti;if(i instanceof Wr)return Ar;if(i instanceof ei)return ri;if(i instanceof Yt)return qr;if(i instanceof fi)return Mi;if(Array.isArray(i)){const e=i.length;let r;for(const a of i){const c=B(a);if(r){if(r===c)continue;r=Xe;break}r=c}return mi(r||Xe,e)}return sr}function I(i){const e=typeof i;return i===null?"":e==="string"||e==="number"||e==="boolean"?String(i):i instanceof ut||i instanceof ei||i instanceof Yt||i instanceof fi?i.toString():JSON.stringify(i)}class C{constructor(e,r){this.type=e,this.value=r}static parse(e,r){if(e.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!yr(e[1]))return r.error("invalid value");const a=e[1];let c=B(a);const u=r.expectedType;return c.kind!=="array"||c.N!==0||!u||u.kind!=="array"||typeof u.N=="number"&&u.N!==0||(c=u),new C(c,a)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class R{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const U={string:Qe,number:Ee,boolean:Je,object:sr};class j{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let a,c=1;const u=e[0];if(u==="array"){let f,_;if(e.length>2){const v=e[1];if(typeof v!="string"||!(v in U)||v==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);f=U[v],c++}else f=Xe;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return r.error('The length argument to "array" must be a positive integer literal',2);_=e[2],c++}a=mi(f,_)}else{if(!U[u])throw new Error(`Types doesn't contain name = ${u}`);a=U[u]}const p=[];for(;c<e.length;c++){const f=r.parse(e[c],c,Xe);if(!f)return null;p.push(f)}return new j(a,p)}evaluate(e){for(let r=0;r<this.args.length;r++){const a=this.args[r].evaluate(e);if(!Zr(this.type,B(a)))return a;if(r===this.args.length-1)throw new R(`Expected value to be of type ${yt(this.type)}, but found ${yt(B(a))} instead.`)}throw new Error}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const X={"to-boolean":Je,"to-color":Ti,"to-number":Ee,"to-string":Qe};class Z{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const a=e[0];if(!X[a])throw new Error(`Can't parse ${a} as it is not part of the known types`);if((a==="to-boolean"||a==="to-string")&&e.length!==2)return r.error("Expected one argument.");const c=X[a],u=[];for(let p=1;p<e.length;p++){const f=r.parse(e[p],p,Xe);if(!f)return null;u.push(f)}return new Z(c,u)}evaluate(e){if(this.type.kind==="boolean")return!!this.args[0].evaluate(e);if(this.type.kind==="color"){let r,a;for(const c of this.args){if(r=c.evaluate(e),a=null,r instanceof ut)return r;if(typeof r=="string"){const u=e.parseColor(r);if(u)return u}else if(Array.isArray(r)&&(a=r.length<3||r.length>4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:gi(r[0],r[1],r[2],r[3]),!a))return new ut(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new R(a||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}if(this.type.kind==="padding"){let r;for(const a of this.args){r=a.evaluate(e);const c=Yt.parse(r);if(c)return c}throw new R(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}if(this.type.kind==="number"){let r=null;for(const a of this.args){if(r=a.evaluate(e),r===null)return 0;const c=Number(r);if(!isNaN(c))return c}throw new R(`Could not convert ${JSON.stringify(r)} to number.`)}return this.type.kind==="formatted"?ei.fromString(I(this.args[0].evaluate(e))):this.type.kind==="resolvedImage"?fi.fromString(I(this.args[0].evaluate(e))):I(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const q=["Unknown","Point","LineString","Polygon"];class Q{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"?q[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let r=this._parseColorCache[e];return r||(r=this._parseColorCache[e]=ut.parse(e)),r}}class oe{constructor(e,r,a,c){this.name=e,this.type=r,this._evaluate=a,this.args=c}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,r){const a=e[0],c=oe.definitions[a];if(!c)return r.error(`Unknown expression "${a}". If you wanted a literal array, use ["literal", [...]].`,0);const u=Array.isArray(c)?c[0]:c.type,p=Array.isArray(c)?[[c[1],c[2]]]:c.overloads,f=p.filter(([v])=>!Array.isArray(v)||v.length===e.length-1);let _=null;for(const[v,w]of f){_=new bn(r.registry,r.path,null,r.scope);const E=[];let P=!1;for(let k=1;k<e.length;k++){const L=e[k],$=Array.isArray(v)?v[k-1]:v.type,N=_.parse(L,1+E.length,$);if(!N){P=!0;break}E.push(N)}if(!P)if(Array.isArray(v)&&v.length!==E.length)_.error(`Expected ${v.length} arguments, but found ${E.length} instead.`);else{for(let k=0;k<E.length;k++){const L=Array.isArray(v)?v[k]:v.type,$=E[k];_.concat(k+1).checkSubtype(L,$.type)}if(_.errors.length===0)return new oe(a,u,w,E)}}if(f.length===1)r.errors.push(..._.errors);else{const v=(f.length?f:p).map(([E])=>{return P=E,Array.isArray(P)?`(${P.map(yt).join(", ")})`:`(${yt(P.type)}...)`;var P}).join(" | "),w=[];for(let E=1;E<e.length;E++){const P=r.parse(e[E],1+w.length);if(!P)return null;w.push(yt(P.type))}r.error(`Expected arguments of type ${v}, but found (${w.join(", ")}) instead.`)}return null}static register(e,r){oe.definitions=r;for(const a in r)e[a]=oe}}class ye{constructor(e,r,a){this.type=Ar,this.locale=a,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error("Expected one argument.");const a=e[1];if(typeof a!="object"||Array.isArray(a))return r.error("Collator options argument must be an object.");const c=r.parse(a["case-sensitive"]!==void 0&&a["case-sensitive"],1,Je);if(!c)return null;const u=r.parse(a["diacritic-sensitive"]!==void 0&&a["diacritic-sensitive"],1,Je);if(!u)return null;let p=null;return a.locale&&(p=r.parse(a.locale,1,Qe),!p)?null:new ye(c,u,p)}evaluate(e){return new Wr(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}const ce=8192;function Ne(i,e){i[0]=Math.min(i[0],e[0]),i[1]=Math.min(i[1],e[1]),i[2]=Math.max(i[2],e[0]),i[3]=Math.max(i[3],e[1])}function je(i,e){return!(i[0]<=e[0]||i[2]>=e[2]||i[1]<=e[1]||i[3]>=e[3])}function Re(i,e){const r=(180+i[0])/360,a=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,c=Math.pow(2,e.z);return[Math.round(r*c*ce),Math.round(a*c*ce)]}function qe(i,e,r){const a=i[0]-e[0],c=i[1]-e[1],u=i[0]-r[0],p=i[1]-r[1];return a*p-u*c==0&&a*u<=0&&c*p<=0}function st(i,e){let r=!1;for(let p=0,f=e.length;p<f;p++){const _=e[p];for(let v=0,w=_.length;v<w-1;v++){if(qe(i,_[v],_[v+1]))return!1;(c=_[v])[1]>(a=i)[1]!=(u=_[v+1])[1]>a[1]&&a[0]<(u[0]-c[0])*(a[1]-c[1])/(u[1]-c[1])+c[0]&&(r=!r)}}var a,c,u;return r}function St(i,e){for(let r=0;r<e.length;r++)if(st(i,e[r]))return!0;return!1}function ot(i,e,r,a){const c=a[0]-r[0],u=a[1]-r[1],p=(i[0]-r[0])*u-c*(i[1]-r[1]),f=(e[0]-r[0])*u-c*(e[1]-r[1]);return p>0&&f<0||p<0&&f>0}function ct(i,e,r){for(const v of r)for(let w=0;w<v.length-1;++w)if((f=[(p=v[w+1])[0]-(u=v[w])[0],p[1]-u[1]])[0]*(_=[(c=e)[0]-(a=i)[0],c[1]-a[1]])[1]-f[1]*_[0]!=0&&ot(a,c,u,p)&&ot(u,p,a,c))return!0;var a,c,u,p,f,_;return!1}function It(i,e){for(let r=0;r<i.length;++r)if(!st(i[r],e))return!1;for(let r=0;r<i.length-1;++r)if(ct(i[r],i[r+1],e))return!1;return!0}function $t(i,e){for(let r=0;r<e.length;r++)if(It(i,e[r]))return!0;return!1}function ti(i,e,r){const a=[];for(let c=0;c<i.length;c++){const u=[];for(let p=0;p<i[c].length;p++){const f=Re(i[c][p],r);Ne(e,f),u.push(f)}a.push(u)}return a}function Wt(i,e,r){const a=[];for(let c=0;c<i.length;c++){const u=ti(i[c],e,r);a.push(u)}return a}function xn(i,e,r,a){if(i[0]<r[0]||i[0]>r[2]){const c=.5*a;let u=i[0]-r[0]>c?-a:r[0]-i[0]>c?a:0;u===0&&(u=i[0]-r[2]>c?-a:r[2]-i[0]>c?a:0),i[0]+=u}Ne(e,i)}function Ro(i,e,r,a){const c=Math.pow(2,a.z)*ce,u=[a.x*ce,a.y*ce],p=[];for(const f of i)for(const _ of f){const v=[_.x+u[0],_.y+u[1]];xn(v,e,r,c),p.push(v)}return p}function Bo(i,e,r,a){const c=Math.pow(2,a.z)*ce,u=[a.x*ce,a.y*ce],p=[];for(const _ of i){const v=[];for(const w of _){const E=[w.x+u[0],w.y+u[1]];Ne(e,E),v.push(E)}p.push(v)}if(e[2]-e[0]<=c/2){(f=e)[0]=f[1]=1/0,f[2]=f[3]=-1/0;for(const _ of p)for(const v of _)xn(v,e,r,c)}var f;return p}class Hr{constructor(e,r){this.type=Je,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(yr(e[1])){const a=e[1];if(a.type==="FeatureCollection")for(let c=0;c<a.features.length;++c){const u=a.features[c].geometry.type;if(u==="Polygon"||u==="MultiPolygon")return new Hr(a,a.features[c].geometry)}else if(a.type==="Feature"){const c=a.geometry.type;if(c==="Polygon"||c==="MultiPolygon")return new Hr(a,a.geometry)}else if(a.type==="Polygon"||a.type==="MultiPolygon")return new Hr(a,a)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return function(r,a){const c=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],p=r.canonicalID();if(a.type==="Polygon"){const f=ti(a.coordinates,u,p),_=Ro(r.geometry(),c,u,p);if(!je(c,u))return!1;for(const v of _)if(!st(v,f))return!1}if(a.type==="MultiPolygon"){const f=Wt(a.coordinates,u,p),_=Ro(r.geometry(),c,u,p);if(!je(c,u))return!1;for(const v of _)if(!St(v,f))return!1}return!0}(e,this.geometries);if(e.geometryType()==="LineString")return function(r,a){const c=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],p=r.canonicalID();if(a.type==="Polygon"){const f=ti(a.coordinates,u,p),_=Bo(r.geometry(),c,u,p);if(!je(c,u))return!1;for(const v of _)if(!It(v,f))return!1}if(a.type==="MultiPolygon"){const f=Wt(a.coordinates,u,p),_=Bo(r.geometry(),c,u,p);if(!je(c,u))return!1;for(const v of _)if(!$t(v,f))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}function fa(i){if(i instanceof oe&&(i.name==="get"&&i.args.length===1||i.name==="feature-state"||i.name==="has"&&i.args.length===1||i.name==="properties"||i.name==="geometry-type"||i.name==="id"||/^filter-/.test(i.name))||i instanceof Hr)return!1;let e=!0;return i.eachChild(r=>{e&&!fa(r)&&(e=!1)}),e}function vn(i){if(i instanceof oe&&i.name==="feature-state")return!1;let e=!0;return i.eachChild(r=>{e&&!vn(r)&&(e=!1)}),e}function Pr(i,e){if(i instanceof oe&&e.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild(a=>{r&&!Pr(a,e)&&(r=!1)}),r}class ga{constructor(e,r){this.type=r.type,this.name=e,this.boundExpression=r}static parse(e,r){if(e.length!==2||typeof e[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");const a=e[1];return r.scope.has(a)?new ga(a,r.scope.get(a)):r.error(`Unknown variable "${a}". Make sure "${a}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class ds{constructor(e,r=[],a,c=new jr,u=[]){this.registry=e,this.path=r,this.key=r.map(p=>`[${p}]`).join(""),this.scope=c,this.errors=u,this.expectedType=a}parse(e,r,a,c,u={}){return r?this.concat(r,a,c)._parse(e,u):this._parse(e,u)}_parse(e,r){function a(c,u,p){return p==="assert"?new j(u,[c]):p==="coerce"?new Z(u,[c]):c}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const c=e[0];if(typeof c!="string")return this.error(`Expression name must be a string, but found ${typeof c} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const u=this.registry[c];if(u){let p=u.parse(e,this);if(!p)return null;if(this.expectedType){const f=this.expectedType,_=p.type;if(f.kind!=="string"&&f.kind!=="number"&&f.kind!=="boolean"&&f.kind!=="object"&&f.kind!=="array"||_.kind!=="value")if(f.kind!=="color"&&f.kind!=="formatted"&&f.kind!=="resolvedImage"||_.kind!=="value"&&_.kind!=="string")if(f.kind!=="padding"||_.kind!=="value"&&_.kind!=="number"&&_.kind!=="array"){if(this.checkSubtype(f,_))return null}else p=a(p,f,r.typeAnnotation||"coerce");else p=a(p,f,r.typeAnnotation||"coerce");else p=a(p,f,r.typeAnnotation||"assert")}if(!(p instanceof C)&&p.type.kind!=="resolvedImage"&&ps(p)){const f=new Q;try{p=new C(p.type,p.evaluate(f))}catch(_){return this.error(_.message),null}}return p}return this.error(`Unknown expression "${c}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,r,a){const c=typeof e=="number"?this.path.concat(e):this.path,u=a?this.scope.concat(a):this.scope;return new ds(this.registry,c,r||null,u,this.errors)}error(e,...r){const a=`${this.key}${r.map(c=>`[${c}]`).join("")}`;this.errors.push(new pi(a,e))}checkSubtype(e,r){const a=Zr(e,r);return a&&this.error(a),a}}var bn=ds;function ps(i){if(i instanceof ga)return ps(i.boundExpression);if(i instanceof oe&&i.name==="error"||i instanceof ye||i instanceof Hr)return!1;const e=i instanceof Z||i instanceof j;let r=!0;return i.eachChild(a=>{r=e?r&&ps(a):r&&a instanceof C}),!!r&&fa(i)&&Pr(i,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function _a(i,e){const r=i.length-1;let a,c,u=0,p=r,f=0;for(;u<=p;)if(f=Math.floor((u+p)/2),a=i[f],c=i[f+1],a<=e){if(f===r||e<c)return f;u=f+1}else{if(!(a>e))throw new R("Input is not a number.");p=f-1}return 0}class qn{constructor(e,r,a){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(const[c,u]of a)this.labels.push(c),this.outputs.push(u)}static parse(e,r){if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");const a=r.parse(e[1],1,Ee);if(!a)return null;const c=[];let u=null;r.expectedType&&r.expectedType.kind!=="value"&&(u=r.expectedType);for(let p=1;p<e.length;p+=2){const f=p===1?-1/0:e[p],_=e[p+1],v=p,w=p+1;if(typeof f!="number")return r.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',v);if(c.length&&c[c.length-1][0]>=f)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',v);const E=r.parse(_,w,u);if(!E)return null;u=u||E.type,c.push([f,E])}return new qn(u,a,c)}evaluate(e){const r=this.labels,a=this.outputs;if(r.length===1)return a[0].evaluate(e);const c=this.input.evaluate(e);if(c<=r[0])return a[0].evaluate(e);const u=r.length;return c>=r[u-1]?a[u-1].evaluate(e):a[_a(r,c)].evaluate(e)}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function zt(i,e,r){return i*(1-r)+e*r}var Kr=Object.freeze({__proto__:null,array:function(i,e,r){return i.map((a,c)=>zt(a,e[c],r))},color:function(i,e,r){return new ut(zt(i.r,e.r,r),zt(i.g,e.g,r),zt(i.b,e.b,r),zt(i.a,e.a,r))},number:zt,padding:function(i,e,r){const a=i.values,c=e.values;return new Yt([zt(a[0],c[0],r),zt(a[1],c[1],r),zt(a[2],c[2],r),zt(a[3],c[3],r)])}});const Fo=.95047,Oo=1.08883,Uo=4/29,Ni=6/29,ya=3*Ni*Ni,ms=Math.PI/180,Zn=180/Math.PI;function xt(i){return i>.008856451679035631?Math.pow(i,1/3):i/ya+Uo}function fs(i){return i>Ni?i*i*i:ya*(i-Uo)}function Xn(i){return 255*(i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055)}function gs(i){return(i/=255)<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function _s(i){const e=gs(i.r),r=gs(i.g),a=gs(i.b),c=xt((.4124564*e+.3575761*r+.1804375*a)/Fo),u=xt((.2126729*e+.7151522*r+.072175*a)/1);return{l:116*u-16,a:500*(c-u),b:200*(u-xt((.0193339*e+.119192*r+.9503041*a)/Oo)),alpha:i.a}}function ys(i){let e=(i.l+16)/116,r=isNaN(i.a)?e:e+i.a/500,a=isNaN(i.b)?e:e-i.b/200;return e=1*fs(e),r=Fo*fs(r),a=Oo*fs(a),new ut(Xn(3.2404542*r-1.5371385*e-.4985314*a),Xn(-.969266*r+1.8760108*e+.041556*a),Xn(.0556434*r-.2040259*e+1.0572252*a),i.alpha)}function Kl(i,e,r){const a=e-i;return i+r*(a>180||a<-180?a-360*Math.round(a/360):a)}const wn={forward:_s,reverse:ys,interpolate:function(i,e,r){return{l:zt(i.l,e.l,r),a:zt(i.a,e.a,r),b:zt(i.b,e.b,r),alpha:zt(i.alpha,e.alpha,r)}}},Tn={forward:function(i){const{l:e,a:r,b:a}=_s(i),c=Math.atan2(a,r)*Zn;return{h:c<0?c+360:c,c:Math.sqrt(r*r+a*a),l:e,alpha:i.a}},reverse:function(i){const e=i.h*ms,r=i.c;return ys({l:i.l,a:Math.cos(e)*r,b:Math.sin(e)*r,alpha:i.alpha})},interpolate:function(i,e,r){return{h:Kl(i.h,e.h,r),c:zt(i.c,e.c,r),l:zt(i.l,e.l,r),alpha:zt(i.alpha,e.alpha,r)}}};var Vo=Object.freeze({__proto__:null,hcl:Tn,lab:wn});class Pi{constructor(e,r,a,c,u){this.type=e,this.operator=r,this.interpolation=a,this.input=c,this.labels=[],this.outputs=[];for(const[p,f]of u)this.labels.push(p),this.outputs.push(f)}static interpolationFactor(e,r,a,c){let u=0;if(e.name==="exponential")u=xs(r,e.base,a,c);else if(e.name==="linear")u=xs(r,1,a,c);else if(e.name==="cubic-bezier"){const p=e.controlPoints;u=new ve(p[0],p[1],p[2],p[3]).solve(xs(r,1,a,c))}return u}static parse(e,r){let[a,c,u,...p]=e;if(!Array.isArray(c)||c.length===0)return r.error("Expected an interpolation type expression.",1);if(c[0]==="linear")c={name:"linear"};else if(c[0]==="exponential"){const v=c[1];if(typeof v!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);c={name:"exponential",base:v}}else{if(c[0]!=="cubic-bezier")return r.error(`Unknown interpolation type ${String(c[0])}`,1,0);{const v=c.slice(1);if(v.length!==4||v.some(w=>typeof w!="number"||w<0||w>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);c={name:"cubic-bezier",controlPoints:v}}}if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(u=r.parse(u,2,Ee),!u)return null;const f=[];let _=null;a==="interpolate-hcl"||a==="interpolate-lab"?_=Ti:r.expectedType&&r.expectedType.kind!=="value"&&(_=r.expectedType);for(let v=0;v<p.length;v+=2){const w=p[v],E=p[v+1],P=v+3,k=v+4;if(typeof w!="number")return r.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',P);if(f.length&&f[f.length-1][0]>=w)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',P);const L=r.parse(E,k,_);if(!L)return null;_=_||L.type,f.push([w,L])}return _.kind==="number"||_.kind==="color"||_.kind==="padding"||_.kind==="array"&&_.itemType.kind==="number"&&typeof _.N=="number"?new Pi(_,a,c,u,f):r.error(`Type ${yt(_)} is not interpolatable.`)}evaluate(e){const r=this.labels,a=this.outputs;if(r.length===1)return a[0].evaluate(e);const c=this.input.evaluate(e);if(c<=r[0])return a[0].evaluate(e);const u=r.length;if(c>=r[u-1])return a[u-1].evaluate(e);const p=_a(r,c),f=Pi.interpolationFactor(this.interpolation,c,r[p],r[p+1]),_=a[p].evaluate(e),v=a[p+1].evaluate(e);return this.operator==="interpolate"?Kr[this.type.kind.toLowerCase()](_,v,f):this.operator==="interpolate-hcl"?Tn.reverse(Tn.interpolate(Tn.forward(_),Tn.forward(v),f)):wn.reverse(wn.interpolate(wn.forward(_),wn.forward(v),f))}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function xs(i,e,r,a){const c=a-r,u=i-r;return c===0?0:e===1?u/c:(Math.pow(e,u)-1)/(Math.pow(e,c)-1)}class xa{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expectected at least one argument.");let a=null;const c=r.expectedType;c&&c.kind!=="value"&&(a=c);const u=[];for(const f of e.slice(1)){const _=r.parse(f,1+u.length,a,void 0,{typeAnnotation:"omit"});if(!_)return null;a=a||_.type,u.push(_)}if(!a)throw new Error("No output type");const p=c&&u.some(f=>Zr(c,f.type));return new xa(p?Xe:a,u)}evaluate(e){let r,a=null,c=0;for(const u of this.args)if(c++,a=u.evaluate(e),a&&a instanceof fi&&!a.available&&(r||(r=a.name),a=null,c===this.args.length&&(a=r)),a!==null)break;return a}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}class Wn{constructor(e,r){this.type=r.type,this.bindings=[].concat(e),this.result=r}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const r of this.bindings)e(r[1]);e(this.result)}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const a=[];for(let u=1;u<e.length-1;u+=2){const p=e[u];if(typeof p!="string")return r.error(`Expected string, but found ${typeof p} instead.`,u);if(/[^a-zA-Z0-9_]/.test(p))return r.error("Variable names must contain only alphanumeric characters or '_'.",u);const f=r.parse(e[u+1],u+1);if(!f)return null;a.push([p,f])}const c=r.parse(e[e.length-1],e.length-1,r.expectedType,a);return c?new Wn(a,c):null}outputDefined(){return this.result.outputDefined()}}class va{constructor(e,r,a){this.type=e,this.index=r,this.input=a}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,Ee),c=r.parse(e[2],2,mi(r.expectedType||Xe));return a&&c?new va(c.type.itemType,a,c):null}evaluate(e){const r=this.index.evaluate(e),a=this.input.evaluate(e);if(r<0)throw new R(`Array index out of bounds: ${r} < 0.`);if(r>=a.length)throw new R(`Array index out of bounds: ${r} > ${a.length-1}.`);if(r!==Math.floor(r))throw new R(`Array index must be an integer, but found ${r} instead.`);return a[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class vs{constructor(e,r){this.type=Je,this.needle=e,this.haystack=r}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,Xe),c=r.parse(e[2],2,Xe);return a&&c?_n(a.type,[Je,Qe,Ee,Hi,Xe])?new vs(a,c):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${yt(a.type)} instead`):null}evaluate(e){const r=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!a)return!1;if(!lt(r,["boolean","string","number","null"]))throw new R(`Expected first argument to be of type boolean, string, number or null, but found ${yt(B(r))} instead.`);if(!lt(a,["string","array"]))throw new R(`Expected second argument to be of type array or string, but found ${yt(B(a))} instead.`);return a.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class ba{constructor(e,r,a){this.type=Ee,this.needle=e,this.haystack=r,this.fromIndex=a}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,Xe),c=r.parse(e[2],2,Xe);if(!a||!c)return null;if(!_n(a.type,[Je,Qe,Ee,Hi,Xe]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${yt(a.type)} instead`);if(e.length===4){const u=r.parse(e[3],3,Ee);return u?new ba(a,c,u):null}return new ba(a,c)}evaluate(e){const r=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!lt(r,["boolean","string","number","null"]))throw new R(`Expected first argument to be of type boolean, string, number or null, but found ${yt(B(r))} instead.`);if(!lt(a,["string","array"]))throw new R(`Expected second argument to be of type array or string, but found ${yt(B(a))} instead.`);if(this.fromIndex){const c=this.fromIndex.evaluate(e);return a.indexOf(r,c)}return a.indexOf(r)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class Hn{constructor(e,r,a,c,u,p){this.inputType=e,this.type=r,this.input=a,this.cases=c,this.outputs=u,this.otherwise=p}static parse(e,r){if(e.length<5)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return r.error("Expected an even number of arguments.");let a,c;r.expectedType&&r.expectedType.kind!=="value"&&(c=r.expectedType);const u={},p=[];for(let v=2;v<e.length-1;v+=2){let w=e[v];const E=e[v+1];Array.isArray(w)||(w=[w]);const P=r.concat(v);if(w.length===0)return P.error("Expected at least one branch label.");for(const L of w){if(typeof L!="number"&&typeof L!="string")return P.error("Branch labels must be numbers or strings.");if(typeof L=="number"&&Math.abs(L)>Number.MAX_SAFE_INTEGER)return P.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof L=="number"&&Math.floor(L)!==L)return P.error("Numeric branch labels must be integer values.");if(a){if(P.checkSubtype(a,B(L)))return null}else a=B(L);if(u[String(L)]!==void 0)return P.error("Branch labels must be unique.");u[String(L)]=p.length}const k=r.parse(E,v,c);if(!k)return null;c=c||k.type,p.push(k)}const f=r.parse(e[1],1,Xe);if(!f)return null;const _=r.parse(e[e.length-1],e.length-1,c);return _?f.type.kind!=="value"&&r.concat(1).checkSubtype(a,f.type)?null:new Hn(a,c,f,u,p,_):null}evaluate(e){const r=this.input.evaluate(e);return(B(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}}class bs{constructor(e,r,a){this.type=e,this.branches=r,this.otherwise=a}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error("Expected an odd number of arguments.");let a;r.expectedType&&r.expectedType.kind!=="value"&&(a=r.expectedType);const c=[];for(let p=1;p<e.length-1;p+=2){const f=r.parse(e[p],p,Je);if(!f)return null;const _=r.parse(e[p+1],p+1,a);if(!_)return null;c.push([f,_]),a=a||_.type}const u=r.parse(e[e.length-1],e.length-1,a);if(!u)return null;if(!a)throw new Error("Can't infer output type");return new bs(a,c,u)}evaluate(e){for(const[r,a]of this.branches)if(r.evaluate(e))return a.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[r,a]of this.branches)e(r),e(a);e(this.otherwise)}outputDefined(){return this.branches.every(([e,r])=>r.outputDefined())&&this.otherwise.outputDefined()}}class wa{constructor(e,r,a,c){this.type=e,this.input=r,this.beginIndex=a,this.endIndex=c}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,Xe),c=r.parse(e[2],2,Ee);if(!a||!c)return null;if(!_n(a.type,[mi(Xe),Qe,Xe]))return r.error(`Expected first argument to be of type array or string, but found ${yt(a.type)} instead`);if(e.length===4){const u=r.parse(e[3],3,Ee);return u?new wa(a.type,a,c,u):null}return new wa(a.type,a,c)}evaluate(e){const r=this.input.evaluate(e),a=this.beginIndex.evaluate(e);if(!lt(r,["string","array"]))throw new R(`Expected first argument to be of type array or string, but found ${yt(B(r))} instead.`);if(this.endIndex){const c=this.endIndex.evaluate(e);return r.slice(a,c)}return r.slice(a)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function No(i,e){return i==="=="||i==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function ws(i,e,r,a){return a.compare(e,r)===0}function Yr(i,e,r){const a=i!=="=="&&i!=="!=";return class ud{constructor(u,p,f){this.type=Je,this.lhs=u,this.rhs=p,this.collator=f,this.hasUntypedArgument=u.type.kind==="value"||p.type.kind==="value"}static parse(u,p){if(u.length!==3&&u.length!==4)return p.error("Expected two or three arguments.");const f=u[0];let _=p.parse(u[1],1,Xe);if(!_)return null;if(!No(f,_.type))return p.concat(1).error(`"${f}" comparisons are not supported for type '${yt(_.type)}'.`);let v=p.parse(u[2],2,Xe);if(!v)return null;if(!No(f,v.type))return p.concat(2).error(`"${f}" comparisons are not supported for type '${yt(v.type)}'.`);if(_.type.kind!==v.type.kind&&_.type.kind!=="value"&&v.type.kind!=="value")return p.error(`Cannot compare types '${yt(_.type)}' and '${yt(v.type)}'.`);a&&(_.type.kind==="value"&&v.type.kind!=="value"?_=new j(v.type,[_]):_.type.kind!=="value"&&v.type.kind==="value"&&(v=new j(_.type,[v])));let w=null;if(u.length===4){if(_.type.kind!=="string"&&v.type.kind!=="string"&&_.type.kind!=="value"&&v.type.kind!=="value")return p.error("Cannot use collator to compare non-string types.");if(w=p.parse(u[3],3,Ar),!w)return null}return new ud(_,v,w)}evaluate(u){const p=this.lhs.evaluate(u),f=this.rhs.evaluate(u);if(a&&this.hasUntypedArgument){const _=B(p),v=B(f);if(_.kind!==v.kind||_.kind!=="string"&&_.kind!=="number")throw new R(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${_.kind}, ${v.kind}) instead.`)}if(this.collator&&!a&&this.hasUntypedArgument){const _=B(p),v=B(f);if(_.kind!=="string"||v.kind!=="string")return e(u,p,f)}return this.collator?r(u,p,f,this.collator.evaluate(u)):e(u,p,f)}eachChild(u){u(this.lhs),u(this.rhs),this.collator&&u(this.collator)}outputDefined(){return!0}}}const Yl=Yr("==",function(i,e,r){return e===r},ws),Jl=Yr("!=",function(i,e,r){return e!==r},function(i,e,r,a){return!ws(0,e,r,a)}),$o=Yr("<",function(i,e,r){return e<r},function(i,e,r,a){return a.compare(e,r)<0}),Go=Yr(">",function(i,e,r){return e>r},function(i,e,r,a){return a.compare(e,r)>0}),Ql=Yr("<=",function(i,e,r){return e<=r},function(i,e,r,a){return a.compare(e,r)<=0}),ec=Yr(">=",function(i,e,r){return e>=r},function(i,e,r,a){return a.compare(e,r)>=0});class Ts{constructor(e,r,a,c,u){this.type=Qe,this.number=e,this.locale=r,this.currency=a,this.minFractionDigits=c,this.maxFractionDigits=u}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");const a=r.parse(e[1],1,Ee);if(!a)return null;const c=e[2];if(typeof c!="object"||Array.isArray(c))return r.error("NumberFormat options argument must be an object.");let u=null;if(c.locale&&(u=r.parse(c.locale,1,Qe),!u))return null;let p=null;if(c.currency&&(p=r.parse(c.currency,1,Qe),!p))return null;let f=null;if(c["min-fraction-digits"]&&(f=r.parse(c["min-fraction-digits"],1,Ee),!f))return null;let _=null;return c["max-fraction-digits"]&&(_=r.parse(c["max-fraction-digits"],1,Ee),!_)?null:new Ts(a,u,p,f,_)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Ta{constructor(e){this.type=ri,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const a=e[1];if(!Array.isArray(a)&&typeof a=="object")return r.error("First argument must be an image or text section.");const c=[];let u=!1;for(let p=1;p<=e.length-1;++p){const f=e[p];if(u&&typeof f=="object"&&!Array.isArray(f)){u=!1;let _=null;if(f["font-scale"]&&(_=r.parse(f["font-scale"],1,Ee),!_))return null;let v=null;if(f["text-font"]&&(v=r.parse(f["text-font"],1,mi(Qe)),!v))return null;let w=null;if(f["text-color"]&&(w=r.parse(f["text-color"],1,Ti),!w))return null;const E=c[c.length-1];E.scale=_,E.font=v,E.textColor=w}else{const _=r.parse(e[p],1,Xe);if(!_)return null;const v=_.type.kind;if(v!=="string"&&v!=="value"&&v!=="null"&&v!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");u=!0,c.push({content:_,scale:null,font:null,textColor:null})}}return new Ta(c)}evaluate(e){return new ei(this.sections.map(r=>{const a=r.content.evaluate(e);return B(a)===Mi?new Vi("",a,null,null,null):new Vi(I(a),null,r.scale?r.scale.evaluate(e):null,r.font?r.font.evaluate(e).join(","):null,r.textColor?r.textColor.evaluate(e):null)}))}eachChild(e){for(const r of this.sections)e(r.content),r.scale&&e(r.scale),r.font&&e(r.font),r.textColor&&e(r.textColor)}outputDefined(){return!1}}class Ss{constructor(e){this.type=Mi,this.input=e}static parse(e,r){if(e.length!==2)return r.error("Expected two arguments.");const a=r.parse(e[1],1,Qe);return a?new Ss(a):r.error("No image name provided.")}evaluate(e){const r=this.input.evaluate(e),a=fi.fromString(r);return a&&e.availableImages&&(a.available=e.availableImages.indexOf(r)>-1),a}eachChild(e){e(this.input)}outputDefined(){return!1}}class Es{constructor(e){this.type=Ee,this.input=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);const a=r.parse(e[1],1);return a?a.type.kind!=="array"&&a.type.kind!=="string"&&a.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${yt(a.type)} instead.`):new Es(a):null}evaluate(e){const r=this.input.evaluate(e);if(typeof r=="string"||Array.isArray(r))return r.length;throw new R(`Expected value to be of type string or array, but found ${yt(B(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Sn={"==":Yl,"!=":Jl,">":Go,"<":$o,">=":ec,"<=":Ql,array:j,at:va,boolean:j,case:bs,coalesce:xa,collator:ye,format:Ta,image:Ss,in:vs,"index-of":ba,interpolate:Pi,"interpolate-hcl":Pi,"interpolate-lab":Pi,length:Es,let:Wn,literal:C,match:Hn,number:j,"number-format":Ts,object:j,slice:wa,step:qn,string:j,"to-boolean":Z,"to-color":Z,"to-number":Z,"to-string":Z,var:ga,within:Hr};function pt(i,[e,r,a,c]){e=e.evaluate(i),r=r.evaluate(i),a=a.evaluate(i);const u=c?c.evaluate(i):1,p=gi(e,r,a,u);if(p)throw new R(p);return new ut(e/255*u,r/255*u,a/255*u,u)}function jo(i,e){return i in e}function Is(i,e){const r=e[i];return r===void 0?null:r}function Jr(i){return{type:i}}function qo(i){return{result:"success",value:i}}function En(i){return{result:"error",value:i}}function In(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function Zo(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function As(i){return!!i.expression&&i.expression.interpolated}function vt(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":i===null?"null":typeof i}function Sa(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function tc(i){return i}function Xo(i,e){const r=e.type==="color",a=i.stops&&typeof i.stops[0][0]=="object",c=a||!(a||i.property!==void 0),u=i.type||(As(e)?"exponential":"interval");if(r||e.type==="padding"){const v=r?ut.parse:Yt.parse;(i=di({},i)).stops&&(i.stops=i.stops.map(w=>[w[0],v(w[1])])),i.default=v(i.default?i.default:e.default)}if(i.colorSpace&&i.colorSpace!=="rgb"&&!Vo[i.colorSpace])throw new Error(`Unknown color space: ${i.colorSpace}`);let p,f,_;if(u==="exponential")p=Wo;else if(u==="interval")p=rc;else if(u==="categorical"){p=ic,f=Object.create(null);for(const v of i.stops)f[v[0]]=v[1];_=typeof i.stops[0][0]}else{if(u!=="identity")throw new Error(`Unknown function type "${u}"`);p=nc}if(a){const v={},w=[];for(let k=0;k<i.stops.length;k++){const L=i.stops[k],$=L[0].zoom;v[$]===void 0&&(v[$]={zoom:$,type:i.type,property:i.property,default:i.default,stops:[]},w.push($)),v[$].stops.push([L[0].value,L[1]])}const E=[];for(const k of w)E.push([v[k].zoom,Xo(v[k],e)]);const P={name:"linear"};return{kind:"composite",interpolationType:P,interpolationFactor:Pi.interpolationFactor.bind(void 0,P),zoomStops:E.map(k=>k[0]),evaluate:({zoom:k},L)=>Wo({stops:E,base:i.base},e,k).evaluate(k,L)}}if(c){const v=u==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:v,interpolationFactor:Pi.interpolationFactor.bind(void 0,v),zoomStops:i.stops.map(w=>w[0]),evaluate:({zoom:w})=>p(i,e,w,f,_)}}return{kind:"source",evaluate(v,w){const E=w&&w.properties?w.properties[i.property]:void 0;return E===void 0?Kn(i.default,e.default):p(i,e,E,f,_)}}}function Kn(i,e,r){return i!==void 0?i:e!==void 0?e:r!==void 0?r:void 0}function ic(i,e,r,a,c){return Kn(typeof r===c?a[r]:void 0,i.default,e.default)}function rc(i,e,r){if(vt(r)!=="number")return Kn(i.default,e.default);const a=i.stops.length;if(a===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[a-1][0])return i.stops[a-1][1];const c=_a(i.stops.map(u=>u[0]),r);return i.stops[c][1]}function Wo(i,e,r){const a=i.base!==void 0?i.base:1;if(vt(r)!=="number")return Kn(i.default,e.default);const c=i.stops.length;if(c===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[c-1][0])return i.stops[c-1][1];const u=_a(i.stops.map(w=>w[0]),r),p=function(w,E,P,k){const L=k-P,$=w-P;return L===0?0:E===1?$/L:(Math.pow(E,$)-1)/(Math.pow(E,L)-1)}(r,a,i.stops[u][0],i.stops[u+1][0]),f=i.stops[u][1],_=i.stops[u+1][1];let v=Kr[e.type]||tc;if(i.colorSpace&&i.colorSpace!=="rgb"){const w=Vo[i.colorSpace];v=(E,P)=>w.reverse(w.interpolate(w.forward(E),w.forward(P),p))}return typeof f.evaluate=="function"?{evaluate(...w){const E=f.evaluate.apply(void 0,w),P=_.evaluate.apply(void 0,w);if(E!==void 0&&P!==void 0)return v(E,P,p)}}:v(f,_,p)}function nc(i,e,r){switch(e.type){case"color":r=ut.parse(r);break;case"formatted":r=ei.fromString(r.toString());break;case"resolvedImage":r=fi.fromString(r.toString());break;case"padding":r=Yt.parse(r);break;default:vt(r)===e.type||e.type==="enum"&&e.values[r]||(r=void 0)}return Kn(r,i.default,e.default)}oe.register(Sn,{error:[{kind:"error"},[Qe],(i,[e])=>{throw new R(e.evaluate(i))}],typeof:[Qe,[Xe],(i,[e])=>yt(B(e.evaluate(i)))],"to-rgba":[mi(Ee,4),[Ti],(i,[e])=>e.evaluate(i).toArray()],rgb:[Ti,[Ee,Ee,Ee],pt],rgba:[Ti,[Ee,Ee,Ee,Ee],pt],has:{type:Je,overloads:[[[Qe],(i,[e])=>jo(e.evaluate(i),i.properties())],[[Qe,sr],(i,[e,r])=>jo(e.evaluate(i),r.evaluate(i))]]},get:{type:Xe,overloads:[[[Qe],(i,[e])=>Is(e.evaluate(i),i.properties())],[[Qe,sr],(i,[e,r])=>Is(e.evaluate(i),r.evaluate(i))]]},"feature-state":[Xe,[Qe],(i,[e])=>Is(e.evaluate(i),i.featureState||{})],properties:[sr,[],i=>i.properties()],"geometry-type":[Qe,[],i=>i.geometryType()],id:[Xe,[],i=>i.id()],zoom:[Ee,[],i=>i.globals.zoom],"heatmap-density":[Ee,[],i=>i.globals.heatmapDensity||0],"line-progress":[Ee,[],i=>i.globals.lineProgress||0],accumulated:[Xe,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[Ee,Jr(Ee),(i,e)=>{let r=0;for(const a of e)r+=a.evaluate(i);return r}],"*":[Ee,Jr(Ee),(i,e)=>{let r=1;for(const a of e)r*=a.evaluate(i);return r}],"-":{type:Ee,overloads:[[[Ee,Ee],(i,[e,r])=>e.evaluate(i)-r.evaluate(i)],[[Ee],(i,[e])=>-e.evaluate(i)]]},"/":[Ee,[Ee,Ee],(i,[e,r])=>e.evaluate(i)/r.evaluate(i)],"%":[Ee,[Ee,Ee],(i,[e,r])=>e.evaluate(i)%r.evaluate(i)],ln2:[Ee,[],()=>Math.LN2],pi:[Ee,[],()=>Math.PI],e:[Ee,[],()=>Math.E],"^":[Ee,[Ee,Ee],(i,[e,r])=>Math.pow(e.evaluate(i),r.evaluate(i))],sqrt:[Ee,[Ee],(i,[e])=>Math.sqrt(e.evaluate(i))],log10:[Ee,[Ee],(i,[e])=>Math.log(e.evaluate(i))/Math.LN10],ln:[Ee,[Ee],(i,[e])=>Math.log(e.evaluate(i))],log2:[Ee,[Ee],(i,[e])=>Math.log(e.evaluate(i))/Math.LN2],sin:[Ee,[Ee],(i,[e])=>Math.sin(e.evaluate(i))],cos:[Ee,[Ee],(i,[e])=>Math.cos(e.evaluate(i))],tan:[Ee,[Ee],(i,[e])=>Math.tan(e.evaluate(i))],asin:[Ee,[Ee],(i,[e])=>Math.asin(e.evaluate(i))],acos:[Ee,[Ee],(i,[e])=>Math.acos(e.evaluate(i))],atan:[Ee,[Ee],(i,[e])=>Math.atan(e.evaluate(i))],min:[Ee,Jr(Ee),(i,e)=>Math.min(...e.map(r=>r.evaluate(i)))],max:[Ee,Jr(Ee),(i,e)=>Math.max(...e.map(r=>r.evaluate(i)))],abs:[Ee,[Ee],(i,[e])=>Math.abs(e.evaluate(i))],round:[Ee,[Ee],(i,[e])=>{const r=e.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[Ee,[Ee],(i,[e])=>Math.floor(e.evaluate(i))],ceil:[Ee,[Ee],(i,[e])=>Math.ceil(e.evaluate(i))],"filter-==":[Je,[Qe,Xe],(i,[e,r])=>i.properties()[e.value]===r.value],"filter-id-==":[Je,[Xe],(i,[e])=>i.id()===e.value],"filter-type-==":[Je,[Qe],(i,[e])=>i.geometryType()===e.value],"filter-<":[Je,[Qe,Xe],(i,[e,r])=>{const a=i.properties()[e.value],c=r.value;return typeof a==typeof c&&a<c}],"filter-id-<":[Je,[Xe],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r<a}],"filter->":[Je,[Qe,Xe],(i,[e,r])=>{const a=i.properties()[e.value],c=r.value;return typeof a==typeof c&&a>c}],"filter-id->":[Je,[Xe],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r>a}],"filter-<=":[Je,[Qe,Xe],(i,[e,r])=>{const a=i.properties()[e.value],c=r.value;return typeof a==typeof c&&a<=c}],"filter-id-<=":[Je,[Xe],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r<=a}],"filter->=":[Je,[Qe,Xe],(i,[e,r])=>{const a=i.properties()[e.value],c=r.value;return typeof a==typeof c&&a>=c}],"filter-id->=":[Je,[Xe],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r>=a}],"filter-has":[Je,[Xe],(i,[e])=>e.value in i.properties()],"filter-has-id":[Je,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[Je,[mi(Qe)],(i,[e])=>e.value.indexOf(i.geometryType())>=0],"filter-id-in":[Je,[mi(Xe)],(i,[e])=>e.value.indexOf(i.id())>=0],"filter-in-small":[Je,[Qe,mi(Xe)],(i,[e,r])=>r.value.indexOf(i.properties()[e.value])>=0],"filter-in-large":[Je,[Qe,mi(Xe)],(i,[e,r])=>function(a,c,u,p){for(;u<=p;){const f=u+p>>1;if(c[f]===a)return!0;c[f]>a?p=f-1:u=f+1}return!1}(i.properties()[e.value],r.value,0,r.value.length-1)],all:{type:Je,overloads:[[[Je,Je],(i,[e,r])=>e.evaluate(i)&&r.evaluate(i)],[Jr(Je),(i,e)=>{for(const r of e)if(!r.evaluate(i))return!1;return!0}]]},any:{type:Je,overloads:[[[Je,Je],(i,[e,r])=>e.evaluate(i)||r.evaluate(i)],[Jr(Je),(i,e)=>{for(const r of e)if(r.evaluate(i))return!0;return!1}]]},"!":[Je,[Je],(i,[e])=>!e.evaluate(i)],"is-supported-script":[Je,[Qe],(i,[e])=>{const r=i.globals&&i.globals.isSupportedScript;return!r||r(e.evaluate(i))}],upcase:[Qe,[Qe],(i,[e])=>e.evaluate(i).toUpperCase()],downcase:[Qe,[Qe],(i,[e])=>e.evaluate(i).toLowerCase()],concat:[Qe,Jr(Xe),(i,e)=>e.map(r=>I(r.evaluate(i))).join("")],"resolved-locale":[Qe,[Ar],(i,[e])=>e.evaluate(i).resolvedLocale()]});class Cs{constructor(e,r){this.expression=e,this._warningHistory={},this._evaluator=new Q,this._defaultValue=r?function(a){return a.type==="color"&&Sa(a.default)?new ut(0,0,0,0):a.type==="color"?ut.parse(a.default)||null:a.type==="padding"?Yt.parse(a.default)||null:a.default===void 0?null:a.default}(r):null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(e,r,a,c,u,p){return this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=a,this._evaluator.canonical=c,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=p,this.expression.evaluate(this._evaluator)}evaluate(e,r,a,c,u,p){this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=a||null,this._evaluator.canonical=c,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=p||null;try{const f=this.expression.evaluate(this._evaluator);if(f==null||typeof f=="number"&&f!=f)return this._defaultValue;if(this._enumValues&&!(f in this._enumValues))throw new R(`Expected value to be one of ${Object.keys(this._enumValues).map(_=>JSON.stringify(_)).join(", ")}, but found ${JSON.stringify(f)} instead.`);return f}catch(f){return this._warningHistory[f.message]||(this._warningHistory[f.message]=!0,typeof console<"u"&&console.warn(f.message)),this._defaultValue}}}function Ea(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in Sn}function Ia(i,e){const r=new bn(Sn,[],e?function(c){const u={color:Ti,string:Qe,number:Ee,enum:Qe,boolean:Je,formatted:ri,padding:qr,resolvedImage:Mi};return c.type==="array"?mi(u[c.value]||Xe,c.length):u[c.type]}(e):void 0),a=r.parse(i,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return a?qo(new Cs(a,e)):En(r.errors)}class Ms{constructor(e,r){this.kind=e,this._styleExpression=r,this.isStateDependent=e!=="constant"&&!vn(r.expression)}evaluateWithoutErrorHandling(e,r,a,c,u,p){return this._styleExpression.evaluateWithoutErrorHandling(e,r,a,c,u,p)}evaluate(e,r,a,c,u,p){return this._styleExpression.evaluate(e,r,a,c,u,p)}}class Ps{constructor(e,r,a,c){this.kind=e,this.zoomStops=a,this._styleExpression=r,this.isStateDependent=e!=="camera"&&!vn(r.expression),this.interpolationType=c}evaluateWithoutErrorHandling(e,r,a,c,u,p){return this._styleExpression.evaluateWithoutErrorHandling(e,r,a,c,u,p)}evaluate(e,r,a,c,u,p){return this._styleExpression.evaluate(e,r,a,c,u,p)}interpolationFactor(e,r,a){return this.interpolationType?Pi.interpolationFactor(this.interpolationType,e,r,a):0}}function Ho(i,e){const r=Ia(i,e);if(r.result==="error")return r;const a=r.value.expression,c=fa(a);if(!c&&!In(e))return En([new pi("","data expressions not supported")]);const u=Pr(a,["zoom"]);if(!u&&!Zo(e))return En([new pi("","zoom expressions not supported")]);const p=Ca(a);return p||u?p instanceof pi?En([p]):p instanceof Pi&&!As(e)?En([new pi("",'"interpolate" expressions cannot be used with this property')]):qo(p?new Ps(c?"camera":"composite",r.value,p.labels,p instanceof Pi?p.interpolation:void 0):new Ms(c?"constant":"source",r.value)):En([new pi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Aa{constructor(e,r){this._parameters=e,this._specification=r,di(this,Xo(this._parameters,this._specification))}static deserialize(e){return new Aa(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Ca(i){let e=null;if(i instanceof Wn)e=Ca(i.result);else if(i instanceof xa){for(const r of i.args)if(e=Ca(r),e)break}else(i instanceof qn||i instanceof Pi)&&i.input instanceof oe&&i.input.name==="zoom"&&(e=i);return e instanceof pi||i.eachChild(r=>{const a=Ca(r);a instanceof pi?e=a:!e&&a?e=new pi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&a&&e!==a&&(e=new pi("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}function $i(i){const e=i.key,r=i.value,a=i.valueSpec||{},c=i.objectElementValidators||{},u=i.style,p=i.styleSpec,f=i.validateSpec;let _=[];const v=vt(r);if(v!=="object")return[new Se(e,r,`object expected, ${v} found`)];for(const w in r){const E=w.split(".")[0],P=a[E]||a["*"];let k;if(c[E])k=c[E];else if(a[E])k=f;else if(c["*"])k=c["*"];else{if(!a["*"]){_.push(new Se(e,r[w],`unknown property "${w}"`));continue}k=f}_=_.concat(k({key:(e&&`${e}.`)+w,value:r[w],valueSpec:P,style:u,styleSpec:p,object:r,objectKey:w,validateSpec:f},r))}for(const w in a)c[w]||a[w].required&&a[w].default===void 0&&r[w]===void 0&&_.push(new Se(e,r,`missing required property "${w}"`));return _}function Ko(i){const e=i.value,r=i.valueSpec,a=i.style,c=i.styleSpec,u=i.key,p=i.arrayElementValidator||i.validateSpec;if(vt(e)!=="array")return[new Se(u,e,`array expected, ${vt(e)} found`)];if(r.length&&e.length!==r.length)return[new Se(u,e,`array length ${r.length} expected, length ${e.length} found`)];if(r["min-length"]&&e.length<r["min-length"])return[new Se(u,e,`array length at least ${r["min-length"]} expected, length ${e.length} found`)];let f={type:r.value,values:r.values};c.$version<7&&(f.function=r.function),vt(r.value)==="object"&&(f=r.value);let _=[];for(let v=0;v<e.length;v++)_=_.concat(p({array:e,arrayIndex:v,value:e[v],valueSpec:f,validateSpec:i.validateSpec,style:a,styleSpec:c,key:`${u}[${v}]`}));return _}function ks(i){const e=i.key,r=i.value,a=i.valueSpec;let c=vt(r);return c==="number"&&r!=r&&(c="NaN"),c!=="number"?[new Se(e,r,`number expected, ${c} found`)]:"minimum"in a&&r<a.minimum?[new Se(e,r,`${r} is less than the minimum value ${a.minimum}`)]:"maximum"in a&&r>a.maximum?[new Se(e,r,`${r} is greater than the maximum value ${a.maximum}`)]:[]}function Yo(i){const e=i.valueSpec,r=bt(i.value.type);let a,c,u,p={};const f=r!=="categorical"&&i.value.property===void 0,_=!f,v=vt(i.value.stops)==="array"&&vt(i.value.stops[0])==="array"&&vt(i.value.stops[0][0])==="object",w=$i({key:i.key,value:i.value,valueSpec:i.styleSpec.function,validateSpec:i.validateSpec,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(k){if(r==="identity")return[new Se(k.key,k.value,'identity function may not have a "stops" property')];let L=[];const $=k.value;return L=L.concat(Ko({key:k.key,value:$,valueSpec:k.valueSpec,validateSpec:k.validateSpec,style:k.style,styleSpec:k.styleSpec,arrayElementValidator:E})),vt($)==="array"&&$.length===0&&L.push(new Se(k.key,$,"array must have at least one stop")),L},default:function(k){return k.validateSpec({key:k.key,value:k.value,valueSpec:e,validateSpec:k.validateSpec,style:k.style,styleSpec:k.styleSpec})}}});return r==="identity"&&f&&w.push(new Se(i.key,i.value,'missing required property "property"')),r==="identity"||i.value.stops||w.push(new Se(i.key,i.value,'missing required property "stops"')),r==="exponential"&&i.valueSpec.expression&&!As(i.valueSpec)&&w.push(new Se(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(_&&!In(i.valueSpec)?w.push(new Se(i.key,i.value,"property functions not supported")):f&&!Zo(i.valueSpec)&&w.push(new Se(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!v||i.value.property!==void 0||w.push(new Se(i.key,i.value,'"property" property is required')),w;function E(k){let L=[];const $=k.value,N=k.key;if(vt($)!=="array")return[new Se(N,$,`array expected, ${vt($)} found`)];if($.length!==2)return[new Se(N,$,`array length 2 expected, length ${$.length} found`)];if(v){if(vt($[0])!=="object")return[new Se(N,$,`object expected, ${vt($[0])} found`)];if($[0].zoom===void 0)return[new Se(N,$,"object stop key must have zoom")];if($[0].value===void 0)return[new Se(N,$,"object stop key must have value")];if(u&&u>bt($[0].zoom))return[new Se(N,$[0].zoom,"stop zoom values must appear in ascending order")];bt($[0].zoom)!==u&&(u=bt($[0].zoom),c=void 0,p={}),L=L.concat($i({key:`${N}[0]`,value:$[0],valueSpec:{zoom:{}},validateSpec:k.validateSpec,style:k.style,styleSpec:k.styleSpec,objectElementValidators:{zoom:ks,value:P}}))}else L=L.concat(P({key:`${N}[0]`,value:$[0],valueSpec:{},validateSpec:k.validateSpec,style:k.style,styleSpec:k.styleSpec},$));return Ea(Wi($[1]))?L.concat([new Se(`${N}[1]`,$[1],"expressions are not allowed in function stops.")]):L.concat(k.validateSpec({key:`${N}[1]`,value:$[1],valueSpec:e,validateSpec:k.validateSpec,style:k.style,styleSpec:k.styleSpec}))}function P(k,L){const $=vt(k.value),N=bt(k.value),J=k.value!==null?k.value:L;if(a){if($!==a)return[new Se(k.key,J,`${$} stop domain type must match previous stop domain type ${a}`)]}else a=$;if($!=="number"&&$!=="string"&&$!=="boolean")return[new Se(k.key,J,"stop domain value must be a number, string, or boolean")];if($!=="number"&&r!=="categorical"){let ne=`number expected, ${$} found`;return In(e)&&r===void 0&&(ne+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Se(k.key,J,ne)]}return r!=="categorical"||$!=="number"||isFinite(N)&&Math.floor(N)===N?r!=="categorical"&&$==="number"&&c!==void 0&&N<c?[new Se(k.key,J,"stop domain values must appear in ascending order")]:(c=N,r==="categorical"&&N in p?[new Se(k.key,J,"stop domain values must be unique")]:(p[N]=!0,[])):[new Se(k.key,J,`integer expected, found ${N}`)]}}function An(i){const e=(i.expressionContext==="property"?Ho:Ia)(Wi(i.value),i.valueSpec);if(e.result==="error")return e.value.map(a=>new Se(`${i.key}${a.key}`,i.value,a.message));const r=e.value.expression||e.value._styleExpression.expression;if(i.expressionContext==="property"&&i.propertyKey==="text-font"&&!r.outputDefined())return[new Se(i.key,i.value,`Invalid data expression for "${i.propertyKey}". Output values must be contained as literals within the expression.`)];if(i.expressionContext==="property"&&i.propertyType==="layout"&&!vn(r))return[new Se(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter"&&!vn(r))return[new Se(i.key,i.value,'"feature-state" data expressions are not supported with filters.')];if(i.expressionContext&&i.expressionContext.indexOf("cluster")===0){if(!Pr(r,["zoom","feature-state"]))return[new Se(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(i.expressionContext==="cluster-initial"&&!fa(r))return[new Se(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Ma(i){const e=i.key,r=i.value,a=i.valueSpec,c=[];return Array.isArray(a.values)?a.values.indexOf(bt(r))===-1&&c.push(new Se(e,r,`expected one of [${a.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(a.values).indexOf(bt(r))===-1&&c.push(new Se(e,r,`expected one of [${Object.keys(a.values).join(", ")}], ${JSON.stringify(r)} found`)),c}function Pa(i){if(i===!0||i===!1)return!0;if(!Array.isArray(i)||i.length===0)return!1;switch(i[0]){case"has":return i.length>=2&&i[1]!=="$id"&&i[1]!=="$type";case"in":return i.length>=3&&(typeof i[1]!="string"||Array.isArray(i[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return i.length!==3||Array.isArray(i[1])||Array.isArray(i[2]);case"any":case"all":for(const e of i.slice(1))if(!Pa(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}const ac={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function zs(i){if(i==null)return{filter:()=>!0,needGeometry:!1};Pa(i)||(i=ka(i));const e=Ia(i,ac);if(e.result==="error")throw new Error(e.value.map(r=>`${r.key}: ${r.message}`).join(", "));return{filter:(r,a,c)=>e.value.evaluate(r,a,{},c),needGeometry:Ot(i)}}function sc(i,e){return i<e?-1:i>e?1:0}function Ot(i){if(!Array.isArray(i))return!1;if(i[0]==="within")return!0;for(let e=1;e<i.length;e++)if(Ot(i[e]))return!0;return!1}function ka(i){if(!i)return!0;const e=i[0];return i.length<=1?e!=="any":e==="=="?at(i[1],i[2],"=="):e==="!="?Et(at(i[1],i[2],"==")):e==="<"||e===">"||e==="<="||e===">="?at(i[1],i[2],e):e==="any"?(r=i.slice(1),["any"].concat(r.map(ka))):e==="all"?["all"].concat(i.slice(1).map(ka)):e==="none"?["all"].concat(i.slice(1).map(ka).map(Et)):e==="in"?za(i[1],i.slice(2)):e==="!in"?Et(za(i[1],i.slice(2))):e==="has"?Lt(i[1]):e==="!has"?Et(Lt(i[1])):e!=="within"||i;var r}function at(i,e,r){switch(i){case"$type":return[`filter-type-${r}`,e];case"$id":return[`filter-id-${r}`,e];default:return[`filter-${r}`,i,e]}}function za(i,e){if(e.length===0)return!1;switch(i){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(r=>typeof r!=typeof e[0])?["filter-in-large",i,["literal",e.sort(sc)]]:["filter-in-small",i,["literal",e]]}}function Lt(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function Et(i){return["!",i]}function Cn(i){return Pa(Wi(i.value))?An(di({},i,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Ls(i)}function Ls(i){const e=i.value,r=i.key;if(vt(e)!=="array")return[new Se(r,e,`array expected, ${vt(e)} found`)];const a=i.styleSpec;let c,u=[];if(e.length<1)return[new Se(r,e,"filter array must have at least 1 element")];switch(u=u.concat(Ma({key:`${r}[0]`,value:e[0],valueSpec:a.filter_operator,style:i.style,styleSpec:i.styleSpec})),bt(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&bt(e[1])==="$type"&&u.push(new Se(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&u.push(new Se(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(c=vt(e[1]),c!=="string"&&u.push(new Se(`${r}[1]`,e[1],`string expected, ${c} found`)));for(let p=2;p<e.length;p++)c=vt(e[p]),bt(e[1])==="$type"?u=u.concat(Ma({key:`${r}[${p}]`,value:e[p],valueSpec:a.geometry_type,style:i.style,styleSpec:i.styleSpec})):c!=="string"&&c!=="number"&&c!=="boolean"&&u.push(new Se(`${r}[${p}]`,e[p],`string, number, or boolean expected, ${c} found`));break;case"any":case"all":case"none":for(let p=1;p<e.length;p++)u=u.concat(Ls({key:`${r}[${p}]`,value:e[p],style:i.style,styleSpec:i.styleSpec}));break;case"has":case"!has":c=vt(e[1]),e.length!==2?u.push(new Se(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):c!=="string"&&u.push(new Se(`${r}[1]`,e[1],`string expected, ${c} found`));break;case"within":c=vt(e[1]),e.length!==2?u.push(new Se(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):c!=="object"&&u.push(new Se(`${r}[1]`,e[1],`object expected, ${c} found`))}return u}function Jo(i,e){const r=i.key,a=i.validateSpec,c=i.style,u=i.styleSpec,p=i.value,f=i.objectKey,_=u[`${e}_${i.layerType}`];if(!_)return[];const v=f.match(/^(.*)-transition$/);if(e==="paint"&&v&&_[v[1]]&&_[v[1]].transition)return a({key:r,value:p,valueSpec:u.transition,style:c,styleSpec:u});const w=i.valueSpec||_[f];if(!w)return[new Se(r,p,`unknown property "${f}"`)];let E;if(vt(p)==="string"&&In(w)&&!w.tokens&&(E=/^{([^}]+)}$/.exec(p)))return[new Se(r,p,`"${f}" does not support interpolation syntax
2
- Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(E[1])} }\`.`)];const P=[];return i.layerType==="symbol"&&(f==="text-field"&&c&&!c.glyphs&&P.push(new Se(r,p,'use of "text-field" requires a style "glyphs" property')),f==="text-font"&&Sa(Wi(p))&&bt(p.type)==="identity"&&P.push(new Se(r,p,'"text-font" does not support identity functions'))),P.concat(a({key:i.key,value:p,valueSpec:w,style:c,styleSpec:u,expressionContext:"property",propertyType:e,propertyKey:f}))}function Qo(i){return Jo(i,"paint")}function el(i){return Jo(i,"layout")}function tl(i){let e=[];const r=i.value,a=i.key,c=i.style,u=i.styleSpec;r.type||r.ref||e.push(new Se(a,r,'either "type" or "ref" is required'));let p=bt(r.type);const f=bt(r.ref);if(r.id){const _=bt(r.id);for(let v=0;v<i.arrayIndex;v++){const w=c.layers[v];bt(w.id)===_&&e.push(new Se(a,r.id,`duplicate layer id "${r.id}", previously used at line ${w.id.__line__}`))}}if("ref"in r){let _;["type","source","source-layer","filter","layout"].forEach(v=>{v in r&&e.push(new Se(a,r[v],`"${v}" is prohibited for ref layers`))}),c.layers.forEach(v=>{bt(v.id)===f&&(_=v)}),_?_.ref?e.push(new Se(a,r.ref,"ref cannot reference another ref layer")):p=bt(_.type):e.push(new Se(a,r.ref,`ref layer "${f}" not found`))}else if(p!=="background")if(r.source){const _=c.sources&&c.sources[r.source],v=_&&bt(_.type);_?v==="vector"&&p==="raster"?e.push(new Se(a,r.source,`layer "${r.id}" requires a raster source`)):v==="raster"&&p!=="raster"?e.push(new Se(a,r.source,`layer "${r.id}" requires a vector source`)):v!=="vector"||r["source-layer"]?v==="raster-dem"&&p!=="hillshade"?e.push(new Se(a,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):p!=="line"||!r.paint||!r.paint["line-gradient"]||v==="geojson"&&_.lineMetrics||e.push(new Se(a,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Se(a,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new Se(a,r.source,`source "${r.source}" not found`))}else e.push(new Se(a,r,'missing required property "source"'));return e=e.concat($i({key:a,value:r,valueSpec:u.layer,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,objectElementValidators:{"*":()=>[],type:()=>i.validateSpec({key:`${a}.type`,value:r.type,valueSpec:u.layer.type,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,object:r,objectKey:"type"}),filter:Cn,layout:_=>$i({layer:r,key:_.key,value:_.value,style:_.style,styleSpec:_.styleSpec,validateSpec:_.validateSpec,objectElementValidators:{"*":v=>el(di({layerType:p},v))}}),paint:_=>$i({layer:r,key:_.key,value:_.value,style:_.style,styleSpec:_.styleSpec,validateSpec:_.validateSpec,objectElementValidators:{"*":v=>Qo(di({layerType:p},v))}})}})),e}function kr(i){const e=i.value,r=i.key,a=vt(e);return a!=="string"?[new Se(r,e,`string expected, ${a} found`)]:[]}const Ds={promoteId:function({key:i,value:e}){if(vt(e)==="string")return kr({key:i,value:e});{const r=[];for(const a in e)r.push(...kr({key:`${i}.${a}`,value:e[a]}));return r}}};function Rs(i){const e=i.value,r=i.key,a=i.styleSpec,c=i.style,u=i.validateSpec;if(!e.type)return[new Se(r,e,'"type" is required')];const p=bt(e.type);let f;switch(p){case"vector":case"raster":case"raster-dem":return f=$i({key:r,value:e,valueSpec:a[`source_${p.replace("-","_")}`],style:i.style,styleSpec:a,objectElementValidators:Ds,validateSpec:u}),f;case"geojson":if(f=$i({key:r,value:e,valueSpec:a.source_geojson,style:c,styleSpec:a,validateSpec:u,objectElementValidators:Ds}),e.cluster)for(const _ in e.clusterProperties){const[v,w]=e.clusterProperties[_],E=typeof v=="string"?[v,["accumulated"],["get",_]]:v;f.push(...An({key:`${r}.${_}.map`,value:w,validateSpec:u,expressionContext:"cluster-map"})),f.push(...An({key:`${r}.${_}.reduce`,value:E,validateSpec:u,expressionContext:"cluster-reduce"}))}return f;case"video":return $i({key:r,value:e,valueSpec:a.source_video,style:c,validateSpec:u,styleSpec:a});case"image":return $i({key:r,value:e,valueSpec:a.source_image,style:c,validateSpec:u,styleSpec:a});case"canvas":return[new Se(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Ma({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:c,validateSpec:u,styleSpec:a})}}function Bs(i){const e=i.value,r=i.styleSpec,a=r.light,c=i.style;let u=[];const p=vt(e);if(e===void 0)return u;if(p!=="object")return u=u.concat([new Se("light",e,`object expected, ${p} found`)]),u;for(const f in e){const _=f.match(/^(.*)-transition$/);u=u.concat(_&&a[_[1]]&&a[_[1]].transition?i.validateSpec({key:f,value:e[f],valueSpec:r.transition,validateSpec:i.validateSpec,style:c,styleSpec:r}):a[f]?i.validateSpec({key:f,value:e[f],valueSpec:a[f],validateSpec:i.validateSpec,style:c,styleSpec:r}):[new Se(f,e[f],`unknown property "${f}"`)])}return u}function La(i){const e=i.value,r=i.styleSpec,a=r.terrain,c=i.style;let u=[];const p=vt(e);if(e===void 0)return u;if(p!=="object")return u=u.concat([new Se("terrain",e,`object expected, ${p} found`)]),u;for(const f in e)u=u.concat(a[f]?i.validateSpec({key:f,value:e[f],valueSpec:a[f],validateSpec:i.validateSpec,style:c,styleSpec:r}):[new Se(f,e[f],`unknown property "${f}"`)]);return u}function il(i){let e=[];const r=i.value,a=i.key;if(Array.isArray(r)){const c=[],u=[];for(const p in r)r[p].id&&c.includes(r[p].id)&&e.push(new Se(a,r,`all the sprites' ids must be unique, but ${r[p].id} is duplicated`)),c.push(r[p].id),r[p].url&&u.includes(r[p].url)&&e.push(new Se(a,r,`all the sprites' URLs must be unique, but ${r[p].url} is duplicated`)),u.push(r[p].url),e=e.concat($i({key:`${a}[${p}]`,value:r[p],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:i.validateSpec}));return e}return kr({key:a,value:r})}const rl={"*":()=>[],array:Ko,boolean:function(i){const e=i.value,r=i.key,a=vt(e);return a!=="boolean"?[new Se(r,e,`boolean expected, ${a} found`)]:[]},number:ks,color:function(i){const e=i.key,r=i.value,a=vt(r);return a!=="string"?[new Se(e,r,`color expected, ${a} found`)]:Cr(r)===null?[new Se(e,r,`color expected, "${r}" found`)]:[]},constants:Gn,enum:Ma,filter:Cn,function:Yo,layer:tl,object:$i,source:Rs,light:Bs,terrain:La,string:kr,formatted:function(i){return kr(i).length===0?[]:An(i)},resolvedImage:function(i){return kr(i).length===0?[]:An(i)},padding:function(i){const e=i.key,r=i.value;if(vt(r)==="array"){if(r.length<1||r.length>4)return[new Se(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const a={type:"number"};let c=[];for(let u=0;u<r.length;u++)c=c.concat(i.validateSpec({key:`${e}[${u}]`,value:r[u],validateSpec:i.validateSpec,valueSpec:a}));return c}return ks({key:e,value:r,valueSpec:{}})},sprite:il};function Yn(i){const e=i.value,r=i.valueSpec,a=i.styleSpec;return i.validateSpec=Yn,r.expression&&Sa(bt(e))?Yo(i):r.expression&&Ea(Wi(e))?An(i):r.type&&rl[r.type]?rl[r.type](i):$i(di({},i,{valueSpec:r.type?a[r.type]:r}))}function nl(i){const e=i.value,r=i.key,a=kr(i);return a.length||(e.indexOf("{fontstack}")===-1&&a.push(new Se(r,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&a.push(new Se(r,e,'"glyphs" url must include a "{range}" token'))),a}function or(i,e=le){let r=[];return r=r.concat(Yn({key:"",value:i,valueSpec:e.$root,styleSpec:e,style:i,validateSpec:Yn,objectElementValidators:{glyphs:nl,"*":()=>[]}})),i.constants&&(r=r.concat(Gn({key:"constants",value:i.constants,style:i,styleSpec:e,validateSpec:Yn}))),al(r)}function xr(i){return function(e){return i({...e,validateSpec:Yn})}}function al(i){return[].concat(i).sort((e,r)=>e.line-r.line)}function vr(i){return function(...e){return al(i.apply(this,e))}}or.source=vr(xr(Rs)),or.sprite=vr(xr(il)),or.glyphs=vr(xr(nl)),or.light=vr(xr(Bs)),or.terrain=vr(xr(La)),or.layer=vr(xr(tl)),or.filter=vr(xr(Cn)),or.paintProperty=vr(xr(Qo)),or.layoutProperty=vr(xr(el));const Mn=or,sl=Mn.light,Da=Mn.paintProperty,oc=Mn.layoutProperty;function Fs(i,e){let r=!1;if(e&&e.length)for(const a of e)i.fire(new Gr(new Error(a.message))),r=!0;return r}class Pn{constructor(e,r,a){const c=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const p=new Int32Array(this.arrayBuffer);e=p[0],this.d=(r=p[1])+2*(a=p[2]);for(let _=0;_<this.d*this.d;_++){const v=p[3+_],w=p[3+_+1];c.push(v===w?null:p.subarray(v,w))}const f=p[3+c.length+1];this.keys=p.subarray(p[3+c.length],f),this.bboxes=p.subarray(f),this.insert=this._insertReadonly}else{this.d=r+2*a;for(let p=0;p<this.d*this.d;p++)c.push([]);this.keys=[],this.bboxes=[]}this.n=r,this.extent=e,this.padding=a,this.scale=r/e,this.uid=0;const u=a/r*e;this.min=-u,this.max=e+u}insert(e,r,a,c,u){this._forEachCell(r,a,c,u,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(r),this.bboxes.push(a),this.bboxes.push(c),this.bboxes.push(u)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,r,a,c,u,p){this.cells[u].push(p)}query(e,r,a,c,u){const p=this.min,f=this.max;if(e<=p&&r<=p&&f<=a&&f<=c&&!u)return Array.prototype.slice.call(this.keys);{const _=[];return this._forEachCell(e,r,a,c,this._queryCell,_,{},u),_}}_queryCell(e,r,a,c,u,p,f,_){const v=this.cells[u];if(v!==null){const w=this.keys,E=this.bboxes;for(let P=0;P<v.length;P++){const k=v[P];if(f[k]===void 0){const L=4*k;(_?_(E[L+0],E[L+1],E[L+2],E[L+3]):e<=E[L+2]&&r<=E[L+3]&&a>=E[L+0]&&c>=E[L+1])?(f[k]=!0,p.push(w[k])):f[k]=!1}}}}_forEachCell(e,r,a,c,u,p,f,_){const v=this._convertToCellCoord(e),w=this._convertToCellCoord(r),E=this._convertToCellCoord(a),P=this._convertToCellCoord(c);for(let k=v;k<=E;k++)for(let L=w;L<=P;L++){const $=this.d*L+k;if((!_||_(this._convertFromCellCoord(k),this._convertFromCellCoord(L),this._convertFromCellCoord(k+1),this._convertFromCellCoord(L+1)))&&u.call(this,e,r,a,c,$,p,f,_))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,r=3+this.cells.length+1+1;let a=0;for(let p=0;p<this.cells.length;p++)a+=this.cells[p].length;const c=new Int32Array(r+a+this.keys.length+this.bboxes.length);c[0]=this.extent,c[1]=this.n,c[2]=this.padding;let u=r;for(let p=0;p<e.length;p++){const f=e[p];c[3+p]=u,c.set(f,u),u+=f.length}return c[3+e.length]=u,c.set(this.keys,u),u+=this.keys.length,c[3+e.length+1]=u,c.set(this.bboxes,u),u+=this.bboxes.length,c.buffer}static serialize(e,r){const a=e.toArrayBuffer();return r&&r.push(a),{buffer:a}}static deserialize(e){return new Pn(e.buffer)}}const zr={};function ke(i,e,r={}){if(zr[i])throw new Error(`${i} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:i,writeable:!1}),zr[i]={klass:e,omit:r.omit||[],shallow:r.shallow||[]}}ke("Object",Object),ke("TransferableGridIndex",Pn),ke("Color",ut),ke("Error",Error),ke("AJAXError",Er),ke("ResolvedImage",fi),ke("StylePropertyFunction",Aa),ke("StyleExpression",Cs,{omit:["_evaluator"]}),ke("ZoomDependentExpression",Ps),ke("ZoomConstantExpression",Ms),ke("CompoundExpression",oe,{omit:["_evaluate"]});for(const i in Sn)Sn[i]._classRegistryKey||ke(`Expression_${i}`,Sn[i]);function Jn(i){return i&&typeof ArrayBuffer<"u"&&(i instanceof ArrayBuffer||i.constructor&&i.constructor.name==="ArrayBuffer")}function Qr(i,e){if(i==null||typeof i=="boolean"||typeof i=="number"||typeof i=="string"||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||i instanceof Blob)return i;if(Jn(i)||gr(i))return e&&e.push(i),i;if(ArrayBuffer.isView(i)){const r=i;return e&&e.push(r.buffer),r}if(i instanceof ImageData)return e&&e.push(i.data.buffer),i;if(Array.isArray(i)){const r=[];for(const a of i)r.push(Qr(a,e));return r}if(typeof i=="object"){const r=i.constructor,a=r._classRegistryKey;if(!a)throw new Error("can't serialize object of unregistered class");if(!zr[a])throw new Error(`${a} is not registered.`);const c=r.serialize?r.serialize(i,e):{};if(r.serialize){if(e&&c===e[e.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const u in i){if(!i.hasOwnProperty(u)||zr[a].omit.indexOf(u)>=0)continue;const p=i[u];c[u]=zr[a].shallow.indexOf(u)>=0?p:Qr(p,e)}i instanceof Error&&(c.message=i.message)}if(c.$name)throw new Error("$name property is reserved for worker serialization logic.");return a!=="Object"&&(c.$name=a),c}throw new Error("can't serialize object of type "+typeof i)}function en(i){if(i==null||typeof i=="boolean"||typeof i=="number"||typeof i=="string"||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||i instanceof Blob||Jn(i)||gr(i)||ArrayBuffer.isView(i)||i instanceof ImageData)return i;if(Array.isArray(i))return i.map(en);if(typeof i=="object"){const e=i.$name||"Object";if(!zr[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=zr[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(i);const a=Object.create(r.prototype);for(const c of Object.keys(i)){if(c==="$name")continue;const u=i[c];a[c]=zr[e].shallow.indexOf(c)>=0?u:en(u)}return a}throw new Error("can't deserialize object of type "+typeof i)}class ol{constructor(){this.first=!0}update(e,r){const a=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=a,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=a,!0):(this.lastFloorZoom>a?(this.lastIntegerZoom=a+1,this.lastIntegerZoomTime=r):this.lastFloorZoom<a&&(this.lastIntegerZoom=a,this.lastIntegerZoomTime=r),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=a,!0))}}const Ae={"Latin-1 Supplement":i=>i>=128&&i<=255,Arabic:i=>i>=1536&&i<=1791,"Arabic Supplement":i=>i>=1872&&i<=1919,"Arabic Extended-A":i=>i>=2208&&i<=2303,"Hangul Jamo":i=>i>=4352&&i<=4607,"Unified Canadian Aboriginal Syllabics":i=>i>=5120&&i<=5759,Khmer:i=>i>=6016&&i<=6143,"Unified Canadian Aboriginal Syllabics Extended":i=>i>=6320&&i<=6399,"General Punctuation":i=>i>=8192&&i<=8303,"Letterlike Symbols":i=>i>=8448&&i<=8527,"Number Forms":i=>i>=8528&&i<=8591,"Miscellaneous Technical":i=>i>=8960&&i<=9215,"Control Pictures":i=>i>=9216&&i<=9279,"Optical Character Recognition":i=>i>=9280&&i<=9311,"Enclosed Alphanumerics":i=>i>=9312&&i<=9471,"Geometric Shapes":i=>i>=9632&&i<=9727,"Miscellaneous Symbols":i=>i>=9728&&i<=9983,"Miscellaneous Symbols and Arrows":i=>i>=11008&&i<=11263,"CJK Radicals Supplement":i=>i>=11904&&i<=12031,"Kangxi Radicals":i=>i>=12032&&i<=12255,"Ideographic Description Characters":i=>i>=12272&&i<=12287,"CJK Symbols and Punctuation":i=>i>=12288&&i<=12351,Hiragana:i=>i>=12352&&i<=12447,Katakana:i=>i>=12448&&i<=12543,Bopomofo:i=>i>=12544&&i<=12591,"Hangul Compatibility Jamo":i=>i>=12592&&i<=12687,Kanbun:i=>i>=12688&&i<=12703,"Bopomofo Extended":i=>i>=12704&&i<=12735,"CJK Strokes":i=>i>=12736&&i<=12783,"Katakana Phonetic Extensions":i=>i>=12784&&i<=12799,"Enclosed CJK Letters and Months":i=>i>=12800&&i<=13055,"CJK Compatibility":i=>i>=13056&&i<=13311,"CJK Unified Ideographs Extension A":i=>i>=13312&&i<=19903,"Yijing Hexagram Symbols":i=>i>=19904&&i<=19967,"CJK Unified Ideographs":i=>i>=19968&&i<=40959,"Yi Syllables":i=>i>=40960&&i<=42127,"Yi Radicals":i=>i>=42128&&i<=42191,"Hangul Jamo Extended-A":i=>i>=43360&&i<=43391,"Hangul Syllables":i=>i>=44032&&i<=55215,"Hangul Jamo Extended-B":i=>i>=55216&&i<=55295,"Private Use Area":i=>i>=57344&&i<=63743,"CJK Compatibility Ideographs":i=>i>=63744&&i<=64255,"Arabic Presentation Forms-A":i=>i>=64336&&i<=65023,"Vertical Forms":i=>i>=65040&&i<=65055,"CJK Compatibility Forms":i=>i>=65072&&i<=65103,"Small Form Variants":i=>i>=65104&&i<=65135,"Arabic Presentation Forms-B":i=>i>=65136&&i<=65279,"Halfwidth and Fullwidth Forms":i=>i>=65280&&i<=65519};function Os(i){for(const e of i)if(Us(e.charCodeAt(0)))return!0;return!1}function lc(i){for(const e of i)if(!cc(e.charCodeAt(0)))return!1;return!0}function cc(i){return!(Ae.Arabic(i)||Ae["Arabic Supplement"](i)||Ae["Arabic Extended-A"](i)||Ae["Arabic Presentation Forms-A"](i)||Ae["Arabic Presentation Forms-B"](i))}function Us(i){return!(i!==746&&i!==747&&(i<4352||!(Ae["Bopomofo Extended"](i)||Ae.Bopomofo(i)||Ae["CJK Compatibility Forms"](i)&&!(i>=65097&&i<=65103)||Ae["CJK Compatibility Ideographs"](i)||Ae["CJK Compatibility"](i)||Ae["CJK Radicals Supplement"](i)||Ae["CJK Strokes"](i)||!(!Ae["CJK Symbols and Punctuation"](i)||i>=12296&&i<=12305||i>=12308&&i<=12319||i===12336)||Ae["CJK Unified Ideographs Extension A"](i)||Ae["CJK Unified Ideographs"](i)||Ae["Enclosed CJK Letters and Months"](i)||Ae["Hangul Compatibility Jamo"](i)||Ae["Hangul Jamo Extended-A"](i)||Ae["Hangul Jamo Extended-B"](i)||Ae["Hangul Jamo"](i)||Ae["Hangul Syllables"](i)||Ae.Hiragana(i)||Ae["Ideographic Description Characters"](i)||Ae.Kanbun(i)||Ae["Kangxi Radicals"](i)||Ae["Katakana Phonetic Extensions"](i)||Ae.Katakana(i)&&i!==12540||!(!Ae["Halfwidth and Fullwidth Forms"](i)||i===65288||i===65289||i===65293||i>=65306&&i<=65310||i===65339||i===65341||i===65343||i>=65371&&i<=65503||i===65507||i>=65512&&i<=65519)||!(!Ae["Small Form Variants"](i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||Ae["Unified Canadian Aboriginal Syllabics"](i)||Ae["Unified Canadian Aboriginal Syllabics Extended"](i)||Ae["Vertical Forms"](i)||Ae["Yijing Hexagram Symbols"](i)||Ae["Yi Syllables"](i)||Ae["Yi Radicals"](i))))}function ll(i){return!(Us(i)||function(e){return!!(Ae["Latin-1 Supplement"](e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||Ae["General Punctuation"](e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||Ae["Letterlike Symbols"](e)||Ae["Number Forms"](e)||Ae["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||Ae["Control Pictures"](e)&&e!==9251||Ae["Optical Character Recognition"](e)||Ae["Enclosed Alphanumerics"](e)||Ae["Geometric Shapes"](e)||Ae["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||Ae["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Ae["CJK Symbols and Punctuation"](e)||Ae.Katakana(e)||Ae["Private Use Area"](e)||Ae["CJK Compatibility Forms"](e)||Ae["Small Form Variants"](e)||Ae["Halfwidth and Fullwidth Forms"](e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(i))}function Qn(i){return i>=1424&&i<=2303||Ae["Arabic Presentation Forms-A"](i)||Ae["Arabic Presentation Forms-B"](i)}function Ra(i,e){return!(!e&&Qn(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||Ae.Khmer(i))}function Gi(i){for(const e of i)if(Qn(e.charCodeAt(0)))return!0;return!1}const kn="deferred",Vs="loading",Ns="loaded";let $s=null,Si="unavailable",lr=null;const cl=function(i){i&&typeof i=="string"&&i.indexOf("NetworkError")>-1&&(Si="error"),$s&&$s(i)};function ea(){Gs.fire(new $r("pluginStateChange",{pluginStatus:Si,pluginURL:lr}))}const Gs=new Ir,tn=function(){return Si},hl=function(){if(Si!==kn||!lr)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Si=Vs,ea(),lr&&Vr({url:lr},i=>{i?cl(i):(Si=Ns,ea())})},Ei={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Si===Ns||Ei.applyArabicShaping!=null,isLoading:()=>Si===Vs,setState(i){if(!Oi())throw new Error("Cannot set the state of the rtl-text-plugin when not in the web-worker context");Si=i.pluginStatus,lr=i.pluginURL},isParsed(){if(!Oi())throw new Error("rtl-text-plugin is only parsed on the worker-threads");return Ei.applyArabicShaping!=null&&Ei.processBidirectionalText!=null&&Ei.processStyledBidirectionalText!=null},getPluginURL(){if(!Oi())throw new Error("rtl-text-plugin url can only be queried from the worker threads");return lr}};class Pt{constructor(e,r){this.zoom=e,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 ol,this.transition={})}isSupportedScript(e){return function(r,a){for(const c of r)if(!Ra(c.charCodeAt(0),a))return!1;return!0}(e,Ei.isLoaded())}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,r=e-Math.floor(e),a=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*a}:{fromScale:.5,toScale:1,t:1-(1-a)*r}}}class zn{constructor(e,r){this.property=e,this.value=r,this.expression=function(a,c){if(Sa(a))return new Aa(a,c);if(Ea(a)){const u=Ho(a,c);if(u.result==="error")throw new Error(u.value.map(p=>`${p.key}: ${p.message}`).join(", "));return u.value}{let u=a;return c.type==="color"&&typeof a=="string"?u=ut.parse(a):c.type!=="padding"||typeof a!="number"&&!Array.isArray(a)||(u=Yt.parse(a)),{kind:"constant",evaluate:()=>u}}}(r===void 0?e.specification.default:r,e.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,r,a){return this.property.possiblyEvaluate(this,e,r,a)}}class Ba{constructor(e){this.property=e,this.value=new zn(e,void 0)}transitioned(e,r){return new ul(this.property,this.value,r,Be({},e.transition,this.transition),e.now)}untransitioned(){return new ul(this.property,this.value,null,{},0)}}class js{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return Ci(this._values[e].value.value)}setValue(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ba(this._values[e].property)),this._values[e].value=new zn(this._values[e].property,r===null?void 0:Ci(r))}getTransition(e){return Ci(this._values[e].transition)}setTransition(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ba(this._values[e].property)),this._values[e].transition=Ci(r)||void 0}serialize(){const e={};for(const r of Object.keys(this._values)){const a=this.getValue(r);a!==void 0&&(e[r]=a);const c=this.getTransition(r);c!==void 0&&(e[`${r}-transition`]=c)}return e}transitioned(e,r){const a=new Fa(this._properties);for(const c of Object.keys(this._values))a._values[c]=this._values[c].transitioned(e,r._values[c]);return a}untransitioned(){const e=new Fa(this._properties);for(const r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class ul{constructor(e,r,a,c,u){this.property=e,this.value=r,this.begin=u+c.delay||0,this.end=this.begin+c.duration||0,e.specification.transition&&(c.delay||c.duration)&&(this.prior=a)}possiblyEvaluate(e,r,a){const c=e.now||0,u=this.value.possiblyEvaluate(e,r,a),p=this.prior;if(p){if(c>this.end)return this.prior=null,u;if(this.value.isDataDriven())return this.prior=null,u;if(c<this.begin)return p.possiblyEvaluate(e,r,a);{const f=(c-this.begin)/(this.end-this.begin);return this.property.interpolate(p.possiblyEvaluate(e,r,a),u,function(_){if(_<=0)return 0;if(_>=1)return 1;const v=_*_,w=v*_;return 4*(_<.5?w:3*(_-v)+w-.75)}(f))}}return u}}class Fa{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,r,a){const c=new Ua(this._properties);for(const u of Object.keys(this._values))c._values[u]=this._values[u].possiblyEvaluate(e,r,a);return c}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Oa{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}getValue(e){return Ci(this._values[e].value)}setValue(e,r){this._values[e]=new zn(this._values[e].property,r===null?void 0:Ci(r))}serialize(){const e={};for(const r of Object.keys(this._values)){const a=this.getValue(r);a!==void 0&&(e[r]=a)}return e}possiblyEvaluate(e,r,a){const c=new Ua(this._properties);for(const u of Object.keys(this._values))c._values[u]=this._values[u].possiblyEvaluate(e,r,a);return c}}class Ki{constructor(e,r,a){this.property=e,this.value=r,this.parameters=a}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,r,a,c){return this.property.evaluate(this.value,this.parameters,e,r,a,c)}}class Ua{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class Oe{constructor(e){this.specification=e}possiblyEvaluate(e,r){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(r)}interpolate(e,r,a){const c=Kr[this.specification.type];return c?c(e,r,a):e}}class Ze{constructor(e,r){this.specification=e,this.overrides=r}possiblyEvaluate(e,r,a,c){return new Ki(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(r,null,{},a,c)}:e.expression,r)}interpolate(e,r,a){if(e.value.kind!=="constant"||r.value.kind!=="constant")return e;if(e.value.value===void 0||r.value.value===void 0)return new Ki(this,{kind:"constant",value:void 0},e.parameters);const c=Kr[this.specification.type];return c?new Ki(this,{kind:"constant",value:c(e.value.value,r.value.value,a)},e.parameters):e}evaluate(e,r,a,c,u,p){return e.kind==="constant"?e.value:e.evaluate(r,a,c,u,p)}}class Ln extends Ze{possiblyEvaluate(e,r,a,c){if(e.value===void 0)return new Ki(this,{kind:"constant",value:void 0},r);if(e.expression.kind==="constant"){const u=e.expression.evaluate(r,null,{},a,c),p=e.property.specification.type==="resolvedImage"&&typeof u!="string"?u.name:u,f=this._calculate(p,p,p,r);return new Ki(this,{kind:"constant",value:f},r)}if(e.expression.kind==="camera"){const u=this._calculate(e.expression.evaluate({zoom:r.zoom-1}),e.expression.evaluate({zoom:r.zoom}),e.expression.evaluate({zoom:r.zoom+1}),r);return new Ki(this,{kind:"constant",value:u},r)}return new Ki(this,e.expression,r)}evaluate(e,r,a,c,u,p){if(e.kind==="source"){const f=e.evaluate(r,a,c,u,p);return this._calculate(f,f,f,r)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(r.zoom)-1},a,c),e.evaluate({zoom:Math.floor(r.zoom)},a,c),e.evaluate({zoom:Math.floor(r.zoom)+1},a,c),r):e.value}_calculate(e,r,a,c){return c.zoom>c.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:a,to:r}}interpolate(e){return e}}class qs{constructor(e){this.specification=e}possiblyEvaluate(e,r,a,c){if(e.value!==void 0){if(e.expression.kind==="constant"){const u=e.expression.evaluate(r,null,{},a,c);return this._calculate(u,u,u,r)}return this._calculate(e.expression.evaluate(new Pt(Math.floor(r.zoom-1),r)),e.expression.evaluate(new Pt(Math.floor(r.zoom),r)),e.expression.evaluate(new Pt(Math.floor(r.zoom+1),r)),r)}}_calculate(e,r,a,c){return c.zoom>c.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:a,to:r}}interpolate(e){return e}}class Zs{constructor(e){this.specification=e}possiblyEvaluate(e,r,a,c){return!!e.expression.evaluate(r,null,{},a,c)}interpolate(){return!1}}class Ii{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const r in e){const a=e[r];a.specification.overridable&&this.overridableProperties.push(r);const c=this.defaultPropertyValues[r]=new zn(a,void 0),u=this.defaultTransitionablePropertyValues[r]=new Ba(a);this.defaultTransitioningPropertyValues[r]=u.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=c.possiblyEvaluate({})}}}ke("DataDrivenProperty",Ze),ke("DataConstantProperty",Oe),ke("CrossFadedDataDrivenProperty",Ln),ke("CrossFadedProperty",qs),ke("ColorRampProperty",Zs);const Va="-transition";class Yi extends Ir{constructor(e,r){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1},e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),r.layout&&(this._unevaluatedLayout=new Oa(r.layout)),r.paint)){this._transitionablePaint=new js(r.paint);for(const a in e.paint)this.setPaintProperty(a,e.paint[a],{validate:!1});for(const a in e.layout)this.setLayoutProperty(a,e.layout[a],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ua(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,r,a={}){r!=null&&this._validate(oc,`layers.${this.id}.layout.${e}`,e,r,a)||(e!=="visibility"?this._unevaluatedLayout.setValue(e,r):this.visibility=r)}getPaintProperty(e){return e.endsWith(Va)?this._transitionablePaint.getTransition(e.slice(0,-Va.length)):this._transitionablePaint.getValue(e)}setPaintProperty(e,r,a={}){if(r!=null&&this._validate(Da,`layers.${this.id}.paint.${e}`,e,r,a))return!1;if(e.endsWith(Va))return this._transitionablePaint.setTransition(e.slice(0,-Va.length),r||void 0),!1;{const c=this._transitionablePaint._values[e],u=c.property.specification["property-type"]==="cross-faded-data-driven",p=c.value.isDataDriven(),f=c.value;this._transitionablePaint.setValue(e,r),this._handleSpecialPaintPropertyUpdate(e);const _=this._transitionablePaint._values[e].value;return _.isDataDriven()||p||u||this._handleOverridablePaintPropertyUpdate(e,f,_)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,r,a){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,r){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,r)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),dn(e,(r,a)=>!(r===void 0||a==="layout"&&!Object.keys(r).length||a==="paint"&&!Object.keys(r).length))}_validate(e,r,a,c,u={}){return(!u||u.validate!==!1)&&Fs(this,e.call(Mn,{key:r,layerType:this.type,objectKey:a,value:c,styleSpec:le,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const r=this.paint.get(e);if(r instanceof Ki&&In(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}}const hc={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Na{constructor(e,r){this._structArray=e,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Ut{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,r){return e._trim(),r&&(e.isTransferred=!0,r.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const r=Object.create(this.prototype);return r.arrayBuffer=e.arrayBuffer,r.length=e.length,r.capacity=e.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);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 jt(i,e=1){let r=0,a=0;return{members:i.map(c=>{const u=hc[c.type].BYTES_PER_ELEMENT,p=r=dl(r,Math.max(e,u)),f=c.components||1;return a=Math.max(a,u),r+=u*f,{name:c.name,type:c.type,components:f,offset:p}}),size:dl(r,Math.max(a,e)),alignment:e}}function dl(i,e){return Math.ceil(i/e)*e}class ta extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r){const a=this.length;return this.resize(a+1),this.emplace(a,e,r)}emplace(e,r,a){const c=2*e;return this.int16[c+0]=r,this.int16[c+1]=a,e}}ta.prototype.bytesPerElement=4,ke("StructArrayLayout2i4",ta);class $a extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,r,a)}emplace(e,r,a,c){const u=3*e;return this.int16[u+0]=r,this.int16[u+1]=a,this.int16[u+2]=c,e}}$a.prototype.bytesPerElement=6,ke("StructArrayLayout3i6",$a);class Dn extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,r,a,c)}emplace(e,r,a,c,u){const p=4*e;return this.int16[p+0]=r,this.int16[p+1]=a,this.int16[p+2]=c,this.int16[p+3]=u,e}}Dn.prototype.bytesPerElement=8,ke("StructArrayLayout4i8",Dn);class Xs extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,a,c,u,p)}emplace(e,r,a,c,u,p,f){const _=6*e;return this.int16[_+0]=r,this.int16[_+1]=a,this.int16[_+2]=c,this.int16[_+3]=u,this.int16[_+4]=p,this.int16[_+5]=f,e}}Xs.prototype.bytesPerElement=12,ke("StructArrayLayout2i4i12",Xs);class ia extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,a,c,u,p)}emplace(e,r,a,c,u,p,f){const _=4*e,v=8*e;return this.int16[_+0]=r,this.int16[_+1]=a,this.uint8[v+4]=c,this.uint8[v+5]=u,this.uint8[v+6]=p,this.uint8[v+7]=f,e}}ia.prototype.bytesPerElement=8,ke("StructArrayLayout2i4ub8",ia);class ra extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r){const a=this.length;return this.resize(a+1),this.emplace(a,e,r)}emplace(e,r,a){const c=2*e;return this.float32[c+0]=r,this.float32[c+1]=a,e}}ra.prototype.bytesPerElement=8,ke("StructArrayLayout2f8",ra);class Ws extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u,p,f,_,v,w){const E=this.length;return this.resize(E+1),this.emplace(E,e,r,a,c,u,p,f,_,v,w)}emplace(e,r,a,c,u,p,f,_,v,w,E){const P=10*e;return this.uint16[P+0]=r,this.uint16[P+1]=a,this.uint16[P+2]=c,this.uint16[P+3]=u,this.uint16[P+4]=p,this.uint16[P+5]=f,this.uint16[P+6]=_,this.uint16[P+7]=v,this.uint16[P+8]=w,this.uint16[P+9]=E,e}}Ws.prototype.bytesPerElement=20,ke("StructArrayLayout10ui20",Ws);class Hs extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u,p,f,_,v,w,E,P){const k=this.length;return this.resize(k+1),this.emplace(k,e,r,a,c,u,p,f,_,v,w,E,P)}emplace(e,r,a,c,u,p,f,_,v,w,E,P,k){const L=12*e;return this.int16[L+0]=r,this.int16[L+1]=a,this.int16[L+2]=c,this.int16[L+3]=u,this.uint16[L+4]=p,this.uint16[L+5]=f,this.uint16[L+6]=_,this.uint16[L+7]=v,this.int16[L+8]=w,this.int16[L+9]=E,this.int16[L+10]=P,this.int16[L+11]=k,e}}Hs.prototype.bytesPerElement=24,ke("StructArrayLayout4i4ui4i24",Hs);class Ga extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,r,a)}emplace(e,r,a,c){const u=3*e;return this.float32[u+0]=r,this.float32[u+1]=a,this.float32[u+2]=c,e}}Ga.prototype.bytesPerElement=12,ke("StructArrayLayout3f12",Ga);class ja extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint32[1*e+0]=r,e}}ja.prototype.bytesPerElement=4,ke("StructArrayLayout1ul4",ja);class Ks extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u,p,f,_,v){const w=this.length;return this.resize(w+1),this.emplace(w,e,r,a,c,u,p,f,_,v)}emplace(e,r,a,c,u,p,f,_,v,w){const E=10*e,P=5*e;return this.int16[E+0]=r,this.int16[E+1]=a,this.int16[E+2]=c,this.int16[E+3]=u,this.int16[E+4]=p,this.int16[E+5]=f,this.uint32[P+3]=_,this.uint16[E+8]=v,this.uint16[E+9]=w,e}}Ks.prototype.bytesPerElement=20,ke("StructArrayLayout6i1ul2ui20",Ks);class Ys extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,a,c,u,p)}emplace(e,r,a,c,u,p,f){const _=6*e;return this.int16[_+0]=r,this.int16[_+1]=a,this.int16[_+2]=c,this.int16[_+3]=u,this.int16[_+4]=p,this.int16[_+5]=f,e}}Ys.prototype.bytesPerElement=12,ke("StructArrayLayout2i2i2i12",Ys);class Js extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,r,a,c,u)}emplace(e,r,a,c,u,p){const f=4*e,_=8*e;return this.float32[f+0]=r,this.float32[f+1]=a,this.float32[f+2]=c,this.int16[_+6]=u,this.int16[_+7]=p,e}}Js.prototype.bytesPerElement=16,ke("StructArrayLayout2f1f2i16",Js);class Qs extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,r,a,c)}emplace(e,r,a,c,u){const p=12*e,f=3*e;return this.uint8[p+0]=r,this.uint8[p+1]=a,this.float32[f+1]=c,this.float32[f+2]=u,e}}Qs.prototype.bytesPerElement=12,ke("StructArrayLayout2ub2f12",Qs);class qa extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,r,a)}emplace(e,r,a,c){const u=3*e;return this.uint16[u+0]=r,this.uint16[u+1]=a,this.uint16[u+2]=c,e}}qa.prototype.bytesPerElement=6,ke("StructArrayLayout3ui6",qa);class eo extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u,p,f,_,v,w,E,P,k,L,$,N,J){const ne=this.length;return this.resize(ne+1),this.emplace(ne,e,r,a,c,u,p,f,_,v,w,E,P,k,L,$,N,J)}emplace(e,r,a,c,u,p,f,_,v,w,E,P,k,L,$,N,J,ne){const K=24*e,re=12*e,ge=48*e;return this.int16[K+0]=r,this.int16[K+1]=a,this.uint16[K+2]=c,this.uint16[K+3]=u,this.uint32[re+2]=p,this.uint32[re+3]=f,this.uint32[re+4]=_,this.uint16[K+10]=v,this.uint16[K+11]=w,this.uint16[K+12]=E,this.float32[re+7]=P,this.float32[re+8]=k,this.uint8[ge+36]=L,this.uint8[ge+37]=$,this.uint8[ge+38]=N,this.uint32[re+10]=J,this.int16[K+22]=ne,e}}eo.prototype.bytesPerElement=48,ke("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",eo);class Lr extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u,p,f,_,v,w,E,P,k,L,$,N,J,ne,K,re,ge,fe,De,Fe,Me,Ie,Te,Pe){const Ce=this.length;return this.resize(Ce+1),this.emplace(Ce,e,r,a,c,u,p,f,_,v,w,E,P,k,L,$,N,J,ne,K,re,ge,fe,De,Fe,Me,Ie,Te,Pe)}emplace(e,r,a,c,u,p,f,_,v,w,E,P,k,L,$,N,J,ne,K,re,ge,fe,De,Fe,Me,Ie,Te,Pe,Ce){const be=34*e,$e=17*e;return this.int16[be+0]=r,this.int16[be+1]=a,this.int16[be+2]=c,this.int16[be+3]=u,this.int16[be+4]=p,this.int16[be+5]=f,this.int16[be+6]=_,this.int16[be+7]=v,this.uint16[be+8]=w,this.uint16[be+9]=E,this.uint16[be+10]=P,this.uint16[be+11]=k,this.uint16[be+12]=L,this.uint16[be+13]=$,this.uint16[be+14]=N,this.uint16[be+15]=J,this.uint16[be+16]=ne,this.uint16[be+17]=K,this.uint16[be+18]=re,this.uint16[be+19]=ge,this.uint16[be+20]=fe,this.uint16[be+21]=De,this.uint16[be+22]=Fe,this.uint32[$e+12]=Me,this.float32[$e+13]=Ie,this.float32[$e+14]=Te,this.float32[$e+15]=Pe,this.float32[$e+16]=Ce,e}}Lr.prototype.bytesPerElement=68,ke("StructArrayLayout8i15ui1ul4f68",Lr);class Za extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.float32[1*e+0]=r,e}}Za.prototype.bytesPerElement=4,ke("StructArrayLayout1f4",Za);class to extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,r,a)}emplace(e,r,a,c){const u=4*e;return this.uint32[2*e+0]=r,this.uint16[u+2]=a,this.uint16[u+3]=c,e}}to.prototype.bytesPerElement=8,ke("StructArrayLayout1ul2ui8",to);class io extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r){const a=this.length;return this.resize(a+1),this.emplace(a,e,r)}emplace(e,r,a){const c=2*e;return this.uint16[c+0]=r,this.uint16[c+1]=a,e}}io.prototype.bytesPerElement=4,ke("StructArrayLayout2ui4",io);class Xa extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint16[1*e+0]=r,e}}Xa.prototype.bytesPerElement=2,ke("StructArrayLayout1ui2",Xa);class ro extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,r,a,c)}emplace(e,r,a,c,u){const p=4*e;return this.float32[p+0]=r,this.float32[p+1]=a,this.float32[p+2]=c,this.float32[p+3]=u,e}}ro.prototype.bytesPerElement=16,ke("StructArrayLayout4f16",ro);class pl extends Na{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 He(this.anchorPointX,this.anchorPointY)}}pl.prototype.size=20;class no extends Ks{get(e){return new pl(this,e)}}ke("CollisionBoxArray",no);class Wa extends Na{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Wa.prototype.size=48;class ao extends eo{get(e){return new Wa(this,e)}}ke("PlacedSymbolArray",ao);class Ha extends Na{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get textOffset0(){return this._structArray.float32[this._pos4+14]}get textOffset1(){return this._structArray.float32[this._pos4+15]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+16]}}Ha.prototype.size=68;class ml extends Lr{get(e){return new Ha(this,e)}}ke("SymbolInstanceArray",ml);class rn extends Za{getoffsetX(e){return this.float32[1*e+0]}}ke("GlyphOffsetArray",rn);class na extends $a{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}ke("SymbolLineVertexArray",na);class Rn extends Na{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]}}Rn.prototype.size=8;class fl extends to{get(e){return new Rn(this,e)}}ke("FeatureIndexArray",fl);class so extends ta{}class aa extends ta{}class uc extends ta{}class dc extends Xs{}class gl extends ia{}class pc extends ra{}class Dr extends Ws{}class o extends Hs{}class t extends Ga{}class n extends ja{}class s extends Ys{}class l extends Qs{}class d extends qa{}class m extends io{}const g=jt([{name:"a_pos",components:2,type:"Int16"}],4),{members:y}=g;class x{constructor(e=[]){this.segments=e}prepareSegment(e,r,a,c){let u=this.segments[this.segments.length-1];return e>x.MAX_VERTEX_ARRAY_LENGTH&&dt(`Max vertices per segment is ${x.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!u||u.vertexLength+e>x.MAX_VERTEX_ARRAY_LENGTH||u.sortKey!==c)&&(u={vertexOffset:r.length,primitiveOffset:a.length,vertexLength:0,primitiveLength:0},c!==void 0&&(u.sortKey=c),this.segments.push(u)),u}get(){return this.segments}destroy(){for(const e of this.segments)for(const r in e.vaos)e.vaos[r].destroy()}static simpleSegment(e,r,a,c){return new x([{vertexOffset:e,primitiveOffset:r,vertexLength:a,primitiveLength:c,vaos:{},sortKey:0}])}}function S(i,e){return 256*(i=pe(Math.floor(i),0,255))+pe(Math.floor(e),0,255)}x.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ke("SegmentVector",x);const T=jt([{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 M={},F={get exports(){return M},set exports(i){M=i}},O={};({get exports(){return O},set exports(i){O=i}}).exports=function(i,e){var r,a,c,u,p,f,_,v;for(a=i.length-(r=3&i.length),c=e,p=3432918353,f=461845907,v=0;v<a;)_=255&i.charCodeAt(v)|(255&i.charCodeAt(++v))<<8|(255&i.charCodeAt(++v))<<16|(255&i.charCodeAt(++v))<<24,++v,c=27492+(65535&(u=5*(65535&(c=(c^=_=(65535&(_=(_=(65535&_)*p+(((_>>>16)*p&65535)<<16)&4294967295)<<15|_>>>17))*f+(((_>>>16)*f&65535)<<16)&4294967295)<<13|c>>>19))+((5*(c>>>16)&65535)<<16)&4294967295))+((58964+(u>>>16)&65535)<<16);switch(_=0,r){case 3:_^=(255&i.charCodeAt(v+2))<<16;case 2:_^=(255&i.charCodeAt(v+1))<<8;case 1:c^=_=(65535&(_=(_=(65535&(_^=255&i.charCodeAt(v)))*p+(((_>>>16)*p&65535)<<16)&4294967295)<<15|_>>>17))*f+(((_>>>16)*f&65535)<<16)&4294967295}return c^=i.length,c=2246822507*(65535&(c^=c>>>16))+((2246822507*(c>>>16)&65535)<<16)&4294967295,c=3266489909*(65535&(c^=c>>>13))+((3266489909*(c>>>16)&65535)<<16)&4294967295,(c^=c>>>16)>>>0};var D={};({get exports(){return D},set exports(i){D=i}}).exports=function(i,e){for(var r,a=i.length,c=e^a,u=0;a>=4;)r=1540483477*(65535&(r=255&i.charCodeAt(u)|(255&i.charCodeAt(++u))<<8|(255&i.charCodeAt(++u))<<16|(255&i.charCodeAt(++u))<<24))+((1540483477*(r>>>16)&65535)<<16),c=1540483477*(65535&c)+((1540483477*(c>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),a-=4,++u;switch(a){case 3:c^=(255&i.charCodeAt(u+2))<<16;case 2:c^=(255&i.charCodeAt(u+1))<<8;case 1:c=1540483477*(65535&(c^=255&i.charCodeAt(u)))+((1540483477*(c>>>16)&65535)<<16)}return c=1540483477*(65535&(c^=c>>>13))+((1540483477*(c>>>16)&65535)<<16),(c^=c>>>15)>>>0};var G=O,Y=D;F.exports=G,M.murmur3=G,M.murmur2=Y;class H{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,r,a,c){this.ids.push(V(e)),this.positions.push(r,a,c)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const r=V(e);let a=0,c=this.ids.length-1;for(;a<c;){const p=a+c>>1;this.ids[p]>=r?c=p:a=p+1}const u=[];for(;this.ids[a]===r;)u.push({index:this.positions[3*a],start:this.positions[3*a+1],end:this.positions[3*a+2]}),a++;return u}static serialize(e,r){const a=new Float64Array(e.ids),c=new Uint32Array(e.positions);return te(a,c,0,a.length-1),r&&r.push(a.buffer,c.buffer),{ids:a,positions:c}}static deserialize(e){const r=new H;return r.ids=e.ids,r.positions=e.positions,r.indexed=!0,r}}function V(i){const e=+i;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:M(String(i))}function te(i,e,r,a){for(;r<a;){const c=i[r+a>>1];let u=r-1,p=a+1;for(;;){do u++;while(i[u]<c);do p--;while(i[p]>c);if(u>=p)break;ae(i,u,p),ae(e,3*u,3*p),ae(e,3*u+1,3*p+1),ae(e,3*u+2,3*p+2)}p-r<a-p?(te(i,e,r,p),r=p+1):(te(i,e,p+1,a),a=p)}}function ae(i,e,r){const a=i[e];i[e]=i[r],i[r]=a}ke("FeaturePositionMap",H);class se{constructor(e,r){this.gl=e.gl,this.location=r}}class ue extends se{constructor(e,r){super(e,r),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class me extends se{constructor(e,r){super(e,r),this.current=[0,0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]&&e[3]===this.current[3]||(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}}class xe extends se{constructor(e,r){super(e,r),this.current=ut.transparent}set(e){e.r===this.current.r&&e.g===this.current.g&&e.b===this.current.b&&e.a===this.current.a||(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}}const _e=new Float32Array(16);function we(i){return[S(255*i.r,255*i.g),S(255*i.b,255*i.a)]}class ze{constructor(e,r,a){this.value=e,this.uniformNames=r.map(c=>`u_${c}`),this.type=a}setUniform(e,r,a){e.set(a.constantOr(this.value))}getBinding(e,r,a){return this.type==="color"?new xe(e,r):new ue(e,r)}}class We{constructor(e,r){this.uniformNames=r.map(a=>`u_${a}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=e.tlbr}setUniform(e,r,a,c){const u=c==="u_pattern_to"?this.patternTo:c==="u_pattern_from"?this.patternFrom:c==="u_pixel_ratio_to"?this.pixelRatioTo:c==="u_pixel_ratio_from"?this.pixelRatioFrom:null;u&&e.set(u)}getBinding(e,r,a){return a.substr(0,9)==="u_pattern"?new me(e,r):new ue(e,r)}}class Ke{constructor(e,r,a,c){this.expression=e,this.type=a,this.maxValue=0,this.paintVertexAttributes=r.map(u=>({name:`a_${u}`,type:"Float32",components:a==="color"?2:1,offset:0})),this.paintVertexArray=new c}populatePaintArray(e,r,a,c,u){const p=this.paintVertexArray.length,f=this.expression.evaluate(new Pt(0),r,{},c,[],u);this.paintVertexArray.resize(e),this._setPaintValue(p,e,f)}updatePaintArray(e,r,a,c){const u=this.expression.evaluate({zoom:0},a,c);this._setPaintValue(e,r,u)}_setPaintValue(e,r,a){if(this.type==="color"){const c=we(a);for(let u=e;u<r;u++)this.paintVertexArray.emplace(u,c[0],c[1])}else{for(let c=e;c<r;c++)this.paintVertexArray.emplace(c,a);this.maxValue=Math.max(this.maxValue,Math.abs(a))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Le{constructor(e,r,a,c,u,p){this.expression=e,this.uniformNames=r.map(f=>`u_${f}_t`),this.type=a,this.useIntegerZoom=c,this.zoom=u,this.maxValue=0,this.paintVertexAttributes=r.map(f=>({name:`a_${f}`,type:"Float32",components:a==="color"?4:2,offset:0})),this.paintVertexArray=new p}populatePaintArray(e,r,a,c,u){const p=this.expression.evaluate(new Pt(this.zoom),r,{},c,[],u),f=this.expression.evaluate(new Pt(this.zoom+1),r,{},c,[],u),_=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(_,e,p,f)}updatePaintArray(e,r,a,c){const u=this.expression.evaluate({zoom:this.zoom},a,c),p=this.expression.evaluate({zoom:this.zoom+1},a,c);this._setPaintValue(e,r,u,p)}_setPaintValue(e,r,a,c){if(this.type==="color"){const u=we(a),p=we(c);for(let f=e;f<r;f++)this.paintVertexArray.emplace(f,u[0],u[1],p[0],p[1])}else{for(let u=e;u<r;u++)this.paintVertexArray.emplace(u,a,c);this.maxValue=Math.max(this.maxValue,Math.abs(a),Math.abs(c))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,r){const a=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,c=pe(this.expression.interpolationFactor(a,this.zoom,this.zoom+1),0,1);e.set(c)}getBinding(e,r,a){return new ue(e,r)}}class mt{constructor(e,r,a,c,u,p){this.expression=e,this.type=r,this.useIntegerZoom=a,this.zoom=c,this.layerId=p,this.zoomInPaintVertexArray=new u,this.zoomOutPaintVertexArray=new u}populatePaintArray(e,r,a){const c=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(c,e,r.patterns&&r.patterns[this.layerId],a)}updatePaintArray(e,r,a,c,u){this._setPaintValues(e,r,a.patterns&&a.patterns[this.layerId],u)}_setPaintValues(e,r,a,c){if(!c||!a)return;const{min:u,mid:p,max:f}=a,_=c[u],v=c[p],w=c[f];if(_&&v&&w)for(let E=e;E<r;E++)this.zoomInPaintVertexArray.emplace(E,v.tl[0],v.tl[1],v.br[0],v.br[1],_.tl[0],_.tl[1],_.br[0],_.br[1],v.pixelRatio,_.pixelRatio),this.zoomOutPaintVertexArray.emplace(E,v.tl[0],v.tl[1],v.br[0],v.br[1],w.tl[0],w.tl[1],w.br[0],w.br[1],v.pixelRatio,w.pixelRatio)}upload(e){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,T.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,T.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class ft{constructor(e,r,a){this.binders={},this._buffers=[];const c=[];for(const u in e.paint._values){if(!a(u))continue;const p=e.paint.get(u);if(!(p instanceof Ki&&In(p.property.specification)))continue;const f=ht(u,e.type),_=p.value,v=p.property.specification.type,w=p.property.useIntegerZoom,E=p.property.specification["property-type"],P=E==="cross-faded"||E==="cross-faded-data-driven";if(_.kind==="constant")this.binders[u]=P?new We(_.value,f):new ze(_.value,f,v),c.push(`/u_${u}`);else if(_.kind==="source"||P){const k=wt(u,v,"source");this.binders[u]=P?new mt(_,v,w,r,k,e.id):new Ke(_,f,v,k),c.push(`/a_${u}`)}else{const k=wt(u,v,"composite");this.binders[u]=new Le(_,f,v,w,r,k),c.push(`/z_${u}`)}}this.cacheKey=c.sort().join("")}getMaxValue(e){const r=this.binders[e];return r instanceof Ke||r instanceof Le?r.maxValue:0}populatePaintArrays(e,r,a,c,u){for(const p in this.binders){const f=this.binders[p];(f instanceof Ke||f instanceof Le||f instanceof mt)&&f.populatePaintArray(e,r,a,c,u)}}setConstantPatternPositions(e,r){for(const a in this.binders){const c=this.binders[a];c instanceof We&&c.setConstantPatternPositions(e,r)}}updatePaintArrays(e,r,a,c,u){let p=!1;for(const f in e){const _=r.getPositions(f);for(const v of _){const w=a.feature(v.index);for(const E in this.binders){const P=this.binders[E];if((P instanceof Ke||P instanceof Le||P instanceof mt)&&P.expression.isStateDependent===!0){const k=c.paint.get(E);P.expression=k.value,P.updatePaintArray(v.start,v.end,w,e[f],u),p=!0}}}}return p}defines(){const e=[];for(const r in this.binders){const a=this.binders[r];(a instanceof ze||a instanceof We)&&e.push(...a.uniformNames.map(c=>`#define HAS_UNIFORM_${c}`))}return e}getBinderAttributes(){const e=[];for(const r in this.binders){const a=this.binders[r];if(a instanceof Ke||a instanceof Le)for(let c=0;c<a.paintVertexAttributes.length;c++)e.push(a.paintVertexAttributes[c].name);else if(a instanceof mt)for(let c=0;c<T.members.length;c++)e.push(T.members[c].name)}return e}getBinderUniforms(){const e=[];for(const r in this.binders){const a=this.binders[r];if(a instanceof ze||a instanceof We||a instanceof Le)for(const c of a.uniformNames)e.push(c)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,r){const a=[];for(const c in this.binders){const u=this.binders[c];if(u instanceof ze||u instanceof We||u instanceof Le){for(const p of u.uniformNames)if(r[p]){const f=u.getBinding(e,r[p],p);a.push({name:p,property:c,binding:f})}}}return a}setUniforms(e,r,a,c){for(const{name:u,property:p,binding:f}of r)this.binders[p].setUniform(f,c,a.get(p),u)}updatePaintBuffers(e){this._buffers=[];for(const r in this.binders){const a=this.binders[r];if(e&&a instanceof mt){const c=e.fromScale===2?a.zoomInPaintVertexBuffer:a.zoomOutPaintVertexBuffer;c&&this._buffers.push(c)}else(a instanceof Ke||a instanceof Le)&&a.paintVertexBuffer&&this._buffers.push(a.paintVertexBuffer)}}upload(e){for(const r in this.binders){const a=this.binders[r];(a instanceof Ke||a instanceof Le||a instanceof mt)&&a.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const r=this.binders[e];(r instanceof Ke||r instanceof Le||r instanceof mt)&&r.destroy()}}}class tt{constructor(e,r,a=()=>!0){this.programConfigurations={};for(const c of e)this.programConfigurations[c.id]=new ft(c,r,a);this.needsUpload=!1,this._featureMap=new H,this._bufferOffset=0}populatePaintArrays(e,r,a,c,u,p){for(const f in this.programConfigurations)this.programConfigurations[f].populatePaintArrays(e,r,c,u,p);r.id!==void 0&&this._featureMap.add(r.id,a,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,r,a,c){for(const u of a)this.needsUpload=this.programConfigurations[u.id].updatePaintArrays(e,this._featureMap,r,u,c)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function ht(i,e){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[i]||[i.replace(`${e}-`,"").replace(/-/g,"_")]}function wt(i,e,r){const a={color:{source:ra,composite:ro},number:{source:Za,composite:ra}},c=function(u){return{"line-pattern":{source:Dr,composite:Dr},"fill-pattern":{source:Dr,composite:Dr},"fill-extrusion-pattern":{source:Dr,composite:Dr}}[u]}(i);return c&&c[r]||a[e][r]}ke("ConstantBinder",ze),ke("CrossFadedConstantBinder",We),ke("SourceExpressionBinder",Ke),ke("CrossFadedCompositeBinder",mt),ke("CompositeExpressionBinder",Le),ke("ProgramConfiguration",ft,{omit:["_buffers"]}),ke("ProgramConfigurationSet",tt);var gt=8192;const ji=Math.pow(2,14)-1,qi=-ji-1;function ni(i){const e=gt/i.extent,r=i.loadGeometry();for(let a=0;a<r.length;a++){const c=r[a];for(let u=0;u<c.length;u++){const p=c[u],f=Math.round(p.x*e),_=Math.round(p.y*e);p.x=pe(f,qi,ji),p.y=pe(_,qi,ji),(f<p.x||f>p.x+1||_<p.y||_>p.y+1)&&dt("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function ki(i,e){return{type:i.type,id:i.id,properties:i.properties,geometry:e?ni(i):[]}}function _i(i,e,r,a,c){i.emplaceBack(2*e+(a+1)/2,2*r+(c+1)/2)}class Ji{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new aa,this.indexArray=new d,this.segments=new x,this.programConfigurations=new tt(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,a){const c=this.layers[0],u=[];let p=null,f=!1;c.type==="circle"&&(p=c.layout.get("circle-sort-key"),f=!p.isConstant());for(const{feature:_,id:v,index:w,sourceLayerIndex:E}of e){const P=this.layers[0]._featureFilter.needGeometry,k=ki(_,P);if(!this.layers[0]._featureFilter.filter(new Pt(this.zoom),k,a))continue;const L=f?p.evaluate(k,{},a):void 0,$={id:v,properties:_.properties,type:_.type,sourceLayerIndex:E,index:w,geometry:P?k.geometry:ni(_),patterns:{},sortKey:L};u.push($)}f&&u.sort((_,v)=>_.sortKey-v.sortKey);for(const _ of u){const{geometry:v,index:w,sourceLayerIndex:E}=_,P=e[w].feature;this.addFeature(_,v,w,a),r.featureIndex.insert(P,v,w,E,this.index)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,y),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,r,a,c){for(const u of r)for(const p of u){const f=p.x,_=p.y;if(f<0||f>=gt||_<0||_>=gt)continue;const v=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),w=v.vertexLength;_i(this.layoutVertexArray,f,_,-1,-1),_i(this.layoutVertexArray,f,_,1,-1),_i(this.layoutVertexArray,f,_,1,1),_i(this.layoutVertexArray,f,_,-1,1),this.indexArray.emplaceBack(w,w+1,w+2),this.indexArray.emplaceBack(w,w+3,w+2),v.vertexLength+=4,v.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,{},c)}}function Rr(i,e){for(let r=0;r<i.length;r++)if(Qi(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(Qi(i,e[r]))return!0;return!!_t(i,e)}function Ka(i,e,r){return!!Qi(i,e)||!!xi(e,i,r)}function qt(i,e){if(i.length===1)return cr(e,i[0]);for(let r=0;r<e.length;r++){const a=e[r];for(let c=0;c<a.length;c++)if(Qi(i,a[c]))return!0}for(let r=0;r<i.length;r++)if(cr(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(_t(i,e[r]))return!0;return!1}function Dt(i,e,r){if(i.length>1){if(_t(i,e))return!0;for(let a=0;a<e.length;a++)if(xi(e[a],i,r))return!0}for(let a=0;a<i.length;a++)if(xi(i[a],e,r))return!0;return!1}function _t(i,e){if(i.length===0||e.length===0)return!1;for(let r=0;r<i.length-1;r++){const a=i[r],c=i[r+1];for(let u=0;u<e.length-1;u++)if(yi(a,c,e[u],e[u+1]))return!0}return!1}function yi(i,e,r,a){return Qt(i,r,a)!==Qt(e,r,a)&&Qt(i,e,r)!==Qt(i,e,a)}function xi(i,e,r){const a=r*r;if(e.length===1)return i.distSqr(e[0])<a;for(let c=1;c<e.length;c++)if(Rt(i,e[c-1],e[c])<a)return!0;return!1}function Rt(i,e,r){const a=e.distSqr(r);if(a===0)return i.distSqr(e);const c=((i.x-e.x)*(r.x-e.x)+(i.y-e.y)*(r.y-e.y))/a;return i.distSqr(c<0?e:c>1?r:r.sub(e)._mult(c)._add(e))}function cr(i,e){let r,a,c,u=!1;for(let p=0;p<i.length;p++){r=i[p];for(let f=0,_=r.length-1;f<r.length;_=f++)a=r[f],c=r[_],a.y>e.y!=c.y>e.y&&e.x<(c.x-a.x)*(e.y-a.y)/(c.y-a.y)+a.x&&(u=!u)}return u}function Qi(i,e){let r=!1;for(let a=0,c=i.length-1;a<i.length;c=a++){const u=i[a],p=i[c];u.y>e.y!=p.y>e.y&&e.x<(p.x-u.x)*(e.y-u.y)/(p.y-u.y)+u.x&&(r=!r)}return r}function oo(i,e,r){const a=r[0],c=r[2];if(i.x<a.x&&e.x<a.x||i.x>c.x&&e.x>c.x||i.y<a.y&&e.y<a.y||i.y>c.y&&e.y>c.y)return!1;const u=Qt(i,e,r[0]);return u!==Qt(i,e,r[1])||u!==Qt(i,e,r[2])||u!==Qt(i,e,r[3])}function nn(i,e,r){const a=e.paint.get(i).value;return a.kind==="constant"?a.value:r.programConfigurations.get(e.id).getMaxValue(i)}function Ya(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function Ja(i,e,r,a,c){if(!e[0]&&!e[1])return i;const u=He.convert(e)._mult(c);r==="viewport"&&u._rotate(-a);const p=[];for(let f=0;f<i.length;f++)p.push(i[f].sub(u));return p}ke("CircleBucket",Ji,{omit:["layers"]});const sa=new Ii({"circle-sort-key":new Ze(le.layout_circle["circle-sort-key"])});var mc={paint:new Ii({"circle-radius":new Ze(le.paint_circle["circle-radius"]),"circle-color":new Ze(le.paint_circle["circle-color"]),"circle-blur":new Ze(le.paint_circle["circle-blur"]),"circle-opacity":new Ze(le.paint_circle["circle-opacity"]),"circle-translate":new Oe(le.paint_circle["circle-translate"]),"circle-translate-anchor":new Oe(le.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Oe(le.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Oe(le.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Ze(le.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Ze(le.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Ze(le.paint_circle["circle-stroke-opacity"])}),layout:sa},Ht=1e-6,Br=typeof Float32Array<"u"?Float32Array:Array;function fc(i){return i[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=1,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i}function Qh(i,e,r){var a=e[0],c=e[1],u=e[2],p=e[3],f=e[4],_=e[5],v=e[6],w=e[7],E=e[8],P=e[9],k=e[10],L=e[11],$=e[12],N=e[13],J=e[14],ne=e[15],K=r[0],re=r[1],ge=r[2],fe=r[3];return i[0]=K*a+re*f+ge*E+fe*$,i[1]=K*c+re*_+ge*P+fe*N,i[2]=K*u+re*v+ge*k+fe*J,i[3]=K*p+re*w+ge*L+fe*ne,i[4]=(K=r[4])*a+(re=r[5])*f+(ge=r[6])*E+(fe=r[7])*$,i[5]=K*c+re*_+ge*P+fe*N,i[6]=K*u+re*v+ge*k+fe*J,i[7]=K*p+re*w+ge*L+fe*ne,i[8]=(K=r[8])*a+(re=r[9])*f+(ge=r[10])*E+(fe=r[11])*$,i[9]=K*c+re*_+ge*P+fe*N,i[10]=K*u+re*v+ge*k+fe*J,i[11]=K*p+re*w+ge*L+fe*ne,i[12]=(K=r[12])*a+(re=r[13])*f+(ge=r[14])*E+(fe=r[15])*$,i[13]=K*c+re*_+ge*P+fe*N,i[14]=K*u+re*v+ge*k+fe*J,i[15]=K*p+re*w+ge*L+fe*ne,i}Math.hypot||(Math.hypot=function(){for(var i=0,e=arguments.length;e--;)i+=arguments[e]*arguments[e];return Math.sqrt(i)});var lo,mm=Qh;function _l(i,e,r){var a=e[0],c=e[1],u=e[2],p=e[3];return i[0]=r[0]*a+r[4]*c+r[8]*u+r[12]*p,i[1]=r[1]*a+r[5]*c+r[9]*u+r[13]*p,i[2]=r[2]*a+r[6]*c+r[10]*u+r[14]*p,i[3]=r[3]*a+r[7]*c+r[11]*u+r[15]*p,i}function eu(i,e){const r=_l([],[i.x,i.y,0,1],e);return new He(r[0]/r[3],r[1]/r[3])}lo=new Br(4),Br!=Float32Array&&(lo[0]=0,lo[1]=0,lo[2]=0,lo[3]=0);class tu extends Ji{}ke("HeatmapBucket",tu,{omit:["layers"]});var fm={paint:new Ii({"heatmap-radius":new Ze(le.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Ze(le.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Oe(le.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Zs(le.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Oe(le.paint_heatmap["heatmap-opacity"])})};function gc(i,{width:e,height:r},a,c){if(c){if(c instanceof Uint8ClampedArray)c=new Uint8Array(c.buffer);else if(c.length!==e*r*a)throw new RangeError(`mismatched image size. expected: ${c.length} but got: ${e*r*a}`)}else c=new Uint8Array(e*r*a);return i.width=e,i.height=r,i.data=c,i}function iu(i,{width:e,height:r},a){if(e===i.width&&r===i.height)return;const c=gc({},{width:e,height:r},a);_c(i,c,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,e),height:Math.min(i.height,r)},a),i.width=e,i.height=r,i.data=c.data}function _c(i,e,r,a,c,u){if(c.width===0||c.height===0)return e;if(c.width>i.width||c.height>i.height||r.x>i.width-c.width||r.y>i.height-c.height)throw new RangeError("out of range source coordinates for image copy");if(c.width>e.width||c.height>e.height||a.x>e.width-c.width||a.y>e.height-c.height)throw new RangeError("out of range destination coordinates for image copy");const p=i.data,f=e.data;if(p===f)throw new Error("srcData equals dstData, so image is already copied");for(let _=0;_<c.height;_++){const v=((r.y+_)*i.width+r.x)*u,w=((a.y+_)*e.width+a.x)*u;for(let E=0;E<c.width*u;E++)f[w+E]=p[v+E]}return e}class co{constructor(e,r){gc(this,e,1,r)}resize(e){iu(this,e,1)}clone(){return new co({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,a,c,u){_c(e,r,a,c,u,1)}}class er{constructor(e,r){gc(this,e,4,r)}resize(e){iu(this,e,4)}replace(e,r){r?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new er({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,a,c,u){_c(e,r,a,c,u,4)}}function ru(i){const e={},r=i.resolution||256,a=i.clips?i.clips.length:1,c=i.image||new er({width:r,height:a});if(Math.log(r)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${r}`);const u=(p,f,_)=>{e[i.evaluationKey]=_;const v=i.expression.evaluate(e);c.data[p+f+0]=Math.floor(255*v.r/v.a),c.data[p+f+1]=Math.floor(255*v.g/v.a),c.data[p+f+2]=Math.floor(255*v.b/v.a),c.data[p+f+3]=Math.floor(255*v.a)};if(i.clips)for(let p=0,f=0;p<a;++p,f+=4*r)for(let _=0,v=0;_<r;_++,v+=4){const w=_/(r-1),{start:E,end:P}=i.clips[p];u(f,v,E*(1-w)+P*w)}else for(let p=0,f=0;p<r;p++,f+=4)u(0,f,p/(r-1));return c}ke("AlphaImage",co),ke("RGBAImage",er);var gm={paint:new Ii({"hillshade-illumination-direction":new Oe(le.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new Oe(le.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Oe(le.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Oe(le.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Oe(le.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Oe(le.paint_hillshade["hillshade-accent-color"])})};const _m=jt([{name:"a_pos",components:2,type:"Int16"}],4),{members:ym}=_m;var ho={};function yl(i,e,r){r=r||2;var a,c,u,p,f,_,v,w=e&&e.length,E=w?e[0]*r:i.length,P=nu(i,0,E,r,!0),k=[];if(!P||P.next===P.prev)return k;if(w&&(P=function($,N,J,ne){var K,re,ge,fe=[];for(K=0,re=N.length;K<re;K++)(ge=nu($,N[K]*ne,K<re-1?N[K+1]*ne:$.length,ne,!1))===ge.next&&(ge.steiner=!0),fe.push(Im(ge));for(fe.sort(Tm),K=0;K<fe.length;K++)J=Sm(fe[K],J);return J}(i,e,P,r)),i.length>80*r){a=u=i[0],c=p=i[1];for(var L=r;L<E;L+=r)(f=i[L])<a&&(a=f),(_=i[L+1])<c&&(c=_),f>u&&(u=f),_>p&&(p=_);v=(v=Math.max(u-a,p-c))!==0?32767/v:0}return uo(P,k,r,a,c,v,0),k}function nu(i,e,r,a,c){var u,p;if(c===vc(i,e,r,a)>0)for(u=e;u<r;u+=a)p=ou(u,i[u],i[u+1],p);else for(u=r-a;u>=e;u-=a)p=ou(u,i[u],i[u+1],p);return p&&xl(p,p.next)&&(mo(p),p=p.next),p}function oa(i,e){if(!i)return i;e||(e=i);var r,a=i;do if(r=!1,a.steiner||!xl(a,a.next)&&Gt(a.prev,a,a.next)!==0)a=a.next;else{if(mo(a),(a=e=a.prev)===a.next)break;r=!0}while(r||a!==e);return e}function uo(i,e,r,a,c,u,p){if(i){!p&&u&&function(w,E,P,k){var L=w;do L.z===0&&(L.z=yc(L.x,L.y,E,P,k)),L.prevZ=L.prev,L.nextZ=L.next,L=L.next;while(L!==w);L.prevZ.nextZ=null,L.prevZ=null,function($){var N,J,ne,K,re,ge,fe,De,Fe=1;do{for(J=$,$=null,re=null,ge=0;J;){for(ge++,ne=J,fe=0,N=0;N<Fe&&(fe++,ne=ne.nextZ);N++);for(De=Fe;fe>0||De>0&&ne;)fe!==0&&(De===0||!ne||J.z<=ne.z)?(K=J,J=J.nextZ,fe--):(K=ne,ne=ne.nextZ,De--),re?re.nextZ=K:$=K,K.prevZ=re,re=K;J=ne}re.nextZ=null,Fe*=2}while(ge>1)}(L)}(i,a,c,u);for(var f,_,v=i;i.prev!==i.next;)if(f=i.prev,_=i.next,u?vm(i,a,c,u):xm(i))e.push(f.i/r|0),e.push(i.i/r|0),e.push(_.i/r|0),mo(i),i=_.next,v=_.next;else if((i=_)===v){p?p===1?uo(i=bm(oa(i),e,r),e,r,a,c,u,2):p===2&&wm(i,e,r,a,c,u):uo(oa(i),e,r,a,c,u,1);break}}}function xm(i){var e=i.prev,r=i,a=i.next;if(Gt(e,r,a)>=0)return!1;for(var c=e.x,u=r.x,p=a.x,f=e.y,_=r.y,v=a.y,w=c<u?c<p?c:p:u<p?u:p,E=f<_?f<v?f:v:_<v?_:v,P=c>u?c>p?c:p:u>p?u:p,k=f>_?f>v?f:v:_>v?_:v,L=a.next;L!==e;){if(L.x>=w&&L.x<=P&&L.y>=E&&L.y<=k&&Qa(c,f,u,_,p,v,L.x,L.y)&&Gt(L.prev,L,L.next)>=0)return!1;L=L.next}return!0}function vm(i,e,r,a){var c=i.prev,u=i,p=i.next;if(Gt(c,u,p)>=0)return!1;for(var f=c.x,_=u.x,v=p.x,w=c.y,E=u.y,P=p.y,k=f<_?f<v?f:v:_<v?_:v,L=w<E?w<P?w:P:E<P?E:P,$=f>_?f>v?f:v:_>v?_:v,N=w>E?w>P?w:P:E>P?E:P,J=yc(k,L,e,r,a),ne=yc($,N,e,r,a),K=i.prevZ,re=i.nextZ;K&&K.z>=J&&re&&re.z<=ne;){if(K.x>=k&&K.x<=$&&K.y>=L&&K.y<=N&&K!==c&&K!==p&&Qa(f,w,_,E,v,P,K.x,K.y)&&Gt(K.prev,K,K.next)>=0||(K=K.prevZ,re.x>=k&&re.x<=$&&re.y>=L&&re.y<=N&&re!==c&&re!==p&&Qa(f,w,_,E,v,P,re.x,re.y)&&Gt(re.prev,re,re.next)>=0))return!1;re=re.nextZ}for(;K&&K.z>=J;){if(K.x>=k&&K.x<=$&&K.y>=L&&K.y<=N&&K!==c&&K!==p&&Qa(f,w,_,E,v,P,K.x,K.y)&&Gt(K.prev,K,K.next)>=0)return!1;K=K.prevZ}for(;re&&re.z<=ne;){if(re.x>=k&&re.x<=$&&re.y>=L&&re.y<=N&&re!==c&&re!==p&&Qa(f,w,_,E,v,P,re.x,re.y)&&Gt(re.prev,re,re.next)>=0)return!1;re=re.nextZ}return!0}function bm(i,e,r){var a=i;do{var c=a.prev,u=a.next.next;!xl(c,u)&&au(c,a,a.next,u)&&po(c,u)&&po(u,c)&&(e.push(c.i/r|0),e.push(a.i/r|0),e.push(u.i/r|0),mo(a),mo(a.next),a=i=u),a=a.next}while(a!==i);return oa(a)}function wm(i,e,r,a,c,u){var p=i;do{for(var f=p.next.next;f!==p.prev;){if(p.i!==f.i&&Am(p,f)){var _=su(p,f);return p=oa(p,p.next),_=oa(_,_.next),uo(p,e,r,a,c,u,0),void uo(_,e,r,a,c,u,0)}f=f.next}p=p.next}while(p!==i)}function Tm(i,e){return i.x-e.x}function Sm(i,e){var r=function(c,u){var p,f=u,_=c.x,v=c.y,w=-1/0;do{if(v<=f.y&&v>=f.next.y&&f.next.y!==f.y){var E=f.x+(v-f.y)*(f.next.x-f.x)/(f.next.y-f.y);if(E<=_&&E>w&&(w=E,p=f.x<f.next.x?f:f.next,E===_))return p}f=f.next}while(f!==u);if(!p)return null;var P,k=p,L=p.x,$=p.y,N=1/0;f=p;do _>=f.x&&f.x>=L&&_!==f.x&&Qa(v<$?_:w,v,L,$,v<$?w:_,v,f.x,f.y)&&(P=Math.abs(v-f.y)/(_-f.x),po(f,c)&&(P<N||P===N&&(f.x>p.x||f.x===p.x&&Em(p,f)))&&(p=f,N=P)),f=f.next;while(f!==k);return p}(i,e);if(!r)return e;var a=su(r,i);return oa(a,a.next),oa(r,r.next)}function Em(i,e){return Gt(i.prev,i,e.prev)<0&&Gt(e.next,i,i.next)<0}function yc(i,e,r,a,c){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-r)*c|0)|i<<8))|i<<4))|i<<2))|i<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-a)*c|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Im(i){var e=i,r=i;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==i);return r}function Qa(i,e,r,a,c,u,p,f){return(c-p)*(e-f)>=(i-p)*(u-f)&&(i-p)*(a-f)>=(r-p)*(e-f)&&(r-p)*(u-f)>=(c-p)*(a-f)}function Am(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!function(r,a){var c=r;do{if(c.i!==r.i&&c.next.i!==r.i&&c.i!==a.i&&c.next.i!==a.i&&au(c,c.next,r,a))return!0;c=c.next}while(c!==r);return!1}(i,e)&&(po(i,e)&&po(e,i)&&function(r,a){var c=r,u=!1,p=(r.x+a.x)/2,f=(r.y+a.y)/2;do c.y>f!=c.next.y>f&&c.next.y!==c.y&&p<(c.next.x-c.x)*(f-c.y)/(c.next.y-c.y)+c.x&&(u=!u),c=c.next;while(c!==r);return u}(i,e)&&(Gt(i.prev,i,e.prev)||Gt(i,e.prev,e))||xl(i,e)&&Gt(i.prev,i,i.next)>0&&Gt(e.prev,e,e.next)>0)}function Gt(i,e,r){return(e.y-i.y)*(r.x-e.x)-(e.x-i.x)*(r.y-e.y)}function xl(i,e){return i.x===e.x&&i.y===e.y}function au(i,e,r,a){var c=bl(Gt(i,e,r)),u=bl(Gt(i,e,a)),p=bl(Gt(r,a,i)),f=bl(Gt(r,a,e));return c!==u&&p!==f||!(c!==0||!vl(i,r,e))||!(u!==0||!vl(i,a,e))||!(p!==0||!vl(r,i,a))||!(f!==0||!vl(r,e,a))}function vl(i,e,r){return e.x<=Math.max(i.x,r.x)&&e.x>=Math.min(i.x,r.x)&&e.y<=Math.max(i.y,r.y)&&e.y>=Math.min(i.y,r.y)}function bl(i){return i>0?1:i<0?-1:0}function po(i,e){return Gt(i.prev,i,i.next)<0?Gt(i,e,i.next)>=0&&Gt(i,i.prev,e)>=0:Gt(i,e,i.prev)<0||Gt(i,i.next,e)<0}function su(i,e){var r=new xc(i.i,i.x,i.y),a=new xc(e.i,e.x,e.y),c=i.next,u=e.prev;return i.next=e,e.prev=i,r.next=c,c.prev=r,a.next=r,r.prev=a,u.next=a,a.prev=u,a}function ou(i,e,r,a){var c=new xc(i,e,r);return a?(c.next=a.next,c.prev=a,a.next.prev=c,a.next=c):(c.prev=c,c.next=c),c}function mo(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function xc(i,e,r){this.i=i,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function vc(i,e,r,a){for(var c=0,u=e,p=r-a;u<r;u+=a)c+=(i[p]-i[u])*(i[u+1]+i[p+1]),p=u;return c}function Cm(i,e,r,a,c){lu(i,e,r||0,a||i.length-1,c||Mm)}function lu(i,e,r,a,c){for(;a>r;){if(a-r>600){var u=a-r+1,p=e-r+1,f=Math.log(u),_=.5*Math.exp(2*f/3),v=.5*Math.sqrt(f*_*(u-_)/u)*(p-u/2<0?-1:1);lu(i,e,Math.max(r,Math.floor(e-p*_/u+v)),Math.min(a,Math.floor(e+(u-p)*_/u+v)),c)}var w=i[e],E=r,P=a;for(fo(i,r,e),c(i[a],w)>0&&fo(i,r,a);E<P;){for(fo(i,E,P),E++,P--;c(i[E],w)<0;)E++;for(;c(i[P],w)>0;)P--}c(i[r],w)===0?fo(i,r,P):fo(i,++P,a),P<=e&&(r=P+1),e<=P&&(a=P-1)}}function fo(i,e,r){var a=i[e];i[e]=i[r],i[r]=a}function Mm(i,e){return i<e?-1:i>e?1:0}function bc(i,e){const r=i.length;if(r<=1)return[i];const a=[];let c,u;for(let p=0;p<r;p++){const f=us(i[p]);f!==0&&(i[p].area=Math.abs(f),u===void 0&&(u=f<0),u===f<0?(c&&a.push(c),c=[i[p]]):c.push(i[p]))}if(c&&a.push(c),e>1)for(let p=0;p<a.length;p++)a[p].length<=e||(Cm(a[p],e,1,a[p].length-1,Pm),a[p]=a[p].slice(0,e));return a}function Pm(i,e){return e.area-i.area}function wc(i,e,r){const a=r.patternDependencies;let c=!1;for(const u of e){const p=u.paint.get(`${i}-pattern`);p.isConstant()||(c=!0);const f=p.constantOr(null);f&&(c=!0,a[f.to]=!0,a[f.from]=!0)}return c}function Tc(i,e,r,a,c){const u=c.patternDependencies;for(const p of e){const f=p.paint.get(`${i}-pattern`).value;if(f.kind!=="constant"){let _=f.evaluate({zoom:a-1},r,{},c.availableImages),v=f.evaluate({zoom:a},r,{},c.availableImages),w=f.evaluate({zoom:a+1},r,{},c.availableImages);_=_&&_.name?_.name:_,v=v&&v.name?v.name:v,w=w&&w.name?w.name:w,u[_]=!0,u[v]=!0,u[w]=!0,r.patterns[p.id]={min:_,mid:v,max:w}}}return r}({get exports(){return ho},set exports(i){ho=i}}).exports=yl,ho.default=yl,yl.deviation=function(i,e,r,a){var c=e&&e.length,u=Math.abs(vc(i,0,c?e[0]*r:i.length,r));if(c)for(var p=0,f=e.length;p<f;p++)u-=Math.abs(vc(i,e[p]*r,p<f-1?e[p+1]*r:i.length,r));var _=0;for(p=0;p<a.length;p+=3){var v=a[p]*r,w=a[p+1]*r,E=a[p+2]*r;_+=Math.abs((i[v]-i[E])*(i[w+1]-i[v+1])-(i[v]-i[w])*(i[E+1]-i[v+1]))}return u===0&&_===0?0:Math.abs((_-u)/u)},yl.flatten=function(i){for(var e=i[0][0].length,r={vertices:[],holes:[],dimensions:e},a=0,c=0;c<i.length;c++){for(var u=0;u<i[c].length;u++)for(var p=0;p<e;p++)r.vertices.push(i[c][u][p]);c>0&&r.holes.push(a+=i[c-1].length)}return r};class Sc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new uc,this.indexArray=new d,this.indexArray2=new m,this.programConfigurations=new tt(e.layers,e.zoom),this.segments=new x,this.segments2=new x,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,a){this.hasPattern=wc("fill",this.layers,r);const c=this.layers[0].layout.get("fill-sort-key"),u=!c.isConstant(),p=[];for(const{feature:f,id:_,index:v,sourceLayerIndex:w}of e){const E=this.layers[0]._featureFilter.needGeometry,P=ki(f,E);if(!this.layers[0]._featureFilter.filter(new Pt(this.zoom),P,a))continue;const k=u?c.evaluate(P,{},a,r.availableImages):void 0,L={id:_,properties:f.properties,type:f.type,sourceLayerIndex:w,index:v,geometry:E?P.geometry:ni(f),patterns:{},sortKey:k};p.push(L)}u&&p.sort((f,_)=>f.sortKey-_.sortKey);for(const f of p){const{geometry:_,index:v,sourceLayerIndex:w}=f;if(this.hasPattern){const E=Tc("fill",this.layers,f,this.zoom,r);this.patternFeatures.push(E)}else this.addFeature(f,_,v,a,{});r.featureIndex.insert(e[v].feature,_,v,w,this.index)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}addFeatures(e,r,a){for(const c of this.patternFeatures)this.addFeature(c,c.geometry,c.index,r,a)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ym),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,r,a,c,u){for(const p of bc(r,500)){let f=0;for(const k of p)f+=k.length;const _=this.segments.prepareSegment(f,this.layoutVertexArray,this.indexArray),v=_.vertexLength,w=[],E=[];for(const k of p){if(k.length===0)continue;k!==p[0]&&E.push(w.length/2);const L=this.segments2.prepareSegment(k.length,this.layoutVertexArray,this.indexArray2),$=L.vertexLength;this.layoutVertexArray.emplaceBack(k[0].x,k[0].y),this.indexArray2.emplaceBack($+k.length-1,$),w.push(k[0].x),w.push(k[0].y);for(let N=1;N<k.length;N++)this.layoutVertexArray.emplaceBack(k[N].x,k[N].y),this.indexArray2.emplaceBack($+N-1,$+N),w.push(k[N].x),w.push(k[N].y);L.vertexLength+=k.length,L.primitiveLength+=k.length}const P=ho(w,E);for(let k=0;k<P.length;k+=3)this.indexArray.emplaceBack(v+P[k],v+P[k+1],v+P[k+2]);_.vertexLength+=f,_.primitiveLength+=P.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,u,c)}}ke("FillBucket",Sc,{omit:["layers","patternFeatures"]});const km=new Ii({"fill-sort-key":new Ze(le.layout_fill["fill-sort-key"])});var zm={paint:new Ii({"fill-antialias":new Oe(le.paint_fill["fill-antialias"]),"fill-opacity":new Ze(le.paint_fill["fill-opacity"]),"fill-color":new Ze(le.paint_fill["fill-color"]),"fill-outline-color":new Ze(le.paint_fill["fill-outline-color"]),"fill-translate":new Oe(le.paint_fill["fill-translate"]),"fill-translate-anchor":new Oe(le.paint_fill["fill-translate-anchor"]),"fill-pattern":new Ln(le.paint_fill["fill-pattern"])}),layout:km};const Lm=jt([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Dm=jt([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Rm}=Lm;var Bn={},Bm=He,cu=es;function es(i,e,r,a,c){this.properties={},this.extent=r,this.type=0,this._pbf=i,this._geometry=-1,this._keys=a,this._values=c,i.readFields(Fm,this,e)}function Fm(i,e,r){i==1?e.id=r.readVarint():i==2?function(a,c){for(var u=a.readVarint()+a.pos;a.pos<u;){var p=c._keys[a.readVarint()],f=c._values[a.readVarint()];c.properties[p]=f}}(r,e):i==3?e.type=r.readVarint():i==4&&(e._geometry=r.pos)}function Om(i){for(var e,r,a=0,c=0,u=i.length,p=u-1;c<u;p=c++)a+=((r=i[p]).x-(e=i[c]).x)*(e.y+r.y);return a}es.types=["Unknown","Point","LineString","Polygon"],es.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var e,r=i.readVarint()+i.pos,a=1,c=0,u=0,p=0,f=[];i.pos<r;){if(c<=0){var _=i.readVarint();a=7&_,c=_>>3}if(c--,a===1||a===2)u+=i.readSVarint(),p+=i.readSVarint(),a===1&&(e&&f.push(e),e=[]),e.push(new Bm(u,p));else{if(a!==7)throw new Error("unknown command "+a);e&&e.push(e[0].clone())}}return e&&f.push(e),f},es.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var e=i.readVarint()+i.pos,r=1,a=0,c=0,u=0,p=1/0,f=-1/0,_=1/0,v=-1/0;i.pos<e;){if(a<=0){var w=i.readVarint();r=7&w,a=w>>3}if(a--,r===1||r===2)(c+=i.readSVarint())<p&&(p=c),c>f&&(f=c),(u+=i.readSVarint())<_&&(_=u),u>v&&(v=u);else if(r!==7)throw new Error("unknown command "+r)}return[p,_,f,v]},es.prototype.toGeoJSON=function(i,e,r){var a,c,u=this.extent*Math.pow(2,r),p=this.extent*i,f=this.extent*e,_=this.loadGeometry(),v=es.types[this.type];function w(k){for(var L=0;L<k.length;L++){var $=k[L];k[L]=[360*($.x+p)/u-180,360/Math.PI*Math.atan(Math.exp((180-360*($.y+f)/u)*Math.PI/180))-90]}}switch(this.type){case 1:var E=[];for(a=0;a<_.length;a++)E[a]=_[a][0];w(_=E);break;case 2:for(a=0;a<_.length;a++)w(_[a]);break;case 3:for(_=function(k){var L=k.length;if(L<=1)return[k];for(var $,N,J=[],ne=0;ne<L;ne++){var K=Om(k[ne]);K!==0&&(N===void 0&&(N=K<0),N===K<0?($&&J.push($),$=[k[ne]]):$.push(k[ne]))}return $&&J.push($),J}(_),a=0;a<_.length;a++)for(c=0;c<_[a].length;c++)w(_[a][c])}_.length===1?_=_[0]:v="Multi"+v;var P={type:"Feature",geometry:{type:v,coordinates:_},properties:this.properties};return"id"in this&&(P.id=this.id),P};var Um=cu,hu=uu;function uu(i,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=i,this._keys=[],this._values=[],this._features=[],i.readFields(Vm,this,e),this.length=this._features.length}function Vm(i,e,r){i===15?e.version=r.readVarint():i===1?e.name=r.readString():i===5?e.extent=r.readVarint():i===2?e._features.push(r.pos):i===3?e._keys.push(r.readString()):i===4&&e._values.push(function(a){for(var c=null,u=a.readVarint()+a.pos;a.pos<u;){var p=a.readVarint()>>3;c=p===1?a.readString():p===2?a.readFloat():p===3?a.readDouble():p===4?a.readVarint64():p===5?a.readVarint():p===6?a.readSVarint():p===7?a.readBoolean():null}return c}(r))}uu.prototype.feature=function(i){if(i<0||i>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[i];var e=this._pbf.readVarint()+this._pbf.pos;return new Um(this._pbf,e,this.extent,this._keys,this._values)};var Nm=hu;function $m(i,e,r){if(i===3){var a=new Nm(r,r.readVarint()+r.pos);a.length&&(e[a.name]=a)}}Bn.VectorTile=function(i,e){this.layers=i.readFields($m,{},e)},Bn.VectorTileFeature=cu,Bn.VectorTileLayer=hu;const Gm=Bn.VectorTileFeature.types,Ec=Math.pow(2,13);function go(i,e,r,a,c,u,p,f){i.emplaceBack(e,r,2*Math.floor(a*Ec)+p,c*Ec*2,u*Ec*2,Math.round(f))}class Ic{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new dc,this.centroidVertexArray=new so,this.indexArray=new d,this.programConfigurations=new tt(e.layers,e.zoom),this.segments=new x,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,a){this.features=[],this.hasPattern=wc("fill-extrusion",this.layers,r);for(const{feature:c,id:u,index:p,sourceLayerIndex:f}of e){const _=this.layers[0]._featureFilter.needGeometry,v=ki(c,_);if(!this.layers[0]._featureFilter.filter(new Pt(this.zoom),v,a))continue;const w={id:u,sourceLayerIndex:f,index:p,geometry:_?v.geometry:ni(c),properties:c.properties,type:c.type,patterns:{}};this.hasPattern?this.features.push(Tc("fill-extrusion",this.layers,w,this.zoom,r)):this.addFeature(w,w.geometry,p,a,{}),r.featureIndex.insert(c,w.geometry,p,f,this.index,!0)}}addFeatures(e,r,a){for(const c of this.features){const{geometry:u}=c;this.addFeature(c,u,c.index,r,a)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Rm),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Dm.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,r,a,c,u){const p={x:0,y:0,vertexCount:0};for(const f of bc(r,500)){let _=0;for(const L of f)_+=L.length;let v=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const L of f){if(L.length===0||qm(L))continue;let $=0;for(let N=0;N<L.length;N++){const J=L[N];if(N>=1){const ne=L[N-1];if(!jm(J,ne)){v.vertexLength+4>x.MAX_VERTEX_ARRAY_LENGTH&&(v=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const K=J.sub(ne)._perp()._unit(),re=ne.dist(J);$+re>32768&&($=0),go(this.layoutVertexArray,J.x,J.y,K.x,K.y,0,0,$),go(this.layoutVertexArray,J.x,J.y,K.x,K.y,0,1,$),p.x+=2*J.x,p.y+=2*J.y,p.vertexCount+=2,$+=re,go(this.layoutVertexArray,ne.x,ne.y,K.x,K.y,0,0,$),go(this.layoutVertexArray,ne.x,ne.y,K.x,K.y,0,1,$),p.x+=2*ne.x,p.y+=2*ne.y,p.vertexCount+=2;const ge=v.vertexLength;this.indexArray.emplaceBack(ge,ge+2,ge+1),this.indexArray.emplaceBack(ge+1,ge+2,ge+3),v.vertexLength+=4,v.primitiveLength+=2}}}}if(v.vertexLength+_>x.MAX_VERTEX_ARRAY_LENGTH&&(v=this.segments.prepareSegment(_,this.layoutVertexArray,this.indexArray)),Gm[e.type]!=="Polygon")continue;const w=[],E=[],P=v.vertexLength;for(const L of f)if(L.length!==0){L!==f[0]&&E.push(w.length/2);for(let $=0;$<L.length;$++){const N=L[$];go(this.layoutVertexArray,N.x,N.y,0,0,1,1,0),p.x+=N.x,p.y+=N.y,p.vertexCount+=1,w.push(N.x),w.push(N.y)}}const k=ho(w,E);for(let L=0;L<k.length;L+=3)this.indexArray.emplaceBack(P+k[L],P+k[L+2],P+k[L+1]);v.primitiveLength+=k.length/3,v.vertexLength+=_}for(let f=0;f<p.vertexCount;f++)this.centroidVertexArray.emplaceBack(Math.floor(p.x/p.vertexCount),Math.floor(p.y/p.vertexCount));this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,u,c)}}function jm(i,e){return i.x===e.x&&(i.x<0||i.x>gt)||i.y===e.y&&(i.y<0||i.y>gt)}function qm(i){return i.every(e=>e.x<0)||i.every(e=>e.x>gt)||i.every(e=>e.y<0)||i.every(e=>e.y>gt)}ke("FillExtrusionBucket",Ic,{omit:["layers","features"]});var Zm={paint:new Ii({"fill-extrusion-opacity":new Oe(le["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Ze(le["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Oe(le["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Oe(le["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Ln(le["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Ze(le["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Ze(le["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Oe(le["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function _o(i,e){return i.x*e.x+i.y*e.y}function du(i,e){if(i.length===1){let r=0;const a=e[r++];let c;for(;!c||a.equals(c);)if(c=e[r++],!c)return 1/0;for(;r<e.length;r++){const u=e[r],p=i[0],f=c.sub(a),_=u.sub(a),v=p.sub(a),w=_o(f,f),E=_o(f,_),P=_o(_,_),k=_o(v,f),L=_o(v,_),$=w*P-E*E,N=(P*k-E*L)/$,J=(w*L-E*k)/$,ne=a.z*(1-N-J)+c.z*N+u.z*J;if(isFinite(ne))return ne}return 1/0}{let r=1/0;for(const a of e)r=Math.min(r,a.z);return r}}const Xm=jt([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:Wm}=Xm,Hm=jt([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:Km}=Hm,Ym=Bn.VectorTileFeature.types,Jm=Math.cos(Math.PI/180*37.5),pu=Math.pow(2,14)/.5;class Ac{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(r=>{this.gradients[r.id]={}}),this.layoutVertexArray=new gl,this.layoutVertexArray2=new pc,this.indexArray=new d,this.programConfigurations=new tt(e.layers,e.zoom),this.segments=new x,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,a){this.hasPattern=wc("line",this.layers,r);const c=this.layers[0].layout.get("line-sort-key"),u=!c.isConstant(),p=[];for(const{feature:f,id:_,index:v,sourceLayerIndex:w}of e){const E=this.layers[0]._featureFilter.needGeometry,P=ki(f,E);if(!this.layers[0]._featureFilter.filter(new Pt(this.zoom),P,a))continue;const k=u?c.evaluate(P,{},a):void 0,L={id:_,properties:f.properties,type:f.type,sourceLayerIndex:w,index:v,geometry:E?P.geometry:ni(f),patterns:{},sortKey:k};p.push(L)}u&&p.sort((f,_)=>f.sortKey-_.sortKey);for(const f of p){const{geometry:_,index:v,sourceLayerIndex:w}=f;if(this.hasPattern){const E=Tc("line",this.layers,f,this.zoom,r);this.patternFeatures.push(E)}else this.addFeature(f,_,v,a,{});r.featureIndex.insert(e[v].feature,_,v,w,this.index)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}addFeatures(e,r,a){for(const c of this.patternFeatures)this.addFeature(c,c.geometry,c.index,r,a)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Km)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Wm),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,r,a,c,u){const p=this.layers[0].layout,f=p.get("line-join").evaluate(e,{}),_=p.get("line-cap"),v=p.get("line-miter-limit"),w=p.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const E of r)this.addLine(E,e,f,_,v,w);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,u,c)}addLine(e,r,a,c,u,p){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let J=0;J<e.length-1;J++)this.totalDistance+=e[J].dist(e[J+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const f=Ym[r.type]==="Polygon";let _=e.length;for(;_>=2&&e[_-1].equals(e[_-2]);)_--;let v=0;for(;v<_-1&&e[v].equals(e[v+1]);)v++;if(_<(f?3:2))return;a==="bevel"&&(u=1.05);const w=this.overscaling<=16?122880/(512*this.overscaling):0,E=this.segments.prepareSegment(10*_,this.layoutVertexArray,this.indexArray);let P,k,L,$,N;this.e1=this.e2=-1,f&&(P=e[_-2],N=e[v].sub(P)._unit()._perp());for(let J=v;J<_;J++){if(L=J===_-1?f?e[v+1]:void 0:e[J+1],L&&e[J].equals(L))continue;N&&($=N),P&&(k=P),P=e[J],N=L?L.sub(P)._unit()._perp():$,$=$||N;let ne=$.add(N);ne.x===0&&ne.y===0||ne._unit();const K=$.x*N.x+$.y*N.y,re=ne.x*N.x+ne.y*N.y,ge=re!==0?1/re:1/0,fe=2*Math.sqrt(2-2*re),De=re<Jm&&k&&L,Fe=$.x*N.y-$.y*N.x>0;if(De&&J>v){const Te=P.dist(k);if(Te>2*w){const Pe=P.sub(P.sub(k)._mult(w/Te)._round());this.updateDistance(k,Pe),this.addCurrentVertex(Pe,$,0,0,E),k=Pe}}const Me=k&&L;let Ie=Me?a:f?"butt":c;if(Me&&Ie==="round"&&(ge<p?Ie="miter":ge<=2&&(Ie="fakeround")),Ie==="miter"&&ge>u&&(Ie="bevel"),Ie==="bevel"&&(ge>2&&(Ie="flipbevel"),ge<u&&(Ie="miter")),k&&this.updateDistance(k,P),Ie==="miter")ne._mult(ge),this.addCurrentVertex(P,ne,0,0,E);else if(Ie==="flipbevel"){if(ge>100)ne=N.mult(-1);else{const Te=ge*$.add(N).mag()/$.sub(N).mag();ne._perp()._mult(Te*(Fe?-1:1))}this.addCurrentVertex(P,ne,0,0,E),this.addCurrentVertex(P,ne.mult(-1),0,0,E)}else if(Ie==="bevel"||Ie==="fakeround"){const Te=-Math.sqrt(ge*ge-1),Pe=Fe?Te:0,Ce=Fe?0:Te;if(k&&this.addCurrentVertex(P,$,Pe,Ce,E),Ie==="fakeround"){const be=Math.round(180*fe/Math.PI/20);for(let $e=1;$e<be;$e++){let Ue=$e/be;if(Ue!==.5){const kt=Ue-.5;Ue+=Ue*kt*(Ue-1)*((1.0904+K*(K*(3.55645-1.43519*K)-3.2452))*kt*kt+(.848013+K*(.215638*K-1.06021)))}const it=N.sub($)._mult(Ue)._add($)._unit()._mult(Fe?-1:1);this.addHalfVertex(P,it.x,it.y,!1,Fe,0,E)}}L&&this.addCurrentVertex(P,N,-Pe,-Ce,E)}else if(Ie==="butt")this.addCurrentVertex(P,ne,0,0,E);else if(Ie==="square"){const Te=k?1:-1;this.addCurrentVertex(P,ne,Te,Te,E)}else Ie==="round"&&(k&&(this.addCurrentVertex(P,$,0,0,E),this.addCurrentVertex(P,$,1,1,E,!0)),L&&(this.addCurrentVertex(P,N,-1,-1,E,!0),this.addCurrentVertex(P,N,0,0,E)));if(De&&J<_-1){const Te=P.dist(L);if(Te>2*w){const Pe=P.add(L.sub(P)._mult(w/Te)._round());this.updateDistance(P,Pe),this.addCurrentVertex(Pe,N,0,0,E),P=Pe}}}}addCurrentVertex(e,r,a,c,u,p=!1){const f=r.y*c-r.x,_=-r.y-r.x*c;this.addHalfVertex(e,r.x+r.y*a,r.y-r.x*a,p,!1,a,u),this.addHalfVertex(e,f,_,p,!0,-c,u),this.distance>pu/2&&this.totalDistance===0&&(this.distance=0,this.addCurrentVertex(e,r,a,c,u,p))}addHalfVertex({x:e,y:r},a,c,u,p,f,_){const v=.5*(this.lineClips?this.scaledDistance*(pu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(u?1:0),(r<<1)+(p?1:0),Math.round(63*a)+128,Math.round(63*c)+128,1+(f===0?0:f<0?-1:1)|(63&v)<<2,v>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const w=_.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,w),_.primitiveLength++),p?this.e2=w:this.e1=w}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,r){this.distance+=e.dist(r),this.updateScaledDistance()}}ke("LineBucket",Ac,{omit:["layers","patternFeatures"]});const Qm=new Ii({"line-cap":new Oe(le.layout_line["line-cap"]),"line-join":new Ze(le.layout_line["line-join"]),"line-miter-limit":new Oe(le.layout_line["line-miter-limit"]),"line-round-limit":new Oe(le.layout_line["line-round-limit"]),"line-sort-key":new Ze(le.layout_line["line-sort-key"])});var mu={paint:new Ii({"line-opacity":new Ze(le.paint_line["line-opacity"]),"line-color":new Ze(le.paint_line["line-color"]),"line-translate":new Oe(le.paint_line["line-translate"]),"line-translate-anchor":new Oe(le.paint_line["line-translate-anchor"]),"line-width":new Ze(le.paint_line["line-width"]),"line-gap-width":new Ze(le.paint_line["line-gap-width"]),"line-offset":new Ze(le.paint_line["line-offset"]),"line-blur":new Ze(le.paint_line["line-blur"]),"line-dasharray":new qs(le.paint_line["line-dasharray"]),"line-pattern":new Ln(le.paint_line["line-pattern"]),"line-gradient":new Zs(le.paint_line["line-gradient"])}),layout:Qm};const fu=new class extends Ze{possiblyEvaluate(i,e){return e=new Pt(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(i,e)}evaluate(i,e,r,a){return e=Be({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(i,e,r,a)}}(mu.paint.properties["line-width"].specification);function gu(i,e){return e>0?e+2*i:i}fu.useIntegerZoom=!0;const ef=jt([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),tf=jt([{name:"a_projected_pos",components:3,type:"Float32"}],4);jt([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const rf=jt([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);jt([{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 _u=jt([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),nf=jt([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function af(i,e,r){return i.sections.forEach(a=>{a.text=function(c,u,p){const f=u.layout.get("text-transform").evaluate(p,{});return f==="uppercase"?c=c.toLocaleUpperCase():f==="lowercase"&&(c=c.toLocaleLowerCase()),Ei.applyArabicShaping&&(c=Ei.applyArabicShaping(c)),c}(a.text,e,r)}),i}jt([{name:"triangle",components:3,type:"Uint16"}]),jt([{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"}]),jt([{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",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),jt([{type:"Float32",name:"offsetX"}]),jt([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);const yo={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"};var ii=24,Cc=Tt,yu=function(i,e,r,a,c){var u,p,f=8*c-a-1,_=(1<<f)-1,v=_>>1,w=-7,E=r?c-1:0,P=r?-1:1,k=i[e+E];for(E+=P,u=k&(1<<-w)-1,k>>=-w,w+=f;w>0;u=256*u+i[e+E],E+=P,w-=8);for(p=u&(1<<-w)-1,u>>=-w,w+=a;w>0;p=256*p+i[e+E],E+=P,w-=8);if(u===0)u=1-v;else{if(u===_)return p?NaN:1/0*(k?-1:1);p+=Math.pow(2,a),u-=v}return(k?-1:1)*p*Math.pow(2,u-a)},xu=function(i,e,r,a,c,u){var p,f,_,v=8*u-c-1,w=(1<<v)-1,E=w>>1,P=c===23?Math.pow(2,-24)-Math.pow(2,-77):0,k=a?0:u-1,L=a?1:-1,$=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(f=isNaN(e)?1:0,p=w):(p=Math.floor(Math.log(e)/Math.LN2),e*(_=Math.pow(2,-p))<1&&(p--,_*=2),(e+=p+E>=1?P/_:P*Math.pow(2,1-E))*_>=2&&(p++,_/=2),p+E>=w?(f=0,p=w):p+E>=1?(f=(e*_-1)*Math.pow(2,c),p+=E):(f=e*Math.pow(2,E-1)*Math.pow(2,c),p=0));c>=8;i[r+k]=255&f,k+=L,f/=256,c-=8);for(p=p<<c|f,v+=c;v>0;i[r+k]=255&p,k+=L,p/=256,v-=8);i[r+k-L]|=128*$};function Tt(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}Tt.Varint=0,Tt.Fixed64=1,Tt.Bytes=2,Tt.Fixed32=5;var Fn,Mc=4294967296,vu=1/Mc,bu=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function an(i){return i.type===Tt.Bytes?i.readVarint()+i.pos:i.pos+1}function ts(i,e,r){return r?4294967296*e+(i>>>0):4294967296*(e>>>0)+(i>>>0)}function wu(i,e,r){var a=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(a);for(var c=r.pos-1;c>=i;c--)r.buf[c+a]=r.buf[c]}function sf(i,e){for(var r=0;r<i.length;r++)e.writeVarint(i[r])}function of(i,e){for(var r=0;r<i.length;r++)e.writeSVarint(i[r])}function lf(i,e){for(var r=0;r<i.length;r++)e.writeFloat(i[r])}function cf(i,e){for(var r=0;r<i.length;r++)e.writeDouble(i[r])}function hf(i,e){for(var r=0;r<i.length;r++)e.writeBoolean(i[r])}function uf(i,e){for(var r=0;r<i.length;r++)e.writeFixed32(i[r])}function df(i,e){for(var r=0;r<i.length;r++)e.writeSFixed32(i[r])}function pf(i,e){for(var r=0;r<i.length;r++)e.writeFixed64(i[r])}function mf(i,e){for(var r=0;r<i.length;r++)e.writeSFixed64(i[r])}function wl(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16)+16777216*i[e+3]}function is(i,e,r){i[r]=e,i[r+1]=e>>>8,i[r+2]=e>>>16,i[r+3]=e>>>24}function Tu(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16)+(i[e+3]<<24)}function ff(i,e,r){i===1&&r.readMessage(gf,e)}function gf(i,e,r){if(i===3){const{id:a,bitmap:c,width:u,height:p,left:f,top:_,advance:v}=r.readMessage(_f,{});e.push({id:a,bitmap:new co({width:u+6,height:p+6},c),metrics:{width:u,height:p,left:f,top:_,advance:v}})}}function _f(i,e,r){i===1?e.id=r.readVarint():i===2?e.bitmap=r.readBytes():i===3?e.width=r.readVarint():i===4?e.height=r.readVarint():i===5?e.left=r.readSVarint():i===6?e.top=r.readSVarint():i===7&&(e.advance=r.readVarint())}function Su(i){let e=0,r=0;for(const p of i)e+=p.w*p.h,r=Math.max(r,p.w);i.sort((p,f)=>f.h-p.h);const a=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let c=0,u=0;for(const p of i)for(let f=a.length-1;f>=0;f--){const _=a[f];if(!(p.w>_.w||p.h>_.h)){if(p.x=_.x,p.y=_.y,u=Math.max(u,p.y+p.h),c=Math.max(c,p.x+p.w),p.w===_.w&&p.h===_.h){const v=a.pop();f<a.length&&(a[f]=v)}else p.h===_.h?(_.x+=p.w,_.w-=p.w):p.w===_.w?(_.y+=p.h,_.h-=p.h):(a.push({x:_.x+p.w,y:_.y,w:_.w-p.w,h:p.h}),_.y+=p.h,_.h-=p.h);break}}return{w:c,h:u,fill:e/(c*u)||0}}Tt.prototype={destroy:function(){this.buf=null},readFields:function(i,e,r){for(r=r||this.length;this.pos<r;){var a=this.readVarint(),c=a>>3,u=this.pos;this.type=7&a,i(c,e,this),this.pos===u&&this.skip(a)}return e},readMessage:function(i,e){return this.readFields(i,e,this.readVarint()+this.pos)},readFixed32:function(){var i=wl(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=Tu(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=wl(this.buf,this.pos)+wl(this.buf,this.pos+4)*Mc;return this.pos+=8,i},readSFixed64:function(){var i=wl(this.buf,this.pos)+Tu(this.buf,this.pos+4)*Mc;return this.pos+=8,i},readFloat:function(){var i=yu(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=yu(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var e,r,a=this.buf;return e=127&(r=a[this.pos++]),r<128?e:(e|=(127&(r=a[this.pos++]))<<7,r<128?e:(e|=(127&(r=a[this.pos++]))<<14,r<128?e:(e|=(127&(r=a[this.pos++]))<<21,r<128?e:function(c,u,p){var f,_,v=p.buf;if(f=(112&(_=v[p.pos++]))>>4,_<128||(f|=(127&(_=v[p.pos++]))<<3,_<128)||(f|=(127&(_=v[p.pos++]))<<10,_<128)||(f|=(127&(_=v[p.pos++]))<<17,_<128)||(f|=(127&(_=v[p.pos++]))<<24,_<128)||(f|=(1&(_=v[p.pos++]))<<31,_<128))return ts(c,f,u);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=a[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,e=this.pos;return this.pos=i,i-e>=12&&bu?function(r,a,c){return bu.decode(r.subarray(a,c))}(this.buf,e,i):function(r,a,c){for(var u="",p=a;p<c;){var f,_,v,w=r[p],E=null,P=w>239?4:w>223?3:w>191?2:1;if(p+P>c)break;P===1?w<128&&(E=w):P===2?(192&(f=r[p+1]))==128&&(E=(31&w)<<6|63&f)<=127&&(E=null):P===3?(_=r[p+2],(192&(f=r[p+1]))==128&&(192&_)==128&&((E=(15&w)<<12|(63&f)<<6|63&_)<=2047||E>=55296&&E<=57343)&&(E=null)):P===4&&(_=r[p+2],v=r[p+3],(192&(f=r[p+1]))==128&&(192&_)==128&&(192&v)==128&&((E=(15&w)<<18|(63&f)<<12|(63&_)<<6|63&v)<=65535||E>=1114112)&&(E=null)),E===null?(E=65533,P=1):E>65535&&(E-=65536,u+=String.fromCharCode(E>>>10&1023|55296),E=56320|1023&E),u+=String.fromCharCode(E),p+=P}return u}(this.buf,e,i)},readBytes:function(){var i=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,i);return this.pos=i,e},readPackedVarint:function(i,e){if(this.type!==Tt.Bytes)return i.push(this.readVarint(e));var r=an(this);for(i=i||[];this.pos<r;)i.push(this.readVarint(e));return i},readPackedSVarint:function(i){if(this.type!==Tt.Bytes)return i.push(this.readSVarint());var e=an(this);for(i=i||[];this.pos<e;)i.push(this.readSVarint());return i},readPackedBoolean:function(i){if(this.type!==Tt.Bytes)return i.push(this.readBoolean());var e=an(this);for(i=i||[];this.pos<e;)i.push(this.readBoolean());return i},readPackedFloat:function(i){if(this.type!==Tt.Bytes)return i.push(this.readFloat());var e=an(this);for(i=i||[];this.pos<e;)i.push(this.readFloat());return i},readPackedDouble:function(i){if(this.type!==Tt.Bytes)return i.push(this.readDouble());var e=an(this);for(i=i||[];this.pos<e;)i.push(this.readDouble());return i},readPackedFixed32:function(i){if(this.type!==Tt.Bytes)return i.push(this.readFixed32());var e=an(this);for(i=i||[];this.pos<e;)i.push(this.readFixed32());return i},readPackedSFixed32:function(i){if(this.type!==Tt.Bytes)return i.push(this.readSFixed32());var e=an(this);for(i=i||[];this.pos<e;)i.push(this.readSFixed32());return i},readPackedFixed64:function(i){if(this.type!==Tt.Bytes)return i.push(this.readFixed64());var e=an(this);for(i=i||[];this.pos<e;)i.push(this.readFixed64());return i},readPackedSFixed64:function(i){if(this.type!==Tt.Bytes)return i.push(this.readSFixed64());var e=an(this);for(i=i||[];this.pos<e;)i.push(this.readSFixed64());return i},skip:function(i){var e=7&i;if(e===Tt.Varint)for(;this.buf[this.pos++]>127;);else if(e===Tt.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Tt.Fixed32)this.pos+=4;else{if(e!==Tt.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(i,e){this.writeVarint(i<<3|e)},realloc:function(i){for(var e=this.length||16;e<this.pos+i;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(i){this.realloc(4),is(this.buf,i,this.pos),this.pos+=4},writeSFixed32:function(i){this.realloc(4),is(this.buf,i,this.pos),this.pos+=4},writeFixed64:function(i){this.realloc(8),is(this.buf,-1&i,this.pos),is(this.buf,Math.floor(i*vu),this.pos+4),this.pos+=8},writeSFixed64:function(i){this.realloc(8),is(this.buf,-1&i,this.pos),is(this.buf,Math.floor(i*vu),this.pos+4),this.pos+=8},writeVarint:function(i){(i=+i||0)>268435455||i<0?function(e,r){var a,c;if(e>=0?(a=e%4294967296|0,c=e/4294967296|0):(c=~(-e/4294967296),4294967295^(a=~(-e%4294967296))?a=a+1|0:(a=0,c=c+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),function(u,p,f){f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,f.buf[f.pos]=127&(u>>>=7)}(a,0,r),function(u,p){var f=(7&u)<<4;p.buf[p.pos++]|=f|((u>>>=3)?128:0),u&&(p.buf[p.pos++]=127&u|((u>>>=7)?128:0),u&&(p.buf[p.pos++]=127&u|((u>>>=7)?128:0),u&&(p.buf[p.pos++]=127&u|((u>>>=7)?128:0),u&&(p.buf[p.pos++]=127&u|((u>>>=7)?128:0),u&&(p.buf[p.pos++]=127&u)))))}(c,r)}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?2*-i-1:2*i)},writeBoolean:function(i){this.writeVarint(!!i)},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var e=this.pos;this.pos=function(a,c,u){for(var p,f,_=0;_<c.length;_++){if((p=c.charCodeAt(_))>55295&&p<57344){if(!f){p>56319||_+1===c.length?(a[u++]=239,a[u++]=191,a[u++]=189):f=p;continue}if(p<56320){a[u++]=239,a[u++]=191,a[u++]=189,f=p;continue}p=f-55296<<10|p-56320|65536,f=null}else f&&(a[u++]=239,a[u++]=191,a[u++]=189,f=null);p<128?a[u++]=p:(p<2048?a[u++]=p>>6|192:(p<65536?a[u++]=p>>12|224:(a[u++]=p>>18|240,a[u++]=p>>12&63|128),a[u++]=p>>6&63|128),a[u++]=63&p|128)}return u}(this.buf,i,this.pos);var r=this.pos-e;r>=128&&wu(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(i){this.realloc(4),xu(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),xu(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var e=i.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=i[r]},writeRawMessage:function(i,e){this.pos++;var r=this.pos;i(e,this);var a=this.pos-r;a>=128&&wu(r,a,this),this.pos=r-1,this.writeVarint(a),this.pos+=a},writeMessage:function(i,e,r){this.writeTag(i,Tt.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(i,e){e.length&&this.writeMessage(i,sf,e)},writePackedSVarint:function(i,e){e.length&&this.writeMessage(i,of,e)},writePackedBoolean:function(i,e){e.length&&this.writeMessage(i,hf,e)},writePackedFloat:function(i,e){e.length&&this.writeMessage(i,lf,e)},writePackedDouble:function(i,e){e.length&&this.writeMessage(i,cf,e)},writePackedFixed32:function(i,e){e.length&&this.writeMessage(i,uf,e)},writePackedSFixed32:function(i,e){e.length&&this.writeMessage(i,df,e)},writePackedFixed64:function(i,e){e.length&&this.writeMessage(i,pf,e)},writePackedSFixed64:function(i,e){e.length&&this.writeMessage(i,mf,e)},writeBytesField:function(i,e){this.writeTag(i,Tt.Bytes),this.writeBytes(e)},writeFixed32Field:function(i,e){this.writeTag(i,Tt.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(i,e){this.writeTag(i,Tt.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(i,e){this.writeTag(i,Tt.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(i,e){this.writeTag(i,Tt.Fixed64),this.writeSFixed64(e)},writeVarintField:function(i,e){this.writeTag(i,Tt.Varint),this.writeVarint(e)},writeSVarintField:function(i,e){this.writeTag(i,Tt.Varint),this.writeSVarint(e)},writeStringField:function(i,e){this.writeTag(i,Tt.Bytes),this.writeString(e)},writeFloatField:function(i,e){this.writeTag(i,Tt.Fixed32),this.writeFloat(e)},writeDoubleField:function(i,e){this.writeTag(i,Tt.Fixed64),this.writeDouble(e)},writeBooleanField:function(i,e){this.writeVarintField(i,!!e)}};class Pc{constructor(e,{pixelRatio:r,version:a,stretchX:c,stretchY:u,content:p}){this.paddedRect=e,this.pixelRatio=r,this.stretchX=c,this.stretchY=u,this.content=p,this.version=a}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class Eu{constructor(e,r){const a={},c={};this.haveRenderCallbacks=[];const u=[];this.addImages(e,a,u),this.addImages(r,c,u);const{w:p,h:f}=Su(u),_=new er({width:p||1,height:f||1});for(const v in e){const w=e[v],E=a[v].paddedRect;er.copy(w.data,_,{x:0,y:0},{x:E.x+1,y:E.y+1},w.data)}for(const v in r){const w=r[v],E=c[v].paddedRect,P=E.x+1,k=E.y+1,L=w.data.width,$=w.data.height;er.copy(w.data,_,{x:0,y:0},{x:P,y:k},w.data),er.copy(w.data,_,{x:0,y:$-1},{x:P,y:k-1},{width:L,height:1}),er.copy(w.data,_,{x:0,y:0},{x:P,y:k+$},{width:L,height:1}),er.copy(w.data,_,{x:L-1,y:0},{x:P-1,y:k},{width:1,height:$}),er.copy(w.data,_,{x:0,y:0},{x:P+L,y:k},{width:1,height:$})}this.image=_,this.iconPositions=a,this.patternPositions=c}addImages(e,r,a){for(const c in e){const u=e[c],p={x:0,y:0,w:u.data.width+2,h:u.data.height+2};a.push(p),r[c]=new Pc(p,u),u.hasRenderCallback&&this.haveRenderCallbacks.push(c)}}patchUpdatedImages(e,r){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const a in e.updatedImages)this.patchUpdatedImage(this.iconPositions[a],e.getImage(a),r),this.patchUpdatedImage(this.patternPositions[a],e.getImage(a),r)}patchUpdatedImage(e,r,a){if(!e||!r||e.version===r.version)return;e.version=r.version;const[c,u]=e.tl;a.update(r.data,void 0,{x:c,y:u})}}ke("ImagePosition",Pc),ke("ImageAtlas",Eu),h.WritingMode=void 0,(Fn=h.WritingMode||(h.WritingMode={}))[Fn.none=0]="none",Fn[Fn.horizontal=1]="horizontal",Fn[Fn.vertical=2]="vertical",Fn[Fn.horizontalOnly=3]="horizontalOnly";const Tl=-17;class xo{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,r){const a=new xo;return a.scale=e||1,a.fontStack=r,a}static forImage(e){const r=new xo;return r.imageName=e,r}}class rs{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,r){const a=new rs;for(let c=0;c<e.sections.length;c++){const u=e.sections[c];u.image?a.addImageSection(u):a.addTextSection(u,r)}return a}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSectionIndex(e){return this.sectionIndex[e]}getCharCode(e){return this.text.charCodeAt(e)}verticalizePunctuation(){this.text=function(e){let r="";for(let a=0;a<e.length;a++){const c=e.charCodeAt(a+1)||null,u=e.charCodeAt(a-1)||null;r+=c&&ll(c)&&!yo[e[a+1]]||u&&ll(u)&&!yo[e[a-1]]||!yo[e[a]]?e[a]:yo[e[a]]}return r}(this.text)}trim(){let e=0;for(let a=0;a<this.text.length&&El[this.text.charCodeAt(a)];a++)e++;let r=this.text.length;for(let a=this.text.length-1;a>=0&&a>=e&&El[this.text.charCodeAt(a)];a--)r--;this.text=this.text.substring(e,r),this.sectionIndex=this.sectionIndex.slice(e,r)}substring(e,r){const a=new rs;return a.text=this.text.substring(e,r),a.sectionIndex=this.sectionIndex.slice(e,r),a.sections=this.sections,a}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,r)=>Math.max(e,this.sections[r].scale),0)}addTextSection(e,r){this.text+=e.text,this.sections.push(xo.forText(e.scale,e.fontStack||r));const a=this.sections.length-1;for(let c=0;c<e.text.length;++c)this.sectionIndex.push(a)}addImageSection(e){const r=e.image?e.image.name:"";if(r.length===0)return void dt("Can't add FormattedSection with an empty image.");const a=this.getNextImageSectionCharCode();a?(this.text+=String.fromCharCode(a),this.sections.push(xo.forImage(r)),this.sectionIndex.push(this.sections.length-1)):dt("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Sl(i,e,r,a,c,u,p,f,_,v,w,E,P,k,L,$){const N=rs.fromFeature(i,c);let J;E===h.WritingMode.vertical&&N.verticalizePunctuation();const{processBidirectionalText:ne,processStyledBidirectionalText:K}=Ei;if(ne&&N.sections.length===1){J=[];const fe=ne(N.toString(),kc(N,v,u,e,a,k,L));for(const De of fe){const Fe=new rs;Fe.text=De,Fe.sections=N.sections;for(let Me=0;Me<De.length;Me++)Fe.sectionIndex.push(0);J.push(Fe)}}else if(K){J=[];const fe=K(N.text,N.sectionIndex,kc(N,v,u,e,a,k,L));for(const De of fe){const Fe=new rs;Fe.text=De[0],Fe.sectionIndex=De[1],Fe.sections=N.sections,J.push(Fe)}}else J=function(fe,De){const Fe=[],Me=fe.text;let Ie=0;for(const Te of De)Fe.push(fe.substring(Ie,Te)),Ie=Te;return Ie<Me.length&&Fe.push(fe.substring(Ie,Me.length)),Fe}(N,kc(N,v,u,e,a,k,L));const re=[],ge={positionedLines:re,text:N.toString(),top:w[1],bottom:w[1],left:w[0],right:w[0],writingMode:E,iconsInText:!1,verticalizable:!1};return function(fe,De,Fe,Me,Ie,Te,Pe,Ce,be,$e,Ue,it){let kt=0,Bt=Tl,Kt=0,ir=0;const ai=Ce==="right"?1:Ce==="left"?0:.5;let Zt=0;for(const Xt of Ie){Xt.trim();const oi=Xt.getMaxScale(),bi=(oi-1)*ii,Ai={positionedGlyphs:[],lineOffset:0};fe.positionedLines[Zt]=Ai;const Li=Ai.positionedGlyphs;let Di=0;if(!Xt.length()){Bt+=Te,++Zt;continue}for(let li=0;li<Xt.length();li++){const rt=Xt.getSection(li),Zi=Xt.getSectionIndex(li),ci=Xt.getCharCode(li);let wi=0,hr=null,br=null,wr=null,on=ii;const ur=!(be===h.WritingMode.horizontal||!Ue&&!Us(ci)||Ue&&(El[ci]||(Jt=ci,Ae.Arabic(Jt)||Ae["Arabic Supplement"](Jt)||Ae["Arabic Extended-A"](Jt)||Ae["Arabic Presentation Forms-A"](Jt)||Ae["Arabic Presentation Forms-B"](Jt))));if(rt.imageName){const rr=Me[rt.imageName];if(!rr)continue;wr=rt.imageName,fe.iconsInText=fe.iconsInText||!0,br=rr.paddedRect;const Ri=rr.displaySize;rt.scale=rt.scale*ii/it,hr={width:Ri[0],height:Ri[1],left:1,top:-3,advance:ur?Ri[1]:Ri[0]},wi=bi+(ii-Ri[1]*rt.scale),on=hr.advance;const ln=ur?Ri[0]*rt.scale-ii*oi:Ri[1]*rt.scale-ii*oi;ln>0&&ln>Di&&(Di=ln)}else{const rr=Fe[rt.fontStack],Ri=rr&&rr[ci];if(Ri&&Ri.rect)br=Ri.rect,hr=Ri.metrics;else{const ln=De[rt.fontStack],To=ln&&ln[ci];if(!To)continue;hr=To.metrics}wi=(oi-rt.scale)*ii}ur?(fe.verticalizable=!0,Li.push({glyph:ci,imageName:wr,x:kt,y:Bt+wi,vertical:ur,scale:rt.scale,fontStack:rt.fontStack,sectionIndex:Zi,metrics:hr,rect:br}),kt+=on*rt.scale+$e):(Li.push({glyph:ci,imageName:wr,x:kt,y:Bt+wi,vertical:ur,scale:rt.scale,fontStack:rt.fontStack,sectionIndex:Zi,metrics:hr,rect:br}),kt+=hr.advance*rt.scale+$e)}Li.length!==0&&(Kt=Math.max(kt-$e,Kt),vf(Li,0,Li.length-1,ai,Di)),kt=0;const Nt=Te*oi+Di;Ai.lineOffset=Math.max(Di,bi),Bt+=Nt,ir=Math.max(Nt,ir),++Zt}var Jt;const si=Bt-Tl,{horizontalAlign:vi,verticalAlign:zi}=zc(Pe);(function(Xt,oi,bi,Ai,Li,Di,Nt,li,rt){const Zi=(oi-bi)*Li;let ci=0;ci=Di!==Nt?-li*Ai-Tl:(-Ai*rt+.5)*Nt;for(const wi of Xt)for(const hr of wi.positionedGlyphs)hr.x+=Zi,hr.y+=ci})(fe.positionedLines,ai,vi,zi,Kt,ir,Te,si,Ie.length),fe.top+=-zi*si,fe.bottom=fe.top+si,fe.left+=-vi*Kt,fe.right=fe.left+Kt}(ge,e,r,a,J,p,f,_,E,v,P,$),!function(fe){for(const De of fe)if(De.positionedGlyphs.length!==0)return!1;return!0}(re)&&ge}const El={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},yf={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function Iu(i,e,r,a,c,u){if(e.imageName){const p=a[e.imageName];return p?p.displaySize[0]*e.scale*ii/u+c:0}{const p=r[e.fontStack],f=p&&p[i];return f?f.metrics.advance*e.scale+c:0}}function Au(i,e,r,a){const c=Math.pow(i-e,2);return a?i<e?c/2:2*c:c+Math.abs(r)*r}function xf(i,e,r){let a=0;return i===10&&(a-=1e4),r&&(a+=150),i!==40&&i!==65288||(a+=50),e!==41&&e!==65289||(a+=50),a}function Cu(i,e,r,a,c,u){let p=null,f=Au(e,r,c,u);for(const _ of a){const v=Au(e-_.x,r,c,u)+_.badness;v<=f&&(p=_,f=v)}return{index:i,x:e,priorBreak:p,badness:f}}function Mu(i){return i?Mu(i.priorBreak).concat(i.index):[]}function kc(i,e,r,a,c,u,p){if(u!=="point")return[];if(!i)return[];const f=[],_=function(P,k,L,$,N,J){let ne=0;for(let K=0;K<P.length();K++){const re=P.getSection(K);ne+=Iu(P.getCharCode(K),re,$,N,k,J)}return ne/Math.max(1,Math.ceil(ne/L))}(i,e,r,a,c,p),v=i.text.indexOf("\u200B")>=0;let w=0;for(let P=0;P<i.length();P++){const k=i.getSection(P),L=i.getCharCode(P);if(El[L]||(w+=Iu(L,k,a,c,e,p)),P<i.length()-1){const $=!((E=L)<11904||!(Ae["Bopomofo Extended"](E)||Ae.Bopomofo(E)||Ae["CJK Compatibility Forms"](E)||Ae["CJK Compatibility Ideographs"](E)||Ae["CJK Compatibility"](E)||Ae["CJK Radicals Supplement"](E)||Ae["CJK Strokes"](E)||Ae["CJK Symbols and Punctuation"](E)||Ae["CJK Unified Ideographs Extension A"](E)||Ae["CJK Unified Ideographs"](E)||Ae["Enclosed CJK Letters and Months"](E)||Ae["Halfwidth and Fullwidth Forms"](E)||Ae.Hiragana(E)||Ae["Ideographic Description Characters"](E)||Ae["Kangxi Radicals"](E)||Ae["Katakana Phonetic Extensions"](E)||Ae.Katakana(E)||Ae["Vertical Forms"](E)||Ae["Yi Radicals"](E)||Ae["Yi Syllables"](E)));(yf[L]||$||k.imageName)&&f.push(Cu(P+1,w,_,f,xf(L,i.getCharCode(P+1),$&&v),!1))}}var E;return Mu(Cu(i.length(),w,_,f,0,!0))}function zc(i){let e=.5,r=.5;switch(i){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(i){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:e,verticalAlign:r}}function vf(i,e,r,a,c){if(!a&&!c)return;const u=i[r],p=(i[r].x+u.metrics.advance*u.scale)*a;for(let f=e;f<=r;f++)i[f].x-=p,i[f].y+=c}function bf(i,e,r){const{horizontalAlign:a,verticalAlign:c}=zc(r),u=e[0]-i.displaySize[0]*a,p=e[1]-i.displaySize[1]*c;return{image:i,top:p,bottom:p+i.displaySize[1],left:u,right:u+i.displaySize[0]}}function Pu(i,e,r,a,c,u){const p=i.image;let f;if(p.content){const N=p.content,J=p.pixelRatio||1;f=[N[0]/J,N[1]/J,p.displaySize[0]-N[2]/J,p.displaySize[1]-N[3]/J]}const _=e.left*u,v=e.right*u;let w,E,P,k;r==="width"||r==="both"?(k=c[0]+_-a[3],E=c[0]+v+a[1]):(k=c[0]+(_+v-p.displaySize[0])/2,E=k+p.displaySize[0]);const L=e.top*u,$=e.bottom*u;return r==="height"||r==="both"?(w=c[1]+L-a[0],P=c[1]+$+a[2]):(w=c[1]+(L+$-p.displaySize[1])/2,P=w+p.displaySize[1]),{image:p,top:w,right:E,bottom:P,left:k,collisionPadding:f}}const sn=128;function ku(i,e){const{expression:r}=e;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new Pt(i+1))};if(r.kind==="source")return{kind:"source"};{const{zoomStops:a,interpolationType:c}=r;let u=0;for(;u<a.length&&a[u]<=i;)u++;u=Math.max(0,u-1);let p=u;for(;p<a.length&&a[p]<i+1;)p++;p=Math.min(a.length-1,p);const f=a[u],_=a[p];return r.kind==="composite"?{kind:"composite",minZoom:f,maxZoom:_,interpolationType:c}:{kind:"camera",minZoom:f,maxZoom:_,minSize:r.evaluate(new Pt(f)),maxSize:r.evaluate(new Pt(_)),interpolationType:c}}}class On extends He{constructor(e,r,a,c){super(e,r),this.angle=a,c!==void 0&&(this.segment=c)}clone(){return new On(this.x,this.y,this.angle,this.segment)}}function zu(i,e,r,a,c){if(e.segment===void 0)return!0;let u=e,p=e.segment+1,f=0;for(;f>-r/2;){if(p--,p<0)return!1;f-=i[p].dist(u),u=i[p]}f+=i[p].dist(i[p+1]),p++;const _=[];let v=0;for(;f<r/2;){const w=i[p],E=i[p+1];if(!E)return!1;let P=i[p-1].angleTo(w)-w.angleTo(E);for(P=Math.abs((P+3*Math.PI)%(2*Math.PI)-Math.PI),_.push({distance:f,angleDelta:P}),v+=P;f-_[0].distance>a;)v-=_.shift().angleDelta;if(v>c)return!1;p++,f+=w.dist(E)}return!0}function Lu(i){let e=0;for(let r=0;r<i.length-1;r++)e+=i[r].dist(i[r+1]);return e}function Du(i,e,r){return i?.6*e*r:0}function Ru(i,e){return Math.max(i?i.right-i.left:0,e?e.right-e.left:0)}function wf(i,e,r,a,c,u){const p=Du(r,c,u),f=Ru(r,a)*u;let _=0;const v=Lu(i)/2;for(let w=0;w<i.length-1;w++){const E=i[w],P=i[w+1],k=E.dist(P);if(_+k>v){const L=(v-_)/k,$=zt(E.x,P.x,L),N=zt(E.y,P.y,L),J=new On($,N,P.angleTo(E),w);return J._round(),!p||zu(i,J,f,p,e)?J:void 0}_+=k}}function Tf(i,e,r,a,c,u,p,f,_){const v=Du(a,u,p),w=Ru(a,c),E=w*p,P=i[0].x===0||i[0].x===_||i[0].y===0||i[0].y===_;return e-E<e/4&&(e=E+e/4),Bu(i,P?e/2*f%e:(w/2+2*u)*p*f%e,e,v,r,E,P,!1,_)}function Bu(i,e,r,a,c,u,p,f,_){const v=u/2,w=Lu(i);let E=0,P=e-r,k=[];for(let L=0;L<i.length-1;L++){const $=i[L],N=i[L+1],J=$.dist(N),ne=N.angleTo($);for(;P+r<E+J;){P+=r;const K=(P-E)/J,re=zt($.x,N.x,K),ge=zt($.y,N.y,K);if(re>=0&&re<_&&ge>=0&&ge<_&&P-v>=0&&P+v<=w){const fe=new On(re,ge,ne,L);fe._round(),a&&!zu(i,fe,u,a,c)||k.push(fe)}}E+=J}return f||k.length||p||(k=Bu(i,E/2,r,a,c,u,p,!0,_)),k}function Fu(i,e,r,a,c){const u=[];for(let p=0;p<i.length;p++){const f=i[p];let _;for(let v=0;v<f.length-1;v++){let w=f[v],E=f[v+1];w.x<e&&E.x<e||(w.x<e?w=new He(e,w.y+(e-w.x)/(E.x-w.x)*(E.y-w.y))._round():E.x<e&&(E=new He(e,w.y+(e-w.x)/(E.x-w.x)*(E.y-w.y))._round()),w.y<r&&E.y<r||(w.y<r?w=new He(w.x+(r-w.y)/(E.y-w.y)*(E.x-w.x),r)._round():E.y<r&&(E=new He(w.x+(r-w.y)/(E.y-w.y)*(E.x-w.x),r)._round()),w.x>=a&&E.x>=a||(w.x>=a?w=new He(a,w.y+(a-w.x)/(E.x-w.x)*(E.y-w.y))._round():E.x>=a&&(E=new He(a,w.y+(a-w.x)/(E.x-w.x)*(E.y-w.y))._round()),w.y>=c&&E.y>=c||(w.y>=c?w=new He(w.x+(c-w.y)/(E.y-w.y)*(E.x-w.x),c)._round():E.y>=c&&(E=new He(w.x+(c-w.y)/(E.y-w.y)*(E.x-w.x),c)._round()),_&&w.equals(_[_.length-1])||(_=[w],u.push(_)),_.push(E)))))}}return u}function Ou(i,e,r,a){const c=[],u=i.image,p=u.pixelRatio,f=u.paddedRect.w-2,_=u.paddedRect.h-2,v=i.right-i.left,w=i.bottom-i.top,E=u.stretchX||[[0,f]],P=u.stretchY||[[0,_]],k=(Te,Pe)=>Te+Pe[1]-Pe[0],L=E.reduce(k,0),$=P.reduce(k,0),N=f-L,J=_-$;let ne=0,K=L,re=0,ge=$,fe=0,De=N,Fe=0,Me=J;if(u.content&&a){const Te=u.content;ne=Il(E,0,Te[0]),re=Il(P,0,Te[1]),K=Il(E,Te[0],Te[2]),ge=Il(P,Te[1],Te[3]),fe=Te[0]-ne,Fe=Te[1]-re,De=Te[2]-Te[0]-K,Me=Te[3]-Te[1]-ge}const Ie=(Te,Pe,Ce,be)=>{const $e=Al(Te.stretch-ne,K,v,i.left),Ue=Cl(Te.fixed-fe,De,Te.stretch,L),it=Al(Pe.stretch-re,ge,w,i.top),kt=Cl(Pe.fixed-Fe,Me,Pe.stretch,$),Bt=Al(Ce.stretch-ne,K,v,i.left),Kt=Cl(Ce.fixed-fe,De,Ce.stretch,L),ir=Al(be.stretch-re,ge,w,i.top),ai=Cl(be.fixed-Fe,Me,be.stretch,$),Zt=new He($e,it),Jt=new He(Bt,it),si=new He(Bt,ir),vi=new He($e,ir),zi=new He(Ue/p,kt/p),Xt=new He(Kt/p,ai/p),oi=e*Math.PI/180;if(oi){const Li=Math.sin(oi),Di=Math.cos(oi),Nt=[Di,-Li,Li,Di];Zt._matMult(Nt),Jt._matMult(Nt),vi._matMult(Nt),si._matMult(Nt)}const bi=Te.stretch+Te.fixed,Ai=Pe.stretch+Pe.fixed;return{tl:Zt,tr:Jt,bl:vi,br:si,tex:{x:u.paddedRect.x+1+bi,y:u.paddedRect.y+1+Ai,w:Ce.stretch+Ce.fixed-bi,h:be.stretch+be.fixed-Ai},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:zi,pixelOffsetBR:Xt,minFontScaleX:De/p/v,minFontScaleY:Me/p/w,isSDF:r}};if(a&&(u.stretchX||u.stretchY)){const Te=Uu(E,N,L),Pe=Uu(P,J,$);for(let Ce=0;Ce<Te.length-1;Ce++){const be=Te[Ce],$e=Te[Ce+1];for(let Ue=0;Ue<Pe.length-1;Ue++)c.push(Ie(be,Pe[Ue],$e,Pe[Ue+1]))}}else c.push(Ie({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:f+1},{fixed:0,stretch:_+1}));return c}function Il(i,e,r){let a=0;for(const c of i)a+=Math.max(e,Math.min(r,c[1]))-Math.max(e,Math.min(r,c[0]));return a}function Uu(i,e,r){const a=[{fixed:-1,stretch:0}];for(const[c,u]of i){const p=a[a.length-1];a.push({fixed:c-p.stretch,stretch:p.stretch}),a.push({fixed:c-p.stretch,stretch:p.stretch+(u-c)})}return a.push({fixed:e+1,stretch:r}),a}function Al(i,e,r,a){return i/e*r+a}function Cl(i,e,r,a){return i-e*r/a}ke("Anchor",On);class Ml{constructor(e,r,a,c,u,p,f,_,v,w){if(this.boxStartIndex=e.length,v){let E=p.top,P=p.bottom;const k=p.collisionPadding;k&&(E-=k[1],P+=k[3]);let L=P-E;L>0&&(L=Math.max(10,L),this.circleDiameter=L)}else{let E=p.top*f-_[0],P=p.bottom*f+_[2],k=p.left*f-_[3],L=p.right*f+_[1];const $=p.collisionPadding;if($&&(k-=$[0]*f,E-=$[1]*f,L+=$[2]*f,P+=$[3]*f),w){const N=new He(k,E),J=new He(L,E),ne=new He(k,P),K=new He(L,P),re=w*Math.PI/180;N._rotate(re),J._rotate(re),ne._rotate(re),K._rotate(re),k=Math.min(N.x,J.x,ne.x,K.x),L=Math.max(N.x,J.x,ne.x,K.x),E=Math.min(N.y,J.y,ne.y,K.y),P=Math.max(N.y,J.y,ne.y,K.y)}e.emplaceBack(r.x,r.y,k,E,L,P,a,c,u)}this.boxEndIndex=e.length}}class Sf{constructor(e=[],r=Ef){if(this.data=e,this.length=this.data.length,this.compare=r,this.length>0)for(let a=(this.length>>1)-1;a>=0;a--)this._down(a)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:r,compare:a}=this,c=r[e];for(;e>0;){const u=e-1>>1,p=r[u];if(a(c,p)>=0)break;r[e]=p,e=u}r[e]=c}_down(e){const{data:r,compare:a}=this,c=this.length>>1,u=r[e];for(;e<c;){let p=1+(e<<1),f=r[p];const _=p+1;if(_<this.length&&a(r[_],f)<0&&(p=_,f=r[_]),a(f,u)>=0)break;r[e]=f,e=p}r[e]=u}}function Ef(i,e){return i<e?-1:i>e?1:0}function If(i,e=1,r=!1){let a=1/0,c=1/0,u=-1/0,p=-1/0;const f=i[0];for(let k=0;k<f.length;k++){const L=f[k];(!k||L.x<a)&&(a=L.x),(!k||L.y<c)&&(c=L.y),(!k||L.x>u)&&(u=L.x),(!k||L.y>p)&&(p=L.y)}const _=Math.min(u-a,p-c);let v=_/2;const w=new Sf([],Af);if(_===0)return new He(a,c);for(let k=a;k<u;k+=_)for(let L=c;L<p;L+=_)w.push(new ns(k+v,L+v,v,i));let E=function(k){let L=0,$=0,N=0;const J=k[0];for(let ne=0,K=J.length,re=K-1;ne<K;re=ne++){const ge=J[ne],fe=J[re],De=ge.x*fe.y-fe.x*ge.y;$+=(ge.x+fe.x)*De,N+=(ge.y+fe.y)*De,L+=3*De}return new ns($/L,N/L,0,k)}(i),P=w.length;for(;w.length;){const k=w.pop();(k.d>E.d||!E.d)&&(E=k,r&&console.log("found best %d after %d probes",Math.round(1e4*k.d)/1e4,P)),k.max-E.d<=e||(v=k.h/2,w.push(new ns(k.p.x-v,k.p.y-v,v,i)),w.push(new ns(k.p.x+v,k.p.y-v,v,i)),w.push(new ns(k.p.x-v,k.p.y+v,v,i)),w.push(new ns(k.p.x+v,k.p.y+v,v,i)),P+=4)}return r&&(console.log(`num probes: ${P}`),console.log(`best distance: ${E.d}`)),E.p}function Af(i,e){return e.max-i.max}function ns(i,e,r,a){this.p=new He(i,e),this.h=r,this.d=function(c,u){let p=!1,f=1/0;for(let _=0;_<u.length;_++){const v=u[_];for(let w=0,E=v.length,P=E-1;w<E;P=w++){const k=v[w],L=v[P];k.y>c.y!=L.y>c.y&&c.x<(L.x-k.x)*(c.y-k.y)/(L.y-k.y)+k.x&&(p=!p),f=Math.min(f,Rt(c,k,L))}}return(p?1:-1)*Math.sqrt(f)}(this.p,a),this.max=this.d+this.h*Math.SQRT2}const Lc=Number.POSITIVE_INFINITY;function Vu(i,e){return e[1]!==Lc?function(r,a,c){let u=0,p=0;switch(a=Math.abs(a),c=Math.abs(c),r){case"top-right":case"top-left":case"top":p=c-7;break;case"bottom-right":case"bottom-left":case"bottom":p=7-c}switch(r){case"top-right":case"bottom-right":case"right":u=-a;break;case"top-left":case"bottom-left":case"left":u=a}return[u,p]}(i,e[0],e[1]):function(r,a){let c=0,u=0;a<0&&(a=0);const p=a/Math.sqrt(2);switch(r){case"top-right":case"top-left":u=p-7;break;case"bottom-right":case"bottom-left":u=7-p;break;case"bottom":u=7-a;break;case"top":u=a-7}switch(r){case"top-right":case"bottom-right":c=-p;break;case"top-left":case"bottom-left":c=p;break;case"left":c=a;break;case"right":c=-a}return[c,u]}(i,e[0])}function Dc(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Cf(i,e,r,a,c,u,p,f,_,v,w){let E=u.textMaxSize.evaluate(e,{});E===void 0&&(E=p);const P=i.layers[0].layout,k=P.get("icon-offset").evaluate(e,{},w),L=$u(r.horizontal),$=p/24,N=i.tilePixelRatio*$,J=i.tilePixelRatio*E/24,ne=i.tilePixelRatio*f,K=i.tilePixelRatio*P.get("symbol-spacing"),re=P.get("text-padding")*i.tilePixelRatio,ge=function(be,$e,Ue,it=1){const kt=be.get("icon-padding").evaluate($e,{},Ue),Bt=kt&&kt.values;return[Bt[0]*it,Bt[1]*it,Bt[2]*it,Bt[3]*it]}(P,e,w,i.tilePixelRatio),fe=P.get("text-max-angle")/180*Math.PI,De=P.get("text-rotation-alignment")!=="viewport"&&P.get("symbol-placement")!=="point",Fe=P.get("icon-rotation-alignment")==="map"&&P.get("symbol-placement")!=="point",Me=P.get("symbol-placement"),Ie=K/2,Te=P.get("icon-text-fit");let Pe;a&&Te!=="none"&&(i.allowVerticalPlacement&&r.vertical&&(Pe=Pu(a,r.vertical,Te,P.get("icon-text-fit-padding"),k,$)),L&&(a=Pu(a,L,Te,P.get("icon-text-fit-padding"),k,$)));const Ce=(be,$e)=>{$e.x<0||$e.x>=gt||$e.y<0||$e.y>=gt||function(Ue,it,kt,Bt,Kt,ir,ai,Zt,Jt,si,vi,zi,Xt,oi,bi,Ai,Li,Di,Nt,li,rt,Zi,ci,wi,hr){const br=Ue.addToLineVertexArray(it,kt);let wr,on,ur,rr,Ri=0,ln=0,To=0,sd=0,Xc=-1,Wc=-1;const cn={};let od=M(""),Hc=0,Kc=0;if(Zt._unevaluatedLayout.getValue("text-radial-offset")===void 0?[Hc,Kc]=Zt.layout.get("text-offset").evaluate(rt,{},wi).map(Bi=>Bi*ii):(Hc=Zt.layout.get("text-radial-offset").evaluate(rt,{},wi)*ii,Kc=Lc),Ue.allowVerticalPlacement&&Bt.vertical){const Bi=Zt.layout.get("text-rotate").evaluate(rt,{},wi)+90;ur=new Ml(Jt,it,si,vi,zi,Bt.vertical,Xt,oi,bi,Bi),ai&&(rr=new Ml(Jt,it,si,vi,zi,ai,Li,Di,bi,Bi))}if(Kt){const Bi=Zt.layout.get("icon-rotate").evaluate(rt,{}),Fr=Zt.layout.get("icon-text-fit")!=="none",So=Ou(Kt,Bi,ci,Fr),Eo=ai?Ou(ai,Bi,ci,Fr):void 0;on=new Ml(Jt,it,si,vi,zi,Kt,Li,Di,!1,Bi),Ri=4*So.length;const hd=Ue.iconSizeData;let la=null;hd.kind==="source"?(la=[sn*Zt.layout.get("icon-size").evaluate(rt,{})],la[0]>Un&&dt(`${Ue.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):hd.kind==="composite"&&(la=[sn*Zi.compositeIconSizes[0].evaluate(rt,{},wi),sn*Zi.compositeIconSizes[1].evaluate(rt,{},wi)],(la[0]>Un||la[1]>Un)&&dt(`${Ue.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),Ue.addSymbols(Ue.icon,So,la,li,Nt,rt,h.WritingMode.none,it,br.lineStartIndex,br.lineLength,-1,wi),Xc=Ue.icon.placedSymbolArray.length-1,Eo&&(ln=4*Eo.length,Ue.addSymbols(Ue.icon,Eo,la,li,Nt,rt,h.WritingMode.vertical,it,br.lineStartIndex,br.lineLength,-1,wi),Wc=Ue.icon.placedSymbolArray.length-1)}const ld=Object.keys(Bt.horizontal);for(const Bi of ld){const Fr=Bt.horizontal[Bi];if(!wr){od=M(Fr.text);const Eo=Zt.layout.get("text-rotate").evaluate(rt,{},wi);wr=new Ml(Jt,it,si,vi,zi,Fr,Xt,oi,bi,Eo)}const So=Fr.positionedLines.length===1;if(To+=Nu(Ue,it,Fr,ir,Zt,bi,rt,Ai,br,Bt.vertical?h.WritingMode.horizontal:h.WritingMode.horizontalOnly,So?ld:[Bi],cn,Xc,Zi,wi),So)break}Bt.vertical&&(sd+=Nu(Ue,it,Bt.vertical,ir,Zt,bi,rt,Ai,br,h.WritingMode.vertical,["vertical"],cn,Wc,Zi,wi));const Gf=wr?wr.boxStartIndex:Ue.collisionBoxArray.length,jf=wr?wr.boxEndIndex:Ue.collisionBoxArray.length,qf=ur?ur.boxStartIndex:Ue.collisionBoxArray.length,Zf=ur?ur.boxEndIndex:Ue.collisionBoxArray.length,Xf=on?on.boxStartIndex:Ue.collisionBoxArray.length,Wf=on?on.boxEndIndex:Ue.collisionBoxArray.length,Hf=rr?rr.boxStartIndex:Ue.collisionBoxArray.length,Kf=rr?rr.boxEndIndex:Ue.collisionBoxArray.length;let Tr=-1;const Dl=(Bi,Fr)=>Bi&&Bi.circleDiameter?Math.max(Bi.circleDiameter,Fr):Fr;Tr=Dl(wr,Tr),Tr=Dl(ur,Tr),Tr=Dl(on,Tr),Tr=Dl(rr,Tr);const cd=Tr>-1?1:0;cd&&(Tr*=hr/ii),Ue.glyphOffsetArray.length>=as.MAX_GLYPHS&&dt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),rt.sortKey!==void 0&&Ue.addToSortKeyRanges(Ue.symbolInstances.length,rt.sortKey),Ue.symbolInstances.emplaceBack(it.x,it.y,cn.right>=0?cn.right:-1,cn.center>=0?cn.center:-1,cn.left>=0?cn.left:-1,cn.vertical||-1,Xc,Wc,od,Gf,jf,qf,Zf,Xf,Wf,Hf,Kf,si,To,sd,Ri,ln,cd,0,Xt,Hc,Kc,Tr)}(i,$e,be,r,a,c,Pe,i.layers[0],i.collisionBoxArray,e.index,e.sourceLayerIndex,i.index,N,[re,re,re,re],De,_,ne,ge,Fe,k,e,u,v,w,p)};if(Me==="line")for(const be of Fu(e.geometry,0,0,gt,gt)){const $e=Tf(be,K,fe,r.vertical||L,a,24,J,i.overscaling,gt);for(const Ue of $e)L&&Mf(i,L.text,Ie,Ue)||Ce(be,Ue)}else if(Me==="line-center"){for(const be of e.geometry)if(be.length>1){const $e=wf(be,fe,r.vertical||L,a,24,J);$e&&Ce(be,$e)}}else if(e.type==="Polygon")for(const be of bc(e.geometry,0)){const $e=If(be,16);Ce(be[0],new On($e.x,$e.y,0))}else if(e.type==="LineString")for(const be of e.geometry)Ce(be,new On(be[0].x,be[0].y,0));else if(e.type==="Point")for(const be of e.geometry)for(const $e of be)Ce([$e],new On($e.x,$e.y,0))}const Un=32640;function Nu(i,e,r,a,c,u,p,f,_,v,w,E,P,k,L){const $=function(ne,K,re,ge,fe,De,Fe,Me){const Ie=ge.layout.get("text-rotate").evaluate(De,{})*Math.PI/180,Te=[];for(const Pe of K.positionedLines)for(const Ce of Pe.positionedGlyphs){if(!Ce.rect)continue;const be=Ce.rect||{};let $e=4,Ue=!0,it=1,kt=0;const Bt=(fe||Me)&&Ce.vertical,Kt=Ce.metrics.advance*Ce.scale/2;if(Me&&K.verticalizable&&(kt=Pe.lineOffset/2-(Ce.imageName?-(ii-Ce.metrics.width*Ce.scale)/2:(Ce.scale-1)*ii)),Ce.imageName){const Nt=Fe[Ce.imageName];Ue=Nt.sdf,it=Nt.pixelRatio,$e=1/it}const ir=fe?[Ce.x+Kt,Ce.y]:[0,0];let ai=fe?[0,0]:[Ce.x+Kt+re[0],Ce.y+re[1]-kt],Zt=[0,0];Bt&&(Zt=ai,ai=[0,0]);const Jt=(Ce.metrics.left-$e)*Ce.scale-Kt+ai[0],si=(-Ce.metrics.top-$e)*Ce.scale+ai[1],vi=Jt+be.w*Ce.scale/it,zi=si+be.h*Ce.scale/it,Xt=new He(Jt,si),oi=new He(vi,si),bi=new He(Jt,zi),Ai=new He(vi,zi);if(Bt){const Nt=new He(-Kt,Kt-Tl),li=-Math.PI/2,rt=12-Kt,Zi=new He(22-rt,-(Ce.imageName?rt:0)),ci=new He(...Zt);Xt._rotateAround(li,Nt)._add(Zi)._add(ci),oi._rotateAround(li,Nt)._add(Zi)._add(ci),bi._rotateAround(li,Nt)._add(Zi)._add(ci),Ai._rotateAround(li,Nt)._add(Zi)._add(ci)}if(Ie){const Nt=Math.sin(Ie),li=Math.cos(Ie),rt=[li,-Nt,Nt,li];Xt._matMult(rt),oi._matMult(rt),bi._matMult(rt),Ai._matMult(rt)}const Li=new He(0,0),Di=new He(0,0);Te.push({tl:Xt,tr:oi,bl:bi,br:Ai,tex:be,writingMode:K.writingMode,glyphOffset:ir,sectionIndex:Ce.sectionIndex,isSDF:Ue,pixelOffsetTL:Li,pixelOffsetBR:Di,minFontScaleX:0,minFontScaleY:0})}return Te}(0,r,f,c,u,p,a,i.allowVerticalPlacement),N=i.textSizeData;let J=null;N.kind==="source"?(J=[sn*c.layout.get("text-size").evaluate(p,{})],J[0]>Un&&dt(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):N.kind==="composite"&&(J=[sn*k.compositeTextSizes[0].evaluate(p,{},L),sn*k.compositeTextSizes[1].evaluate(p,{},L)],(J[0]>Un||J[1]>Un)&&dt(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),i.addSymbols(i.text,$,J,f,u,p,v,e,_.lineStartIndex,_.lineLength,P,L);for(const ne of w)E[ne]=i.text.placedSymbolArray.length-1;return 4*$.length}function $u(i){for(const e in i)return i[e];return null}function Mf(i,e,r,a){const c=i.compareText;if(e in c){const u=c[e];for(let p=u.length-1;p>=0;p--)if(a.dist(u[p])<r)return!0}else c[e]=[];return c[e].push(a),!1}const Pf=Bn.VectorTileFeature.types,kf=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Pl(i,e,r,a,c,u,p,f,_,v,w,E,P){const k=f?Math.min(Un,Math.round(f[0])):0,L=f?Math.min(Un,Math.round(f[1])):0;i.emplaceBack(e,r,Math.round(32*a),Math.round(32*c),u,p,(k<<1)+(_?1:0),L,16*v,16*w,256*E,256*P)}function Rc(i,e,r){i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r)}function zf(i){for(const e of i.sections)if(Gi(e.text))return!0;return!1}class Bc{constructor(e){this.layoutVertexArray=new o,this.indexArray=new d,this.programConfigurations=e,this.segments=new x,this.dynamicLayoutVertexArray=new t,this.opacityVertexArray=new n,this.hasVisibleVertices=!1,this.placedSymbolArray=new ao}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,r,a,c){this.isEmpty()||(a&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ef.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,tf.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,kf,!0),this.opacityVertexBuffer.itemSize=1),(a||c)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}ke("SymbolBuffers",Bc);class Fc{constructor(e,r,a){this.layoutVertexArray=new e,this.layoutAttributes=r,this.indexArray=new a,this.segments=new x,this.collisionVertexArray=new l}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,rf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}ke("CollisionBuffers",Fc);class as{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(p=>p.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=fc([]),this.placementViewportMatrix=fc([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ku(this.zoom,r["text-size"]),this.iconSizeData=ku(this.zoom,r["icon-size"]);const a=this.layers[0].layout,c=a.get("symbol-sort-key"),u=a.get("symbol-z-order");this.canOverlap=Uc(a,"text-overlap","text-allow-overlap")!=="never"||Uc(a,"icon-overlap","icon-allow-overlap")!=="never"||a.get("text-ignore-placement")||a.get("icon-ignore-placement"),this.sortFeaturesByKey=u!=="viewport-y"&&!c.isConstant(),this.sortFeaturesByY=(u==="viewport-y"||u==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,a.get("symbol-placement")==="point"&&(this.writingModes=a.get("text-writing-mode").map(p=>h.WritingMode[p])),this.stateDependentLayerIds=this.layers.filter(p=>p.isStateDependent()).map(p=>p.id),this.sourceID=e.sourceID}createArrays(){this.text=new Bc(new tt(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Bc(new tt(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new rn,this.lineVertexArray=new na,this.symbolInstances=new ml}calculateGlyphDependencies(e,r,a,c,u){for(let p=0;p<e.length;p++)if(r[e.charCodeAt(p)]=!0,(a||c)&&u){const f=yo[e.charAt(p)];f&&(r[f.charCodeAt(0)]=!0)}}populate(e,r,a){const c=this.layers[0],u=c.layout,p=u.get("text-font"),f=u.get("text-field"),_=u.get("icon-image"),v=(f.value.kind!=="constant"||f.value.value instanceof ei&&!f.value.value.isEmpty()||f.value.value.toString().length>0)&&(p.value.kind!=="constant"||p.value.value.length>0),w=_.value.kind!=="constant"||!!_.value.value||Object.keys(_.parameters).length>0,E=u.get("symbol-sort-key");if(this.features=[],!v&&!w)return;const P=r.iconDependencies,k=r.glyphDependencies,L=r.availableImages,$=new Pt(this.zoom);for(const{feature:N,id:J,index:ne,sourceLayerIndex:K}of e){const re=c._featureFilter.needGeometry,ge=ki(N,re);if(!c._featureFilter.filter($,ge,a))continue;let fe,De;if(re||(ge.geometry=ni(N)),v){const Me=c.getValueAndResolveTokens("text-field",ge,a,L),Ie=ei.factory(Me);zf(Ie)&&(this.hasRTLText=!0),(!this.hasRTLText||tn()==="unavailable"||this.hasRTLText&&Ei.isParsed())&&(fe=af(Ie,c,ge))}if(w){const Me=c.getValueAndResolveTokens("icon-image",ge,a,L);De=Me instanceof fi?Me:fi.fromString(Me)}if(!fe&&!De)continue;const Fe=this.sortFeaturesByKey?E.evaluate(ge,{},a):void 0;if(this.features.push({id:J,text:fe,icon:De,index:ne,sourceLayerIndex:K,geometry:ge.geometry,properties:N.properties,type:Pf[N.type],sortKey:Fe}),De&&(P[De.name]=!0),fe){const Me=p.evaluate(ge,{},a).join(","),Ie=u.get("text-rotation-alignment")!=="viewport"&&u.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(h.WritingMode.vertical)>=0;for(const Te of fe.sections)if(Te.image)P[Te.image.name]=!0;else{const Pe=Os(fe.toString()),Ce=Te.fontStack||Me,be=k[Ce]=k[Ce]||{};this.calculateGlyphDependencies(Te.text,be,Ie,this.allowVerticalPlacement,Pe)}}}u.get("symbol-placement")==="line"&&(this.features=function(N){const J={},ne={},K=[];let re=0;function ge(Me){K.push(N[Me]),re++}function fe(Me,Ie,Te){const Pe=ne[Me];return delete ne[Me],ne[Ie]=Pe,K[Pe].geometry[0].pop(),K[Pe].geometry[0]=K[Pe].geometry[0].concat(Te[0]),Pe}function De(Me,Ie,Te){const Pe=J[Ie];return delete J[Ie],J[Me]=Pe,K[Pe].geometry[0].shift(),K[Pe].geometry[0]=Te[0].concat(K[Pe].geometry[0]),Pe}function Fe(Me,Ie,Te){const Pe=Te?Ie[0][Ie[0].length-1]:Ie[0][0];return`${Me}:${Pe.x}:${Pe.y}`}for(let Me=0;Me<N.length;Me++){const Ie=N[Me],Te=Ie.geometry,Pe=Ie.text?Ie.text.toString():null;if(!Pe){ge(Me);continue}const Ce=Fe(Pe,Te),be=Fe(Pe,Te,!0);if(Ce in ne&&be in J&&ne[Ce]!==J[be]){const $e=De(Ce,be,Te),Ue=fe(Ce,be,K[$e].geometry);delete J[Ce],delete ne[be],ne[Fe(Pe,K[Ue].geometry,!0)]=Ue,K[$e].geometry=null}else Ce in ne?fe(Ce,be,Te):be in J?De(Ce,be,Te):(ge(Me),J[Ce]=re-1,ne[be]=re-1)}return K.filter(Me=>Me.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((N,J)=>N.sortKey-J.sortKey)}update(e,r,a){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,r,this.layers,a),this.icon.programConfigurations.updatePaintArrays(e,r,this.layers,a))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,r){const a=this.lineVertexArray.length;if(e.segment!==void 0){let c=e.dist(r[e.segment+1]),u=e.dist(r[e.segment]);const p={};for(let f=e.segment+1;f<r.length;f++)p[f]={x:r[f].x,y:r[f].y,tileUnitDistanceFromAnchor:c},f<r.length-1&&(c+=r[f+1].dist(r[f]));for(let f=e.segment||0;f>=0;f--)p[f]={x:r[f].x,y:r[f].y,tileUnitDistanceFromAnchor:u},f>0&&(u+=r[f-1].dist(r[f]));for(let f=0;f<r.length;f++){const _=p[f];this.lineVertexArray.emplaceBack(_.x,_.y,_.tileUnitDistanceFromAnchor)}}return{lineStartIndex:a,lineLength:this.lineVertexArray.length-a}}addSymbols(e,r,a,c,u,p,f,_,v,w,E,P){const k=e.indexArray,L=e.layoutVertexArray,$=e.segments.prepareSegment(4*r.length,L,k,this.canOverlap?p.sortKey:void 0),N=this.glyphOffsetArray.length,J=$.vertexLength,ne=this.allowVerticalPlacement&&f===h.WritingMode.vertical?Math.PI/2:0,K=p.text&&p.text.sections;for(let re=0;re<r.length;re++){const{tl:ge,tr:fe,bl:De,br:Fe,tex:Me,pixelOffsetTL:Ie,pixelOffsetBR:Te,minFontScaleX:Pe,minFontScaleY:Ce,glyphOffset:be,isSDF:$e,sectionIndex:Ue}=r[re],it=$.vertexLength,kt=be[1];Pl(L,_.x,_.y,ge.x,kt+ge.y,Me.x,Me.y,a,$e,Ie.x,Ie.y,Pe,Ce),Pl(L,_.x,_.y,fe.x,kt+fe.y,Me.x+Me.w,Me.y,a,$e,Te.x,Ie.y,Pe,Ce),Pl(L,_.x,_.y,De.x,kt+De.y,Me.x,Me.y+Me.h,a,$e,Ie.x,Te.y,Pe,Ce),Pl(L,_.x,_.y,Fe.x,kt+Fe.y,Me.x+Me.w,Me.y+Me.h,a,$e,Te.x,Te.y,Pe,Ce),Rc(e.dynamicLayoutVertexArray,_,ne),k.emplaceBack(it,it+1,it+2),k.emplaceBack(it+1,it+2,it+3),$.vertexLength+=4,$.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(be[0]),re!==r.length-1&&Ue===r[re+1].sectionIndex||e.programConfigurations.populatePaintArrays(L.length,p,p.index,{},P,K&&K[Ue])}e.placedSymbolArray.emplaceBack(_.x,_.y,N,this.glyphOffsetArray.length-N,J,v,w,_.segment,a?a[0]:0,a?a[1]:0,c[0],c[1],f,0,!1,0,E)}_addCollisionDebugVertex(e,r,a,c,u,p){return r.emplaceBack(0,0),e.emplaceBack(a.x,a.y,c,u,Math.round(p.x),Math.round(p.y))}addCollisionDebugVertices(e,r,a,c,u,p,f){const _=u.segments.prepareSegment(4,u.layoutVertexArray,u.indexArray),v=_.vertexLength,w=u.layoutVertexArray,E=u.collisionVertexArray,P=f.anchorX,k=f.anchorY;this._addCollisionDebugVertex(w,E,p,P,k,new He(e,r)),this._addCollisionDebugVertex(w,E,p,P,k,new He(a,r)),this._addCollisionDebugVertex(w,E,p,P,k,new He(a,c)),this._addCollisionDebugVertex(w,E,p,P,k,new He(e,c)),_.vertexLength+=4;const L=u.indexArray;L.emplaceBack(v,v+1),L.emplaceBack(v+1,v+2),L.emplaceBack(v+2,v+3),L.emplaceBack(v+3,v),_.primitiveLength+=4}addDebugCollisionBoxes(e,r,a,c){for(let u=e;u<r;u++){const p=this.collisionBoxArray.get(u);this.addCollisionDebugVertices(p.x1,p.y1,p.x2,p.y2,c?this.textCollisionBox:this.iconCollisionBox,p.anchorPoint,a)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Fc(s,_u.members,m),this.iconCollisionBox=new Fc(s,_u.members,m);for(let e=0;e<this.symbolInstances.length;e++){const r=this.symbolInstances.get(e);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(e,r,a,c,u,p,f,_,v){const w={};for(let E=r;E<a;E++){const P=e.get(E);w.textBox={x1:P.x1,y1:P.y1,x2:P.x2,y2:P.y2,anchorPointX:P.anchorPointX,anchorPointY:P.anchorPointY},w.textFeatureIndex=P.featureIndex;break}for(let E=c;E<u;E++){const P=e.get(E);w.verticalTextBox={x1:P.x1,y1:P.y1,x2:P.x2,y2:P.y2,anchorPointX:P.anchorPointX,anchorPointY:P.anchorPointY},w.verticalTextFeatureIndex=P.featureIndex;break}for(let E=p;E<f;E++){const P=e.get(E);w.iconBox={x1:P.x1,y1:P.y1,x2:P.x2,y2:P.y2,anchorPointX:P.anchorPointX,anchorPointY:P.anchorPointY},w.iconFeatureIndex=P.featureIndex;break}for(let E=_;E<v;E++){const P=e.get(E);w.verticalIconBox={x1:P.x1,y1:P.y1,x2:P.x2,y2:P.y2,anchorPointX:P.anchorPointX,anchorPointY:P.anchorPointY},w.verticalIconFeatureIndex=P.featureIndex;break}return w}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let r=0;r<this.symbolInstances.length;r++){const a=this.symbolInstances.get(r);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,a.textBoxStartIndex,a.textBoxEndIndex,a.verticalTextBoxStartIndex,a.verticalTextBoxEndIndex,a.iconBoxStartIndex,a.iconBoxEndIndex,a.verticalIconBoxStartIndex,a.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,r){const a=e.placedSymbolArray.get(r),c=a.vertexStartIndex+4*a.numGlyphs;for(let u=a.vertexStartIndex;u<c;u+=4)e.indexArray.emplaceBack(u,u+1,u+2),e.indexArray.emplaceBack(u+1,u+2,u+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const r=Math.sin(e),a=Math.cos(e),c=[],u=[],p=[];for(let f=0;f<this.symbolInstances.length;++f){p.push(f);const _=this.symbolInstances.get(f);c.push(0|Math.round(r*_.anchorX+a*_.anchorY)),u.push(_.featureIndex)}return p.sort((f,_)=>c[f]-c[_]||u[_]-u[f]),p}addToSortKeyRanges(e,r){const a=this.sortKeyRanges[this.sortKeyRanges.length-1];a&&a.sortKey===r?a.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const r of this.symbolInstanceIndexes){const a=this.symbolInstances.get(r);this.featureSortOrder.push(a.featureIndex),[a.rightJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.leftJustifiedTextSymbolIndex].forEach((c,u,p)=>{c>=0&&p.indexOf(c)===u&&this.addIndicesForPlacedSymbol(this.text,c)}),a.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,a.verticalPlacedTextSymbolIndex),a.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.placedIconSymbolIndex),a.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ke("SymbolBucket",as,{omit:["layers","collisionBoxArray","features","compareText"]}),as.MAX_GLYPHS=65535,as.addDynamicAttributes=Rc;const Lf=new Ii({"symbol-placement":new Oe(le.layout_symbol["symbol-placement"]),"symbol-spacing":new Oe(le.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Oe(le.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ze(le.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Oe(le.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Oe(le.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Oe(le.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Oe(le.layout_symbol["icon-ignore-placement"]),"icon-optional":new Oe(le.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Oe(le.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ze(le.layout_symbol["icon-size"]),"icon-text-fit":new Oe(le.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Oe(le.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ze(le.layout_symbol["icon-image"]),"icon-rotate":new Ze(le.layout_symbol["icon-rotate"]),"icon-padding":new Ze(le.layout_symbol["icon-padding"]),"icon-keep-upright":new Oe(le.layout_symbol["icon-keep-upright"]),"icon-offset":new Ze(le.layout_symbol["icon-offset"]),"icon-anchor":new Ze(le.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Oe(le.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Oe(le.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Oe(le.layout_symbol["text-rotation-alignment"]),"text-field":new Ze(le.layout_symbol["text-field"]),"text-font":new Ze(le.layout_symbol["text-font"]),"text-size":new Ze(le.layout_symbol["text-size"]),"text-max-width":new Ze(le.layout_symbol["text-max-width"]),"text-line-height":new Oe(le.layout_symbol["text-line-height"]),"text-letter-spacing":new Ze(le.layout_symbol["text-letter-spacing"]),"text-justify":new Ze(le.layout_symbol["text-justify"]),"text-radial-offset":new Ze(le.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Oe(le.layout_symbol["text-variable-anchor"]),"text-anchor":new Ze(le.layout_symbol["text-anchor"]),"text-max-angle":new Oe(le.layout_symbol["text-max-angle"]),"text-writing-mode":new Oe(le.layout_symbol["text-writing-mode"]),"text-rotate":new Ze(le.layout_symbol["text-rotate"]),"text-padding":new Oe(le.layout_symbol["text-padding"]),"text-keep-upright":new Oe(le.layout_symbol["text-keep-upright"]),"text-transform":new Ze(le.layout_symbol["text-transform"]),"text-offset":new Ze(le.layout_symbol["text-offset"]),"text-allow-overlap":new Oe(le.layout_symbol["text-allow-overlap"]),"text-overlap":new Oe(le.layout_symbol["text-overlap"]),"text-ignore-placement":new Oe(le.layout_symbol["text-ignore-placement"]),"text-optional":new Oe(le.layout_symbol["text-optional"])});var Oc={paint:new Ii({"icon-opacity":new Ze(le.paint_symbol["icon-opacity"]),"icon-color":new Ze(le.paint_symbol["icon-color"]),"icon-halo-color":new Ze(le.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ze(le.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ze(le.paint_symbol["icon-halo-blur"]),"icon-translate":new Oe(le.paint_symbol["icon-translate"]),"icon-translate-anchor":new Oe(le.paint_symbol["icon-translate-anchor"]),"text-opacity":new Ze(le.paint_symbol["text-opacity"]),"text-color":new Ze(le.paint_symbol["text-color"],{runtimeType:Ti,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new Ze(le.paint_symbol["text-halo-color"]),"text-halo-width":new Ze(le.paint_symbol["text-halo-width"]),"text-halo-blur":new Ze(le.paint_symbol["text-halo-blur"]),"text-translate":new Oe(le.paint_symbol["text-translate"]),"text-translate-anchor":new Oe(le.paint_symbol["text-translate-anchor"])}),layout:Lf};class Gu{constructor(e){if(e.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Hi,this.defaultValue=e}evaluate(e){if(e.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(e.formattedSection))return r.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ke("FormatSectionOverride",Gu,{omit:["defaultValue"]});class kl extends Yi{constructor(e){super(e,Oc)}recalculate(e,r){if(super.recalculate(e,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"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 a=this.layout.get("text-writing-mode");if(a){const c=[];for(const u of a)c.indexOf(u)<0&&c.push(u);this.layout._values["text-writing-mode"]=c}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,r,a,c){const u=this.layout.get(e).evaluate(r,{},a,c),p=this._unevaluatedLayout._values[e];return p.isDataDriven()||Ea(p.value)||!u?u:function(f,_){return _.replace(/{([^{}]+)}/g,(v,w)=>w in f?String(f[w]):"")}(r.properties,u)}createBucket(e){return new as(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Oc.paint.overridableProperties){if(!kl.hasPaintOverride(this.layout,e))continue;const r=this.paint.get(e),a=new Gu(r),c=new Cs(a,r.property.specification);let u=null;u=r.value.kind==="constant"||r.value.kind==="source"?new Ms("source",c):new Ps("composite",c,r.value.zoomStops),this.paint._values[e]=new Ki(r.property,u,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,a){return!(!this.layout||r.isDataDriven()||a.isDataDriven())&&kl.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){const a=e.get("text-field"),c=Oc.paint.properties[r];let u=!1;const p=f=>{for(const _ of f)if(c.overrides&&c.overrides.hasOverride(_))return void(u=!0)};if(a.value.kind==="constant"&&a.value.value instanceof ei)p(a.value.value.sections);else if(a.value.kind==="source"){const f=v=>{u||(v instanceof C&&B(v.value)===ri?p(v.value.sections):v instanceof Ta?p(v.sections):v.eachChild(f))},_=a.value;_._styleExpression&&f(_._styleExpression.expression)}return u}}function Uc(i,e,r){let a="never";const c=i.get(e);return c?a=c:i.get(r)&&(a="always"),a}var Df={paint:new Ii({"background-color":new Oe(le.paint_background["background-color"]),"background-pattern":new qs(le.paint_background["background-pattern"]),"background-opacity":new Oe(le.paint_background["background-opacity"])})},Rf={paint:new Ii({"raster-opacity":new Oe(le.paint_raster["raster-opacity"]),"raster-hue-rotate":new Oe(le.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Oe(le.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Oe(le.paint_raster["raster-brightness-max"]),"raster-saturation":new Oe(le.paint_raster["raster-saturation"]),"raster-contrast":new Oe(le.paint_raster["raster-contrast"]),"raster-resampling":new Oe(le.paint_raster["raster-resampling"]),"raster-fade-duration":new Oe(le.paint_raster["raster-fade-duration"])})};class Bf extends Yi{constructor(e){super(e,{}),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=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}const Ff={circle:class extends Yi{constructor(i){super(i,mc)}createBucket(i){return new Ji(i)}queryRadius(i){const e=i;return nn("circle-radius",this,e)+nn("circle-stroke-width",this,e)+Ya(this.paint.get("circle-translate"))}queryIntersectsFeature(i,e,r,a,c,u,p,f){const _=Ja(i,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),u.angle,p),v=this.paint.get("circle-radius").evaluate(e,r)+this.paint.get("circle-stroke-width").evaluate(e,r),w=this.paint.get("circle-pitch-alignment")==="map",E=w?_:function(k,L){return k.map($=>eu($,L))}(_,f),P=w?v*p:v;for(const k of a)for(const L of k){const $=w?L:eu(L,f);let N=P;const J=_l([],[L.x,L.y,0,1],f);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?N*=J[3]/u.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(N*=u.cameraToCenterDistance/J[3]),Ka(E,$,N))return!0}return!1}},heatmap:class extends Yi{createBucket(i){return new tu(i)}constructor(i){super(i,fm),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){i==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=ru({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}},hillshade:class extends Yi{constructor(i){super(i,gm)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}},fill:class extends Yi{constructor(i){super(i,zm)}recalculate(i,e){super.recalculate(i,e);const r=this.paint._values["fill-outline-color"];r.value.kind==="constant"&&r.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new Sc(i)}queryRadius(){return Ya(this.paint.get("fill-translate"))}queryIntersectsFeature(i,e,r,a,c,u,p){return qt(Ja(i,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),u.angle,p),a)}isTileClipped(){return!0}},"fill-extrusion":class extends Yi{constructor(i){super(i,Zm)}createBucket(i){return new Ic(i)}queryRadius(){return Ya(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(i,e,r,a,c,u,p,f){const _=Ja(i,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),u.angle,p),v=this.paint.get("fill-extrusion-height").evaluate(e,r),w=this.paint.get("fill-extrusion-base").evaluate(e,r),E=function(k,L,$,N){const J=[];for(const ne of k){const K=[ne.x,ne.y,0,1];_l(K,K,L),J.push(new He(K[0]/K[3],K[1]/K[3]))}return J}(_,f),P=function(k,L,$,N){const J=[],ne=[],K=N[8]*L,re=N[9]*L,ge=N[10]*L,fe=N[11]*L,De=N[8]*$,Fe=N[9]*$,Me=N[10]*$,Ie=N[11]*$;for(const Te of k){const Pe=[],Ce=[];for(const be of Te){const $e=be.x,Ue=be.y,it=N[0]*$e+N[4]*Ue+N[12],kt=N[1]*$e+N[5]*Ue+N[13],Bt=N[2]*$e+N[6]*Ue+N[14],Kt=N[3]*$e+N[7]*Ue+N[15],ir=Bt+ge,ai=Kt+fe,Zt=it+De,Jt=kt+Fe,si=Bt+Me,vi=Kt+Ie,zi=new He((it+K)/ai,(kt+re)/ai);zi.z=ir/ai,Pe.push(zi);const Xt=new He(Zt/vi,Jt/vi);Xt.z=si/vi,Ce.push(Xt)}J.push(Pe),ne.push(Ce)}return[J,ne]}(a,w,v,f);return function(k,L,$){let N=1/0;qt($,L)&&(N=du($,L[0]));for(let J=0;J<L.length;J++){const ne=L[J],K=k[J];for(let re=0;re<ne.length-1;re++){const ge=ne[re],fe=[ge,ne[re+1],K[re+1],K[re],ge];Rr($,fe)&&(N=Math.min(N,du($,fe)))}}return N!==1/0&&N}(P[0],P[1],E)}},line:class extends Yi{constructor(i){super(i,mu),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(i){i==="line-gradient"&&(this.stepInterpolant=this._transitionablePaint._values["line-gradient"].value.expression._styleExpression.expression instanceof qn,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER)}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(i,e){super.recalculate(i,e),this.paint._values["line-floorwidth"]=fu.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,i)}createBucket(i){return new Ac(i)}queryRadius(i){const e=i,r=gu(nn("line-width",this,e),nn("line-gap-width",this,e)),a=nn("line-offset",this,e);return r/2+Math.abs(a)+Ya(this.paint.get("line-translate"))}queryIntersectsFeature(i,e,r,a,c,u,p){const f=Ja(i,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),u.angle,p),_=p/2*gu(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),v=this.paint.get("line-offset").evaluate(e,r);return v&&(a=function(w,E){const P=[];for(let k=0;k<w.length;k++){const L=w[k],$=[];for(let N=0;N<L.length;N++){const J=L[N-1],ne=L[N],K=L[N+1],re=N===0?new He(0,0):ne.sub(J)._unit()._perp(),ge=N===L.length-1?new He(0,0):K.sub(ne)._unit()._perp(),fe=re._add(ge)._unit(),De=fe.x*ge.x+fe.y*ge.y;De!==0&&fe._mult(1/De),$.push(fe._mult(E)._add(ne))}P.push($)}return P}(a,v*p)),function(w,E,P){for(let k=0;k<E.length;k++){const L=E[k];if(w.length>=3){for(let $=0;$<L.length;$++)if(Qi(w,L[$]))return!0}if(Dt(w,L,P))return!0}return!1}(f,a,_)}isTileClipped(){return!0}},symbol:kl,background:class extends Yi{constructor(i){super(i,Df)}},raster:class extends Yi{constructor(i){super(i,Rf)}}};class Of{constructor(e){this._callback=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){delete this._channel,this._callback=()=>{}}}const Vc=63710088e-1;class Vt{constructor(e,r){if(isNaN(e)||isNaN(r))throw new Error(`Invalid LngLat object: (${e}, ${r})`);if(this.lng=+e,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 Vt(ee(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const r=Math.PI/180,a=this.lat*r,c=e.lat*r,u=Math.sin(a)*Math.sin(c)+Math.cos(a)*Math.cos(c)*Math.cos((e.lng-this.lng)*r);return Vc*Math.acos(Math.min(u,1))}toBounds(e=0){const r=360*e/40075017,a=r/Math.cos(Math.PI/180*this.lat);return new ju(new Vt(this.lng-a,this.lat-r),new Vt(this.lng+a,this.lat+r))}static convert(e){if(e instanceof Vt)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Vt(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new Vt(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}class ss{constructor(e,r){e&&(r?this.setSouthWest(e).setNorthEast(r):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 Vt?new Vt(e.lng,e.lat):Vt.convert(e),this}setSouthWest(e){return this._sw=e instanceof Vt?new Vt(e.lng,e.lat):Vt.convert(e),this}extend(e){const r=this._sw,a=this._ne;let c,u;if(e instanceof Vt)c=e,u=e;else{if(!(e instanceof ss))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(ss.convert(e)):this.extend(Vt.convert(e)):this;if(c=e._sw,u=e._ne,!c||!u)return this}return r||a?(r.lng=Math.min(c.lng,r.lng),r.lat=Math.min(c.lat,r.lat),a.lng=Math.max(u.lng,a.lng),a.lat=Math.max(u.lat,a.lat)):(this._sw=new Vt(c.lng,c.lat),this._ne=new Vt(u.lng,u.lat)),this}getCenter(){return new Vt((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 Vt(this.getWest(),this.getNorth())}getSouthEast(){return new Vt(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:r,lat:a}=Vt.convert(e);let c=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(c=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=a&&a<=this._ne.lat&&c}static convert(e){return e instanceof ss?e:e&&new ss(e)}}var ju=ss;const qu=2*Math.PI*Vc;function Zu(i){return qu*Math.cos(i*Math.PI/180)}function Xu(i){return(180+i)/360}function Wu(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function Hu(i,e){return i/Zu(e)}function Nc(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class zl{constructor(e,r,a=0){this.x=+e,this.y=+r,this.z=+a}static fromLngLat(e,r=0){const a=Vt.convert(e);return new zl(Xu(a.lng),Wu(a.lat),Hu(r,a.lat))}toLngLat(){return new Vt(360*this.x-180,Nc(this.y))}toAltitude(){return this.z*Zu(Nc(this.y))}meterInMercatorCoordinateUnits(){return 1/qu*(e=Nc(this.y),1/Math.cos(e*Math.PI/180));var e}}function Ku(i,e,r){var a=2*Math.PI*6378137/256/Math.pow(2,r);return[i*a-2*Math.PI*6378137/2,e*a-2*Math.PI*6378137/2]}class $c{constructor(e,r,a){if(e<0||e>25||a<0||a>=Math.pow(2,e)||r<0||r>=Math.pow(2,e))throw new Error(`x=${r}, y=${a}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=r,this.y=a,this.key=vo(0,e,e,r,a)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,r,a){const c=(p=this.y,f=this.z,_=Ku(256*(u=this.x),256*(p=Math.pow(2,f)-p-1),f),v=Ku(256*(u+1),256*(p+1),f),_[0]+","+_[1]+","+v[0]+","+v[1]);var u,p,f,_,v;const w=function(E,P,k){let L,$="";for(let N=E;N>0;N--)L=1<<N-1,$+=(P&L?1:0)+(k&L?2:0);return $}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(a==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,r>1?"@2x":"").replace(/{quadkey}/g,w).replace(/{bbox-epsg-3857}/g,c)}isChildOf(e){const r=this.z-e.z;return r>0&&e.x===this.x>>r&&e.y===this.y>>r}getTilePoint(e){const r=Math.pow(2,this.z);return new He((e.x*r-this.x)*gt,(e.y*r-this.y)*gt)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Yu{constructor(e,r){this.wrap=e,this.canonical=r,this.key=vo(e,r.z,r.z,r.x,r.y)}}class tr{constructor(e,r,a,c,u){if(e<a)throw new Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${a}`);this.overscaledZ=e,this.wrap=r,this.canonical=new $c(a,+c,+u),this.key=vo(r,e,a,c,u)}clone(){return new tr(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-e;return e>this.canonical.z?new tr(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new tr(e,this.wrap,e,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(e,r){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const a=this.canonical.z-e;return e>this.canonical.z?vo(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y):vo(this.wrap*+r,e,e,this.canonical.x>>a,this.canonical.y>>a)}isChildOf(e){if(e.wrap!==this.wrap)return!1;const r=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ<this.overscaledZ&&e.canonical.x===this.canonical.x>>r&&e.canonical.y===this.canonical.y>>r}children(e){if(this.overscaledZ>=e)return[new tr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,a=2*this.canonical.x,c=2*this.canonical.y;return[new tr(r,this.wrap,r,a,c),new tr(r,this.wrap,r,a+1,c),new tr(r,this.wrap,r,a,c+1),new tr(r,this.wrap,r,a+1,c+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new tr(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new tr(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Yu(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new zl(e.x-this.wrap,e.y))}}function vo(i,e,r,a,c){(i*=2)<0&&(i=-1*i-1);const u=1<<r;return(u*u*i+u*c+a).toString(36)+r.toString(36)+e.toString(36)}ke("CanonicalTileID",$c),ke("OverscaledTileID",tr,{omit:["posMatrix"]});class Ju{constructor(e,r,a){if(this.uid=e,r.height!==r.width)throw new RangeError("DEM tiles must be square");if(a&&a!=="mapbox"&&a!=="terrarium")return void dt(`"${a}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=r.height;const c=this.dim=r.height-2;this.data=new Uint32Array(r.data.buffer),this.encoding=a||"mapbox";for(let u=0;u<c;u++)this.data[this._idx(-1,u)]=this.data[this._idx(0,u)],this.data[this._idx(c,u)]=this.data[this._idx(c-1,u)],this.data[this._idx(u,-1)]=this.data[this._idx(u,0)],this.data[this._idx(u,c)]=this.data[this._idx(u,c-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(c,-1)]=this.data[this._idx(c-1,0)],this.data[this._idx(-1,c)]=this.data[this._idx(0,c-1)],this.data[this._idx(c,c)]=this.data[this._idx(c-1,c-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let u=0;u<c;u++)for(let p=0;p<c;p++){const f=this.get(u,p);f>this.max&&(this.max=f),f<this.min&&(this.min=f)}}get(e,r){const a=new Uint8Array(this.data.buffer),c=4*this._idx(e,r);return(this.encoding==="terrarium"?this._unpackTerrarium:this._unpackMapbox)(a[c],a[c+1],a[c+2])}getUnpackVector(){return this.encoding==="terrarium"?[256,1,1/256,32768]:[6553.6,25.6,.1,1e4]}_idx(e,r){if(e<-1||e>=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+(e+1)}_unpackMapbox(e,r,a){return(256*e*256+256*r+a)/10-1e4}_unpackTerrarium(e,r,a){return 256*e+r+a/256-32768}getPixels(){return new er({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,r,a){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let c=r*this.dim,u=r*this.dim+this.dim,p=a*this.dim,f=a*this.dim+this.dim;switch(r){case-1:c=u-1;break;case 1:u=c+1}switch(a){case-1:p=f-1;break;case 1:f=p+1}const _=-r*this.dim,v=-a*this.dim;for(let w=p;w<f;w++)for(let E=c;E<u;E++)this.data[this._idx(E,w)]=e.data[this._idx(E+_,w+v)]}}ke("DEMData",Ju);class Qu{constructor(e){this._stringToNumber={},this._numberToString=[];for(let r=0;r<e.length;r++){const a=e[r];this._stringToNumber[a]=r,this._numberToString[r]=a}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class ed{constructor(e,r,a,c,u){this.type="Feature",this._vectorTileFeature=e,e._z=r,e._x=a,e._y=c,this.properties=e.properties,this.id=u}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const r in this)r!=="_geometry"&&r!=="_vectorTileFeature"&&(e[r]=this[r]);return e}}class td{constructor(e,r){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Pn(gt,16,0),this.grid3D=new Pn(gt,16,0),this.featureIndexArray=new fl,this.promoteId=r}insert(e,r,a,c,u,p){const f=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(a,c,u);const _=p?this.grid3D:this.grid;for(let v=0;v<r.length;v++){const w=r[v],E=[1/0,1/0,-1/0,-1/0];for(let P=0;P<w.length;P++){const k=w[P];E[0]=Math.min(E[0],k.x),E[1]=Math.min(E[1],k.y),E[2]=Math.max(E[2],k.x),E[3]=Math.max(E[3],k.y)}E[0]<gt&&E[1]<gt&&E[2]>=0&&E[3]>=0&&_.insert(f,E[0],E[1],E[2],E[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Bn.VectorTile(new Cc(this.rawTileData)).layers,this.sourceLayerCoder=new Qu(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(e,r,a,c){this.loadVTLayers();const u=e.params||{},p=gt/e.tileSize/e.scale,f=zs(u.filter),_=e.queryGeometry,v=e.queryPadding*p,w=rd(_),E=this.grid.query(w.minX-v,w.minY-v,w.maxX+v,w.maxY+v),P=rd(e.cameraQueryGeometry),k=this.grid3D.query(P.minX-v,P.minY-v,P.maxX+v,P.maxY+v,(N,J,ne,K)=>function(re,ge,fe,De,Fe){for(const Ie of re)if(ge<=Ie.x&&fe<=Ie.y&&De>=Ie.x&&Fe>=Ie.y)return!0;const Me=[new He(ge,fe),new He(ge,Fe),new He(De,Fe),new He(De,fe)];if(re.length>2){for(const Ie of Me)if(Qi(re,Ie))return!0}for(let Ie=0;Ie<re.length-1;Ie++)if(oo(re[Ie],re[Ie+1],Me))return!0;return!1}(e.cameraQueryGeometry,N-v,J-v,ne+v,K+v));for(const N of k)E.push(N);E.sort(Uf);const L={};let $;for(let N=0;N<E.length;N++){const J=E[N];if(J===$)continue;$=J;const ne=this.featureIndexArray.get(J);let K=null;this.loadMatchingFeature(L,ne.bucketIndex,ne.sourceLayerIndex,ne.featureIndex,f,u.layers,u.availableImages,r,a,c,(re,ge,fe)=>(K||(K=ni(re)),ge.queryIntersectsFeature(_,re,fe,K,this.z,e.transform,p,e.pixelPosMatrix)))}return L}loadMatchingFeature(e,r,a,c,u,p,f,_,v,w,E){const P=this.bucketLayerIDs[r];if(p&&!function(N,J){for(let ne=0;ne<N.length;ne++)if(J.indexOf(N[ne])>=0)return!0;return!1}(p,P))return;const k=this.sourceLayerCoder.decode(a),L=this.vtLayers[k].feature(c);if(u.needGeometry){const N=ki(L,!0);if(!u.filter(new Pt(this.tileID.overscaledZ),N,this.tileID.canonical))return}else if(!u.filter(new Pt(this.tileID.overscaledZ),L))return;const $=this.getId(L,k);for(let N=0;N<P.length;N++){const J=P[N];if(p&&p.indexOf(J)<0)continue;const ne=_[J];if(!ne)continue;let K={};$&&w&&(K=w.getState(ne.sourceLayer||"_geojsonTileLayer",$));const re=Be({},v[J]);re.paint=id(re.paint,ne.paint,L,K,f),re.layout=id(re.layout,ne.layout,L,K,f);const ge=!E||E(L,ne,K);if(!ge)continue;const fe=new ed(L,this.z,this.x,this.y,$);fe.layer=re;let De=e[J];De===void 0&&(De=e[J]=[]),De.push({featureIndex:c,feature:fe,intersectionZ:ge})}}lookupSymbolFeatures(e,r,a,c,u,p,f,_){const v={};this.loadVTLayers();const w=zs(u);for(const E of e)this.loadMatchingFeature(v,a,c,E,w,p,f,_,r);return v}hasLayer(e){for(const r of this.bucketLayerIDs)for(const a of r)if(e===a)return!0;return!1}getId(e,r){let a=e.id;return this.promoteId&&(a=e.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[r]],typeof a=="boolean"&&(a=Number(a))),a}}function id(i,e,r,a,c){return mr(i,(u,p)=>{const f=e instanceof Ua?e.get(p):null;return f&&f.evaluate?f.evaluate(r,a,c):f})}function rd(i){let e=1/0,r=1/0,a=-1/0,c=-1/0;for(const u of i)e=Math.min(e,u.x),r=Math.min(r,u.y),a=Math.max(a,u.x),c=Math.max(c,u.y);return{minX:e,minY:r,maxX:a,maxY:c}}function Uf(i,e){return e-i}function Gc(i,e,r,a,c,u){if(c-a<=r)return;const p=a+c>>1;nd(i,e,p,a,c,u%2),Gc(i,e,r,a,p-1,u+1),Gc(i,e,r,p+1,c,u+1)}function nd(i,e,r,a,c,u){for(;c>a;){if(c-a>600){const v=c-a+1,w=r-a+1,E=Math.log(v),P=.5*Math.exp(2*E/3),k=.5*Math.sqrt(E*P*(v-P)/v)*(w-v/2<0?-1:1);nd(i,e,r,Math.max(a,Math.floor(r-w*P/v+k)),Math.min(c,Math.floor(r+(v-w)*P/v+k)),u)}const p=e[2*r+u];let f=a,_=c;for(bo(i,e,a,r),e[2*c+u]>p&&bo(i,e,a,c);f<_;){for(bo(i,e,f,_),f++,_--;e[2*f+u]<p;)f++;for(;e[2*_+u]>p;)_--}e[2*a+u]===p?bo(i,e,a,_):(_++,bo(i,e,_,c)),_<=r&&(a=_+1),r<=_&&(c=_-1)}}function bo(i,e,r,a){jc(i,r,a),jc(e,2*r,2*a),jc(e,2*r+1,2*a+1)}function jc(i,e,r){const a=i[e];i[e]=i[r],i[r]=a}function ad(i,e,r,a){const c=i-r,u=e-a;return c*c+u*u}ke("FeatureIndex",td,{omit:["rawTileData","sourceLayerCoder"]});const Vf=i=>i[0],Nf=i=>i[1];var qc;h.PerformanceMarkers=void 0,(qc=h.PerformanceMarkers||(h.PerformanceMarkers={})).create="create",qc.load="load",qc.fullLoad="fullLoad";let Ll=null,wo=[];const Zc=1e3/30,$f={mark(i){performance.mark(i)},frame(i){const e=i;Ll!=null&&wo.push(e-Ll),Ll=e},clearMetrics(){Ll=null,wo=[],performance.clearMeasures("loadTime"),performance.clearMeasures("fullLoadTime");for(const i in h.PerformanceMarkers)performance.clearMarks(h.PerformanceMarkers[i])},getPerformanceMetrics(){performance.measure("loadTime",h.PerformanceMarkers.create,h.PerformanceMarkers.load),performance.measure("fullLoadTime",h.PerformanceMarkers.create,h.PerformanceMarkers.fullLoad);const i=performance.getEntriesByName("loadTime")[0].duration,e=performance.getEntriesByName("fullLoadTime")[0].duration,r=wo.length,a=1/(wo.reduce((u,p)=>u+p,0)/r/1e3),c=wo.filter(u=>u>Zc).reduce((u,p)=>u+(p-Zc)/Zc,0);return{loadTime:i,fullLoadTime:e,fps:a,percentDroppedFrames:c/(r+c)*100}}};h.AJAXError=Er,h.ARRAY_TYPE=Br,h.Actor=class{constructor(i,e,r){this.target=i,this.parent=e,this.mapId=r,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},Ft(["receive","process"],this),this.invoker=new Of(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=Oi()?i:window}send(i,e,r,a,c=!1){const u=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(this.callbacks[u]=r);const p=fr(this.globalScope)?void 0:[];return this.target.postMessage({id:u,type:i,hasCallback:!!r,targetMapId:a,mustQueue:c,sourceMapId:this.mapId,data:Qr(e,p)},p),{cancel:()=>{r&&delete this.callbacks[u],this.target.postMessage({id:u,type:"<cancel>",targetMapId:a,sourceMapId:this.mapId})}}}receive(i){const e=i.data,r=e.id;if(r&&(!e.targetMapId||this.mapId===e.targetMapId))if(e.type==="<cancel>"){delete this.tasks[r];const a=this.cancelCallbacks[r];delete this.cancelCallbacks[r],a&&a()}else Oi()||e.mustQueue?(this.tasks[r]=e,this.taskQueue.push(r),this.invoker.trigger()):this.processTask(r,e)}process(){if(!this.taskQueue.length)return;const i=this.taskQueue.shift(),e=this.tasks[i];delete this.tasks[i],this.taskQueue.length&&this.invoker.trigger(),e&&this.processTask(i,e)}processTask(i,e){if(e.type==="<response>"){const r=this.callbacks[i];delete this.callbacks[i],r&&(e.error?r(en(e.error)):r(null,en(e.data)))}else{let r=!1;const a=fr(this.globalScope)?void 0:[],c=e.hasCallback?(f,_)=>{r=!0,delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"<response>",sourceMapId:this.mapId,error:f?Qr(f):null,data:Qr(_,a)},a)}:f=>{r=!0};let u=null;const p=en(e.data);if(this.parent[e.type])u=this.parent[e.type](e.sourceMapId,p,c);else if(this.parent.getWorkerSource){const f=e.type.split(".");u=this.parent.getWorkerSource(e.sourceMapId,f[0],p.source)[f[1]](p,c)}else c(new Error(`Could not find function ${e.type}`));!r&&u&&u.cancel&&(this.cancelCallbacks[i]=u.cancel)}}remove(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)}},h.AlphaImage=co,h.CanonicalTileID=$c,h.CollisionBoxArray=no,h.CollisionCircleLayoutArray=class extends Js{},h.Color=ut,h.DEMData=Ju,h.DataConstantProperty=Oe,h.DictionaryCoder=Qu,h.EXTENT=gt,h.ErrorEvent=Gr,h.EvaluationParameters=Pt,h.Event=$r,h.Evented=Ir,h.FeatureIndex=td,h.FillBucket=Sc,h.FillExtrusionBucket=Ic,h.GeoJSONFeature=ed,h.ImageAtlas=Eu,h.ImagePosition=Pc,h.KDBush=class{constructor(i,e=Vf,r=Nf,a=64,c=Float64Array){this.nodeSize=a,this.points=i;const u=i.length<65536?Uint16Array:Uint32Array,p=this.ids=new u(i.length),f=this.coords=new c(2*i.length);for(let _=0;_<i.length;_++)p[_]=_,f[2*_]=e(i[_]),f[2*_+1]=r(i[_]);Gc(p,f,a,0,p.length-1,0)}range(i,e,r,a){return function(c,u,p,f,_,v,w){const E=[0,c.length-1,0],P=[];let k,L;for(;E.length;){const $=E.pop(),N=E.pop(),J=E.pop();if(N-J<=w){for(let re=J;re<=N;re++)k=u[2*re],L=u[2*re+1],k>=p&&k<=_&&L>=f&&L<=v&&P.push(c[re]);continue}const ne=Math.floor((J+N)/2);k=u[2*ne],L=u[2*ne+1],k>=p&&k<=_&&L>=f&&L<=v&&P.push(c[ne]);const K=($+1)%2;($===0?p<=k:f<=L)&&(E.push(J),E.push(ne-1),E.push(K)),($===0?_>=k:v>=L)&&(E.push(ne+1),E.push(N),E.push(K))}return P}(this.ids,this.coords,i,e,r,a,this.nodeSize)}within(i,e,r){return function(a,c,u,p,f,_){const v=[0,a.length-1,0],w=[],E=f*f;for(;v.length;){const P=v.pop(),k=v.pop(),L=v.pop();if(k-L<=_){for(let K=L;K<=k;K++)ad(c[2*K],c[2*K+1],u,p)<=E&&w.push(a[K]);continue}const $=Math.floor((L+k)/2),N=c[2*$],J=c[2*$+1];ad(N,J,u,p)<=E&&w.push(a[$]);const ne=(P+1)%2;(P===0?u-f<=N:p-f<=J)&&(v.push(L),v.push($-1),v.push(ne)),(P===0?u+f>=N:p+f>=J)&&(v.push($+1),v.push(k),v.push(ne))}return w}(this.ids,this.coords,i,e,r,this.nodeSize)}},h.LineBucket=Ac,h.LineStripIndexArray=class extends Xa{},h.LngLat=Vt,h.LngLatBounds=ju,h.MercatorCoordinate=zl,h.ONE_EM=ii,h.OverscaledTileID=tr,h.PerformanceUtils=$f,h.Pos3dArray=class extends $a{},h.PosArray=so,h.Properties=Ii,h.QuadTriangleArray=class extends qa{},h.RGBAImage=er,h.RasterBoundsArray=class extends Dn{},h.RequestPerformance=class{constructor(i){this._marks={start:[i.url,"start"].join("#"),end:[i.url,"end"].join("#"),measure:i.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let i=performance.getEntriesByName(this._marks.measure);return i.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),i=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),i}},h.SegmentVector=x,h.SymbolBucket=as,h.Transitionable=js,h.TriangleIndexArray=d,h.Uniform1f=ue,h.Uniform1i=class extends se{constructor(i,e){super(i,e),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},h.Uniform2f=class extends se{constructor(i,e){super(i,e),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},h.Uniform3f=class extends se{constructor(i,e){super(i,e),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},h.Uniform4f=me,h.UniformColor=xe,h.UniformMatrix4f=class extends se{constructor(i,e){super(i,e),this.current=_e}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let e=1;e<16;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},h.UnwrappedTileID=Yu,h.ValidationError=Se,h.ZoomHistory=ol,h.addDynamicAttributes=Rc,h.arrayBufferToImage=function(i,e){const r=new Image;r.onload=()=>{e(null,r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame(()=>{r.src=da})},r.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const a=new Blob([new Uint8Array(i)],{type:"image/png"});r.src=i.byteLength?URL.createObjectURL(a):da},h.arrayBufferToImageBitmap=function(i,e){const r=new Blob([new Uint8Array(i)],{type:"image/png"});createImageBitmap(r).then(a=>{e(null,a)}).catch(a=>{e(new Error(`Could not load image because of ${a.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})},h.asyncAll=function(i,e,r){if(!i.length)return r(null,[]);let a=i.length;const c=new Array(i.length);let u=null;i.forEach((p,f)=>{e(p,(_,v)=>{_&&(u=_),c[f]=v,--a==0&&r(u,c)})})},h.bezier=et,h.bindAll=Ft,h.clamp=pe,h.clipLine=Fu,h.clone=function(i){var e=new Br(16);return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],e},h.clone$1=Ci,h.collisionCircleLayout=nf,h.config=Ur,h.copy=function(i,e){return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},h.create=function(){var i=new Br(16);return Br!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},h.createExpression=Ia,h.createFilter=zs,h.createLayout=jt,h.createStyleLayer=function(i){return i.type==="custom"?new Bf(i):new Ff[i.type](i)},h.dot=function(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]+i[3]*e[3]},h.earthRadius=Vc,h.ease=Ye,h.emitValidationErrors=Fs,h.equals=function(i,e){var r=i[0],a=i[1],c=i[2],u=i[3],p=i[4],f=i[5],_=i[6],v=i[7],w=i[8],E=i[9],P=i[10],k=i[11],L=i[12],$=i[13],N=i[14],J=i[15],ne=e[0],K=e[1],re=e[2],ge=e[3],fe=e[4],De=e[5],Fe=e[6],Me=e[7],Ie=e[8],Te=e[9],Pe=e[10],Ce=e[11],be=e[12],$e=e[13],Ue=e[14],it=e[15];return Math.abs(r-ne)<=Ht*Math.max(1,Math.abs(r),Math.abs(ne))&&Math.abs(a-K)<=Ht*Math.max(1,Math.abs(a),Math.abs(K))&&Math.abs(c-re)<=Ht*Math.max(1,Math.abs(c),Math.abs(re))&&Math.abs(u-ge)<=Ht*Math.max(1,Math.abs(u),Math.abs(ge))&&Math.abs(p-fe)<=Ht*Math.max(1,Math.abs(p),Math.abs(fe))&&Math.abs(f-De)<=Ht*Math.max(1,Math.abs(f),Math.abs(De))&&Math.abs(_-Fe)<=Ht*Math.max(1,Math.abs(_),Math.abs(Fe))&&Math.abs(v-Me)<=Ht*Math.max(1,Math.abs(v),Math.abs(Me))&&Math.abs(w-Ie)<=Ht*Math.max(1,Math.abs(w),Math.abs(Ie))&&Math.abs(E-Te)<=Ht*Math.max(1,Math.abs(E),Math.abs(Te))&&Math.abs(P-Pe)<=Ht*Math.max(1,Math.abs(P),Math.abs(Pe))&&Math.abs(k-Ce)<=Ht*Math.max(1,Math.abs(k),Math.abs(Ce))&&Math.abs(L-be)<=Ht*Math.max(1,Math.abs(L),Math.abs(be))&&Math.abs($-$e)<=Ht*Math.max(1,Math.abs($),Math.abs($e))&&Math.abs(N-Ue)<=Ht*Math.max(1,Math.abs(N),Math.abs(Ue))&&Math.abs(J-it)<=Ht*Math.max(1,Math.abs(J),Math.abs(it))},h.evaluateSizeForFeature=function(i,{uSize:e,uSizeT:r},{lowerSize:a,upperSize:c}){return i.kind==="source"?a/sn:i.kind==="composite"?zt(a/sn,c/sn,r):e},h.evaluateSizeForZoom=function(i,e){let r=0,a=0;if(i.kind==="constant")a=i.layoutSize;else if(i.kind!=="source"){const{interpolationType:c,minZoom:u,maxZoom:p}=i,f=c?pe(Pi.interpolationFactor(c,e,u,p),0,1):0;i.kind==="camera"?a=zt(i.minSize,i.maxSize,f):r=f}return{uSizeT:r,uSize:a}},h.evaluateVariableOffset=Vu,h.evented=Gs,h.exported=pa,h.extend=Be,h.filterObject=dn,h.fromScaling=function(i,e){return i[0]=e[0],i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=e[1],i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=e[2],i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},h.getAnchorAlignment=zc,h.getAnchorJustification=Dc,h.getArrayBuffer=Vr,h.getJSON=function(i,e){return mn(Be(i,{type:"json"}),e)},h.getOverlapMode=Uc,h.getRTLTextPluginStatus=tn,h.getReferrer=ar,h.getVideo=function(i,e){const r=window.document.createElement("video");r.muted=!0,r.onloadstart=function(){e(null,r)};for(let a=0;a<i.length;a++){const c=window.document.createElement("source");$n(i[a])||(r.crossOrigin="Anonymous"),c.src=i[a],r.appendChild(c)}return{cancel:()=>{}}},h.identity=fc,h.invert=function(i,e){var r=e[0],a=e[1],c=e[2],u=e[3],p=e[4],f=e[5],_=e[6],v=e[7],w=e[8],E=e[9],P=e[10],k=e[11],L=e[12],$=e[13],N=e[14],J=e[15],ne=r*f-a*p,K=r*_-c*p,re=r*v-u*p,ge=a*_-c*f,fe=a*v-u*f,De=c*v-u*_,Fe=w*$-E*L,Me=w*N-P*L,Ie=w*J-k*L,Te=E*N-P*$,Pe=E*J-k*$,Ce=P*J-k*N,be=ne*Ce-K*Pe+re*Te+ge*Ie-fe*Me+De*Fe;return be?(i[0]=(f*Ce-_*Pe+v*Te)*(be=1/be),i[1]=(c*Pe-a*Ce-u*Te)*be,i[2]=($*De-N*fe+J*ge)*be,i[3]=(P*fe-E*De-k*ge)*be,i[4]=(_*Ie-p*Ce-v*Me)*be,i[5]=(r*Ce-c*Ie+u*Me)*be,i[6]=(N*re-L*De-J*K)*be,i[7]=(w*De-P*re+k*K)*be,i[8]=(p*Pe-f*Ie+v*Fe)*be,i[9]=(a*Ie-r*Pe-u*Fe)*be,i[10]=(L*fe-$*re+J*ne)*be,i[11]=(E*re-w*fe-k*ne)*be,i[12]=(f*Me-p*Te-_*Fe)*be,i[13]=(r*Te-a*Me+c*Fe)*be,i[14]=($*K-L*ge-N*ne)*be,i[15]=(w*ge-E*K+P*ne)*be,i):null},h.isImageBitmap=gr,h.isSafari=fr,h.isWorker=Oi,h.keysDifference=function(i,e){const r=[];for(const a in i)a in e||r.push(a);return r},h.lazyLoadRTLTextPlugin=function(){Ei.isLoading()||Ei.isLoaded()||tn()!=="deferred"||hl()},h.makeRequest=mn,h.mapObject=mr,h.mercatorXfromLng=Xu,h.mercatorYfromLat=Wu,h.mercatorZfromAltitude=Hu,h.mul=mm,h.mul$1=function(i,e,r){return i[0]=e[0]*r[0],i[1]=e[1]*r[1],i[2]=e[2]*r[2],i[3]=e[3]*r[3],i},h.multiply=Qh,h.nextPowerOfTwo=function(i){return i<=1?1:Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))},h.number=zt,h.ortho=function(i,e,r,a,c,u,p){var f=1/(e-r),_=1/(a-c),v=1/(u-p);return i[0]=-2*f,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*_,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*v,i[11]=0,i[12]=(e+r)*f,i[13]=(c+a)*_,i[14]=(p+u)*v,i[15]=1,i},h.parseCacheControl=function(i){const e={};if(i.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(r,a,c,u)=>{const p=c||u;return e[a]=!p||p.toLowerCase(),""}),e["max-age"]){const r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e},h.parseGlyphPbf=function(i){return new Cc(i).readFields(ff,[])},h.pbf=Cc,h.performSymbolLayout=function(i){i.bucket.createArrays(),i.bucket.tilePixelRatio=gt/(512*i.bucket.overscaling),i.bucket.compareText={},i.bucket.iconsNeedLinear=!1;const e=i.bucket.layers[0].layout,r=i.bucket.layers[0]._unevaluatedLayout._values,a={layoutIconSize:r["icon-size"].possiblyEvaluate(new Pt(i.bucket.zoom+1),i.canonical),layoutTextSize:r["text-size"].possiblyEvaluate(new Pt(i.bucket.zoom+1),i.canonical),textMaxSize:r["text-size"].possiblyEvaluate(new Pt(18))};if(i.bucket.textSizeData.kind==="composite"){const{minZoom:_,maxZoom:v}=i.bucket.textSizeData;a.compositeTextSizes=[r["text-size"].possiblyEvaluate(new Pt(_),i.canonical),r["text-size"].possiblyEvaluate(new Pt(v),i.canonical)]}if(i.bucket.iconSizeData.kind==="composite"){const{minZoom:_,maxZoom:v}=i.bucket.iconSizeData;a.compositeIconSizes=[r["icon-size"].possiblyEvaluate(new Pt(_),i.canonical),r["icon-size"].possiblyEvaluate(new Pt(v),i.canonical)]}const c=e.get("text-line-height")*ii,u=e.get("text-rotation-alignment")!=="viewport"&&e.get("symbol-placement")!=="point",p=e.get("text-keep-upright"),f=e.get("text-size");for(const _ of i.bucket.features){const v=e.get("text-font").evaluate(_,{},i.canonical).join(","),w=f.evaluate(_,{},i.canonical),E=a.layoutTextSize.evaluate(_,{},i.canonical),P=a.layoutIconSize.evaluate(_,{},i.canonical),k={horizontal:{},vertical:void 0},L=_.text;let $,N=[0,0];if(L){const K=L.toString(),re=e.get("text-letter-spacing").evaluate(_,{},i.canonical)*ii,ge=lc(K)?re:0,fe=e.get("text-anchor").evaluate(_,{},i.canonical),De=e.get("text-variable-anchor");if(!De){const Pe=e.get("text-radial-offset").evaluate(_,{},i.canonical);N=Pe?Vu(fe,[Pe*ii,Lc]):e.get("text-offset").evaluate(_,{},i.canonical).map(Ce=>Ce*ii)}let Fe=u?"center":e.get("text-justify").evaluate(_,{},i.canonical);const Me=e.get("symbol-placement"),Ie=Me==="point"?e.get("text-max-width").evaluate(_,{},i.canonical)*ii:0,Te=()=>{i.bucket.allowVerticalPlacement&&Os(K)&&(k.vertical=Sl(L,i.glyphMap,i.glyphPositions,i.imagePositions,v,Ie,c,fe,"left",ge,N,h.WritingMode.vertical,!0,Me,E,w))};if(!u&&De){const Pe=Fe==="auto"?De.map(be=>Dc(be)):[Fe];let Ce=!1;for(let be=0;be<Pe.length;be++){const $e=Pe[be];if(!k.horizontal[$e])if(Ce)k.horizontal[$e]=k.horizontal[0];else{const Ue=Sl(L,i.glyphMap,i.glyphPositions,i.imagePositions,v,Ie,c,"center",$e,ge,N,h.WritingMode.horizontal,!1,Me,E,w);Ue&&(k.horizontal[$e]=Ue,Ce=Ue.positionedLines.length===1)}}Te()}else{Fe==="auto"&&(Fe=Dc(fe));const Pe=Sl(L,i.glyphMap,i.glyphPositions,i.imagePositions,v,Ie,c,fe,Fe,ge,N,h.WritingMode.horizontal,!1,Me,E,w);Pe&&(k.horizontal[Fe]=Pe),Te(),Os(K)&&u&&p&&(k.vertical=Sl(L,i.glyphMap,i.glyphPositions,i.imagePositions,v,Ie,c,fe,Fe,ge,N,h.WritingMode.vertical,!1,Me,E,w))}}let J=!1;if(_.icon&&_.icon.name){const K=i.imageMap[_.icon.name];K&&($=bf(i.imagePositions[_.icon.name],e.get("icon-offset").evaluate(_,{},i.canonical),e.get("icon-anchor").evaluate(_,{},i.canonical)),J=!!K.sdf,i.bucket.sdfIcons===void 0?i.bucket.sdfIcons=J:i.bucket.sdfIcons!==J&&dt("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(K.pixelRatio!==i.bucket.pixelRatio||e.get("icon-rotate").constantOr(1)!==0)&&(i.bucket.iconsNeedLinear=!0))}const ne=$u(k.horizontal)||k.vertical;i.bucket.iconsInText=!!ne&&ne.iconsInText,(ne||$)&&Cf(i.bucket,_,k,$,i.imageMap,a,E,P,N,J,i.canonical)}i.showCollisionBoxes&&i.bucket.generateCollisionDebugBuffers()},h.perspective=function(i,e,r,a,c){var u,p=1/Math.tan(e/2);return i[0]=p/r,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=p,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,c!=null&&c!==1/0?(i[10]=(c+a)*(u=1/(a-c)),i[14]=2*c*a*u):(i[10]=-1,i[14]=-2*a),i},h.pick=function(i,e){const r={};for(let a=0;a<e.length;a++){const c=e[a];c in i&&(r[c]=i[c])}return r},h.plugin=Ei,h.pointGeometry=He,h.polygonIntersectsPolygon=Rr,h.potpack=Su,h.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],h.register=ke,h.registerForPluginStateChange=function(i){return i({pluginStatus:Si,pluginURL:lr}),Gs.on("pluginStateChange",i),i},h.renderColorRamp=ru,h.rotateX=function(i,e,r){var a=Math.sin(r),c=Math.cos(r),u=e[4],p=e[5],f=e[6],_=e[7],v=e[8],w=e[9],E=e[10],P=e[11];return e!==i&&(i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[4]=u*c+v*a,i[5]=p*c+w*a,i[6]=f*c+E*a,i[7]=_*c+P*a,i[8]=v*c-u*a,i[9]=w*c-p*a,i[10]=E*c-f*a,i[11]=P*c-_*a,i},h.rotateZ=function(i,e,r){var a=Math.sin(r),c=Math.cos(r),u=e[0],p=e[1],f=e[2],_=e[3],v=e[4],w=e[5],E=e[6],P=e[7];return e!==i&&(i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[0]=u*c+v*a,i[1]=p*c+w*a,i[2]=f*c+E*a,i[3]=_*c+P*a,i[4]=v*c-u*a,i[5]=w*c-p*a,i[6]=E*c-f*a,i[7]=P*c-_*a,i},h.scale=function(i,e,r){var a=r[0],c=r[1],u=r[2];return i[0]=e[0]*a,i[1]=e[1]*a,i[2]=e[2]*a,i[3]=e[3]*a,i[4]=e[4]*c,i[5]=e[5]*c,i[6]=e[6]*c,i[7]=e[7]*c,i[8]=e[8]*u,i[9]=e[9]*u,i[10]=e[10]*u,i[11]=e[11]*u,i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},h.setRTLTextPlugin=function(i,e,r=!1){if(Si===kn||Si===Vs||Si===Ns)throw new Error("setRTLTextPlugin cannot be called multiple times.");lr=pa.resolveURL(i),Si=kn,$s=e,ea(),r||hl()},h.spec=le,h.sphericalToCartesian=function([i,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:i*Math.cos(e)*Math.sin(r),y:i*Math.sin(e)*Math.sin(r),z:i*Math.cos(r)}},h.toEvaluationFeature=ki,h.transformMat4=_l,h.translate=function(i,e,r){var a,c,u,p,f,_,v,w,E,P,k,L,$=r[0],N=r[1],J=r[2];return e===i?(i[12]=e[0]*$+e[4]*N+e[8]*J+e[12],i[13]=e[1]*$+e[5]*N+e[9]*J+e[13],i[14]=e[2]*$+e[6]*N+e[10]*J+e[14],i[15]=e[3]*$+e[7]*N+e[11]*J+e[15]):(c=e[1],u=e[2],p=e[3],f=e[4],_=e[5],v=e[6],w=e[7],E=e[8],P=e[9],k=e[10],L=e[11],i[0]=a=e[0],i[1]=c,i[2]=u,i[3]=p,i[4]=f,i[5]=_,i[6]=v,i[7]=w,i[8]=E,i[9]=P,i[10]=k,i[11]=L,i[12]=a*$+f*N+E*J+e[12],i[13]=c*$+_*N+P*J+e[13],i[14]=u*$+v*N+k*J+e[14],i[15]=p*$+w*N+L*J+e[15]),i},h.triggerPluginCompletionEvent=cl,h.unicodeBlockLookup=Ae,h.uniqueId=function(){return Ct++},h.validateCustomStyleLayer=function(i){const e=[],r=i.id;return r===void 0&&e.push({message:`layers.${r}: missing required property "id"`}),i.render===void 0&&e.push({message:`layers.${r}: missing required method "render"`}),i.renderingMode&&i.renderingMode!=="2d"&&i.renderingMode!=="3d"&&e.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),e},h.validateLight=sl,h.validateStyle=Mn,h.vectorTile=Bn,h.warnOnce=dt,h.wrap=ee}),de(["./shared"],function(h){function ve(B){const I=typeof B;if(I==="number"||I==="boolean"||I==="string"||B==null)return JSON.stringify(B);if(Array.isArray(B)){let U="[";for(const j of B)U+=`${ve(j)},`;return`${U}]`}const C=Object.keys(B).sort();let R="{";for(let U=0;U<C.length;U++)R+=`${JSON.stringify(C[U])}:${ve(B[C[U]])},`;return`${R}}`}function Ge(B){let I="";for(const C of h.refProperties)I+=`/${ve(B[C])}`;return I}class et{constructor(I){this.keyCache={},I&&this.replace(I)}replace(I){this._layerConfigs={},this._layers={},this.update(I,[])}update(I,C){for(const U of I){this._layerConfigs[U.id]=U;const j=this._layers[U.id]=h.createStyleLayer(U);j._featureFilter=h.createFilter(j.filter),this.keyCache[U.id]&&delete this.keyCache[U.id]}for(const U of C)delete this.keyCache[U],delete this._layerConfigs[U],delete this._layers[U];this.familiesBySource={};const R=function(U,j){const X={};for(let q=0;q<U.length;q++){const Q=j&&j[U[q].id]||Ge(U[q]);j&&(j[U[q].id]=Q);let oe=X[Q];oe||(oe=X[Q]=[]),oe.push(U[q])}const Z=[];for(const q in X)Z.push(X[q]);return Z}(Object.values(this._layerConfigs),this.keyCache);for(const U of R){const j=U.map(ye=>this._layers[ye.id]),X=j[0];if(X.visibility==="none")continue;const Z=X.source||"";let q=this.familiesBySource[Z];q||(q=this.familiesBySource[Z]={});const Q=X.sourceLayer||"_geojsonTileLayer";let oe=q[Q];oe||(oe=q[Q]=[]),oe.push(j)}}}class Ye{constructor(I){const C={},R=[];for(const Z in I){const q=I[Z],Q=C[Z]={};for(const oe in q){const ye=q[+oe];if(!ye||ye.bitmap.width===0||ye.bitmap.height===0)continue;const ce={x:0,y:0,w:ye.bitmap.width+2,h:ye.bitmap.height+2};R.push(ce),Q[oe]={rect:ce,metrics:ye.metrics}}}const{w:U,h:j}=h.potpack(R),X=new h.AlphaImage({width:U||1,height:j||1});for(const Z in I){const q=I[Z];for(const Q in q){const oe=q[+Q];if(!oe||oe.bitmap.width===0||oe.bitmap.height===0)continue;const ye=C[Z][Q].rect;h.AlphaImage.copy(oe.bitmap,X,{x:0,y:0},{x:ye.x+1,y:ye.y+1},oe.bitmap)}}this.image=X,this.positions=C}}h.register("GlyphAtlas",Ye);class pe{constructor(I){this.tileID=new h.OverscaledTileID(I.tileID.overscaledZ,I.tileID.wrap,I.tileID.canonical.z,I.tileID.canonical.x,I.tileID.canonical.y),this.uid=I.uid,this.zoom=I.zoom,this.pixelRatio=I.pixelRatio,this.tileSize=I.tileSize,this.source=I.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=I.showCollisionBoxes,this.collectResourceTiming=!!I.collectResourceTiming,this.returnDependencies=!!I.returnDependencies,this.promoteId=I.promoteId}parse(I,C,R,U,j){this.status="parsing",this.data=I,this.collisionBoxArray=new h.CollisionBoxArray;const X=new h.DictionaryCoder(Object.keys(I.layers).sort()),Z=new h.FeatureIndex(this.tileID,this.promoteId);Z.bucketLayerIDs=[];const q={},Q={featureIndex:Z,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:R},oe=C.familiesBySource[this.source];for(const ot in oe){const ct=I.layers[ot];if(!ct)continue;ct.version===1&&h.warnOnce(`Vector tile source "${this.source}" layer "${ot}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const It=X.encode(ot),$t=[];for(let ti=0;ti<ct.length;ti++){const Wt=ct.feature(ti),xn=Z.getId(Wt,ot);$t.push({feature:Wt,id:xn,index:ti,sourceLayerIndex:It})}for(const ti of oe[ot]){const Wt=ti[0];Wt.source!==this.source&&h.warnOnce(`layer.source = ${Wt.source} does not equal this.source = ${this.source}`),Wt.minzoom&&this.zoom<Math.floor(Wt.minzoom)||Wt.maxzoom&&this.zoom>=Wt.maxzoom||Wt.visibility!=="none"&&(ee(ti,this.zoom,R),(q[Wt.id]=Wt.createBucket({index:Z.bucketLayerIDs.length,layers:ti,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:It,sourceID:this.source})).populate($t,Q,this.tileID.canonical),Z.bucketLayerIDs.push(ti.map(xn=>xn.id)))}}let ye,ce,Ne,je;const Re=h.mapObject(Q.glyphDependencies,ot=>Object.keys(ot).map(Number));Object.keys(Re).length?U.send("getGlyphs",{uid:this.uid,stacks:Re,source:this.source,tileID:this.tileID,type:"glyphs"},(ot,ct)=>{ye||(ye=ot,ce=ct,St.call(this))}):ce={};const qe=Object.keys(Q.iconDependencies);qe.length?U.send("getImages",{icons:qe,source:this.source,tileID:this.tileID,type:"icons"},(ot,ct)=>{ye||(ye=ot,Ne=ct,St.call(this))}):Ne={};const st=Object.keys(Q.patternDependencies);function St(){if(ye)return j(ye);if(ce&&Ne&&je){const ot=new Ye(ce),ct=new h.ImageAtlas(Ne,je);for(const It in q){const $t=q[It];$t instanceof h.SymbolBucket?(ee($t.layers,this.zoom,R),h.performSymbolLayout({bucket:$t,glyphMap:ce,glyphPositions:ot.positions,imageMap:Ne,imagePositions:ct.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):$t.hasPattern&&($t instanceof h.LineBucket||$t instanceof h.FillBucket||$t instanceof h.FillExtrusionBucket)&&(ee($t.layers,this.zoom,R),$t.addFeatures(Q,this.tileID.canonical,ct.patternPositions))}this.status="done",j(null,{buckets:Object.values(q).filter(It=>!It.isEmpty()),featureIndex:Z,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:ot.image,imageAtlas:ct,glyphMap:this.returnDependencies?ce:null,iconMap:this.returnDependencies?Ne:null,glyphPositions:this.returnDependencies?ot.positions:null})}}st.length?U.send("getImages",{icons:st,source:this.source,tileID:this.tileID,type:"patterns"},(ot,ct)=>{ye||(ye=ot,je=ct,St.call(this))}):je={},St.call(this)}}function ee(B,I,C){const R=new h.EvaluationParameters(I);for(const U of B)U.recalculate(R,C)}function Be(B,I){const C=h.getArrayBuffer(B.request,(R,U,j,X)=>{R?I(R):U&&I(null,{vectorTile:new h.vectorTile.VectorTile(new h.pbf(U)),rawData:U,cacheControl:j,expires:X})});return()=>{C.cancel(),I()}}class Ct{constructor(I,C,R,U){this.actor=I,this.layerIndex=C,this.availableImages=R,this.loadVectorData=U||Be,this.loading={},this.loaded={}}loadTile(I,C){const R=I.uid;this.loading||(this.loading={});const U=!!(I&&I.request&&I.request.collectResourceTiming)&&new h.RequestPerformance(I.request),j=this.loading[R]=new pe(I);j.abort=this.loadVectorData(I,(X,Z)=>{if(delete this.loading[R],X||!Z)return j.status="done",this.loaded[R]=j,C(X);const q=Z.rawData,Q={};Z.expires&&(Q.expires=Z.expires),Z.cacheControl&&(Q.cacheControl=Z.cacheControl);const oe={};if(U){const ye=U.finish();ye&&(oe.resourceTiming=JSON.parse(JSON.stringify(ye)))}j.vectorTile=Z.vectorTile,j.parse(Z.vectorTile,this.layerIndex,this.availableImages,this.actor,(ye,ce)=>{if(ye||!ce)return C(ye);C(null,h.extend({rawTileData:q.slice(0)},ce,Q,oe))}),this.loaded=this.loaded||{},this.loaded[R]=j})}reloadTile(I,C){const R=this.loaded,U=I.uid,j=this;if(R&&R[U]){const X=R[U];X.showCollisionBoxes=I.showCollisionBoxes;const Z=(q,Q)=>{const oe=X.reloadCallback;oe&&(delete X.reloadCallback,X.parse(X.vectorTile,j.layerIndex,this.availableImages,j.actor,oe)),C(q,Q)};X.status==="parsing"?X.reloadCallback=Z:X.status==="done"&&(X.vectorTile?X.parse(X.vectorTile,this.layerIndex,this.availableImages,this.actor,Z):Z())}}abortTile(I,C){const R=this.loading,U=I.uid;R&&R[U]&&R[U].abort&&(R[U].abort(),delete R[U]),C()}removeTile(I,C){const R=this.loaded,U=I.uid;R&&R[U]&&delete R[U],C()}}class Ft{constructor(){this.loaded={}}loadTile(I,C){const{uid:R,encoding:U,rawImageData:j}=I,X=h.isImageBitmap(j)?this.getImageData(j):j,Z=new h.DEMData(R,X,U);this.loaded=this.loaded||{},this.loaded[R]=Z,C(null,Z)}getImageData(I){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(I.width,I.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=I.width,this.offscreenCanvas.height=I.height,this.offscreenCanvasContext.drawImage(I,0,0,I.width,I.height);const C=this.offscreenCanvasContext.getImageData(-1,-1,I.width+2,I.height+2);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new h.RGBAImage({width:C.width,height:C.height},C.data)}removeTile(I){const C=this.loaded,R=I.uid;C&&C[R]&&delete C[R]}}var mr=function B(I,C){var R,U=I&&I.type;if(U==="FeatureCollection")for(R=0;R<I.features.length;R++)B(I.features[R],C);else if(U==="GeometryCollection")for(R=0;R<I.geometries.length;R++)B(I.geometries[R],C);else if(U==="Feature")B(I.geometry,C);else if(U==="Polygon")dn(I.coordinates,C);else if(U==="MultiPolygon")for(R=0;R<I.coordinates.length;R++)dn(I.coordinates[R],C);return I};function dn(B,I){if(B.length!==0){Ci(B[0],I);for(var C=1;C<B.length;C++)Ci(B[C],!I)}}function Ci(B,I){for(var C=0,R=0,U=0,j=B.length,X=j-1;U<j;X=U++){var Z=(B[U][0]-B[X][0])*(B[X][1]+B[U][1]),q=C+Z;R+=Math.abs(C)>=Math.abs(Z)?C-q+Z:Z-q+C,C=q}C+R>=0!=!!I&&B.reverse()}const Or=h.vectorTile.VectorTileFeature.prototype.toGeoJSON;var dt={},Qt={get exports(){return dt},set exports(B){dt=B}},us=h.pointGeometry,Oi=h.vectorTile.VectorTileFeature,pn=fr;function fr(B,I){this.options=I||{},this.features=B,this.length=B.length}function gr(B,I){this.id=typeof B.id=="number"?B.id:void 0,this.type=B.type,this.rawGeometry=B.type===1?[B.geometry]:B.geometry,this.properties=B.tags,this.extent=I||4096}fr.prototype.feature=function(B){return new gr(this.features[B],this.options.extent)},gr.prototype.loadGeometry=function(){var B=this.rawGeometry;this.geometry=[];for(var I=0;I<B.length;I++){for(var C=B[I],R=[],U=0;U<C.length;U++)R.push(new us(C[U][0],C[U][1]));this.geometry.push(R)}return this.geometry},gr.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var B=this.geometry,I=1/0,C=-1/0,R=1/0,U=-1/0,j=0;j<B.length;j++)for(var X=B[j],Z=0;Z<X.length;Z++){var q=X[Z];I=Math.min(I,q.x),C=Math.max(C,q.x),R=Math.min(R,q.y),U=Math.max(U,q.y)}return[I,R,C,U]},gr.prototype.toGeoJSON=Oi.prototype.toGeoJSON;var da=h.pbf,nr=pn;function Mt(B){var I=new da;return function(C,R){for(var U in C.layers)R.writeMessage(3,pa,C.layers[U])}(B,I),I.finish()}function pa(B,I){var C;I.writeVarintField(15,B.version||1),I.writeStringField(1,B.name||""),I.writeVarintField(5,B.extent||4096);var R={keys:[],values:[],keycache:{},valuecache:{}};for(C=0;C<B.length;C++)R.feature=B.feature(C),I.writeMessage(2,He,R);var U=R.keys;for(C=0;C<U.length;C++)I.writeStringField(3,U[C]);var j=R.values;for(C=0;C<j.length;C++)I.writeMessage(4,ma,j[C])}function He(B,I){var C=B.feature;C.id!==void 0&&I.writeVarintField(1,C.id),I.writeMessage(2,Ui,B),I.writeVarintField(3,C.type),I.writeMessage(4,ar,C)}function Ui(B,I){var C=B.feature,R=B.keys,U=B.values,j=B.keycache,X=B.valuecache;for(var Z in C.properties){var q=C.properties[Z],Q=j[Z];if(q!==null){Q===void 0&&(R.push(Z),j[Z]=Q=R.length-1),I.writeVarint(Q);var oe=typeof q;oe!=="string"&&oe!=="boolean"&&oe!=="number"&&(q=JSON.stringify(q));var ye=oe+":"+q,ce=X[ye];ce===void 0&&(U.push(q),X[ye]=ce=U.length-1),I.writeVarint(ce)}}}function Ur(B,I){return(I<<3)+(7&B)}function Er(B){return B<<1^B>>31}function ar(B,I){for(var C=B.loadGeometry(),R=B.type,U=0,j=0,X=C.length,Z=0;Z<X;Z++){var q=C[Z],Q=1;R===1&&(Q=q.length),I.writeVarint(Ur(1,Q));for(var oe=R===3?q.length-1:q.length,ye=0;ye<oe;ye++){ye===1&&R!==1&&I.writeVarint(Ur(2,oe-1));var ce=q[ye].x-U,Ne=q[ye].y-j;I.writeVarint(Er(ce)),I.writeVarint(Er(Ne)),U+=ce,j+=Ne}R===3&&I.writeVarint(Ur(7,1))}}function ma(B,I){var C=typeof B;C==="string"?I.writeStringField(1,B):C==="boolean"?I.writeBooleanField(7,B):C==="number"&&(B%1!=0?I.writeDoubleField(3,B):B<0?I.writeSVarintField(6,B):I.writeVarintField(5,B))}Qt.exports=Mt,dt.fromVectorTileJs=Mt,dt.fromGeojsonVt=function(B,I){I=I||{};var C={};for(var R in B)C[R]=new nr(B[R].features,I),C[R].name=R,C[R].version=I.version,C[R].extent=I.extent;return Mt({layers:C})},dt.GeoJSONWrapper=nr;const mn={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:B=>B},Vr=Math.fround||($n=new Float32Array(1),B=>($n[0]=+B,$n[0]));var $n;class Nr{constructor(I){this.options=di(Object.create(mn),I),this.trees=new Array(this.options.maxZoom+1)}load(I){const{log:C,minZoom:R,maxZoom:U,nodeSize:j}=this.options;C&&console.time("total time");const X=`prepare ${I.length} points`;C&&console.time(X),this.points=I;let Z=[];for(let q=0;q<I.length;q++)I[q].geometry&&Z.push($r(I[q],q));this.trees[U+1]=new h.KDBush(Z,bt,Wi,j,Float32Array),C&&console.timeEnd(X);for(let q=U;q>=R;q--){const Q=+Date.now();Z=this._cluster(Z,q),this.trees[q]=new h.KDBush(Z,bt,Wi,j,Float32Array),C&&console.log("z%d: %d clusters in %dms",q,Z.length,+Date.now()-Q)}return C&&console.timeEnd("total time"),this}getClusters(I,C){let R=((I[0]+180)%360+360)%360-180;const U=Math.max(-90,Math.min(90,I[1]));let j=I[2]===180?180:((I[2]+180)%360+360)%360-180;const X=Math.max(-90,Math.min(90,I[3]));if(I[2]-I[0]>=360)R=-180,j=180;else if(R>j){const oe=this.getClusters([R,U,180,X],C),ye=this.getClusters([-180,U,j,X],C);return oe.concat(ye)}const Z=this.trees[this._limitZoom(C)],q=Z.range(le(R),Se(X),le(j),Se(U)),Q=[];for(const oe of q){const ye=Z.points[oe];Q.push(ye.numPoints?Gr(ye):this.points[ye.index])}return Q}getChildren(I){const C=this._getOriginId(I),R=this._getOriginZoom(I),U="No cluster with the specified id.",j=this.trees[R];if(!j)throw new Error(U);const X=j.points[C];if(!X)throw new Error(U);const Z=this.options.radius/(this.options.extent*Math.pow(2,R-1)),q=j.within(X.x,X.y,Z),Q=[];for(const oe of q){const ye=j.points[oe];ye.parentId===I&&Q.push(ye.numPoints?Gr(ye):this.points[ye.index])}if(Q.length===0)throw new Error(U);return Q}getLeaves(I,C,R){const U=[];return this._appendLeaves(U,I,C=C||10,R=R||0,0),U}getTile(I,C,R){const U=this.trees[this._limitZoom(I)],j=Math.pow(2,I),{extent:X,radius:Z}=this.options,q=Z/X,Q=(R-q)/j,oe=(R+1+q)/j,ye={features:[]};return this._addTileFeatures(U.range((C-q)/j,Q,(C+1+q)/j,oe),U.points,C,R,j,ye),C===0&&this._addTileFeatures(U.range(1-q/j,Q,1,oe),U.points,j,R,j,ye),C===j-1&&this._addTileFeatures(U.range(0,Q,q/j,oe),U.points,-1,R,j,ye),ye.features.length?ye:null}getClusterExpansionZoom(I){let C=this._getOriginZoom(I)-1;for(;C<=this.options.maxZoom;){const R=this.getChildren(I);if(C++,R.length!==1)break;I=R[0].properties.cluster_id}return C}_appendLeaves(I,C,R,U,j){const X=this.getChildren(C);for(const Z of X){const q=Z.properties;if(q&&q.cluster?j+q.point_count<=U?j+=q.point_count:j=this._appendLeaves(I,q.cluster_id,R,U,j):j<U?j++:I.push(Z),I.length===R)break}return j}_addTileFeatures(I,C,R,U,j,X){for(const Z of I){const q=C[Z],Q=q.numPoints;let oe,ye,ce;if(Q)oe=Ir(q),ye=q.x,ce=q.y;else{const Re=this.points[q.index];oe=Re.properties,ye=le(Re.geometry.coordinates[0]),ce=Se(Re.geometry.coordinates[1])}const Ne={type:1,geometry:[[Math.round(this.options.extent*(ye*j-R)),Math.round(this.options.extent*(ce*j-U))]],tags:oe};let je;Q?je=q.id:this.options.generateId?je=q.index:this.points[q.index].id&&(je=this.points[q.index].id),je!==void 0&&(Ne.id=je),X.features.push(Ne)}}_limitZoom(I){return Math.max(this.options.minZoom,Math.min(Math.floor(+I),this.options.maxZoom+1))}_cluster(I,C){const R=[],{radius:U,extent:j,reduce:X,minPoints:Z}=this.options,q=U/(j*Math.pow(2,C));for(let Q=0;Q<I.length;Q++){const oe=I[Q];if(oe.zoom<=C)continue;oe.zoom=C;const ye=this.trees[C+1],ce=ye.within(oe.x,oe.y,q),Ne=oe.numPoints||1;let je=Ne;for(const Re of ce){const qe=ye.points[Re];qe.zoom>C&&(je+=qe.numPoints||1)}if(je>Ne&&je>=Z){let Re=oe.x*Ne,qe=oe.y*Ne,st=X&&Ne>1?this._map(oe,!0):null;const St=(Q<<5)+(C+1)+this.points.length;for(const ot of ce){const ct=ye.points[ot];if(ct.zoom<=C)continue;ct.zoom=C;const It=ct.numPoints||1;Re+=ct.x*It,qe+=ct.y*It,ct.parentId=St,X&&(st||(st=this._map(oe,!0)),X(st,this._map(ct)))}oe.parentId=St,R.push(fn(Re/je,qe/je,St,je,st))}else if(R.push(oe),je>1)for(const Re of ce){const qe=ye.points[Re];qe.zoom<=C||(qe.zoom=C,R.push(qe))}}return R}_getOriginId(I){return I-this.points.length>>5}_getOriginZoom(I){return(I-this.points.length)%32}_map(I,C){if(I.numPoints)return C?di({},I.properties):I.properties;const R=this.points[I.index].properties,U=this.options.map(R);return C&&U===R?di({},U):U}}function fn(B,I,C,R,U){return{x:Vr(B),y:Vr(I),zoom:1/0,id:C,parentId:-1,numPoints:R,properties:U}}function $r(B,I){const[C,R]=B.geometry.coordinates;return{x:Vr(le(C)),y:Vr(Se(R)),zoom:1/0,index:I,parentId:-1}}function Gr(B){return{type:"Feature",id:B.id,properties:Ir(B),geometry:{type:"Point",coordinates:[(I=B.x,360*(I-.5)),Gn(B.y)]}};var I}function Ir(B){const I=B.numPoints,C=I>=1e4?`${Math.round(I/1e3)}k`:I>=1e3?Math.round(I/100)/10+"k":I;return di(di({},B.properties),{cluster:!0,cluster_id:B.id,point_count:I,point_count_abbreviated:C})}function le(B){return B/360+.5}function Se(B){const I=Math.sin(B*Math.PI/180),C=.5-.25*Math.log((1+I)/(1-I))/Math.PI;return C<0?0:C>1?1:C}function Gn(B){const I=(180-360*B)*Math.PI/180;return 360*Math.atan(Math.exp(I))/Math.PI-90}function di(B,I){for(const C in I)B[C]=I[C];return B}function bt(B){return B.x}function Wi(B){return B.y}function pi(B,I,C,R){for(var U,j=R,X=C-I>>1,Z=C-I,q=B[I],Q=B[I+1],oe=B[C],ye=B[C+1],ce=I+3;ce<C;ce+=3){var Ne=jr(B[ce],B[ce+1],q,Q,oe,ye);if(Ne>j)U=ce,j=Ne;else if(Ne===j){var je=Math.abs(ce-X);je<Z&&(U=ce,Z=je)}}j>R&&(U-I>3&&pi(B,I,U,R),B[U+2]=j,C-U>3&&pi(B,U,C,R))}function jr(B,I,C,R,U,j){var X=U-C,Z=j-R;if(X!==0||Z!==0){var q=((B-C)*X+(I-R)*Z)/(X*X+Z*Z);q>1?(C=U,R=j):q>0&&(C+=X*q,R+=Z*q)}return(X=B-C)*X+(Z=I-R)*Z}function Hi(B,I,C,R){var U={id:B===void 0?null:B,type:I,geometry:C,tags:R,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(j){var X=j.geometry,Z=j.type;if(Z==="Point"||Z==="MultiPoint"||Z==="LineString")Ee(j,X);else if(Z==="Polygon"||Z==="MultiLineString")for(var q=0;q<X.length;q++)Ee(j,X[q]);else if(Z==="MultiPolygon")for(q=0;q<X.length;q++)for(var Q=0;Q<X[q].length;Q++)Ee(j,X[q][Q])}(U),U}function Ee(B,I){for(var C=0;C<I.length;C+=3)B.minX=Math.min(B.minX,I[C]),B.minY=Math.min(B.minY,I[C+1]),B.maxX=Math.max(B.maxX,I[C]),B.maxY=Math.max(B.maxY,I[C+1])}function Qe(B,I,C,R){if(I.geometry){var U=I.geometry.coordinates,j=I.geometry.type,X=Math.pow(C.tolerance/((1<<C.maxZoom)*C.extent),2),Z=[],q=I.id;if(C.promoteId?q=I.properties[C.promoteId]:C.generateId&&(q=R||0),j==="Point")Je(U,Z);else if(j==="MultiPoint")for(var Q=0;Q<U.length;Q++)Je(U[Q],Z);else if(j==="LineString")Ti(U,Z,X,!1);else if(j==="MultiLineString"){if(C.lineMetrics){for(Q=0;Q<U.length;Q++)Ti(U[Q],Z=[],X,!1),B.push(Hi(q,"LineString",Z,I.properties));return}sr(U,Z,X,!1)}else if(j==="Polygon")sr(U,Z,X,!0);else{if(j!=="MultiPolygon"){if(j==="GeometryCollection"){for(Q=0;Q<I.geometry.geometries.length;Q++)Qe(B,{id:q,geometry:I.geometry.geometries[Q],properties:I.properties},C,R);return}throw new Error("Input data is not a valid GeoJSON object.")}for(Q=0;Q<U.length;Q++){var oe=[];sr(U[Q],oe,X,!0),Z.push(oe)}}B.push(Hi(q,j,Z,I.properties))}}function Je(B,I){I.push(Xe(B[0])),I.push(Ar(B[1])),I.push(0)}function Ti(B,I,C,R){for(var U,j,X=0,Z=0;Z<B.length;Z++){var q=Xe(B[Z][0]),Q=Ar(B[Z][1]);I.push(q),I.push(Q),I.push(0),Z>0&&(X+=R?(U*Q-q*j)/2:Math.sqrt(Math.pow(q-U,2)+Math.pow(Q-j,2))),U=q,j=Q}var oe=I.length-3;I[2]=1,pi(I,0,oe,C),I[oe+2]=1,I.size=Math.abs(X),I.start=0,I.end=I.size}function sr(B,I,C,R){for(var U=0;U<B.length;U++){var j=[];Ti(B[U],j,C,R),I.push(j)}}function Xe(B){return B/360+.5}function Ar(B){var I=Math.sin(B*Math.PI/180),C=.5-.25*Math.log((1+I)/(1-I))/Math.PI;return C<0?0:C>1?1:C}function ri(B,I,C,R,U,j,X,Z){if(R/=I,j>=(C/=I)&&X<R)return B;if(X<C||j>=R)return null;for(var q=[],Q=0;Q<B.length;Q++){var oe=B[Q],ye=oe.geometry,ce=oe.type,Ne=U===0?oe.minX:oe.minY,je=U===0?oe.maxX:oe.maxY;if(Ne>=C&&je<R)q.push(oe);else if(!(je<C||Ne>=R)){var Re=[];if(ce==="Point"||ce==="MultiPoint")qr(ye,Re,C,R,U);else if(ce==="LineString")Mi(ye,Re,C,R,U,!1,Z.lineMetrics);else if(ce==="MultiLineString")yt(ye,Re,C,R,U,!1);else if(ce==="Polygon")yt(ye,Re,C,R,U,!0);else if(ce==="MultiPolygon")for(var qe=0;qe<ye.length;qe++){var st=[];yt(ye[qe],st,C,R,U,!0),st.length&&Re.push(st)}if(Re.length){if(Z.lineMetrics&&ce==="LineString"){for(qe=0;qe<Re.length;qe++)q.push(Hi(oe.id,ce,Re[qe],oe.tags));continue}ce!=="LineString"&&ce!=="MultiLineString"||(Re.length===1?(ce="LineString",Re=Re[0]):ce="MultiLineString"),ce!=="Point"&&ce!=="MultiPoint"||(ce=Re.length===3?"Point":"MultiPoint"),q.push(Hi(oe.id,ce,Re,oe.tags))}}}return q.length?q:null}function qr(B,I,C,R,U){for(var j=0;j<B.length;j+=3){var X=B[j+U];X>=C&&X<=R&&(I.push(B[j]),I.push(B[j+1]),I.push(B[j+2]))}}function Mi(B,I,C,R,U,j,X){for(var Z,q,Q=mi(B),oe=U===0?Zr:_n,ye=B.start,ce=0;ce<B.length-3;ce+=3){var Ne=B[ce],je=B[ce+1],Re=B[ce+2],qe=B[ce+3],st=B[ce+4],St=U===0?Ne:je,ot=U===0?qe:st,ct=!1;X&&(Z=Math.sqrt(Math.pow(Ne-qe,2)+Math.pow(je-st,2))),St<C?ot>C&&(q=oe(Q,Ne,je,qe,st,C),X&&(Q.start=ye+Z*q)):St>R?ot<R&&(q=oe(Q,Ne,je,qe,st,R),X&&(Q.start=ye+Z*q)):gn(Q,Ne,je,Re),ot<C&&St>=C&&(q=oe(Q,Ne,je,qe,st,C),ct=!0),ot>R&&St<=R&&(q=oe(Q,Ne,je,qe,st,R),ct=!0),!j&&ct&&(X&&(Q.end=ye+Z*q),I.push(Q),Q=mi(B)),X&&(ye+=Z)}var It=B.length-3;Ne=B[It],je=B[It+1],Re=B[It+2],(St=U===0?Ne:je)>=C&&St<=R&&gn(Q,Ne,je,Re),It=Q.length-3,j&&It>=3&&(Q[It]!==Q[0]||Q[It+1]!==Q[1])&&gn(Q,Q[0],Q[1],Q[2]),Q.length&&I.push(Q)}function mi(B){var I=[];return I.size=B.size,I.start=B.start,I.end=B.end,I}function yt(B,I,C,R,U,j){for(var X=0;X<B.length;X++)Mi(B[X],I,C,R,U,j,!1)}function gn(B,I,C,R){B.push(I),B.push(C),B.push(R)}function Zr(B,I,C,R,U,j){var X=(j-I)/(R-I);return B.push(j),B.push(C+(U-C)*X),B.push(1),X}function _n(B,I,C,R,U,j){var X=(j-C)/(U-C);return B.push(I+(R-I)*X),B.push(j),B.push(1),X}function lt(B,I){for(var C=[],R=0;R<B.length;R++){var U,j=B[R],X=j.type;if(X==="Point"||X==="MultiPoint"||X==="LineString")U=Cr(j.geometry,I);else if(X==="MultiLineString"||X==="Polygon"){U=[];for(var Z=0;Z<j.geometry.length;Z++)U.push(Cr(j.geometry[Z],I))}else if(X==="MultiPolygon")for(U=[],Z=0;Z<j.geometry.length;Z++){for(var q=[],Q=0;Q<j.geometry[Z].length;Q++)q.push(Cr(j.geometry[Z][Q],I));U.push(q)}C.push(Hi(j.id,X,U,j.tags))}return C}function Cr(B,I){var C=[];C.size=B.size,B.start!==void 0&&(C.start=B.start,C.end=B.end);for(var R=0;R<B.length;R+=3)C.push(B[R]+I,B[R+1],B[R+2]);return C}function yn(B,I){if(B.transformed)return B;var C,R,U,j=1<<B.z,X=B.x,Z=B.y;for(C=0;C<B.features.length;C++){var q=B.features[C],Q=q.geometry,oe=q.type;if(q.geometry=[],oe===1)for(R=0;R<Q.length;R+=2)q.geometry.push(Xr(Q[R],Q[R+1],I,j,X,Z));else for(R=0;R<Q.length;R++){var ye=[];for(U=0;U<Q[R].length;U+=2)ye.push(Xr(Q[R][U],Q[R][U+1],I,j,X,Z));q.geometry.push(ye)}}return B.transformed=!0,B}function Xr(B,I,C,R,U,j){return[Math.round(C*(B*R-U)),Math.round(C*(I*R-j))]}function jn(B,I,C,R,U){for(var j=I===U.maxZoom?0:U.tolerance/((1<<I)*U.extent),X={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:C,y:R,z:I,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},Z=0;Z<B.length;Z++){X.numFeatures++,_r(X,B[Z],j,U);var q=B[Z].minX,Q=B[Z].minY,oe=B[Z].maxX,ye=B[Z].maxY;q<X.minX&&(X.minX=q),Q<X.minY&&(X.minY=Q),oe>X.maxX&&(X.maxX=oe),ye>X.maxY&&(X.maxY=ye)}return X}function _r(B,I,C,R){var U=I.geometry,j=I.type,X=[];if(j==="Point"||j==="MultiPoint")for(var Z=0;Z<U.length;Z+=3)X.push(U[Z]),X.push(U[Z+1]),B.numPoints++,B.numSimplified++;else if(j==="LineString")Mr(X,U,B,C,!1,!1);else if(j==="MultiLineString"||j==="Polygon")for(Z=0;Z<U.length;Z++)Mr(X,U[Z],B,C,j==="Polygon",Z===0);else if(j==="MultiPolygon")for(var q=0;q<U.length;q++){var Q=U[q];for(Z=0;Z<Q.length;Z++)Mr(X,Q[Z],B,C,!0,Z===0)}if(X.length){var oe=I.tags||null;if(j==="LineString"&&R.lineMetrics){for(var ye in oe={},I.tags)oe[ye]=I.tags[ye];oe.mapbox_clip_start=U.start/U.size,oe.mapbox_clip_end=U.end/U.size}var ce={geometry:X,type:j==="Polygon"||j==="MultiPolygon"?3:j==="LineString"||j==="MultiLineString"?2:1,tags:oe};I.id!==null&&(ce.id=I.id),B.features.push(ce)}}function Mr(B,I,C,R,U,j){var X=R*R;if(R>0&&I.size<(U?X:R))C.numPoints+=I.length/3;else{for(var Z=[],q=0;q<I.length;q+=3)(R===0||I[q+2]>X)&&(C.numSimplified++,Z.push(I[q]),Z.push(I[q+1])),C.numPoints++;U&&function(Q,oe){for(var ye=0,ce=0,Ne=Q.length,je=Ne-2;ce<Ne;je=ce,ce+=2)ye+=(Q[ce]-Q[je])*(Q[ce+1]+Q[je+1]);if(ye>0===oe)for(ce=0,Ne=Q.length;ce<Ne/2;ce+=2){var Re=Q[ce],qe=Q[ce+1];Q[ce]=Q[Ne-2-ce],Q[ce+1]=Q[Ne-1-ce],Q[Ne-2-ce]=Re,Q[Ne-1-ce]=qe}}(Z,j),B.push(Z)}}function ut(B,I){var C=(I=this.options=function(U,j){for(var X in j)U[X]=j[X];return U}(Object.create(this.options),I)).debug;if(C&&console.time("preprocess data"),I.maxZoom<0||I.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(I.promoteId&&I.generateId)throw new Error("promoteId and generateId cannot be used together.");var R=function(U,j){var X=[];if(U.type==="FeatureCollection")for(var Z=0;Z<U.features.length;Z++)Qe(X,U.features[Z],j,Z);else Qe(X,U.type==="Feature"?U:{geometry:U},j);return X}(B,I);this.tiles={},this.tileCoords=[],C&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",I.indexMaxZoom,I.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),R=function(U,j){var X=j.buffer/j.extent,Z=U,q=ri(U,1,-1-X,X,0,-1,2,j),Q=ri(U,1,1-X,2+X,0,-1,2,j);return(q||Q)&&(Z=ri(U,1,-X,1+X,0,-1,2,j)||[],q&&(Z=lt(q,1).concat(Z)),Q&&(Z=Z.concat(lt(Q,-1)))),Z}(R,I),R.length&&this.splitTile(R,0,0,0),C&&(R.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)))}function Wr(B,I,C){return 32*((1<<B)*C+I)+B}function Vi(B,I){return I?B.properties[I]:B.id}function ei(B,I){if(B==null)return!0;if(B.type==="Feature")return Vi(B,I)!=null;if(B.type==="FeatureCollection"){const C=new Set;for(const R of B.features){const U=Vi(R,I);if(U==null||C.has(U))return!1;C.add(U)}return!0}return!1}function Yt(B,I){const C=new Map;if(B!=null)if(B.type==="Feature")C.set(Vi(B,I),B);else for(const R of B.features)C.set(Vi(R,I),R);return C}function fi(B,I){const C=B.tileID.canonical;if(!this._geoJSONIndex)return I(null,null);const R=this._geoJSONIndex.getTile(C.z,C.x,C.y);if(!R)return I(null,null);const U=new class{constructor(X){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=h.EXTENT,this.length=X.length,this._features=X}feature(X){return new class{constructor(Z){this._feature=Z,this.extent=h.EXTENT,this.type=Z.type,this.properties=Z.tags,"id"in Z&&!isNaN(Z.id)&&(this.id=parseInt(Z.id,10))}loadGeometry(){if(this._feature.type===1){const Z=[];for(const q of this._feature.geometry)Z.push([new h.pointGeometry(q[0],q[1])]);return Z}{const Z=[];for(const q of this._feature.geometry){const Q=[];for(const oe of q)Q.push(new h.pointGeometry(oe[0],oe[1]));Z.push(Q)}return Z}}toGeoJSON(Z,q,Q){return Or.call(this,Z,q,Q)}}(this._features[X])}}(R.features);let j=dt(U);j.byteOffset===0&&j.byteLength===j.buffer.byteLength||(j=new Uint8Array(j)),I(null,{vectorTile:U,rawData:j.buffer})}ut.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},ut.prototype.splitTile=function(B,I,C,R,U,j,X){for(var Z=[B,I,C,R],q=this.options,Q=q.debug;Z.length;){R=Z.pop(),C=Z.pop(),I=Z.pop(),B=Z.pop();var oe=1<<I,ye=Wr(I,C,R),ce=this.tiles[ye];if(!ce&&(Q>1&&console.time("creation"),ce=this.tiles[ye]=jn(B,I,C,R,q),this.tileCoords.push({z:I,x:C,y:R}),Q)){Q>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",I,C,R,ce.numFeatures,ce.numPoints,ce.numSimplified),console.timeEnd("creation"));var Ne="z"+I;this.stats[Ne]=(this.stats[Ne]||0)+1,this.total++}if(ce.source=B,U){if(I===q.maxZoom||I===U)continue;var je=1<<U-I;if(C!==Math.floor(j/je)||R!==Math.floor(X/je))continue}else if(I===q.indexMaxZoom||ce.numPoints<=q.indexMaxPoints)continue;if(ce.source=null,B.length!==0){Q>1&&console.time("clipping");var Re,qe,st,St,ot,ct,It=.5*q.buffer/q.extent,$t=.5-It,ti=.5+It,Wt=1+It;Re=qe=st=St=null,ot=ri(B,oe,C-It,C+ti,0,ce.minX,ce.maxX,q),ct=ri(B,oe,C+$t,C+Wt,0,ce.minX,ce.maxX,q),B=null,ot&&(Re=ri(ot,oe,R-It,R+ti,1,ce.minY,ce.maxY,q),qe=ri(ot,oe,R+$t,R+Wt,1,ce.minY,ce.maxY,q),ot=null),ct&&(st=ri(ct,oe,R-It,R+ti,1,ce.minY,ce.maxY,q),St=ri(ct,oe,R+$t,R+Wt,1,ce.minY,ce.maxY,q),ct=null),Q>1&&console.timeEnd("clipping"),Z.push(Re||[],I+1,2*C,2*R),Z.push(qe||[],I+1,2*C,2*R+1),Z.push(st||[],I+1,2*C+1,2*R),Z.push(St||[],I+1,2*C+1,2*R+1)}}},ut.prototype.getTile=function(B,I,C){var R=this.options,U=R.extent,j=R.debug;if(B<0||B>24)return null;var X=1<<B,Z=Wr(B,I=(I%X+X)%X,C);if(this.tiles[Z])return yn(this.tiles[Z],U);j>1&&console.log("drilling down to z%d-%d-%d",B,I,C);for(var q,Q=B,oe=I,ye=C;!q&&Q>0;)Q--,oe=Math.floor(oe/2),ye=Math.floor(ye/2),q=this.tiles[Wr(Q,oe,ye)];return q&&q.source?(j>1&&console.log("found parent tile z%d-%d-%d",Q,oe,ye),j>1&&console.time("drilling down"),this.splitTile(q.source,Q,oe,ye,B,I,C),j>1&&console.timeEnd("drilling down"),this.tiles[Z]?yn(this.tiles[Z],U):null):null};class gi extends Ct{constructor(I,C,R,U){super(I,C,R,fi),this._dataUpdateable=new Map,this.loadGeoJSON=(j,X)=>{const{promoteId:Z}=j;if(j.request)return h.getJSON(j.request,(q,Q,oe,ye)=>{this._dataUpdateable=ei(Q,Z)?Yt(Q,Z):void 0,X(q,Q,oe,ye)});if(typeof j.data=="string")try{const q=JSON.parse(j.data);this._dataUpdateable=ei(q,Z)?Yt(q,Z):void 0,X(null,q)}catch{X(new Error(`Input data given to '${j.source}' is not a valid GeoJSON object.`))}else j.dataDiff?this._dataUpdateable?(function(q,Q,oe){var ye,ce,Ne,je;if(Q.removeAll&&q.clear(),Q.remove)for(const Re of Q.remove)q.delete(Re);if(Q.add)for(const Re of Q.add){const qe=Vi(Re,oe);qe!=null&&q.set(qe,Re)}if(Q.update)for(const Re of Q.update){let qe=q.get(Re.id);if(qe==null)continue;const st=!Re.removeAllProperties&&(((ye=Re.removeProperties)===null||ye===void 0?void 0:ye.length)>0||((ce=Re.addOrUpdateProperties)===null||ce===void 0?void 0:ce.length)>0);if((Re.newGeometry||Re.removeAllProperties||st)&&(qe={...qe},q.set(Re.id,qe),st&&(qe.properties={...qe.properties})),Re.newGeometry&&(qe.geometry=Re.newGeometry),Re.removeAllProperties)qe.properties={};else if(((Ne=Re.removeProperties)===null||Ne===void 0?void 0:Ne.length)>0)for(const St of Re.removeProperties)Object.prototype.hasOwnProperty.call(qe.properties,St)&&delete qe.properties[St];if(((je=Re.addOrUpdateProperties)===null||je===void 0?void 0:je.length)>0)for(const{key:St,value:ot}of Re.addOrUpdateProperties)qe.properties[St]=ot}}(this._dataUpdateable,j.dataDiff,Z),X(null,{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())})):X(new Error(`Cannot update existing geojson data in ${j.source}`)):X(new Error(`Input data given to '${j.source}' is not a valid GeoJSON object.`));return{cancel:()=>{}}},U&&(this.loadGeoJSON=U)}loadData(I,C){var R;(R=this._pendingRequest)===null||R===void 0||R.cancel(),this._pendingCallback&&this._pendingCallback(null,{abandoned:!0});const U=!!(I&&I.request&&I.request.collectResourceTiming)&&new h.RequestPerformance(I.request);this._pendingCallback=C,this._pendingRequest=this.loadGeoJSON(I,(j,X)=>{if(delete this._pendingCallback,delete this._pendingRequest,j||!X)return C(j);if(typeof X!="object")return C(new Error(`Input data given to '${I.source}' is not a valid GeoJSON object.`));{mr(X,!0);try{if(I.filter){const q=h.createExpression(I.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(q.result==="error")throw new Error(q.value.map(oe=>`${oe.key}: ${oe.message}`).join(", "));X={type:"FeatureCollection",features:X.features.filter(oe=>q.value.evaluate({zoom:0},oe))}}this._geoJSONIndex=I.cluster?new Nr(function({superclusterOptions:q,clusterProperties:Q}){if(!Q||!q)return q;const oe={},ye={},ce={accumulated:null,zoom:0},Ne={properties:null},je=Object.keys(Q);for(const Re of je){const[qe,st]=Q[Re],St=h.createExpression(st),ot=h.createExpression(typeof qe=="string"?[qe,["accumulated"],["get",Re]]:qe);oe[Re]=St.value,ye[Re]=ot.value}return q.map=Re=>{Ne.properties=Re;const qe={};for(const st of je)qe[st]=oe[st].evaluate(ce,Ne);return qe},q.reduce=(Re,qe)=>{Ne.properties=qe;for(const st of je)ce.accumulated=Re[st],Re[st]=ye[st].evaluate(ce,Ne)},q}(I)).load(X.features):function(q,Q){return new ut(q,Q)}(X,I.geojsonVtOptions)}catch(q){return C(q)}this.loaded={};const Z={};if(U){const q=U.finish();q&&(Z.resourceTiming={},Z.resourceTiming[I.source]=JSON.parse(JSON.stringify(q)))}C(null,Z)}})}reloadTile(I,C){const R=this.loaded;return R&&R[I.uid]?super.reloadTile(I,C):this.loadTile(I,C)}removeSource(I,C){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),C()}getClusterExpansionZoom(I,C){try{C(null,this._geoJSONIndex.getClusterExpansionZoom(I.clusterId))}catch(R){C(R)}}getClusterChildren(I,C){try{C(null,this._geoJSONIndex.getChildren(I.clusterId))}catch(R){C(R)}}getClusterLeaves(I,C){try{C(null,this._geoJSONIndex.getLeaves(I.clusterId,I.limit,I.offset))}catch(R){C(R)}}}class yr{constructor(I){this.self=I,this.actor=new h.Actor(I,this),this.layerIndexes={},this.availableImages={},this.workerSourceTypes={vector:Ct,geojson:gi},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(C,R)=>{if(this.workerSourceTypes[C])throw new Error(`Worker source with name "${C}" already registered.`);this.workerSourceTypes[C]=R},this.self.registerRTLTextPlugin=C=>{if(h.plugin.isParsed())throw new Error("RTL text plugin already registered.");h.plugin.applyArabicShaping=C.applyArabicShaping,h.plugin.processBidirectionalText=C.processBidirectionalText,h.plugin.processStyledBidirectionalText=C.processStyledBidirectionalText}}setReferrer(I,C){this.referrer=C}setImages(I,C,R){this.availableImages[I]=C;for(const U in this.workerSources[I]){const j=this.workerSources[I][U];for(const X in j)j[X].availableImages=C}R()}setLayers(I,C,R){this.getLayerIndex(I).replace(C),R()}updateLayers(I,C,R){this.getLayerIndex(I).update(C.layers,C.removedIds),R()}loadTile(I,C,R){this.getWorkerSource(I,C.type,C.source).loadTile(C,R)}loadDEMTile(I,C,R){this.getDEMWorkerSource(I,C.source).loadTile(C,R)}reloadTile(I,C,R){this.getWorkerSource(I,C.type,C.source).reloadTile(C,R)}abortTile(I,C,R){this.getWorkerSource(I,C.type,C.source).abortTile(C,R)}removeTile(I,C,R){this.getWorkerSource(I,C.type,C.source).removeTile(C,R)}removeDEMTile(I,C){this.getDEMWorkerSource(I,C.source).removeTile(C)}removeSource(I,C,R){if(!this.workerSources[I]||!this.workerSources[I][C.type]||!this.workerSources[I][C.type][C.source])return;const U=this.workerSources[I][C.type][C.source];delete this.workerSources[I][C.type][C.source],U.removeSource!==void 0?U.removeSource(C,R):R()}loadWorkerSource(I,C,R){try{this.self.importScripts(C.url),R()}catch(U){R(U.toString())}}syncRTLPluginState(I,C,R){try{h.plugin.setState(C);const U=h.plugin.getPluginURL();if(h.plugin.isLoaded()&&!h.plugin.isParsed()&&U!=null){this.self.importScripts(U);const j=h.plugin.isParsed();R(j?void 0:new Error(`RTL Text Plugin failed to import scripts from ${U}`),j)}}catch(U){R(U.toString())}}getAvailableImages(I){let C=this.availableImages[I];return C||(C=[]),C}getLayerIndex(I){let C=this.layerIndexes[I];return C||(C=this.layerIndexes[I]=new et),C}getWorkerSource(I,C,R){if(this.workerSources[I]||(this.workerSources[I]={}),this.workerSources[I][C]||(this.workerSources[I][C]={}),!this.workerSources[I][C][R]){const U={send:(j,X,Z)=>{this.actor.send(j,X,Z,I)}};this.workerSources[I][C][R]=new this.workerSourceTypes[C](U,this.getLayerIndex(I),this.getAvailableImages(I))}return this.workerSources[I][C][R]}getDEMWorkerSource(I,C){return this.demWorkerSources[I]||(this.demWorkerSources[I]={}),this.demWorkerSources[I][C]||(this.demWorkerSources[I][C]=new Ft),this.demWorkerSources[I][C]}}return h.isWorker()&&(self.worker=new yr(self)),yr}),de(["./shared"],function(h){var ve=Ge;function Ge(o){return!function(t){return typeof window>"u"||typeof document>"u"?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var s,l,d=new Blob([""],{type:"text/javascript"}),m=URL.createObjectURL(d);try{l=new Worker(m),s=!0}catch{s=!1}return l&&l.terminate(),URL.revokeObjectURL(m),s}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var s=document.createElement("canvas");s.width=s.height=1;var l=s.getContext("2d");if(!l)return!1;var d=l.getImageData(0,0,1,1);return d&&d.width===s.width}()?(et[n=t&&t.failIfMajorPerformanceCaveat]===void 0&&(et[n]=function(s){var l,d=function(m){var g=document.createElement("canvas"),y=Object.create(Ge.webGLContextAttributes);return y.failIfMajorPerformanceCaveat=m,g.getContext("webgl",y)||g.getContext("experimental-webgl",y)}(s);if(!d)return!1;try{l=d.createShader(d.VERTEX_SHADER)}catch{return!1}return!(!l||d.isContextLost())&&(d.shaderSource(l,"void main() {}"),d.compileShader(l),d.getShaderParameter(l,d.COMPILE_STATUS)===!0)}(n)),et[n]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var n}(o)}var et={};Ge.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};var Ye="3.0.0-pre.4";function pe(o,t){if(Array.isArray(o)){if(!Array.isArray(t)||o.length!==t.length)return!1;for(let n=0;n<o.length;n++)if(!pe(o[n],t[n]))return!1;return!0}if(typeof o=="object"&&o!==null&&t!==null){if(typeof t!="object"||Object.keys(o).length!==Object.keys(t).length)return!1;for(const n in o)if(!pe(o[n],t[n]))return!1;return!0}return o===t}class ee{static testProp(t){if(!ee.docStyle)return t[0];for(let n=0;n<t.length;n++)if(t[n]in ee.docStyle)return t[n];return t[0]}static create(t,n,s){const l=window.document.createElement(t);return n!==void 0&&(l.className=n),s&&s.appendChild(l),l}static createNS(t,n){return window.document.createElementNS(t,n)}static disableDrag(){ee.docStyle&&ee.selectProp&&(ee.userSelect=ee.docStyle[ee.selectProp],ee.docStyle[ee.selectProp]="none")}static enableDrag(){ee.docStyle&&ee.selectProp&&(ee.docStyle[ee.selectProp]=ee.userSelect)}static setTransform(t,n){t.style[ee.transformProp]=n}static addEventListener(t,n,s,l={}){t.addEventListener(n,s,"passive"in l?l:l.capture)}static removeEventListener(t,n,s,l={}){t.removeEventListener(n,s,"passive"in l?l:l.capture)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",ee.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",ee.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",ee.suppressClickInternal,!0)},0)}static mousePos(t,n){const s=t.getBoundingClientRect();return new h.pointGeometry(n.clientX-s.left-t.clientLeft,n.clientY-s.top-t.clientTop)}static touchPos(t,n){const s=t.getBoundingClientRect(),l=[];for(let d=0;d<n.length;d++)l.push(new h.pointGeometry(n[d].clientX-s.left-t.clientLeft,n[d].clientY-s.top-t.clientTop));return l}static mouseButton(t){return t.button}static remove(t){t.parentNode&&t.parentNode.removeChild(t)}}ee.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,ee.selectProp=ee.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),ee.transformProp=ee.testProp(["transform","WebkitTransform"]);const Be={supported:!1,testSupport:function(o){!mr&&Ft&&(dn?Ci(o):Ct=o)}};let Ct,Ft,mr=!1,dn=!1;function Ci(o){const t=o.createTexture();o.bindTexture(o.TEXTURE_2D,t);try{if(o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,Ft),o.isContextLost())return;Be.supported=!0}catch{}o.deleteTexture(t),mr=!0}var Or;typeof document<"u"&&(Ft=document.createElement("img"),Ft.onload=function(){Ct&&Ci(Ct),Ct=null,dn=!0},Ft.onerror=function(){mr=!0,Ct=null},Ft.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(o){let t,n,s,l;o.resetRequestQueue=()=>{t=[],n=0,s=0,l={}},o.addThrottleControl=g=>{const y=s++;return l[y]=g,y},o.removeThrottleControl=g=>{delete l[g]};const d=()=>{const g=Object.keys(l);let y=!1;if(g.length>0){for(const x of g)if(y=l[x](),y)break}return y};o.getImage=(g,y)=>{Be.supported&&(g.headers||(g.headers={}),g.headers.accept="image/webp,*/*");const x={requestParameters:g,callback:y,cancelled:!1,completed:!1,cancel:()=>{}};return t.push(x),d()||o.processQueue(),x};const m=g=>{const{requestParameters:y,callback:x}=g;return h.getArrayBuffer(y,(S,T,M,F)=>{S?x(S):T&&((O,D)=>{typeof createImageBitmap=="function"?h.arrayBufferToImageBitmap(O,D):h.arrayBufferToImage(O,D)})(T,(O,D)=>{O!=null?x(O):D!=null&&x(null,D,{cacheControl:M,expires:F})}),g.cancelled||(g.completed=!0,n--,d()||o.processQueue())})};o.processQueue=(g=0)=>{g<=0&&(g=d()?h.config.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:h.config.MAX_PARALLEL_IMAGE_REQUESTS);for(let y=n;y<g&&t.length>0;y++){const x=t.shift();if(x.cancelled)continue;const S=m(x);n++,x.innerRequest=S,x.cancel=()=>{var T;(T=x).completed||T.cancelled||(n--,T.cancelled=!0,T.innerRequest.cancel(),o.processQueue())}}return t.length}}(Or||(Or={})),Or.resetRequestQueue();var dt,Qt=Or;(function(o){o.Glyphs="Glyphs",o.Image="Image",o.Source="Source",o.SpriteImage="SpriteImage",o.SpriteJSON="SpriteJSON",o.Style="Style",o.Tile="Tile",o.Unknown="Unknown"})(dt||(dt={}));class us{constructor(t){this._transformRequestFn=t}transformRequest(t,n){return this._transformRequestFn&&this._transformRequestFn(t,n)||{url:t}}normalizeSpriteURL(t,n,s){const l=function(d){const m=d.match(Oi);if(!m)throw new Error(`Unable to parse URL "${d}"`);return{protocol:m[1],authority:m[2],path:m[3]||"/",params:m[4]?m[4].split("&"):[]}}(t);return l.path+=`${n}${s}`,function(d){const m=d.params.length?`?${d.params.join("&")}`:"";return`${d.protocol}://${d.authority}${d.path}${m}`}(l)}setTransformRequest(t){this._transformRequestFn=t}}const Oi=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function pn(o){var t=new h.ARRAY_TYPE(3);return t[0]=o[0],t[1]=o[1],t[2]=o[2],t}var fr,gr=function(o,t,n){return o[0]=t[0]-n[0],o[1]=t[1]-n[1],o[2]=t[2]-n[2],o};fr=new h.ARRAY_TYPE(3),h.ARRAY_TYPE!=Float32Array&&(fr[0]=0,fr[1]=0,fr[2]=0);var da=function(o){var t=o[0],n=o[1];return t*t+n*n};function nr(o){return typeof o=="string"?[{id:"default",url:o}]:o??[]}(function(){var o=new h.ARRAY_TYPE(2);h.ARRAY_TYPE!=Float32Array&&(o[0]=0,o[1]=0)})();class Mt{constructor(t,n,s,l){this.context=t,this.format=s,this.texture=t.gl.createTexture(),this.update(n,l)}update(t,n,s){const{width:l,height:d}=t,m=!(this.size&&this.size[0]===l&&this.size[1]===d||s),{context:g}=this,{gl:y}=g;if(this.useMipmap=!!(n&&n.useMipmap),y.bindTexture(y.TEXTURE_2D,this.texture),g.pixelStoreUnpackFlipY.set(!1),g.pixelStoreUnpack.set(1),g.pixelStoreUnpackPremultiplyAlpha.set(this.format===y.RGBA&&(!n||n.premultiply!==!1)),m)this.size=[l,d],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||h.isImageBitmap(t)?y.texImage2D(y.TEXTURE_2D,0,this.format,this.format,y.UNSIGNED_BYTE,t):y.texImage2D(y.TEXTURE_2D,0,this.format,l,d,0,this.format,y.UNSIGNED_BYTE,t.data);else{const{x,y:S}=s||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||h.isImageBitmap(t)?y.texSubImage2D(y.TEXTURE_2D,0,x,S,y.RGBA,y.UNSIGNED_BYTE,t):y.texSubImage2D(y.TEXTURE_2D,0,x,S,l,d,y.RGBA,y.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&y.generateMipmap(y.TEXTURE_2D)}bind(t,n,s){const{context:l}=this,{gl:d}=l;d.bindTexture(d.TEXTURE_2D,this.texture),s!==d.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(s=d.LINEAR),t!==this.filter&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,t),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,s||t),this.filter=t),n!==this.wrap&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,n),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,n),this.wrap=n)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}function pa(o){const{userImage:t}=o;return!!(t&&t.render&&t.render())&&(o.data.replace(new Uint8Array(t.data.buffer)),!0)}class He extends h.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new h.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:n,callback:s}of this.requestors)this._notify(n,s);this.requestors=[]}}getImage(t){const n=this.images[t];if(n&&!n.data&&n.spriteData){const s=n.spriteData;n.data=new h.RGBAImage({width:s.width,height:s.height},s.context.getImageData(s.x,s.y,s.width,s.height).data),n.spriteData=null}return n}addImage(t,n){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,n)&&(this.images[t]=n)}_validate(t,n){let s=!0;const l=n.data||n.spriteData;return this._validateStretch(n.stretchX,l&&l.width)||(this.fire(new h.ErrorEvent(new Error(`Image "${t}" has invalid "stretchX" value`))),s=!1),this._validateStretch(n.stretchY,l&&l.height)||(this.fire(new h.ErrorEvent(new Error(`Image "${t}" has invalid "stretchY" value`))),s=!1),this._validateContent(n.content,n)||(this.fire(new h.ErrorEvent(new Error(`Image "${t}" has invalid "content" value`))),s=!1),s}_validateStretch(t,n){if(!t)return!0;let s=0;for(const l of t){if(l[0]<s||l[1]<l[0]||n<l[1])return!1;s=l[1]}return!0}_validateContent(t,n){if(!t)return!0;if(t.length!==4)return!1;const s=n.spriteData,l=s&&s.width||n.data.width,d=s&&s.height||n.data.height;return!(t[0]<0||l<t[0]||t[1]<0||d<t[1]||t[2]<0||l<t[2]||t[3]<0||d<t[3]||t[2]<t[0]||t[3]<t[1])}updateImage(t,n,s=!0){const l=this.getImage(t);if(s&&(l.data.width!==n.data.width||l.data.height!==n.data.height))throw new Error(`size mismatch between old image (${l.data.width}x${l.data.height}) and new image (${n.data.width}x${n.data.height}).`);n.version=l.version+1,this.images[t]=n,this.updatedImages[t]=!0}removeImage(t){const n=this.images[t];delete this.images[t],delete this.patterns[t],n.userImage&&n.userImage.onRemove&&n.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t,n){let s=!0;if(!this.isLoaded())for(const l of t)this.images[l]||(s=!1);this.isLoaded()||s?this._notify(t,n):this.requestors.push({ids:t,callback:n})}_notify(t,n){const s={};for(const l of t){const d=this.getImage(l);d?s[l]={data:d.data.clone(),pixelRatio:d.pixelRatio,sdf:d.sdf,version:d.version,stretchX:d.stretchX,stretchY:d.stretchY,content:d.content,hasRenderCallback:!!(d.userImage&&d.userImage.render)}:(this.fire(new h.Event("styleimagemissing",{id:l})),h.warnOnce(`Image "${l}" 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.`))}n(null,s)}getPixelSize(){const{width:t,height:n}=this.atlasImage;return{width:t,height:n}}getPattern(t){const n=this.patterns[t],s=this.getImage(t);if(!s)return null;if(n&&n.position.version===s.version)return n.position;if(n)n.position.version=s.version;else{const l={w:s.data.width+2,h:s.data.height+2,x:0,y:0},d=new h.ImagePosition(l,s);this.patterns[t]={bin:l,position:d}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const n=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new Mt(t,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const d in this.patterns)t.push(this.patterns[d].bin);const{w:n,h:s}=h.potpack(t),l=this.atlasImage;l.resize({width:n||1,height:s||1});for(const d in this.patterns){const{bin:m}=this.patterns[d],g=m.x+1,y=m.y+1,x=this.getImage(d).data,S=x.width,T=x.height;h.RGBAImage.copy(x,l,{x:0,y:0},{x:g,y},{width:S,height:T}),h.RGBAImage.copy(x,l,{x:0,y:T-1},{x:g,y:y-1},{width:S,height:1}),h.RGBAImage.copy(x,l,{x:0,y:0},{x:g,y:y+T},{width:S,height:1}),h.RGBAImage.copy(x,l,{x:S-1,y:0},{x:g-1,y},{width:1,height:T}),h.RGBAImage.copy(x,l,{x:0,y:0},{x:g+S,y},{width:1,height:T})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const n of t){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;const s=this.getImage(n);s||h.warnOnce(`Image with ID: "${n}" was not found`),pa(s)&&this.updateImage(n,s)}}}const Ui=1e20;function Ur(o,t,n,s,l,d,m,g,y){for(let x=t;x<t+s;x++)Er(o,n*d+x,d,l,m,g,y);for(let x=n;x<n+l;x++)Er(o,x*d+t,1,s,m,g,y)}function Er(o,t,n,s,l,d,m){d[0]=0,m[0]=-Ui,m[1]=Ui,l[0]=o[t];for(let g=1,y=0,x=0;g<s;g++){l[g]=o[t+g*n];const S=g*g;do{const T=d[y];x=(l[g]-l[T]+S-T*T)/(g-T)/2}while(x<=m[y]&&--y>-1);y++,d[y]=g,m[y]=x,m[y+1]=Ui}for(let g=0,y=0;g<s;g++){for(;m[y+1]<g;)y++;const x=d[y],S=g-x;o[t+g*n]=l[x]+S*S}}class ar{constructor(t,n){this.requestManager=t,this.localIdeographFontFamily=n,this.entries={}}setURL(t){this.url=t}getGlyphs(t,n){const s=[];for(const l in t)for(const d of t[l])s.push({stack:l,id:d});h.asyncAll(s,({stack:l,id:d},m)=>{let g=this.entries[l];g||(g=this.entries[l]={glyphs:{},requests:{},ranges:{}});let y=g.glyphs[d];if(y!==void 0)return void m(null,{stack:l,id:d,glyph:y});if(y=this._tinySDF(g,l,d),y)return g.glyphs[d]=y,void m(null,{stack:l,id:d,glyph:y});const x=Math.floor(d/256);if(256*x>65535)return void m(new Error("glyphs > 65535 not supported"));if(g.ranges[x])return void m(null,{stack:l,id:d,glyph:y});if(!this.url)return void m(new Error("glyphsUrl is not set"));let S=g.requests[x];S||(S=g.requests[x]=[],ar.loadGlyphRange(l,x,this.url,this.requestManager,(T,M)=>{if(M){for(const F in M)this._doesCharSupportLocalGlyph(+F)||(g.glyphs[+F]=M[+F]);g.ranges[x]=!0}for(const F of S)F(T,M);delete g.requests[x]})),S.push((T,M)=>{T?m(T):M&&m(null,{stack:l,id:d,glyph:M[d]||null})})},(l,d)=>{if(l)n(l);else if(d){const m={};for(const{stack:g,id:y,glyph:x}of d)(m[g]||(m[g]={}))[y]=x&&{id:x.id,bitmap:x.bitmap.clone(),metrics:x.metrics};n(null,m)}})}_doesCharSupportLocalGlyph(t){return!!this.localIdeographFontFamily&&(h.unicodeBlockLookup["CJK Unified Ideographs"](t)||h.unicodeBlockLookup["Hangul Syllables"](t)||h.unicodeBlockLookup.Hiragana(t)||h.unicodeBlockLookup.Katakana(t))}_tinySDF(t,n,s){const l=this.localIdeographFontFamily;if(!l||!this._doesCharSupportLocalGlyph(s))return;let d=t.tinySDF;if(!d){let g="400";/bold/i.test(n)?g="900":/medium/i.test(n)?g="500":/light/i.test(n)&&(g="200"),d=t.tinySDF=new ar.TinySDF({fontSize:24,buffer:3,radius:8,cutoff:.25,fontFamily:l,fontWeight:g})}const m=d.draw(String.fromCharCode(s));return{id:s,bitmap:new h.AlphaImage({width:m.width||30,height:m.height||30},m.data),metrics:{width:m.glyphWidth||24,height:m.glyphHeight||24,left:m.glyphLeft||0,top:m.glyphTop-27||-8,advance:m.glyphAdvance||24}}}}ar.loadGlyphRange=function(o,t,n,s,l){const d=256*t,m=d+255,g=s.transformRequest(n.replace("{fontstack}",o).replace("{range}",`${d}-${m}`),dt.Glyphs);h.getArrayBuffer(g,(y,x)=>{if(y)l(y);else if(x){const S={};for(const T of h.parseGlyphPbf(x))S[T.id]=T;l(null,S)}})},ar.TinySDF=class{constructor({fontSize:o=24,buffer:t=3,radius:n=8,cutoff:s=.25,fontFamily:l="sans-serif",fontWeight:d="normal",fontStyle:m="normal"}={}){this.buffer=t,this.cutoff=s,this.radius=n;const g=this.size=o+4*t,y=this._createCanvas(g),x=this.ctx=y.getContext("2d",{willReadFrequently:!0});x.font=`${m} ${d} ${o}px ${l}`,x.textBaseline="alphabetic",x.textAlign="left",x.fillStyle="black",this.gridOuter=new Float64Array(g*g),this.gridInner=new Float64Array(g*g),this.f=new Float64Array(g),this.z=new Float64Array(g+1),this.v=new Uint16Array(g)}_createCanvas(o){const t=document.createElement("canvas");return t.width=t.height=o,t}draw(o){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:s,actualBoundingBoxLeft:l,actualBoundingBoxRight:d}=this.ctx.measureText(o),m=Math.ceil(n),g=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(d-l))),y=Math.min(this.size-this.buffer,m+Math.ceil(s)),x=g+2*this.buffer,S=y+2*this.buffer,T=Math.max(x*S,0),M=new Uint8ClampedArray(T),F={data:M,width:x,height:S,glyphWidth:g,glyphHeight:y,glyphTop:m,glyphLeft:0,glyphAdvance:t};if(g===0||y===0)return F;const{ctx:O,buffer:D,gridInner:G,gridOuter:Y}=this;O.clearRect(D,D,g,y),O.fillText(o,D,D+m);const H=O.getImageData(D,D,g,y);Y.fill(Ui,0,T),G.fill(0,0,T);for(let V=0;V<y;V++)for(let te=0;te<g;te++){const ae=H.data[4*(V*g+te)+3]/255;if(ae===0)continue;const se=(V+D)*x+te+D;if(ae===1)Y[se]=0,G[se]=Ui;else{const ue=.5-ae;Y[se]=ue>0?ue*ue:0,G[se]=ue<0?ue*ue:0}}Ur(Y,0,0,x,S,x,this.f,this.v,this.z),Ur(G,D,D,g,y,x,this.f,this.v,this.z);for(let V=0;V<T;V++){const te=Math.sqrt(Y[V])-Math.sqrt(G[V]);M[V]=Math.round(255-255*(te/this.radius+this.cutoff))}return F}};const ma=new h.Properties({anchor:new h.DataConstantProperty(h.spec.light.anchor),position:new class{constructor(){this.specification=h.spec.light.position}possiblyEvaluate(o,t){return h.sphericalToCartesian(o.expression.evaluate(t))}interpolate(o,t,n){return{x:h.number(o.x,t.x,n),y:h.number(o.y,t.y,n),z:h.number(o.z,t.z,n)}}},color:new h.DataConstantProperty(h.spec.light.color),intensity:new h.DataConstantProperty(h.spec.light.intensity)}),mn="-transition";class Vr extends h.Evented{constructor(t){super(),this._transitionable=new h.Transitionable(ma),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,n={}){if(!this._validate(h.validateLight,t,n))for(const s in t){const l=t[s];s.endsWith(mn)?this._transitionable.setTransition(s.slice(0,-mn.length),l):this._transitionable.setValue(s,l)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,n,s){return(!s||s.validate!==!1)&&h.emitValidationErrors(this,t.call(h.validateStyle,h.extend({value:n,style:{glyphs:!0,sprite:!0},styleSpec:h.spec})))}}class $n{constructor(t,n){this.width=t,this.height=n,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,n){const s=t.join(",")+String(n);return this.dashEntry[s]||(this.dashEntry[s]=this.addDash(t,n)),this.dashEntry[s]}getDashRanges(t,n,s){const l=[];let d=t.length%2==1?-t[t.length-1]*s:0,m=t[0]*s,g=!0;l.push({left:d,right:m,isDash:g,zeroLength:t[0]===0});let y=t[0];for(let x=1;x<t.length;x++){g=!g;const S=t[x];d=y*s,y+=S,m=y*s,l.push({left:d,right:m,isDash:g,zeroLength:S===0})}return l}addRoundDash(t,n,s){const l=n/2;for(let d=-s;d<=s;d++){const m=this.width*(this.nextRow+s+d);let g=0,y=t[g];for(let x=0;x<this.width;x++){x/y.right>1&&(y=t[++g]);const S=Math.abs(x-y.left),T=Math.abs(x-y.right),M=Math.min(S,T);let F;const O=d/s*(l+1);if(y.isDash){const D=l-Math.abs(O);F=Math.sqrt(M*M+D*D)}else F=l-Math.sqrt(M*M+O*O);this.data[m+x]=Math.max(0,Math.min(255,F+128))}}}addRegularDash(t){for(let g=t.length-1;g>=0;--g){const y=t[g],x=t[g+1];y.zeroLength?t.splice(g,1):x&&x.isDash===y.isDash&&(x.left=y.left,t.splice(g,1))}const n=t[0],s=t[t.length-1];n.isDash===s.isDash&&(n.left=s.left-this.width,s.right=n.right+this.width);const l=this.width*this.nextRow;let d=0,m=t[d];for(let g=0;g<this.width;g++){g/m.right>1&&(m=t[++d]);const y=Math.abs(g-m.left),x=Math.abs(g-m.right),S=Math.min(y,x);this.data[l+g]=Math.max(0,Math.min(255,(m.isDash?S:-S)+128))}}addDash(t,n){const s=n?7:0,l=2*s+1;if(this.nextRow+l>this.height)return h.warnOnce("LineAtlas out of space"),null;let d=0;for(let g=0;g<t.length;g++)d+=t[g];if(d!==0){const g=this.width/d,y=this.getDashRanges(t,this.width,g);n?this.addRoundDash(y,g,s):this.addRegularDash(y)}const m={y:(this.nextRow+s+.5)/this.height,height:2*s/this.height,width:d};return this.nextRow+=l,this.dirty=!0,m}bind(t){const n=t.gl;this.texture?(n.bindTexture(n.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,n.texSubImage2D(n.TEXTURE_2D,0,0,0,this.width,this.height,n.ALPHA,n.UNSIGNED_BYTE,this.data))):(this.texture=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this.texture),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texImage2D(n.TEXTURE_2D,0,n.ALPHA,this.width,this.height,0,n.ALPHA,n.UNSIGNED_BYTE,this.data))}}class Nr{constructor(t,n,s){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=s;const l=this.workerPool.acquire(s);for(let d=0;d<l.length;d++){const m=new Nr.Actor(l[d],n,s);m.name=`Worker ${d}`,this.actors.push(m)}if(!this.actors.length)throw new Error("No actors found")}broadcast(t,n,s){h.asyncAll(this.actors,(l,d)=>{l.send(t,n,d)},s=s||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.actors.forEach(n=>{n.remove()}),this.actors=[],t&&this.workerPool.release(this.id)}}function fn(o,t,n){const s=function(l,d){if(l)return n(l);if(d){const m=h.pick(h.extend(d,o),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);d.vector_layers&&(m.vectorLayers=d.vector_layers,m.vectorLayerIds=m.vectorLayers.map(g=>g.id)),n(null,m)}};return o.url?h.getJSON(t.transformRequest(o.url,dt.Source),s):h.exported.frame(()=>s(null,o))}Nr.Actor=h.Actor;class $r{constructor(t,n,s){this.bounds=h.LngLatBounds.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=s||24}validateBounds(t){return Array.isArray(t)&&t.length===4?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const n=Math.pow(2,t.z),s=Math.floor(h.mercatorXfromLng(this.bounds.getWest())*n),l=Math.floor(h.mercatorYfromLat(this.bounds.getNorth())*n),d=Math.ceil(h.mercatorXfromLng(this.bounds.getEast())*n),m=Math.ceil(h.mercatorYfromLat(this.bounds.getSouth())*n);return t.x>=s&&t.x<d&&t.y>=l&&t.y<m}}class Gr extends h.Evented{constructor(t,n,s,l){if(super(),this.id=t,this.dispatcher=s,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,h.extend(this,h.pick(n,["url","scheme","tileSize","promoteId"])),this._options=h.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(l)}load(){this._loaded=!1,this.fire(new h.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=fn(this._options,this.map._requestManager,(t,n)=>{this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),t?this.fire(new h.ErrorEvent(t)):n&&(h.extend(this,n),n.bounds&&(this.tileBounds=new $r(n.bounds,this.minzoom,this.maxzoom)),this.fire(new h.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new h.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.load()}setTiles(t){return this.setSourceProperty(()=>{this._options.tiles=t}),this}setUrl(t){return this.setSourceProperty(()=>{this.url=t,this._options.url=t}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return h.extend({},this._options)}loadTile(t,n){const s=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),l={request:this.map._requestManager.transformRequest(s,dt.Tile),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};function d(m,g){return delete t.request,t.aborted?n(null):m&&m.status!==404?n(m):(g&&g.resourceTiming&&(t.resourceTiming=g.resourceTiming),this.map._refreshExpiredTiles&&g&&t.setExpiryData(g),t.loadVectorData(g,this.map.painter),n(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}l.request.collectResourceTiming=this._collectResourceTiming,t.actor&&t.state!=="expired"?t.state==="loading"?t.reloadCallback=n:t.request=t.actor.send("reloadTile",l,d.bind(this)):(t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",l,d.bind(this)))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id},void 0)}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id},void 0)}hasTransition(){return!1}}class Ir extends h.Evented{constructor(t,n,s,l){super(),this.id=t,this.dispatcher=s,this.setEventedParent(l),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=h.extend({type:"raster"},n),h.extend(this,h.pick(n,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new h.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=fn(this._options,this.map._requestManager,(t,n)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new h.ErrorEvent(t)):n&&(h.extend(this,n),n.bounds&&(this.tileBounds=new $r(n.bounds,this.minzoom,this.maxzoom)),this.fire(new h.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new h.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return h.extend({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t,n){const s=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.request=Qt.getImage(this.map._requestManager.transformRequest(s,dt.Tile),(l,d,m)=>{if(delete t.request,t.aborted)t.state="unloaded",n(null);else if(l)t.state="errored",n(l);else if(d){this.map._refreshExpiredTiles&&t.setExpiryData(m);const g=this.map.painter.context,y=g.gl;t.texture=this.map.painter.getTileTexture(d.width),t.texture?t.texture.update(d,{useMipmap:!0}):(t.texture=new Mt(g,d,y.RGBA,{useMipmap:!0}),t.texture.bind(y.LINEAR,y.CLAMP_TO_EDGE,y.LINEAR_MIPMAP_NEAREST),g.extTextureFilterAnisotropic&&y.texParameterf(y.TEXTURE_2D,g.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,g.extTextureFilterAnisotropicMax)),t.state="loaded",n(null)}})}abortTile(t,n){t.request&&(t.request.cancel(),delete t.request),n()}unloadTile(t,n){t.texture&&this.map.painter.saveTileTexture(t.texture),n()}hasTransition(){return!1}}let le;class Se extends Ir{constructor(t,n,s,l){super(t,n,s,l),this.type="raster-dem",this.maxzoom=22,this._options=h.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}serialize(){return{type:"raster-dem",url:this.url,tileSize:this.tileSize,tiles:this.tiles,bounds:this.bounds,encoding:this.encoding}}loadTile(t,n){const s=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);function l(d,m){d&&(t.state="errored",n(d)),m&&(t.dem=m,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded",n(null))}t.request=Qt.getImage(this.map._requestManager.transformRequest(s,dt.Tile),function(d,m){if(delete t.request,t.aborted)t.state="unloaded",n(null);else if(d)t.state="errored",n(d);else if(m){this.map._refreshExpiredTiles&&t.setExpiryData(m),delete m.cacheControl,delete m.expires;const g=h.isImageBitmap(m)&&(le==null&&(le=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),le)?m:h.exported.getImageData(m,1),y={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:g,encoding:this.encoding};t.actor&&t.state!=="expired"||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",y,l.bind(this)))}}.bind(this)),t.neighboringTiles=this._getNeighboringTiles(t.tileID)}_getNeighboringTiles(t){const n=t.canonical,s=Math.pow(2,n.z),l=(n.x-1+s)%s,d=n.x===0?t.wrap-1:t.wrap,m=(n.x+1+s)%s,g=n.x+1===s?t.wrap+1:t.wrap,y={};return y[new h.OverscaledTileID(t.overscaledZ,d,n.z,l,n.y).key]={backfilled:!1},y[new h.OverscaledTileID(t.overscaledZ,g,n.z,m,n.y).key]={backfilled:!1},n.y>0&&(y[new h.OverscaledTileID(t.overscaledZ,d,n.z,l,n.y-1).key]={backfilled:!1},y[new h.OverscaledTileID(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},y[new h.OverscaledTileID(t.overscaledZ,g,n.z,m,n.y-1).key]={backfilled:!1}),n.y+1<s&&(y[new h.OverscaledTileID(t.overscaledZ,d,n.z,l,n.y+1).key]={backfilled:!1},y[new h.OverscaledTileID(t.overscaledZ,t.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},y[new h.OverscaledTileID(t.overscaledZ,g,n.z,m,n.y+1).key]={backfilled:!1}),y}unloadTile(t){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded",t.actor&&t.actor.send("removeDEMTile",{uid:t.uid,source:this.id})}}class Gn extends h.Evented{constructor(t,n,s,l){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._pendingLoads=0,this.actor=s.getActor(),this.setEventedParent(l),this._data=n.data,this._options=h.extend({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId;const d=h.EXTENT/this.tileSize;this.workerOptions=h.extend({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:(n.buffer!==void 0?n.buffer:128)*d,tolerance:(n.tolerance!==void 0?n.tolerance:.375)*d,extent:h.EXTENT,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1},superclusterOptions:{maxZoom:n.clusterMaxZoom!==void 0?n.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,n.clusterMinPoints||2),extent:h.EXTENT,radius:(n.clusterRadius||50)*d,log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}load(){this._updateWorkerData()}onAdd(t){this.map=t,this.load()}setData(t){return this._data=t,this._updateWorkerData(),this}updateData(t){return this._updateWorkerData(t),this}setClusterOptions(t){return this.workerOptions.cluster=t.cluster,t&&(t.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=t.clusterRadius),t.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=t.clusterMaxZoom)),this._updateWorkerData(),this}getClusterExpansionZoom(t,n){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},n),this}getClusterChildren(t,n){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},n),this}getClusterLeaves(t,n,s,l){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:n,offset:s},l),this}_updateWorkerData(t){const n=h.extend({},this.workerOptions);t?n.dataDiff=t:typeof this._data=="string"?(n.request=this.map._requestManager.transformRequest(h.exported.resolveURL(this._data),dt.Source),n.request.collectResourceTiming=this._collectResourceTiming):n.data=JSON.stringify(this._data),this._pendingLoads++,this.fire(new h.Event("dataloading",{dataType:"source"})),this.actor.send(`${this.type}.loadData`,n,(s,l)=>{if(this._pendingLoads--,this._removed||l&&l.abandoned)return void this.fire(new h.Event("dataabort",{dataType:"source"}));let d=null;if(l&&l.resourceTiming&&l.resourceTiming[this.id]&&(d=l.resourceTiming[this.id].slice(0)),s)return void this.fire(new h.ErrorEvent(s));const m={dataType:"source"};this._collectResourceTiming&&d&&d.length>0&&h.extend(m,{resourceTiming:d}),this.fire(new h.Event("data",{...m,sourceDataType:"metadata"})),this.fire(new h.Event("data",{...m,sourceDataType:"content"}))})}loaded(){return this._pendingLoads===0}loadTile(t,n){const s=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const l={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};t.request=this.actor.send(s,l,(d,m)=>(delete t.request,t.unloadVectorData(),t.aborted?n(null):d?n(d):(t.loadVectorData(m,this.map.painter,s==="reloadTile"),n(null))))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._removed=!0,this.actor.send("removeSource",{type:this.type,source:this.id})}serialize(){return h.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var di=h.createLayout([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class bt extends h.Evented{constructor(t,n,s,l){super(),this.id=t,this.dispatcher=s,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(l),this.options=n}load(t,n){this._loaded=!1,this.fire(new h.Event("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=Qt.getImage(this.map._requestManager.transformRequest(this.url,dt.Image),(s,l)=>{this._request=null,this._loaded=!0,s?this.fire(new h.ErrorEvent(s)):l&&(this.image=l,t&&(this.coordinates=t),n&&n(),this._finishLoading())})}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.cancel(),this._request=null),this.options.url=t.url,this.load(t.coordinates,()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new h.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.cancel(),this._request=null)}setCoordinates(t){this.coordinates=t;const n=t.map(h.MercatorCoordinate.fromLngLat);this.tileID=function(l){let d=1/0,m=1/0,g=-1/0,y=-1/0;for(const M of l)d=Math.min(d,M.x),m=Math.min(m,M.y),g=Math.max(g,M.x),y=Math.max(y,M.y);const x=Math.max(g-d,y-m),S=Math.max(0,Math.floor(-Math.log(x)/Math.LN2)),T=Math.pow(2,S);return new h.CanonicalTileID(S,Math.floor((d+g)/2*T),Math.floor((m+y)/2*T))}(n),this.minzoom=this.maxzoom=this.tileID.z;const s=n.map(l=>this.tileID.getTilePoint(l)._round());return this._boundsArray=new h.RasterBoundsArray,this._boundsArray.emplaceBack(s[0].x,s[0].y,0,0),this._boundsArray.emplaceBack(s[1].x,s[1].y,h.EXTENT,0),this._boundsArray.emplaceBack(s[3].x,s[3].y,0,h.EXTENT),this._boundsArray.emplaceBack(s[2].x,s[2].y,h.EXTENT,h.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new h.Event("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const t=this.map.painter.context,n=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,di.members)),this.boundsSegments||(this.boundsSegments=h.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new Mt(t,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));for(const s in this.tiles){const l=this.tiles[s];l.state!=="loaded"&&(l.state="loaded",l.texture=this.texture)}}loadTile(t,n){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},n(null)):(t.state="errored",n(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class Wi extends bt{constructor(t,n,s,l){super(t,n,s,l),this.roundZoom=!0,this.type="video",this.options=n}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const n of t.urls)this.urls.push(this.map._requestManager.transformRequest(n,dt.Source).url);h.getVideo(this.urls,(n,s)=>{this._loaded=!0,n?this.fire(new h.ErrorEvent(n)):s&&(this.video=s,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const n=this.video.seekable;t<n.start(0)||t>n.end(0)?this.fire(new h.ErrorEvent(new h.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const t=this.map.painter.context,n=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,di.members)),this.boundsSegments||(this.boundsSegments=h.SegmentVector.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new Mt(t,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));for(const s in this.tiles){const l=this.tiles[s];l.state!=="loaded"&&(l.state="loaded",l.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class pi extends bt{constructor(t,n,s,l){super(t,n,s,l),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some(d=>!Array.isArray(d)||d.length!==2||d.some(m=>typeof m!="number"))||this.fire(new h.ErrorEvent(new h.ValidationError(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new h.ErrorEvent(new h.ValidationError(`sources.${t}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new h.ErrorEvent(new h.ValidationError(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new h.ErrorEvent(new h.ValidationError(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new h.ErrorEvent(new h.ValidationError(`sources.${t}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){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 h.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const n=this.map.painter.context,s=n.gl;this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,di.members)),this.boundsSegments||(this.boundsSegments=h.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new Mt(n,this.canvas,s.RGBA,{premultiply:!0});for(const l in this.tiles){const d=this.tiles[l];d.state!=="loaded"&&(d.state="loaded",d.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const jr={vector:Gr,raster:Ir,"raster-dem":Se,geojson:Gn,video:Wi,image:bt,canvas:pi};function Hi(o,t){const n=h.create();return h.translate(n,n,[1,1,0]),h.scale(n,n,[.5*o.width,.5*o.height,1]),h.multiply(n,n,o.calculatePosMatrix(t.toUnwrapped()))}function Ee(o,t,n,s,l,d){const m=function(T,M,F){if(T)for(const O of T){const D=M[O];if(D&&D.source===F&&D.type==="fill-extrusion")return!0}else for(const O in M){const D=M[O];if(D.source===F&&D.type==="fill-extrusion")return!0}return!1}(l&&l.layers,t,o.id),g=d.maxPitchScaleFactor(),y=o.tilesIn(s,g,m);y.sort(Qe);const x=[];for(const T of y)x.push({wrappedTileID:T.tileID.wrapped().key,queryResults:T.tile.queryRenderedFeatures(t,n,o._state,T.queryGeometry,T.cameraQueryGeometry,T.scale,l,d,g,Hi(o.transform,T.tileID))});const S=function(T){const M={},F={};for(const O of T){const D=O.queryResults,G=O.wrappedTileID,Y=F[G]=F[G]||{};for(const H in D){const V=D[H],te=Y[H]=Y[H]||{},ae=M[H]=M[H]||[];for(const se of V)te[se.featureIndex]||(te[se.featureIndex]=!0,ae.push(se))}}return M}(x);for(const T in S)S[T].forEach(M=>{const F=M.feature,O=o.getFeatureState(F.layer["source-layer"],F.id);F.source=F.layer.source,F.layer["source-layer"]&&(F.sourceLayer=F.layer["source-layer"]),F.state=O});return S}function Qe(o,t){const n=o.tileID,s=t.tileID;return n.overscaledZ-s.overscaledZ||n.canonical.y-s.canonical.y||n.wrap-s.wrap||n.canonical.x-s.canonical.x}class Je{constructor(t,n){this.tileID=t,this.uid=h.uniqueId(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(t){const n=t+this.timeAdded;n<h.exported.now()||this.fadeEndTime&&n<this.fadeEndTime||(this.fadeEndTime=n)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(t,n,s){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(l,d){const m={};if(!d)return m;for(const g of l){const y=g.layerIds.map(x=>d.getLayer(x)).filter(Boolean);if(y.length!==0){g.layers=y,g.stateDependentLayerIds&&(g.stateDependentLayers=g.stateDependentLayerIds.map(x=>y.filter(S=>S.id===x)[0]));for(const x of y)m[x.id]=g}}return m}(t.buckets,n.style),this.hasSymbolBuckets=!1;for(const l in this.buckets){const d=this.buckets[l];if(d instanceof h.SymbolBucket){if(this.hasSymbolBuckets=!0,!s)break;d.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const l in this.buckets){const d=this.buckets[l];if(d instanceof h.SymbolBucket&&d.hasRTLText){this.hasRTLText=!0,h.lazyLoadRTLTextPlugin();break}}this.queryPadding=0;for(const l in this.buckets){const d=this.buckets[l];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(l).queryRadius(d))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage)}else this.collisionBoxArray=new h.CollisionBoxArray}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const s in this.buckets){const l=this.buckets[s];l.uploadPending()&&l.upload(t)}const n=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Mt(t,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Mt(t,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,n,s,l,d,m,g,y,x,S){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:l,cameraQueryGeometry:d,scale:m,tileSize:this.tileSize,pixelPosMatrix:S,transform:y,params:g,queryPadding:this.queryPadding*x},t,n,s):{}}querySourceFeatures(t,n){const s=this.latestFeatureIndex;if(!s||!s.rawTileData)return;const l=s.loadVTLayers(),d=n&&n.sourceLayer?n.sourceLayer:"",m=l._geojsonTileLayer||l[d];if(!m)return;const g=h.createFilter(n&&n.filter),{z:y,x,y:S}=this.tileID.canonical,T={z:y,x,y:S};for(let M=0;M<m.length;M++){const F=m.feature(M);if(g.needGeometry){const G=h.toEvaluationFeature(F,!0);if(!g.filter(new h.EvaluationParameters(this.tileID.overscaledZ),G,this.tileID.canonical))continue}else if(!g.filter(new h.EvaluationParameters(this.tileID.overscaledZ),F))continue;const O=s.getId(F,d),D=new h.GeoJSONFeature(F,y,x,S,O);D.tile=T,t.push(D)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const n=this.expirationTime;if(t.cacheControl){const s=h.parseCacheControl(t.cacheControl);s["max-age"]&&(this.expirationTime=Date.now()+1e3*s["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const s=Date.now();let l=!1;if(this.expirationTime>s)l=!1;else if(n)if(this.expirationTime<n)l=!0;else{const d=this.expirationTime-n;d?this.expirationTime=s+Math.max(d,3e4):l=!0}else l=!0;l?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(t,n){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(t).length===0)return;const s=this.latestFeatureIndex.loadVTLayers();for(const l in this.buckets){if(!n.style.hasLayer(l))continue;const d=this.buckets[l],m=d.layers[0].sourceLayer||"_geojsonTileLayer",g=s[m],y=t[m];if(!g||!y||Object.keys(y).length===0)continue;d.update(y,g,this.imageAtlas&&this.imageAtlas.patternPositions||{});const x=n&&n.style&&n.style.getLayer(l);x&&(this.queryPadding=Math.max(this.queryPadding,x.queryRadius(d)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<h.exported.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=h.exported.now()+t}setDependencies(t,n){const s={};for(const l of n)s[l]=!0;this.dependencies[t]=s}hasDependency(t,n){for(const s of t){const l=this.dependencies[s];if(l){for(const d of n)if(l[d])return!0}}return!1}}class Ti{constructor(t,n){this.max=t,this.onRemove=n,this.reset()}reset(){for(const t in this.data)for(const n of this.data[t])n.timeout&&clearTimeout(n.timeout),this.onRemove(n.value);return this.data={},this.order=[],this}add(t,n,s){const l=t.wrapped().key;this.data[l]===void 0&&(this.data[l]=[]);const d={value:n,timeout:void 0};if(s!==void 0&&(d.timeout=setTimeout(()=>{this.remove(t,d)},s)),this.data[l].push(d),this.order.push(l),this.order.length>this.max){const m=this._getAndRemoveByKey(this.order[0]);m&&this.onRemove(m)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const n=this.data[t].shift();return n.timeout&&clearTimeout(n.timeout),this.data[t].length===0&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),n.value}getByKey(t){const n=this.data[t];return n?n[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,n){if(!this.has(t))return this;const s=t.wrapped().key,l=n===void 0?0:this.data[s].indexOf(n),d=this.data[s][l];return this.data[s].splice(l,1),d.timeout&&clearTimeout(d.timeout),this.data[s].length===0&&delete this.data[s],this.onRemove(d.value),this.order.splice(this.order.indexOf(s),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}filter(t){const n=[];for(const s in this.data)for(const l of this.data[s])t(l.value)||n.push(l);for(const s of n)this.remove(s.value.tileID,s)}}class sr{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,n,s){const l=String(n);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][l]=this.stateChanges[t][l]||{},h.extend(this.stateChanges[t][l],s),this.deletedStates[t]===null){this.deletedStates[t]={};for(const d in this.state[t])d!==l&&(this.deletedStates[t][d]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][l]===null){this.deletedStates[t][l]={};for(const d in this.state[t][l])s[d]||(this.deletedStates[t][l][d]=null)}else for(const d in s)this.deletedStates[t]&&this.deletedStates[t][l]&&this.deletedStates[t][l][d]===null&&delete this.deletedStates[t][l][d]}removeFeatureState(t,n,s){if(this.deletedStates[t]===null)return;const l=String(n);if(this.deletedStates[t]=this.deletedStates[t]||{},s&&n!==void 0)this.deletedStates[t][l]!==null&&(this.deletedStates[t][l]=this.deletedStates[t][l]||{},this.deletedStates[t][l][s]=null);else if(n!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][l])for(s in this.deletedStates[t][l]={},this.stateChanges[t][l])this.deletedStates[t][l][s]=null;else this.deletedStates[t][l]=null;else this.deletedStates[t]=null}getState(t,n){const s=String(n),l=h.extend({},(this.state[t]||{})[s],(this.stateChanges[t]||{})[s]);if(this.deletedStates[t]===null)return{};if(this.deletedStates[t]){const d=this.deletedStates[t][n];if(d===null)return{};for(const m in d)delete l[m]}return l}initializeTileState(t,n){t.setFeatureState(this.state,n)}coalesceChanges(t,n){const s={};for(const l in this.stateChanges){this.state[l]=this.state[l]||{};const d={};for(const m in this.stateChanges[l])this.state[l][m]||(this.state[l][m]={}),h.extend(this.state[l][m],this.stateChanges[l][m]),d[m]=this.state[l][m];s[l]=d}for(const l in this.deletedStates){this.state[l]=this.state[l]||{};const d={};if(this.deletedStates[l]===null)for(const m in this.state[l])d[m]={},this.state[l][m]={};else for(const m in this.deletedStates[l]){if(this.deletedStates[l][m]===null)this.state[l][m]={};else for(const g of Object.keys(this.deletedStates[l][m]))delete this.state[l][m][g];d[m]=this.state[l][m]}s[l]=s[l]||{},h.extend(s[l],d)}if(this.stateChanges={},this.deletedStates={},Object.keys(s).length!==0)for(const l in t)t[l].setFeatureState(s,n)}}class Xe extends h.Evented{constructor(t,n,s){super(),this.id=t,this.dispatcher=s,this.on("data",l=>{l.dataType==="source"&&l.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&l.dataType==="source"&&l.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain))}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=function(l,d,m,g){const y=new jr[d.type](l,d,m,g);if(y.id!==l)throw new Error(`Expected Source id to be ${l} instead of ${y.id}`);return h.bindAll(["load","abort","unload","serialize","prepare"],y),y}(t,n,s,this),this._tiles={},this._cache=new Ti(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new sr}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const t in this._tiles){const n=this._tiles[t];if(n.state!=="loaded"&&n.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(t,n){return this._source.loadTile(t,n)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,()=>{})}_abortTile(t){this._source.abortTile&&this._source.abortTile(t,()=>{}),this._source.fire(new h.Event("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const n in this._tiles){const s=this._tiles[n];s.upload(t),s.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(t=>t.tileID).sort(Ar).map(t=>t.key)}getRenderableIds(t){const n=[];for(const s in this._tiles)this._isIdRenderable(s,t)&&n.push(this._tiles[s]);return t?n.sort((s,l)=>{const d=s.tileID,m=l.tileID,g=new h.pointGeometry(d.canonical.x,d.canonical.y)._rotate(this.transform.angle),y=new h.pointGeometry(m.canonical.x,m.canonical.y)._rotate(this.transform.angle);return d.overscaledZ-m.overscaledZ||y.y-g.y||y.x-g.x}).map(s=>s.tileID.key):n.map(s=>s.tileID).sort(Ar).map(s=>s.key)}hasRenderableParent(t){const n=this.findLoadedParent(t,0);return!!n&&this._isIdRenderable(n.tileID.key)}_isIdRenderable(t,n){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(n||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)this._tiles[t].state!=="errored"&&this._reloadTile(t,"reloading")}}_reloadTile(t,n){const s=this._tiles[t];s&&(s.state!=="loading"&&(s.state=n),this._loadTile(s,this._tileLoaded.bind(this,s,t,n)))}_tileLoaded(t,n,s,l){if(l)return t.state="errored",void(l.status!==404?this._source.fire(new h.ErrorEvent(l,{tile:t})):this.update(this.transform,this.terrain));t.timeAdded=h.exported.now(),s==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(n,t),this.getSource().type==="raster-dem"&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new h.Event("data",{dataType:"source",tile:t,coord:t.tileID}))}_backfillDEM(t){const n=this.getRenderableIds();for(let l=0;l<n.length;l++){const d=n[l];if(t.neighboringTiles&&t.neighboringTiles[d]){const m=this.getTileByID(d);s(t,m),s(m,t)}}function s(l,d){l.needsHillshadePrepare=!0,l.needsTerrainPrepare=!0;let m=d.tileID.canonical.x-l.tileID.canonical.x;const g=d.tileID.canonical.y-l.tileID.canonical.y,y=Math.pow(2,l.tileID.canonical.z),x=d.tileID.key;m===0&&g===0||Math.abs(g)>1||(Math.abs(m)>1&&(Math.abs(m+y)===1?m+=y:Math.abs(m-y)===1&&(m-=y)),d.dem&&l.dem&&(l.dem.backfillBorder(d.dem,m,g),l.neighboringTiles&&l.neighboringTiles[x]&&(l.neighboringTiles[x].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,n,s,l){for(const d in this._tiles){let m=this._tiles[d];if(l[d]||!m.hasData()||m.tileID.overscaledZ<=n||m.tileID.overscaledZ>s)continue;let g=m.tileID;for(;m&&m.tileID.overscaledZ>n+1;){const x=m.tileID.scaledTo(m.tileID.overscaledZ-1);m=this._tiles[x.key],m&&m.hasData()&&(g=x)}let y=g;for(;y.overscaledZ>n;)if(y=y.scaledTo(y.overscaledZ-1),t[y.key]){l[g.key]=g;break}}}findLoadedParent(t,n){if(t.key in this._loadedParentTiles){const s=this._loadedParentTiles[t.key];return s&&s.tileID.overscaledZ>=n?s:null}for(let s=t.overscaledZ-1;s>=n;s--){const l=t.scaledTo(s),d=this._getLoadedTile(l);if(d)return d}}_getLoadedTile(t){const n=this._tiles[t.key];return n&&n.hasData()?n:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const n=Math.ceil(t.width/this._source.tileSize)+1,s=Math.ceil(t.height/this._source.tileSize)+1,l=Math.floor(n*s*5),d=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,l):l;this._cache.setMaxSize(d)}handleWrapJump(t){const n=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);if(this._prevLng=t,n){const s={};for(const l in this._tiles){const d=this._tiles[l];d.tileID=d.tileID.unwrapTo(d.tileID.wrap+n),s[d.tileID.key]=d}this._tiles=s;for(const l in this._timers)clearTimeout(this._timers[l]),delete this._timers[l];for(const l in this._tiles)this._setTileReloadTimer(l,this._tiles[l])}}update(t,n){if(this.transform=t,this.terrain=n,!this._sourceLoaded||this._paused)return;let s;this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?s=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(x=>new h.OverscaledTileID(x.canonical.z,x.wrap,x.canonical.z,x.canonical.x,x.canonical.y)):(s=t.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n}),this._source.hasTile&&(s=s.filter(x=>this._source.hasTile(x)))):s=[];const l=t.coveringZoomLevel(this._source),d=Math.max(l-Xe.maxOverzooming,this._source.minzoom),m=Math.max(l+Xe.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const x={};for(const S of s)if(S.canonical.z>this._source.minzoom){const T=S.scaledTo(S.canonical.z-1);x[T.key]=T;const M=S.scaledTo(Math.max(this._source.minzoom,Math.min(S.canonical.z,5)));x[M.key]=M}s=s.concat(Object.values(x))}const g=this._updateRetainedTiles(s,l);if(ri(this._source.type)){const x={},S={},T=Object.keys(g);for(const M of T){const F=g[M],O=this._tiles[M];if(!O||O.fadeEndTime&&O.fadeEndTime<=h.exported.now())continue;const D=this.findLoadedParent(F,d);D&&(this._addTile(D.tileID),x[D.tileID.key]=D.tileID),S[M]=F}this._retainLoadedChildren(S,l,m,g);for(const M in x)g[M]||(this._coveredTiles[M]=!0,g[M]=x[M]);if(n){const M={},F={};for(const O of s)this._tiles[O.key].hasData()?M[O.key]=O:F[O.key]=O;for(const O in F){const D=F[O].children(this._source.maxzoom);this._tiles[D[0].key]&&this._tiles[D[1].key]&&this._tiles[D[2].key]&&this._tiles[D[3].key]&&(M[D[0].key]=g[D[0].key]=D[0],M[D[1].key]=g[D[1].key]=D[1],M[D[2].key]=g[D[2].key]=D[2],M[D[3].key]=g[D[3].key]=D[3],delete F[O])}for(const O in F){const D=this.findLoadedParent(F[O],this._source.minzoom);if(D){M[D.tileID.key]=g[D.tileID.key]=D.tileID;for(const G in M)M[G].isChildOf(D.tileID)&&delete M[G]}}for(const O in this._tiles)M[O]||(this._coveredTiles[O]=!0)}}for(const x in g)this._tiles[x].clearFadeHold();const y=h.keysDifference(this._tiles,g);for(const x of y){const S=this._tiles[x];S.hasSymbolBuckets&&!S.holdingForFade()?S.setHoldDuration(this.map._fadeDuration):S.hasSymbolBuckets&&!S.symbolFadeFinished()||this._removeTile(x)}this._updateLoadedParentTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,n){const s={},l={},d=Math.max(n-Xe.maxOverzooming,this._source.minzoom),m=Math.max(n+Xe.maxUnderzooming,this._source.minzoom),g={};for(const y of t){const x=this._addTile(y);s[y.key]=y,x.hasData()||n<this._source.maxzoom&&(g[y.key]=y)}this._retainLoadedChildren(g,n,m,s);for(const y of t){let x=this._tiles[y.key];if(x.hasData())continue;if(n+1>this._source.maxzoom){const T=y.children(this._source.maxzoom)[0],M=this.getTile(T);if(M&&M.hasData()){s[T.key]=T;continue}}else{const T=y.children(this._source.maxzoom);if(s[T[0].key]&&s[T[1].key]&&s[T[2].key]&&s[T[3].key])continue}let S=x.wasRequested();for(let T=y.overscaledZ-1;T>=d;--T){const M=y.scaledTo(T);if(l[M.key]||(l[M.key]=!0,x=this.getTile(M),!x&&S&&(x=this._addTile(M)),x&&(s[M.key]=M,S=x.wasRequested(),x.hasData())))break}}return s}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const n=[];let s,l=this._tiles[t].tileID;for(;l.overscaledZ>0;){if(l.key in this._loadedParentTiles){s=this._loadedParentTiles[l.key];break}n.push(l.key);const d=l.scaledTo(l.overscaledZ-1);if(s=this._getLoadedTile(d),s)break;l=d}for(const d of n)this._loadedParentTiles[d]=s}}_addTile(t){let n=this._tiles[t.key];if(n)return n;n=this._cache.getAndRemove(t),n&&(this._setTileReloadTimer(t.key,n),n.tileID=t,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,n)));const s=n;return n||(n=new Je(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(n,this._tileLoaded.bind(this,n,t.key,n.state))),n.uses++,this._tiles[t.key]=n,s||this._source.fire(new h.Event("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(t,n){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const s=n.getExpiryTimeout();s&&(this._timers[t]=setTimeout(()=>{this._reloadTile(t,"expired"),delete this._timers[t]},s))}_removeTile(t){const n=this._tiles[t];n&&(n.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._cache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(t,n,s){const l=[],d=this.transform;if(!d)return l;const m=s?d.getCameraQueryGeometry(t):t,g=t.map(O=>d.pointCoordinate(O,this.terrain)),y=m.map(O=>d.pointCoordinate(O,this.terrain)),x=this.getIds();let S=1/0,T=1/0,M=-1/0,F=-1/0;for(const O of y)S=Math.min(S,O.x),T=Math.min(T,O.y),M=Math.max(M,O.x),F=Math.max(F,O.y);for(let O=0;O<x.length;O++){const D=this._tiles[x[O]];if(D.holdingForFade())continue;const G=D.tileID,Y=Math.pow(2,d.zoom-D.tileID.overscaledZ),H=n*D.queryPadding*h.EXTENT/D.tileSize/Y,V=[G.getTilePoint(new h.MercatorCoordinate(S,T)),G.getTilePoint(new h.MercatorCoordinate(M,F))];if(V[0].x-H<h.EXTENT&&V[0].y-H<h.EXTENT&&V[1].x+H>=0&&V[1].y+H>=0){const te=g.map(se=>G.getTilePoint(se)),ae=y.map(se=>G.getTilePoint(se));l.push({tile:D,tileID:G,queryGeometry:te,cameraQueryGeometry:ae,scale:Y})}}return l}getVisibleCoordinates(t){const n=this.getRenderableIds(t).map(s=>this._tiles[s].tileID);for(const s of n)s.posMatrix=this.transform.calculatePosMatrix(s.toUnwrapped());return n}hasTransition(){if(this._source.hasTransition())return!0;if(ri(this._source.type))for(const t in this._tiles){const n=this._tiles[t];if(n.fadeEndTime!==void 0&&n.fadeEndTime>=h.exported.now())return!0}return!1}setFeatureState(t,n,s){this._state.updateState(t=t||"_geojsonTileLayer",n,s)}removeFeatureState(t,n,s){this._state.removeFeatureState(t=t||"_geojsonTileLayer",n,s)}getFeatureState(t,n){return this._state.getState(t=t||"_geojsonTileLayer",n)}setDependencies(t,n,s){const l=this._tiles[t];l&&l.setDependencies(n,s)}reloadTilesForDependencies(t,n){for(const s in this._tiles)this._tiles[s].hasDependency(t,n)&&this._reloadTile(s,"reloading");this._cache.filter(s=>!s.hasDependency(t,n))}}function Ar(o,t){const n=Math.abs(2*o.wrap)-+(o.wrap<0),s=Math.abs(2*t.wrap)-+(t.wrap<0);return o.overscaledZ-t.overscaledZ||s-n||t.canonical.y-o.canonical.y||t.canonical.x-o.canonical.x}function ri(o){return o==="raster"||o==="image"||o==="video"}Xe.maxOverzooming=10,Xe.maxUnderzooming=3;const qr="mapboxgl_preloaded_worker_pool";class Mi{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<Mi.workerCount;)this.workers.push(new Worker(Dr.workerUrl));return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],this.numActive()===0&&(this.workers.forEach(n=>{n.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[qr]}numActive(){return Object.keys(this.active).length}}const mi=Math.floor(h.exported.hardwareConcurrency/2);let yt;function gn(){return yt||(yt=new Mi),yt}function Zr(o,t){const n={};for(const s in o)s!=="ref"&&(n[s]=o[s]);return h.refProperties.forEach(s=>{s in t&&(n[s]=t[s])}),n}function _n(o){o=o.slice();const t=Object.create(null);for(let n=0;n<o.length;n++)t[o[n].id]=o[n];for(let n=0;n<o.length;n++)"ref"in o[n]&&(o[n]=Zr(o[n],t[o[n].ref]));return o}Mi.workerCount=Math.max(Math.min(mi,6),1);const lt={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight"};function Cr(o,t,n){n.push({command:lt.addSource,args:[o,t[o]]})}function yn(o,t,n){t.push({command:lt.removeSource,args:[o]}),n[o]=!0}function Xr(o,t,n,s){yn(o,n,s),Cr(o,t,n)}function jn(o,t,n){let s;for(s in o[n])if(Object.prototype.hasOwnProperty.call(o[n],s)&&s!=="data"&&!pe(o[n][s],t[n][s]))return!1;for(s in t[n])if(Object.prototype.hasOwnProperty.call(t[n],s)&&s!=="data"&&!pe(o[n][s],t[n][s]))return!1;return!0}function _r(o,t,n,s,l,d){let m;for(m in t=t||{},o=o||{})Object.prototype.hasOwnProperty.call(o,m)&&(pe(o[m],t[m])||n.push({command:d,args:[s,m,t[m],l]}));for(m in t)Object.prototype.hasOwnProperty.call(t,m)&&!Object.prototype.hasOwnProperty.call(o,m)&&(pe(o[m],t[m])||n.push({command:d,args:[s,m,t[m],l]}))}function Mr(o){return o.id}function ut(o,t){return o[t.id]=t,o}class Wr{constructor(t,n){this.reset(t,n)}reset(t,n){this.points=t||[],this._distances=[0];for(let s=1;s<this.points.length;s++)this._distances[s]=this._distances[s-1]+this.points[s].dist(this.points[s-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(n||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(this.points.length===1)return this.points[0];t=h.clamp(t,0,1);let n=1,s=this._distances[n];const l=t*this.paddedLength+this.padding;for(;s<l&&n<this._distances.length;)s=this._distances[++n];const d=n-1,m=this._distances[d],g=s-m,y=g>0?(l-m)/g:0;return this.points[d].mult(1-y).add(this.points[n].mult(y))}}function Vi(o,t){let n=!0;return o==="always"||o!=="never"&&t!=="never"||(n=!1),n}class ei{constructor(t,n,s){const l=this.boxCells=[],d=this.circleCells=[];this.xCellCount=Math.ceil(t/s),this.yCellCount=Math.ceil(n/s);for(let m=0;m<this.xCellCount*this.yCellCount;m++)l.push([]),d.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=n,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/n,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,n,s,l,d){this._forEachCell(n,s,l,d,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(n),this.bboxes.push(s),this.bboxes.push(l),this.bboxes.push(d)}insertCircle(t,n,s,l){this._forEachCell(n-l,s-l,n+l,s+l,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(n),this.circles.push(s),this.circles.push(l)}_insertBoxCell(t,n,s,l,d,m){this.boxCells[d].push(m)}_insertCircleCell(t,n,s,l,d,m){this.circleCells[d].push(m)}_query(t,n,s,l,d,m,g){if(s<0||t>this.width||l<0||n>this.height)return[];const y=[];if(t<=0&&n<=0&&this.width<=s&&this.height<=l){if(d)return[{key:null,x1:t,y1:n,x2:s,y2:l}];for(let x=0;x<this.boxKeys.length;x++)y.push({key:this.boxKeys[x],x1:this.bboxes[4*x],y1:this.bboxes[4*x+1],x2:this.bboxes[4*x+2],y2:this.bboxes[4*x+3]});for(let x=0;x<this.circleKeys.length;x++){const S=this.circles[3*x],T=this.circles[3*x+1],M=this.circles[3*x+2];y.push({key:this.circleKeys[x],x1:S-M,y1:T-M,x2:S+M,y2:T+M})}}else this._forEachCell(t,n,s,l,this._queryCell,y,{hitTest:d,overlapMode:m,seenUids:{box:{},circle:{}}},g);return y}query(t,n,s,l){return this._query(t,n,s,l,!1,null)}hitTest(t,n,s,l,d,m){return this._query(t,n,s,l,!0,d,m).length>0}hitTestCircle(t,n,s,l,d){const m=t-s,g=t+s,y=n-s,x=n+s;if(g<0||m>this.width||x<0||y>this.height)return!1;const S=[];return this._forEachCell(m,y,g,x,this._queryCellCircle,S,{hitTest:!0,overlapMode:l,circle:{x:t,y:n,radius:s},seenUids:{box:{},circle:{}}},d),S.length>0}_queryCell(t,n,s,l,d,m,g,y){const{seenUids:x,hitTest:S,overlapMode:T}=g,M=this.boxCells[d];if(M!==null){const O=this.bboxes;for(const D of M)if(!x.box[D]){x.box[D]=!0;const G=4*D,Y=this.boxKeys[D];if(t<=O[G+2]&&n<=O[G+3]&&s>=O[G+0]&&l>=O[G+1]&&(!y||y(Y))&&(!S||!Vi(T,Y.overlapMode))&&(m.push({key:Y,x1:O[G],y1:O[G+1],x2:O[G+2],y2:O[G+3]}),S))return!0}}const F=this.circleCells[d];if(F!==null){const O=this.circles;for(const D of F)if(!x.circle[D]){x.circle[D]=!0;const G=3*D,Y=this.circleKeys[D];if(this._circleAndRectCollide(O[G],O[G+1],O[G+2],t,n,s,l)&&(!y||y(Y))&&(!S||!Vi(T,Y.overlapMode))){const H=O[G],V=O[G+1],te=O[G+2];if(m.push({key:Y,x1:H-te,y1:V-te,x2:H+te,y2:V+te}),S)return!0}}}return!1}_queryCellCircle(t,n,s,l,d,m,g,y){const{circle:x,seenUids:S,overlapMode:T}=g,M=this.boxCells[d];if(M!==null){const O=this.bboxes;for(const D of M)if(!S.box[D]){S.box[D]=!0;const G=4*D,Y=this.boxKeys[D];if(this._circleAndRectCollide(x.x,x.y,x.radius,O[G+0],O[G+1],O[G+2],O[G+3])&&(!y||y(Y))&&!Vi(T,Y.overlapMode))return m.push(!0),!0}}const F=this.circleCells[d];if(F!==null){const O=this.circles;for(const D of F)if(!S.circle[D]){S.circle[D]=!0;const G=3*D,Y=this.circleKeys[D];if(this._circlesCollide(O[G],O[G+1],O[G+2],x.x,x.y,x.radius)&&(!y||y(Y))&&!Vi(T,Y.overlapMode))return m.push(!0),!0}}}_forEachCell(t,n,s,l,d,m,g,y){const x=this._convertToXCellCoord(t),S=this._convertToYCellCoord(n),T=this._convertToXCellCoord(s),M=this._convertToYCellCoord(l);for(let F=x;F<=T;F++)for(let O=S;O<=M;O++)if(d.call(this,t,n,s,l,this.xCellCount*O+F,m,g,y))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,n,s,l,d,m){const g=l-t,y=d-n,x=s+m;return x*x>g*g+y*y}_circleAndRectCollide(t,n,s,l,d,m,g){const y=(m-l)/2,x=Math.abs(t-(l+y));if(x>y+s)return!1;const S=(g-d)/2,T=Math.abs(n-(d+S));if(T>S+s)return!1;if(x<=y||T<=S)return!0;const M=x-y,F=T-S;return M*M+F*F<=s*s}}function Yt(o,t,n,s,l){const d=h.create();return t?(h.scale(d,d,[1/l,1/l,1]),n||h.rotateZ(d,d,s.angle)):h.multiply(d,s.labelPlaneMatrix,o),d}function fi(o,t,n,s,l){if(t){const d=h.clone(o);return h.scale(d,d,[l,l,1]),n||h.rotateZ(d,d,-s.angle),d}return s.glCoordMatrix}function gi(o,t,n){let s;n?(s=[o.x,o.y,n(o.x,o.y),1],h.transformMat4(s,s,t)):(s=[o.x,o.y,0,1],Q(s,s,t));const l=s[3];return{point:new h.pointGeometry(s[0]/l,s[1]/l),signedDistanceFromCamera:l}}function yr(o,t){return .5+o/t*.5}function B(o,t){const n=o[0]/o[3],s=o[1]/o[3];return n>=-t[0]&&n<=t[0]&&s>=-t[1]&&s<=t[1]}function I(o,t,n,s,l,d,m,g,y,x){const S=s?o.textSizeData:o.iconSizeData,T=h.evaluateSizeForZoom(S,n.transform.zoom),M=[256/n.width*2+1,256/n.height*2+1],F=s?o.text.dynamicLayoutVertexArray:o.icon.dynamicLayoutVertexArray;F.clear();const O=o.lineVertexArray,D=s?o.text.placedSymbolArray:o.icon.placedSymbolArray,G=n.transform.width/n.transform.height;let Y=!1;for(let H=0;H<D.length;H++){const V=D.get(H);if(V.hidden||V.writingMode===h.WritingMode.vertical&&!Y){q(V.numGlyphs,F);continue}let te;if(Y=!1,x?(te=[V.anchorX,V.anchorY,x(V.anchorX,V.anchorY),1],h.transformMat4(te,te,t)):(te=[V.anchorX,V.anchorY,0,1],Q(te,te,t)),!B(te,M)){q(V.numGlyphs,F);continue}const ae=yr(n.transform.cameraToCenterDistance,te[3]),se=h.evaluateSizeForFeature(S,T,V),ue=m?se/ae:se*ae,me=new h.pointGeometry(V.anchorX,V.anchorY),xe=gi(me,l,x).point,_e={},we=U(V,ue,!1,g,t,l,d,o.glyphOffsetArray,O,F,xe,me,_e,G,y,x);Y=we.useVertical,(we.notEnoughRoom||Y||we.needsFlipping&&U(V,ue,!0,g,t,l,d,o.glyphOffsetArray,O,F,xe,me,_e,G,y,x).notEnoughRoom)&&q(V.numGlyphs,F)}s?o.text.dynamicLayoutVertexBuffer.updateData(F):o.icon.dynamicLayoutVertexBuffer.updateData(F)}function C(o,t,n,s,l,d,m,g,y,x,S,T,M){const F=g.glyphStartIndex+g.numGlyphs,O=g.lineStartIndex,D=g.lineStartIndex+g.lineLength,G=t.getoffsetX(g.glyphStartIndex),Y=t.getoffsetX(F-1),H=X(o*G,n,s,l,d,m,g.segment,O,D,y,x,S,T,M);if(!H)return null;const V=X(o*Y,n,s,l,d,m,g.segment,O,D,y,x,S,T,M);return V?{first:H,last:V}:null}function R(o,t,n,s){return o===h.WritingMode.horizontal&&Math.abs(n.y-t.y)>Math.abs(n.x-t.x)*s?{useVertical:!0}:(o===h.WritingMode.vertical?t.y<n.y:t.x>n.x)?{needsFlipping:!0}:null}function U(o,t,n,s,l,d,m,g,y,x,S,T,M,F,O,D){const G=t/24,Y=o.lineOffsetX*G,H=o.lineOffsetY*G;let V;if(o.numGlyphs>1){const te=o.glyphStartIndex+o.numGlyphs,ae=o.lineStartIndex,se=o.lineStartIndex+o.lineLength,ue=C(G,g,Y,H,n,S,T,o,y,d,M,O,D);if(!ue)return{notEnoughRoom:!0};const me=gi(ue.first.point,m,D).point,xe=gi(ue.last.point,m,D).point;if(s&&!n){const _e=R(o.writingMode,me,xe,F);if(_e)return _e}V=[ue.first];for(let _e=o.glyphStartIndex+1;_e<te-1;_e++)V.push(X(G*g.getoffsetX(_e),Y,H,n,S,T,o.segment,ae,se,y,d,M,O,D));V.push(ue.last)}else{if(s&&!n){const ae=gi(T,l,D).point,se=o.lineStartIndex+o.segment+1,ue=new h.pointGeometry(y.getx(se),y.gety(se)),me=gi(ue,l,D),xe=me.signedDistanceFromCamera>0?me.point:j(T,ue,ae,1,l,D),_e=R(o.writingMode,ae,xe,F);if(_e)return _e}const te=X(G*g.getoffsetX(o.glyphStartIndex),Y,H,n,S,T,o.segment,o.lineStartIndex,o.lineStartIndex+o.lineLength,y,d,M,O,D);if(!te)return{notEnoughRoom:!0};V=[te]}for(const te of V)h.addDynamicAttributes(x,te.point,te.angle);return{}}function j(o,t,n,s,l,d){const m=gi(o.add(o.sub(t)._unit()),l,d).point,g=n.sub(m);return n.add(g._mult(s/g.mag()))}function X(o,t,n,s,l,d,m,g,y,x,S,T,M,F){const O=s?o-t:o+t;let D=O>0?1:-1,G=0;s&&(D*=-1,G=Math.PI),D<0&&(G+=Math.PI);let Y=D>0?g+m:g+m+1,H=l,V=l,te=0,ae=0;const se=Math.abs(O),ue=[];for(;te+ae<=se;){if(Y+=D,Y<g||Y>=y)return null;if(V=H,ue.push(H),H=T[Y],H===void 0){const ze=new h.pointGeometry(x.getx(Y),x.gety(Y)),We=gi(ze,S,F);if(We.signedDistanceFromCamera>0)H=T[Y]=We.point;else{const Ke=Y-D;H=j(te===0?d:new h.pointGeometry(x.getx(Ke),x.gety(Ke)),ze,V,se-te+1,S,F)}}te+=ae,ae=V.dist(H)}const me=(se-te)/ae,xe=H.sub(V),_e=xe.mult(me)._add(V);_e._add(xe._unit()._perp()._mult(n*D));const we=G+Math.atan2(H.y-V.y,H.x-V.x);return ue.push(_e),{point:_e,angle:M?we:0,path:ue}}const Z=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function q(o,t){for(let n=0;n<o;n++){const s=t.length;t.resize(s+4),t.float32.set(Z,3*s)}}function Q(o,t,n){const s=t[0],l=t[1];return o[0]=n[0]*s+n[4]*l+n[12],o[1]=n[1]*s+n[5]*l+n[13],o[3]=n[3]*s+n[7]*l+n[15],o}const oe=100;class ye{constructor(t,n=new ei(t.width+200,t.height+200,25),s=new ei(t.width+200,t.height+200,25)){this.transform=t,this.grid=n,this.ignoredGrid=s,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+oe,this.screenBottomBoundary=t.height+oe,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,n,s,l,d,m){const g=this.projectAndGetPerspectiveRatio(l,t.anchorPointX,t.anchorPointY,m),y=s*g.perspectiveRatio,x=t.x1*y+g.point.x,S=t.y1*y+g.point.y,T=t.x2*y+g.point.x,M=t.y2*y+g.point.y;return!this.isInsideGrid(x,S,T,M)||n!=="always"&&this.grid.hitTest(x,S,T,M,n,d)||g.perspectiveRatio<this.perspectiveRatioCutoff?{box:[],offscreen:!1}:{box:[x,S,T,M],offscreen:this.isOffscreen(x,S,T,M)}}placeCollisionCircles(t,n,s,l,d,m,g,y,x,S,T,M,F,O){const D=[],G=new h.pointGeometry(n.anchorX,n.anchorY),Y=gi(G,m,O),H=yr(this.transform.cameraToCenterDistance,Y.signedDistanceFromCamera),V=(S?d/H:d*H)/h.ONE_EM,te=gi(G,g,O).point,ae=C(V,l,n.lineOffsetX*V,n.lineOffsetY*V,!1,te,G,n,s,g,{},!1,O);let se=!1,ue=!1,me=!0;if(ae){const xe=.5*M*H+F,_e=new h.pointGeometry(-100,-100),we=new h.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),ze=new Wr,We=ae.first,Ke=ae.last;let Le=[];for(let tt=We.path.length-1;tt>=1;tt--)Le.push(We.path[tt]);for(let tt=1;tt<Ke.path.length;tt++)Le.push(Ke.path[tt]);const mt=2.5*xe;if(y){const tt=Le.map(ht=>gi(ht,y,O));Le=tt.some(ht=>ht.signedDistanceFromCamera<=0)?[]:tt.map(ht=>ht.point)}let ft=[];if(Le.length>0){const tt=Le[0].clone(),ht=Le[0].clone();for(let wt=1;wt<Le.length;wt++)tt.x=Math.min(tt.x,Le[wt].x),tt.y=Math.min(tt.y,Le[wt].y),ht.x=Math.max(ht.x,Le[wt].x),ht.y=Math.max(ht.y,Le[wt].y);ft=tt.x>=_e.x&&ht.x<=we.x&&tt.y>=_e.y&&ht.y<=we.y?[Le]:ht.x<_e.x||tt.x>we.x||ht.y<_e.y||tt.y>we.y?[]:h.clipLine([Le],_e.x,_e.y,we.x,we.y)}for(const tt of ft){ze.reset(tt,.25*xe);let ht=0;ht=ze.length<=.5*xe?1:Math.ceil(ze.paddedLength/mt)+1;for(let wt=0;wt<ht;wt++){const gt=wt/Math.max(ht-1,1),ji=ze.lerp(gt),qi=ji.x+oe,ni=ji.y+oe;D.push(qi,ni,xe,0);const ki=qi-xe,_i=ni-xe,Ji=qi+xe,Rr=ni+xe;if(me=me&&this.isOffscreen(ki,_i,Ji,Rr),ue=ue||this.isInsideGrid(ki,_i,Ji,Rr),t!=="always"&&this.grid.hitTestCircle(qi,ni,xe,t,T)&&(se=!0,!x))return{circles:[],offscreen:!1,collisionDetected:se}}}}return{circles:!x&&se||!ue||H<this.perspectiveRatioCutoff?[]:D,offscreen:me,collisionDetected:se}}queryRenderedSymbols(t){if(t.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const n=[];let s=1/0,l=1/0,d=-1/0,m=-1/0;for(const S of t){const T=new h.pointGeometry(S.x+oe,S.y+oe);s=Math.min(s,T.x),l=Math.min(l,T.y),d=Math.max(d,T.x),m=Math.max(m,T.y),n.push(T)}const g=this.grid.query(s,l,d,m).concat(this.ignoredGrid.query(s,l,d,m)),y={},x={};for(const S of g){const T=S.key;if(y[T.bucketInstanceId]===void 0&&(y[T.bucketInstanceId]={}),y[T.bucketInstanceId][T.featureIndex])continue;const M=[new h.pointGeometry(S.x1,S.y1),new h.pointGeometry(S.x2,S.y1),new h.pointGeometry(S.x2,S.y2),new h.pointGeometry(S.x1,S.y2)];h.polygonIntersectsPolygon(n,M)&&(y[T.bucketInstanceId][T.featureIndex]=!0,x[T.bucketInstanceId]===void 0&&(x[T.bucketInstanceId]=[]),x[T.bucketInstanceId].push(T.featureIndex))}return x}insertCollisionBox(t,n,s,l,d,m){(s?this.ignoredGrid:this.grid).insert({bucketInstanceId:l,featureIndex:d,collisionGroupID:m,overlapMode:n},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,n,s,l,d,m){const g=s?this.ignoredGrid:this.grid,y={bucketInstanceId:l,featureIndex:d,collisionGroupID:m,overlapMode:n};for(let x=0;x<t.length;x+=4)g.insertCircle(y,t[x],t[x+1],t[x+2])}projectAndGetPerspectiveRatio(t,n,s,l){let d;return l?(d=[n,s,l(n,s),1],h.transformMat4(d,d,t)):(d=[n,s,0,1],Q(d,d,t)),{point:new h.pointGeometry((d[0]/d[3]+1)/2*this.transform.width+oe,(-d[1]/d[3]+1)/2*this.transform.height+oe),perspectiveRatio:.5+this.transform.cameraToCenterDistance/d[3]*.5}}isOffscreen(t,n,s,l){return s<oe||t>=this.screenRightBoundary||l<oe||n>this.screenBottomBoundary}isInsideGrid(t,n,s,l){return s>=0&&t<this.gridRightBoundary&&l>=0&&n<this.gridBottomBoundary}getViewportMatrix(){const t=h.identity([]);return h.translate(t,t,[-100,-100,0]),t}}function ce(o,t,n){return t*(h.EXTENT/(o.tileSize*Math.pow(2,n-o.tileID.overscaledZ)))}class Ne{constructor(t,n,s,l){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?n:-n))):l&&s?1:0,this.placed=s}isHidden(){return this.opacity===0&&!this.placed}}class je{constructor(t,n,s,l,d){this.text=new Ne(t?t.text:null,n,s,d),this.icon=new Ne(t?t.icon:null,n,l,d)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Re{constructor(t,n,s){this.text=t,this.icon=n,this.skipFade=s}}class qe{constructor(){this.invProjMatrix=h.create(),this.viewportMatrix=h.create(),this.circles=[]}}class st{constructor(t,n,s,l,d){this.bucketInstanceId=t,this.featureIndex=n,this.sourceLayerIndex=s,this.bucketIndex=l,this.tileID=d}}class St{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const n=++this.maxGroupID;this.collisionGroups[t]={ID:n,predicate:s=>s.collisionGroupID===n}}return this.collisionGroups[t]}}function ot(o,t,n,s,l){const{horizontalAlign:d,verticalAlign:m}=h.getAnchorAlignment(o),g=-(d-.5)*t,y=-(m-.5)*n,x=h.evaluateVariableOffset(o,s);return new h.pointGeometry(g+x[0]*l,y+x[1]*l)}function ct(o,t,n,s,l,d){const{x1:m,x2:g,y1:y,y2:x,anchorPointX:S,anchorPointY:T}=o,M=new h.pointGeometry(t,n);return s&&M._rotate(l?d:-d),{x1:m+M.x,y1:y+M.y,x2:g+M.x,y2:x+M.y,anchorPointX:S,anchorPointY:T}}class It{constructor(t,n,s,l,d){this.transform=t.clone(),this.terrain=n,this.collisionIndex=new ye(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=s,this.retainedQueryData={},this.collisionGroups=new St(l),this.collisionCircleArrays={},this.prevPlacement=d,d&&(d.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,n,s,l){const d=s.getBucket(n),m=s.latestFeatureIndex;if(!d||!m||n.id!==d.layerIds[0])return;const g=s.collisionBoxArray,y=d.layers[0].layout,x=Math.pow(2,this.transform.zoom-s.tileID.overscaledZ),S=s.tileSize/h.EXTENT,T=this.transform.calculatePosMatrix(s.tileID.toUnwrapped()),M=y.get("text-pitch-alignment")==="map",F=y.get("text-rotation-alignment")==="map",O=ce(s,1,this.transform.zoom),D=Yt(T,M,F,this.transform,O);let G=null;if(M){const H=fi(T,M,F,this.transform,O);G=h.multiply([],this.transform.labelPlaneMatrix,H)}this.retainedQueryData[d.bucketInstanceId]=new st(d.bucketInstanceId,m,d.sourceLayerIndex,d.index,s.tileID);const Y={bucket:d,layout:y,posMatrix:T,textLabelPlaneMatrix:D,labelToScreenMatrix:G,scale:x,textPixelRatio:S,holdingForFade:s.holdingForFade(),collisionBoxArray:g,partiallyEvaluatedTextSize:h.evaluateSizeForZoom(d.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(d.sourceID)};if(l)for(const H of d.sortKeyRanges){const{sortKey:V,symbolInstanceStart:te,symbolInstanceEnd:ae}=H;t.push({sortKey:V,symbolInstanceStart:te,symbolInstanceEnd:ae,parameters:Y})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:d.symbolInstances.length,parameters:Y})}attemptAnchorPlacement(t,n,s,l,d,m,g,y,x,S,T,M,F,O,D,G){const Y=[M.textOffset0,M.textOffset1],H=ot(t,s,l,Y,d),V=this.collisionIndex.placeCollisionBox(ct(n,H.x,H.y,m,g,this.transform.angle),T,y,x,S.predicate,G);if((!D||this.collisionIndex.placeCollisionBox(ct(D,H.x,H.y,m,g,this.transform.angle),T,y,x,S.predicate,G).box.length!==0)&&V.box.length>0){let te;if(this.prevPlacement&&this.prevPlacement.variableOffsets[M.crossTileID]&&this.prevPlacement.placements[M.crossTileID]&&this.prevPlacement.placements[M.crossTileID].text&&(te=this.prevPlacement.variableOffsets[M.crossTileID].anchor),M.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[M.crossTileID]={textOffset:Y,width:s,height:l,anchor:t,textBoxScale:d,prevAnchor:te},this.markUsedJustification(F,t,M,O),F.allowVerticalPlacement&&(this.markUsedOrientation(F,O,M),this.placedOrientations[M.crossTileID]=O),{shift:H,placedGlyphBoxes:V}}}placeLayerBucketPart(t,n,s){const{bucket:l,layout:d,posMatrix:m,textLabelPlaneMatrix:g,labelToScreenMatrix:y,textPixelRatio:x,holdingForFade:S,collisionBoxArray:T,partiallyEvaluatedTextSize:M,collisionGroup:F}=t.parameters,O=d.get("text-optional"),D=d.get("icon-optional"),G=h.getOverlapMode(d,"text-overlap","text-allow-overlap"),Y=G==="always",H=h.getOverlapMode(d,"icon-overlap","icon-allow-overlap"),V=H==="always",te=d.get("text-rotation-alignment")==="map",ae=d.get("text-pitch-alignment")==="map",se=d.get("icon-text-fit")!=="none",ue=d.get("symbol-z-order")==="viewport-y",me=Y&&(V||!l.hasIconData()||D),xe=V&&(Y||!l.hasTextData()||O);!l.collisionArrays&&T&&l.deserializeCollisionBoxes(T);const _e=(we,ze)=>{if(n[we.crossTileID])return;if(S)return void(this.placements[we.crossTileID]=new Re(!1,!1,!1));let We=!1,Ke=!1,Le=!0,mt=null,ft={box:null,offscreen:null},tt={box:null,offscreen:null},ht=null,wt=null,gt=null,ji=0,qi=0,ni=0;ze.textFeatureIndex?ji=ze.textFeatureIndex:we.useRuntimeCollisionCircles&&(ji=we.featureIndex),ze.verticalTextFeatureIndex&&(qi=ze.verticalTextFeatureIndex);const ki=this.retainedQueryData[l.bucketInstanceId].tileID,_i=this.terrain?(qt,Dt)=>this.terrain.getElevation(ki,qt,Dt):null;for(const qt of["textBox","verticalTextBox","iconBox","verticalIconBox"]){const Dt=ze[qt];Dt&&(Dt.elevation=_i?_i(Dt.anchorPointX,Dt.anchorPointY):0)}const Ji=ze.textBox;if(Ji){const qt=_t=>{let yi=h.WritingMode.horizontal;if(l.allowVerticalPlacement&&!_t&&this.prevPlacement){const xi=this.prevPlacement.placedOrientations[we.crossTileID];xi&&(this.placedOrientations[we.crossTileID]=xi,yi=xi,this.markUsedOrientation(l,yi,we))}return yi},Dt=(_t,yi)=>{if(l.allowVerticalPlacement&&we.numVerticalGlyphVertices>0&&ze.verticalTextBox){for(const xi of l.writingModes)if(xi===h.WritingMode.vertical?(ft=yi(),tt=ft):ft=_t(),ft&&ft.box&&ft.box.length)break}else ft=_t()};if(d.get("text-variable-anchor")){let _t=d.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[we.crossTileID]){const Rt=this.prevPlacement.variableOffsets[we.crossTileID];_t.indexOf(Rt.anchor)>0&&(_t=_t.filter(cr=>cr!==Rt.anchor),_t.unshift(Rt.anchor))}const yi=(Rt,cr,Qi)=>{const oo=Rt.x2-Rt.x1,nn=Rt.y2-Rt.y1,Ya=we.textBoxScale,Ja=se&&H==="never"?cr:null;let sa={box:[],offscreen:!1};const mc=G!=="never"?2*_t.length:_t.length;for(let Ht=0;Ht<mc;++Ht){const Br=this.attemptAnchorPlacement(_t[Ht%_t.length],Rt,oo,nn,Ya,te,ae,x,m,F,Ht>=_t.length?G:"never",we,l,Qi,Ja,_i);if(Br&&(sa=Br.placedGlyphBoxes,sa&&sa.box&&sa.box.length)){We=!0,mt=Br.shift;break}}return sa};Dt(()=>yi(Ji,ze.iconBox,h.WritingMode.horizontal),()=>{const Rt=ze.verticalTextBox;return l.allowVerticalPlacement&&!(ft&&ft.box&&ft.box.length)&&we.numVerticalGlyphVertices>0&&Rt?yi(Rt,ze.verticalIconBox,h.WritingMode.vertical):{box:null,offscreen:null}}),ft&&(We=ft.box,Le=ft.offscreen);const xi=qt(ft&&ft.box);if(!We&&this.prevPlacement){const Rt=this.prevPlacement.variableOffsets[we.crossTileID];Rt&&(this.variableOffsets[we.crossTileID]=Rt,this.markUsedJustification(l,Rt.anchor,we,xi))}}else{const _t=(yi,xi)=>{const Rt=this.collisionIndex.placeCollisionBox(yi,G,x,m,F.predicate,_i);return Rt&&Rt.box&&Rt.box.length&&(this.markUsedOrientation(l,xi,we),this.placedOrientations[we.crossTileID]=xi),Rt};Dt(()=>_t(Ji,h.WritingMode.horizontal),()=>{const yi=ze.verticalTextBox;return l.allowVerticalPlacement&&we.numVerticalGlyphVertices>0&&yi?_t(yi,h.WritingMode.vertical):{box:null,offscreen:null}}),qt(ft&&ft.box&&ft.box.length)}}if(ht=ft,We=ht&&ht.box&&ht.box.length>0,Le=ht&&ht.offscreen,we.useRuntimeCollisionCircles){const qt=l.text.placedSymbolArray.get(we.centerJustifiedTextSymbolIndex),Dt=h.evaluateSizeForFeature(l.textSizeData,M,qt),_t=d.get("text-padding");wt=this.collisionIndex.placeCollisionCircles(G,qt,l.lineVertexArray,l.glyphOffsetArray,Dt,m,g,y,s,ae,F.predicate,we.collisionCircleDiameter,_t,_i),wt.circles.length&&wt.collisionDetected&&!s&&h.warnOnce("Collisions detected, but collision boxes are not shown"),We=Y||wt.circles.length>0&&!wt.collisionDetected,Le=Le&&wt.offscreen}if(ze.iconFeatureIndex&&(ni=ze.iconFeatureIndex),ze.iconBox){const qt=Dt=>{const _t=se&&mt?ct(Dt,mt.x,mt.y,te,ae,this.transform.angle):Dt;return this.collisionIndex.placeCollisionBox(_t,H,x,m,F.predicate,_i)};tt&&tt.box&&tt.box.length&&ze.verticalIconBox?(gt=qt(ze.verticalIconBox),Ke=gt.box.length>0):(gt=qt(ze.iconBox),Ke=gt.box.length>0),Le=Le&&gt.offscreen}const Rr=O||we.numHorizontalGlyphVertices===0&&we.numVerticalGlyphVertices===0,Ka=D||we.numIconVertices===0;if(Rr||Ka?Ka?Rr||(Ke=Ke&&We):We=Ke&&We:Ke=We=Ke&&We,We&&ht&&ht.box&&this.collisionIndex.insertCollisionBox(ht.box,G,d.get("text-ignore-placement"),l.bucketInstanceId,tt&&tt.box&&qi?qi:ji,F.ID),Ke&&gt&&this.collisionIndex.insertCollisionBox(gt.box,H,d.get("icon-ignore-placement"),l.bucketInstanceId,ni,F.ID),wt&&(We&&this.collisionIndex.insertCollisionCircles(wt.circles,G,d.get("text-ignore-placement"),l.bucketInstanceId,ji,F.ID),s)){const qt=l.bucketInstanceId;let Dt=this.collisionCircleArrays[qt];Dt===void 0&&(Dt=this.collisionCircleArrays[qt]=new qe);for(let _t=0;_t<wt.circles.length;_t+=4)Dt.circles.push(wt.circles[_t+0]),Dt.circles.push(wt.circles[_t+1]),Dt.circles.push(wt.circles[_t+2]),Dt.circles.push(wt.collisionDetected?1:0)}if(we.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(l.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[we.crossTileID]=new Re(We||me,Ke||xe,Le||l.justReloaded),n[we.crossTileID]=!0};if(ue){if(t.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const we=l.getSortedSymbolIndexes(this.transform.angle);for(let ze=we.length-1;ze>=0;--ze){const We=we[ze];_e(l.symbolInstances.get(We),l.collisionArrays[We])}}else for(let we=t.symbolInstanceStart;we<t.symbolInstanceEnd;we++)_e(l.symbolInstances.get(we),l.collisionArrays[we]);if(s&&l.bucketInstanceId in this.collisionCircleArrays){const we=this.collisionCircleArrays[l.bucketInstanceId];h.invert(we.invProjMatrix,m),we.viewportMatrix=this.collisionIndex.getViewportMatrix()}l.justReloaded=!1}markUsedJustification(t,n,s,l){let d;d=l===h.WritingMode.vertical?s.verticalPlacedTextSymbolIndex:{left:s.leftJustifiedTextSymbolIndex,center:s.centerJustifiedTextSymbolIndex,right:s.rightJustifiedTextSymbolIndex}[h.getAnchorJustification(n)];const m=[s.leftJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.rightJustifiedTextSymbolIndex,s.verticalPlacedTextSymbolIndex];for(const g of m)g>=0&&(t.text.placedSymbolArray.get(g).crossTileID=d>=0&&g!==d?0:s.crossTileID)}markUsedOrientation(t,n,s){const l=n===h.WritingMode.horizontal||n===h.WritingMode.horizontalOnly?n:0,d=n===h.WritingMode.vertical?n:0,m=[s.leftJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.rightJustifiedTextSymbolIndex];for(const g of m)t.text.placedSymbolArray.get(g).placedOrientation=l;s.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(s.verticalPlacedTextSymbolIndex).placedOrientation=d)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let s=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const l=n?n.symbolFadeChange(t):1,d=n?n.opacities:{},m=n?n.variableOffsets:{},g=n?n.placedOrientations:{};for(const y in this.placements){const x=this.placements[y],S=d[y];S?(this.opacities[y]=new je(S,l,x.text,x.icon),s=s||x.text!==S.text.placed||x.icon!==S.icon.placed):(this.opacities[y]=new je(null,l,x.text,x.icon,x.skipFade),s=s||x.text||x.icon)}for(const y in d){const x=d[y];if(!this.opacities[y]){const S=new je(x,l,!1,!1);S.isHidden()||(this.opacities[y]=S,s=s||x.text.placed||x.icon.placed)}}for(const y in m)this.variableOffsets[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.variableOffsets[y]=m[y]);for(const y in g)this.placedOrientations[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.placedOrientations[y]=g[y]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");s?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:t)}updateLayerOpacities(t,n){const s={};for(const l of n){const d=l.getBucket(t);d&&l.latestFeatureIndex&&t.id===d.layerIds[0]&&this.updateBucketOpacities(d,s,l.collisionBoxArray)}}updateBucketOpacities(t,n,s){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const l=t.layers[0].layout,d=new je(null,0,!1,!1,!0),m=l.get("text-allow-overlap"),g=l.get("icon-allow-overlap"),y=l.get("text-variable-anchor"),x=l.get("text-rotation-alignment")==="map",S=l.get("text-pitch-alignment")==="map",T=l.get("icon-text-fit")!=="none",M=new je(null,0,m&&(g||!t.hasIconData()||l.get("icon-optional")),g&&(m||!t.hasTextData()||l.get("text-optional")),!0);!t.collisionArrays&&s&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(s);const F=(O,D,G)=>{for(let Y=0;Y<D/4;Y++)O.opacityVertexArray.emplaceBack(G);O.hasVisibleVertices=O.hasVisibleVertices||G!==Pr};for(let O=0;O<t.symbolInstances.length;O++){const D=t.symbolInstances.get(O),{numHorizontalGlyphVertices:G,numVerticalGlyphVertices:Y,crossTileID:H}=D;let V=this.opacities[H];n[H]?V=d:V||(V=M,this.opacities[H]=V),n[H]=!0;const te=D.numIconVertices>0,ae=this.placedOrientations[D.crossTileID],se=ae===h.WritingMode.vertical,ue=ae===h.WritingMode.horizontal||ae===h.WritingMode.horizontalOnly;if(G>0||Y>0){const me=vn(V.text);F(t.text,G,se?Pr:me),F(t.text,Y,ue?Pr:me);const xe=V.text.isHidden();[D.rightJustifiedTextSymbolIndex,D.centerJustifiedTextSymbolIndex,D.leftJustifiedTextSymbolIndex].forEach(ze=>{ze>=0&&(t.text.placedSymbolArray.get(ze).hidden=xe||se?1:0)}),D.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(D.verticalPlacedTextSymbolIndex).hidden=xe||ue?1:0);const _e=this.variableOffsets[D.crossTileID];_e&&this.markUsedJustification(t,_e.anchor,D,ae);const we=this.placedOrientations[D.crossTileID];we&&(this.markUsedJustification(t,"left",D,we),this.markUsedOrientation(t,we,D))}if(te){const me=vn(V.icon),xe=!(T&&D.verticalPlacedIconSymbolIndex&&se);D.placedIconSymbolIndex>=0&&(F(t.icon,D.numIconVertices,xe?me:Pr),t.icon.placedSymbolArray.get(D.placedIconSymbolIndex).hidden=V.icon.isHidden()),D.verticalPlacedIconSymbolIndex>=0&&(F(t.icon,D.numVerticalIconVertices,xe?Pr:me),t.icon.placedSymbolArray.get(D.verticalPlacedIconSymbolIndex).hidden=V.icon.isHidden())}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const me=t.collisionArrays[O];if(me){let xe=new h.pointGeometry(0,0);if(me.textBox||me.verticalTextBox){let we=!0;if(y){const ze=this.variableOffsets[H];ze?(xe=ot(ze.anchor,ze.width,ze.height,ze.textOffset,ze.textBoxScale),x&&xe._rotate(S?this.transform.angle:-this.transform.angle)):we=!1}me.textBox&&$t(t.textCollisionBox.collisionVertexArray,V.text.placed,!we||se,xe.x,xe.y),me.verticalTextBox&&$t(t.textCollisionBox.collisionVertexArray,V.text.placed,!we||ue,xe.x,xe.y)}const _e=!!(!ue&&me.verticalIconBox);me.iconBox&&$t(t.iconCollisionBox.collisionVertexArray,V.icon.placed,_e,T?xe.x:0,T?xe.y:0),me.verticalIconBox&&$t(t.iconCollisionBox.collisionVertexArray,V.icon.placed,!_e,T?xe.x:0,T?xe.y:0)}}}if(t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);if(t.bucketInstanceId in this.collisionCircleArrays){const O=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=O.invProjMatrix,t.placementViewportMatrix=O.viewportMatrix,t.collisionCircleArray=O.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return this.fadeDuration===0?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,n){const s=this.zoomAtLastRecencyCheck===n?1-this.zoomAdjustment(n):1;return this.zoomAtLastRecencyCheck=n,this.commitTime+this.fadeDuration*s>t}setStale(){this.stale=!0}}function $t(o,t,n,s,l){o.emplaceBack(t?1:0,n?1:0,s||0,l||0),o.emplaceBack(t?1:0,n?1:0,s||0,l||0),o.emplaceBack(t?1:0,n?1:0,s||0,l||0),o.emplaceBack(t?1:0,n?1:0,s||0,l||0)}const ti=Math.pow(2,25),Wt=Math.pow(2,24),xn=Math.pow(2,17),Ro=Math.pow(2,16),Bo=Math.pow(2,9),Hr=Math.pow(2,8),fa=Math.pow(2,1);function vn(o){if(o.opacity===0&&!o.placed)return 0;if(o.opacity===1&&o.placed)return 4294967295;const t=o.placed?1:0,n=Math.floor(127*o.opacity);return n*ti+t*Wt+n*xn+t*Ro+n*Bo+t*Hr+n*fa+t}const Pr=0;class ga{constructor(t){this._sortAcrossTiles=t.layout.get("symbol-z-order")!=="viewport-y"&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,n,s,l,d){const m=this._bucketParts;for(;this._currentTileIndex<t.length;)if(n.getBucketParts(m,l,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,d())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,m.sort((g,y)=>g.sortKey-y.sortKey));this._currentPartIndex<m.length;)if(n.placeLayerBucketPart(m[this._currentPartIndex],this._seenCrossTileIDs,s),this._currentPartIndex++,d())return!0;return!1}}class ds{constructor(t,n,s,l,d,m,g,y){this.placement=new It(t,n,m,g,y),this._currentPlacementIndex=s.length-1,this._forceFullPlacement=l,this._showCollisionBoxes=d,this._done=!1}isDone(){return this._done}continuePlacement(t,n,s){const l=h.exported.now(),d=()=>{const m=h.exported.now()-l;return!this._forceFullPlacement&&m>2};for(;this._currentPlacementIndex>=0;){const m=n[t[this._currentPlacementIndex]],g=this.placement.collisionIndex.transform.zoom;if(m.type==="symbol"&&(!m.minzoom||m.minzoom<=g)&&(!m.maxzoom||m.maxzoom>g)){if(this._inProgressLayer||(this._inProgressLayer=new ga(m)),this._inProgressLayer.continuePlacement(s[m.source],this.placement,this._showCollisionBoxes,m,d))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const bn=512/h.EXTENT/2;class ps{constructor(t,n,s){this.tileID=t,this.bucketInstanceId=s,this._symbolsByKey={};const l=new Map;for(let d=0;d<n.length;d++){const m=n.get(d),g=m.key,y=l.get(g);y?y.push(m):l.set(g,[m])}for(const[d,m]of l){const g={positions:m.map(y=>({x:Math.floor(y.anchorX*bn),y:Math.floor(y.anchorY*bn)})),crossTileIDs:m.map(y=>y.crossTileID)};if(g.positions.length>128){const y=new h.KDBush(g.positions,x=>x.x,x=>x.y,16,Uint16Array);delete y.points,delete g.positions,g.index=y}this._symbolsByKey[d]=g}}getScaledCoordinates(t,n){const{x:s,y:l,z:d}=this.tileID.canonical,{x:m,y:g,z:y}=n.canonical,x=bn/Math.pow(2,y-d),S=(g*h.EXTENT+t.anchorY)*x,T=l*h.EXTENT*bn;return{x:Math.floor((m*h.EXTENT+t.anchorX)*x-s*h.EXTENT*bn),y:Math.floor(S-T)}}findMatches(t,n,s){const l=this.tileID.canonical.z<n.canonical.z?1:Math.pow(2,this.tileID.canonical.z-n.canonical.z);for(let d=0;d<t.length;d++){const m=t.get(d);if(m.crossTileID)continue;const g=this._symbolsByKey[m.key];if(!g)continue;const y=this.getScaledCoordinates(m,n);if(g.index){const x=g.index.range(y.x-l,y.y-l,y.x+l,y.y+l).sort();for(const S of x){const T=g.crossTileIDs[S];if(!s[T]){s[T]=!0,m.crossTileID=T;break}}}else if(g.positions)for(let x=0;x<g.positions.length;x++){const S=g.positions[x],T=g.crossTileIDs[x];if(Math.abs(S.x-y.x)<=l&&Math.abs(S.y-y.y)<=l&&!s[T]){s[T]=!0,m.crossTileID=T;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:t})=>t)}}class _a{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class qn{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const n=Math.round((t-this.lng)/360);if(n!==0)for(const s in this.indexes){const l=this.indexes[s],d={};for(const m in l){const g=l[m];g.tileID=g.tileID.unwrapTo(g.tileID.wrap+n),d[g.tileID.key]=g}this.indexes[s]=d}this.lng=t}addBucket(t,n,s){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let d=0;d<n.symbolInstances.length;d++)n.symbolInstances.get(d).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const l=this.usedCrossTileIDs[t.overscaledZ];for(const d in this.indexes){const m=this.indexes[d];if(Number(d)>t.overscaledZ)for(const g in m){const y=m[g];y.tileID.isChildOf(t)&&y.findMatches(n.symbolInstances,t,l)}else{const g=m[t.scaledTo(Number(d)).key];g&&g.findMatches(n.symbolInstances,t,l)}}for(let d=0;d<n.symbolInstances.length;d++){const m=n.symbolInstances.get(d);m.crossTileID||(m.crossTileID=s.generate(),l[m.crossTileID]=!0)}return this.indexes[t.overscaledZ]===void 0&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new ps(t,n.symbolInstances,n.bucketInstanceId),!0}removeBucketCrossTileIDs(t,n){for(const s of n.getCrossTileIDsLists())for(const l of s)delete this.usedCrossTileIDs[t][l]}removeStaleBuckets(t){let n=!1;for(const s in this.indexes){const l=this.indexes[s];for(const d in l)t[l[d].bucketInstanceId]||(this.removeBucketCrossTileIDs(s,l[d]),delete l[d],n=!0)}return n}}class zt{constructor(){this.layerIndexes={},this.crossTileIDs=new _a,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,n,s){let l=this.layerIndexes[t.id];l===void 0&&(l=this.layerIndexes[t.id]=new qn);let d=!1;const m={};l.handleWrapJump(s);for(const g of n){const y=g.getBucket(t);y&&t.id===y.layerIds[0]&&(y.bucketInstanceId||(y.bucketInstanceId=++this.maxBucketInstanceId),l.addBucket(g.tileID,y,this.crossTileIDs)&&(d=!0),m[y.bucketInstanceId]=!0)}return l.removeStaleBuckets(m)&&(d=!0),d}pruneUnusedLayers(t){const n={};t.forEach(s=>{n[s]=!0});for(const s in this.layerIndexes)n[s]||delete this.layerIndexes[s]}}const Kr=(o,t)=>h.emitValidationErrors(o,t&&t.filter(n=>n.identifier!=="source.canvas")),Fo=h.pick(lt,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setGlyphs","setSprite"]),Oo=h.pick(lt,["setCenter","setZoom","setBearing","setPitch"]),Uo=function(){const o={},t=h.spec.$version;for(const n in h.spec.$root){const s=h.spec.$root[n];if(s.required){let l=null;l=n==="version"?t:s.type==="array"?[]:{},l!=null&&(o[n]=l)}}return o}();class Ni extends h.Evented{constructor(t,n={}){super(),this.map=t,this.dispatcher=new Nr(gn(),this,t._getMapId()),this.imageManager=new He,this.imageManager.setEventedParent(this),this.glyphManager=new ar(t._requestManager,n.localIdeographFontFamily),this.lineAtlas=new $n(256,512),this.crossTileSymbolIndex=new zt,this._spritesImagesIds={},this._layers={},this._serializedLayers={},this._order=[],this.sourceCaches={},this.zoomHistory=new h.ZoomHistory,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("setReferrer",h.getReferrer());const s=this;this._rtlTextPluginCallback=Ni.registerForPluginStateChange(l=>{s.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:l.pluginStatus,pluginURL:l.pluginURL},(d,m)=>{if(h.triggerPluginCompletionEvent(d),m&&m.every(g=>g))for(const g in s.sourceCaches)s.sourceCaches[g].reload()})}),this.on("data",l=>{if(l.dataType!=="source"||l.sourceDataType!=="metadata")return;const d=this.sourceCaches[l.sourceId];if(!d)return;const m=d.getSource();if(m&&m.vectorLayerIds)for(const g in this._layers){const y=this._layers[g];y.source===m.id&&this._validateLayer(y)}})}loadURL(t,n={},s){this.fire(new h.Event("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const l=this.map._requestManager.transformRequest(t,dt.Style);this._request=h.getJSON(l,(d,m)=>{this._request=null,d?this.fire(new h.ErrorEvent(d)):m&&this._load(m,n,s)})}loadJSON(t,n={},s){this.fire(new h.Event("dataloading",{dataType:"style"})),this._request=h.exported.frame(()=>{this._request=null,n.validate=n.validate!==!1,this._load(t,n,s)})}loadEmpty(){this.fire(new h.Event("dataloading",{dataType:"style"})),this._load(Uo,{validate:!1})}_load(t,n,s){const l=n.transformStyle?n.transformStyle(s,t):t;if(n.validate&&Kr(this,h.validateStyle(l)))return;this._loaded=!0,this.stylesheet=l;for(const m in l.sources)this.addSource(m,l.sources[m],{validate:!1});l.sprite?this._loadSprite(l.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(l.glyphs);const d=_n(this.stylesheet.layers);this._order=d.map(m=>m.id),this._layers={},this._serializedLayers={};for(let m of d)m=h.createStyleLayer(m),m.setEventedParent(this,{layer:{id:m.id}}),this._layers[m.id]=m,this._serializedLayers[m.id]=m.serialize();this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new Vr(this.stylesheet.light),this.map.setTerrain(this.stylesheet.terrain),this.fire(new h.Event("data",{dataType:"style"})),this.fire(new h.Event("style.load"))}_loadSprite(t,n=!1,s){this.imageManager.setLoaded(!1),this._spriteRequest=function(l,d,m,g){const y=nr(l),x=m>1?"@2x":"";let S;const T=[],M=[],F={},O={};for(const{id:G,url:Y}of y){const H=T.push(h.getJSON(d.transformRequest(d.normalizeSpriteURL(Y,x,".json"),dt.SpriteJSON),(te,ae)=>{T.splice(H,1),S||(S=te,F[G]=ae,D())})),V=M.push(Qt.getImage(d.transformRequest(d.normalizeSpriteURL(Y,x,".png"),dt.SpriteImage),(te,ae)=>{M.splice(V,1),S||(S=te,O[G]=ae,D())}))}function D(){const G=Object.values(F).length,Y=Object.values(O).length;if(S)g(S);else if(y.length===G&&G===Y){const H={};for(const V in F){H[V]={};const te=h.exported.getImageCanvasContext(O[V]),ae=F[V];for(const se in ae){const{width:ue,height:me,x:xe,y:_e,sdf:we,pixelRatio:ze,stretchX:We,stretchY:Ke,content:Le}=ae[se];H[V][se]={data:null,pixelRatio:ze,sdf:we,stretchX:We,stretchY:Ke,content:Le,spriteData:{width:ue,height:me,x:xe,y:_e,context:te}}}}g(null,H)}}return{cancel(){if(T.length)for(const G of T)G.cancel(),T.splice(T.indexOf(G),1);if(M.length)for(const G of M)G.cancel(),M.splice(M.indexOf(G),1)}}}(t,this.map._requestManager,this.map.getPixelRatio(),(l,d)=>{if(this._spriteRequest=null,l)this.fire(new h.ErrorEvent(l));else if(d)for(const m in d){this._spritesImagesIds[m]=[];const g=this._spritesImagesIds[m]?this._spritesImagesIds[m].filter(y=>!(y in d)):[];for(const y of g)this.imageManager.removeImage(y),this._changedImages[y]=!0;for(const y in d[m]){const x=m==="default"?y:`${m}:${y}`;this._spritesImagesIds[m].push(x),x in this.imageManager.images?this.imageManager.updateImage(x,d[m][y],!1):this.imageManager.addImage(x,d[m][y]),n&&(this._changedImages[x]=!0)}}this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new h.Event("data",{dataType:"style"})),s&&s(l)})}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new h.Event("data",{dataType:"style"}))}_validateLayer(t){const n=this.sourceCaches[t.source];if(!n)return;const s=t.sourceLayer;if(!s)return;const l=n.getSource();(l.type==="geojson"||l.vectorLayerIds&&l.vectorLayerIds.indexOf(s)===-1)&&this.fire(new h.ErrorEvent(new Error(`Source layer "${s}" does not exist on source "${l.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(t){const n=[];for(const s of t){const l=this._layers[s];l.type!=="custom"&&n.push(l.serialize())}return n}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;for(const t in this.sourceCaches)if(this.sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const n=this._changed;if(this._changed){const l=Object.keys(this._updatedLayers),d=Object.keys(this._removedLayers);(l.length||d.length)&&this._updateWorkerLayers(l,d);for(const m in this._updatedSources){const g=this._updatedSources[m];if(g==="reload")this._reloadSource(m);else{if(g!=="clear")throw new Error(`Invalid action ${g}`);this._clearSource(m)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const m in this._updatedPaintProps)this._layers[m].updateTransitions(t);this.light.updateTransitions(t),this._resetUpdates()}const s={};for(const l in this.sourceCaches){const d=this.sourceCaches[l];s[l]=d.used,d.used=!1}for(const l of this._order){const d=this._layers[l];d.recalculate(t,this._availableImages),!d.isHidden(t.zoom)&&d.source&&(this.sourceCaches[d.source].used=!0)}for(const l in s){const d=this.sourceCaches[l];s[l]!==d.used&&d.fire(new h.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:l}))}this.light.recalculate(t),this.z=t.zoom,n&&this.fire(new h.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const n in this.sourceCaches)this.sourceCaches[n].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,n){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(t),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,n={}){if(this._checkLoaded(),t=n.transformStyle?n.transformStyle(this.serialize(),t):t,Kr(this,h.validateStyle(t)))return!1;(t=h.clone$1(t)).layers=_n(t.layers);const s=function(d,m){if(!d)return[{command:lt.setStyle,args:[m]}];let g=[];try{if(!pe(d.version,m.version))return[{command:lt.setStyle,args:[m]}];pe(d.center,m.center)||g.push({command:lt.setCenter,args:[m.center]}),pe(d.zoom,m.zoom)||g.push({command:lt.setZoom,args:[m.zoom]}),pe(d.bearing,m.bearing)||g.push({command:lt.setBearing,args:[m.bearing]}),pe(d.pitch,m.pitch)||g.push({command:lt.setPitch,args:[m.pitch]}),pe(d.sprite,m.sprite)||g.push({command:lt.setSprite,args:[m.sprite]}),pe(d.glyphs,m.glyphs)||g.push({command:lt.setGlyphs,args:[m.glyphs]}),pe(d.transition,m.transition)||g.push({command:lt.setTransition,args:[m.transition]}),pe(d.light,m.light)||g.push({command:lt.setLight,args:[m.light]});const y={},x=[];(function(T,M,F,O){let D;for(D in M=M||{},T=T||{})Object.prototype.hasOwnProperty.call(T,D)&&(Object.prototype.hasOwnProperty.call(M,D)||yn(D,F,O));for(D in M)Object.prototype.hasOwnProperty.call(M,D)&&(Object.prototype.hasOwnProperty.call(T,D)?pe(T[D],M[D])||(T[D].type==="geojson"&&M[D].type==="geojson"&&jn(T,M,D)?F.push({command:lt.setGeoJSONSourceData,args:[D,M[D].data]}):Xr(D,M,F,O)):Cr(D,M,F))})(d.sources,m.sources,x,y);const S=[];d.layers&&d.layers.forEach(T=>{y[T.source]?g.push({command:lt.removeLayer,args:[T.id]}):S.push(T)}),g=g.concat(x),function(T,M,F){M=M||[];const O=(T=T||[]).map(Mr),D=M.map(Mr),G=T.reduce(ut,{}),Y=M.reduce(ut,{}),H=O.slice(),V=Object.create(null);let te,ae,se,ue,me,xe,_e;for(te=0,ae=0;te<O.length;te++)se=O[te],Object.prototype.hasOwnProperty.call(Y,se)?ae++:(F.push({command:lt.removeLayer,args:[se]}),H.splice(H.indexOf(se,ae),1));for(te=0,ae=0;te<D.length;te++)se=D[D.length-1-te],H[H.length-1-te]!==se&&(Object.prototype.hasOwnProperty.call(G,se)?(F.push({command:lt.removeLayer,args:[se]}),H.splice(H.lastIndexOf(se,H.length-ae),1)):ae++,xe=H[H.length-te],F.push({command:lt.addLayer,args:[Y[se],xe]}),H.splice(H.length-te,0,se),V[se]=!0);for(te=0;te<D.length;te++)if(se=D[te],ue=G[se],me=Y[se],!V[se]&&!pe(ue,me))if(pe(ue.source,me.source)&&pe(ue["source-layer"],me["source-layer"])&&pe(ue.type,me.type)){for(_e in _r(ue.layout,me.layout,F,se,null,lt.setLayoutProperty),_r(ue.paint,me.paint,F,se,null,lt.setPaintProperty),pe(ue.filter,me.filter)||F.push({command:lt.setFilter,args:[se,me.filter]}),pe(ue.minzoom,me.minzoom)&&pe(ue.maxzoom,me.maxzoom)||F.push({command:lt.setLayerZoomRange,args:[se,me.minzoom,me.maxzoom]}),ue)Object.prototype.hasOwnProperty.call(ue,_e)&&_e!=="layout"&&_e!=="paint"&&_e!=="filter"&&_e!=="metadata"&&_e!=="minzoom"&&_e!=="maxzoom"&&(_e.indexOf("paint.")===0?_r(ue[_e],me[_e],F,se,_e.slice(6),lt.setPaintProperty):pe(ue[_e],me[_e])||F.push({command:lt.setLayerProperty,args:[se,_e,me[_e]]}));for(_e in me)Object.prototype.hasOwnProperty.call(me,_e)&&!Object.prototype.hasOwnProperty.call(ue,_e)&&_e!=="layout"&&_e!=="paint"&&_e!=="filter"&&_e!=="metadata"&&_e!=="minzoom"&&_e!=="maxzoom"&&(_e.indexOf("paint.")===0?_r(ue[_e],me[_e],F,se,_e.slice(6),lt.setPaintProperty):pe(ue[_e],me[_e])||F.push({command:lt.setLayerProperty,args:[se,_e,me[_e]]}))}else F.push({command:lt.removeLayer,args:[se]}),xe=H[H.lastIndexOf(se)+1],F.push({command:lt.addLayer,args:[me,xe]})}(S,m.layers,g)}catch(y){console.warn("Unable to compute style diff:",y),g=[{command:lt.setStyle,args:[m]}]}return g}(this.serialize(),t).filter(d=>!(d.command in Oo));if(s.length===0)return!1;const l=s.filter(d=>!(d.command in Fo));if(l.length>0)throw new Error(`Unimplemented: ${l.map(d=>d.command).join(", ")}.`);return s.forEach(d=>{d.command!=="setTransition"&&this[d.command].apply(this,d.args)}),this.stylesheet=t,!0}addImage(t,n){if(this.getImage(t))return this.fire(new h.ErrorEvent(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,n),this._afterImageUpdated(t)}updateImage(t,n){this.imageManager.updateImage(t,n)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new h.ErrorEvent(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new h.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,n,s={}){if(this._checkLoaded(),this.sourceCaches[t]!==void 0)throw new Error(`Source "${t}" already exists.`);if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(h.validateStyle.source,`sources.${t}`,n,null,s))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const l=this.sourceCaches[t]=new Xe(t,n,this.dispatcher);l.style=this,l.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:l.serialize(),sourceId:t})),l.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),this.sourceCaches[t]===void 0)throw new Error("There is no source with this ID");for(const s in this._layers)if(this._layers[s].source===t)return this.fire(new h.ErrorEvent(new Error(`Source "${t}" cannot be removed while layer "${s}" is using it.`)));const n=this.sourceCaches[t];delete this.sourceCaches[t],delete this._updatedSources[t],n.fire(new h.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,n){if(this._checkLoaded(),this.sourceCaches[t]===void 0)throw new Error(`There is no source with this ID=${t}`);const s=this.sourceCaches[t].getSource();if(s.type!=="geojson")throw new Error(`geojsonSource.type is ${s.type}, which is !== 'geojson`);s.setData(n),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(t,n,s={}){this._checkLoaded();const l=t.id;if(this.getLayer(l))return void this.fire(new h.ErrorEvent(new Error(`Layer "${l}" already exists on this map.`)));let d;if(t.type==="custom"){if(Kr(this,h.validateCustomStyleLayer(t)))return;d=h.createStyleLayer(t)}else{if(typeof t.source=="object"&&(this.addSource(l,t.source),t=h.clone$1(t),t=h.extend(t,{source:l})),this._validate(h.validateStyle.layer,`layers.${l}`,t,{arrayIndex:-1},s))return;d=h.createStyleLayer(t),this._validateLayer(d),d.setEventedParent(this,{layer:{id:l}}),this._serializedLayers[d.id]=d.serialize()}const m=n?this._order.indexOf(n):this._order.length;if(n&&m===-1)this.fire(new h.ErrorEvent(new Error(`Cannot add layer "${l}" before non-existing layer "${n}".`)));else{if(this._order.splice(m,0,l),this._layerOrderChanged=!0,this._layers[l]=d,this._removedLayers[l]&&d.source&&d.type!=="custom"){const g=this._removedLayers[l];delete this._removedLayers[l],g.type!==d.type?this._updatedSources[d.source]="clear":(this._updatedSources[d.source]="reload",this.sourceCaches[d.source].pause())}this._updateLayer(d),d.onAdd&&d.onAdd(this.map)}}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new h.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===n)return;const s=this._order.indexOf(t);this._order.splice(s,1);const l=n?this._order.indexOf(n):this._order.length;n&&l===-1?this.fire(new h.ErrorEvent(new Error(`Cannot move layer "${t}" before non-existing layer "${n}".`))):(this._order.splice(l,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const n=this._layers[t];if(!n)return void this.fire(new h.ErrorEvent(new Error(`Cannot remove non-existing layer "${t}".`)));n.setEventedParent(null);const s=this._order.indexOf(t);this._order.splice(s,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map)}getLayer(t){return this._layers[t]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,n,s){this._checkLoaded();const l=this.getLayer(t);l?l.minzoom===n&&l.maxzoom===s||(n!=null&&(l.minzoom=n),s!=null&&(l.maxzoom=s),this._updateLayer(l)):this.fire(new h.ErrorEvent(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,n,s={}){this._checkLoaded();const l=this.getLayer(t);if(l){if(!pe(l.filter,n))return n==null?(l.filter=void 0,void this._updateLayer(l)):void(this._validate(h.validateStyle.filter,`layers.${l.id}.filter`,n,null,s)||(l.filter=h.clone$1(n),this._updateLayer(l)))}else this.fire(new h.ErrorEvent(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return h.clone$1(this.getLayer(t).filter)}setLayoutProperty(t,n,s,l={}){this._checkLoaded();const d=this.getLayer(t);d?pe(d.getLayoutProperty(n),s)||(d.setLayoutProperty(n,s,l),this._updateLayer(d)):this.fire(new h.ErrorEvent(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,n){const s=this.getLayer(t);if(s)return s.getLayoutProperty(n);this.fire(new h.ErrorEvent(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,n,s,l={}){this._checkLoaded();const d=this.getLayer(t);d?pe(d.getPaintProperty(n),s)||(d.setPaintProperty(n,s,l)&&this._updateLayer(d),this._changed=!0,this._updatedPaintProps[t]=!0):this.fire(new h.ErrorEvent(new Error(`Cannot style non-existing layer "${t}".`)))}getPaintProperty(t,n){return this.getLayer(t).getPaintProperty(n)}setFeatureState(t,n){this._checkLoaded();const s=t.source,l=t.sourceLayer,d=this.sourceCaches[s];if(d===void 0)return void this.fire(new h.ErrorEvent(new Error(`The source '${s}' does not exist in the map's style.`)));const m=d.getSource().type;m==="geojson"&&l?this.fire(new h.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):m!=="vector"||l?(t.id===void 0&&this.fire(new h.ErrorEvent(new Error("The feature id parameter must be provided."))),d.setFeatureState(l,t.id,n)):this.fire(new h.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,n){this._checkLoaded();const s=t.source,l=this.sourceCaches[s];if(l===void 0)return void this.fire(new h.ErrorEvent(new Error(`The source '${s}' does not exist in the map's style.`)));const d=l.getSource().type,m=d==="vector"?t.sourceLayer:void 0;d!=="vector"||m?n&&typeof t.id!="string"&&typeof t.id!="number"?this.fire(new h.ErrorEvent(new Error("A feature id is required to remove its specific state property."))):l.removeFeatureState(m,t.id,n):this.fire(new h.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const n=t.source,s=t.sourceLayer,l=this.sourceCaches[n];if(l!==void 0)return l.getSource().type!=="vector"||s?(t.id===void 0&&this.fire(new h.ErrorEvent(new Error("The feature id parameter must be provided."))),l.getFeatureState(s,t.id)):void this.fire(new h.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new h.ErrorEvent(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return h.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){return h.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,sources:h.mapObject(this.sourceCaches,t=>t.serialize()),layers:this._serializeLayers(this._order)},t=>t!==void 0)}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&this.sourceCaches[t.source].getSource().type!=="raster"&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._changed=!0}_flattenAndSortRenderedFeatures(t){const n=m=>this._layers[m].type==="fill-extrusion",s={},l=[];for(let m=this._order.length-1;m>=0;m--){const g=this._order[m];if(n(g)){s[g]=m;for(const y of t){const x=y[g];if(x)for(const S of x)l.push(S)}}}l.sort((m,g)=>g.intersectionZ-m.intersectionZ);const d=[];for(let m=this._order.length-1;m>=0;m--){const g=this._order[m];if(n(g))for(let y=l.length-1;y>=0;y--){const x=l[y].feature;if(s[x.layer.id]<m)break;d.push(x),l.pop()}else for(const y of t){const x=y[g];if(x)for(const S of x)d.push(S.feature)}}return d}queryRenderedFeatures(t,n,s){n&&n.filter&&this._validate(h.validateStyle.filter,"queryRenderedFeatures.filter",n.filter,null,n);const l={};if(n&&n.layers){if(!Array.isArray(n.layers))return this.fire(new h.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const m of n.layers){const g=this._layers[m];if(!g)return this.fire(new h.ErrorEvent(new Error(`The layer '${m}' does not exist in the map's style and cannot be queried for features.`))),[];l[g.source]=!0}}const d=[];n.availableImages=this._availableImages;for(const m in this.sourceCaches)n.layers&&!l[m]||d.push(Ee(this.sourceCaches[m],this._layers,this._serializedLayers,t,n,s));return this.placement&&d.push(function(m,g,y,x,S,T,M){const F={},O=T.queryRenderedSymbols(x),D=[];for(const G of Object.keys(O).map(Number))D.push(M[G]);D.sort(Qe);for(const G of D){const Y=G.featureIndex.lookupSymbolFeatures(O[G.bucketInstanceId],g,G.bucketIndex,G.sourceLayerIndex,S.filter,S.layers,S.availableImages,m);for(const H in Y){const V=F[H]=F[H]||[],te=Y[H];te.sort((ae,se)=>{const ue=G.featureSortOrder;if(ue){const me=ue.indexOf(ae.featureIndex);return ue.indexOf(se.featureIndex)-me}return se.featureIndex-ae.featureIndex});for(const ae of te)V.push(ae)}}for(const G in F)F[G].forEach(Y=>{const H=Y.feature,V=y[m[G].source].getFeatureState(H.layer["source-layer"],H.id);H.source=H.layer.source,H.layer["source-layer"]&&(H.sourceLayer=H.layer["source-layer"]),H.state=V});return F}(this._layers,this._serializedLayers,this.sourceCaches,t,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(d)}querySourceFeatures(t,n){n&&n.filter&&this._validate(h.validateStyle.filter,"querySourceFeatures.filter",n.filter,null,n);const s=this.sourceCaches[t];return s?function(l,d){const m=l.getRenderableIds().map(x=>l.getTileByID(x)),g=[],y={};for(let x=0;x<m.length;x++){const S=m[x],T=S.tileID.canonical.key;y[T]||(y[T]=!0,S.querySourceFeatures(g,d))}return g}(s,n):[]}addSourceType(t,n,s){return Ni.getSourceType(t)?s(new Error(`A source type called "${t}" already exists.`)):(Ni.setSourceType(t,n),n.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:n.workerSourceURL},s):s(null,null))}getLight(){return this.light.getLight()}setLight(t,n={}){this._checkLoaded();const s=this.light.getLight();let l=!1;for(const m in t)if(!pe(t[m],s[m])){l=!0;break}if(!l)return;const d={now:h.exported.now(),transition:h.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,n),this.light.updateTransitions(d)}_validate(t,n,s,l,d={}){return(!d||d.validate!==!1)&&Kr(this,t.call(h.validateStyle,h.extend({key:n,style:this.serialize(),value:s,styleSpec:h.spec},l)))}_remove(t=!0){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),h.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const n in this._layers)this._layers[n].setEventedParent(null);for(const n in this.sourceCaches){const s=this.sourceCaches[n];s.setEventedParent(null),s.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove(t)}_clearSource(t){this.sourceCaches[t].clearTiles()}_reloadSource(t){this.sourceCaches[t].resume(),this.sourceCaches[t].reload()}_updateSources(t){for(const n in this.sourceCaches)this.sourceCaches[n].update(t,this.map.terrain)}_generateCollisionBoxes(){for(const t in this.sourceCaches)this._reloadSource(t)}_updatePlacement(t,n,s,l,d=!1){let m=!1,g=!1;const y={};for(const x of this._order){const S=this._layers[x];if(S.type!=="symbol")continue;if(!y[S.source]){const M=this.sourceCaches[S.source];y[S.source]=M.getRenderableIds(!0).map(F=>M.getTileByID(F)).sort((F,O)=>O.tileID.overscaledZ-F.tileID.overscaledZ||(F.tileID.isLessThan(O.tileID)?-1:1))}const T=this.crossTileSymbolIndex.addLayer(S,y[S.source],t.center.lng);m=m||T}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((d=d||this._layerOrderChanged||s===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(h.exported.now(),t.zoom))&&(this.pauseablePlacement=new ds(t,this.map.terrain,this._order,d,n,s,l,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(h.exported.now()),g=!0),m&&this.pauseablePlacement.placement.setStale()),g||m)for(const x of this._order){const S=this._layers[x];S.type==="symbol"&&this.placement.updateLayerOpacities(S,y[S.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(h.exported.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,n,s){this.imageManager.getImages(n.icons,s),this._updateTilesForChangedImages();const l=this.sourceCaches[n.source];l&&l.setDependencies(n.tileID.key,n.type,n.icons)}getGlyphs(t,n,s){this.glyphManager.getGlyphs(n.stacks,s);const l=this.sourceCaches[n.source];l&&l.setDependencies(n.tileID.key,n.type,[""])}getResource(t,n,s){return h.makeRequest(n,s)}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,n={}){this._checkLoaded(),t&&this._validate(h.validateStyle.glyphs,"glyphs",t,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}addSprite(t,n,s={},l){this._checkLoaded();const d=[{id:t,url:n}],m=[...nr(this.stylesheet.sprite),...d];this._validate(h.validateStyle.sprite,"sprite",m,null,s)||(this.stylesheet.sprite=m,this._loadSprite(d,!0,l))}removeSprite(t){this._checkLoaded();const n=nr(this.stylesheet.sprite);if(n.find(s=>s.id===t)){if(this._spritesImagesIds[t])for(const s of this._spritesImagesIds[t])this.imageManager.removeImage(s),this._changedImages[s]=!0;n.splice(n.findIndex(s=>s.id===t),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new h.Event("data",{dataType:"style"}))}else this.fire(new h.ErrorEvent(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return nr(this.stylesheet.sprite)}setSprite(t,n={},s){this._checkLoaded(),t&&this._validate(h.validateStyle.sprite,"sprite",t,null,n)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,s):(this._unloadSprite(),s(null)))}}Ni.getSourceType=function(o){return jr[o]},Ni.setSourceType=function(o,t){jr[o]=t},Ni.registerForPluginStateChange=h.registerForPluginStateChange;var ya=h.createLayout([{name:"a_pos",type:"Int16",components:2}]),ms="attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_depth;void main() {float extent=8192.0;float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/extent;gl_Position=u_matrix*vec4(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}";const Zn={prelude:xt(`#ifdef GL_ES
1
+ (function(Oe,os){typeof exports=="object"&&typeof module<"u"?os(exports):typeof define=="function"&&define.amd?define(["exports"],os):(Oe=typeof globalThis<"u"?globalThis:Oe||self,os(Oe.maptilersdk={}))})(this,function(Oe){"use strict";var os=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yc(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var Jc={exports:{}};(function(A,b){(function(z,W){A.exports=W()})(os,function(){var z,W,ie;function de(h,ve){if(!z)z=ve;else if(!W)W=ve;else{var Ge="var sharedChunk = {}; ("+z+")(sharedChunk); ("+W+")(sharedChunk);",et={};z(et),ie=ve(et),typeof window<"u"&&(ie.workerUrl=window.URL.createObjectURL(new Blob([Ge],{type:"text/javascript"})))}}de(["exports"],function(h){var ve=Ge;function Ge(i,e,r,a){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(a-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=e,this.p2x=r,this.p2y=a}function et(i,e,r,a){const c=new ve(i,e,r,a);return function(u){return c.solve(u)}}Ge.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,e){if(e===void 0&&(e=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,a=0;a<8;a++){var c=this.sampleCurveX(r)-i;if(Math.abs(c)<e)return r;var u=this.sampleCurveDerivativeX(r);if(Math.abs(u)<1e-6)break;r-=c/u}var p=0,f=1;for(r=i,a=0;a<20&&(c=this.sampleCurveX(r),!(Math.abs(c-i)<e));a++)i>c?p=r:f=r,r=.5*(f-p)+p;return r},solve:function(i,e){return this.sampleCurveY(this.solveCurveX(i,e))}};const Ye=et(.25,.1,.25,1);function pe(i,e,r){return Math.min(r,Math.max(e,i))}function ee(i,e,r){const a=r-e,c=((i-e)%a+a)%a+e;return c===e?r:c}function Be(i,...e){for(const r of e)for(const a in r)i[a]=r[a];return i}let Ct=1;function Ft(i,e){i.forEach(r=>{e[r]&&(e[r]=e[r].bind(e))})}function mr(i,e,r){const a={};for(const c in i)a[c]=e.call(r||this,i[c],c,i);return a}function dn(i,e,r){const a={};for(const c in i)e.call(r||this,i[c],c,i)&&(a[c]=i[c]);return a}function Ci(i){return Array.isArray(i)?i.map(Ci):typeof i=="object"&&i?mr(i,Ci):i}const Or={};function dt(i){Or[i]||(typeof console<"u"&&console.warn(i),Or[i]=!0)}function Qt(i,e,r){return(r.y-i.y)*(e.x-i.x)>(e.y-i.y)*(r.x-i.x)}function us(i){let e=0;for(let r,a,c=0,u=i.length,p=u-1;c<u;p=c++)r=i[c],a=i[p],e+=(a.x-r.x)*(r.y+a.y);return e}function Oi(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}let pn=null;function fr(i){if(pn==null){const e=i.navigator?i.navigator.userAgent:null;pn=!!i.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return pn}function gr(i){return typeof ImageBitmap<"u"&&i instanceof ImageBitmap}const da="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let nr,Mt;const pa={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(i){const e=requestAnimationFrame(i);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(i,e=0){return this.getImageCanvasContext(i).getImageData(-e,-e,i.width+2*e,i.height+2*e)},getImageCanvasContext(i){const e=window.document.createElement("canvas"),r=e.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("failed to create canvas 2d context");return e.width=i.width,e.height=i.height,r.drawImage(i,0,0,i.width,i.height),r},resolveURL:i=>(nr||(nr=document.createElement("a")),nr.href=i,nr.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(Mt==null&&(Mt=matchMedia("(prefers-reduced-motion: reduce)")),Mt.matches)}};var He=Ui;function Ui(i,e){this.x=i,this.y=e}Ui.prototype={clone:function(){return new Ui(this.x,this.y)},add:function(i){return this.clone()._add(i)},sub:function(i){return this.clone()._sub(i)},multByPoint:function(i){return this.clone()._multByPoint(i)},divByPoint:function(i){return this.clone()._divByPoint(i)},mult:function(i){return this.clone()._mult(i)},div:function(i){return this.clone()._div(i)},rotate:function(i){return this.clone()._rotate(i)},rotateAround:function(i,e){return this.clone()._rotateAround(i,e)},matMult:function(i){return this.clone()._matMult(i)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(i){return this.x===i.x&&this.y===i.y},dist:function(i){return Math.sqrt(this.distSqr(i))},distSqr:function(i){var e=i.x-this.x,r=i.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith:function(i){return this.angleWithSep(i.x,i.y)},angleWithSep:function(i,e){return Math.atan2(this.x*e-this.y*i,this.x*i+this.y*e)},_matMult:function(i){var e=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=e,this},_add:function(i){return this.x+=i.x,this.y+=i.y,this},_sub:function(i){return this.x-=i.x,this.y-=i.y,this},_mult:function(i){return this.x*=i,this.y*=i,this},_div:function(i){return this.x/=i,this.y/=i,this},_multByPoint:function(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint:function(i){return this.x/=i.x,this.y/=i.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var i=this.y;return this.y=this.x,this.x=-i,this},_rotate:function(i){var e=Math.cos(i),r=Math.sin(i),a=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=a,this},_rotateAround:function(i,e){var r=Math.cos(i),a=Math.sin(i),c=e.y+a*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-a*(this.y-e.y),this.y=c,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Ui.convert=function(i){return i instanceof Ui?i:Array.isArray(i)?new Ui(i[0],i[1]):i};const Ur={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,REGISTERED_PROTOCOLS:{}};class Er extends Error{constructor(e,r,a,c){super(`AJAXError: ${r} (${e}): ${a}`),this.status=e,this.statusText=r,this.url=a,this.body=c}}const ar=Oi()?()=>self.worker&&self.worker.referrer:()=>(window.location.protocol==="blob:"?window.parent:window).location.href;function ma(i,e){const r=new AbortController,a=new Request(i.url,{method:i.method||"GET",body:i.body,credentials:i.credentials,headers:i.headers,referrer:ar(),signal:r.signal});let c=!1,u=!1;return i.type==="json"&&a.headers.set("Accept","application/json"),u||fetch(a).then(p=>p.ok?(f=>{(i.type==="arrayBuffer"?f.arrayBuffer():i.type==="json"?f.json():f.text()).then(_=>{u||(c=!0,e(null,_,f.headers.get("Cache-Control"),f.headers.get("Expires")))}).catch(_=>{u||e(new Error(_.message))})})(p):p.blob().then(f=>e(new Er(p.status,p.statusText,i.url,f)))).catch(p=>{p.code!==20&&e(new Error(p.message))}),{cancel:()=>{u=!0,c||r.abort()}}}const mn=function(i,e){if(/:\/\//.test(i.url)&&!/^https?:|^file:/.test(i.url)){if(Oi()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",i,e);if(!Oi()){const a=i.url.substring(0,i.url.indexOf("://"));return(Ur.REGISTERED_PROTOCOLS[a]||ma)(i,e)}}if(!(/^file:/.test(r=i.url)||/^file:/.test(ar())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return ma(i,e);if(Oi()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",i,e,void 0,!0)}var r;return function(a,c){const u=new XMLHttpRequest;u.open(a.method||"GET",a.url,!0),a.type==="arrayBuffer"&&(u.responseType="arraybuffer");for(const p in a.headers)u.setRequestHeader(p,a.headers[p]);return a.type==="json"&&(u.responseType="text",u.setRequestHeader("Accept","application/json")),u.withCredentials=a.credentials==="include",u.onerror=()=>{c(new Error(u.statusText))},u.onload=()=>{if((u.status>=200&&u.status<300||u.status===0)&&u.response!==null){let p=u.response;if(a.type==="json")try{p=JSON.parse(u.response)}catch(f){return c(f)}c(null,p,u.getResponseHeader("Cache-Control"),u.getResponseHeader("Expires"))}else{const p=new Blob([u.response],{type:u.getResponseHeader("Content-Type")});c(new Er(u.status,u.statusText,a.url,p))}},u.send(a.body),{cancel:()=>u.abort()}}(i,e)},Vr=function(i,e){return mn(Be(i,{type:"arrayBuffer"}),e)};function $n(i){const e=window.document.createElement("a");return e.href=i,e.protocol===window.document.location.protocol&&e.host===window.document.location.host}function Nr(i,e,r){r[i]&&r[i].indexOf(e)!==-1||(r[i]=r[i]||[],r[i].push(e))}function fn(i,e,r){if(r&&r[i]){const a=r[i].indexOf(e);a!==-1&&r[i].splice(a,1)}}class $r{constructor(e,r={}){Be(this,r),this.type=e}}class Gr extends $r{constructor(e,r={}){super("error",Be({error:e},r))}}class Ir{on(e,r){return this._listeners=this._listeners||{},Nr(e,r,this._listeners),this}off(e,r){return fn(e,r,this._listeners),fn(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},Nr(e,r,this._oneTimeListeners),this):new Promise(a=>this.once(e,a))}fire(e,r){typeof e=="string"&&(e=new $r(e,r||{}));const a=e.type;if(this.listens(a)){e.target=this;const c=this._listeners&&this._listeners[a]?this._listeners[a].slice():[];for(const f of c)f.call(this,e);const u=this._oneTimeListeners&&this._oneTimeListeners[a]?this._oneTimeListeners[a].slice():[];for(const f of u)fn(a,f,this._oneTimeListeners),f.call(this,e);const p=this._eventedParent;p&&(Be(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),p.fire(e))}else e instanceof Gr&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,r){return this._eventedParent=e,this._eventedParentData=r,this}}var le={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},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:{}},default:"mapbox"},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-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":{},within:{}}},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}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},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"}}};class Se{constructor(e,r,a,c){this.message=(e?`${e}: `:"")+a,c&&(this.identifier=c),r!=null&&r.__line__&&(this.line=r.__line__)}}function Gn(i){const e=i.value;return e?[new Se(i.key,e,"constants have been deprecated as of v8")]:[]}function di(i,...e){for(const r of e)for(const a in r)i[a]=r[a];return i}function bt(i){return i instanceof Number||i instanceof String||i instanceof Boolean?i.valueOf():i}function Wi(i){if(Array.isArray(i))return i.map(Wi);if(i instanceof Object&&!(i instanceof Number||i instanceof String||i instanceof Boolean)){const e={};for(const r in i)e[r]=Wi(i[r]);return e}return bt(i)}class pi extends Error{constructor(e,r){super(r),this.message=r,this.key=e}}class jr{constructor(e,r=[]){this.parent=e,this.bindings={};for(const[a,c]of r)this.bindings[a]=c}concat(e){return new jr(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const Hi={kind:"null"},Ee={kind:"number"},Qe={kind:"string"},Je={kind:"boolean"},Ti={kind:"color"},sr={kind:"object"},Xe={kind:"value"},Ar={kind:"collator"},ri={kind:"formatted"},qr={kind:"padding"},Mi={kind:"resolvedImage"};function mi(i,e){return{kind:"array",itemType:i,N:e}}function yt(i){if(i.kind==="array"){const e=yt(i.itemType);return typeof i.N=="number"?`array<${e}, ${i.N}>`:i.itemType.kind==="value"?"array":`array<${e}>`}return i.kind}const gn=[Hi,Ee,Qe,Je,Ti,ri,sr,mi(Xe),qr,Mi];function Zr(i,e){if(e.kind==="error")return null;if(i.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!Zr(i.itemType,e.itemType))&&(typeof i.N!="number"||i.N===e.N))return null}else{if(i.kind===e.kind)return null;if(i.kind==="value"){for(const r of gn)if(!Zr(r,e))return null}}return`Expected ${yt(i)} but found ${yt(e)} instead.`}function _n(i,e){return e.some(r=>r.kind===i.kind)}function lt(i,e){return e.some(r=>r==="null"?i===null:r==="array"?Array.isArray(i):r==="object"?i&&!Array.isArray(i)&&typeof i=="object":r===typeof i)}var Cr,yn={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function Xr(i){return(i=Math.round(i))<0?0:i>255?255:i}function jn(i){return Xr(i[i.length-1]==="%"?parseFloat(i)/100*255:parseInt(i))}function _r(i){return(e=i[i.length-1]==="%"?parseFloat(i)/100:parseFloat(i))<0?0:e>1?1:e;var e}function Mr(i,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?i+(e-i)*r*6:2*r<1?e:3*r<2?i+(e-i)*(2/3-r)*6:i}try{Cr={}.parseCSSColor=function(i){var e,r=i.replace(/ /g,"").toLowerCase();if(r in yn)return yn[r].slice();if(r[0]==="#")return r.length===4?(e=parseInt(r.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:r.length===7&&(e=parseInt(r.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var a=r.indexOf("("),c=r.indexOf(")");if(a!==-1&&c+1===r.length){var u=r.substr(0,a),p=r.substr(a+1,c-(a+1)).split(","),f=1;switch(u){case"rgba":if(p.length!==4)return null;f=_r(p.pop());case"rgb":return p.length!==3?null:[jn(p[0]),jn(p[1]),jn(p[2]),f];case"hsla":if(p.length!==4)return null;f=_r(p.pop());case"hsl":if(p.length!==3)return null;var _=(parseFloat(p[0])%360+360)%360/360,v=_r(p[1]),w=_r(p[2]),E=w<=.5?w*(v+1):w+v-w*v,P=2*w-E;return[Xr(255*Mr(P,E,_+1/3)),Xr(255*Mr(P,E,_)),Xr(255*Mr(P,E,_-1/3)),f];default:return null}}return null}}catch{}class ut{constructor(e,r,a,c=1){this.r=e,this.g=r,this.b=a,this.a=c}static parse(e){if(!e)return;if(e instanceof ut)return e;if(typeof e!="string")return;const r=Cr(e);return r?new ut(r[0]/255*r[3],r[1]/255*r[3],r[2]/255*r[3],r[3]):void 0}toString(){const[e,r,a,c]=this.toArray();return`rgba(${Math.round(e)},${Math.round(r)},${Math.round(a)},${c})`}toArray(){const{r:e,g:r,b:a,a:c}=this;return c===0?[0,0,0,0]:[255*e/c,255*r/c,255*a/c,c]}}ut.black=new ut(0,0,0,1),ut.white=new ut(1,1,1,1),ut.transparent=new ut(0,0,0,0),ut.red=new ut(1,0,0,1);class Wr{constructor(e,r,a){this.sensitivity=e?r?"variant":"case":r?"accent":"base",this.locale=a,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,r){return this.collator.compare(e,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Vi{constructor(e,r,a,c,u){this.text=e,this.image=r,this.scale=a,this.fontStack=c,this.textColor=u}}class ei{constructor(e){this.sections=e}static fromString(e){return new ei([new Vi(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||e.image&&e.image.name.length!==0)}static factory(e){return e instanceof ei?e:ei.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}}class Yt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Yt)return e;if(typeof e=="number")return new Yt([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const r of e)if(typeof r!="number")return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Yt(e)}}toString(){return JSON.stringify(this.values)}}class fi{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new fi({name:e,available:!1}):null}}function gi(i,e,r,a){return typeof i=="number"&&i>=0&&i<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof r=="number"&&r>=0&&r<=255?a===void 0||typeof a=="number"&&a>=0&&a<=1?null:`Invalid rgba value [${[i,e,r,a].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof a=="number"?[i,e,r,a]:[i,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function yr(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof ut||i instanceof Wr||i instanceof ei||i instanceof Yt||i instanceof fi)return!0;if(Array.isArray(i)){for(const e of i)if(!yr(e))return!1;return!0}if(typeof i=="object"){for(const e in i)if(!yr(i[e]))return!1;return!0}return!1}function B(i){if(i===null)return Hi;if(typeof i=="string")return Qe;if(typeof i=="boolean")return Je;if(typeof i=="number")return Ee;if(i instanceof ut)return Ti;if(i instanceof Wr)return Ar;if(i instanceof ei)return ri;if(i instanceof Yt)return qr;if(i instanceof fi)return Mi;if(Array.isArray(i)){const e=i.length;let r;for(const a of i){const c=B(a);if(r){if(r===c)continue;r=Xe;break}r=c}return mi(r||Xe,e)}return sr}function I(i){const e=typeof i;return i===null?"":e==="string"||e==="number"||e==="boolean"?String(i):i instanceof ut||i instanceof ei||i instanceof Yt||i instanceof fi?i.toString():JSON.stringify(i)}class C{constructor(e,r){this.type=e,this.value=r}static parse(e,r){if(e.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!yr(e[1]))return r.error("invalid value");const a=e[1];let c=B(a);const u=r.expectedType;return c.kind!=="array"||c.N!==0||!u||u.kind!=="array"||typeof u.N=="number"&&u.N!==0||(c=u),new C(c,a)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class R{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const U={string:Qe,number:Ee,boolean:Je,object:sr};class j{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let a,c=1;const u=e[0];if(u==="array"){let f,_;if(e.length>2){const v=e[1];if(typeof v!="string"||!(v in U)||v==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);f=U[v],c++}else f=Xe;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return r.error('The length argument to "array" must be a positive integer literal',2);_=e[2],c++}a=mi(f,_)}else{if(!U[u])throw new Error(`Types doesn't contain name = ${u}`);a=U[u]}const p=[];for(;c<e.length;c++){const f=r.parse(e[c],c,Xe);if(!f)return null;p.push(f)}return new j(a,p)}evaluate(e){for(let r=0;r<this.args.length;r++){const a=this.args[r].evaluate(e);if(!Zr(this.type,B(a)))return a;if(r===this.args.length-1)throw new R(`Expected value to be of type ${yt(this.type)}, but found ${yt(B(a))} instead.`)}throw new Error}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const X={"to-boolean":Je,"to-color":Ti,"to-number":Ee,"to-string":Qe};class Z{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const a=e[0];if(!X[a])throw new Error(`Can't parse ${a} as it is not part of the known types`);if((a==="to-boolean"||a==="to-string")&&e.length!==2)return r.error("Expected one argument.");const c=X[a],u=[];for(let p=1;p<e.length;p++){const f=r.parse(e[p],p,Xe);if(!f)return null;u.push(f)}return new Z(c,u)}evaluate(e){if(this.type.kind==="boolean")return!!this.args[0].evaluate(e);if(this.type.kind==="color"){let r,a;for(const c of this.args){if(r=c.evaluate(e),a=null,r instanceof ut)return r;if(typeof r=="string"){const u=e.parseColor(r);if(u)return u}else if(Array.isArray(r)&&(a=r.length<3||r.length>4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:gi(r[0],r[1],r[2],r[3]),!a))return new ut(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new R(a||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}if(this.type.kind==="padding"){let r;for(const a of this.args){r=a.evaluate(e);const c=Yt.parse(r);if(c)return c}throw new R(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}if(this.type.kind==="number"){let r=null;for(const a of this.args){if(r=a.evaluate(e),r===null)return 0;const c=Number(r);if(!isNaN(c))return c}throw new R(`Could not convert ${JSON.stringify(r)} to number.`)}return this.type.kind==="formatted"?ei.fromString(I(this.args[0].evaluate(e))):this.type.kind==="resolvedImage"?fi.fromString(I(this.args[0].evaluate(e))):I(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const q=["Unknown","Point","LineString","Polygon"];class Q{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"?q[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let r=this._parseColorCache[e];return r||(r=this._parseColorCache[e]=ut.parse(e)),r}}class oe{constructor(e,r,a,c){this.name=e,this.type=r,this._evaluate=a,this.args=c}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,r){const a=e[0],c=oe.definitions[a];if(!c)return r.error(`Unknown expression "${a}". If you wanted a literal array, use ["literal", [...]].`,0);const u=Array.isArray(c)?c[0]:c.type,p=Array.isArray(c)?[[c[1],c[2]]]:c.overloads,f=p.filter(([v])=>!Array.isArray(v)||v.length===e.length-1);let _=null;for(const[v,w]of f){_=new bn(r.registry,r.path,null,r.scope);const E=[];let P=!1;for(let k=1;k<e.length;k++){const L=e[k],$=Array.isArray(v)?v[k-1]:v.type,N=_.parse(L,1+E.length,$);if(!N){P=!0;break}E.push(N)}if(!P)if(Array.isArray(v)&&v.length!==E.length)_.error(`Expected ${v.length} arguments, but found ${E.length} instead.`);else{for(let k=0;k<E.length;k++){const L=Array.isArray(v)?v[k]:v.type,$=E[k];_.concat(k+1).checkSubtype(L,$.type)}if(_.errors.length===0)return new oe(a,u,w,E)}}if(f.length===1)r.errors.push(..._.errors);else{const v=(f.length?f:p).map(([E])=>{return P=E,Array.isArray(P)?`(${P.map(yt).join(", ")})`:`(${yt(P.type)}...)`;var P}).join(" | "),w=[];for(let E=1;E<e.length;E++){const P=r.parse(e[E],1+w.length);if(!P)return null;w.push(yt(P.type))}r.error(`Expected arguments of type ${v}, but found (${w.join(", ")}) instead.`)}return null}static register(e,r){oe.definitions=r;for(const a in r)e[a]=oe}}class ye{constructor(e,r,a){this.type=Ar,this.locale=a,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error("Expected one argument.");const a=e[1];if(typeof a!="object"||Array.isArray(a))return r.error("Collator options argument must be an object.");const c=r.parse(a["case-sensitive"]!==void 0&&a["case-sensitive"],1,Je);if(!c)return null;const u=r.parse(a["diacritic-sensitive"]!==void 0&&a["diacritic-sensitive"],1,Je);if(!u)return null;let p=null;return a.locale&&(p=r.parse(a.locale,1,Qe),!p)?null:new ye(c,u,p)}evaluate(e){return new Wr(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}const ce=8192;function Ne(i,e){i[0]=Math.min(i[0],e[0]),i[1]=Math.min(i[1],e[1]),i[2]=Math.max(i[2],e[0]),i[3]=Math.max(i[3],e[1])}function je(i,e){return!(i[0]<=e[0]||i[2]>=e[2]||i[1]<=e[1]||i[3]>=e[3])}function Re(i,e){const r=(180+i[0])/360,a=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,c=Math.pow(2,e.z);return[Math.round(r*c*ce),Math.round(a*c*ce)]}function qe(i,e,r){const a=i[0]-e[0],c=i[1]-e[1],u=i[0]-r[0],p=i[1]-r[1];return a*p-u*c==0&&a*u<=0&&c*p<=0}function st(i,e){let r=!1;for(let p=0,f=e.length;p<f;p++){const _=e[p];for(let v=0,w=_.length;v<w-1;v++){if(qe(i,_[v],_[v+1]))return!1;(c=_[v])[1]>(a=i)[1]!=(u=_[v+1])[1]>a[1]&&a[0]<(u[0]-c[0])*(a[1]-c[1])/(u[1]-c[1])+c[0]&&(r=!r)}}var a,c,u;return r}function St(i,e){for(let r=0;r<e.length;r++)if(st(i,e[r]))return!0;return!1}function ot(i,e,r,a){const c=a[0]-r[0],u=a[1]-r[1],p=(i[0]-r[0])*u-c*(i[1]-r[1]),f=(e[0]-r[0])*u-c*(e[1]-r[1]);return p>0&&f<0||p<0&&f>0}function ct(i,e,r){for(const v of r)for(let w=0;w<v.length-1;++w)if((f=[(p=v[w+1])[0]-(u=v[w])[0],p[1]-u[1]])[0]*(_=[(c=e)[0]-(a=i)[0],c[1]-a[1]])[1]-f[1]*_[0]!=0&&ot(a,c,u,p)&&ot(u,p,a,c))return!0;var a,c,u,p,f,_;return!1}function It(i,e){for(let r=0;r<i.length;++r)if(!st(i[r],e))return!1;for(let r=0;r<i.length-1;++r)if(ct(i[r],i[r+1],e))return!1;return!0}function $t(i,e){for(let r=0;r<e.length;r++)if(It(i,e[r]))return!0;return!1}function ti(i,e,r){const a=[];for(let c=0;c<i.length;c++){const u=[];for(let p=0;p<i[c].length;p++){const f=Re(i[c][p],r);Ne(e,f),u.push(f)}a.push(u)}return a}function Wt(i,e,r){const a=[];for(let c=0;c<i.length;c++){const u=ti(i[c],e,r);a.push(u)}return a}function xn(i,e,r,a){if(i[0]<r[0]||i[0]>r[2]){const c=.5*a;let u=i[0]-r[0]>c?-a:r[0]-i[0]>c?a:0;u===0&&(u=i[0]-r[2]>c?-a:r[2]-i[0]>c?a:0),i[0]+=u}Ne(e,i)}function Ro(i,e,r,a){const c=Math.pow(2,a.z)*ce,u=[a.x*ce,a.y*ce],p=[];for(const f of i)for(const _ of f){const v=[_.x+u[0],_.y+u[1]];xn(v,e,r,c),p.push(v)}return p}function Bo(i,e,r,a){const c=Math.pow(2,a.z)*ce,u=[a.x*ce,a.y*ce],p=[];for(const _ of i){const v=[];for(const w of _){const E=[w.x+u[0],w.y+u[1]];Ne(e,E),v.push(E)}p.push(v)}if(e[2]-e[0]<=c/2){(f=e)[0]=f[1]=1/0,f[2]=f[3]=-1/0;for(const _ of p)for(const v of _)xn(v,e,r,c)}var f;return p}class Hr{constructor(e,r){this.type=Je,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(yr(e[1])){const a=e[1];if(a.type==="FeatureCollection")for(let c=0;c<a.features.length;++c){const u=a.features[c].geometry.type;if(u==="Polygon"||u==="MultiPolygon")return new Hr(a,a.features[c].geometry)}else if(a.type==="Feature"){const c=a.geometry.type;if(c==="Polygon"||c==="MultiPolygon")return new Hr(a,a.geometry)}else if(a.type==="Polygon"||a.type==="MultiPolygon")return new Hr(a,a)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return function(r,a){const c=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],p=r.canonicalID();if(a.type==="Polygon"){const f=ti(a.coordinates,u,p),_=Ro(r.geometry(),c,u,p);if(!je(c,u))return!1;for(const v of _)if(!st(v,f))return!1}if(a.type==="MultiPolygon"){const f=Wt(a.coordinates,u,p),_=Ro(r.geometry(),c,u,p);if(!je(c,u))return!1;for(const v of _)if(!St(v,f))return!1}return!0}(e,this.geometries);if(e.geometryType()==="LineString")return function(r,a){const c=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],p=r.canonicalID();if(a.type==="Polygon"){const f=ti(a.coordinates,u,p),_=Bo(r.geometry(),c,u,p);if(!je(c,u))return!1;for(const v of _)if(!It(v,f))return!1}if(a.type==="MultiPolygon"){const f=Wt(a.coordinates,u,p),_=Bo(r.geometry(),c,u,p);if(!je(c,u))return!1;for(const v of _)if(!$t(v,f))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}function fa(i){if(i instanceof oe&&(i.name==="get"&&i.args.length===1||i.name==="feature-state"||i.name==="has"&&i.args.length===1||i.name==="properties"||i.name==="geometry-type"||i.name==="id"||/^filter-/.test(i.name))||i instanceof Hr)return!1;let e=!0;return i.eachChild(r=>{e&&!fa(r)&&(e=!1)}),e}function vn(i){if(i instanceof oe&&i.name==="feature-state")return!1;let e=!0;return i.eachChild(r=>{e&&!vn(r)&&(e=!1)}),e}function Pr(i,e){if(i instanceof oe&&e.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild(a=>{r&&!Pr(a,e)&&(r=!1)}),r}class ga{constructor(e,r){this.type=r.type,this.name=e,this.boundExpression=r}static parse(e,r){if(e.length!==2||typeof e[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");const a=e[1];return r.scope.has(a)?new ga(a,r.scope.get(a)):r.error(`Unknown variable "${a}". Make sure "${a}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class ds{constructor(e,r=[],a,c=new jr,u=[]){this.registry=e,this.path=r,this.key=r.map(p=>`[${p}]`).join(""),this.scope=c,this.errors=u,this.expectedType=a}parse(e,r,a,c,u={}){return r?this.concat(r,a,c)._parse(e,u):this._parse(e,u)}_parse(e,r){function a(c,u,p){return p==="assert"?new j(u,[c]):p==="coerce"?new Z(u,[c]):c}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const c=e[0];if(typeof c!="string")return this.error(`Expression name must be a string, but found ${typeof c} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const u=this.registry[c];if(u){let p=u.parse(e,this);if(!p)return null;if(this.expectedType){const f=this.expectedType,_=p.type;if(f.kind!=="string"&&f.kind!=="number"&&f.kind!=="boolean"&&f.kind!=="object"&&f.kind!=="array"||_.kind!=="value")if(f.kind!=="color"&&f.kind!=="formatted"&&f.kind!=="resolvedImage"||_.kind!=="value"&&_.kind!=="string")if(f.kind!=="padding"||_.kind!=="value"&&_.kind!=="number"&&_.kind!=="array"){if(this.checkSubtype(f,_))return null}else p=a(p,f,r.typeAnnotation||"coerce");else p=a(p,f,r.typeAnnotation||"coerce");else p=a(p,f,r.typeAnnotation||"assert")}if(!(p instanceof C)&&p.type.kind!=="resolvedImage"&&ps(p)){const f=new Q;try{p=new C(p.type,p.evaluate(f))}catch(_){return this.error(_.message),null}}return p}return this.error(`Unknown expression "${c}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,r,a){const c=typeof e=="number"?this.path.concat(e):this.path,u=a?this.scope.concat(a):this.scope;return new ds(this.registry,c,r||null,u,this.errors)}error(e,...r){const a=`${this.key}${r.map(c=>`[${c}]`).join("")}`;this.errors.push(new pi(a,e))}checkSubtype(e,r){const a=Zr(e,r);return a&&this.error(a),a}}var bn=ds;function ps(i){if(i instanceof ga)return ps(i.boundExpression);if(i instanceof oe&&i.name==="error"||i instanceof ye||i instanceof Hr)return!1;const e=i instanceof Z||i instanceof j;let r=!0;return i.eachChild(a=>{r=e?r&&ps(a):r&&a instanceof C}),!!r&&fa(i)&&Pr(i,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function _a(i,e){const r=i.length-1;let a,c,u=0,p=r,f=0;for(;u<=p;)if(f=Math.floor((u+p)/2),a=i[f],c=i[f+1],a<=e){if(f===r||e<c)return f;u=f+1}else{if(!(a>e))throw new R("Input is not a number.");p=f-1}return 0}class qn{constructor(e,r,a){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(const[c,u]of a)this.labels.push(c),this.outputs.push(u)}static parse(e,r){if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");const a=r.parse(e[1],1,Ee);if(!a)return null;const c=[];let u=null;r.expectedType&&r.expectedType.kind!=="value"&&(u=r.expectedType);for(let p=1;p<e.length;p+=2){const f=p===1?-1/0:e[p],_=e[p+1],v=p,w=p+1;if(typeof f!="number")return r.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',v);if(c.length&&c[c.length-1][0]>=f)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',v);const E=r.parse(_,w,u);if(!E)return null;u=u||E.type,c.push([f,E])}return new qn(u,a,c)}evaluate(e){const r=this.labels,a=this.outputs;if(r.length===1)return a[0].evaluate(e);const c=this.input.evaluate(e);if(c<=r[0])return a[0].evaluate(e);const u=r.length;return c>=r[u-1]?a[u-1].evaluate(e):a[_a(r,c)].evaluate(e)}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function zt(i,e,r){return i*(1-r)+e*r}var Kr=Object.freeze({__proto__:null,array:function(i,e,r){return i.map((a,c)=>zt(a,e[c],r))},color:function(i,e,r){return new ut(zt(i.r,e.r,r),zt(i.g,e.g,r),zt(i.b,e.b,r),zt(i.a,e.a,r))},number:zt,padding:function(i,e,r){const a=i.values,c=e.values;return new Yt([zt(a[0],c[0],r),zt(a[1],c[1],r),zt(a[2],c[2],r),zt(a[3],c[3],r)])}});const Fo=.95047,Oo=1.08883,Uo=4/29,Ni=6/29,ya=3*Ni*Ni,ms=Math.PI/180,Zn=180/Math.PI;function xt(i){return i>.008856451679035631?Math.pow(i,1/3):i/ya+Uo}function fs(i){return i>Ni?i*i*i:ya*(i-Uo)}function Xn(i){return 255*(i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055)}function gs(i){return(i/=255)<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function _s(i){const e=gs(i.r),r=gs(i.g),a=gs(i.b),c=xt((.4124564*e+.3575761*r+.1804375*a)/Fo),u=xt((.2126729*e+.7151522*r+.072175*a)/1);return{l:116*u-16,a:500*(c-u),b:200*(u-xt((.0193339*e+.119192*r+.9503041*a)/Oo)),alpha:i.a}}function ys(i){let e=(i.l+16)/116,r=isNaN(i.a)?e:e+i.a/500,a=isNaN(i.b)?e:e-i.b/200;return e=1*fs(e),r=Fo*fs(r),a=Oo*fs(a),new ut(Xn(3.2404542*r-1.5371385*e-.4985314*a),Xn(-.969266*r+1.8760108*e+.041556*a),Xn(.0556434*r-.2040259*e+1.0572252*a),i.alpha)}function Kl(i,e,r){const a=e-i;return i+r*(a>180||a<-180?a-360*Math.round(a/360):a)}const wn={forward:_s,reverse:ys,interpolate:function(i,e,r){return{l:zt(i.l,e.l,r),a:zt(i.a,e.a,r),b:zt(i.b,e.b,r),alpha:zt(i.alpha,e.alpha,r)}}},Tn={forward:function(i){const{l:e,a:r,b:a}=_s(i),c=Math.atan2(a,r)*Zn;return{h:c<0?c+360:c,c:Math.sqrt(r*r+a*a),l:e,alpha:i.a}},reverse:function(i){const e=i.h*ms,r=i.c;return ys({l:i.l,a:Math.cos(e)*r,b:Math.sin(e)*r,alpha:i.alpha})},interpolate:function(i,e,r){return{h:Kl(i.h,e.h,r),c:zt(i.c,e.c,r),l:zt(i.l,e.l,r),alpha:zt(i.alpha,e.alpha,r)}}};var Vo=Object.freeze({__proto__:null,hcl:Tn,lab:wn});class Pi{constructor(e,r,a,c,u){this.type=e,this.operator=r,this.interpolation=a,this.input=c,this.labels=[],this.outputs=[];for(const[p,f]of u)this.labels.push(p),this.outputs.push(f)}static interpolationFactor(e,r,a,c){let u=0;if(e.name==="exponential")u=xs(r,e.base,a,c);else if(e.name==="linear")u=xs(r,1,a,c);else if(e.name==="cubic-bezier"){const p=e.controlPoints;u=new ve(p[0],p[1],p[2],p[3]).solve(xs(r,1,a,c))}return u}static parse(e,r){let[a,c,u,...p]=e;if(!Array.isArray(c)||c.length===0)return r.error("Expected an interpolation type expression.",1);if(c[0]==="linear")c={name:"linear"};else if(c[0]==="exponential"){const v=c[1];if(typeof v!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);c={name:"exponential",base:v}}else{if(c[0]!=="cubic-bezier")return r.error(`Unknown interpolation type ${String(c[0])}`,1,0);{const v=c.slice(1);if(v.length!==4||v.some(w=>typeof w!="number"||w<0||w>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);c={name:"cubic-bezier",controlPoints:v}}}if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(u=r.parse(u,2,Ee),!u)return null;const f=[];let _=null;a==="interpolate-hcl"||a==="interpolate-lab"?_=Ti:r.expectedType&&r.expectedType.kind!=="value"&&(_=r.expectedType);for(let v=0;v<p.length;v+=2){const w=p[v],E=p[v+1],P=v+3,k=v+4;if(typeof w!="number")return r.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',P);if(f.length&&f[f.length-1][0]>=w)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',P);const L=r.parse(E,k,_);if(!L)return null;_=_||L.type,f.push([w,L])}return _.kind==="number"||_.kind==="color"||_.kind==="padding"||_.kind==="array"&&_.itemType.kind==="number"&&typeof _.N=="number"?new Pi(_,a,c,u,f):r.error(`Type ${yt(_)} is not interpolatable.`)}evaluate(e){const r=this.labels,a=this.outputs;if(r.length===1)return a[0].evaluate(e);const c=this.input.evaluate(e);if(c<=r[0])return a[0].evaluate(e);const u=r.length;if(c>=r[u-1])return a[u-1].evaluate(e);const p=_a(r,c),f=Pi.interpolationFactor(this.interpolation,c,r[p],r[p+1]),_=a[p].evaluate(e),v=a[p+1].evaluate(e);return this.operator==="interpolate"?Kr[this.type.kind.toLowerCase()](_,v,f):this.operator==="interpolate-hcl"?Tn.reverse(Tn.interpolate(Tn.forward(_),Tn.forward(v),f)):wn.reverse(wn.interpolate(wn.forward(_),wn.forward(v),f))}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function xs(i,e,r,a){const c=a-r,u=i-r;return c===0?0:e===1?u/c:(Math.pow(e,u)-1)/(Math.pow(e,c)-1)}class xa{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expectected at least one argument.");let a=null;const c=r.expectedType;c&&c.kind!=="value"&&(a=c);const u=[];for(const f of e.slice(1)){const _=r.parse(f,1+u.length,a,void 0,{typeAnnotation:"omit"});if(!_)return null;a=a||_.type,u.push(_)}if(!a)throw new Error("No output type");const p=c&&u.some(f=>Zr(c,f.type));return new xa(p?Xe:a,u)}evaluate(e){let r,a=null,c=0;for(const u of this.args)if(c++,a=u.evaluate(e),a&&a instanceof fi&&!a.available&&(r||(r=a.name),a=null,c===this.args.length&&(a=r)),a!==null)break;return a}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}class Wn{constructor(e,r){this.type=r.type,this.bindings=[].concat(e),this.result=r}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const r of this.bindings)e(r[1]);e(this.result)}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const a=[];for(let u=1;u<e.length-1;u+=2){const p=e[u];if(typeof p!="string")return r.error(`Expected string, but found ${typeof p} instead.`,u);if(/[^a-zA-Z0-9_]/.test(p))return r.error("Variable names must contain only alphanumeric characters or '_'.",u);const f=r.parse(e[u+1],u+1);if(!f)return null;a.push([p,f])}const c=r.parse(e[e.length-1],e.length-1,r.expectedType,a);return c?new Wn(a,c):null}outputDefined(){return this.result.outputDefined()}}class va{constructor(e,r,a){this.type=e,this.index=r,this.input=a}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,Ee),c=r.parse(e[2],2,mi(r.expectedType||Xe));return a&&c?new va(c.type.itemType,a,c):null}evaluate(e){const r=this.index.evaluate(e),a=this.input.evaluate(e);if(r<0)throw new R(`Array index out of bounds: ${r} < 0.`);if(r>=a.length)throw new R(`Array index out of bounds: ${r} > ${a.length-1}.`);if(r!==Math.floor(r))throw new R(`Array index must be an integer, but found ${r} instead.`);return a[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class vs{constructor(e,r){this.type=Je,this.needle=e,this.haystack=r}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,Xe),c=r.parse(e[2],2,Xe);return a&&c?_n(a.type,[Je,Qe,Ee,Hi,Xe])?new vs(a,c):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${yt(a.type)} instead`):null}evaluate(e){const r=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!a)return!1;if(!lt(r,["boolean","string","number","null"]))throw new R(`Expected first argument to be of type boolean, string, number or null, but found ${yt(B(r))} instead.`);if(!lt(a,["string","array"]))throw new R(`Expected second argument to be of type array or string, but found ${yt(B(a))} instead.`);return a.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class ba{constructor(e,r,a){this.type=Ee,this.needle=e,this.haystack=r,this.fromIndex=a}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,Xe),c=r.parse(e[2],2,Xe);if(!a||!c)return null;if(!_n(a.type,[Je,Qe,Ee,Hi,Xe]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${yt(a.type)} instead`);if(e.length===4){const u=r.parse(e[3],3,Ee);return u?new ba(a,c,u):null}return new ba(a,c)}evaluate(e){const r=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!lt(r,["boolean","string","number","null"]))throw new R(`Expected first argument to be of type boolean, string, number or null, but found ${yt(B(r))} instead.`);if(!lt(a,["string","array"]))throw new R(`Expected second argument to be of type array or string, but found ${yt(B(a))} instead.`);if(this.fromIndex){const c=this.fromIndex.evaluate(e);return a.indexOf(r,c)}return a.indexOf(r)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class Hn{constructor(e,r,a,c,u,p){this.inputType=e,this.type=r,this.input=a,this.cases=c,this.outputs=u,this.otherwise=p}static parse(e,r){if(e.length<5)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return r.error("Expected an even number of arguments.");let a,c;r.expectedType&&r.expectedType.kind!=="value"&&(c=r.expectedType);const u={},p=[];for(let v=2;v<e.length-1;v+=2){let w=e[v];const E=e[v+1];Array.isArray(w)||(w=[w]);const P=r.concat(v);if(w.length===0)return P.error("Expected at least one branch label.");for(const L of w){if(typeof L!="number"&&typeof L!="string")return P.error("Branch labels must be numbers or strings.");if(typeof L=="number"&&Math.abs(L)>Number.MAX_SAFE_INTEGER)return P.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof L=="number"&&Math.floor(L)!==L)return P.error("Numeric branch labels must be integer values.");if(a){if(P.checkSubtype(a,B(L)))return null}else a=B(L);if(u[String(L)]!==void 0)return P.error("Branch labels must be unique.");u[String(L)]=p.length}const k=r.parse(E,v,c);if(!k)return null;c=c||k.type,p.push(k)}const f=r.parse(e[1],1,Xe);if(!f)return null;const _=r.parse(e[e.length-1],e.length-1,c);return _?f.type.kind!=="value"&&r.concat(1).checkSubtype(a,f.type)?null:new Hn(a,c,f,u,p,_):null}evaluate(e){const r=this.input.evaluate(e);return(B(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}}class bs{constructor(e,r,a){this.type=e,this.branches=r,this.otherwise=a}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error("Expected an odd number of arguments.");let a;r.expectedType&&r.expectedType.kind!=="value"&&(a=r.expectedType);const c=[];for(let p=1;p<e.length-1;p+=2){const f=r.parse(e[p],p,Je);if(!f)return null;const _=r.parse(e[p+1],p+1,a);if(!_)return null;c.push([f,_]),a=a||_.type}const u=r.parse(e[e.length-1],e.length-1,a);if(!u)return null;if(!a)throw new Error("Can't infer output type");return new bs(a,c,u)}evaluate(e){for(const[r,a]of this.branches)if(r.evaluate(e))return a.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[r,a]of this.branches)e(r),e(a);e(this.otherwise)}outputDefined(){return this.branches.every(([e,r])=>r.outputDefined())&&this.otherwise.outputDefined()}}class wa{constructor(e,r,a,c){this.type=e,this.input=r,this.beginIndex=a,this.endIndex=c}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,Xe),c=r.parse(e[2],2,Ee);if(!a||!c)return null;if(!_n(a.type,[mi(Xe),Qe,Xe]))return r.error(`Expected first argument to be of type array or string, but found ${yt(a.type)} instead`);if(e.length===4){const u=r.parse(e[3],3,Ee);return u?new wa(a.type,a,c,u):null}return new wa(a.type,a,c)}evaluate(e){const r=this.input.evaluate(e),a=this.beginIndex.evaluate(e);if(!lt(r,["string","array"]))throw new R(`Expected first argument to be of type array or string, but found ${yt(B(r))} instead.`);if(this.endIndex){const c=this.endIndex.evaluate(e);return r.slice(a,c)}return r.slice(a)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function No(i,e){return i==="=="||i==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function ws(i,e,r,a){return a.compare(e,r)===0}function Yr(i,e,r){const a=i!=="=="&&i!=="!=";return class dd{constructor(u,p,f){this.type=Je,this.lhs=u,this.rhs=p,this.collator=f,this.hasUntypedArgument=u.type.kind==="value"||p.type.kind==="value"}static parse(u,p){if(u.length!==3&&u.length!==4)return p.error("Expected two or three arguments.");const f=u[0];let _=p.parse(u[1],1,Xe);if(!_)return null;if(!No(f,_.type))return p.concat(1).error(`"${f}" comparisons are not supported for type '${yt(_.type)}'.`);let v=p.parse(u[2],2,Xe);if(!v)return null;if(!No(f,v.type))return p.concat(2).error(`"${f}" comparisons are not supported for type '${yt(v.type)}'.`);if(_.type.kind!==v.type.kind&&_.type.kind!=="value"&&v.type.kind!=="value")return p.error(`Cannot compare types '${yt(_.type)}' and '${yt(v.type)}'.`);a&&(_.type.kind==="value"&&v.type.kind!=="value"?_=new j(v.type,[_]):_.type.kind!=="value"&&v.type.kind==="value"&&(v=new j(_.type,[v])));let w=null;if(u.length===4){if(_.type.kind!=="string"&&v.type.kind!=="string"&&_.type.kind!=="value"&&v.type.kind!=="value")return p.error("Cannot use collator to compare non-string types.");if(w=p.parse(u[3],3,Ar),!w)return null}return new dd(_,v,w)}evaluate(u){const p=this.lhs.evaluate(u),f=this.rhs.evaluate(u);if(a&&this.hasUntypedArgument){const _=B(p),v=B(f);if(_.kind!==v.kind||_.kind!=="string"&&_.kind!=="number")throw new R(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${_.kind}, ${v.kind}) instead.`)}if(this.collator&&!a&&this.hasUntypedArgument){const _=B(p),v=B(f);if(_.kind!=="string"||v.kind!=="string")return e(u,p,f)}return this.collator?r(u,p,f,this.collator.evaluate(u)):e(u,p,f)}eachChild(u){u(this.lhs),u(this.rhs),this.collator&&u(this.collator)}outputDefined(){return!0}}}const Yl=Yr("==",function(i,e,r){return e===r},ws),Jl=Yr("!=",function(i,e,r){return e!==r},function(i,e,r,a){return!ws(0,e,r,a)}),$o=Yr("<",function(i,e,r){return e<r},function(i,e,r,a){return a.compare(e,r)<0}),Go=Yr(">",function(i,e,r){return e>r},function(i,e,r,a){return a.compare(e,r)>0}),Ql=Yr("<=",function(i,e,r){return e<=r},function(i,e,r,a){return a.compare(e,r)<=0}),ec=Yr(">=",function(i,e,r){return e>=r},function(i,e,r,a){return a.compare(e,r)>=0});class Ts{constructor(e,r,a,c,u){this.type=Qe,this.number=e,this.locale=r,this.currency=a,this.minFractionDigits=c,this.maxFractionDigits=u}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");const a=r.parse(e[1],1,Ee);if(!a)return null;const c=e[2];if(typeof c!="object"||Array.isArray(c))return r.error("NumberFormat options argument must be an object.");let u=null;if(c.locale&&(u=r.parse(c.locale,1,Qe),!u))return null;let p=null;if(c.currency&&(p=r.parse(c.currency,1,Qe),!p))return null;let f=null;if(c["min-fraction-digits"]&&(f=r.parse(c["min-fraction-digits"],1,Ee),!f))return null;let _=null;return c["max-fraction-digits"]&&(_=r.parse(c["max-fraction-digits"],1,Ee),!_)?null:new Ts(a,u,p,f,_)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Ta{constructor(e){this.type=ri,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const a=e[1];if(!Array.isArray(a)&&typeof a=="object")return r.error("First argument must be an image or text section.");const c=[];let u=!1;for(let p=1;p<=e.length-1;++p){const f=e[p];if(u&&typeof f=="object"&&!Array.isArray(f)){u=!1;let _=null;if(f["font-scale"]&&(_=r.parse(f["font-scale"],1,Ee),!_))return null;let v=null;if(f["text-font"]&&(v=r.parse(f["text-font"],1,mi(Qe)),!v))return null;let w=null;if(f["text-color"]&&(w=r.parse(f["text-color"],1,Ti),!w))return null;const E=c[c.length-1];E.scale=_,E.font=v,E.textColor=w}else{const _=r.parse(e[p],1,Xe);if(!_)return null;const v=_.type.kind;if(v!=="string"&&v!=="value"&&v!=="null"&&v!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");u=!0,c.push({content:_,scale:null,font:null,textColor:null})}}return new Ta(c)}evaluate(e){return new ei(this.sections.map(r=>{const a=r.content.evaluate(e);return B(a)===Mi?new Vi("",a,null,null,null):new Vi(I(a),null,r.scale?r.scale.evaluate(e):null,r.font?r.font.evaluate(e).join(","):null,r.textColor?r.textColor.evaluate(e):null)}))}eachChild(e){for(const r of this.sections)e(r.content),r.scale&&e(r.scale),r.font&&e(r.font),r.textColor&&e(r.textColor)}outputDefined(){return!1}}class Ss{constructor(e){this.type=Mi,this.input=e}static parse(e,r){if(e.length!==2)return r.error("Expected two arguments.");const a=r.parse(e[1],1,Qe);return a?new Ss(a):r.error("No image name provided.")}evaluate(e){const r=this.input.evaluate(e),a=fi.fromString(r);return a&&e.availableImages&&(a.available=e.availableImages.indexOf(r)>-1),a}eachChild(e){e(this.input)}outputDefined(){return!1}}class Es{constructor(e){this.type=Ee,this.input=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);const a=r.parse(e[1],1);return a?a.type.kind!=="array"&&a.type.kind!=="string"&&a.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${yt(a.type)} instead.`):new Es(a):null}evaluate(e){const r=this.input.evaluate(e);if(typeof r=="string"||Array.isArray(r))return r.length;throw new R(`Expected value to be of type string or array, but found ${yt(B(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Sn={"==":Yl,"!=":Jl,">":Go,"<":$o,">=":ec,"<=":Ql,array:j,at:va,boolean:j,case:bs,coalesce:xa,collator:ye,format:Ta,image:Ss,in:vs,"index-of":ba,interpolate:Pi,"interpolate-hcl":Pi,"interpolate-lab":Pi,length:Es,let:Wn,literal:C,match:Hn,number:j,"number-format":Ts,object:j,slice:wa,step:qn,string:j,"to-boolean":Z,"to-color":Z,"to-number":Z,"to-string":Z,var:ga,within:Hr};function pt(i,[e,r,a,c]){e=e.evaluate(i),r=r.evaluate(i),a=a.evaluate(i);const u=c?c.evaluate(i):1,p=gi(e,r,a,u);if(p)throw new R(p);return new ut(e/255*u,r/255*u,a/255*u,u)}function jo(i,e){return i in e}function Is(i,e){const r=e[i];return r===void 0?null:r}function Jr(i){return{type:i}}function qo(i){return{result:"success",value:i}}function En(i){return{result:"error",value:i}}function In(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function Zo(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function As(i){return!!i.expression&&i.expression.interpolated}function vt(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":i===null?"null":typeof i}function Sa(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function tc(i){return i}function Xo(i,e){const r=e.type==="color",a=i.stops&&typeof i.stops[0][0]=="object",c=a||!(a||i.property!==void 0),u=i.type||(As(e)?"exponential":"interval");if(r||e.type==="padding"){const v=r?ut.parse:Yt.parse;(i=di({},i)).stops&&(i.stops=i.stops.map(w=>[w[0],v(w[1])])),i.default=v(i.default?i.default:e.default)}if(i.colorSpace&&i.colorSpace!=="rgb"&&!Vo[i.colorSpace])throw new Error(`Unknown color space: ${i.colorSpace}`);let p,f,_;if(u==="exponential")p=Wo;else if(u==="interval")p=rc;else if(u==="categorical"){p=ic,f=Object.create(null);for(const v of i.stops)f[v[0]]=v[1];_=typeof i.stops[0][0]}else{if(u!=="identity")throw new Error(`Unknown function type "${u}"`);p=nc}if(a){const v={},w=[];for(let k=0;k<i.stops.length;k++){const L=i.stops[k],$=L[0].zoom;v[$]===void 0&&(v[$]={zoom:$,type:i.type,property:i.property,default:i.default,stops:[]},w.push($)),v[$].stops.push([L[0].value,L[1]])}const E=[];for(const k of w)E.push([v[k].zoom,Xo(v[k],e)]);const P={name:"linear"};return{kind:"composite",interpolationType:P,interpolationFactor:Pi.interpolationFactor.bind(void 0,P),zoomStops:E.map(k=>k[0]),evaluate:({zoom:k},L)=>Wo({stops:E,base:i.base},e,k).evaluate(k,L)}}if(c){const v=u==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:v,interpolationFactor:Pi.interpolationFactor.bind(void 0,v),zoomStops:i.stops.map(w=>w[0]),evaluate:({zoom:w})=>p(i,e,w,f,_)}}return{kind:"source",evaluate(v,w){const E=w&&w.properties?w.properties[i.property]:void 0;return E===void 0?Kn(i.default,e.default):p(i,e,E,f,_)}}}function Kn(i,e,r){return i!==void 0?i:e!==void 0?e:r!==void 0?r:void 0}function ic(i,e,r,a,c){return Kn(typeof r===c?a[r]:void 0,i.default,e.default)}function rc(i,e,r){if(vt(r)!=="number")return Kn(i.default,e.default);const a=i.stops.length;if(a===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[a-1][0])return i.stops[a-1][1];const c=_a(i.stops.map(u=>u[0]),r);return i.stops[c][1]}function Wo(i,e,r){const a=i.base!==void 0?i.base:1;if(vt(r)!=="number")return Kn(i.default,e.default);const c=i.stops.length;if(c===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[c-1][0])return i.stops[c-1][1];const u=_a(i.stops.map(w=>w[0]),r),p=function(w,E,P,k){const L=k-P,$=w-P;return L===0?0:E===1?$/L:(Math.pow(E,$)-1)/(Math.pow(E,L)-1)}(r,a,i.stops[u][0],i.stops[u+1][0]),f=i.stops[u][1],_=i.stops[u+1][1];let v=Kr[e.type]||tc;if(i.colorSpace&&i.colorSpace!=="rgb"){const w=Vo[i.colorSpace];v=(E,P)=>w.reverse(w.interpolate(w.forward(E),w.forward(P),p))}return typeof f.evaluate=="function"?{evaluate(...w){const E=f.evaluate.apply(void 0,w),P=_.evaluate.apply(void 0,w);if(E!==void 0&&P!==void 0)return v(E,P,p)}}:v(f,_,p)}function nc(i,e,r){switch(e.type){case"color":r=ut.parse(r);break;case"formatted":r=ei.fromString(r.toString());break;case"resolvedImage":r=fi.fromString(r.toString());break;case"padding":r=Yt.parse(r);break;default:vt(r)===e.type||e.type==="enum"&&e.values[r]||(r=void 0)}return Kn(r,i.default,e.default)}oe.register(Sn,{error:[{kind:"error"},[Qe],(i,[e])=>{throw new R(e.evaluate(i))}],typeof:[Qe,[Xe],(i,[e])=>yt(B(e.evaluate(i)))],"to-rgba":[mi(Ee,4),[Ti],(i,[e])=>e.evaluate(i).toArray()],rgb:[Ti,[Ee,Ee,Ee],pt],rgba:[Ti,[Ee,Ee,Ee,Ee],pt],has:{type:Je,overloads:[[[Qe],(i,[e])=>jo(e.evaluate(i),i.properties())],[[Qe,sr],(i,[e,r])=>jo(e.evaluate(i),r.evaluate(i))]]},get:{type:Xe,overloads:[[[Qe],(i,[e])=>Is(e.evaluate(i),i.properties())],[[Qe,sr],(i,[e,r])=>Is(e.evaluate(i),r.evaluate(i))]]},"feature-state":[Xe,[Qe],(i,[e])=>Is(e.evaluate(i),i.featureState||{})],properties:[sr,[],i=>i.properties()],"geometry-type":[Qe,[],i=>i.geometryType()],id:[Xe,[],i=>i.id()],zoom:[Ee,[],i=>i.globals.zoom],"heatmap-density":[Ee,[],i=>i.globals.heatmapDensity||0],"line-progress":[Ee,[],i=>i.globals.lineProgress||0],accumulated:[Xe,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[Ee,Jr(Ee),(i,e)=>{let r=0;for(const a of e)r+=a.evaluate(i);return r}],"*":[Ee,Jr(Ee),(i,e)=>{let r=1;for(const a of e)r*=a.evaluate(i);return r}],"-":{type:Ee,overloads:[[[Ee,Ee],(i,[e,r])=>e.evaluate(i)-r.evaluate(i)],[[Ee],(i,[e])=>-e.evaluate(i)]]},"/":[Ee,[Ee,Ee],(i,[e,r])=>e.evaluate(i)/r.evaluate(i)],"%":[Ee,[Ee,Ee],(i,[e,r])=>e.evaluate(i)%r.evaluate(i)],ln2:[Ee,[],()=>Math.LN2],pi:[Ee,[],()=>Math.PI],e:[Ee,[],()=>Math.E],"^":[Ee,[Ee,Ee],(i,[e,r])=>Math.pow(e.evaluate(i),r.evaluate(i))],sqrt:[Ee,[Ee],(i,[e])=>Math.sqrt(e.evaluate(i))],log10:[Ee,[Ee],(i,[e])=>Math.log(e.evaluate(i))/Math.LN10],ln:[Ee,[Ee],(i,[e])=>Math.log(e.evaluate(i))],log2:[Ee,[Ee],(i,[e])=>Math.log(e.evaluate(i))/Math.LN2],sin:[Ee,[Ee],(i,[e])=>Math.sin(e.evaluate(i))],cos:[Ee,[Ee],(i,[e])=>Math.cos(e.evaluate(i))],tan:[Ee,[Ee],(i,[e])=>Math.tan(e.evaluate(i))],asin:[Ee,[Ee],(i,[e])=>Math.asin(e.evaluate(i))],acos:[Ee,[Ee],(i,[e])=>Math.acos(e.evaluate(i))],atan:[Ee,[Ee],(i,[e])=>Math.atan(e.evaluate(i))],min:[Ee,Jr(Ee),(i,e)=>Math.min(...e.map(r=>r.evaluate(i)))],max:[Ee,Jr(Ee),(i,e)=>Math.max(...e.map(r=>r.evaluate(i)))],abs:[Ee,[Ee],(i,[e])=>Math.abs(e.evaluate(i))],round:[Ee,[Ee],(i,[e])=>{const r=e.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[Ee,[Ee],(i,[e])=>Math.floor(e.evaluate(i))],ceil:[Ee,[Ee],(i,[e])=>Math.ceil(e.evaluate(i))],"filter-==":[Je,[Qe,Xe],(i,[e,r])=>i.properties()[e.value]===r.value],"filter-id-==":[Je,[Xe],(i,[e])=>i.id()===e.value],"filter-type-==":[Je,[Qe],(i,[e])=>i.geometryType()===e.value],"filter-<":[Je,[Qe,Xe],(i,[e,r])=>{const a=i.properties()[e.value],c=r.value;return typeof a==typeof c&&a<c}],"filter-id-<":[Je,[Xe],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r<a}],"filter->":[Je,[Qe,Xe],(i,[e,r])=>{const a=i.properties()[e.value],c=r.value;return typeof a==typeof c&&a>c}],"filter-id->":[Je,[Xe],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r>a}],"filter-<=":[Je,[Qe,Xe],(i,[e,r])=>{const a=i.properties()[e.value],c=r.value;return typeof a==typeof c&&a<=c}],"filter-id-<=":[Je,[Xe],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r<=a}],"filter->=":[Je,[Qe,Xe],(i,[e,r])=>{const a=i.properties()[e.value],c=r.value;return typeof a==typeof c&&a>=c}],"filter-id->=":[Je,[Xe],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r>=a}],"filter-has":[Je,[Xe],(i,[e])=>e.value in i.properties()],"filter-has-id":[Je,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[Je,[mi(Qe)],(i,[e])=>e.value.indexOf(i.geometryType())>=0],"filter-id-in":[Je,[mi(Xe)],(i,[e])=>e.value.indexOf(i.id())>=0],"filter-in-small":[Je,[Qe,mi(Xe)],(i,[e,r])=>r.value.indexOf(i.properties()[e.value])>=0],"filter-in-large":[Je,[Qe,mi(Xe)],(i,[e,r])=>function(a,c,u,p){for(;u<=p;){const f=u+p>>1;if(c[f]===a)return!0;c[f]>a?p=f-1:u=f+1}return!1}(i.properties()[e.value],r.value,0,r.value.length-1)],all:{type:Je,overloads:[[[Je,Je],(i,[e,r])=>e.evaluate(i)&&r.evaluate(i)],[Jr(Je),(i,e)=>{for(const r of e)if(!r.evaluate(i))return!1;return!0}]]},any:{type:Je,overloads:[[[Je,Je],(i,[e,r])=>e.evaluate(i)||r.evaluate(i)],[Jr(Je),(i,e)=>{for(const r of e)if(r.evaluate(i))return!0;return!1}]]},"!":[Je,[Je],(i,[e])=>!e.evaluate(i)],"is-supported-script":[Je,[Qe],(i,[e])=>{const r=i.globals&&i.globals.isSupportedScript;return!r||r(e.evaluate(i))}],upcase:[Qe,[Qe],(i,[e])=>e.evaluate(i).toUpperCase()],downcase:[Qe,[Qe],(i,[e])=>e.evaluate(i).toLowerCase()],concat:[Qe,Jr(Xe),(i,e)=>e.map(r=>I(r.evaluate(i))).join("")],"resolved-locale":[Qe,[Ar],(i,[e])=>e.evaluate(i).resolvedLocale()]});class Cs{constructor(e,r){this.expression=e,this._warningHistory={},this._evaluator=new Q,this._defaultValue=r?function(a){return a.type==="color"&&Sa(a.default)?new ut(0,0,0,0):a.type==="color"?ut.parse(a.default)||null:a.type==="padding"?Yt.parse(a.default)||null:a.default===void 0?null:a.default}(r):null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(e,r,a,c,u,p){return this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=a,this._evaluator.canonical=c,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=p,this.expression.evaluate(this._evaluator)}evaluate(e,r,a,c,u,p){this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=a||null,this._evaluator.canonical=c,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=p||null;try{const f=this.expression.evaluate(this._evaluator);if(f==null||typeof f=="number"&&f!=f)return this._defaultValue;if(this._enumValues&&!(f in this._enumValues))throw new R(`Expected value to be one of ${Object.keys(this._enumValues).map(_=>JSON.stringify(_)).join(", ")}, but found ${JSON.stringify(f)} instead.`);return f}catch(f){return this._warningHistory[f.message]||(this._warningHistory[f.message]=!0,typeof console<"u"&&console.warn(f.message)),this._defaultValue}}}function Ea(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in Sn}function Ia(i,e){const r=new bn(Sn,[],e?function(c){const u={color:Ti,string:Qe,number:Ee,enum:Qe,boolean:Je,formatted:ri,padding:qr,resolvedImage:Mi};return c.type==="array"?mi(u[c.value]||Xe,c.length):u[c.type]}(e):void 0),a=r.parse(i,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return a?qo(new Cs(a,e)):En(r.errors)}class Ms{constructor(e,r){this.kind=e,this._styleExpression=r,this.isStateDependent=e!=="constant"&&!vn(r.expression)}evaluateWithoutErrorHandling(e,r,a,c,u,p){return this._styleExpression.evaluateWithoutErrorHandling(e,r,a,c,u,p)}evaluate(e,r,a,c,u,p){return this._styleExpression.evaluate(e,r,a,c,u,p)}}class Ps{constructor(e,r,a,c){this.kind=e,this.zoomStops=a,this._styleExpression=r,this.isStateDependent=e!=="camera"&&!vn(r.expression),this.interpolationType=c}evaluateWithoutErrorHandling(e,r,a,c,u,p){return this._styleExpression.evaluateWithoutErrorHandling(e,r,a,c,u,p)}evaluate(e,r,a,c,u,p){return this._styleExpression.evaluate(e,r,a,c,u,p)}interpolationFactor(e,r,a){return this.interpolationType?Pi.interpolationFactor(this.interpolationType,e,r,a):0}}function Ho(i,e){const r=Ia(i,e);if(r.result==="error")return r;const a=r.value.expression,c=fa(a);if(!c&&!In(e))return En([new pi("","data expressions not supported")]);const u=Pr(a,["zoom"]);if(!u&&!Zo(e))return En([new pi("","zoom expressions not supported")]);const p=Ca(a);return p||u?p instanceof pi?En([p]):p instanceof Pi&&!As(e)?En([new pi("",'"interpolate" expressions cannot be used with this property')]):qo(p?new Ps(c?"camera":"composite",r.value,p.labels,p instanceof Pi?p.interpolation:void 0):new Ms(c?"constant":"source",r.value)):En([new pi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Aa{constructor(e,r){this._parameters=e,this._specification=r,di(this,Xo(this._parameters,this._specification))}static deserialize(e){return new Aa(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Ca(i){let e=null;if(i instanceof Wn)e=Ca(i.result);else if(i instanceof xa){for(const r of i.args)if(e=Ca(r),e)break}else(i instanceof qn||i instanceof Pi)&&i.input instanceof oe&&i.input.name==="zoom"&&(e=i);return e instanceof pi||i.eachChild(r=>{const a=Ca(r);a instanceof pi?e=a:!e&&a?e=new pi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&a&&e!==a&&(e=new pi("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}function $i(i){const e=i.key,r=i.value,a=i.valueSpec||{},c=i.objectElementValidators||{},u=i.style,p=i.styleSpec,f=i.validateSpec;let _=[];const v=vt(r);if(v!=="object")return[new Se(e,r,`object expected, ${v} found`)];for(const w in r){const E=w.split(".")[0],P=a[E]||a["*"];let k;if(c[E])k=c[E];else if(a[E])k=f;else if(c["*"])k=c["*"];else{if(!a["*"]){_.push(new Se(e,r[w],`unknown property "${w}"`));continue}k=f}_=_.concat(k({key:(e&&`${e}.`)+w,value:r[w],valueSpec:P,style:u,styleSpec:p,object:r,objectKey:w,validateSpec:f},r))}for(const w in a)c[w]||a[w].required&&a[w].default===void 0&&r[w]===void 0&&_.push(new Se(e,r,`missing required property "${w}"`));return _}function Ko(i){const e=i.value,r=i.valueSpec,a=i.style,c=i.styleSpec,u=i.key,p=i.arrayElementValidator||i.validateSpec;if(vt(e)!=="array")return[new Se(u,e,`array expected, ${vt(e)} found`)];if(r.length&&e.length!==r.length)return[new Se(u,e,`array length ${r.length} expected, length ${e.length} found`)];if(r["min-length"]&&e.length<r["min-length"])return[new Se(u,e,`array length at least ${r["min-length"]} expected, length ${e.length} found`)];let f={type:r.value,values:r.values};c.$version<7&&(f.function=r.function),vt(r.value)==="object"&&(f=r.value);let _=[];for(let v=0;v<e.length;v++)_=_.concat(p({array:e,arrayIndex:v,value:e[v],valueSpec:f,validateSpec:i.validateSpec,style:a,styleSpec:c,key:`${u}[${v}]`}));return _}function ks(i){const e=i.key,r=i.value,a=i.valueSpec;let c=vt(r);return c==="number"&&r!=r&&(c="NaN"),c!=="number"?[new Se(e,r,`number expected, ${c} found`)]:"minimum"in a&&r<a.minimum?[new Se(e,r,`${r} is less than the minimum value ${a.minimum}`)]:"maximum"in a&&r>a.maximum?[new Se(e,r,`${r} is greater than the maximum value ${a.maximum}`)]:[]}function Yo(i){const e=i.valueSpec,r=bt(i.value.type);let a,c,u,p={};const f=r!=="categorical"&&i.value.property===void 0,_=!f,v=vt(i.value.stops)==="array"&&vt(i.value.stops[0])==="array"&&vt(i.value.stops[0][0])==="object",w=$i({key:i.key,value:i.value,valueSpec:i.styleSpec.function,validateSpec:i.validateSpec,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(k){if(r==="identity")return[new Se(k.key,k.value,'identity function may not have a "stops" property')];let L=[];const $=k.value;return L=L.concat(Ko({key:k.key,value:$,valueSpec:k.valueSpec,validateSpec:k.validateSpec,style:k.style,styleSpec:k.styleSpec,arrayElementValidator:E})),vt($)==="array"&&$.length===0&&L.push(new Se(k.key,$,"array must have at least one stop")),L},default:function(k){return k.validateSpec({key:k.key,value:k.value,valueSpec:e,validateSpec:k.validateSpec,style:k.style,styleSpec:k.styleSpec})}}});return r==="identity"&&f&&w.push(new Se(i.key,i.value,'missing required property "property"')),r==="identity"||i.value.stops||w.push(new Se(i.key,i.value,'missing required property "stops"')),r==="exponential"&&i.valueSpec.expression&&!As(i.valueSpec)&&w.push(new Se(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(_&&!In(i.valueSpec)?w.push(new Se(i.key,i.value,"property functions not supported")):f&&!Zo(i.valueSpec)&&w.push(new Se(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!v||i.value.property!==void 0||w.push(new Se(i.key,i.value,'"property" property is required')),w;function E(k){let L=[];const $=k.value,N=k.key;if(vt($)!=="array")return[new Se(N,$,`array expected, ${vt($)} found`)];if($.length!==2)return[new Se(N,$,`array length 2 expected, length ${$.length} found`)];if(v){if(vt($[0])!=="object")return[new Se(N,$,`object expected, ${vt($[0])} found`)];if($[0].zoom===void 0)return[new Se(N,$,"object stop key must have zoom")];if($[0].value===void 0)return[new Se(N,$,"object stop key must have value")];if(u&&u>bt($[0].zoom))return[new Se(N,$[0].zoom,"stop zoom values must appear in ascending order")];bt($[0].zoom)!==u&&(u=bt($[0].zoom),c=void 0,p={}),L=L.concat($i({key:`${N}[0]`,value:$[0],valueSpec:{zoom:{}},validateSpec:k.validateSpec,style:k.style,styleSpec:k.styleSpec,objectElementValidators:{zoom:ks,value:P}}))}else L=L.concat(P({key:`${N}[0]`,value:$[0],valueSpec:{},validateSpec:k.validateSpec,style:k.style,styleSpec:k.styleSpec},$));return Ea(Wi($[1]))?L.concat([new Se(`${N}[1]`,$[1],"expressions are not allowed in function stops.")]):L.concat(k.validateSpec({key:`${N}[1]`,value:$[1],valueSpec:e,validateSpec:k.validateSpec,style:k.style,styleSpec:k.styleSpec}))}function P(k,L){const $=vt(k.value),N=bt(k.value),J=k.value!==null?k.value:L;if(a){if($!==a)return[new Se(k.key,J,`${$} stop domain type must match previous stop domain type ${a}`)]}else a=$;if($!=="number"&&$!=="string"&&$!=="boolean")return[new Se(k.key,J,"stop domain value must be a number, string, or boolean")];if($!=="number"&&r!=="categorical"){let ne=`number expected, ${$} found`;return In(e)&&r===void 0&&(ne+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Se(k.key,J,ne)]}return r!=="categorical"||$!=="number"||isFinite(N)&&Math.floor(N)===N?r!=="categorical"&&$==="number"&&c!==void 0&&N<c?[new Se(k.key,J,"stop domain values must appear in ascending order")]:(c=N,r==="categorical"&&N in p?[new Se(k.key,J,"stop domain values must be unique")]:(p[N]=!0,[])):[new Se(k.key,J,`integer expected, found ${N}`)]}}function An(i){const e=(i.expressionContext==="property"?Ho:Ia)(Wi(i.value),i.valueSpec);if(e.result==="error")return e.value.map(a=>new Se(`${i.key}${a.key}`,i.value,a.message));const r=e.value.expression||e.value._styleExpression.expression;if(i.expressionContext==="property"&&i.propertyKey==="text-font"&&!r.outputDefined())return[new Se(i.key,i.value,`Invalid data expression for "${i.propertyKey}". Output values must be contained as literals within the expression.`)];if(i.expressionContext==="property"&&i.propertyType==="layout"&&!vn(r))return[new Se(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter"&&!vn(r))return[new Se(i.key,i.value,'"feature-state" data expressions are not supported with filters.')];if(i.expressionContext&&i.expressionContext.indexOf("cluster")===0){if(!Pr(r,["zoom","feature-state"]))return[new Se(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(i.expressionContext==="cluster-initial"&&!fa(r))return[new Se(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Ma(i){const e=i.key,r=i.value,a=i.valueSpec,c=[];return Array.isArray(a.values)?a.values.indexOf(bt(r))===-1&&c.push(new Se(e,r,`expected one of [${a.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(a.values).indexOf(bt(r))===-1&&c.push(new Se(e,r,`expected one of [${Object.keys(a.values).join(", ")}], ${JSON.stringify(r)} found`)),c}function Pa(i){if(i===!0||i===!1)return!0;if(!Array.isArray(i)||i.length===0)return!1;switch(i[0]){case"has":return i.length>=2&&i[1]!=="$id"&&i[1]!=="$type";case"in":return i.length>=3&&(typeof i[1]!="string"||Array.isArray(i[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return i.length!==3||Array.isArray(i[1])||Array.isArray(i[2]);case"any":case"all":for(const e of i.slice(1))if(!Pa(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}const ac={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function zs(i){if(i==null)return{filter:()=>!0,needGeometry:!1};Pa(i)||(i=ka(i));const e=Ia(i,ac);if(e.result==="error")throw new Error(e.value.map(r=>`${r.key}: ${r.message}`).join(", "));return{filter:(r,a,c)=>e.value.evaluate(r,a,{},c),needGeometry:Ot(i)}}function sc(i,e){return i<e?-1:i>e?1:0}function Ot(i){if(!Array.isArray(i))return!1;if(i[0]==="within")return!0;for(let e=1;e<i.length;e++)if(Ot(i[e]))return!0;return!1}function ka(i){if(!i)return!0;const e=i[0];return i.length<=1?e!=="any":e==="=="?at(i[1],i[2],"=="):e==="!="?Et(at(i[1],i[2],"==")):e==="<"||e===">"||e==="<="||e===">="?at(i[1],i[2],e):e==="any"?(r=i.slice(1),["any"].concat(r.map(ka))):e==="all"?["all"].concat(i.slice(1).map(ka)):e==="none"?["all"].concat(i.slice(1).map(ka).map(Et)):e==="in"?za(i[1],i.slice(2)):e==="!in"?Et(za(i[1],i.slice(2))):e==="has"?Lt(i[1]):e==="!has"?Et(Lt(i[1])):e!=="within"||i;var r}function at(i,e,r){switch(i){case"$type":return[`filter-type-${r}`,e];case"$id":return[`filter-id-${r}`,e];default:return[`filter-${r}`,i,e]}}function za(i,e){if(e.length===0)return!1;switch(i){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(r=>typeof r!=typeof e[0])?["filter-in-large",i,["literal",e.sort(sc)]]:["filter-in-small",i,["literal",e]]}}function Lt(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function Et(i){return["!",i]}function Cn(i){return Pa(Wi(i.value))?An(di({},i,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Ls(i)}function Ls(i){const e=i.value,r=i.key;if(vt(e)!=="array")return[new Se(r,e,`array expected, ${vt(e)} found`)];const a=i.styleSpec;let c,u=[];if(e.length<1)return[new Se(r,e,"filter array must have at least 1 element")];switch(u=u.concat(Ma({key:`${r}[0]`,value:e[0],valueSpec:a.filter_operator,style:i.style,styleSpec:i.styleSpec})),bt(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&bt(e[1])==="$type"&&u.push(new Se(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&u.push(new Se(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(c=vt(e[1]),c!=="string"&&u.push(new Se(`${r}[1]`,e[1],`string expected, ${c} found`)));for(let p=2;p<e.length;p++)c=vt(e[p]),bt(e[1])==="$type"?u=u.concat(Ma({key:`${r}[${p}]`,value:e[p],valueSpec:a.geometry_type,style:i.style,styleSpec:i.styleSpec})):c!=="string"&&c!=="number"&&c!=="boolean"&&u.push(new Se(`${r}[${p}]`,e[p],`string, number, or boolean expected, ${c} found`));break;case"any":case"all":case"none":for(let p=1;p<e.length;p++)u=u.concat(Ls({key:`${r}[${p}]`,value:e[p],style:i.style,styleSpec:i.styleSpec}));break;case"has":case"!has":c=vt(e[1]),e.length!==2?u.push(new Se(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):c!=="string"&&u.push(new Se(`${r}[1]`,e[1],`string expected, ${c} found`));break;case"within":c=vt(e[1]),e.length!==2?u.push(new Se(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):c!=="object"&&u.push(new Se(`${r}[1]`,e[1],`object expected, ${c} found`))}return u}function Jo(i,e){const r=i.key,a=i.validateSpec,c=i.style,u=i.styleSpec,p=i.value,f=i.objectKey,_=u[`${e}_${i.layerType}`];if(!_)return[];const v=f.match(/^(.*)-transition$/);if(e==="paint"&&v&&_[v[1]]&&_[v[1]].transition)return a({key:r,value:p,valueSpec:u.transition,style:c,styleSpec:u});const w=i.valueSpec||_[f];if(!w)return[new Se(r,p,`unknown property "${f}"`)];let E;if(vt(p)==="string"&&In(w)&&!w.tokens&&(E=/^{([^}]+)}$/.exec(p)))return[new Se(r,p,`"${f}" does not support interpolation syntax
2
+ Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(E[1])} }\`.`)];const P=[];return i.layerType==="symbol"&&(f==="text-field"&&c&&!c.glyphs&&P.push(new Se(r,p,'use of "text-field" requires a style "glyphs" property')),f==="text-font"&&Sa(Wi(p))&&bt(p.type)==="identity"&&P.push(new Se(r,p,'"text-font" does not support identity functions'))),P.concat(a({key:i.key,value:p,valueSpec:w,style:c,styleSpec:u,expressionContext:"property",propertyType:e,propertyKey:f}))}function Qo(i){return Jo(i,"paint")}function el(i){return Jo(i,"layout")}function tl(i){let e=[];const r=i.value,a=i.key,c=i.style,u=i.styleSpec;r.type||r.ref||e.push(new Se(a,r,'either "type" or "ref" is required'));let p=bt(r.type);const f=bt(r.ref);if(r.id){const _=bt(r.id);for(let v=0;v<i.arrayIndex;v++){const w=c.layers[v];bt(w.id)===_&&e.push(new Se(a,r.id,`duplicate layer id "${r.id}", previously used at line ${w.id.__line__}`))}}if("ref"in r){let _;["type","source","source-layer","filter","layout"].forEach(v=>{v in r&&e.push(new Se(a,r[v],`"${v}" is prohibited for ref layers`))}),c.layers.forEach(v=>{bt(v.id)===f&&(_=v)}),_?_.ref?e.push(new Se(a,r.ref,"ref cannot reference another ref layer")):p=bt(_.type):e.push(new Se(a,r.ref,`ref layer "${f}" not found`))}else if(p!=="background")if(r.source){const _=c.sources&&c.sources[r.source],v=_&&bt(_.type);_?v==="vector"&&p==="raster"?e.push(new Se(a,r.source,`layer "${r.id}" requires a raster source`)):v==="raster"&&p!=="raster"?e.push(new Se(a,r.source,`layer "${r.id}" requires a vector source`)):v!=="vector"||r["source-layer"]?v==="raster-dem"&&p!=="hillshade"?e.push(new Se(a,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):p!=="line"||!r.paint||!r.paint["line-gradient"]||v==="geojson"&&_.lineMetrics||e.push(new Se(a,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Se(a,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new Se(a,r.source,`source "${r.source}" not found`))}else e.push(new Se(a,r,'missing required property "source"'));return e=e.concat($i({key:a,value:r,valueSpec:u.layer,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,objectElementValidators:{"*":()=>[],type:()=>i.validateSpec({key:`${a}.type`,value:r.type,valueSpec:u.layer.type,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,object:r,objectKey:"type"}),filter:Cn,layout:_=>$i({layer:r,key:_.key,value:_.value,style:_.style,styleSpec:_.styleSpec,validateSpec:_.validateSpec,objectElementValidators:{"*":v=>el(di({layerType:p},v))}}),paint:_=>$i({layer:r,key:_.key,value:_.value,style:_.style,styleSpec:_.styleSpec,validateSpec:_.validateSpec,objectElementValidators:{"*":v=>Qo(di({layerType:p},v))}})}})),e}function kr(i){const e=i.value,r=i.key,a=vt(e);return a!=="string"?[new Se(r,e,`string expected, ${a} found`)]:[]}const Ds={promoteId:function({key:i,value:e}){if(vt(e)==="string")return kr({key:i,value:e});{const r=[];for(const a in e)r.push(...kr({key:`${i}.${a}`,value:e[a]}));return r}}};function Rs(i){const e=i.value,r=i.key,a=i.styleSpec,c=i.style,u=i.validateSpec;if(!e.type)return[new Se(r,e,'"type" is required')];const p=bt(e.type);let f;switch(p){case"vector":case"raster":case"raster-dem":return f=$i({key:r,value:e,valueSpec:a[`source_${p.replace("-","_")}`],style:i.style,styleSpec:a,objectElementValidators:Ds,validateSpec:u}),f;case"geojson":if(f=$i({key:r,value:e,valueSpec:a.source_geojson,style:c,styleSpec:a,validateSpec:u,objectElementValidators:Ds}),e.cluster)for(const _ in e.clusterProperties){const[v,w]=e.clusterProperties[_],E=typeof v=="string"?[v,["accumulated"],["get",_]]:v;f.push(...An({key:`${r}.${_}.map`,value:w,validateSpec:u,expressionContext:"cluster-map"})),f.push(...An({key:`${r}.${_}.reduce`,value:E,validateSpec:u,expressionContext:"cluster-reduce"}))}return f;case"video":return $i({key:r,value:e,valueSpec:a.source_video,style:c,validateSpec:u,styleSpec:a});case"image":return $i({key:r,value:e,valueSpec:a.source_image,style:c,validateSpec:u,styleSpec:a});case"canvas":return[new Se(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Ma({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:c,validateSpec:u,styleSpec:a})}}function Bs(i){const e=i.value,r=i.styleSpec,a=r.light,c=i.style;let u=[];const p=vt(e);if(e===void 0)return u;if(p!=="object")return u=u.concat([new Se("light",e,`object expected, ${p} found`)]),u;for(const f in e){const _=f.match(/^(.*)-transition$/);u=u.concat(_&&a[_[1]]&&a[_[1]].transition?i.validateSpec({key:f,value:e[f],valueSpec:r.transition,validateSpec:i.validateSpec,style:c,styleSpec:r}):a[f]?i.validateSpec({key:f,value:e[f],valueSpec:a[f],validateSpec:i.validateSpec,style:c,styleSpec:r}):[new Se(f,e[f],`unknown property "${f}"`)])}return u}function La(i){const e=i.value,r=i.styleSpec,a=r.terrain,c=i.style;let u=[];const p=vt(e);if(e===void 0)return u;if(p!=="object")return u=u.concat([new Se("terrain",e,`object expected, ${p} found`)]),u;for(const f in e)u=u.concat(a[f]?i.validateSpec({key:f,value:e[f],valueSpec:a[f],validateSpec:i.validateSpec,style:c,styleSpec:r}):[new Se(f,e[f],`unknown property "${f}"`)]);return u}function il(i){let e=[];const r=i.value,a=i.key;if(Array.isArray(r)){const c=[],u=[];for(const p in r)r[p].id&&c.includes(r[p].id)&&e.push(new Se(a,r,`all the sprites' ids must be unique, but ${r[p].id} is duplicated`)),c.push(r[p].id),r[p].url&&u.includes(r[p].url)&&e.push(new Se(a,r,`all the sprites' URLs must be unique, but ${r[p].url} is duplicated`)),u.push(r[p].url),e=e.concat($i({key:`${a}[${p}]`,value:r[p],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:i.validateSpec}));return e}return kr({key:a,value:r})}const rl={"*":()=>[],array:Ko,boolean:function(i){const e=i.value,r=i.key,a=vt(e);return a!=="boolean"?[new Se(r,e,`boolean expected, ${a} found`)]:[]},number:ks,color:function(i){const e=i.key,r=i.value,a=vt(r);return a!=="string"?[new Se(e,r,`color expected, ${a} found`)]:Cr(r)===null?[new Se(e,r,`color expected, "${r}" found`)]:[]},constants:Gn,enum:Ma,filter:Cn,function:Yo,layer:tl,object:$i,source:Rs,light:Bs,terrain:La,string:kr,formatted:function(i){return kr(i).length===0?[]:An(i)},resolvedImage:function(i){return kr(i).length===0?[]:An(i)},padding:function(i){const e=i.key,r=i.value;if(vt(r)==="array"){if(r.length<1||r.length>4)return[new Se(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const a={type:"number"};let c=[];for(let u=0;u<r.length;u++)c=c.concat(i.validateSpec({key:`${e}[${u}]`,value:r[u],validateSpec:i.validateSpec,valueSpec:a}));return c}return ks({key:e,value:r,valueSpec:{}})},sprite:il};function Yn(i){const e=i.value,r=i.valueSpec,a=i.styleSpec;return i.validateSpec=Yn,r.expression&&Sa(bt(e))?Yo(i):r.expression&&Ea(Wi(e))?An(i):r.type&&rl[r.type]?rl[r.type](i):$i(di({},i,{valueSpec:r.type?a[r.type]:r}))}function nl(i){const e=i.value,r=i.key,a=kr(i);return a.length||(e.indexOf("{fontstack}")===-1&&a.push(new Se(r,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&a.push(new Se(r,e,'"glyphs" url must include a "{range}" token'))),a}function or(i,e=le){let r=[];return r=r.concat(Yn({key:"",value:i,valueSpec:e.$root,styleSpec:e,style:i,validateSpec:Yn,objectElementValidators:{glyphs:nl,"*":()=>[]}})),i.constants&&(r=r.concat(Gn({key:"constants",value:i.constants,style:i,styleSpec:e,validateSpec:Yn}))),al(r)}function xr(i){return function(e){return i({...e,validateSpec:Yn})}}function al(i){return[].concat(i).sort((e,r)=>e.line-r.line)}function vr(i){return function(...e){return al(i.apply(this,e))}}or.source=vr(xr(Rs)),or.sprite=vr(xr(il)),or.glyphs=vr(xr(nl)),or.light=vr(xr(Bs)),or.terrain=vr(xr(La)),or.layer=vr(xr(tl)),or.filter=vr(xr(Cn)),or.paintProperty=vr(xr(Qo)),or.layoutProperty=vr(xr(el));const Mn=or,sl=Mn.light,Da=Mn.paintProperty,oc=Mn.layoutProperty;function Fs(i,e){let r=!1;if(e&&e.length)for(const a of e)i.fire(new Gr(new Error(a.message))),r=!0;return r}class Pn{constructor(e,r,a){const c=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const p=new Int32Array(this.arrayBuffer);e=p[0],this.d=(r=p[1])+2*(a=p[2]);for(let _=0;_<this.d*this.d;_++){const v=p[3+_],w=p[3+_+1];c.push(v===w?null:p.subarray(v,w))}const f=p[3+c.length+1];this.keys=p.subarray(p[3+c.length],f),this.bboxes=p.subarray(f),this.insert=this._insertReadonly}else{this.d=r+2*a;for(let p=0;p<this.d*this.d;p++)c.push([]);this.keys=[],this.bboxes=[]}this.n=r,this.extent=e,this.padding=a,this.scale=r/e,this.uid=0;const u=a/r*e;this.min=-u,this.max=e+u}insert(e,r,a,c,u){this._forEachCell(r,a,c,u,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(r),this.bboxes.push(a),this.bboxes.push(c),this.bboxes.push(u)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,r,a,c,u,p){this.cells[u].push(p)}query(e,r,a,c,u){const p=this.min,f=this.max;if(e<=p&&r<=p&&f<=a&&f<=c&&!u)return Array.prototype.slice.call(this.keys);{const _=[];return this._forEachCell(e,r,a,c,this._queryCell,_,{},u),_}}_queryCell(e,r,a,c,u,p,f,_){const v=this.cells[u];if(v!==null){const w=this.keys,E=this.bboxes;for(let P=0;P<v.length;P++){const k=v[P];if(f[k]===void 0){const L=4*k;(_?_(E[L+0],E[L+1],E[L+2],E[L+3]):e<=E[L+2]&&r<=E[L+3]&&a>=E[L+0]&&c>=E[L+1])?(f[k]=!0,p.push(w[k])):f[k]=!1}}}}_forEachCell(e,r,a,c,u,p,f,_){const v=this._convertToCellCoord(e),w=this._convertToCellCoord(r),E=this._convertToCellCoord(a),P=this._convertToCellCoord(c);for(let k=v;k<=E;k++)for(let L=w;L<=P;L++){const $=this.d*L+k;if((!_||_(this._convertFromCellCoord(k),this._convertFromCellCoord(L),this._convertFromCellCoord(k+1),this._convertFromCellCoord(L+1)))&&u.call(this,e,r,a,c,$,p,f,_))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,r=3+this.cells.length+1+1;let a=0;for(let p=0;p<this.cells.length;p++)a+=this.cells[p].length;const c=new Int32Array(r+a+this.keys.length+this.bboxes.length);c[0]=this.extent,c[1]=this.n,c[2]=this.padding;let u=r;for(let p=0;p<e.length;p++){const f=e[p];c[3+p]=u,c.set(f,u),u+=f.length}return c[3+e.length]=u,c.set(this.keys,u),u+=this.keys.length,c[3+e.length+1]=u,c.set(this.bboxes,u),u+=this.bboxes.length,c.buffer}static serialize(e,r){const a=e.toArrayBuffer();return r&&r.push(a),{buffer:a}}static deserialize(e){return new Pn(e.buffer)}}const zr={};function ke(i,e,r={}){if(zr[i])throw new Error(`${i} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:i,writeable:!1}),zr[i]={klass:e,omit:r.omit||[],shallow:r.shallow||[]}}ke("Object",Object),ke("TransferableGridIndex",Pn),ke("Color",ut),ke("Error",Error),ke("AJAXError",Er),ke("ResolvedImage",fi),ke("StylePropertyFunction",Aa),ke("StyleExpression",Cs,{omit:["_evaluator"]}),ke("ZoomDependentExpression",Ps),ke("ZoomConstantExpression",Ms),ke("CompoundExpression",oe,{omit:["_evaluate"]});for(const i in Sn)Sn[i]._classRegistryKey||ke(`Expression_${i}`,Sn[i]);function Jn(i){return i&&typeof ArrayBuffer<"u"&&(i instanceof ArrayBuffer||i.constructor&&i.constructor.name==="ArrayBuffer")}function Qr(i,e){if(i==null||typeof i=="boolean"||typeof i=="number"||typeof i=="string"||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||i instanceof Blob)return i;if(Jn(i)||gr(i))return e&&e.push(i),i;if(ArrayBuffer.isView(i)){const r=i;return e&&e.push(r.buffer),r}if(i instanceof ImageData)return e&&e.push(i.data.buffer),i;if(Array.isArray(i)){const r=[];for(const a of i)r.push(Qr(a,e));return r}if(typeof i=="object"){const r=i.constructor,a=r._classRegistryKey;if(!a)throw new Error("can't serialize object of unregistered class");if(!zr[a])throw new Error(`${a} is not registered.`);const c=r.serialize?r.serialize(i,e):{};if(r.serialize){if(e&&c===e[e.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const u in i){if(!i.hasOwnProperty(u)||zr[a].omit.indexOf(u)>=0)continue;const p=i[u];c[u]=zr[a].shallow.indexOf(u)>=0?p:Qr(p,e)}i instanceof Error&&(c.message=i.message)}if(c.$name)throw new Error("$name property is reserved for worker serialization logic.");return a!=="Object"&&(c.$name=a),c}throw new Error("can't serialize object of type "+typeof i)}function en(i){if(i==null||typeof i=="boolean"||typeof i=="number"||typeof i=="string"||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||i instanceof Blob||Jn(i)||gr(i)||ArrayBuffer.isView(i)||i instanceof ImageData)return i;if(Array.isArray(i))return i.map(en);if(typeof i=="object"){const e=i.$name||"Object";if(!zr[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=zr[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(i);const a=Object.create(r.prototype);for(const c of Object.keys(i)){if(c==="$name")continue;const u=i[c];a[c]=zr[e].shallow.indexOf(c)>=0?u:en(u)}return a}throw new Error("can't deserialize object of type "+typeof i)}class ol{constructor(){this.first=!0}update(e,r){const a=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=a,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=a,!0):(this.lastFloorZoom>a?(this.lastIntegerZoom=a+1,this.lastIntegerZoomTime=r):this.lastFloorZoom<a&&(this.lastIntegerZoom=a,this.lastIntegerZoomTime=r),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=a,!0))}}const Ae={"Latin-1 Supplement":i=>i>=128&&i<=255,Arabic:i=>i>=1536&&i<=1791,"Arabic Supplement":i=>i>=1872&&i<=1919,"Arabic Extended-A":i=>i>=2208&&i<=2303,"Hangul Jamo":i=>i>=4352&&i<=4607,"Unified Canadian Aboriginal Syllabics":i=>i>=5120&&i<=5759,Khmer:i=>i>=6016&&i<=6143,"Unified Canadian Aboriginal Syllabics Extended":i=>i>=6320&&i<=6399,"General Punctuation":i=>i>=8192&&i<=8303,"Letterlike Symbols":i=>i>=8448&&i<=8527,"Number Forms":i=>i>=8528&&i<=8591,"Miscellaneous Technical":i=>i>=8960&&i<=9215,"Control Pictures":i=>i>=9216&&i<=9279,"Optical Character Recognition":i=>i>=9280&&i<=9311,"Enclosed Alphanumerics":i=>i>=9312&&i<=9471,"Geometric Shapes":i=>i>=9632&&i<=9727,"Miscellaneous Symbols":i=>i>=9728&&i<=9983,"Miscellaneous Symbols and Arrows":i=>i>=11008&&i<=11263,"CJK Radicals Supplement":i=>i>=11904&&i<=12031,"Kangxi Radicals":i=>i>=12032&&i<=12255,"Ideographic Description Characters":i=>i>=12272&&i<=12287,"CJK Symbols and Punctuation":i=>i>=12288&&i<=12351,Hiragana:i=>i>=12352&&i<=12447,Katakana:i=>i>=12448&&i<=12543,Bopomofo:i=>i>=12544&&i<=12591,"Hangul Compatibility Jamo":i=>i>=12592&&i<=12687,Kanbun:i=>i>=12688&&i<=12703,"Bopomofo Extended":i=>i>=12704&&i<=12735,"CJK Strokes":i=>i>=12736&&i<=12783,"Katakana Phonetic Extensions":i=>i>=12784&&i<=12799,"Enclosed CJK Letters and Months":i=>i>=12800&&i<=13055,"CJK Compatibility":i=>i>=13056&&i<=13311,"CJK Unified Ideographs Extension A":i=>i>=13312&&i<=19903,"Yijing Hexagram Symbols":i=>i>=19904&&i<=19967,"CJK Unified Ideographs":i=>i>=19968&&i<=40959,"Yi Syllables":i=>i>=40960&&i<=42127,"Yi Radicals":i=>i>=42128&&i<=42191,"Hangul Jamo Extended-A":i=>i>=43360&&i<=43391,"Hangul Syllables":i=>i>=44032&&i<=55215,"Hangul Jamo Extended-B":i=>i>=55216&&i<=55295,"Private Use Area":i=>i>=57344&&i<=63743,"CJK Compatibility Ideographs":i=>i>=63744&&i<=64255,"Arabic Presentation Forms-A":i=>i>=64336&&i<=65023,"Vertical Forms":i=>i>=65040&&i<=65055,"CJK Compatibility Forms":i=>i>=65072&&i<=65103,"Small Form Variants":i=>i>=65104&&i<=65135,"Arabic Presentation Forms-B":i=>i>=65136&&i<=65279,"Halfwidth and Fullwidth Forms":i=>i>=65280&&i<=65519};function Os(i){for(const e of i)if(Us(e.charCodeAt(0)))return!0;return!1}function lc(i){for(const e of i)if(!cc(e.charCodeAt(0)))return!1;return!0}function cc(i){return!(Ae.Arabic(i)||Ae["Arabic Supplement"](i)||Ae["Arabic Extended-A"](i)||Ae["Arabic Presentation Forms-A"](i)||Ae["Arabic Presentation Forms-B"](i))}function Us(i){return!(i!==746&&i!==747&&(i<4352||!(Ae["Bopomofo Extended"](i)||Ae.Bopomofo(i)||Ae["CJK Compatibility Forms"](i)&&!(i>=65097&&i<=65103)||Ae["CJK Compatibility Ideographs"](i)||Ae["CJK Compatibility"](i)||Ae["CJK Radicals Supplement"](i)||Ae["CJK Strokes"](i)||!(!Ae["CJK Symbols and Punctuation"](i)||i>=12296&&i<=12305||i>=12308&&i<=12319||i===12336)||Ae["CJK Unified Ideographs Extension A"](i)||Ae["CJK Unified Ideographs"](i)||Ae["Enclosed CJK Letters and Months"](i)||Ae["Hangul Compatibility Jamo"](i)||Ae["Hangul Jamo Extended-A"](i)||Ae["Hangul Jamo Extended-B"](i)||Ae["Hangul Jamo"](i)||Ae["Hangul Syllables"](i)||Ae.Hiragana(i)||Ae["Ideographic Description Characters"](i)||Ae.Kanbun(i)||Ae["Kangxi Radicals"](i)||Ae["Katakana Phonetic Extensions"](i)||Ae.Katakana(i)&&i!==12540||!(!Ae["Halfwidth and Fullwidth Forms"](i)||i===65288||i===65289||i===65293||i>=65306&&i<=65310||i===65339||i===65341||i===65343||i>=65371&&i<=65503||i===65507||i>=65512&&i<=65519)||!(!Ae["Small Form Variants"](i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||Ae["Unified Canadian Aboriginal Syllabics"](i)||Ae["Unified Canadian Aboriginal Syllabics Extended"](i)||Ae["Vertical Forms"](i)||Ae["Yijing Hexagram Symbols"](i)||Ae["Yi Syllables"](i)||Ae["Yi Radicals"](i))))}function ll(i){return!(Us(i)||function(e){return!!(Ae["Latin-1 Supplement"](e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||Ae["General Punctuation"](e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||Ae["Letterlike Symbols"](e)||Ae["Number Forms"](e)||Ae["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||Ae["Control Pictures"](e)&&e!==9251||Ae["Optical Character Recognition"](e)||Ae["Enclosed Alphanumerics"](e)||Ae["Geometric Shapes"](e)||Ae["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||Ae["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Ae["CJK Symbols and Punctuation"](e)||Ae.Katakana(e)||Ae["Private Use Area"](e)||Ae["CJK Compatibility Forms"](e)||Ae["Small Form Variants"](e)||Ae["Halfwidth and Fullwidth Forms"](e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(i))}function Qn(i){return i>=1424&&i<=2303||Ae["Arabic Presentation Forms-A"](i)||Ae["Arabic Presentation Forms-B"](i)}function Ra(i,e){return!(!e&&Qn(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||Ae.Khmer(i))}function Gi(i){for(const e of i)if(Qn(e.charCodeAt(0)))return!0;return!1}const kn="deferred",Vs="loading",Ns="loaded";let $s=null,Si="unavailable",lr=null;const cl=function(i){i&&typeof i=="string"&&i.indexOf("NetworkError")>-1&&(Si="error"),$s&&$s(i)};function ea(){Gs.fire(new $r("pluginStateChange",{pluginStatus:Si,pluginURL:lr}))}const Gs=new Ir,tn=function(){return Si},hl=function(){if(Si!==kn||!lr)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Si=Vs,ea(),lr&&Vr({url:lr},i=>{i?cl(i):(Si=Ns,ea())})},Ei={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Si===Ns||Ei.applyArabicShaping!=null,isLoading:()=>Si===Vs,setState(i){if(!Oi())throw new Error("Cannot set the state of the rtl-text-plugin when not in the web-worker context");Si=i.pluginStatus,lr=i.pluginURL},isParsed(){if(!Oi())throw new Error("rtl-text-plugin is only parsed on the worker-threads");return Ei.applyArabicShaping!=null&&Ei.processBidirectionalText!=null&&Ei.processStyledBidirectionalText!=null},getPluginURL(){if(!Oi())throw new Error("rtl-text-plugin url can only be queried from the worker threads");return lr}};class Pt{constructor(e,r){this.zoom=e,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 ol,this.transition={})}isSupportedScript(e){return function(r,a){for(const c of r)if(!Ra(c.charCodeAt(0),a))return!1;return!0}(e,Ei.isLoaded())}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,r=e-Math.floor(e),a=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*a}:{fromScale:.5,toScale:1,t:1-(1-a)*r}}}class zn{constructor(e,r){this.property=e,this.value=r,this.expression=function(a,c){if(Sa(a))return new Aa(a,c);if(Ea(a)){const u=Ho(a,c);if(u.result==="error")throw new Error(u.value.map(p=>`${p.key}: ${p.message}`).join(", "));return u.value}{let u=a;return c.type==="color"&&typeof a=="string"?u=ut.parse(a):c.type!=="padding"||typeof a!="number"&&!Array.isArray(a)||(u=Yt.parse(a)),{kind:"constant",evaluate:()=>u}}}(r===void 0?e.specification.default:r,e.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,r,a){return this.property.possiblyEvaluate(this,e,r,a)}}class Ba{constructor(e){this.property=e,this.value=new zn(e,void 0)}transitioned(e,r){return new ul(this.property,this.value,r,Be({},e.transition,this.transition),e.now)}untransitioned(){return new ul(this.property,this.value,null,{},0)}}class js{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return Ci(this._values[e].value.value)}setValue(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ba(this._values[e].property)),this._values[e].value=new zn(this._values[e].property,r===null?void 0:Ci(r))}getTransition(e){return Ci(this._values[e].transition)}setTransition(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ba(this._values[e].property)),this._values[e].transition=Ci(r)||void 0}serialize(){const e={};for(const r of Object.keys(this._values)){const a=this.getValue(r);a!==void 0&&(e[r]=a);const c=this.getTransition(r);c!==void 0&&(e[`${r}-transition`]=c)}return e}transitioned(e,r){const a=new Fa(this._properties);for(const c of Object.keys(this._values))a._values[c]=this._values[c].transitioned(e,r._values[c]);return a}untransitioned(){const e=new Fa(this._properties);for(const r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class ul{constructor(e,r,a,c,u){this.property=e,this.value=r,this.begin=u+c.delay||0,this.end=this.begin+c.duration||0,e.specification.transition&&(c.delay||c.duration)&&(this.prior=a)}possiblyEvaluate(e,r,a){const c=e.now||0,u=this.value.possiblyEvaluate(e,r,a),p=this.prior;if(p){if(c>this.end)return this.prior=null,u;if(this.value.isDataDriven())return this.prior=null,u;if(c<this.begin)return p.possiblyEvaluate(e,r,a);{const f=(c-this.begin)/(this.end-this.begin);return this.property.interpolate(p.possiblyEvaluate(e,r,a),u,function(_){if(_<=0)return 0;if(_>=1)return 1;const v=_*_,w=v*_;return 4*(_<.5?w:3*(_-v)+w-.75)}(f))}}return u}}class Fa{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,r,a){const c=new Ua(this._properties);for(const u of Object.keys(this._values))c._values[u]=this._values[u].possiblyEvaluate(e,r,a);return c}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Oa{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}getValue(e){return Ci(this._values[e].value)}setValue(e,r){this._values[e]=new zn(this._values[e].property,r===null?void 0:Ci(r))}serialize(){const e={};for(const r of Object.keys(this._values)){const a=this.getValue(r);a!==void 0&&(e[r]=a)}return e}possiblyEvaluate(e,r,a){const c=new Ua(this._properties);for(const u of Object.keys(this._values))c._values[u]=this._values[u].possiblyEvaluate(e,r,a);return c}}class Ki{constructor(e,r,a){this.property=e,this.value=r,this.parameters=a}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,r,a,c){return this.property.evaluate(this.value,this.parameters,e,r,a,c)}}class Ua{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class Ue{constructor(e){this.specification=e}possiblyEvaluate(e,r){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(r)}interpolate(e,r,a){const c=Kr[this.specification.type];return c?c(e,r,a):e}}class Ze{constructor(e,r){this.specification=e,this.overrides=r}possiblyEvaluate(e,r,a,c){return new Ki(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(r,null,{},a,c)}:e.expression,r)}interpolate(e,r,a){if(e.value.kind!=="constant"||r.value.kind!=="constant")return e;if(e.value.value===void 0||r.value.value===void 0)return new Ki(this,{kind:"constant",value:void 0},e.parameters);const c=Kr[this.specification.type];return c?new Ki(this,{kind:"constant",value:c(e.value.value,r.value.value,a)},e.parameters):e}evaluate(e,r,a,c,u,p){return e.kind==="constant"?e.value:e.evaluate(r,a,c,u,p)}}class Ln extends Ze{possiblyEvaluate(e,r,a,c){if(e.value===void 0)return new Ki(this,{kind:"constant",value:void 0},r);if(e.expression.kind==="constant"){const u=e.expression.evaluate(r,null,{},a,c),p=e.property.specification.type==="resolvedImage"&&typeof u!="string"?u.name:u,f=this._calculate(p,p,p,r);return new Ki(this,{kind:"constant",value:f},r)}if(e.expression.kind==="camera"){const u=this._calculate(e.expression.evaluate({zoom:r.zoom-1}),e.expression.evaluate({zoom:r.zoom}),e.expression.evaluate({zoom:r.zoom+1}),r);return new Ki(this,{kind:"constant",value:u},r)}return new Ki(this,e.expression,r)}evaluate(e,r,a,c,u,p){if(e.kind==="source"){const f=e.evaluate(r,a,c,u,p);return this._calculate(f,f,f,r)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(r.zoom)-1},a,c),e.evaluate({zoom:Math.floor(r.zoom)},a,c),e.evaluate({zoom:Math.floor(r.zoom)+1},a,c),r):e.value}_calculate(e,r,a,c){return c.zoom>c.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:a,to:r}}interpolate(e){return e}}class qs{constructor(e){this.specification=e}possiblyEvaluate(e,r,a,c){if(e.value!==void 0){if(e.expression.kind==="constant"){const u=e.expression.evaluate(r,null,{},a,c);return this._calculate(u,u,u,r)}return this._calculate(e.expression.evaluate(new Pt(Math.floor(r.zoom-1),r)),e.expression.evaluate(new Pt(Math.floor(r.zoom),r)),e.expression.evaluate(new Pt(Math.floor(r.zoom+1),r)),r)}}_calculate(e,r,a,c){return c.zoom>c.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:a,to:r}}interpolate(e){return e}}class Zs{constructor(e){this.specification=e}possiblyEvaluate(e,r,a,c){return!!e.expression.evaluate(r,null,{},a,c)}interpolate(){return!1}}class Ii{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const r in e){const a=e[r];a.specification.overridable&&this.overridableProperties.push(r);const c=this.defaultPropertyValues[r]=new zn(a,void 0),u=this.defaultTransitionablePropertyValues[r]=new Ba(a);this.defaultTransitioningPropertyValues[r]=u.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=c.possiblyEvaluate({})}}}ke("DataDrivenProperty",Ze),ke("DataConstantProperty",Ue),ke("CrossFadedDataDrivenProperty",Ln),ke("CrossFadedProperty",qs),ke("ColorRampProperty",Zs);const Va="-transition";class Yi extends Ir{constructor(e,r){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1},e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),r.layout&&(this._unevaluatedLayout=new Oa(r.layout)),r.paint)){this._transitionablePaint=new js(r.paint);for(const a in e.paint)this.setPaintProperty(a,e.paint[a],{validate:!1});for(const a in e.layout)this.setLayoutProperty(a,e.layout[a],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ua(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,r,a={}){r!=null&&this._validate(oc,`layers.${this.id}.layout.${e}`,e,r,a)||(e!=="visibility"?this._unevaluatedLayout.setValue(e,r):this.visibility=r)}getPaintProperty(e){return e.endsWith(Va)?this._transitionablePaint.getTransition(e.slice(0,-Va.length)):this._transitionablePaint.getValue(e)}setPaintProperty(e,r,a={}){if(r!=null&&this._validate(Da,`layers.${this.id}.paint.${e}`,e,r,a))return!1;if(e.endsWith(Va))return this._transitionablePaint.setTransition(e.slice(0,-Va.length),r||void 0),!1;{const c=this._transitionablePaint._values[e],u=c.property.specification["property-type"]==="cross-faded-data-driven",p=c.value.isDataDriven(),f=c.value;this._transitionablePaint.setValue(e,r),this._handleSpecialPaintPropertyUpdate(e);const _=this._transitionablePaint._values[e].value;return _.isDataDriven()||p||u||this._handleOverridablePaintPropertyUpdate(e,f,_)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,r,a){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,r){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,r)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),dn(e,(r,a)=>!(r===void 0||a==="layout"&&!Object.keys(r).length||a==="paint"&&!Object.keys(r).length))}_validate(e,r,a,c,u={}){return(!u||u.validate!==!1)&&Fs(this,e.call(Mn,{key:r,layerType:this.type,objectKey:a,value:c,styleSpec:le,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const r=this.paint.get(e);if(r instanceof Ki&&In(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}}const hc={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Na{constructor(e,r){this._structArray=e,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Ut{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,r){return e._trim(),r&&(e.isTransferred=!0,r.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const r=Object.create(this.prototype);return r.arrayBuffer=e.arrayBuffer,r.length=e.length,r.capacity=e.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);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 jt(i,e=1){let r=0,a=0;return{members:i.map(c=>{const u=hc[c.type].BYTES_PER_ELEMENT,p=r=dl(r,Math.max(e,u)),f=c.components||1;return a=Math.max(a,u),r+=u*f,{name:c.name,type:c.type,components:f,offset:p}}),size:dl(r,Math.max(a,e)),alignment:e}}function dl(i,e){return Math.ceil(i/e)*e}class ta extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r){const a=this.length;return this.resize(a+1),this.emplace(a,e,r)}emplace(e,r,a){const c=2*e;return this.int16[c+0]=r,this.int16[c+1]=a,e}}ta.prototype.bytesPerElement=4,ke("StructArrayLayout2i4",ta);class $a extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,r,a)}emplace(e,r,a,c){const u=3*e;return this.int16[u+0]=r,this.int16[u+1]=a,this.int16[u+2]=c,e}}$a.prototype.bytesPerElement=6,ke("StructArrayLayout3i6",$a);class Dn extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,r,a,c)}emplace(e,r,a,c,u){const p=4*e;return this.int16[p+0]=r,this.int16[p+1]=a,this.int16[p+2]=c,this.int16[p+3]=u,e}}Dn.prototype.bytesPerElement=8,ke("StructArrayLayout4i8",Dn);class Xs extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,a,c,u,p)}emplace(e,r,a,c,u,p,f){const _=6*e;return this.int16[_+0]=r,this.int16[_+1]=a,this.int16[_+2]=c,this.int16[_+3]=u,this.int16[_+4]=p,this.int16[_+5]=f,e}}Xs.prototype.bytesPerElement=12,ke("StructArrayLayout2i4i12",Xs);class ia extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,a,c,u,p)}emplace(e,r,a,c,u,p,f){const _=4*e,v=8*e;return this.int16[_+0]=r,this.int16[_+1]=a,this.uint8[v+4]=c,this.uint8[v+5]=u,this.uint8[v+6]=p,this.uint8[v+7]=f,e}}ia.prototype.bytesPerElement=8,ke("StructArrayLayout2i4ub8",ia);class ra extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r){const a=this.length;return this.resize(a+1),this.emplace(a,e,r)}emplace(e,r,a){const c=2*e;return this.float32[c+0]=r,this.float32[c+1]=a,e}}ra.prototype.bytesPerElement=8,ke("StructArrayLayout2f8",ra);class Ws extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u,p,f,_,v,w){const E=this.length;return this.resize(E+1),this.emplace(E,e,r,a,c,u,p,f,_,v,w)}emplace(e,r,a,c,u,p,f,_,v,w,E){const P=10*e;return this.uint16[P+0]=r,this.uint16[P+1]=a,this.uint16[P+2]=c,this.uint16[P+3]=u,this.uint16[P+4]=p,this.uint16[P+5]=f,this.uint16[P+6]=_,this.uint16[P+7]=v,this.uint16[P+8]=w,this.uint16[P+9]=E,e}}Ws.prototype.bytesPerElement=20,ke("StructArrayLayout10ui20",Ws);class Hs extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u,p,f,_,v,w,E,P){const k=this.length;return this.resize(k+1),this.emplace(k,e,r,a,c,u,p,f,_,v,w,E,P)}emplace(e,r,a,c,u,p,f,_,v,w,E,P,k){const L=12*e;return this.int16[L+0]=r,this.int16[L+1]=a,this.int16[L+2]=c,this.int16[L+3]=u,this.uint16[L+4]=p,this.uint16[L+5]=f,this.uint16[L+6]=_,this.uint16[L+7]=v,this.int16[L+8]=w,this.int16[L+9]=E,this.int16[L+10]=P,this.int16[L+11]=k,e}}Hs.prototype.bytesPerElement=24,ke("StructArrayLayout4i4ui4i24",Hs);class Ga extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,r,a)}emplace(e,r,a,c){const u=3*e;return this.float32[u+0]=r,this.float32[u+1]=a,this.float32[u+2]=c,e}}Ga.prototype.bytesPerElement=12,ke("StructArrayLayout3f12",Ga);class ja extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint32[1*e+0]=r,e}}ja.prototype.bytesPerElement=4,ke("StructArrayLayout1ul4",ja);class Ks extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u,p,f,_,v){const w=this.length;return this.resize(w+1),this.emplace(w,e,r,a,c,u,p,f,_,v)}emplace(e,r,a,c,u,p,f,_,v,w){const E=10*e,P=5*e;return this.int16[E+0]=r,this.int16[E+1]=a,this.int16[E+2]=c,this.int16[E+3]=u,this.int16[E+4]=p,this.int16[E+5]=f,this.uint32[P+3]=_,this.uint16[E+8]=v,this.uint16[E+9]=w,e}}Ks.prototype.bytesPerElement=20,ke("StructArrayLayout6i1ul2ui20",Ks);class Ys extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,a,c,u,p)}emplace(e,r,a,c,u,p,f){const _=6*e;return this.int16[_+0]=r,this.int16[_+1]=a,this.int16[_+2]=c,this.int16[_+3]=u,this.int16[_+4]=p,this.int16[_+5]=f,e}}Ys.prototype.bytesPerElement=12,ke("StructArrayLayout2i2i2i12",Ys);class Js extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,r,a,c,u)}emplace(e,r,a,c,u,p){const f=4*e,_=8*e;return this.float32[f+0]=r,this.float32[f+1]=a,this.float32[f+2]=c,this.int16[_+6]=u,this.int16[_+7]=p,e}}Js.prototype.bytesPerElement=16,ke("StructArrayLayout2f1f2i16",Js);class Qs extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,r,a,c)}emplace(e,r,a,c,u){const p=12*e,f=3*e;return this.uint8[p+0]=r,this.uint8[p+1]=a,this.float32[f+1]=c,this.float32[f+2]=u,e}}Qs.prototype.bytesPerElement=12,ke("StructArrayLayout2ub2f12",Qs);class qa extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,r,a)}emplace(e,r,a,c){const u=3*e;return this.uint16[u+0]=r,this.uint16[u+1]=a,this.uint16[u+2]=c,e}}qa.prototype.bytesPerElement=6,ke("StructArrayLayout3ui6",qa);class eo extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u,p,f,_,v,w,E,P,k,L,$,N,J){const ne=this.length;return this.resize(ne+1),this.emplace(ne,e,r,a,c,u,p,f,_,v,w,E,P,k,L,$,N,J)}emplace(e,r,a,c,u,p,f,_,v,w,E,P,k,L,$,N,J,ne){const K=24*e,re=12*e,ge=48*e;return this.int16[K+0]=r,this.int16[K+1]=a,this.uint16[K+2]=c,this.uint16[K+3]=u,this.uint32[re+2]=p,this.uint32[re+3]=f,this.uint32[re+4]=_,this.uint16[K+10]=v,this.uint16[K+11]=w,this.uint16[K+12]=E,this.float32[re+7]=P,this.float32[re+8]=k,this.uint8[ge+36]=L,this.uint8[ge+37]=$,this.uint8[ge+38]=N,this.uint32[re+10]=J,this.int16[K+22]=ne,e}}eo.prototype.bytesPerElement=48,ke("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",eo);class Lr extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a,c,u,p,f,_,v,w,E,P,k,L,$,N,J,ne,K,re,ge,fe,De,Fe,Me,Ie,Te,Pe){const Ce=this.length;return this.resize(Ce+1),this.emplace(Ce,e,r,a,c,u,p,f,_,v,w,E,P,k,L,$,N,J,ne,K,re,ge,fe,De,Fe,Me,Ie,Te,Pe)}emplace(e,r,a,c,u,p,f,_,v,w,E,P,k,L,$,N,J,ne,K,re,ge,fe,De,Fe,Me,Ie,Te,Pe,Ce){const be=34*e,$e=17*e;return this.int16[be+0]=r,this.int16[be+1]=a,this.int16[be+2]=c,this.int16[be+3]=u,this.int16[be+4]=p,this.int16[be+5]=f,this.int16[be+6]=_,this.int16[be+7]=v,this.uint16[be+8]=w,this.uint16[be+9]=E,this.uint16[be+10]=P,this.uint16[be+11]=k,this.uint16[be+12]=L,this.uint16[be+13]=$,this.uint16[be+14]=N,this.uint16[be+15]=J,this.uint16[be+16]=ne,this.uint16[be+17]=K,this.uint16[be+18]=re,this.uint16[be+19]=ge,this.uint16[be+20]=fe,this.uint16[be+21]=De,this.uint16[be+22]=Fe,this.uint32[$e+12]=Me,this.float32[$e+13]=Ie,this.float32[$e+14]=Te,this.float32[$e+15]=Pe,this.float32[$e+16]=Ce,e}}Lr.prototype.bytesPerElement=68,ke("StructArrayLayout8i15ui1ul4f68",Lr);class Za extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.float32[1*e+0]=r,e}}Za.prototype.bytesPerElement=4,ke("StructArrayLayout1f4",Za);class to extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,r,a)}emplace(e,r,a,c){const u=4*e;return this.uint32[2*e+0]=r,this.uint16[u+2]=a,this.uint16[u+3]=c,e}}to.prototype.bytesPerElement=8,ke("StructArrayLayout1ul2ui8",to);class io extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r){const a=this.length;return this.resize(a+1),this.emplace(a,e,r)}emplace(e,r,a){const c=2*e;return this.uint16[c+0]=r,this.uint16[c+1]=a,e}}io.prototype.bytesPerElement=4,ke("StructArrayLayout2ui4",io);class Xa extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint16[1*e+0]=r,e}}Xa.prototype.bytesPerElement=2,ke("StructArrayLayout1ui2",Xa);class ro extends Ut{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,r,a,c)}emplace(e,r,a,c,u){const p=4*e;return this.float32[p+0]=r,this.float32[p+1]=a,this.float32[p+2]=c,this.float32[p+3]=u,e}}ro.prototype.bytesPerElement=16,ke("StructArrayLayout4f16",ro);class pl extends Na{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 He(this.anchorPointX,this.anchorPointY)}}pl.prototype.size=20;class no extends Ks{get(e){return new pl(this,e)}}ke("CollisionBoxArray",no);class Wa extends Na{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Wa.prototype.size=48;class ao extends eo{get(e){return new Wa(this,e)}}ke("PlacedSymbolArray",ao);class Ha extends Na{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get textOffset0(){return this._structArray.float32[this._pos4+14]}get textOffset1(){return this._structArray.float32[this._pos4+15]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+16]}}Ha.prototype.size=68;class ml extends Lr{get(e){return new Ha(this,e)}}ke("SymbolInstanceArray",ml);class rn extends Za{getoffsetX(e){return this.float32[1*e+0]}}ke("GlyphOffsetArray",rn);class na extends $a{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}ke("SymbolLineVertexArray",na);class Rn extends Na{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]}}Rn.prototype.size=8;class fl extends to{get(e){return new Rn(this,e)}}ke("FeatureIndexArray",fl);class so extends ta{}class aa extends ta{}class uc extends ta{}class dc extends Xs{}class gl extends ia{}class pc extends ra{}class Dr extends Ws{}class o extends Hs{}class t extends Ga{}class n extends ja{}class s extends Ys{}class l extends Qs{}class d extends qa{}class m extends io{}const g=jt([{name:"a_pos",components:2,type:"Int16"}],4),{members:y}=g;class x{constructor(e=[]){this.segments=e}prepareSegment(e,r,a,c){let u=this.segments[this.segments.length-1];return e>x.MAX_VERTEX_ARRAY_LENGTH&&dt(`Max vertices per segment is ${x.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!u||u.vertexLength+e>x.MAX_VERTEX_ARRAY_LENGTH||u.sortKey!==c)&&(u={vertexOffset:r.length,primitiveOffset:a.length,vertexLength:0,primitiveLength:0},c!==void 0&&(u.sortKey=c),this.segments.push(u)),u}get(){return this.segments}destroy(){for(const e of this.segments)for(const r in e.vaos)e.vaos[r].destroy()}static simpleSegment(e,r,a,c){return new x([{vertexOffset:e,primitiveOffset:r,vertexLength:a,primitiveLength:c,vaos:{},sortKey:0}])}}function S(i,e){return 256*(i=pe(Math.floor(i),0,255))+pe(Math.floor(e),0,255)}x.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ke("SegmentVector",x);const T=jt([{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 M={},F={get exports(){return M},set exports(i){M=i}},O={};({get exports(){return O},set exports(i){O=i}}).exports=function(i,e){var r,a,c,u,p,f,_,v;for(a=i.length-(r=3&i.length),c=e,p=3432918353,f=461845907,v=0;v<a;)_=255&i.charCodeAt(v)|(255&i.charCodeAt(++v))<<8|(255&i.charCodeAt(++v))<<16|(255&i.charCodeAt(++v))<<24,++v,c=27492+(65535&(u=5*(65535&(c=(c^=_=(65535&(_=(_=(65535&_)*p+(((_>>>16)*p&65535)<<16)&4294967295)<<15|_>>>17))*f+(((_>>>16)*f&65535)<<16)&4294967295)<<13|c>>>19))+((5*(c>>>16)&65535)<<16)&4294967295))+((58964+(u>>>16)&65535)<<16);switch(_=0,r){case 3:_^=(255&i.charCodeAt(v+2))<<16;case 2:_^=(255&i.charCodeAt(v+1))<<8;case 1:c^=_=(65535&(_=(_=(65535&(_^=255&i.charCodeAt(v)))*p+(((_>>>16)*p&65535)<<16)&4294967295)<<15|_>>>17))*f+(((_>>>16)*f&65535)<<16)&4294967295}return c^=i.length,c=2246822507*(65535&(c^=c>>>16))+((2246822507*(c>>>16)&65535)<<16)&4294967295,c=3266489909*(65535&(c^=c>>>13))+((3266489909*(c>>>16)&65535)<<16)&4294967295,(c^=c>>>16)>>>0};var D={};({get exports(){return D},set exports(i){D=i}}).exports=function(i,e){for(var r,a=i.length,c=e^a,u=0;a>=4;)r=1540483477*(65535&(r=255&i.charCodeAt(u)|(255&i.charCodeAt(++u))<<8|(255&i.charCodeAt(++u))<<16|(255&i.charCodeAt(++u))<<24))+((1540483477*(r>>>16)&65535)<<16),c=1540483477*(65535&c)+((1540483477*(c>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),a-=4,++u;switch(a){case 3:c^=(255&i.charCodeAt(u+2))<<16;case 2:c^=(255&i.charCodeAt(u+1))<<8;case 1:c=1540483477*(65535&(c^=255&i.charCodeAt(u)))+((1540483477*(c>>>16)&65535)<<16)}return c=1540483477*(65535&(c^=c>>>13))+((1540483477*(c>>>16)&65535)<<16),(c^=c>>>15)>>>0};var G=O,Y=D;F.exports=G,M.murmur3=G,M.murmur2=Y;class H{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,r,a,c){this.ids.push(V(e)),this.positions.push(r,a,c)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const r=V(e);let a=0,c=this.ids.length-1;for(;a<c;){const p=a+c>>1;this.ids[p]>=r?c=p:a=p+1}const u=[];for(;this.ids[a]===r;)u.push({index:this.positions[3*a],start:this.positions[3*a+1],end:this.positions[3*a+2]}),a++;return u}static serialize(e,r){const a=new Float64Array(e.ids),c=new Uint32Array(e.positions);return te(a,c,0,a.length-1),r&&r.push(a.buffer,c.buffer),{ids:a,positions:c}}static deserialize(e){const r=new H;return r.ids=e.ids,r.positions=e.positions,r.indexed=!0,r}}function V(i){const e=+i;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:M(String(i))}function te(i,e,r,a){for(;r<a;){const c=i[r+a>>1];let u=r-1,p=a+1;for(;;){do u++;while(i[u]<c);do p--;while(i[p]>c);if(u>=p)break;ae(i,u,p),ae(e,3*u,3*p),ae(e,3*u+1,3*p+1),ae(e,3*u+2,3*p+2)}p-r<a-p?(te(i,e,r,p),r=p+1):(te(i,e,p+1,a),a=p)}}function ae(i,e,r){const a=i[e];i[e]=i[r],i[r]=a}ke("FeaturePositionMap",H);class se{constructor(e,r){this.gl=e.gl,this.location=r}}class ue extends se{constructor(e,r){super(e,r),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class me extends se{constructor(e,r){super(e,r),this.current=[0,0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]&&e[3]===this.current[3]||(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}}class xe extends se{constructor(e,r){super(e,r),this.current=ut.transparent}set(e){e.r===this.current.r&&e.g===this.current.g&&e.b===this.current.b&&e.a===this.current.a||(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}}const _e=new Float32Array(16);function we(i){return[S(255*i.r,255*i.g),S(255*i.b,255*i.a)]}class ze{constructor(e,r,a){this.value=e,this.uniformNames=r.map(c=>`u_${c}`),this.type=a}setUniform(e,r,a){e.set(a.constantOr(this.value))}getBinding(e,r,a){return this.type==="color"?new xe(e,r):new ue(e,r)}}class We{constructor(e,r){this.uniformNames=r.map(a=>`u_${a}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=e.tlbr}setUniform(e,r,a,c){const u=c==="u_pattern_to"?this.patternTo:c==="u_pattern_from"?this.patternFrom:c==="u_pixel_ratio_to"?this.pixelRatioTo:c==="u_pixel_ratio_from"?this.pixelRatioFrom:null;u&&e.set(u)}getBinding(e,r,a){return a.substr(0,9)==="u_pattern"?new me(e,r):new ue(e,r)}}class Ke{constructor(e,r,a,c){this.expression=e,this.type=a,this.maxValue=0,this.paintVertexAttributes=r.map(u=>({name:`a_${u}`,type:"Float32",components:a==="color"?2:1,offset:0})),this.paintVertexArray=new c}populatePaintArray(e,r,a,c,u){const p=this.paintVertexArray.length,f=this.expression.evaluate(new Pt(0),r,{},c,[],u);this.paintVertexArray.resize(e),this._setPaintValue(p,e,f)}updatePaintArray(e,r,a,c){const u=this.expression.evaluate({zoom:0},a,c);this._setPaintValue(e,r,u)}_setPaintValue(e,r,a){if(this.type==="color"){const c=we(a);for(let u=e;u<r;u++)this.paintVertexArray.emplace(u,c[0],c[1])}else{for(let c=e;c<r;c++)this.paintVertexArray.emplace(c,a);this.maxValue=Math.max(this.maxValue,Math.abs(a))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Le{constructor(e,r,a,c,u,p){this.expression=e,this.uniformNames=r.map(f=>`u_${f}_t`),this.type=a,this.useIntegerZoom=c,this.zoom=u,this.maxValue=0,this.paintVertexAttributes=r.map(f=>({name:`a_${f}`,type:"Float32",components:a==="color"?4:2,offset:0})),this.paintVertexArray=new p}populatePaintArray(e,r,a,c,u){const p=this.expression.evaluate(new Pt(this.zoom),r,{},c,[],u),f=this.expression.evaluate(new Pt(this.zoom+1),r,{},c,[],u),_=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(_,e,p,f)}updatePaintArray(e,r,a,c){const u=this.expression.evaluate({zoom:this.zoom},a,c),p=this.expression.evaluate({zoom:this.zoom+1},a,c);this._setPaintValue(e,r,u,p)}_setPaintValue(e,r,a,c){if(this.type==="color"){const u=we(a),p=we(c);for(let f=e;f<r;f++)this.paintVertexArray.emplace(f,u[0],u[1],p[0],p[1])}else{for(let u=e;u<r;u++)this.paintVertexArray.emplace(u,a,c);this.maxValue=Math.max(this.maxValue,Math.abs(a),Math.abs(c))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,r){const a=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,c=pe(this.expression.interpolationFactor(a,this.zoom,this.zoom+1),0,1);e.set(c)}getBinding(e,r,a){return new ue(e,r)}}class mt{constructor(e,r,a,c,u,p){this.expression=e,this.type=r,this.useIntegerZoom=a,this.zoom=c,this.layerId=p,this.zoomInPaintVertexArray=new u,this.zoomOutPaintVertexArray=new u}populatePaintArray(e,r,a){const c=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(c,e,r.patterns&&r.patterns[this.layerId],a)}updatePaintArray(e,r,a,c,u){this._setPaintValues(e,r,a.patterns&&a.patterns[this.layerId],u)}_setPaintValues(e,r,a,c){if(!c||!a)return;const{min:u,mid:p,max:f}=a,_=c[u],v=c[p],w=c[f];if(_&&v&&w)for(let E=e;E<r;E++)this.zoomInPaintVertexArray.emplace(E,v.tl[0],v.tl[1],v.br[0],v.br[1],_.tl[0],_.tl[1],_.br[0],_.br[1],v.pixelRatio,_.pixelRatio),this.zoomOutPaintVertexArray.emplace(E,v.tl[0],v.tl[1],v.br[0],v.br[1],w.tl[0],w.tl[1],w.br[0],w.br[1],v.pixelRatio,w.pixelRatio)}upload(e){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,T.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,T.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class ft{constructor(e,r,a){this.binders={},this._buffers=[];const c=[];for(const u in e.paint._values){if(!a(u))continue;const p=e.paint.get(u);if(!(p instanceof Ki&&In(p.property.specification)))continue;const f=ht(u,e.type),_=p.value,v=p.property.specification.type,w=p.property.useIntegerZoom,E=p.property.specification["property-type"],P=E==="cross-faded"||E==="cross-faded-data-driven";if(_.kind==="constant")this.binders[u]=P?new We(_.value,f):new ze(_.value,f,v),c.push(`/u_${u}`);else if(_.kind==="source"||P){const k=wt(u,v,"source");this.binders[u]=P?new mt(_,v,w,r,k,e.id):new Ke(_,f,v,k),c.push(`/a_${u}`)}else{const k=wt(u,v,"composite");this.binders[u]=new Le(_,f,v,w,r,k),c.push(`/z_${u}`)}}this.cacheKey=c.sort().join("")}getMaxValue(e){const r=this.binders[e];return r instanceof Ke||r instanceof Le?r.maxValue:0}populatePaintArrays(e,r,a,c,u){for(const p in this.binders){const f=this.binders[p];(f instanceof Ke||f instanceof Le||f instanceof mt)&&f.populatePaintArray(e,r,a,c,u)}}setConstantPatternPositions(e,r){for(const a in this.binders){const c=this.binders[a];c instanceof We&&c.setConstantPatternPositions(e,r)}}updatePaintArrays(e,r,a,c,u){let p=!1;for(const f in e){const _=r.getPositions(f);for(const v of _){const w=a.feature(v.index);for(const E in this.binders){const P=this.binders[E];if((P instanceof Ke||P instanceof Le||P instanceof mt)&&P.expression.isStateDependent===!0){const k=c.paint.get(E);P.expression=k.value,P.updatePaintArray(v.start,v.end,w,e[f],u),p=!0}}}}return p}defines(){const e=[];for(const r in this.binders){const a=this.binders[r];(a instanceof ze||a instanceof We)&&e.push(...a.uniformNames.map(c=>`#define HAS_UNIFORM_${c}`))}return e}getBinderAttributes(){const e=[];for(const r in this.binders){const a=this.binders[r];if(a instanceof Ke||a instanceof Le)for(let c=0;c<a.paintVertexAttributes.length;c++)e.push(a.paintVertexAttributes[c].name);else if(a instanceof mt)for(let c=0;c<T.members.length;c++)e.push(T.members[c].name)}return e}getBinderUniforms(){const e=[];for(const r in this.binders){const a=this.binders[r];if(a instanceof ze||a instanceof We||a instanceof Le)for(const c of a.uniformNames)e.push(c)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,r){const a=[];for(const c in this.binders){const u=this.binders[c];if(u instanceof ze||u instanceof We||u instanceof Le){for(const p of u.uniformNames)if(r[p]){const f=u.getBinding(e,r[p],p);a.push({name:p,property:c,binding:f})}}}return a}setUniforms(e,r,a,c){for(const{name:u,property:p,binding:f}of r)this.binders[p].setUniform(f,c,a.get(p),u)}updatePaintBuffers(e){this._buffers=[];for(const r in this.binders){const a=this.binders[r];if(e&&a instanceof mt){const c=e.fromScale===2?a.zoomInPaintVertexBuffer:a.zoomOutPaintVertexBuffer;c&&this._buffers.push(c)}else(a instanceof Ke||a instanceof Le)&&a.paintVertexBuffer&&this._buffers.push(a.paintVertexBuffer)}}upload(e){for(const r in this.binders){const a=this.binders[r];(a instanceof Ke||a instanceof Le||a instanceof mt)&&a.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const r=this.binders[e];(r instanceof Ke||r instanceof Le||r instanceof mt)&&r.destroy()}}}class tt{constructor(e,r,a=()=>!0){this.programConfigurations={};for(const c of e)this.programConfigurations[c.id]=new ft(c,r,a);this.needsUpload=!1,this._featureMap=new H,this._bufferOffset=0}populatePaintArrays(e,r,a,c,u,p){for(const f in this.programConfigurations)this.programConfigurations[f].populatePaintArrays(e,r,c,u,p);r.id!==void 0&&this._featureMap.add(r.id,a,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,r,a,c){for(const u of a)this.needsUpload=this.programConfigurations[u.id].updatePaintArrays(e,this._featureMap,r,u,c)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function ht(i,e){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[i]||[i.replace(`${e}-`,"").replace(/-/g,"_")]}function wt(i,e,r){const a={color:{source:ra,composite:ro},number:{source:Za,composite:ra}},c=function(u){return{"line-pattern":{source:Dr,composite:Dr},"fill-pattern":{source:Dr,composite:Dr},"fill-extrusion-pattern":{source:Dr,composite:Dr}}[u]}(i);return c&&c[r]||a[e][r]}ke("ConstantBinder",ze),ke("CrossFadedConstantBinder",We),ke("SourceExpressionBinder",Ke),ke("CrossFadedCompositeBinder",mt),ke("CompositeExpressionBinder",Le),ke("ProgramConfiguration",ft,{omit:["_buffers"]}),ke("ProgramConfigurationSet",tt);var gt=8192;const ji=Math.pow(2,14)-1,qi=-ji-1;function ni(i){const e=gt/i.extent,r=i.loadGeometry();for(let a=0;a<r.length;a++){const c=r[a];for(let u=0;u<c.length;u++){const p=c[u],f=Math.round(p.x*e),_=Math.round(p.y*e);p.x=pe(f,qi,ji),p.y=pe(_,qi,ji),(f<p.x||f>p.x+1||_<p.y||_>p.y+1)&&dt("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function ki(i,e){return{type:i.type,id:i.id,properties:i.properties,geometry:e?ni(i):[]}}function _i(i,e,r,a,c){i.emplaceBack(2*e+(a+1)/2,2*r+(c+1)/2)}class Ji{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new aa,this.indexArray=new d,this.segments=new x,this.programConfigurations=new tt(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,a){const c=this.layers[0],u=[];let p=null,f=!1;c.type==="circle"&&(p=c.layout.get("circle-sort-key"),f=!p.isConstant());for(const{feature:_,id:v,index:w,sourceLayerIndex:E}of e){const P=this.layers[0]._featureFilter.needGeometry,k=ki(_,P);if(!this.layers[0]._featureFilter.filter(new Pt(this.zoom),k,a))continue;const L=f?p.evaluate(k,{},a):void 0,$={id:v,properties:_.properties,type:_.type,sourceLayerIndex:E,index:w,geometry:P?k.geometry:ni(_),patterns:{},sortKey:L};u.push($)}f&&u.sort((_,v)=>_.sortKey-v.sortKey);for(const _ of u){const{geometry:v,index:w,sourceLayerIndex:E}=_,P=e[w].feature;this.addFeature(_,v,w,a),r.featureIndex.insert(P,v,w,E,this.index)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,y),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,r,a,c){for(const u of r)for(const p of u){const f=p.x,_=p.y;if(f<0||f>=gt||_<0||_>=gt)continue;const v=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),w=v.vertexLength;_i(this.layoutVertexArray,f,_,-1,-1),_i(this.layoutVertexArray,f,_,1,-1),_i(this.layoutVertexArray,f,_,1,1),_i(this.layoutVertexArray,f,_,-1,1),this.indexArray.emplaceBack(w,w+1,w+2),this.indexArray.emplaceBack(w,w+3,w+2),v.vertexLength+=4,v.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,{},c)}}function Rr(i,e){for(let r=0;r<i.length;r++)if(Qi(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(Qi(i,e[r]))return!0;return!!_t(i,e)}function Ka(i,e,r){return!!Qi(i,e)||!!xi(e,i,r)}function qt(i,e){if(i.length===1)return cr(e,i[0]);for(let r=0;r<e.length;r++){const a=e[r];for(let c=0;c<a.length;c++)if(Qi(i,a[c]))return!0}for(let r=0;r<i.length;r++)if(cr(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(_t(i,e[r]))return!0;return!1}function Dt(i,e,r){if(i.length>1){if(_t(i,e))return!0;for(let a=0;a<e.length;a++)if(xi(e[a],i,r))return!0}for(let a=0;a<i.length;a++)if(xi(i[a],e,r))return!0;return!1}function _t(i,e){if(i.length===0||e.length===0)return!1;for(let r=0;r<i.length-1;r++){const a=i[r],c=i[r+1];for(let u=0;u<e.length-1;u++)if(yi(a,c,e[u],e[u+1]))return!0}return!1}function yi(i,e,r,a){return Qt(i,r,a)!==Qt(e,r,a)&&Qt(i,e,r)!==Qt(i,e,a)}function xi(i,e,r){const a=r*r;if(e.length===1)return i.distSqr(e[0])<a;for(let c=1;c<e.length;c++)if(Rt(i,e[c-1],e[c])<a)return!0;return!1}function Rt(i,e,r){const a=e.distSqr(r);if(a===0)return i.distSqr(e);const c=((i.x-e.x)*(r.x-e.x)+(i.y-e.y)*(r.y-e.y))/a;return i.distSqr(c<0?e:c>1?r:r.sub(e)._mult(c)._add(e))}function cr(i,e){let r,a,c,u=!1;for(let p=0;p<i.length;p++){r=i[p];for(let f=0,_=r.length-1;f<r.length;_=f++)a=r[f],c=r[_],a.y>e.y!=c.y>e.y&&e.x<(c.x-a.x)*(e.y-a.y)/(c.y-a.y)+a.x&&(u=!u)}return u}function Qi(i,e){let r=!1;for(let a=0,c=i.length-1;a<i.length;c=a++){const u=i[a],p=i[c];u.y>e.y!=p.y>e.y&&e.x<(p.x-u.x)*(e.y-u.y)/(p.y-u.y)+u.x&&(r=!r)}return r}function oo(i,e,r){const a=r[0],c=r[2];if(i.x<a.x&&e.x<a.x||i.x>c.x&&e.x>c.x||i.y<a.y&&e.y<a.y||i.y>c.y&&e.y>c.y)return!1;const u=Qt(i,e,r[0]);return u!==Qt(i,e,r[1])||u!==Qt(i,e,r[2])||u!==Qt(i,e,r[3])}function nn(i,e,r){const a=e.paint.get(i).value;return a.kind==="constant"?a.value:r.programConfigurations.get(e.id).getMaxValue(i)}function Ya(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function Ja(i,e,r,a,c){if(!e[0]&&!e[1])return i;const u=He.convert(e)._mult(c);r==="viewport"&&u._rotate(-a);const p=[];for(let f=0;f<i.length;f++)p.push(i[f].sub(u));return p}ke("CircleBucket",Ji,{omit:["layers"]});const sa=new Ii({"circle-sort-key":new Ze(le.layout_circle["circle-sort-key"])});var mc={paint:new Ii({"circle-radius":new Ze(le.paint_circle["circle-radius"]),"circle-color":new Ze(le.paint_circle["circle-color"]),"circle-blur":new Ze(le.paint_circle["circle-blur"]),"circle-opacity":new Ze(le.paint_circle["circle-opacity"]),"circle-translate":new Ue(le.paint_circle["circle-translate"]),"circle-translate-anchor":new Ue(le.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Ue(le.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Ue(le.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Ze(le.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Ze(le.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Ze(le.paint_circle["circle-stroke-opacity"])}),layout:sa},Ht=1e-6,Br=typeof Float32Array<"u"?Float32Array:Array;function fc(i){return i[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=1,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i}function eu(i,e,r){var a=e[0],c=e[1],u=e[2],p=e[3],f=e[4],_=e[5],v=e[6],w=e[7],E=e[8],P=e[9],k=e[10],L=e[11],$=e[12],N=e[13],J=e[14],ne=e[15],K=r[0],re=r[1],ge=r[2],fe=r[3];return i[0]=K*a+re*f+ge*E+fe*$,i[1]=K*c+re*_+ge*P+fe*N,i[2]=K*u+re*v+ge*k+fe*J,i[3]=K*p+re*w+ge*L+fe*ne,i[4]=(K=r[4])*a+(re=r[5])*f+(ge=r[6])*E+(fe=r[7])*$,i[5]=K*c+re*_+ge*P+fe*N,i[6]=K*u+re*v+ge*k+fe*J,i[7]=K*p+re*w+ge*L+fe*ne,i[8]=(K=r[8])*a+(re=r[9])*f+(ge=r[10])*E+(fe=r[11])*$,i[9]=K*c+re*_+ge*P+fe*N,i[10]=K*u+re*v+ge*k+fe*J,i[11]=K*p+re*w+ge*L+fe*ne,i[12]=(K=r[12])*a+(re=r[13])*f+(ge=r[14])*E+(fe=r[15])*$,i[13]=K*c+re*_+ge*P+fe*N,i[14]=K*u+re*v+ge*k+fe*J,i[15]=K*p+re*w+ge*L+fe*ne,i}Math.hypot||(Math.hypot=function(){for(var i=0,e=arguments.length;e--;)i+=arguments[e]*arguments[e];return Math.sqrt(i)});var lo,mm=eu;function _l(i,e,r){var a=e[0],c=e[1],u=e[2],p=e[3];return i[0]=r[0]*a+r[4]*c+r[8]*u+r[12]*p,i[1]=r[1]*a+r[5]*c+r[9]*u+r[13]*p,i[2]=r[2]*a+r[6]*c+r[10]*u+r[14]*p,i[3]=r[3]*a+r[7]*c+r[11]*u+r[15]*p,i}function tu(i,e){const r=_l([],[i.x,i.y,0,1],e);return new He(r[0]/r[3],r[1]/r[3])}lo=new Br(4),Br!=Float32Array&&(lo[0]=0,lo[1]=0,lo[2]=0,lo[3]=0);class iu extends Ji{}ke("HeatmapBucket",iu,{omit:["layers"]});var fm={paint:new Ii({"heatmap-radius":new Ze(le.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Ze(le.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Ue(le.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Zs(le.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Ue(le.paint_heatmap["heatmap-opacity"])})};function gc(i,{width:e,height:r},a,c){if(c){if(c instanceof Uint8ClampedArray)c=new Uint8Array(c.buffer);else if(c.length!==e*r*a)throw new RangeError(`mismatched image size. expected: ${c.length} but got: ${e*r*a}`)}else c=new Uint8Array(e*r*a);return i.width=e,i.height=r,i.data=c,i}function ru(i,{width:e,height:r},a){if(e===i.width&&r===i.height)return;const c=gc({},{width:e,height:r},a);_c(i,c,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,e),height:Math.min(i.height,r)},a),i.width=e,i.height=r,i.data=c.data}function _c(i,e,r,a,c,u){if(c.width===0||c.height===0)return e;if(c.width>i.width||c.height>i.height||r.x>i.width-c.width||r.y>i.height-c.height)throw new RangeError("out of range source coordinates for image copy");if(c.width>e.width||c.height>e.height||a.x>e.width-c.width||a.y>e.height-c.height)throw new RangeError("out of range destination coordinates for image copy");const p=i.data,f=e.data;if(p===f)throw new Error("srcData equals dstData, so image is already copied");for(let _=0;_<c.height;_++){const v=((r.y+_)*i.width+r.x)*u,w=((a.y+_)*e.width+a.x)*u;for(let E=0;E<c.width*u;E++)f[w+E]=p[v+E]}return e}class co{constructor(e,r){gc(this,e,1,r)}resize(e){ru(this,e,1)}clone(){return new co({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,a,c,u){_c(e,r,a,c,u,1)}}class er{constructor(e,r){gc(this,e,4,r)}resize(e){ru(this,e,4)}replace(e,r){r?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new er({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,a,c,u){_c(e,r,a,c,u,4)}}function nu(i){const e={},r=i.resolution||256,a=i.clips?i.clips.length:1,c=i.image||new er({width:r,height:a});if(Math.log(r)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${r}`);const u=(p,f,_)=>{e[i.evaluationKey]=_;const v=i.expression.evaluate(e);c.data[p+f+0]=Math.floor(255*v.r/v.a),c.data[p+f+1]=Math.floor(255*v.g/v.a),c.data[p+f+2]=Math.floor(255*v.b/v.a),c.data[p+f+3]=Math.floor(255*v.a)};if(i.clips)for(let p=0,f=0;p<a;++p,f+=4*r)for(let _=0,v=0;_<r;_++,v+=4){const w=_/(r-1),{start:E,end:P}=i.clips[p];u(f,v,E*(1-w)+P*w)}else for(let p=0,f=0;p<r;p++,f+=4)u(0,f,p/(r-1));return c}ke("AlphaImage",co),ke("RGBAImage",er);var gm={paint:new Ii({"hillshade-illumination-direction":new Ue(le.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new Ue(le.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Ue(le.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Ue(le.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Ue(le.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Ue(le.paint_hillshade["hillshade-accent-color"])})};const _m=jt([{name:"a_pos",components:2,type:"Int16"}],4),{members:ym}=_m;var ho={};function yl(i,e,r){r=r||2;var a,c,u,p,f,_,v,w=e&&e.length,E=w?e[0]*r:i.length,P=au(i,0,E,r,!0),k=[];if(!P||P.next===P.prev)return k;if(w&&(P=function($,N,J,ne){var K,re,ge,fe=[];for(K=0,re=N.length;K<re;K++)(ge=au($,N[K]*ne,K<re-1?N[K+1]*ne:$.length,ne,!1))===ge.next&&(ge.steiner=!0),fe.push(Im(ge));for(fe.sort(Tm),K=0;K<fe.length;K++)J=Sm(fe[K],J);return J}(i,e,P,r)),i.length>80*r){a=u=i[0],c=p=i[1];for(var L=r;L<E;L+=r)(f=i[L])<a&&(a=f),(_=i[L+1])<c&&(c=_),f>u&&(u=f),_>p&&(p=_);v=(v=Math.max(u-a,p-c))!==0?32767/v:0}return uo(P,k,r,a,c,v,0),k}function au(i,e,r,a,c){var u,p;if(c===vc(i,e,r,a)>0)for(u=e;u<r;u+=a)p=lu(u,i[u],i[u+1],p);else for(u=r-a;u>=e;u-=a)p=lu(u,i[u],i[u+1],p);return p&&xl(p,p.next)&&(mo(p),p=p.next),p}function oa(i,e){if(!i)return i;e||(e=i);var r,a=i;do if(r=!1,a.steiner||!xl(a,a.next)&&Gt(a.prev,a,a.next)!==0)a=a.next;else{if(mo(a),(a=e=a.prev)===a.next)break;r=!0}while(r||a!==e);return e}function uo(i,e,r,a,c,u,p){if(i){!p&&u&&function(w,E,P,k){var L=w;do L.z===0&&(L.z=yc(L.x,L.y,E,P,k)),L.prevZ=L.prev,L.nextZ=L.next,L=L.next;while(L!==w);L.prevZ.nextZ=null,L.prevZ=null,function($){var N,J,ne,K,re,ge,fe,De,Fe=1;do{for(J=$,$=null,re=null,ge=0;J;){for(ge++,ne=J,fe=0,N=0;N<Fe&&(fe++,ne=ne.nextZ);N++);for(De=Fe;fe>0||De>0&&ne;)fe!==0&&(De===0||!ne||J.z<=ne.z)?(K=J,J=J.nextZ,fe--):(K=ne,ne=ne.nextZ,De--),re?re.nextZ=K:$=K,K.prevZ=re,re=K;J=ne}re.nextZ=null,Fe*=2}while(ge>1)}(L)}(i,a,c,u);for(var f,_,v=i;i.prev!==i.next;)if(f=i.prev,_=i.next,u?vm(i,a,c,u):xm(i))e.push(f.i/r|0),e.push(i.i/r|0),e.push(_.i/r|0),mo(i),i=_.next,v=_.next;else if((i=_)===v){p?p===1?uo(i=bm(oa(i),e,r),e,r,a,c,u,2):p===2&&wm(i,e,r,a,c,u):uo(oa(i),e,r,a,c,u,1);break}}}function xm(i){var e=i.prev,r=i,a=i.next;if(Gt(e,r,a)>=0)return!1;for(var c=e.x,u=r.x,p=a.x,f=e.y,_=r.y,v=a.y,w=c<u?c<p?c:p:u<p?u:p,E=f<_?f<v?f:v:_<v?_:v,P=c>u?c>p?c:p:u>p?u:p,k=f>_?f>v?f:v:_>v?_:v,L=a.next;L!==e;){if(L.x>=w&&L.x<=P&&L.y>=E&&L.y<=k&&Qa(c,f,u,_,p,v,L.x,L.y)&&Gt(L.prev,L,L.next)>=0)return!1;L=L.next}return!0}function vm(i,e,r,a){var c=i.prev,u=i,p=i.next;if(Gt(c,u,p)>=0)return!1;for(var f=c.x,_=u.x,v=p.x,w=c.y,E=u.y,P=p.y,k=f<_?f<v?f:v:_<v?_:v,L=w<E?w<P?w:P:E<P?E:P,$=f>_?f>v?f:v:_>v?_:v,N=w>E?w>P?w:P:E>P?E:P,J=yc(k,L,e,r,a),ne=yc($,N,e,r,a),K=i.prevZ,re=i.nextZ;K&&K.z>=J&&re&&re.z<=ne;){if(K.x>=k&&K.x<=$&&K.y>=L&&K.y<=N&&K!==c&&K!==p&&Qa(f,w,_,E,v,P,K.x,K.y)&&Gt(K.prev,K,K.next)>=0||(K=K.prevZ,re.x>=k&&re.x<=$&&re.y>=L&&re.y<=N&&re!==c&&re!==p&&Qa(f,w,_,E,v,P,re.x,re.y)&&Gt(re.prev,re,re.next)>=0))return!1;re=re.nextZ}for(;K&&K.z>=J;){if(K.x>=k&&K.x<=$&&K.y>=L&&K.y<=N&&K!==c&&K!==p&&Qa(f,w,_,E,v,P,K.x,K.y)&&Gt(K.prev,K,K.next)>=0)return!1;K=K.prevZ}for(;re&&re.z<=ne;){if(re.x>=k&&re.x<=$&&re.y>=L&&re.y<=N&&re!==c&&re!==p&&Qa(f,w,_,E,v,P,re.x,re.y)&&Gt(re.prev,re,re.next)>=0)return!1;re=re.nextZ}return!0}function bm(i,e,r){var a=i;do{var c=a.prev,u=a.next.next;!xl(c,u)&&su(c,a,a.next,u)&&po(c,u)&&po(u,c)&&(e.push(c.i/r|0),e.push(a.i/r|0),e.push(u.i/r|0),mo(a),mo(a.next),a=i=u),a=a.next}while(a!==i);return oa(a)}function wm(i,e,r,a,c,u){var p=i;do{for(var f=p.next.next;f!==p.prev;){if(p.i!==f.i&&Am(p,f)){var _=ou(p,f);return p=oa(p,p.next),_=oa(_,_.next),uo(p,e,r,a,c,u,0),void uo(_,e,r,a,c,u,0)}f=f.next}p=p.next}while(p!==i)}function Tm(i,e){return i.x-e.x}function Sm(i,e){var r=function(c,u){var p,f=u,_=c.x,v=c.y,w=-1/0;do{if(v<=f.y&&v>=f.next.y&&f.next.y!==f.y){var E=f.x+(v-f.y)*(f.next.x-f.x)/(f.next.y-f.y);if(E<=_&&E>w&&(w=E,p=f.x<f.next.x?f:f.next,E===_))return p}f=f.next}while(f!==u);if(!p)return null;var P,k=p,L=p.x,$=p.y,N=1/0;f=p;do _>=f.x&&f.x>=L&&_!==f.x&&Qa(v<$?_:w,v,L,$,v<$?w:_,v,f.x,f.y)&&(P=Math.abs(v-f.y)/(_-f.x),po(f,c)&&(P<N||P===N&&(f.x>p.x||f.x===p.x&&Em(p,f)))&&(p=f,N=P)),f=f.next;while(f!==k);return p}(i,e);if(!r)return e;var a=ou(r,i);return oa(a,a.next),oa(r,r.next)}function Em(i,e){return Gt(i.prev,i,e.prev)<0&&Gt(e.next,i,i.next)<0}function yc(i,e,r,a,c){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-r)*c|0)|i<<8))|i<<4))|i<<2))|i<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-a)*c|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Im(i){var e=i,r=i;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==i);return r}function Qa(i,e,r,a,c,u,p,f){return(c-p)*(e-f)>=(i-p)*(u-f)&&(i-p)*(a-f)>=(r-p)*(e-f)&&(r-p)*(u-f)>=(c-p)*(a-f)}function Am(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!function(r,a){var c=r;do{if(c.i!==r.i&&c.next.i!==r.i&&c.i!==a.i&&c.next.i!==a.i&&su(c,c.next,r,a))return!0;c=c.next}while(c!==r);return!1}(i,e)&&(po(i,e)&&po(e,i)&&function(r,a){var c=r,u=!1,p=(r.x+a.x)/2,f=(r.y+a.y)/2;do c.y>f!=c.next.y>f&&c.next.y!==c.y&&p<(c.next.x-c.x)*(f-c.y)/(c.next.y-c.y)+c.x&&(u=!u),c=c.next;while(c!==r);return u}(i,e)&&(Gt(i.prev,i,e.prev)||Gt(i,e.prev,e))||xl(i,e)&&Gt(i.prev,i,i.next)>0&&Gt(e.prev,e,e.next)>0)}function Gt(i,e,r){return(e.y-i.y)*(r.x-e.x)-(e.x-i.x)*(r.y-e.y)}function xl(i,e){return i.x===e.x&&i.y===e.y}function su(i,e,r,a){var c=bl(Gt(i,e,r)),u=bl(Gt(i,e,a)),p=bl(Gt(r,a,i)),f=bl(Gt(r,a,e));return c!==u&&p!==f||!(c!==0||!vl(i,r,e))||!(u!==0||!vl(i,a,e))||!(p!==0||!vl(r,i,a))||!(f!==0||!vl(r,e,a))}function vl(i,e,r){return e.x<=Math.max(i.x,r.x)&&e.x>=Math.min(i.x,r.x)&&e.y<=Math.max(i.y,r.y)&&e.y>=Math.min(i.y,r.y)}function bl(i){return i>0?1:i<0?-1:0}function po(i,e){return Gt(i.prev,i,i.next)<0?Gt(i,e,i.next)>=0&&Gt(i,i.prev,e)>=0:Gt(i,e,i.prev)<0||Gt(i,i.next,e)<0}function ou(i,e){var r=new xc(i.i,i.x,i.y),a=new xc(e.i,e.x,e.y),c=i.next,u=e.prev;return i.next=e,e.prev=i,r.next=c,c.prev=r,a.next=r,r.prev=a,u.next=a,a.prev=u,a}function lu(i,e,r,a){var c=new xc(i,e,r);return a?(c.next=a.next,c.prev=a,a.next.prev=c,a.next=c):(c.prev=c,c.next=c),c}function mo(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function xc(i,e,r){this.i=i,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function vc(i,e,r,a){for(var c=0,u=e,p=r-a;u<r;u+=a)c+=(i[p]-i[u])*(i[u+1]+i[p+1]),p=u;return c}function Cm(i,e,r,a,c){cu(i,e,r||0,a||i.length-1,c||Mm)}function cu(i,e,r,a,c){for(;a>r;){if(a-r>600){var u=a-r+1,p=e-r+1,f=Math.log(u),_=.5*Math.exp(2*f/3),v=.5*Math.sqrt(f*_*(u-_)/u)*(p-u/2<0?-1:1);cu(i,e,Math.max(r,Math.floor(e-p*_/u+v)),Math.min(a,Math.floor(e+(u-p)*_/u+v)),c)}var w=i[e],E=r,P=a;for(fo(i,r,e),c(i[a],w)>0&&fo(i,r,a);E<P;){for(fo(i,E,P),E++,P--;c(i[E],w)<0;)E++;for(;c(i[P],w)>0;)P--}c(i[r],w)===0?fo(i,r,P):fo(i,++P,a),P<=e&&(r=P+1),e<=P&&(a=P-1)}}function fo(i,e,r){var a=i[e];i[e]=i[r],i[r]=a}function Mm(i,e){return i<e?-1:i>e?1:0}function bc(i,e){const r=i.length;if(r<=1)return[i];const a=[];let c,u;for(let p=0;p<r;p++){const f=us(i[p]);f!==0&&(i[p].area=Math.abs(f),u===void 0&&(u=f<0),u===f<0?(c&&a.push(c),c=[i[p]]):c.push(i[p]))}if(c&&a.push(c),e>1)for(let p=0;p<a.length;p++)a[p].length<=e||(Cm(a[p],e,1,a[p].length-1,Pm),a[p]=a[p].slice(0,e));return a}function Pm(i,e){return e.area-i.area}function wc(i,e,r){const a=r.patternDependencies;let c=!1;for(const u of e){const p=u.paint.get(`${i}-pattern`);p.isConstant()||(c=!0);const f=p.constantOr(null);f&&(c=!0,a[f.to]=!0,a[f.from]=!0)}return c}function Tc(i,e,r,a,c){const u=c.patternDependencies;for(const p of e){const f=p.paint.get(`${i}-pattern`).value;if(f.kind!=="constant"){let _=f.evaluate({zoom:a-1},r,{},c.availableImages),v=f.evaluate({zoom:a},r,{},c.availableImages),w=f.evaluate({zoom:a+1},r,{},c.availableImages);_=_&&_.name?_.name:_,v=v&&v.name?v.name:v,w=w&&w.name?w.name:w,u[_]=!0,u[v]=!0,u[w]=!0,r.patterns[p.id]={min:_,mid:v,max:w}}}return r}({get exports(){return ho},set exports(i){ho=i}}).exports=yl,ho.default=yl,yl.deviation=function(i,e,r,a){var c=e&&e.length,u=Math.abs(vc(i,0,c?e[0]*r:i.length,r));if(c)for(var p=0,f=e.length;p<f;p++)u-=Math.abs(vc(i,e[p]*r,p<f-1?e[p+1]*r:i.length,r));var _=0;for(p=0;p<a.length;p+=3){var v=a[p]*r,w=a[p+1]*r,E=a[p+2]*r;_+=Math.abs((i[v]-i[E])*(i[w+1]-i[v+1])-(i[v]-i[w])*(i[E+1]-i[v+1]))}return u===0&&_===0?0:Math.abs((_-u)/u)},yl.flatten=function(i){for(var e=i[0][0].length,r={vertices:[],holes:[],dimensions:e},a=0,c=0;c<i.length;c++){for(var u=0;u<i[c].length;u++)for(var p=0;p<e;p++)r.vertices.push(i[c][u][p]);c>0&&r.holes.push(a+=i[c-1].length)}return r};class Sc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new uc,this.indexArray=new d,this.indexArray2=new m,this.programConfigurations=new tt(e.layers,e.zoom),this.segments=new x,this.segments2=new x,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,a){this.hasPattern=wc("fill",this.layers,r);const c=this.layers[0].layout.get("fill-sort-key"),u=!c.isConstant(),p=[];for(const{feature:f,id:_,index:v,sourceLayerIndex:w}of e){const E=this.layers[0]._featureFilter.needGeometry,P=ki(f,E);if(!this.layers[0]._featureFilter.filter(new Pt(this.zoom),P,a))continue;const k=u?c.evaluate(P,{},a,r.availableImages):void 0,L={id:_,properties:f.properties,type:f.type,sourceLayerIndex:w,index:v,geometry:E?P.geometry:ni(f),patterns:{},sortKey:k};p.push(L)}u&&p.sort((f,_)=>f.sortKey-_.sortKey);for(const f of p){const{geometry:_,index:v,sourceLayerIndex:w}=f;if(this.hasPattern){const E=Tc("fill",this.layers,f,this.zoom,r);this.patternFeatures.push(E)}else this.addFeature(f,_,v,a,{});r.featureIndex.insert(e[v].feature,_,v,w,this.index)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}addFeatures(e,r,a){for(const c of this.patternFeatures)this.addFeature(c,c.geometry,c.index,r,a)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ym),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,r,a,c,u){for(const p of bc(r,500)){let f=0;for(const k of p)f+=k.length;const _=this.segments.prepareSegment(f,this.layoutVertexArray,this.indexArray),v=_.vertexLength,w=[],E=[];for(const k of p){if(k.length===0)continue;k!==p[0]&&E.push(w.length/2);const L=this.segments2.prepareSegment(k.length,this.layoutVertexArray,this.indexArray2),$=L.vertexLength;this.layoutVertexArray.emplaceBack(k[0].x,k[0].y),this.indexArray2.emplaceBack($+k.length-1,$),w.push(k[0].x),w.push(k[0].y);for(let N=1;N<k.length;N++)this.layoutVertexArray.emplaceBack(k[N].x,k[N].y),this.indexArray2.emplaceBack($+N-1,$+N),w.push(k[N].x),w.push(k[N].y);L.vertexLength+=k.length,L.primitiveLength+=k.length}const P=ho(w,E);for(let k=0;k<P.length;k+=3)this.indexArray.emplaceBack(v+P[k],v+P[k+1],v+P[k+2]);_.vertexLength+=f,_.primitiveLength+=P.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,u,c)}}ke("FillBucket",Sc,{omit:["layers","patternFeatures"]});const km=new Ii({"fill-sort-key":new Ze(le.layout_fill["fill-sort-key"])});var zm={paint:new Ii({"fill-antialias":new Ue(le.paint_fill["fill-antialias"]),"fill-opacity":new Ze(le.paint_fill["fill-opacity"]),"fill-color":new Ze(le.paint_fill["fill-color"]),"fill-outline-color":new Ze(le.paint_fill["fill-outline-color"]),"fill-translate":new Ue(le.paint_fill["fill-translate"]),"fill-translate-anchor":new Ue(le.paint_fill["fill-translate-anchor"]),"fill-pattern":new Ln(le.paint_fill["fill-pattern"])}),layout:km};const Lm=jt([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Dm=jt([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Rm}=Lm;var Bn={},Bm=He,hu=es;function es(i,e,r,a,c){this.properties={},this.extent=r,this.type=0,this._pbf=i,this._geometry=-1,this._keys=a,this._values=c,i.readFields(Fm,this,e)}function Fm(i,e,r){i==1?e.id=r.readVarint():i==2?function(a,c){for(var u=a.readVarint()+a.pos;a.pos<u;){var p=c._keys[a.readVarint()],f=c._values[a.readVarint()];c.properties[p]=f}}(r,e):i==3?e.type=r.readVarint():i==4&&(e._geometry=r.pos)}function Om(i){for(var e,r,a=0,c=0,u=i.length,p=u-1;c<u;p=c++)a+=((r=i[p]).x-(e=i[c]).x)*(e.y+r.y);return a}es.types=["Unknown","Point","LineString","Polygon"],es.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var e,r=i.readVarint()+i.pos,a=1,c=0,u=0,p=0,f=[];i.pos<r;){if(c<=0){var _=i.readVarint();a=7&_,c=_>>3}if(c--,a===1||a===2)u+=i.readSVarint(),p+=i.readSVarint(),a===1&&(e&&f.push(e),e=[]),e.push(new Bm(u,p));else{if(a!==7)throw new Error("unknown command "+a);e&&e.push(e[0].clone())}}return e&&f.push(e),f},es.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var e=i.readVarint()+i.pos,r=1,a=0,c=0,u=0,p=1/0,f=-1/0,_=1/0,v=-1/0;i.pos<e;){if(a<=0){var w=i.readVarint();r=7&w,a=w>>3}if(a--,r===1||r===2)(c+=i.readSVarint())<p&&(p=c),c>f&&(f=c),(u+=i.readSVarint())<_&&(_=u),u>v&&(v=u);else if(r!==7)throw new Error("unknown command "+r)}return[p,_,f,v]},es.prototype.toGeoJSON=function(i,e,r){var a,c,u=this.extent*Math.pow(2,r),p=this.extent*i,f=this.extent*e,_=this.loadGeometry(),v=es.types[this.type];function w(k){for(var L=0;L<k.length;L++){var $=k[L];k[L]=[360*($.x+p)/u-180,360/Math.PI*Math.atan(Math.exp((180-360*($.y+f)/u)*Math.PI/180))-90]}}switch(this.type){case 1:var E=[];for(a=0;a<_.length;a++)E[a]=_[a][0];w(_=E);break;case 2:for(a=0;a<_.length;a++)w(_[a]);break;case 3:for(_=function(k){var L=k.length;if(L<=1)return[k];for(var $,N,J=[],ne=0;ne<L;ne++){var K=Om(k[ne]);K!==0&&(N===void 0&&(N=K<0),N===K<0?($&&J.push($),$=[k[ne]]):$.push(k[ne]))}return $&&J.push($),J}(_),a=0;a<_.length;a++)for(c=0;c<_[a].length;c++)w(_[a][c])}_.length===1?_=_[0]:v="Multi"+v;var P={type:"Feature",geometry:{type:v,coordinates:_},properties:this.properties};return"id"in this&&(P.id=this.id),P};var Um=hu,uu=du;function du(i,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=i,this._keys=[],this._values=[],this._features=[],i.readFields(Vm,this,e),this.length=this._features.length}function Vm(i,e,r){i===15?e.version=r.readVarint():i===1?e.name=r.readString():i===5?e.extent=r.readVarint():i===2?e._features.push(r.pos):i===3?e._keys.push(r.readString()):i===4&&e._values.push(function(a){for(var c=null,u=a.readVarint()+a.pos;a.pos<u;){var p=a.readVarint()>>3;c=p===1?a.readString():p===2?a.readFloat():p===3?a.readDouble():p===4?a.readVarint64():p===5?a.readVarint():p===6?a.readSVarint():p===7?a.readBoolean():null}return c}(r))}du.prototype.feature=function(i){if(i<0||i>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[i];var e=this._pbf.readVarint()+this._pbf.pos;return new Um(this._pbf,e,this.extent,this._keys,this._values)};var Nm=uu;function $m(i,e,r){if(i===3){var a=new Nm(r,r.readVarint()+r.pos);a.length&&(e[a.name]=a)}}Bn.VectorTile=function(i,e){this.layers=i.readFields($m,{},e)},Bn.VectorTileFeature=hu,Bn.VectorTileLayer=uu;const Gm=Bn.VectorTileFeature.types,Ec=Math.pow(2,13);function go(i,e,r,a,c,u,p,f){i.emplaceBack(e,r,2*Math.floor(a*Ec)+p,c*Ec*2,u*Ec*2,Math.round(f))}class Ic{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new dc,this.centroidVertexArray=new so,this.indexArray=new d,this.programConfigurations=new tt(e.layers,e.zoom),this.segments=new x,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,a){this.features=[],this.hasPattern=wc("fill-extrusion",this.layers,r);for(const{feature:c,id:u,index:p,sourceLayerIndex:f}of e){const _=this.layers[0]._featureFilter.needGeometry,v=ki(c,_);if(!this.layers[0]._featureFilter.filter(new Pt(this.zoom),v,a))continue;const w={id:u,sourceLayerIndex:f,index:p,geometry:_?v.geometry:ni(c),properties:c.properties,type:c.type,patterns:{}};this.hasPattern?this.features.push(Tc("fill-extrusion",this.layers,w,this.zoom,r)):this.addFeature(w,w.geometry,p,a,{}),r.featureIndex.insert(c,w.geometry,p,f,this.index,!0)}}addFeatures(e,r,a){for(const c of this.features){const{geometry:u}=c;this.addFeature(c,u,c.index,r,a)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Rm),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Dm.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,r,a,c,u){const p={x:0,y:0,vertexCount:0};for(const f of bc(r,500)){let _=0;for(const L of f)_+=L.length;let v=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const L of f){if(L.length===0||qm(L))continue;let $=0;for(let N=0;N<L.length;N++){const J=L[N];if(N>=1){const ne=L[N-1];if(!jm(J,ne)){v.vertexLength+4>x.MAX_VERTEX_ARRAY_LENGTH&&(v=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const K=J.sub(ne)._perp()._unit(),re=ne.dist(J);$+re>32768&&($=0),go(this.layoutVertexArray,J.x,J.y,K.x,K.y,0,0,$),go(this.layoutVertexArray,J.x,J.y,K.x,K.y,0,1,$),p.x+=2*J.x,p.y+=2*J.y,p.vertexCount+=2,$+=re,go(this.layoutVertexArray,ne.x,ne.y,K.x,K.y,0,0,$),go(this.layoutVertexArray,ne.x,ne.y,K.x,K.y,0,1,$),p.x+=2*ne.x,p.y+=2*ne.y,p.vertexCount+=2;const ge=v.vertexLength;this.indexArray.emplaceBack(ge,ge+2,ge+1),this.indexArray.emplaceBack(ge+1,ge+2,ge+3),v.vertexLength+=4,v.primitiveLength+=2}}}}if(v.vertexLength+_>x.MAX_VERTEX_ARRAY_LENGTH&&(v=this.segments.prepareSegment(_,this.layoutVertexArray,this.indexArray)),Gm[e.type]!=="Polygon")continue;const w=[],E=[],P=v.vertexLength;for(const L of f)if(L.length!==0){L!==f[0]&&E.push(w.length/2);for(let $=0;$<L.length;$++){const N=L[$];go(this.layoutVertexArray,N.x,N.y,0,0,1,1,0),p.x+=N.x,p.y+=N.y,p.vertexCount+=1,w.push(N.x),w.push(N.y)}}const k=ho(w,E);for(let L=0;L<k.length;L+=3)this.indexArray.emplaceBack(P+k[L],P+k[L+2],P+k[L+1]);v.primitiveLength+=k.length/3,v.vertexLength+=_}for(let f=0;f<p.vertexCount;f++)this.centroidVertexArray.emplaceBack(Math.floor(p.x/p.vertexCount),Math.floor(p.y/p.vertexCount));this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,u,c)}}function jm(i,e){return i.x===e.x&&(i.x<0||i.x>gt)||i.y===e.y&&(i.y<0||i.y>gt)}function qm(i){return i.every(e=>e.x<0)||i.every(e=>e.x>gt)||i.every(e=>e.y<0)||i.every(e=>e.y>gt)}ke("FillExtrusionBucket",Ic,{omit:["layers","features"]});var Zm={paint:new Ii({"fill-extrusion-opacity":new Ue(le["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Ze(le["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Ue(le["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Ue(le["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Ln(le["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Ze(le["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Ze(le["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Ue(le["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function _o(i,e){return i.x*e.x+i.y*e.y}function pu(i,e){if(i.length===1){let r=0;const a=e[r++];let c;for(;!c||a.equals(c);)if(c=e[r++],!c)return 1/0;for(;r<e.length;r++){const u=e[r],p=i[0],f=c.sub(a),_=u.sub(a),v=p.sub(a),w=_o(f,f),E=_o(f,_),P=_o(_,_),k=_o(v,f),L=_o(v,_),$=w*P-E*E,N=(P*k-E*L)/$,J=(w*L-E*k)/$,ne=a.z*(1-N-J)+c.z*N+u.z*J;if(isFinite(ne))return ne}return 1/0}{let r=1/0;for(const a of e)r=Math.min(r,a.z);return r}}const Xm=jt([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:Wm}=Xm,Hm=jt([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:Km}=Hm,Ym=Bn.VectorTileFeature.types,Jm=Math.cos(Math.PI/180*37.5),mu=Math.pow(2,14)/.5;class Ac{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(r=>{this.gradients[r.id]={}}),this.layoutVertexArray=new gl,this.layoutVertexArray2=new pc,this.indexArray=new d,this.programConfigurations=new tt(e.layers,e.zoom),this.segments=new x,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,a){this.hasPattern=wc("line",this.layers,r);const c=this.layers[0].layout.get("line-sort-key"),u=!c.isConstant(),p=[];for(const{feature:f,id:_,index:v,sourceLayerIndex:w}of e){const E=this.layers[0]._featureFilter.needGeometry,P=ki(f,E);if(!this.layers[0]._featureFilter.filter(new Pt(this.zoom),P,a))continue;const k=u?c.evaluate(P,{},a):void 0,L={id:_,properties:f.properties,type:f.type,sourceLayerIndex:w,index:v,geometry:E?P.geometry:ni(f),patterns:{},sortKey:k};p.push(L)}u&&p.sort((f,_)=>f.sortKey-_.sortKey);for(const f of p){const{geometry:_,index:v,sourceLayerIndex:w}=f;if(this.hasPattern){const E=Tc("line",this.layers,f,this.zoom,r);this.patternFeatures.push(E)}else this.addFeature(f,_,v,a,{});r.featureIndex.insert(e[v].feature,_,v,w,this.index)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}addFeatures(e,r,a){for(const c of this.patternFeatures)this.addFeature(c,c.geometry,c.index,r,a)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Km)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Wm),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,r,a,c,u){const p=this.layers[0].layout,f=p.get("line-join").evaluate(e,{}),_=p.get("line-cap"),v=p.get("line-miter-limit"),w=p.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const E of r)this.addLine(E,e,f,_,v,w);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,u,c)}addLine(e,r,a,c,u,p){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let J=0;J<e.length-1;J++)this.totalDistance+=e[J].dist(e[J+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const f=Ym[r.type]==="Polygon";let _=e.length;for(;_>=2&&e[_-1].equals(e[_-2]);)_--;let v=0;for(;v<_-1&&e[v].equals(e[v+1]);)v++;if(_<(f?3:2))return;a==="bevel"&&(u=1.05);const w=this.overscaling<=16?122880/(512*this.overscaling):0,E=this.segments.prepareSegment(10*_,this.layoutVertexArray,this.indexArray);let P,k,L,$,N;this.e1=this.e2=-1,f&&(P=e[_-2],N=e[v].sub(P)._unit()._perp());for(let J=v;J<_;J++){if(L=J===_-1?f?e[v+1]:void 0:e[J+1],L&&e[J].equals(L))continue;N&&($=N),P&&(k=P),P=e[J],N=L?L.sub(P)._unit()._perp():$,$=$||N;let ne=$.add(N);ne.x===0&&ne.y===0||ne._unit();const K=$.x*N.x+$.y*N.y,re=ne.x*N.x+ne.y*N.y,ge=re!==0?1/re:1/0,fe=2*Math.sqrt(2-2*re),De=re<Jm&&k&&L,Fe=$.x*N.y-$.y*N.x>0;if(De&&J>v){const Te=P.dist(k);if(Te>2*w){const Pe=P.sub(P.sub(k)._mult(w/Te)._round());this.updateDistance(k,Pe),this.addCurrentVertex(Pe,$,0,0,E),k=Pe}}const Me=k&&L;let Ie=Me?a:f?"butt":c;if(Me&&Ie==="round"&&(ge<p?Ie="miter":ge<=2&&(Ie="fakeround")),Ie==="miter"&&ge>u&&(Ie="bevel"),Ie==="bevel"&&(ge>2&&(Ie="flipbevel"),ge<u&&(Ie="miter")),k&&this.updateDistance(k,P),Ie==="miter")ne._mult(ge),this.addCurrentVertex(P,ne,0,0,E);else if(Ie==="flipbevel"){if(ge>100)ne=N.mult(-1);else{const Te=ge*$.add(N).mag()/$.sub(N).mag();ne._perp()._mult(Te*(Fe?-1:1))}this.addCurrentVertex(P,ne,0,0,E),this.addCurrentVertex(P,ne.mult(-1),0,0,E)}else if(Ie==="bevel"||Ie==="fakeround"){const Te=-Math.sqrt(ge*ge-1),Pe=Fe?Te:0,Ce=Fe?0:Te;if(k&&this.addCurrentVertex(P,$,Pe,Ce,E),Ie==="fakeround"){const be=Math.round(180*fe/Math.PI/20);for(let $e=1;$e<be;$e++){let Ve=$e/be;if(Ve!==.5){const kt=Ve-.5;Ve+=Ve*kt*(Ve-1)*((1.0904+K*(K*(3.55645-1.43519*K)-3.2452))*kt*kt+(.848013+K*(.215638*K-1.06021)))}const it=N.sub($)._mult(Ve)._add($)._unit()._mult(Fe?-1:1);this.addHalfVertex(P,it.x,it.y,!1,Fe,0,E)}}L&&this.addCurrentVertex(P,N,-Pe,-Ce,E)}else if(Ie==="butt")this.addCurrentVertex(P,ne,0,0,E);else if(Ie==="square"){const Te=k?1:-1;this.addCurrentVertex(P,ne,Te,Te,E)}else Ie==="round"&&(k&&(this.addCurrentVertex(P,$,0,0,E),this.addCurrentVertex(P,$,1,1,E,!0)),L&&(this.addCurrentVertex(P,N,-1,-1,E,!0),this.addCurrentVertex(P,N,0,0,E)));if(De&&J<_-1){const Te=P.dist(L);if(Te>2*w){const Pe=P.add(L.sub(P)._mult(w/Te)._round());this.updateDistance(P,Pe),this.addCurrentVertex(Pe,N,0,0,E),P=Pe}}}}addCurrentVertex(e,r,a,c,u,p=!1){const f=r.y*c-r.x,_=-r.y-r.x*c;this.addHalfVertex(e,r.x+r.y*a,r.y-r.x*a,p,!1,a,u),this.addHalfVertex(e,f,_,p,!0,-c,u),this.distance>mu/2&&this.totalDistance===0&&(this.distance=0,this.addCurrentVertex(e,r,a,c,u,p))}addHalfVertex({x:e,y:r},a,c,u,p,f,_){const v=.5*(this.lineClips?this.scaledDistance*(mu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(u?1:0),(r<<1)+(p?1:0),Math.round(63*a)+128,Math.round(63*c)+128,1+(f===0?0:f<0?-1:1)|(63&v)<<2,v>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const w=_.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,w),_.primitiveLength++),p?this.e2=w:this.e1=w}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,r){this.distance+=e.dist(r),this.updateScaledDistance()}}ke("LineBucket",Ac,{omit:["layers","patternFeatures"]});const Qm=new Ii({"line-cap":new Ue(le.layout_line["line-cap"]),"line-join":new Ze(le.layout_line["line-join"]),"line-miter-limit":new Ue(le.layout_line["line-miter-limit"]),"line-round-limit":new Ue(le.layout_line["line-round-limit"]),"line-sort-key":new Ze(le.layout_line["line-sort-key"])});var fu={paint:new Ii({"line-opacity":new Ze(le.paint_line["line-opacity"]),"line-color":new Ze(le.paint_line["line-color"]),"line-translate":new Ue(le.paint_line["line-translate"]),"line-translate-anchor":new Ue(le.paint_line["line-translate-anchor"]),"line-width":new Ze(le.paint_line["line-width"]),"line-gap-width":new Ze(le.paint_line["line-gap-width"]),"line-offset":new Ze(le.paint_line["line-offset"]),"line-blur":new Ze(le.paint_line["line-blur"]),"line-dasharray":new qs(le.paint_line["line-dasharray"]),"line-pattern":new Ln(le.paint_line["line-pattern"]),"line-gradient":new Zs(le.paint_line["line-gradient"])}),layout:Qm};const gu=new class extends Ze{possiblyEvaluate(i,e){return e=new Pt(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(i,e)}evaluate(i,e,r,a){return e=Be({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(i,e,r,a)}}(fu.paint.properties["line-width"].specification);function _u(i,e){return e>0?e+2*i:i}gu.useIntegerZoom=!0;const ef=jt([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),tf=jt([{name:"a_projected_pos",components:3,type:"Float32"}],4);jt([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const rf=jt([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);jt([{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 yu=jt([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),nf=jt([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function af(i,e,r){return i.sections.forEach(a=>{a.text=function(c,u,p){const f=u.layout.get("text-transform").evaluate(p,{});return f==="uppercase"?c=c.toLocaleUpperCase():f==="lowercase"&&(c=c.toLocaleLowerCase()),Ei.applyArabicShaping&&(c=Ei.applyArabicShaping(c)),c}(a.text,e,r)}),i}jt([{name:"triangle",components:3,type:"Uint16"}]),jt([{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"}]),jt([{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",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),jt([{type:"Float32",name:"offsetX"}]),jt([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);const yo={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"};var ii=24,Cc=Tt,xu=function(i,e,r,a,c){var u,p,f=8*c-a-1,_=(1<<f)-1,v=_>>1,w=-7,E=r?c-1:0,P=r?-1:1,k=i[e+E];for(E+=P,u=k&(1<<-w)-1,k>>=-w,w+=f;w>0;u=256*u+i[e+E],E+=P,w-=8);for(p=u&(1<<-w)-1,u>>=-w,w+=a;w>0;p=256*p+i[e+E],E+=P,w-=8);if(u===0)u=1-v;else{if(u===_)return p?NaN:1/0*(k?-1:1);p+=Math.pow(2,a),u-=v}return(k?-1:1)*p*Math.pow(2,u-a)},vu=function(i,e,r,a,c,u){var p,f,_,v=8*u-c-1,w=(1<<v)-1,E=w>>1,P=c===23?Math.pow(2,-24)-Math.pow(2,-77):0,k=a?0:u-1,L=a?1:-1,$=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(f=isNaN(e)?1:0,p=w):(p=Math.floor(Math.log(e)/Math.LN2),e*(_=Math.pow(2,-p))<1&&(p--,_*=2),(e+=p+E>=1?P/_:P*Math.pow(2,1-E))*_>=2&&(p++,_/=2),p+E>=w?(f=0,p=w):p+E>=1?(f=(e*_-1)*Math.pow(2,c),p+=E):(f=e*Math.pow(2,E-1)*Math.pow(2,c),p=0));c>=8;i[r+k]=255&f,k+=L,f/=256,c-=8);for(p=p<<c|f,v+=c;v>0;i[r+k]=255&p,k+=L,p/=256,v-=8);i[r+k-L]|=128*$};function Tt(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}Tt.Varint=0,Tt.Fixed64=1,Tt.Bytes=2,Tt.Fixed32=5;var Fn,Mc=4294967296,bu=1/Mc,wu=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function an(i){return i.type===Tt.Bytes?i.readVarint()+i.pos:i.pos+1}function ts(i,e,r){return r?4294967296*e+(i>>>0):4294967296*(e>>>0)+(i>>>0)}function Tu(i,e,r){var a=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(a);for(var c=r.pos-1;c>=i;c--)r.buf[c+a]=r.buf[c]}function sf(i,e){for(var r=0;r<i.length;r++)e.writeVarint(i[r])}function of(i,e){for(var r=0;r<i.length;r++)e.writeSVarint(i[r])}function lf(i,e){for(var r=0;r<i.length;r++)e.writeFloat(i[r])}function cf(i,e){for(var r=0;r<i.length;r++)e.writeDouble(i[r])}function hf(i,e){for(var r=0;r<i.length;r++)e.writeBoolean(i[r])}function uf(i,e){for(var r=0;r<i.length;r++)e.writeFixed32(i[r])}function df(i,e){for(var r=0;r<i.length;r++)e.writeSFixed32(i[r])}function pf(i,e){for(var r=0;r<i.length;r++)e.writeFixed64(i[r])}function mf(i,e){for(var r=0;r<i.length;r++)e.writeSFixed64(i[r])}function wl(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16)+16777216*i[e+3]}function is(i,e,r){i[r]=e,i[r+1]=e>>>8,i[r+2]=e>>>16,i[r+3]=e>>>24}function Su(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16)+(i[e+3]<<24)}function ff(i,e,r){i===1&&r.readMessage(gf,e)}function gf(i,e,r){if(i===3){const{id:a,bitmap:c,width:u,height:p,left:f,top:_,advance:v}=r.readMessage(_f,{});e.push({id:a,bitmap:new co({width:u+6,height:p+6},c),metrics:{width:u,height:p,left:f,top:_,advance:v}})}}function _f(i,e,r){i===1?e.id=r.readVarint():i===2?e.bitmap=r.readBytes():i===3?e.width=r.readVarint():i===4?e.height=r.readVarint():i===5?e.left=r.readSVarint():i===6?e.top=r.readSVarint():i===7&&(e.advance=r.readVarint())}function Eu(i){let e=0,r=0;for(const p of i)e+=p.w*p.h,r=Math.max(r,p.w);i.sort((p,f)=>f.h-p.h);const a=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let c=0,u=0;for(const p of i)for(let f=a.length-1;f>=0;f--){const _=a[f];if(!(p.w>_.w||p.h>_.h)){if(p.x=_.x,p.y=_.y,u=Math.max(u,p.y+p.h),c=Math.max(c,p.x+p.w),p.w===_.w&&p.h===_.h){const v=a.pop();f<a.length&&(a[f]=v)}else p.h===_.h?(_.x+=p.w,_.w-=p.w):p.w===_.w?(_.y+=p.h,_.h-=p.h):(a.push({x:_.x+p.w,y:_.y,w:_.w-p.w,h:p.h}),_.y+=p.h,_.h-=p.h);break}}return{w:c,h:u,fill:e/(c*u)||0}}Tt.prototype={destroy:function(){this.buf=null},readFields:function(i,e,r){for(r=r||this.length;this.pos<r;){var a=this.readVarint(),c=a>>3,u=this.pos;this.type=7&a,i(c,e,this),this.pos===u&&this.skip(a)}return e},readMessage:function(i,e){return this.readFields(i,e,this.readVarint()+this.pos)},readFixed32:function(){var i=wl(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=Su(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=wl(this.buf,this.pos)+wl(this.buf,this.pos+4)*Mc;return this.pos+=8,i},readSFixed64:function(){var i=wl(this.buf,this.pos)+Su(this.buf,this.pos+4)*Mc;return this.pos+=8,i},readFloat:function(){var i=xu(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=xu(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var e,r,a=this.buf;return e=127&(r=a[this.pos++]),r<128?e:(e|=(127&(r=a[this.pos++]))<<7,r<128?e:(e|=(127&(r=a[this.pos++]))<<14,r<128?e:(e|=(127&(r=a[this.pos++]))<<21,r<128?e:function(c,u,p){var f,_,v=p.buf;if(f=(112&(_=v[p.pos++]))>>4,_<128||(f|=(127&(_=v[p.pos++]))<<3,_<128)||(f|=(127&(_=v[p.pos++]))<<10,_<128)||(f|=(127&(_=v[p.pos++]))<<17,_<128)||(f|=(127&(_=v[p.pos++]))<<24,_<128)||(f|=(1&(_=v[p.pos++]))<<31,_<128))return ts(c,f,u);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=a[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,e=this.pos;return this.pos=i,i-e>=12&&wu?function(r,a,c){return wu.decode(r.subarray(a,c))}(this.buf,e,i):function(r,a,c){for(var u="",p=a;p<c;){var f,_,v,w=r[p],E=null,P=w>239?4:w>223?3:w>191?2:1;if(p+P>c)break;P===1?w<128&&(E=w):P===2?(192&(f=r[p+1]))==128&&(E=(31&w)<<6|63&f)<=127&&(E=null):P===3?(_=r[p+2],(192&(f=r[p+1]))==128&&(192&_)==128&&((E=(15&w)<<12|(63&f)<<6|63&_)<=2047||E>=55296&&E<=57343)&&(E=null)):P===4&&(_=r[p+2],v=r[p+3],(192&(f=r[p+1]))==128&&(192&_)==128&&(192&v)==128&&((E=(15&w)<<18|(63&f)<<12|(63&_)<<6|63&v)<=65535||E>=1114112)&&(E=null)),E===null?(E=65533,P=1):E>65535&&(E-=65536,u+=String.fromCharCode(E>>>10&1023|55296),E=56320|1023&E),u+=String.fromCharCode(E),p+=P}return u}(this.buf,e,i)},readBytes:function(){var i=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,i);return this.pos=i,e},readPackedVarint:function(i,e){if(this.type!==Tt.Bytes)return i.push(this.readVarint(e));var r=an(this);for(i=i||[];this.pos<r;)i.push(this.readVarint(e));return i},readPackedSVarint:function(i){if(this.type!==Tt.Bytes)return i.push(this.readSVarint());var e=an(this);for(i=i||[];this.pos<e;)i.push(this.readSVarint());return i},readPackedBoolean:function(i){if(this.type!==Tt.Bytes)return i.push(this.readBoolean());var e=an(this);for(i=i||[];this.pos<e;)i.push(this.readBoolean());return i},readPackedFloat:function(i){if(this.type!==Tt.Bytes)return i.push(this.readFloat());var e=an(this);for(i=i||[];this.pos<e;)i.push(this.readFloat());return i},readPackedDouble:function(i){if(this.type!==Tt.Bytes)return i.push(this.readDouble());var e=an(this);for(i=i||[];this.pos<e;)i.push(this.readDouble());return i},readPackedFixed32:function(i){if(this.type!==Tt.Bytes)return i.push(this.readFixed32());var e=an(this);for(i=i||[];this.pos<e;)i.push(this.readFixed32());return i},readPackedSFixed32:function(i){if(this.type!==Tt.Bytes)return i.push(this.readSFixed32());var e=an(this);for(i=i||[];this.pos<e;)i.push(this.readSFixed32());return i},readPackedFixed64:function(i){if(this.type!==Tt.Bytes)return i.push(this.readFixed64());var e=an(this);for(i=i||[];this.pos<e;)i.push(this.readFixed64());return i},readPackedSFixed64:function(i){if(this.type!==Tt.Bytes)return i.push(this.readSFixed64());var e=an(this);for(i=i||[];this.pos<e;)i.push(this.readSFixed64());return i},skip:function(i){var e=7&i;if(e===Tt.Varint)for(;this.buf[this.pos++]>127;);else if(e===Tt.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Tt.Fixed32)this.pos+=4;else{if(e!==Tt.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(i,e){this.writeVarint(i<<3|e)},realloc:function(i){for(var e=this.length||16;e<this.pos+i;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(i){this.realloc(4),is(this.buf,i,this.pos),this.pos+=4},writeSFixed32:function(i){this.realloc(4),is(this.buf,i,this.pos),this.pos+=4},writeFixed64:function(i){this.realloc(8),is(this.buf,-1&i,this.pos),is(this.buf,Math.floor(i*bu),this.pos+4),this.pos+=8},writeSFixed64:function(i){this.realloc(8),is(this.buf,-1&i,this.pos),is(this.buf,Math.floor(i*bu),this.pos+4),this.pos+=8},writeVarint:function(i){(i=+i||0)>268435455||i<0?function(e,r){var a,c;if(e>=0?(a=e%4294967296|0,c=e/4294967296|0):(c=~(-e/4294967296),4294967295^(a=~(-e%4294967296))?a=a+1|0:(a=0,c=c+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),function(u,p,f){f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,f.buf[f.pos]=127&(u>>>=7)}(a,0,r),function(u,p){var f=(7&u)<<4;p.buf[p.pos++]|=f|((u>>>=3)?128:0),u&&(p.buf[p.pos++]=127&u|((u>>>=7)?128:0),u&&(p.buf[p.pos++]=127&u|((u>>>=7)?128:0),u&&(p.buf[p.pos++]=127&u|((u>>>=7)?128:0),u&&(p.buf[p.pos++]=127&u|((u>>>=7)?128:0),u&&(p.buf[p.pos++]=127&u)))))}(c,r)}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?2*-i-1:2*i)},writeBoolean:function(i){this.writeVarint(!!i)},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var e=this.pos;this.pos=function(a,c,u){for(var p,f,_=0;_<c.length;_++){if((p=c.charCodeAt(_))>55295&&p<57344){if(!f){p>56319||_+1===c.length?(a[u++]=239,a[u++]=191,a[u++]=189):f=p;continue}if(p<56320){a[u++]=239,a[u++]=191,a[u++]=189,f=p;continue}p=f-55296<<10|p-56320|65536,f=null}else f&&(a[u++]=239,a[u++]=191,a[u++]=189,f=null);p<128?a[u++]=p:(p<2048?a[u++]=p>>6|192:(p<65536?a[u++]=p>>12|224:(a[u++]=p>>18|240,a[u++]=p>>12&63|128),a[u++]=p>>6&63|128),a[u++]=63&p|128)}return u}(this.buf,i,this.pos);var r=this.pos-e;r>=128&&Tu(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(i){this.realloc(4),vu(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),vu(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var e=i.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=i[r]},writeRawMessage:function(i,e){this.pos++;var r=this.pos;i(e,this);var a=this.pos-r;a>=128&&Tu(r,a,this),this.pos=r-1,this.writeVarint(a),this.pos+=a},writeMessage:function(i,e,r){this.writeTag(i,Tt.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(i,e){e.length&&this.writeMessage(i,sf,e)},writePackedSVarint:function(i,e){e.length&&this.writeMessage(i,of,e)},writePackedBoolean:function(i,e){e.length&&this.writeMessage(i,hf,e)},writePackedFloat:function(i,e){e.length&&this.writeMessage(i,lf,e)},writePackedDouble:function(i,e){e.length&&this.writeMessage(i,cf,e)},writePackedFixed32:function(i,e){e.length&&this.writeMessage(i,uf,e)},writePackedSFixed32:function(i,e){e.length&&this.writeMessage(i,df,e)},writePackedFixed64:function(i,e){e.length&&this.writeMessage(i,pf,e)},writePackedSFixed64:function(i,e){e.length&&this.writeMessage(i,mf,e)},writeBytesField:function(i,e){this.writeTag(i,Tt.Bytes),this.writeBytes(e)},writeFixed32Field:function(i,e){this.writeTag(i,Tt.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(i,e){this.writeTag(i,Tt.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(i,e){this.writeTag(i,Tt.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(i,e){this.writeTag(i,Tt.Fixed64),this.writeSFixed64(e)},writeVarintField:function(i,e){this.writeTag(i,Tt.Varint),this.writeVarint(e)},writeSVarintField:function(i,e){this.writeTag(i,Tt.Varint),this.writeSVarint(e)},writeStringField:function(i,e){this.writeTag(i,Tt.Bytes),this.writeString(e)},writeFloatField:function(i,e){this.writeTag(i,Tt.Fixed32),this.writeFloat(e)},writeDoubleField:function(i,e){this.writeTag(i,Tt.Fixed64),this.writeDouble(e)},writeBooleanField:function(i,e){this.writeVarintField(i,!!e)}};class Pc{constructor(e,{pixelRatio:r,version:a,stretchX:c,stretchY:u,content:p}){this.paddedRect=e,this.pixelRatio=r,this.stretchX=c,this.stretchY=u,this.content=p,this.version=a}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class Iu{constructor(e,r){const a={},c={};this.haveRenderCallbacks=[];const u=[];this.addImages(e,a,u),this.addImages(r,c,u);const{w:p,h:f}=Eu(u),_=new er({width:p||1,height:f||1});for(const v in e){const w=e[v],E=a[v].paddedRect;er.copy(w.data,_,{x:0,y:0},{x:E.x+1,y:E.y+1},w.data)}for(const v in r){const w=r[v],E=c[v].paddedRect,P=E.x+1,k=E.y+1,L=w.data.width,$=w.data.height;er.copy(w.data,_,{x:0,y:0},{x:P,y:k},w.data),er.copy(w.data,_,{x:0,y:$-1},{x:P,y:k-1},{width:L,height:1}),er.copy(w.data,_,{x:0,y:0},{x:P,y:k+$},{width:L,height:1}),er.copy(w.data,_,{x:L-1,y:0},{x:P-1,y:k},{width:1,height:$}),er.copy(w.data,_,{x:0,y:0},{x:P+L,y:k},{width:1,height:$})}this.image=_,this.iconPositions=a,this.patternPositions=c}addImages(e,r,a){for(const c in e){const u=e[c],p={x:0,y:0,w:u.data.width+2,h:u.data.height+2};a.push(p),r[c]=new Pc(p,u),u.hasRenderCallback&&this.haveRenderCallbacks.push(c)}}patchUpdatedImages(e,r){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const a in e.updatedImages)this.patchUpdatedImage(this.iconPositions[a],e.getImage(a),r),this.patchUpdatedImage(this.patternPositions[a],e.getImage(a),r)}patchUpdatedImage(e,r,a){if(!e||!r||e.version===r.version)return;e.version=r.version;const[c,u]=e.tl;a.update(r.data,void 0,{x:c,y:u})}}ke("ImagePosition",Pc),ke("ImageAtlas",Iu),h.WritingMode=void 0,(Fn=h.WritingMode||(h.WritingMode={}))[Fn.none=0]="none",Fn[Fn.horizontal=1]="horizontal",Fn[Fn.vertical=2]="vertical",Fn[Fn.horizontalOnly=3]="horizontalOnly";const Tl=-17;class xo{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,r){const a=new xo;return a.scale=e||1,a.fontStack=r,a}static forImage(e){const r=new xo;return r.imageName=e,r}}class rs{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,r){const a=new rs;for(let c=0;c<e.sections.length;c++){const u=e.sections[c];u.image?a.addImageSection(u):a.addTextSection(u,r)}return a}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSectionIndex(e){return this.sectionIndex[e]}getCharCode(e){return this.text.charCodeAt(e)}verticalizePunctuation(){this.text=function(e){let r="";for(let a=0;a<e.length;a++){const c=e.charCodeAt(a+1)||null,u=e.charCodeAt(a-1)||null;r+=c&&ll(c)&&!yo[e[a+1]]||u&&ll(u)&&!yo[e[a-1]]||!yo[e[a]]?e[a]:yo[e[a]]}return r}(this.text)}trim(){let e=0;for(let a=0;a<this.text.length&&El[this.text.charCodeAt(a)];a++)e++;let r=this.text.length;for(let a=this.text.length-1;a>=0&&a>=e&&El[this.text.charCodeAt(a)];a--)r--;this.text=this.text.substring(e,r),this.sectionIndex=this.sectionIndex.slice(e,r)}substring(e,r){const a=new rs;return a.text=this.text.substring(e,r),a.sectionIndex=this.sectionIndex.slice(e,r),a.sections=this.sections,a}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,r)=>Math.max(e,this.sections[r].scale),0)}addTextSection(e,r){this.text+=e.text,this.sections.push(xo.forText(e.scale,e.fontStack||r));const a=this.sections.length-1;for(let c=0;c<e.text.length;++c)this.sectionIndex.push(a)}addImageSection(e){const r=e.image?e.image.name:"";if(r.length===0)return void dt("Can't add FormattedSection with an empty image.");const a=this.getNextImageSectionCharCode();a?(this.text+=String.fromCharCode(a),this.sections.push(xo.forImage(r)),this.sectionIndex.push(this.sections.length-1)):dt("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Sl(i,e,r,a,c,u,p,f,_,v,w,E,P,k,L,$){const N=rs.fromFeature(i,c);let J;E===h.WritingMode.vertical&&N.verticalizePunctuation();const{processBidirectionalText:ne,processStyledBidirectionalText:K}=Ei;if(ne&&N.sections.length===1){J=[];const fe=ne(N.toString(),kc(N,v,u,e,a,k,L));for(const De of fe){const Fe=new rs;Fe.text=De,Fe.sections=N.sections;for(let Me=0;Me<De.length;Me++)Fe.sectionIndex.push(0);J.push(Fe)}}else if(K){J=[];const fe=K(N.text,N.sectionIndex,kc(N,v,u,e,a,k,L));for(const De of fe){const Fe=new rs;Fe.text=De[0],Fe.sectionIndex=De[1],Fe.sections=N.sections,J.push(Fe)}}else J=function(fe,De){const Fe=[],Me=fe.text;let Ie=0;for(const Te of De)Fe.push(fe.substring(Ie,Te)),Ie=Te;return Ie<Me.length&&Fe.push(fe.substring(Ie,Me.length)),Fe}(N,kc(N,v,u,e,a,k,L));const re=[],ge={positionedLines:re,text:N.toString(),top:w[1],bottom:w[1],left:w[0],right:w[0],writingMode:E,iconsInText:!1,verticalizable:!1};return function(fe,De,Fe,Me,Ie,Te,Pe,Ce,be,$e,Ve,it){let kt=0,Bt=Tl,Kt=0,ir=0;const ai=Ce==="right"?1:Ce==="left"?0:.5;let Zt=0;for(const Xt of Ie){Xt.trim();const oi=Xt.getMaxScale(),bi=(oi-1)*ii,Ai={positionedGlyphs:[],lineOffset:0};fe.positionedLines[Zt]=Ai;const Li=Ai.positionedGlyphs;let Di=0;if(!Xt.length()){Bt+=Te,++Zt;continue}for(let li=0;li<Xt.length();li++){const rt=Xt.getSection(li),Zi=Xt.getSectionIndex(li),ci=Xt.getCharCode(li);let wi=0,hr=null,br=null,wr=null,on=ii;const ur=!(be===h.WritingMode.horizontal||!Ve&&!Us(ci)||Ve&&(El[ci]||(Jt=ci,Ae.Arabic(Jt)||Ae["Arabic Supplement"](Jt)||Ae["Arabic Extended-A"](Jt)||Ae["Arabic Presentation Forms-A"](Jt)||Ae["Arabic Presentation Forms-B"](Jt))));if(rt.imageName){const rr=Me[rt.imageName];if(!rr)continue;wr=rt.imageName,fe.iconsInText=fe.iconsInText||!0,br=rr.paddedRect;const Ri=rr.displaySize;rt.scale=rt.scale*ii/it,hr={width:Ri[0],height:Ri[1],left:1,top:-3,advance:ur?Ri[1]:Ri[0]},wi=bi+(ii-Ri[1]*rt.scale),on=hr.advance;const ln=ur?Ri[0]*rt.scale-ii*oi:Ri[1]*rt.scale-ii*oi;ln>0&&ln>Di&&(Di=ln)}else{const rr=Fe[rt.fontStack],Ri=rr&&rr[ci];if(Ri&&Ri.rect)br=Ri.rect,hr=Ri.metrics;else{const ln=De[rt.fontStack],To=ln&&ln[ci];if(!To)continue;hr=To.metrics}wi=(oi-rt.scale)*ii}ur?(fe.verticalizable=!0,Li.push({glyph:ci,imageName:wr,x:kt,y:Bt+wi,vertical:ur,scale:rt.scale,fontStack:rt.fontStack,sectionIndex:Zi,metrics:hr,rect:br}),kt+=on*rt.scale+$e):(Li.push({glyph:ci,imageName:wr,x:kt,y:Bt+wi,vertical:ur,scale:rt.scale,fontStack:rt.fontStack,sectionIndex:Zi,metrics:hr,rect:br}),kt+=hr.advance*rt.scale+$e)}Li.length!==0&&(Kt=Math.max(kt-$e,Kt),vf(Li,0,Li.length-1,ai,Di)),kt=0;const Nt=Te*oi+Di;Ai.lineOffset=Math.max(Di,bi),Bt+=Nt,ir=Math.max(Nt,ir),++Zt}var Jt;const si=Bt-Tl,{horizontalAlign:vi,verticalAlign:zi}=zc(Pe);(function(Xt,oi,bi,Ai,Li,Di,Nt,li,rt){const Zi=(oi-bi)*Li;let ci=0;ci=Di!==Nt?-li*Ai-Tl:(-Ai*rt+.5)*Nt;for(const wi of Xt)for(const hr of wi.positionedGlyphs)hr.x+=Zi,hr.y+=ci})(fe.positionedLines,ai,vi,zi,Kt,ir,Te,si,Ie.length),fe.top+=-zi*si,fe.bottom=fe.top+si,fe.left+=-vi*Kt,fe.right=fe.left+Kt}(ge,e,r,a,J,p,f,_,E,v,P,$),!function(fe){for(const De of fe)if(De.positionedGlyphs.length!==0)return!1;return!0}(re)&&ge}const El={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},yf={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function Au(i,e,r,a,c,u){if(e.imageName){const p=a[e.imageName];return p?p.displaySize[0]*e.scale*ii/u+c:0}{const p=r[e.fontStack],f=p&&p[i];return f?f.metrics.advance*e.scale+c:0}}function Cu(i,e,r,a){const c=Math.pow(i-e,2);return a?i<e?c/2:2*c:c+Math.abs(r)*r}function xf(i,e,r){let a=0;return i===10&&(a-=1e4),r&&(a+=150),i!==40&&i!==65288||(a+=50),e!==41&&e!==65289||(a+=50),a}function Mu(i,e,r,a,c,u){let p=null,f=Cu(e,r,c,u);for(const _ of a){const v=Cu(e-_.x,r,c,u)+_.badness;v<=f&&(p=_,f=v)}return{index:i,x:e,priorBreak:p,badness:f}}function Pu(i){return i?Pu(i.priorBreak).concat(i.index):[]}function kc(i,e,r,a,c,u,p){if(u!=="point")return[];if(!i)return[];const f=[],_=function(P,k,L,$,N,J){let ne=0;for(let K=0;K<P.length();K++){const re=P.getSection(K);ne+=Au(P.getCharCode(K),re,$,N,k,J)}return ne/Math.max(1,Math.ceil(ne/L))}(i,e,r,a,c,p),v=i.text.indexOf("\u200B")>=0;let w=0;for(let P=0;P<i.length();P++){const k=i.getSection(P),L=i.getCharCode(P);if(El[L]||(w+=Au(L,k,a,c,e,p)),P<i.length()-1){const $=!((E=L)<11904||!(Ae["Bopomofo Extended"](E)||Ae.Bopomofo(E)||Ae["CJK Compatibility Forms"](E)||Ae["CJK Compatibility Ideographs"](E)||Ae["CJK Compatibility"](E)||Ae["CJK Radicals Supplement"](E)||Ae["CJK Strokes"](E)||Ae["CJK Symbols and Punctuation"](E)||Ae["CJK Unified Ideographs Extension A"](E)||Ae["CJK Unified Ideographs"](E)||Ae["Enclosed CJK Letters and Months"](E)||Ae["Halfwidth and Fullwidth Forms"](E)||Ae.Hiragana(E)||Ae["Ideographic Description Characters"](E)||Ae["Kangxi Radicals"](E)||Ae["Katakana Phonetic Extensions"](E)||Ae.Katakana(E)||Ae["Vertical Forms"](E)||Ae["Yi Radicals"](E)||Ae["Yi Syllables"](E)));(yf[L]||$||k.imageName)&&f.push(Mu(P+1,w,_,f,xf(L,i.getCharCode(P+1),$&&v),!1))}}var E;return Pu(Mu(i.length(),w,_,f,0,!0))}function zc(i){let e=.5,r=.5;switch(i){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(i){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:e,verticalAlign:r}}function vf(i,e,r,a,c){if(!a&&!c)return;const u=i[r],p=(i[r].x+u.metrics.advance*u.scale)*a;for(let f=e;f<=r;f++)i[f].x-=p,i[f].y+=c}function bf(i,e,r){const{horizontalAlign:a,verticalAlign:c}=zc(r),u=e[0]-i.displaySize[0]*a,p=e[1]-i.displaySize[1]*c;return{image:i,top:p,bottom:p+i.displaySize[1],left:u,right:u+i.displaySize[0]}}function ku(i,e,r,a,c,u){const p=i.image;let f;if(p.content){const N=p.content,J=p.pixelRatio||1;f=[N[0]/J,N[1]/J,p.displaySize[0]-N[2]/J,p.displaySize[1]-N[3]/J]}const _=e.left*u,v=e.right*u;let w,E,P,k;r==="width"||r==="both"?(k=c[0]+_-a[3],E=c[0]+v+a[1]):(k=c[0]+(_+v-p.displaySize[0])/2,E=k+p.displaySize[0]);const L=e.top*u,$=e.bottom*u;return r==="height"||r==="both"?(w=c[1]+L-a[0],P=c[1]+$+a[2]):(w=c[1]+(L+$-p.displaySize[1])/2,P=w+p.displaySize[1]),{image:p,top:w,right:E,bottom:P,left:k,collisionPadding:f}}const sn=128;function zu(i,e){const{expression:r}=e;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new Pt(i+1))};if(r.kind==="source")return{kind:"source"};{const{zoomStops:a,interpolationType:c}=r;let u=0;for(;u<a.length&&a[u]<=i;)u++;u=Math.max(0,u-1);let p=u;for(;p<a.length&&a[p]<i+1;)p++;p=Math.min(a.length-1,p);const f=a[u],_=a[p];return r.kind==="composite"?{kind:"composite",minZoom:f,maxZoom:_,interpolationType:c}:{kind:"camera",minZoom:f,maxZoom:_,minSize:r.evaluate(new Pt(f)),maxSize:r.evaluate(new Pt(_)),interpolationType:c}}}class On extends He{constructor(e,r,a,c){super(e,r),this.angle=a,c!==void 0&&(this.segment=c)}clone(){return new On(this.x,this.y,this.angle,this.segment)}}function Lu(i,e,r,a,c){if(e.segment===void 0)return!0;let u=e,p=e.segment+1,f=0;for(;f>-r/2;){if(p--,p<0)return!1;f-=i[p].dist(u),u=i[p]}f+=i[p].dist(i[p+1]),p++;const _=[];let v=0;for(;f<r/2;){const w=i[p],E=i[p+1];if(!E)return!1;let P=i[p-1].angleTo(w)-w.angleTo(E);for(P=Math.abs((P+3*Math.PI)%(2*Math.PI)-Math.PI),_.push({distance:f,angleDelta:P}),v+=P;f-_[0].distance>a;)v-=_.shift().angleDelta;if(v>c)return!1;p++,f+=w.dist(E)}return!0}function Du(i){let e=0;for(let r=0;r<i.length-1;r++)e+=i[r].dist(i[r+1]);return e}function Ru(i,e,r){return i?.6*e*r:0}function Bu(i,e){return Math.max(i?i.right-i.left:0,e?e.right-e.left:0)}function wf(i,e,r,a,c,u){const p=Ru(r,c,u),f=Bu(r,a)*u;let _=0;const v=Du(i)/2;for(let w=0;w<i.length-1;w++){const E=i[w],P=i[w+1],k=E.dist(P);if(_+k>v){const L=(v-_)/k,$=zt(E.x,P.x,L),N=zt(E.y,P.y,L),J=new On($,N,P.angleTo(E),w);return J._round(),!p||Lu(i,J,f,p,e)?J:void 0}_+=k}}function Tf(i,e,r,a,c,u,p,f,_){const v=Ru(a,u,p),w=Bu(a,c),E=w*p,P=i[0].x===0||i[0].x===_||i[0].y===0||i[0].y===_;return e-E<e/4&&(e=E+e/4),Fu(i,P?e/2*f%e:(w/2+2*u)*p*f%e,e,v,r,E,P,!1,_)}function Fu(i,e,r,a,c,u,p,f,_){const v=u/2,w=Du(i);let E=0,P=e-r,k=[];for(let L=0;L<i.length-1;L++){const $=i[L],N=i[L+1],J=$.dist(N),ne=N.angleTo($);for(;P+r<E+J;){P+=r;const K=(P-E)/J,re=zt($.x,N.x,K),ge=zt($.y,N.y,K);if(re>=0&&re<_&&ge>=0&&ge<_&&P-v>=0&&P+v<=w){const fe=new On(re,ge,ne,L);fe._round(),a&&!Lu(i,fe,u,a,c)||k.push(fe)}}E+=J}return f||k.length||p||(k=Fu(i,E/2,r,a,c,u,p,!0,_)),k}function Ou(i,e,r,a,c){const u=[];for(let p=0;p<i.length;p++){const f=i[p];let _;for(let v=0;v<f.length-1;v++){let w=f[v],E=f[v+1];w.x<e&&E.x<e||(w.x<e?w=new He(e,w.y+(e-w.x)/(E.x-w.x)*(E.y-w.y))._round():E.x<e&&(E=new He(e,w.y+(e-w.x)/(E.x-w.x)*(E.y-w.y))._round()),w.y<r&&E.y<r||(w.y<r?w=new He(w.x+(r-w.y)/(E.y-w.y)*(E.x-w.x),r)._round():E.y<r&&(E=new He(w.x+(r-w.y)/(E.y-w.y)*(E.x-w.x),r)._round()),w.x>=a&&E.x>=a||(w.x>=a?w=new He(a,w.y+(a-w.x)/(E.x-w.x)*(E.y-w.y))._round():E.x>=a&&(E=new He(a,w.y+(a-w.x)/(E.x-w.x)*(E.y-w.y))._round()),w.y>=c&&E.y>=c||(w.y>=c?w=new He(w.x+(c-w.y)/(E.y-w.y)*(E.x-w.x),c)._round():E.y>=c&&(E=new He(w.x+(c-w.y)/(E.y-w.y)*(E.x-w.x),c)._round()),_&&w.equals(_[_.length-1])||(_=[w],u.push(_)),_.push(E)))))}}return u}function Uu(i,e,r,a){const c=[],u=i.image,p=u.pixelRatio,f=u.paddedRect.w-2,_=u.paddedRect.h-2,v=i.right-i.left,w=i.bottom-i.top,E=u.stretchX||[[0,f]],P=u.stretchY||[[0,_]],k=(Te,Pe)=>Te+Pe[1]-Pe[0],L=E.reduce(k,0),$=P.reduce(k,0),N=f-L,J=_-$;let ne=0,K=L,re=0,ge=$,fe=0,De=N,Fe=0,Me=J;if(u.content&&a){const Te=u.content;ne=Il(E,0,Te[0]),re=Il(P,0,Te[1]),K=Il(E,Te[0],Te[2]),ge=Il(P,Te[1],Te[3]),fe=Te[0]-ne,Fe=Te[1]-re,De=Te[2]-Te[0]-K,Me=Te[3]-Te[1]-ge}const Ie=(Te,Pe,Ce,be)=>{const $e=Al(Te.stretch-ne,K,v,i.left),Ve=Cl(Te.fixed-fe,De,Te.stretch,L),it=Al(Pe.stretch-re,ge,w,i.top),kt=Cl(Pe.fixed-Fe,Me,Pe.stretch,$),Bt=Al(Ce.stretch-ne,K,v,i.left),Kt=Cl(Ce.fixed-fe,De,Ce.stretch,L),ir=Al(be.stretch-re,ge,w,i.top),ai=Cl(be.fixed-Fe,Me,be.stretch,$),Zt=new He($e,it),Jt=new He(Bt,it),si=new He(Bt,ir),vi=new He($e,ir),zi=new He(Ve/p,kt/p),Xt=new He(Kt/p,ai/p),oi=e*Math.PI/180;if(oi){const Li=Math.sin(oi),Di=Math.cos(oi),Nt=[Di,-Li,Li,Di];Zt._matMult(Nt),Jt._matMult(Nt),vi._matMult(Nt),si._matMult(Nt)}const bi=Te.stretch+Te.fixed,Ai=Pe.stretch+Pe.fixed;return{tl:Zt,tr:Jt,bl:vi,br:si,tex:{x:u.paddedRect.x+1+bi,y:u.paddedRect.y+1+Ai,w:Ce.stretch+Ce.fixed-bi,h:be.stretch+be.fixed-Ai},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:zi,pixelOffsetBR:Xt,minFontScaleX:De/p/v,minFontScaleY:Me/p/w,isSDF:r}};if(a&&(u.stretchX||u.stretchY)){const Te=Vu(E,N,L),Pe=Vu(P,J,$);for(let Ce=0;Ce<Te.length-1;Ce++){const be=Te[Ce],$e=Te[Ce+1];for(let Ve=0;Ve<Pe.length-1;Ve++)c.push(Ie(be,Pe[Ve],$e,Pe[Ve+1]))}}else c.push(Ie({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:f+1},{fixed:0,stretch:_+1}));return c}function Il(i,e,r){let a=0;for(const c of i)a+=Math.max(e,Math.min(r,c[1]))-Math.max(e,Math.min(r,c[0]));return a}function Vu(i,e,r){const a=[{fixed:-1,stretch:0}];for(const[c,u]of i){const p=a[a.length-1];a.push({fixed:c-p.stretch,stretch:p.stretch}),a.push({fixed:c-p.stretch,stretch:p.stretch+(u-c)})}return a.push({fixed:e+1,stretch:r}),a}function Al(i,e,r,a){return i/e*r+a}function Cl(i,e,r,a){return i-e*r/a}ke("Anchor",On);class Ml{constructor(e,r,a,c,u,p,f,_,v,w){if(this.boxStartIndex=e.length,v){let E=p.top,P=p.bottom;const k=p.collisionPadding;k&&(E-=k[1],P+=k[3]);let L=P-E;L>0&&(L=Math.max(10,L),this.circleDiameter=L)}else{let E=p.top*f-_[0],P=p.bottom*f+_[2],k=p.left*f-_[3],L=p.right*f+_[1];const $=p.collisionPadding;if($&&(k-=$[0]*f,E-=$[1]*f,L+=$[2]*f,P+=$[3]*f),w){const N=new He(k,E),J=new He(L,E),ne=new He(k,P),K=new He(L,P),re=w*Math.PI/180;N._rotate(re),J._rotate(re),ne._rotate(re),K._rotate(re),k=Math.min(N.x,J.x,ne.x,K.x),L=Math.max(N.x,J.x,ne.x,K.x),E=Math.min(N.y,J.y,ne.y,K.y),P=Math.max(N.y,J.y,ne.y,K.y)}e.emplaceBack(r.x,r.y,k,E,L,P,a,c,u)}this.boxEndIndex=e.length}}class Sf{constructor(e=[],r=Ef){if(this.data=e,this.length=this.data.length,this.compare=r,this.length>0)for(let a=(this.length>>1)-1;a>=0;a--)this._down(a)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:r,compare:a}=this,c=r[e];for(;e>0;){const u=e-1>>1,p=r[u];if(a(c,p)>=0)break;r[e]=p,e=u}r[e]=c}_down(e){const{data:r,compare:a}=this,c=this.length>>1,u=r[e];for(;e<c;){let p=1+(e<<1),f=r[p];const _=p+1;if(_<this.length&&a(r[_],f)<0&&(p=_,f=r[_]),a(f,u)>=0)break;r[e]=f,e=p}r[e]=u}}function Ef(i,e){return i<e?-1:i>e?1:0}function If(i,e=1,r=!1){let a=1/0,c=1/0,u=-1/0,p=-1/0;const f=i[0];for(let k=0;k<f.length;k++){const L=f[k];(!k||L.x<a)&&(a=L.x),(!k||L.y<c)&&(c=L.y),(!k||L.x>u)&&(u=L.x),(!k||L.y>p)&&(p=L.y)}const _=Math.min(u-a,p-c);let v=_/2;const w=new Sf([],Af);if(_===0)return new He(a,c);for(let k=a;k<u;k+=_)for(let L=c;L<p;L+=_)w.push(new ns(k+v,L+v,v,i));let E=function(k){let L=0,$=0,N=0;const J=k[0];for(let ne=0,K=J.length,re=K-1;ne<K;re=ne++){const ge=J[ne],fe=J[re],De=ge.x*fe.y-fe.x*ge.y;$+=(ge.x+fe.x)*De,N+=(ge.y+fe.y)*De,L+=3*De}return new ns($/L,N/L,0,k)}(i),P=w.length;for(;w.length;){const k=w.pop();(k.d>E.d||!E.d)&&(E=k,r&&console.log("found best %d after %d probes",Math.round(1e4*k.d)/1e4,P)),k.max-E.d<=e||(v=k.h/2,w.push(new ns(k.p.x-v,k.p.y-v,v,i)),w.push(new ns(k.p.x+v,k.p.y-v,v,i)),w.push(new ns(k.p.x-v,k.p.y+v,v,i)),w.push(new ns(k.p.x+v,k.p.y+v,v,i)),P+=4)}return r&&(console.log(`num probes: ${P}`),console.log(`best distance: ${E.d}`)),E.p}function Af(i,e){return e.max-i.max}function ns(i,e,r,a){this.p=new He(i,e),this.h=r,this.d=function(c,u){let p=!1,f=1/0;for(let _=0;_<u.length;_++){const v=u[_];for(let w=0,E=v.length,P=E-1;w<E;P=w++){const k=v[w],L=v[P];k.y>c.y!=L.y>c.y&&c.x<(L.x-k.x)*(c.y-k.y)/(L.y-k.y)+k.x&&(p=!p),f=Math.min(f,Rt(c,k,L))}}return(p?1:-1)*Math.sqrt(f)}(this.p,a),this.max=this.d+this.h*Math.SQRT2}const Lc=Number.POSITIVE_INFINITY;function Nu(i,e){return e[1]!==Lc?function(r,a,c){let u=0,p=0;switch(a=Math.abs(a),c=Math.abs(c),r){case"top-right":case"top-left":case"top":p=c-7;break;case"bottom-right":case"bottom-left":case"bottom":p=7-c}switch(r){case"top-right":case"bottom-right":case"right":u=-a;break;case"top-left":case"bottom-left":case"left":u=a}return[u,p]}(i,e[0],e[1]):function(r,a){let c=0,u=0;a<0&&(a=0);const p=a/Math.sqrt(2);switch(r){case"top-right":case"top-left":u=p-7;break;case"bottom-right":case"bottom-left":u=7-p;break;case"bottom":u=7-a;break;case"top":u=a-7}switch(r){case"top-right":case"bottom-right":c=-p;break;case"top-left":case"bottom-left":c=p;break;case"left":c=a;break;case"right":c=-a}return[c,u]}(i,e[0])}function Dc(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Cf(i,e,r,a,c,u,p,f,_,v,w){let E=u.textMaxSize.evaluate(e,{});E===void 0&&(E=p);const P=i.layers[0].layout,k=P.get("icon-offset").evaluate(e,{},w),L=Gu(r.horizontal),$=p/24,N=i.tilePixelRatio*$,J=i.tilePixelRatio*E/24,ne=i.tilePixelRatio*f,K=i.tilePixelRatio*P.get("symbol-spacing"),re=P.get("text-padding")*i.tilePixelRatio,ge=function(be,$e,Ve,it=1){const kt=be.get("icon-padding").evaluate($e,{},Ve),Bt=kt&&kt.values;return[Bt[0]*it,Bt[1]*it,Bt[2]*it,Bt[3]*it]}(P,e,w,i.tilePixelRatio),fe=P.get("text-max-angle")/180*Math.PI,De=P.get("text-rotation-alignment")!=="viewport"&&P.get("symbol-placement")!=="point",Fe=P.get("icon-rotation-alignment")==="map"&&P.get("symbol-placement")!=="point",Me=P.get("symbol-placement"),Ie=K/2,Te=P.get("icon-text-fit");let Pe;a&&Te!=="none"&&(i.allowVerticalPlacement&&r.vertical&&(Pe=ku(a,r.vertical,Te,P.get("icon-text-fit-padding"),k,$)),L&&(a=ku(a,L,Te,P.get("icon-text-fit-padding"),k,$)));const Ce=(be,$e)=>{$e.x<0||$e.x>=gt||$e.y<0||$e.y>=gt||function(Ve,it,kt,Bt,Kt,ir,ai,Zt,Jt,si,vi,zi,Xt,oi,bi,Ai,Li,Di,Nt,li,rt,Zi,ci,wi,hr){const br=Ve.addToLineVertexArray(it,kt);let wr,on,ur,rr,Ri=0,ln=0,To=0,od=0,Xc=-1,Wc=-1;const cn={};let ld=M(""),Hc=0,Kc=0;if(Zt._unevaluatedLayout.getValue("text-radial-offset")===void 0?[Hc,Kc]=Zt.layout.get("text-offset").evaluate(rt,{},wi).map(Bi=>Bi*ii):(Hc=Zt.layout.get("text-radial-offset").evaluate(rt,{},wi)*ii,Kc=Lc),Ve.allowVerticalPlacement&&Bt.vertical){const Bi=Zt.layout.get("text-rotate").evaluate(rt,{},wi)+90;ur=new Ml(Jt,it,si,vi,zi,Bt.vertical,Xt,oi,bi,Bi),ai&&(rr=new Ml(Jt,it,si,vi,zi,ai,Li,Di,bi,Bi))}if(Kt){const Bi=Zt.layout.get("icon-rotate").evaluate(rt,{}),Fr=Zt.layout.get("icon-text-fit")!=="none",So=Uu(Kt,Bi,ci,Fr),Eo=ai?Uu(ai,Bi,ci,Fr):void 0;on=new Ml(Jt,it,si,vi,zi,Kt,Li,Di,!1,Bi),Ri=4*So.length;const ud=Ve.iconSizeData;let la=null;ud.kind==="source"?(la=[sn*Zt.layout.get("icon-size").evaluate(rt,{})],la[0]>Un&&dt(`${Ve.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):ud.kind==="composite"&&(la=[sn*Zi.compositeIconSizes[0].evaluate(rt,{},wi),sn*Zi.compositeIconSizes[1].evaluate(rt,{},wi)],(la[0]>Un||la[1]>Un)&&dt(`${Ve.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),Ve.addSymbols(Ve.icon,So,la,li,Nt,rt,h.WritingMode.none,it,br.lineStartIndex,br.lineLength,-1,wi),Xc=Ve.icon.placedSymbolArray.length-1,Eo&&(ln=4*Eo.length,Ve.addSymbols(Ve.icon,Eo,la,li,Nt,rt,h.WritingMode.vertical,it,br.lineStartIndex,br.lineLength,-1,wi),Wc=Ve.icon.placedSymbolArray.length-1)}const cd=Object.keys(Bt.horizontal);for(const Bi of cd){const Fr=Bt.horizontal[Bi];if(!wr){ld=M(Fr.text);const Eo=Zt.layout.get("text-rotate").evaluate(rt,{},wi);wr=new Ml(Jt,it,si,vi,zi,Fr,Xt,oi,bi,Eo)}const So=Fr.positionedLines.length===1;if(To+=$u(Ve,it,Fr,ir,Zt,bi,rt,Ai,br,Bt.vertical?h.WritingMode.horizontal:h.WritingMode.horizontalOnly,So?cd:[Bi],cn,Xc,Zi,wi),So)break}Bt.vertical&&(od+=$u(Ve,it,Bt.vertical,ir,Zt,bi,rt,Ai,br,h.WritingMode.vertical,["vertical"],cn,Wc,Zi,wi));const Gf=wr?wr.boxStartIndex:Ve.collisionBoxArray.length,jf=wr?wr.boxEndIndex:Ve.collisionBoxArray.length,qf=ur?ur.boxStartIndex:Ve.collisionBoxArray.length,Zf=ur?ur.boxEndIndex:Ve.collisionBoxArray.length,Xf=on?on.boxStartIndex:Ve.collisionBoxArray.length,Wf=on?on.boxEndIndex:Ve.collisionBoxArray.length,Hf=rr?rr.boxStartIndex:Ve.collisionBoxArray.length,Kf=rr?rr.boxEndIndex:Ve.collisionBoxArray.length;let Tr=-1;const Dl=(Bi,Fr)=>Bi&&Bi.circleDiameter?Math.max(Bi.circleDiameter,Fr):Fr;Tr=Dl(wr,Tr),Tr=Dl(ur,Tr),Tr=Dl(on,Tr),Tr=Dl(rr,Tr);const hd=Tr>-1?1:0;hd&&(Tr*=hr/ii),Ve.glyphOffsetArray.length>=as.MAX_GLYPHS&&dt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),rt.sortKey!==void 0&&Ve.addToSortKeyRanges(Ve.symbolInstances.length,rt.sortKey),Ve.symbolInstances.emplaceBack(it.x,it.y,cn.right>=0?cn.right:-1,cn.center>=0?cn.center:-1,cn.left>=0?cn.left:-1,cn.vertical||-1,Xc,Wc,ld,Gf,jf,qf,Zf,Xf,Wf,Hf,Kf,si,To,od,Ri,ln,hd,0,Xt,Hc,Kc,Tr)}(i,$e,be,r,a,c,Pe,i.layers[0],i.collisionBoxArray,e.index,e.sourceLayerIndex,i.index,N,[re,re,re,re],De,_,ne,ge,Fe,k,e,u,v,w,p)};if(Me==="line")for(const be of Ou(e.geometry,0,0,gt,gt)){const $e=Tf(be,K,fe,r.vertical||L,a,24,J,i.overscaling,gt);for(const Ve of $e)L&&Mf(i,L.text,Ie,Ve)||Ce(be,Ve)}else if(Me==="line-center"){for(const be of e.geometry)if(be.length>1){const $e=wf(be,fe,r.vertical||L,a,24,J);$e&&Ce(be,$e)}}else if(e.type==="Polygon")for(const be of bc(e.geometry,0)){const $e=If(be,16);Ce(be[0],new On($e.x,$e.y,0))}else if(e.type==="LineString")for(const be of e.geometry)Ce(be,new On(be[0].x,be[0].y,0));else if(e.type==="Point")for(const be of e.geometry)for(const $e of be)Ce([$e],new On($e.x,$e.y,0))}const Un=32640;function $u(i,e,r,a,c,u,p,f,_,v,w,E,P,k,L){const $=function(ne,K,re,ge,fe,De,Fe,Me){const Ie=ge.layout.get("text-rotate").evaluate(De,{})*Math.PI/180,Te=[];for(const Pe of K.positionedLines)for(const Ce of Pe.positionedGlyphs){if(!Ce.rect)continue;const be=Ce.rect||{};let $e=4,Ve=!0,it=1,kt=0;const Bt=(fe||Me)&&Ce.vertical,Kt=Ce.metrics.advance*Ce.scale/2;if(Me&&K.verticalizable&&(kt=Pe.lineOffset/2-(Ce.imageName?-(ii-Ce.metrics.width*Ce.scale)/2:(Ce.scale-1)*ii)),Ce.imageName){const Nt=Fe[Ce.imageName];Ve=Nt.sdf,it=Nt.pixelRatio,$e=1/it}const ir=fe?[Ce.x+Kt,Ce.y]:[0,0];let ai=fe?[0,0]:[Ce.x+Kt+re[0],Ce.y+re[1]-kt],Zt=[0,0];Bt&&(Zt=ai,ai=[0,0]);const Jt=(Ce.metrics.left-$e)*Ce.scale-Kt+ai[0],si=(-Ce.metrics.top-$e)*Ce.scale+ai[1],vi=Jt+be.w*Ce.scale/it,zi=si+be.h*Ce.scale/it,Xt=new He(Jt,si),oi=new He(vi,si),bi=new He(Jt,zi),Ai=new He(vi,zi);if(Bt){const Nt=new He(-Kt,Kt-Tl),li=-Math.PI/2,rt=12-Kt,Zi=new He(22-rt,-(Ce.imageName?rt:0)),ci=new He(...Zt);Xt._rotateAround(li,Nt)._add(Zi)._add(ci),oi._rotateAround(li,Nt)._add(Zi)._add(ci),bi._rotateAround(li,Nt)._add(Zi)._add(ci),Ai._rotateAround(li,Nt)._add(Zi)._add(ci)}if(Ie){const Nt=Math.sin(Ie),li=Math.cos(Ie),rt=[li,-Nt,Nt,li];Xt._matMult(rt),oi._matMult(rt),bi._matMult(rt),Ai._matMult(rt)}const Li=new He(0,0),Di=new He(0,0);Te.push({tl:Xt,tr:oi,bl:bi,br:Ai,tex:be,writingMode:K.writingMode,glyphOffset:ir,sectionIndex:Ce.sectionIndex,isSDF:Ve,pixelOffsetTL:Li,pixelOffsetBR:Di,minFontScaleX:0,minFontScaleY:0})}return Te}(0,r,f,c,u,p,a,i.allowVerticalPlacement),N=i.textSizeData;let J=null;N.kind==="source"?(J=[sn*c.layout.get("text-size").evaluate(p,{})],J[0]>Un&&dt(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):N.kind==="composite"&&(J=[sn*k.compositeTextSizes[0].evaluate(p,{},L),sn*k.compositeTextSizes[1].evaluate(p,{},L)],(J[0]>Un||J[1]>Un)&&dt(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),i.addSymbols(i.text,$,J,f,u,p,v,e,_.lineStartIndex,_.lineLength,P,L);for(const ne of w)E[ne]=i.text.placedSymbolArray.length-1;return 4*$.length}function Gu(i){for(const e in i)return i[e];return null}function Mf(i,e,r,a){const c=i.compareText;if(e in c){const u=c[e];for(let p=u.length-1;p>=0;p--)if(a.dist(u[p])<r)return!0}else c[e]=[];return c[e].push(a),!1}const Pf=Bn.VectorTileFeature.types,kf=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Pl(i,e,r,a,c,u,p,f,_,v,w,E,P){const k=f?Math.min(Un,Math.round(f[0])):0,L=f?Math.min(Un,Math.round(f[1])):0;i.emplaceBack(e,r,Math.round(32*a),Math.round(32*c),u,p,(k<<1)+(_?1:0),L,16*v,16*w,256*E,256*P)}function Rc(i,e,r){i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r)}function zf(i){for(const e of i.sections)if(Gi(e.text))return!0;return!1}class Bc{constructor(e){this.layoutVertexArray=new o,this.indexArray=new d,this.programConfigurations=e,this.segments=new x,this.dynamicLayoutVertexArray=new t,this.opacityVertexArray=new n,this.hasVisibleVertices=!1,this.placedSymbolArray=new ao}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,r,a,c){this.isEmpty()||(a&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ef.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,tf.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,kf,!0),this.opacityVertexBuffer.itemSize=1),(a||c)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}ke("SymbolBuffers",Bc);class Fc{constructor(e,r,a){this.layoutVertexArray=new e,this.layoutAttributes=r,this.indexArray=new a,this.segments=new x,this.collisionVertexArray=new l}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,rf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}ke("CollisionBuffers",Fc);class as{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(p=>p.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=fc([]),this.placementViewportMatrix=fc([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=zu(this.zoom,r["text-size"]),this.iconSizeData=zu(this.zoom,r["icon-size"]);const a=this.layers[0].layout,c=a.get("symbol-sort-key"),u=a.get("symbol-z-order");this.canOverlap=Uc(a,"text-overlap","text-allow-overlap")!=="never"||Uc(a,"icon-overlap","icon-allow-overlap")!=="never"||a.get("text-ignore-placement")||a.get("icon-ignore-placement"),this.sortFeaturesByKey=u!=="viewport-y"&&!c.isConstant(),this.sortFeaturesByY=(u==="viewport-y"||u==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,a.get("symbol-placement")==="point"&&(this.writingModes=a.get("text-writing-mode").map(p=>h.WritingMode[p])),this.stateDependentLayerIds=this.layers.filter(p=>p.isStateDependent()).map(p=>p.id),this.sourceID=e.sourceID}createArrays(){this.text=new Bc(new tt(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Bc(new tt(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new rn,this.lineVertexArray=new na,this.symbolInstances=new ml}calculateGlyphDependencies(e,r,a,c,u){for(let p=0;p<e.length;p++)if(r[e.charCodeAt(p)]=!0,(a||c)&&u){const f=yo[e.charAt(p)];f&&(r[f.charCodeAt(0)]=!0)}}populate(e,r,a){const c=this.layers[0],u=c.layout,p=u.get("text-font"),f=u.get("text-field"),_=u.get("icon-image"),v=(f.value.kind!=="constant"||f.value.value instanceof ei&&!f.value.value.isEmpty()||f.value.value.toString().length>0)&&(p.value.kind!=="constant"||p.value.value.length>0),w=_.value.kind!=="constant"||!!_.value.value||Object.keys(_.parameters).length>0,E=u.get("symbol-sort-key");if(this.features=[],!v&&!w)return;const P=r.iconDependencies,k=r.glyphDependencies,L=r.availableImages,$=new Pt(this.zoom);for(const{feature:N,id:J,index:ne,sourceLayerIndex:K}of e){const re=c._featureFilter.needGeometry,ge=ki(N,re);if(!c._featureFilter.filter($,ge,a))continue;let fe,De;if(re||(ge.geometry=ni(N)),v){const Me=c.getValueAndResolveTokens("text-field",ge,a,L),Ie=ei.factory(Me);zf(Ie)&&(this.hasRTLText=!0),(!this.hasRTLText||tn()==="unavailable"||this.hasRTLText&&Ei.isParsed())&&(fe=af(Ie,c,ge))}if(w){const Me=c.getValueAndResolveTokens("icon-image",ge,a,L);De=Me instanceof fi?Me:fi.fromString(Me)}if(!fe&&!De)continue;const Fe=this.sortFeaturesByKey?E.evaluate(ge,{},a):void 0;if(this.features.push({id:J,text:fe,icon:De,index:ne,sourceLayerIndex:K,geometry:ge.geometry,properties:N.properties,type:Pf[N.type],sortKey:Fe}),De&&(P[De.name]=!0),fe){const Me=p.evaluate(ge,{},a).join(","),Ie=u.get("text-rotation-alignment")!=="viewport"&&u.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(h.WritingMode.vertical)>=0;for(const Te of fe.sections)if(Te.image)P[Te.image.name]=!0;else{const Pe=Os(fe.toString()),Ce=Te.fontStack||Me,be=k[Ce]=k[Ce]||{};this.calculateGlyphDependencies(Te.text,be,Ie,this.allowVerticalPlacement,Pe)}}}u.get("symbol-placement")==="line"&&(this.features=function(N){const J={},ne={},K=[];let re=0;function ge(Me){K.push(N[Me]),re++}function fe(Me,Ie,Te){const Pe=ne[Me];return delete ne[Me],ne[Ie]=Pe,K[Pe].geometry[0].pop(),K[Pe].geometry[0]=K[Pe].geometry[0].concat(Te[0]),Pe}function De(Me,Ie,Te){const Pe=J[Ie];return delete J[Ie],J[Me]=Pe,K[Pe].geometry[0].shift(),K[Pe].geometry[0]=Te[0].concat(K[Pe].geometry[0]),Pe}function Fe(Me,Ie,Te){const Pe=Te?Ie[0][Ie[0].length-1]:Ie[0][0];return`${Me}:${Pe.x}:${Pe.y}`}for(let Me=0;Me<N.length;Me++){const Ie=N[Me],Te=Ie.geometry,Pe=Ie.text?Ie.text.toString():null;if(!Pe){ge(Me);continue}const Ce=Fe(Pe,Te),be=Fe(Pe,Te,!0);if(Ce in ne&&be in J&&ne[Ce]!==J[be]){const $e=De(Ce,be,Te),Ve=fe(Ce,be,K[$e].geometry);delete J[Ce],delete ne[be],ne[Fe(Pe,K[Ve].geometry,!0)]=Ve,K[$e].geometry=null}else Ce in ne?fe(Ce,be,Te):be in J?De(Ce,be,Te):(ge(Me),J[Ce]=re-1,ne[be]=re-1)}return K.filter(Me=>Me.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((N,J)=>N.sortKey-J.sortKey)}update(e,r,a){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,r,this.layers,a),this.icon.programConfigurations.updatePaintArrays(e,r,this.layers,a))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,r){const a=this.lineVertexArray.length;if(e.segment!==void 0){let c=e.dist(r[e.segment+1]),u=e.dist(r[e.segment]);const p={};for(let f=e.segment+1;f<r.length;f++)p[f]={x:r[f].x,y:r[f].y,tileUnitDistanceFromAnchor:c},f<r.length-1&&(c+=r[f+1].dist(r[f]));for(let f=e.segment||0;f>=0;f--)p[f]={x:r[f].x,y:r[f].y,tileUnitDistanceFromAnchor:u},f>0&&(u+=r[f-1].dist(r[f]));for(let f=0;f<r.length;f++){const _=p[f];this.lineVertexArray.emplaceBack(_.x,_.y,_.tileUnitDistanceFromAnchor)}}return{lineStartIndex:a,lineLength:this.lineVertexArray.length-a}}addSymbols(e,r,a,c,u,p,f,_,v,w,E,P){const k=e.indexArray,L=e.layoutVertexArray,$=e.segments.prepareSegment(4*r.length,L,k,this.canOverlap?p.sortKey:void 0),N=this.glyphOffsetArray.length,J=$.vertexLength,ne=this.allowVerticalPlacement&&f===h.WritingMode.vertical?Math.PI/2:0,K=p.text&&p.text.sections;for(let re=0;re<r.length;re++){const{tl:ge,tr:fe,bl:De,br:Fe,tex:Me,pixelOffsetTL:Ie,pixelOffsetBR:Te,minFontScaleX:Pe,minFontScaleY:Ce,glyphOffset:be,isSDF:$e,sectionIndex:Ve}=r[re],it=$.vertexLength,kt=be[1];Pl(L,_.x,_.y,ge.x,kt+ge.y,Me.x,Me.y,a,$e,Ie.x,Ie.y,Pe,Ce),Pl(L,_.x,_.y,fe.x,kt+fe.y,Me.x+Me.w,Me.y,a,$e,Te.x,Ie.y,Pe,Ce),Pl(L,_.x,_.y,De.x,kt+De.y,Me.x,Me.y+Me.h,a,$e,Ie.x,Te.y,Pe,Ce),Pl(L,_.x,_.y,Fe.x,kt+Fe.y,Me.x+Me.w,Me.y+Me.h,a,$e,Te.x,Te.y,Pe,Ce),Rc(e.dynamicLayoutVertexArray,_,ne),k.emplaceBack(it,it+1,it+2),k.emplaceBack(it+1,it+2,it+3),$.vertexLength+=4,$.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(be[0]),re!==r.length-1&&Ve===r[re+1].sectionIndex||e.programConfigurations.populatePaintArrays(L.length,p,p.index,{},P,K&&K[Ve])}e.placedSymbolArray.emplaceBack(_.x,_.y,N,this.glyphOffsetArray.length-N,J,v,w,_.segment,a?a[0]:0,a?a[1]:0,c[0],c[1],f,0,!1,0,E)}_addCollisionDebugVertex(e,r,a,c,u,p){return r.emplaceBack(0,0),e.emplaceBack(a.x,a.y,c,u,Math.round(p.x),Math.round(p.y))}addCollisionDebugVertices(e,r,a,c,u,p,f){const _=u.segments.prepareSegment(4,u.layoutVertexArray,u.indexArray),v=_.vertexLength,w=u.layoutVertexArray,E=u.collisionVertexArray,P=f.anchorX,k=f.anchorY;this._addCollisionDebugVertex(w,E,p,P,k,new He(e,r)),this._addCollisionDebugVertex(w,E,p,P,k,new He(a,r)),this._addCollisionDebugVertex(w,E,p,P,k,new He(a,c)),this._addCollisionDebugVertex(w,E,p,P,k,new He(e,c)),_.vertexLength+=4;const L=u.indexArray;L.emplaceBack(v,v+1),L.emplaceBack(v+1,v+2),L.emplaceBack(v+2,v+3),L.emplaceBack(v+3,v),_.primitiveLength+=4}addDebugCollisionBoxes(e,r,a,c){for(let u=e;u<r;u++){const p=this.collisionBoxArray.get(u);this.addCollisionDebugVertices(p.x1,p.y1,p.x2,p.y2,c?this.textCollisionBox:this.iconCollisionBox,p.anchorPoint,a)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Fc(s,yu.members,m),this.iconCollisionBox=new Fc(s,yu.members,m);for(let e=0;e<this.symbolInstances.length;e++){const r=this.symbolInstances.get(e);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(e,r,a,c,u,p,f,_,v){const w={};for(let E=r;E<a;E++){const P=e.get(E);w.textBox={x1:P.x1,y1:P.y1,x2:P.x2,y2:P.y2,anchorPointX:P.anchorPointX,anchorPointY:P.anchorPointY},w.textFeatureIndex=P.featureIndex;break}for(let E=c;E<u;E++){const P=e.get(E);w.verticalTextBox={x1:P.x1,y1:P.y1,x2:P.x2,y2:P.y2,anchorPointX:P.anchorPointX,anchorPointY:P.anchorPointY},w.verticalTextFeatureIndex=P.featureIndex;break}for(let E=p;E<f;E++){const P=e.get(E);w.iconBox={x1:P.x1,y1:P.y1,x2:P.x2,y2:P.y2,anchorPointX:P.anchorPointX,anchorPointY:P.anchorPointY},w.iconFeatureIndex=P.featureIndex;break}for(let E=_;E<v;E++){const P=e.get(E);w.verticalIconBox={x1:P.x1,y1:P.y1,x2:P.x2,y2:P.y2,anchorPointX:P.anchorPointX,anchorPointY:P.anchorPointY},w.verticalIconFeatureIndex=P.featureIndex;break}return w}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let r=0;r<this.symbolInstances.length;r++){const a=this.symbolInstances.get(r);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,a.textBoxStartIndex,a.textBoxEndIndex,a.verticalTextBoxStartIndex,a.verticalTextBoxEndIndex,a.iconBoxStartIndex,a.iconBoxEndIndex,a.verticalIconBoxStartIndex,a.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,r){const a=e.placedSymbolArray.get(r),c=a.vertexStartIndex+4*a.numGlyphs;for(let u=a.vertexStartIndex;u<c;u+=4)e.indexArray.emplaceBack(u,u+1,u+2),e.indexArray.emplaceBack(u+1,u+2,u+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const r=Math.sin(e),a=Math.cos(e),c=[],u=[],p=[];for(let f=0;f<this.symbolInstances.length;++f){p.push(f);const _=this.symbolInstances.get(f);c.push(0|Math.round(r*_.anchorX+a*_.anchorY)),u.push(_.featureIndex)}return p.sort((f,_)=>c[f]-c[_]||u[_]-u[f]),p}addToSortKeyRanges(e,r){const a=this.sortKeyRanges[this.sortKeyRanges.length-1];a&&a.sortKey===r?a.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const r of this.symbolInstanceIndexes){const a=this.symbolInstances.get(r);this.featureSortOrder.push(a.featureIndex),[a.rightJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.leftJustifiedTextSymbolIndex].forEach((c,u,p)=>{c>=0&&p.indexOf(c)===u&&this.addIndicesForPlacedSymbol(this.text,c)}),a.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,a.verticalPlacedTextSymbolIndex),a.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.placedIconSymbolIndex),a.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ke("SymbolBucket",as,{omit:["layers","collisionBoxArray","features","compareText"]}),as.MAX_GLYPHS=65535,as.addDynamicAttributes=Rc;const Lf=new Ii({"symbol-placement":new Ue(le.layout_symbol["symbol-placement"]),"symbol-spacing":new Ue(le.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ue(le.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ze(le.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ue(le.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Ue(le.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Ue(le.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Ue(le.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ue(le.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ue(le.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ze(le.layout_symbol["icon-size"]),"icon-text-fit":new Ue(le.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Ue(le.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ze(le.layout_symbol["icon-image"]),"icon-rotate":new Ze(le.layout_symbol["icon-rotate"]),"icon-padding":new Ze(le.layout_symbol["icon-padding"]),"icon-keep-upright":new Ue(le.layout_symbol["icon-keep-upright"]),"icon-offset":new Ze(le.layout_symbol["icon-offset"]),"icon-anchor":new Ze(le.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ue(le.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ue(le.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ue(le.layout_symbol["text-rotation-alignment"]),"text-field":new Ze(le.layout_symbol["text-field"]),"text-font":new Ze(le.layout_symbol["text-font"]),"text-size":new Ze(le.layout_symbol["text-size"]),"text-max-width":new Ze(le.layout_symbol["text-max-width"]),"text-line-height":new Ue(le.layout_symbol["text-line-height"]),"text-letter-spacing":new Ze(le.layout_symbol["text-letter-spacing"]),"text-justify":new Ze(le.layout_symbol["text-justify"]),"text-radial-offset":new Ze(le.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ue(le.layout_symbol["text-variable-anchor"]),"text-anchor":new Ze(le.layout_symbol["text-anchor"]),"text-max-angle":new Ue(le.layout_symbol["text-max-angle"]),"text-writing-mode":new Ue(le.layout_symbol["text-writing-mode"]),"text-rotate":new Ze(le.layout_symbol["text-rotate"]),"text-padding":new Ue(le.layout_symbol["text-padding"]),"text-keep-upright":new Ue(le.layout_symbol["text-keep-upright"]),"text-transform":new Ze(le.layout_symbol["text-transform"]),"text-offset":new Ze(le.layout_symbol["text-offset"]),"text-allow-overlap":new Ue(le.layout_symbol["text-allow-overlap"]),"text-overlap":new Ue(le.layout_symbol["text-overlap"]),"text-ignore-placement":new Ue(le.layout_symbol["text-ignore-placement"]),"text-optional":new Ue(le.layout_symbol["text-optional"])});var Oc={paint:new Ii({"icon-opacity":new Ze(le.paint_symbol["icon-opacity"]),"icon-color":new Ze(le.paint_symbol["icon-color"]),"icon-halo-color":new Ze(le.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ze(le.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ze(le.paint_symbol["icon-halo-blur"]),"icon-translate":new Ue(le.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ue(le.paint_symbol["icon-translate-anchor"]),"text-opacity":new Ze(le.paint_symbol["text-opacity"]),"text-color":new Ze(le.paint_symbol["text-color"],{runtimeType:Ti,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new Ze(le.paint_symbol["text-halo-color"]),"text-halo-width":new Ze(le.paint_symbol["text-halo-width"]),"text-halo-blur":new Ze(le.paint_symbol["text-halo-blur"]),"text-translate":new Ue(le.paint_symbol["text-translate"]),"text-translate-anchor":new Ue(le.paint_symbol["text-translate-anchor"])}),layout:Lf};class ju{constructor(e){if(e.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Hi,this.defaultValue=e}evaluate(e){if(e.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(e.formattedSection))return r.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ke("FormatSectionOverride",ju,{omit:["defaultValue"]});class kl extends Yi{constructor(e){super(e,Oc)}recalculate(e,r){if(super.recalculate(e,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"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 a=this.layout.get("text-writing-mode");if(a){const c=[];for(const u of a)c.indexOf(u)<0&&c.push(u);this.layout._values["text-writing-mode"]=c}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,r,a,c){const u=this.layout.get(e).evaluate(r,{},a,c),p=this._unevaluatedLayout._values[e];return p.isDataDriven()||Ea(p.value)||!u?u:function(f,_){return _.replace(/{([^{}]+)}/g,(v,w)=>w in f?String(f[w]):"")}(r.properties,u)}createBucket(e){return new as(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Oc.paint.overridableProperties){if(!kl.hasPaintOverride(this.layout,e))continue;const r=this.paint.get(e),a=new ju(r),c=new Cs(a,r.property.specification);let u=null;u=r.value.kind==="constant"||r.value.kind==="source"?new Ms("source",c):new Ps("composite",c,r.value.zoomStops),this.paint._values[e]=new Ki(r.property,u,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,a){return!(!this.layout||r.isDataDriven()||a.isDataDriven())&&kl.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){const a=e.get("text-field"),c=Oc.paint.properties[r];let u=!1;const p=f=>{for(const _ of f)if(c.overrides&&c.overrides.hasOverride(_))return void(u=!0)};if(a.value.kind==="constant"&&a.value.value instanceof ei)p(a.value.value.sections);else if(a.value.kind==="source"){const f=v=>{u||(v instanceof C&&B(v.value)===ri?p(v.value.sections):v instanceof Ta?p(v.sections):v.eachChild(f))},_=a.value;_._styleExpression&&f(_._styleExpression.expression)}return u}}function Uc(i,e,r){let a="never";const c=i.get(e);return c?a=c:i.get(r)&&(a="always"),a}var Df={paint:new Ii({"background-color":new Ue(le.paint_background["background-color"]),"background-pattern":new qs(le.paint_background["background-pattern"]),"background-opacity":new Ue(le.paint_background["background-opacity"])})},Rf={paint:new Ii({"raster-opacity":new Ue(le.paint_raster["raster-opacity"]),"raster-hue-rotate":new Ue(le.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Ue(le.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Ue(le.paint_raster["raster-brightness-max"]),"raster-saturation":new Ue(le.paint_raster["raster-saturation"]),"raster-contrast":new Ue(le.paint_raster["raster-contrast"]),"raster-resampling":new Ue(le.paint_raster["raster-resampling"]),"raster-fade-duration":new Ue(le.paint_raster["raster-fade-duration"])})};class Bf extends Yi{constructor(e){super(e,{}),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=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}const Ff={circle:class extends Yi{constructor(i){super(i,mc)}createBucket(i){return new Ji(i)}queryRadius(i){const e=i;return nn("circle-radius",this,e)+nn("circle-stroke-width",this,e)+Ya(this.paint.get("circle-translate"))}queryIntersectsFeature(i,e,r,a,c,u,p,f){const _=Ja(i,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),u.angle,p),v=this.paint.get("circle-radius").evaluate(e,r)+this.paint.get("circle-stroke-width").evaluate(e,r),w=this.paint.get("circle-pitch-alignment")==="map",E=w?_:function(k,L){return k.map($=>tu($,L))}(_,f),P=w?v*p:v;for(const k of a)for(const L of k){const $=w?L:tu(L,f);let N=P;const J=_l([],[L.x,L.y,0,1],f);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?N*=J[3]/u.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(N*=u.cameraToCenterDistance/J[3]),Ka(E,$,N))return!0}return!1}},heatmap:class extends Yi{createBucket(i){return new iu(i)}constructor(i){super(i,fm),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){i==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=nu({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}},hillshade:class extends Yi{constructor(i){super(i,gm)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}},fill:class extends Yi{constructor(i){super(i,zm)}recalculate(i,e){super.recalculate(i,e);const r=this.paint._values["fill-outline-color"];r.value.kind==="constant"&&r.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new Sc(i)}queryRadius(){return Ya(this.paint.get("fill-translate"))}queryIntersectsFeature(i,e,r,a,c,u,p){return qt(Ja(i,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),u.angle,p),a)}isTileClipped(){return!0}},"fill-extrusion":class extends Yi{constructor(i){super(i,Zm)}createBucket(i){return new Ic(i)}queryRadius(){return Ya(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(i,e,r,a,c,u,p,f){const _=Ja(i,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),u.angle,p),v=this.paint.get("fill-extrusion-height").evaluate(e,r),w=this.paint.get("fill-extrusion-base").evaluate(e,r),E=function(k,L,$,N){const J=[];for(const ne of k){const K=[ne.x,ne.y,0,1];_l(K,K,L),J.push(new He(K[0]/K[3],K[1]/K[3]))}return J}(_,f),P=function(k,L,$,N){const J=[],ne=[],K=N[8]*L,re=N[9]*L,ge=N[10]*L,fe=N[11]*L,De=N[8]*$,Fe=N[9]*$,Me=N[10]*$,Ie=N[11]*$;for(const Te of k){const Pe=[],Ce=[];for(const be of Te){const $e=be.x,Ve=be.y,it=N[0]*$e+N[4]*Ve+N[12],kt=N[1]*$e+N[5]*Ve+N[13],Bt=N[2]*$e+N[6]*Ve+N[14],Kt=N[3]*$e+N[7]*Ve+N[15],ir=Bt+ge,ai=Kt+fe,Zt=it+De,Jt=kt+Fe,si=Bt+Me,vi=Kt+Ie,zi=new He((it+K)/ai,(kt+re)/ai);zi.z=ir/ai,Pe.push(zi);const Xt=new He(Zt/vi,Jt/vi);Xt.z=si/vi,Ce.push(Xt)}J.push(Pe),ne.push(Ce)}return[J,ne]}(a,w,v,f);return function(k,L,$){let N=1/0;qt($,L)&&(N=pu($,L[0]));for(let J=0;J<L.length;J++){const ne=L[J],K=k[J];for(let re=0;re<ne.length-1;re++){const ge=ne[re],fe=[ge,ne[re+1],K[re+1],K[re],ge];Rr($,fe)&&(N=Math.min(N,pu($,fe)))}}return N!==1/0&&N}(P[0],P[1],E)}},line:class extends Yi{constructor(i){super(i,fu),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(i){i==="line-gradient"&&(this.stepInterpolant=this._transitionablePaint._values["line-gradient"].value.expression._styleExpression.expression instanceof qn,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER)}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(i,e){super.recalculate(i,e),this.paint._values["line-floorwidth"]=gu.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,i)}createBucket(i){return new Ac(i)}queryRadius(i){const e=i,r=_u(nn("line-width",this,e),nn("line-gap-width",this,e)),a=nn("line-offset",this,e);return r/2+Math.abs(a)+Ya(this.paint.get("line-translate"))}queryIntersectsFeature(i,e,r,a,c,u,p){const f=Ja(i,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),u.angle,p),_=p/2*_u(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),v=this.paint.get("line-offset").evaluate(e,r);return v&&(a=function(w,E){const P=[];for(let k=0;k<w.length;k++){const L=w[k],$=[];for(let N=0;N<L.length;N++){const J=L[N-1],ne=L[N],K=L[N+1],re=N===0?new He(0,0):ne.sub(J)._unit()._perp(),ge=N===L.length-1?new He(0,0):K.sub(ne)._unit()._perp(),fe=re._add(ge)._unit(),De=fe.x*ge.x+fe.y*ge.y;De!==0&&fe._mult(1/De),$.push(fe._mult(E)._add(ne))}P.push($)}return P}(a,v*p)),function(w,E,P){for(let k=0;k<E.length;k++){const L=E[k];if(w.length>=3){for(let $=0;$<L.length;$++)if(Qi(w,L[$]))return!0}if(Dt(w,L,P))return!0}return!1}(f,a,_)}isTileClipped(){return!0}},symbol:kl,background:class extends Yi{constructor(i){super(i,Df)}},raster:class extends Yi{constructor(i){super(i,Rf)}}};class Of{constructor(e){this._callback=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){delete this._channel,this._callback=()=>{}}}const Vc=63710088e-1;class Vt{constructor(e,r){if(isNaN(e)||isNaN(r))throw new Error(`Invalid LngLat object: (${e}, ${r})`);if(this.lng=+e,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 Vt(ee(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const r=Math.PI/180,a=this.lat*r,c=e.lat*r,u=Math.sin(a)*Math.sin(c)+Math.cos(a)*Math.cos(c)*Math.cos((e.lng-this.lng)*r);return Vc*Math.acos(Math.min(u,1))}toBounds(e=0){const r=360*e/40075017,a=r/Math.cos(Math.PI/180*this.lat);return new qu(new Vt(this.lng-a,this.lat-r),new Vt(this.lng+a,this.lat+r))}static convert(e){if(e instanceof Vt)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Vt(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new Vt(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}class ss{constructor(e,r){e&&(r?this.setSouthWest(e).setNorthEast(r):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 Vt?new Vt(e.lng,e.lat):Vt.convert(e),this}setSouthWest(e){return this._sw=e instanceof Vt?new Vt(e.lng,e.lat):Vt.convert(e),this}extend(e){const r=this._sw,a=this._ne;let c,u;if(e instanceof Vt)c=e,u=e;else{if(!(e instanceof ss))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(ss.convert(e)):this.extend(Vt.convert(e)):this;if(c=e._sw,u=e._ne,!c||!u)return this}return r||a?(r.lng=Math.min(c.lng,r.lng),r.lat=Math.min(c.lat,r.lat),a.lng=Math.max(u.lng,a.lng),a.lat=Math.max(u.lat,a.lat)):(this._sw=new Vt(c.lng,c.lat),this._ne=new Vt(u.lng,u.lat)),this}getCenter(){return new Vt((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 Vt(this.getWest(),this.getNorth())}getSouthEast(){return new Vt(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:r,lat:a}=Vt.convert(e);let c=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(c=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=a&&a<=this._ne.lat&&c}static convert(e){return e instanceof ss?e:e&&new ss(e)}}var qu=ss;const Zu=2*Math.PI*Vc;function Xu(i){return Zu*Math.cos(i*Math.PI/180)}function Wu(i){return(180+i)/360}function Hu(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function Ku(i,e){return i/Xu(e)}function Nc(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class zl{constructor(e,r,a=0){this.x=+e,this.y=+r,this.z=+a}static fromLngLat(e,r=0){const a=Vt.convert(e);return new zl(Wu(a.lng),Hu(a.lat),Ku(r,a.lat))}toLngLat(){return new Vt(360*this.x-180,Nc(this.y))}toAltitude(){return this.z*Xu(Nc(this.y))}meterInMercatorCoordinateUnits(){return 1/Zu*(e=Nc(this.y),1/Math.cos(e*Math.PI/180));var e}}function Yu(i,e,r){var a=2*Math.PI*6378137/256/Math.pow(2,r);return[i*a-2*Math.PI*6378137/2,e*a-2*Math.PI*6378137/2]}class $c{constructor(e,r,a){if(e<0||e>25||a<0||a>=Math.pow(2,e)||r<0||r>=Math.pow(2,e))throw new Error(`x=${r}, y=${a}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=r,this.y=a,this.key=vo(0,e,e,r,a)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,r,a){const c=(p=this.y,f=this.z,_=Yu(256*(u=this.x),256*(p=Math.pow(2,f)-p-1),f),v=Yu(256*(u+1),256*(p+1),f),_[0]+","+_[1]+","+v[0]+","+v[1]);var u,p,f,_,v;const w=function(E,P,k){let L,$="";for(let N=E;N>0;N--)L=1<<N-1,$+=(P&L?1:0)+(k&L?2:0);return $}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(a==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,r>1?"@2x":"").replace(/{quadkey}/g,w).replace(/{bbox-epsg-3857}/g,c)}isChildOf(e){const r=this.z-e.z;return r>0&&e.x===this.x>>r&&e.y===this.y>>r}getTilePoint(e){const r=Math.pow(2,this.z);return new He((e.x*r-this.x)*gt,(e.y*r-this.y)*gt)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Ju{constructor(e,r){this.wrap=e,this.canonical=r,this.key=vo(e,r.z,r.z,r.x,r.y)}}class tr{constructor(e,r,a,c,u){if(e<a)throw new Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${a}`);this.overscaledZ=e,this.wrap=r,this.canonical=new $c(a,+c,+u),this.key=vo(r,e,a,c,u)}clone(){return new tr(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-e;return e>this.canonical.z?new tr(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new tr(e,this.wrap,e,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(e,r){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const a=this.canonical.z-e;return e>this.canonical.z?vo(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y):vo(this.wrap*+r,e,e,this.canonical.x>>a,this.canonical.y>>a)}isChildOf(e){if(e.wrap!==this.wrap)return!1;const r=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ<this.overscaledZ&&e.canonical.x===this.canonical.x>>r&&e.canonical.y===this.canonical.y>>r}children(e){if(this.overscaledZ>=e)return[new tr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,a=2*this.canonical.x,c=2*this.canonical.y;return[new tr(r,this.wrap,r,a,c),new tr(r,this.wrap,r,a+1,c),new tr(r,this.wrap,r,a,c+1),new tr(r,this.wrap,r,a+1,c+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new tr(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new tr(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Ju(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new zl(e.x-this.wrap,e.y))}}function vo(i,e,r,a,c){(i*=2)<0&&(i=-1*i-1);const u=1<<r;return(u*u*i+u*c+a).toString(36)+r.toString(36)+e.toString(36)}ke("CanonicalTileID",$c),ke("OverscaledTileID",tr,{omit:["posMatrix"]});class Qu{constructor(e,r,a){if(this.uid=e,r.height!==r.width)throw new RangeError("DEM tiles must be square");if(a&&a!=="mapbox"&&a!=="terrarium")return void dt(`"${a}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=r.height;const c=this.dim=r.height-2;this.data=new Uint32Array(r.data.buffer),this.encoding=a||"mapbox";for(let u=0;u<c;u++)this.data[this._idx(-1,u)]=this.data[this._idx(0,u)],this.data[this._idx(c,u)]=this.data[this._idx(c-1,u)],this.data[this._idx(u,-1)]=this.data[this._idx(u,0)],this.data[this._idx(u,c)]=this.data[this._idx(u,c-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(c,-1)]=this.data[this._idx(c-1,0)],this.data[this._idx(-1,c)]=this.data[this._idx(0,c-1)],this.data[this._idx(c,c)]=this.data[this._idx(c-1,c-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let u=0;u<c;u++)for(let p=0;p<c;p++){const f=this.get(u,p);f>this.max&&(this.max=f),f<this.min&&(this.min=f)}}get(e,r){const a=new Uint8Array(this.data.buffer),c=4*this._idx(e,r);return(this.encoding==="terrarium"?this._unpackTerrarium:this._unpackMapbox)(a[c],a[c+1],a[c+2])}getUnpackVector(){return this.encoding==="terrarium"?[256,1,1/256,32768]:[6553.6,25.6,.1,1e4]}_idx(e,r){if(e<-1||e>=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+(e+1)}_unpackMapbox(e,r,a){return(256*e*256+256*r+a)/10-1e4}_unpackTerrarium(e,r,a){return 256*e+r+a/256-32768}getPixels(){return new er({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,r,a){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let c=r*this.dim,u=r*this.dim+this.dim,p=a*this.dim,f=a*this.dim+this.dim;switch(r){case-1:c=u-1;break;case 1:u=c+1}switch(a){case-1:p=f-1;break;case 1:f=p+1}const _=-r*this.dim,v=-a*this.dim;for(let w=p;w<f;w++)for(let E=c;E<u;E++)this.data[this._idx(E,w)]=e.data[this._idx(E+_,w+v)]}}ke("DEMData",Qu);class ed{constructor(e){this._stringToNumber={},this._numberToString=[];for(let r=0;r<e.length;r++){const a=e[r];this._stringToNumber[a]=r,this._numberToString[r]=a}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class td{constructor(e,r,a,c,u){this.type="Feature",this._vectorTileFeature=e,e._z=r,e._x=a,e._y=c,this.properties=e.properties,this.id=u}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const r in this)r!=="_geometry"&&r!=="_vectorTileFeature"&&(e[r]=this[r]);return e}}class id{constructor(e,r){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Pn(gt,16,0),this.grid3D=new Pn(gt,16,0),this.featureIndexArray=new fl,this.promoteId=r}insert(e,r,a,c,u,p){const f=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(a,c,u);const _=p?this.grid3D:this.grid;for(let v=0;v<r.length;v++){const w=r[v],E=[1/0,1/0,-1/0,-1/0];for(let P=0;P<w.length;P++){const k=w[P];E[0]=Math.min(E[0],k.x),E[1]=Math.min(E[1],k.y),E[2]=Math.max(E[2],k.x),E[3]=Math.max(E[3],k.y)}E[0]<gt&&E[1]<gt&&E[2]>=0&&E[3]>=0&&_.insert(f,E[0],E[1],E[2],E[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Bn.VectorTile(new Cc(this.rawTileData)).layers,this.sourceLayerCoder=new ed(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(e,r,a,c){this.loadVTLayers();const u=e.params||{},p=gt/e.tileSize/e.scale,f=zs(u.filter),_=e.queryGeometry,v=e.queryPadding*p,w=nd(_),E=this.grid.query(w.minX-v,w.minY-v,w.maxX+v,w.maxY+v),P=nd(e.cameraQueryGeometry),k=this.grid3D.query(P.minX-v,P.minY-v,P.maxX+v,P.maxY+v,(N,J,ne,K)=>function(re,ge,fe,De,Fe){for(const Ie of re)if(ge<=Ie.x&&fe<=Ie.y&&De>=Ie.x&&Fe>=Ie.y)return!0;const Me=[new He(ge,fe),new He(ge,Fe),new He(De,Fe),new He(De,fe)];if(re.length>2){for(const Ie of Me)if(Qi(re,Ie))return!0}for(let Ie=0;Ie<re.length-1;Ie++)if(oo(re[Ie],re[Ie+1],Me))return!0;return!1}(e.cameraQueryGeometry,N-v,J-v,ne+v,K+v));for(const N of k)E.push(N);E.sort(Uf);const L={};let $;for(let N=0;N<E.length;N++){const J=E[N];if(J===$)continue;$=J;const ne=this.featureIndexArray.get(J);let K=null;this.loadMatchingFeature(L,ne.bucketIndex,ne.sourceLayerIndex,ne.featureIndex,f,u.layers,u.availableImages,r,a,c,(re,ge,fe)=>(K||(K=ni(re)),ge.queryIntersectsFeature(_,re,fe,K,this.z,e.transform,p,e.pixelPosMatrix)))}return L}loadMatchingFeature(e,r,a,c,u,p,f,_,v,w,E){const P=this.bucketLayerIDs[r];if(p&&!function(N,J){for(let ne=0;ne<N.length;ne++)if(J.indexOf(N[ne])>=0)return!0;return!1}(p,P))return;const k=this.sourceLayerCoder.decode(a),L=this.vtLayers[k].feature(c);if(u.needGeometry){const N=ki(L,!0);if(!u.filter(new Pt(this.tileID.overscaledZ),N,this.tileID.canonical))return}else if(!u.filter(new Pt(this.tileID.overscaledZ),L))return;const $=this.getId(L,k);for(let N=0;N<P.length;N++){const J=P[N];if(p&&p.indexOf(J)<0)continue;const ne=_[J];if(!ne)continue;let K={};$&&w&&(K=w.getState(ne.sourceLayer||"_geojsonTileLayer",$));const re=Be({},v[J]);re.paint=rd(re.paint,ne.paint,L,K,f),re.layout=rd(re.layout,ne.layout,L,K,f);const ge=!E||E(L,ne,K);if(!ge)continue;const fe=new td(L,this.z,this.x,this.y,$);fe.layer=re;let De=e[J];De===void 0&&(De=e[J]=[]),De.push({featureIndex:c,feature:fe,intersectionZ:ge})}}lookupSymbolFeatures(e,r,a,c,u,p,f,_){const v={};this.loadVTLayers();const w=zs(u);for(const E of e)this.loadMatchingFeature(v,a,c,E,w,p,f,_,r);return v}hasLayer(e){for(const r of this.bucketLayerIDs)for(const a of r)if(e===a)return!0;return!1}getId(e,r){let a=e.id;return this.promoteId&&(a=e.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[r]],typeof a=="boolean"&&(a=Number(a))),a}}function rd(i,e,r,a,c){return mr(i,(u,p)=>{const f=e instanceof Ua?e.get(p):null;return f&&f.evaluate?f.evaluate(r,a,c):f})}function nd(i){let e=1/0,r=1/0,a=-1/0,c=-1/0;for(const u of i)e=Math.min(e,u.x),r=Math.min(r,u.y),a=Math.max(a,u.x),c=Math.max(c,u.y);return{minX:e,minY:r,maxX:a,maxY:c}}function Uf(i,e){return e-i}function Gc(i,e,r,a,c,u){if(c-a<=r)return;const p=a+c>>1;ad(i,e,p,a,c,u%2),Gc(i,e,r,a,p-1,u+1),Gc(i,e,r,p+1,c,u+1)}function ad(i,e,r,a,c,u){for(;c>a;){if(c-a>600){const v=c-a+1,w=r-a+1,E=Math.log(v),P=.5*Math.exp(2*E/3),k=.5*Math.sqrt(E*P*(v-P)/v)*(w-v/2<0?-1:1);ad(i,e,r,Math.max(a,Math.floor(r-w*P/v+k)),Math.min(c,Math.floor(r+(v-w)*P/v+k)),u)}const p=e[2*r+u];let f=a,_=c;for(bo(i,e,a,r),e[2*c+u]>p&&bo(i,e,a,c);f<_;){for(bo(i,e,f,_),f++,_--;e[2*f+u]<p;)f++;for(;e[2*_+u]>p;)_--}e[2*a+u]===p?bo(i,e,a,_):(_++,bo(i,e,_,c)),_<=r&&(a=_+1),r<=_&&(c=_-1)}}function bo(i,e,r,a){jc(i,r,a),jc(e,2*r,2*a),jc(e,2*r+1,2*a+1)}function jc(i,e,r){const a=i[e];i[e]=i[r],i[r]=a}function sd(i,e,r,a){const c=i-r,u=e-a;return c*c+u*u}ke("FeatureIndex",id,{omit:["rawTileData","sourceLayerCoder"]});const Vf=i=>i[0],Nf=i=>i[1];var qc;h.PerformanceMarkers=void 0,(qc=h.PerformanceMarkers||(h.PerformanceMarkers={})).create="create",qc.load="load",qc.fullLoad="fullLoad";let Ll=null,wo=[];const Zc=1e3/30,$f={mark(i){performance.mark(i)},frame(i){const e=i;Ll!=null&&wo.push(e-Ll),Ll=e},clearMetrics(){Ll=null,wo=[],performance.clearMeasures("loadTime"),performance.clearMeasures("fullLoadTime");for(const i in h.PerformanceMarkers)performance.clearMarks(h.PerformanceMarkers[i])},getPerformanceMetrics(){performance.measure("loadTime",h.PerformanceMarkers.create,h.PerformanceMarkers.load),performance.measure("fullLoadTime",h.PerformanceMarkers.create,h.PerformanceMarkers.fullLoad);const i=performance.getEntriesByName("loadTime")[0].duration,e=performance.getEntriesByName("fullLoadTime")[0].duration,r=wo.length,a=1/(wo.reduce((u,p)=>u+p,0)/r/1e3),c=wo.filter(u=>u>Zc).reduce((u,p)=>u+(p-Zc)/Zc,0);return{loadTime:i,fullLoadTime:e,fps:a,percentDroppedFrames:c/(r+c)*100}}};h.AJAXError=Er,h.ARRAY_TYPE=Br,h.Actor=class{constructor(i,e,r){this.target=i,this.parent=e,this.mapId=r,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},Ft(["receive","process"],this),this.invoker=new Of(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=Oi()?i:window}send(i,e,r,a,c=!1){const u=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(this.callbacks[u]=r);const p=fr(this.globalScope)?void 0:[];return this.target.postMessage({id:u,type:i,hasCallback:!!r,targetMapId:a,mustQueue:c,sourceMapId:this.mapId,data:Qr(e,p)},p),{cancel:()=>{r&&delete this.callbacks[u],this.target.postMessage({id:u,type:"<cancel>",targetMapId:a,sourceMapId:this.mapId})}}}receive(i){const e=i.data,r=e.id;if(r&&(!e.targetMapId||this.mapId===e.targetMapId))if(e.type==="<cancel>"){delete this.tasks[r];const a=this.cancelCallbacks[r];delete this.cancelCallbacks[r],a&&a()}else Oi()||e.mustQueue?(this.tasks[r]=e,this.taskQueue.push(r),this.invoker.trigger()):this.processTask(r,e)}process(){if(!this.taskQueue.length)return;const i=this.taskQueue.shift(),e=this.tasks[i];delete this.tasks[i],this.taskQueue.length&&this.invoker.trigger(),e&&this.processTask(i,e)}processTask(i,e){if(e.type==="<response>"){const r=this.callbacks[i];delete this.callbacks[i],r&&(e.error?r(en(e.error)):r(null,en(e.data)))}else{let r=!1;const a=fr(this.globalScope)?void 0:[],c=e.hasCallback?(f,_)=>{r=!0,delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"<response>",sourceMapId:this.mapId,error:f?Qr(f):null,data:Qr(_,a)},a)}:f=>{r=!0};let u=null;const p=en(e.data);if(this.parent[e.type])u=this.parent[e.type](e.sourceMapId,p,c);else if(this.parent.getWorkerSource){const f=e.type.split(".");u=this.parent.getWorkerSource(e.sourceMapId,f[0],p.source)[f[1]](p,c)}else c(new Error(`Could not find function ${e.type}`));!r&&u&&u.cancel&&(this.cancelCallbacks[i]=u.cancel)}}remove(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)}},h.AlphaImage=co,h.CanonicalTileID=$c,h.CollisionBoxArray=no,h.CollisionCircleLayoutArray=class extends Js{},h.Color=ut,h.DEMData=Qu,h.DataConstantProperty=Ue,h.DictionaryCoder=ed,h.EXTENT=gt,h.ErrorEvent=Gr,h.EvaluationParameters=Pt,h.Event=$r,h.Evented=Ir,h.FeatureIndex=id,h.FillBucket=Sc,h.FillExtrusionBucket=Ic,h.GeoJSONFeature=td,h.ImageAtlas=Iu,h.ImagePosition=Pc,h.KDBush=class{constructor(i,e=Vf,r=Nf,a=64,c=Float64Array){this.nodeSize=a,this.points=i;const u=i.length<65536?Uint16Array:Uint32Array,p=this.ids=new u(i.length),f=this.coords=new c(2*i.length);for(let _=0;_<i.length;_++)p[_]=_,f[2*_]=e(i[_]),f[2*_+1]=r(i[_]);Gc(p,f,a,0,p.length-1,0)}range(i,e,r,a){return function(c,u,p,f,_,v,w){const E=[0,c.length-1,0],P=[];let k,L;for(;E.length;){const $=E.pop(),N=E.pop(),J=E.pop();if(N-J<=w){for(let re=J;re<=N;re++)k=u[2*re],L=u[2*re+1],k>=p&&k<=_&&L>=f&&L<=v&&P.push(c[re]);continue}const ne=Math.floor((J+N)/2);k=u[2*ne],L=u[2*ne+1],k>=p&&k<=_&&L>=f&&L<=v&&P.push(c[ne]);const K=($+1)%2;($===0?p<=k:f<=L)&&(E.push(J),E.push(ne-1),E.push(K)),($===0?_>=k:v>=L)&&(E.push(ne+1),E.push(N),E.push(K))}return P}(this.ids,this.coords,i,e,r,a,this.nodeSize)}within(i,e,r){return function(a,c,u,p,f,_){const v=[0,a.length-1,0],w=[],E=f*f;for(;v.length;){const P=v.pop(),k=v.pop(),L=v.pop();if(k-L<=_){for(let K=L;K<=k;K++)sd(c[2*K],c[2*K+1],u,p)<=E&&w.push(a[K]);continue}const $=Math.floor((L+k)/2),N=c[2*$],J=c[2*$+1];sd(N,J,u,p)<=E&&w.push(a[$]);const ne=(P+1)%2;(P===0?u-f<=N:p-f<=J)&&(v.push(L),v.push($-1),v.push(ne)),(P===0?u+f>=N:p+f>=J)&&(v.push($+1),v.push(k),v.push(ne))}return w}(this.ids,this.coords,i,e,r,this.nodeSize)}},h.LineBucket=Ac,h.LineStripIndexArray=class extends Xa{},h.LngLat=Vt,h.LngLatBounds=qu,h.MercatorCoordinate=zl,h.ONE_EM=ii,h.OverscaledTileID=tr,h.PerformanceUtils=$f,h.Pos3dArray=class extends $a{},h.PosArray=so,h.Properties=Ii,h.QuadTriangleArray=class extends qa{},h.RGBAImage=er,h.RasterBoundsArray=class extends Dn{},h.RequestPerformance=class{constructor(i){this._marks={start:[i.url,"start"].join("#"),end:[i.url,"end"].join("#"),measure:i.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let i=performance.getEntriesByName(this._marks.measure);return i.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),i=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),i}},h.SegmentVector=x,h.SymbolBucket=as,h.Transitionable=js,h.TriangleIndexArray=d,h.Uniform1f=ue,h.Uniform1i=class extends se{constructor(i,e){super(i,e),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},h.Uniform2f=class extends se{constructor(i,e){super(i,e),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},h.Uniform3f=class extends se{constructor(i,e){super(i,e),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},h.Uniform4f=me,h.UniformColor=xe,h.UniformMatrix4f=class extends se{constructor(i,e){super(i,e),this.current=_e}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let e=1;e<16;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},h.UnwrappedTileID=Ju,h.ValidationError=Se,h.ZoomHistory=ol,h.addDynamicAttributes=Rc,h.arrayBufferToImage=function(i,e){const r=new Image;r.onload=()=>{e(null,r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame(()=>{r.src=da})},r.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const a=new Blob([new Uint8Array(i)],{type:"image/png"});r.src=i.byteLength?URL.createObjectURL(a):da},h.arrayBufferToImageBitmap=function(i,e){const r=new Blob([new Uint8Array(i)],{type:"image/png"});createImageBitmap(r).then(a=>{e(null,a)}).catch(a=>{e(new Error(`Could not load image because of ${a.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})},h.asyncAll=function(i,e,r){if(!i.length)return r(null,[]);let a=i.length;const c=new Array(i.length);let u=null;i.forEach((p,f)=>{e(p,(_,v)=>{_&&(u=_),c[f]=v,--a==0&&r(u,c)})})},h.bezier=et,h.bindAll=Ft,h.clamp=pe,h.clipLine=Ou,h.clone=function(i){var e=new Br(16);return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],e},h.clone$1=Ci,h.collisionCircleLayout=nf,h.config=Ur,h.copy=function(i,e){return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},h.create=function(){var i=new Br(16);return Br!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},h.createExpression=Ia,h.createFilter=zs,h.createLayout=jt,h.createStyleLayer=function(i){return i.type==="custom"?new Bf(i):new Ff[i.type](i)},h.dot=function(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]+i[3]*e[3]},h.earthRadius=Vc,h.ease=Ye,h.emitValidationErrors=Fs,h.equals=function(i,e){var r=i[0],a=i[1],c=i[2],u=i[3],p=i[4],f=i[5],_=i[6],v=i[7],w=i[8],E=i[9],P=i[10],k=i[11],L=i[12],$=i[13],N=i[14],J=i[15],ne=e[0],K=e[1],re=e[2],ge=e[3],fe=e[4],De=e[5],Fe=e[6],Me=e[7],Ie=e[8],Te=e[9],Pe=e[10],Ce=e[11],be=e[12],$e=e[13],Ve=e[14],it=e[15];return Math.abs(r-ne)<=Ht*Math.max(1,Math.abs(r),Math.abs(ne))&&Math.abs(a-K)<=Ht*Math.max(1,Math.abs(a),Math.abs(K))&&Math.abs(c-re)<=Ht*Math.max(1,Math.abs(c),Math.abs(re))&&Math.abs(u-ge)<=Ht*Math.max(1,Math.abs(u),Math.abs(ge))&&Math.abs(p-fe)<=Ht*Math.max(1,Math.abs(p),Math.abs(fe))&&Math.abs(f-De)<=Ht*Math.max(1,Math.abs(f),Math.abs(De))&&Math.abs(_-Fe)<=Ht*Math.max(1,Math.abs(_),Math.abs(Fe))&&Math.abs(v-Me)<=Ht*Math.max(1,Math.abs(v),Math.abs(Me))&&Math.abs(w-Ie)<=Ht*Math.max(1,Math.abs(w),Math.abs(Ie))&&Math.abs(E-Te)<=Ht*Math.max(1,Math.abs(E),Math.abs(Te))&&Math.abs(P-Pe)<=Ht*Math.max(1,Math.abs(P),Math.abs(Pe))&&Math.abs(k-Ce)<=Ht*Math.max(1,Math.abs(k),Math.abs(Ce))&&Math.abs(L-be)<=Ht*Math.max(1,Math.abs(L),Math.abs(be))&&Math.abs($-$e)<=Ht*Math.max(1,Math.abs($),Math.abs($e))&&Math.abs(N-Ve)<=Ht*Math.max(1,Math.abs(N),Math.abs(Ve))&&Math.abs(J-it)<=Ht*Math.max(1,Math.abs(J),Math.abs(it))},h.evaluateSizeForFeature=function(i,{uSize:e,uSizeT:r},{lowerSize:a,upperSize:c}){return i.kind==="source"?a/sn:i.kind==="composite"?zt(a/sn,c/sn,r):e},h.evaluateSizeForZoom=function(i,e){let r=0,a=0;if(i.kind==="constant")a=i.layoutSize;else if(i.kind!=="source"){const{interpolationType:c,minZoom:u,maxZoom:p}=i,f=c?pe(Pi.interpolationFactor(c,e,u,p),0,1):0;i.kind==="camera"?a=zt(i.minSize,i.maxSize,f):r=f}return{uSizeT:r,uSize:a}},h.evaluateVariableOffset=Nu,h.evented=Gs,h.exported=pa,h.extend=Be,h.filterObject=dn,h.fromScaling=function(i,e){return i[0]=e[0],i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=e[1],i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=e[2],i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},h.getAnchorAlignment=zc,h.getAnchorJustification=Dc,h.getArrayBuffer=Vr,h.getJSON=function(i,e){return mn(Be(i,{type:"json"}),e)},h.getOverlapMode=Uc,h.getRTLTextPluginStatus=tn,h.getReferrer=ar,h.getVideo=function(i,e){const r=window.document.createElement("video");r.muted=!0,r.onloadstart=function(){e(null,r)};for(let a=0;a<i.length;a++){const c=window.document.createElement("source");$n(i[a])||(r.crossOrigin="Anonymous"),c.src=i[a],r.appendChild(c)}return{cancel:()=>{}}},h.identity=fc,h.invert=function(i,e){var r=e[0],a=e[1],c=e[2],u=e[3],p=e[4],f=e[5],_=e[6],v=e[7],w=e[8],E=e[9],P=e[10],k=e[11],L=e[12],$=e[13],N=e[14],J=e[15],ne=r*f-a*p,K=r*_-c*p,re=r*v-u*p,ge=a*_-c*f,fe=a*v-u*f,De=c*v-u*_,Fe=w*$-E*L,Me=w*N-P*L,Ie=w*J-k*L,Te=E*N-P*$,Pe=E*J-k*$,Ce=P*J-k*N,be=ne*Ce-K*Pe+re*Te+ge*Ie-fe*Me+De*Fe;return be?(i[0]=(f*Ce-_*Pe+v*Te)*(be=1/be),i[1]=(c*Pe-a*Ce-u*Te)*be,i[2]=($*De-N*fe+J*ge)*be,i[3]=(P*fe-E*De-k*ge)*be,i[4]=(_*Ie-p*Ce-v*Me)*be,i[5]=(r*Ce-c*Ie+u*Me)*be,i[6]=(N*re-L*De-J*K)*be,i[7]=(w*De-P*re+k*K)*be,i[8]=(p*Pe-f*Ie+v*Fe)*be,i[9]=(a*Ie-r*Pe-u*Fe)*be,i[10]=(L*fe-$*re+J*ne)*be,i[11]=(E*re-w*fe-k*ne)*be,i[12]=(f*Me-p*Te-_*Fe)*be,i[13]=(r*Te-a*Me+c*Fe)*be,i[14]=($*K-L*ge-N*ne)*be,i[15]=(w*ge-E*K+P*ne)*be,i):null},h.isImageBitmap=gr,h.isSafari=fr,h.isWorker=Oi,h.keysDifference=function(i,e){const r=[];for(const a in i)a in e||r.push(a);return r},h.lazyLoadRTLTextPlugin=function(){Ei.isLoading()||Ei.isLoaded()||tn()!=="deferred"||hl()},h.makeRequest=mn,h.mapObject=mr,h.mercatorXfromLng=Wu,h.mercatorYfromLat=Hu,h.mercatorZfromAltitude=Ku,h.mul=mm,h.mul$1=function(i,e,r){return i[0]=e[0]*r[0],i[1]=e[1]*r[1],i[2]=e[2]*r[2],i[3]=e[3]*r[3],i},h.multiply=eu,h.nextPowerOfTwo=function(i){return i<=1?1:Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))},h.number=zt,h.ortho=function(i,e,r,a,c,u,p){var f=1/(e-r),_=1/(a-c),v=1/(u-p);return i[0]=-2*f,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*_,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*v,i[11]=0,i[12]=(e+r)*f,i[13]=(c+a)*_,i[14]=(p+u)*v,i[15]=1,i},h.parseCacheControl=function(i){const e={};if(i.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(r,a,c,u)=>{const p=c||u;return e[a]=!p||p.toLowerCase(),""}),e["max-age"]){const r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e},h.parseGlyphPbf=function(i){return new Cc(i).readFields(ff,[])},h.pbf=Cc,h.performSymbolLayout=function(i){i.bucket.createArrays(),i.bucket.tilePixelRatio=gt/(512*i.bucket.overscaling),i.bucket.compareText={},i.bucket.iconsNeedLinear=!1;const e=i.bucket.layers[0].layout,r=i.bucket.layers[0]._unevaluatedLayout._values,a={layoutIconSize:r["icon-size"].possiblyEvaluate(new Pt(i.bucket.zoom+1),i.canonical),layoutTextSize:r["text-size"].possiblyEvaluate(new Pt(i.bucket.zoom+1),i.canonical),textMaxSize:r["text-size"].possiblyEvaluate(new Pt(18))};if(i.bucket.textSizeData.kind==="composite"){const{minZoom:_,maxZoom:v}=i.bucket.textSizeData;a.compositeTextSizes=[r["text-size"].possiblyEvaluate(new Pt(_),i.canonical),r["text-size"].possiblyEvaluate(new Pt(v),i.canonical)]}if(i.bucket.iconSizeData.kind==="composite"){const{minZoom:_,maxZoom:v}=i.bucket.iconSizeData;a.compositeIconSizes=[r["icon-size"].possiblyEvaluate(new Pt(_),i.canonical),r["icon-size"].possiblyEvaluate(new Pt(v),i.canonical)]}const c=e.get("text-line-height")*ii,u=e.get("text-rotation-alignment")!=="viewport"&&e.get("symbol-placement")!=="point",p=e.get("text-keep-upright"),f=e.get("text-size");for(const _ of i.bucket.features){const v=e.get("text-font").evaluate(_,{},i.canonical).join(","),w=f.evaluate(_,{},i.canonical),E=a.layoutTextSize.evaluate(_,{},i.canonical),P=a.layoutIconSize.evaluate(_,{},i.canonical),k={horizontal:{},vertical:void 0},L=_.text;let $,N=[0,0];if(L){const K=L.toString(),re=e.get("text-letter-spacing").evaluate(_,{},i.canonical)*ii,ge=lc(K)?re:0,fe=e.get("text-anchor").evaluate(_,{},i.canonical),De=e.get("text-variable-anchor");if(!De){const Pe=e.get("text-radial-offset").evaluate(_,{},i.canonical);N=Pe?Nu(fe,[Pe*ii,Lc]):e.get("text-offset").evaluate(_,{},i.canonical).map(Ce=>Ce*ii)}let Fe=u?"center":e.get("text-justify").evaluate(_,{},i.canonical);const Me=e.get("symbol-placement"),Ie=Me==="point"?e.get("text-max-width").evaluate(_,{},i.canonical)*ii:0,Te=()=>{i.bucket.allowVerticalPlacement&&Os(K)&&(k.vertical=Sl(L,i.glyphMap,i.glyphPositions,i.imagePositions,v,Ie,c,fe,"left",ge,N,h.WritingMode.vertical,!0,Me,E,w))};if(!u&&De){const Pe=Fe==="auto"?De.map(be=>Dc(be)):[Fe];let Ce=!1;for(let be=0;be<Pe.length;be++){const $e=Pe[be];if(!k.horizontal[$e])if(Ce)k.horizontal[$e]=k.horizontal[0];else{const Ve=Sl(L,i.glyphMap,i.glyphPositions,i.imagePositions,v,Ie,c,"center",$e,ge,N,h.WritingMode.horizontal,!1,Me,E,w);Ve&&(k.horizontal[$e]=Ve,Ce=Ve.positionedLines.length===1)}}Te()}else{Fe==="auto"&&(Fe=Dc(fe));const Pe=Sl(L,i.glyphMap,i.glyphPositions,i.imagePositions,v,Ie,c,fe,Fe,ge,N,h.WritingMode.horizontal,!1,Me,E,w);Pe&&(k.horizontal[Fe]=Pe),Te(),Os(K)&&u&&p&&(k.vertical=Sl(L,i.glyphMap,i.glyphPositions,i.imagePositions,v,Ie,c,fe,Fe,ge,N,h.WritingMode.vertical,!1,Me,E,w))}}let J=!1;if(_.icon&&_.icon.name){const K=i.imageMap[_.icon.name];K&&($=bf(i.imagePositions[_.icon.name],e.get("icon-offset").evaluate(_,{},i.canonical),e.get("icon-anchor").evaluate(_,{},i.canonical)),J=!!K.sdf,i.bucket.sdfIcons===void 0?i.bucket.sdfIcons=J:i.bucket.sdfIcons!==J&&dt("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(K.pixelRatio!==i.bucket.pixelRatio||e.get("icon-rotate").constantOr(1)!==0)&&(i.bucket.iconsNeedLinear=!0))}const ne=Gu(k.horizontal)||k.vertical;i.bucket.iconsInText=!!ne&&ne.iconsInText,(ne||$)&&Cf(i.bucket,_,k,$,i.imageMap,a,E,P,N,J,i.canonical)}i.showCollisionBoxes&&i.bucket.generateCollisionDebugBuffers()},h.perspective=function(i,e,r,a,c){var u,p=1/Math.tan(e/2);return i[0]=p/r,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=p,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,c!=null&&c!==1/0?(i[10]=(c+a)*(u=1/(a-c)),i[14]=2*c*a*u):(i[10]=-1,i[14]=-2*a),i},h.pick=function(i,e){const r={};for(let a=0;a<e.length;a++){const c=e[a];c in i&&(r[c]=i[c])}return r},h.plugin=Ei,h.pointGeometry=He,h.polygonIntersectsPolygon=Rr,h.potpack=Eu,h.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],h.register=ke,h.registerForPluginStateChange=function(i){return i({pluginStatus:Si,pluginURL:lr}),Gs.on("pluginStateChange",i),i},h.renderColorRamp=nu,h.rotateX=function(i,e,r){var a=Math.sin(r),c=Math.cos(r),u=e[4],p=e[5],f=e[6],_=e[7],v=e[8],w=e[9],E=e[10],P=e[11];return e!==i&&(i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[4]=u*c+v*a,i[5]=p*c+w*a,i[6]=f*c+E*a,i[7]=_*c+P*a,i[8]=v*c-u*a,i[9]=w*c-p*a,i[10]=E*c-f*a,i[11]=P*c-_*a,i},h.rotateZ=function(i,e,r){var a=Math.sin(r),c=Math.cos(r),u=e[0],p=e[1],f=e[2],_=e[3],v=e[4],w=e[5],E=e[6],P=e[7];return e!==i&&(i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[0]=u*c+v*a,i[1]=p*c+w*a,i[2]=f*c+E*a,i[3]=_*c+P*a,i[4]=v*c-u*a,i[5]=w*c-p*a,i[6]=E*c-f*a,i[7]=P*c-_*a,i},h.scale=function(i,e,r){var a=r[0],c=r[1],u=r[2];return i[0]=e[0]*a,i[1]=e[1]*a,i[2]=e[2]*a,i[3]=e[3]*a,i[4]=e[4]*c,i[5]=e[5]*c,i[6]=e[6]*c,i[7]=e[7]*c,i[8]=e[8]*u,i[9]=e[9]*u,i[10]=e[10]*u,i[11]=e[11]*u,i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},h.setRTLTextPlugin=function(i,e,r=!1){if(Si===kn||Si===Vs||Si===Ns)throw new Error("setRTLTextPlugin cannot be called multiple times.");lr=pa.resolveURL(i),Si=kn,$s=e,ea(),r||hl()},h.spec=le,h.sphericalToCartesian=function([i,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:i*Math.cos(e)*Math.sin(r),y:i*Math.sin(e)*Math.sin(r),z:i*Math.cos(r)}},h.toEvaluationFeature=ki,h.transformMat4=_l,h.translate=function(i,e,r){var a,c,u,p,f,_,v,w,E,P,k,L,$=r[0],N=r[1],J=r[2];return e===i?(i[12]=e[0]*$+e[4]*N+e[8]*J+e[12],i[13]=e[1]*$+e[5]*N+e[9]*J+e[13],i[14]=e[2]*$+e[6]*N+e[10]*J+e[14],i[15]=e[3]*$+e[7]*N+e[11]*J+e[15]):(c=e[1],u=e[2],p=e[3],f=e[4],_=e[5],v=e[6],w=e[7],E=e[8],P=e[9],k=e[10],L=e[11],i[0]=a=e[0],i[1]=c,i[2]=u,i[3]=p,i[4]=f,i[5]=_,i[6]=v,i[7]=w,i[8]=E,i[9]=P,i[10]=k,i[11]=L,i[12]=a*$+f*N+E*J+e[12],i[13]=c*$+_*N+P*J+e[13],i[14]=u*$+v*N+k*J+e[14],i[15]=p*$+w*N+L*J+e[15]),i},h.triggerPluginCompletionEvent=cl,h.unicodeBlockLookup=Ae,h.uniqueId=function(){return Ct++},h.validateCustomStyleLayer=function(i){const e=[],r=i.id;return r===void 0&&e.push({message:`layers.${r}: missing required property "id"`}),i.render===void 0&&e.push({message:`layers.${r}: missing required method "render"`}),i.renderingMode&&i.renderingMode!=="2d"&&i.renderingMode!=="3d"&&e.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),e},h.validateLight=sl,h.validateStyle=Mn,h.vectorTile=Bn,h.warnOnce=dt,h.wrap=ee}),de(["./shared"],function(h){function ve(B){const I=typeof B;if(I==="number"||I==="boolean"||I==="string"||B==null)return JSON.stringify(B);if(Array.isArray(B)){let U="[";for(const j of B)U+=`${ve(j)},`;return`${U}]`}const C=Object.keys(B).sort();let R="{";for(let U=0;U<C.length;U++)R+=`${JSON.stringify(C[U])}:${ve(B[C[U]])},`;return`${R}}`}function Ge(B){let I="";for(const C of h.refProperties)I+=`/${ve(B[C])}`;return I}class et{constructor(I){this.keyCache={},I&&this.replace(I)}replace(I){this._layerConfigs={},this._layers={},this.update(I,[])}update(I,C){for(const U of I){this._layerConfigs[U.id]=U;const j=this._layers[U.id]=h.createStyleLayer(U);j._featureFilter=h.createFilter(j.filter),this.keyCache[U.id]&&delete this.keyCache[U.id]}for(const U of C)delete this.keyCache[U],delete this._layerConfigs[U],delete this._layers[U];this.familiesBySource={};const R=function(U,j){const X={};for(let q=0;q<U.length;q++){const Q=j&&j[U[q].id]||Ge(U[q]);j&&(j[U[q].id]=Q);let oe=X[Q];oe||(oe=X[Q]=[]),oe.push(U[q])}const Z=[];for(const q in X)Z.push(X[q]);return Z}(Object.values(this._layerConfigs),this.keyCache);for(const U of R){const j=U.map(ye=>this._layers[ye.id]),X=j[0];if(X.visibility==="none")continue;const Z=X.source||"";let q=this.familiesBySource[Z];q||(q=this.familiesBySource[Z]={});const Q=X.sourceLayer||"_geojsonTileLayer";let oe=q[Q];oe||(oe=q[Q]=[]),oe.push(j)}}}class Ye{constructor(I){const C={},R=[];for(const Z in I){const q=I[Z],Q=C[Z]={};for(const oe in q){const ye=q[+oe];if(!ye||ye.bitmap.width===0||ye.bitmap.height===0)continue;const ce={x:0,y:0,w:ye.bitmap.width+2,h:ye.bitmap.height+2};R.push(ce),Q[oe]={rect:ce,metrics:ye.metrics}}}const{w:U,h:j}=h.potpack(R),X=new h.AlphaImage({width:U||1,height:j||1});for(const Z in I){const q=I[Z];for(const Q in q){const oe=q[+Q];if(!oe||oe.bitmap.width===0||oe.bitmap.height===0)continue;const ye=C[Z][Q].rect;h.AlphaImage.copy(oe.bitmap,X,{x:0,y:0},{x:ye.x+1,y:ye.y+1},oe.bitmap)}}this.image=X,this.positions=C}}h.register("GlyphAtlas",Ye);class pe{constructor(I){this.tileID=new h.OverscaledTileID(I.tileID.overscaledZ,I.tileID.wrap,I.tileID.canonical.z,I.tileID.canonical.x,I.tileID.canonical.y),this.uid=I.uid,this.zoom=I.zoom,this.pixelRatio=I.pixelRatio,this.tileSize=I.tileSize,this.source=I.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=I.showCollisionBoxes,this.collectResourceTiming=!!I.collectResourceTiming,this.returnDependencies=!!I.returnDependencies,this.promoteId=I.promoteId}parse(I,C,R,U,j){this.status="parsing",this.data=I,this.collisionBoxArray=new h.CollisionBoxArray;const X=new h.DictionaryCoder(Object.keys(I.layers).sort()),Z=new h.FeatureIndex(this.tileID,this.promoteId);Z.bucketLayerIDs=[];const q={},Q={featureIndex:Z,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:R},oe=C.familiesBySource[this.source];for(const ot in oe){const ct=I.layers[ot];if(!ct)continue;ct.version===1&&h.warnOnce(`Vector tile source "${this.source}" layer "${ot}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const It=X.encode(ot),$t=[];for(let ti=0;ti<ct.length;ti++){const Wt=ct.feature(ti),xn=Z.getId(Wt,ot);$t.push({feature:Wt,id:xn,index:ti,sourceLayerIndex:It})}for(const ti of oe[ot]){const Wt=ti[0];Wt.source!==this.source&&h.warnOnce(`layer.source = ${Wt.source} does not equal this.source = ${this.source}`),Wt.minzoom&&this.zoom<Math.floor(Wt.minzoom)||Wt.maxzoom&&this.zoom>=Wt.maxzoom||Wt.visibility!=="none"&&(ee(ti,this.zoom,R),(q[Wt.id]=Wt.createBucket({index:Z.bucketLayerIDs.length,layers:ti,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:It,sourceID:this.source})).populate($t,Q,this.tileID.canonical),Z.bucketLayerIDs.push(ti.map(xn=>xn.id)))}}let ye,ce,Ne,je;const Re=h.mapObject(Q.glyphDependencies,ot=>Object.keys(ot).map(Number));Object.keys(Re).length?U.send("getGlyphs",{uid:this.uid,stacks:Re,source:this.source,tileID:this.tileID,type:"glyphs"},(ot,ct)=>{ye||(ye=ot,ce=ct,St.call(this))}):ce={};const qe=Object.keys(Q.iconDependencies);qe.length?U.send("getImages",{icons:qe,source:this.source,tileID:this.tileID,type:"icons"},(ot,ct)=>{ye||(ye=ot,Ne=ct,St.call(this))}):Ne={};const st=Object.keys(Q.patternDependencies);function St(){if(ye)return j(ye);if(ce&&Ne&&je){const ot=new Ye(ce),ct=new h.ImageAtlas(Ne,je);for(const It in q){const $t=q[It];$t instanceof h.SymbolBucket?(ee($t.layers,this.zoom,R),h.performSymbolLayout({bucket:$t,glyphMap:ce,glyphPositions:ot.positions,imageMap:Ne,imagePositions:ct.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):$t.hasPattern&&($t instanceof h.LineBucket||$t instanceof h.FillBucket||$t instanceof h.FillExtrusionBucket)&&(ee($t.layers,this.zoom,R),$t.addFeatures(Q,this.tileID.canonical,ct.patternPositions))}this.status="done",j(null,{buckets:Object.values(q).filter(It=>!It.isEmpty()),featureIndex:Z,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:ot.image,imageAtlas:ct,glyphMap:this.returnDependencies?ce:null,iconMap:this.returnDependencies?Ne:null,glyphPositions:this.returnDependencies?ot.positions:null})}}st.length?U.send("getImages",{icons:st,source:this.source,tileID:this.tileID,type:"patterns"},(ot,ct)=>{ye||(ye=ot,je=ct,St.call(this))}):je={},St.call(this)}}function ee(B,I,C){const R=new h.EvaluationParameters(I);for(const U of B)U.recalculate(R,C)}function Be(B,I){const C=h.getArrayBuffer(B.request,(R,U,j,X)=>{R?I(R):U&&I(null,{vectorTile:new h.vectorTile.VectorTile(new h.pbf(U)),rawData:U,cacheControl:j,expires:X})});return()=>{C.cancel(),I()}}class Ct{constructor(I,C,R,U){this.actor=I,this.layerIndex=C,this.availableImages=R,this.loadVectorData=U||Be,this.loading={},this.loaded={}}loadTile(I,C){const R=I.uid;this.loading||(this.loading={});const U=!!(I&&I.request&&I.request.collectResourceTiming)&&new h.RequestPerformance(I.request),j=this.loading[R]=new pe(I);j.abort=this.loadVectorData(I,(X,Z)=>{if(delete this.loading[R],X||!Z)return j.status="done",this.loaded[R]=j,C(X);const q=Z.rawData,Q={};Z.expires&&(Q.expires=Z.expires),Z.cacheControl&&(Q.cacheControl=Z.cacheControl);const oe={};if(U){const ye=U.finish();ye&&(oe.resourceTiming=JSON.parse(JSON.stringify(ye)))}j.vectorTile=Z.vectorTile,j.parse(Z.vectorTile,this.layerIndex,this.availableImages,this.actor,(ye,ce)=>{if(ye||!ce)return C(ye);C(null,h.extend({rawTileData:q.slice(0)},ce,Q,oe))}),this.loaded=this.loaded||{},this.loaded[R]=j})}reloadTile(I,C){const R=this.loaded,U=I.uid,j=this;if(R&&R[U]){const X=R[U];X.showCollisionBoxes=I.showCollisionBoxes;const Z=(q,Q)=>{const oe=X.reloadCallback;oe&&(delete X.reloadCallback,X.parse(X.vectorTile,j.layerIndex,this.availableImages,j.actor,oe)),C(q,Q)};X.status==="parsing"?X.reloadCallback=Z:X.status==="done"&&(X.vectorTile?X.parse(X.vectorTile,this.layerIndex,this.availableImages,this.actor,Z):Z())}}abortTile(I,C){const R=this.loading,U=I.uid;R&&R[U]&&R[U].abort&&(R[U].abort(),delete R[U]),C()}removeTile(I,C){const R=this.loaded,U=I.uid;R&&R[U]&&delete R[U],C()}}class Ft{constructor(){this.loaded={}}loadTile(I,C){const{uid:R,encoding:U,rawImageData:j}=I,X=h.isImageBitmap(j)?this.getImageData(j):j,Z=new h.DEMData(R,X,U);this.loaded=this.loaded||{},this.loaded[R]=Z,C(null,Z)}getImageData(I){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(I.width,I.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=I.width,this.offscreenCanvas.height=I.height,this.offscreenCanvasContext.drawImage(I,0,0,I.width,I.height);const C=this.offscreenCanvasContext.getImageData(-1,-1,I.width+2,I.height+2);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new h.RGBAImage({width:C.width,height:C.height},C.data)}removeTile(I){const C=this.loaded,R=I.uid;C&&C[R]&&delete C[R]}}var mr=function B(I,C){var R,U=I&&I.type;if(U==="FeatureCollection")for(R=0;R<I.features.length;R++)B(I.features[R],C);else if(U==="GeometryCollection")for(R=0;R<I.geometries.length;R++)B(I.geometries[R],C);else if(U==="Feature")B(I.geometry,C);else if(U==="Polygon")dn(I.coordinates,C);else if(U==="MultiPolygon")for(R=0;R<I.coordinates.length;R++)dn(I.coordinates[R],C);return I};function dn(B,I){if(B.length!==0){Ci(B[0],I);for(var C=1;C<B.length;C++)Ci(B[C],!I)}}function Ci(B,I){for(var C=0,R=0,U=0,j=B.length,X=j-1;U<j;X=U++){var Z=(B[U][0]-B[X][0])*(B[X][1]+B[U][1]),q=C+Z;R+=Math.abs(C)>=Math.abs(Z)?C-q+Z:Z-q+C,C=q}C+R>=0!=!!I&&B.reverse()}const Or=h.vectorTile.VectorTileFeature.prototype.toGeoJSON;var dt={},Qt={get exports(){return dt},set exports(B){dt=B}},us=h.pointGeometry,Oi=h.vectorTile.VectorTileFeature,pn=fr;function fr(B,I){this.options=I||{},this.features=B,this.length=B.length}function gr(B,I){this.id=typeof B.id=="number"?B.id:void 0,this.type=B.type,this.rawGeometry=B.type===1?[B.geometry]:B.geometry,this.properties=B.tags,this.extent=I||4096}fr.prototype.feature=function(B){return new gr(this.features[B],this.options.extent)},gr.prototype.loadGeometry=function(){var B=this.rawGeometry;this.geometry=[];for(var I=0;I<B.length;I++){for(var C=B[I],R=[],U=0;U<C.length;U++)R.push(new us(C[U][0],C[U][1]));this.geometry.push(R)}return this.geometry},gr.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var B=this.geometry,I=1/0,C=-1/0,R=1/0,U=-1/0,j=0;j<B.length;j++)for(var X=B[j],Z=0;Z<X.length;Z++){var q=X[Z];I=Math.min(I,q.x),C=Math.max(C,q.x),R=Math.min(R,q.y),U=Math.max(U,q.y)}return[I,R,C,U]},gr.prototype.toGeoJSON=Oi.prototype.toGeoJSON;var da=h.pbf,nr=pn;function Mt(B){var I=new da;return function(C,R){for(var U in C.layers)R.writeMessage(3,pa,C.layers[U])}(B,I),I.finish()}function pa(B,I){var C;I.writeVarintField(15,B.version||1),I.writeStringField(1,B.name||""),I.writeVarintField(5,B.extent||4096);var R={keys:[],values:[],keycache:{},valuecache:{}};for(C=0;C<B.length;C++)R.feature=B.feature(C),I.writeMessage(2,He,R);var U=R.keys;for(C=0;C<U.length;C++)I.writeStringField(3,U[C]);var j=R.values;for(C=0;C<j.length;C++)I.writeMessage(4,ma,j[C])}function He(B,I){var C=B.feature;C.id!==void 0&&I.writeVarintField(1,C.id),I.writeMessage(2,Ui,B),I.writeVarintField(3,C.type),I.writeMessage(4,ar,C)}function Ui(B,I){var C=B.feature,R=B.keys,U=B.values,j=B.keycache,X=B.valuecache;for(var Z in C.properties){var q=C.properties[Z],Q=j[Z];if(q!==null){Q===void 0&&(R.push(Z),j[Z]=Q=R.length-1),I.writeVarint(Q);var oe=typeof q;oe!=="string"&&oe!=="boolean"&&oe!=="number"&&(q=JSON.stringify(q));var ye=oe+":"+q,ce=X[ye];ce===void 0&&(U.push(q),X[ye]=ce=U.length-1),I.writeVarint(ce)}}}function Ur(B,I){return(I<<3)+(7&B)}function Er(B){return B<<1^B>>31}function ar(B,I){for(var C=B.loadGeometry(),R=B.type,U=0,j=0,X=C.length,Z=0;Z<X;Z++){var q=C[Z],Q=1;R===1&&(Q=q.length),I.writeVarint(Ur(1,Q));for(var oe=R===3?q.length-1:q.length,ye=0;ye<oe;ye++){ye===1&&R!==1&&I.writeVarint(Ur(2,oe-1));var ce=q[ye].x-U,Ne=q[ye].y-j;I.writeVarint(Er(ce)),I.writeVarint(Er(Ne)),U+=ce,j+=Ne}R===3&&I.writeVarint(Ur(7,1))}}function ma(B,I){var C=typeof B;C==="string"?I.writeStringField(1,B):C==="boolean"?I.writeBooleanField(7,B):C==="number"&&(B%1!=0?I.writeDoubleField(3,B):B<0?I.writeSVarintField(6,B):I.writeVarintField(5,B))}Qt.exports=Mt,dt.fromVectorTileJs=Mt,dt.fromGeojsonVt=function(B,I){I=I||{};var C={};for(var R in B)C[R]=new nr(B[R].features,I),C[R].name=R,C[R].version=I.version,C[R].extent=I.extent;return Mt({layers:C})},dt.GeoJSONWrapper=nr;const mn={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:B=>B},Vr=Math.fround||($n=new Float32Array(1),B=>($n[0]=+B,$n[0]));var $n;class Nr{constructor(I){this.options=di(Object.create(mn),I),this.trees=new Array(this.options.maxZoom+1)}load(I){const{log:C,minZoom:R,maxZoom:U,nodeSize:j}=this.options;C&&console.time("total time");const X=`prepare ${I.length} points`;C&&console.time(X),this.points=I;let Z=[];for(let q=0;q<I.length;q++)I[q].geometry&&Z.push($r(I[q],q));this.trees[U+1]=new h.KDBush(Z,bt,Wi,j,Float32Array),C&&console.timeEnd(X);for(let q=U;q>=R;q--){const Q=+Date.now();Z=this._cluster(Z,q),this.trees[q]=new h.KDBush(Z,bt,Wi,j,Float32Array),C&&console.log("z%d: %d clusters in %dms",q,Z.length,+Date.now()-Q)}return C&&console.timeEnd("total time"),this}getClusters(I,C){let R=((I[0]+180)%360+360)%360-180;const U=Math.max(-90,Math.min(90,I[1]));let j=I[2]===180?180:((I[2]+180)%360+360)%360-180;const X=Math.max(-90,Math.min(90,I[3]));if(I[2]-I[0]>=360)R=-180,j=180;else if(R>j){const oe=this.getClusters([R,U,180,X],C),ye=this.getClusters([-180,U,j,X],C);return oe.concat(ye)}const Z=this.trees[this._limitZoom(C)],q=Z.range(le(R),Se(X),le(j),Se(U)),Q=[];for(const oe of q){const ye=Z.points[oe];Q.push(ye.numPoints?Gr(ye):this.points[ye.index])}return Q}getChildren(I){const C=this._getOriginId(I),R=this._getOriginZoom(I),U="No cluster with the specified id.",j=this.trees[R];if(!j)throw new Error(U);const X=j.points[C];if(!X)throw new Error(U);const Z=this.options.radius/(this.options.extent*Math.pow(2,R-1)),q=j.within(X.x,X.y,Z),Q=[];for(const oe of q){const ye=j.points[oe];ye.parentId===I&&Q.push(ye.numPoints?Gr(ye):this.points[ye.index])}if(Q.length===0)throw new Error(U);return Q}getLeaves(I,C,R){const U=[];return this._appendLeaves(U,I,C=C||10,R=R||0,0),U}getTile(I,C,R){const U=this.trees[this._limitZoom(I)],j=Math.pow(2,I),{extent:X,radius:Z}=this.options,q=Z/X,Q=(R-q)/j,oe=(R+1+q)/j,ye={features:[]};return this._addTileFeatures(U.range((C-q)/j,Q,(C+1+q)/j,oe),U.points,C,R,j,ye),C===0&&this._addTileFeatures(U.range(1-q/j,Q,1,oe),U.points,j,R,j,ye),C===j-1&&this._addTileFeatures(U.range(0,Q,q/j,oe),U.points,-1,R,j,ye),ye.features.length?ye:null}getClusterExpansionZoom(I){let C=this._getOriginZoom(I)-1;for(;C<=this.options.maxZoom;){const R=this.getChildren(I);if(C++,R.length!==1)break;I=R[0].properties.cluster_id}return C}_appendLeaves(I,C,R,U,j){const X=this.getChildren(C);for(const Z of X){const q=Z.properties;if(q&&q.cluster?j+q.point_count<=U?j+=q.point_count:j=this._appendLeaves(I,q.cluster_id,R,U,j):j<U?j++:I.push(Z),I.length===R)break}return j}_addTileFeatures(I,C,R,U,j,X){for(const Z of I){const q=C[Z],Q=q.numPoints;let oe,ye,ce;if(Q)oe=Ir(q),ye=q.x,ce=q.y;else{const Re=this.points[q.index];oe=Re.properties,ye=le(Re.geometry.coordinates[0]),ce=Se(Re.geometry.coordinates[1])}const Ne={type:1,geometry:[[Math.round(this.options.extent*(ye*j-R)),Math.round(this.options.extent*(ce*j-U))]],tags:oe};let je;Q?je=q.id:this.options.generateId?je=q.index:this.points[q.index].id&&(je=this.points[q.index].id),je!==void 0&&(Ne.id=je),X.features.push(Ne)}}_limitZoom(I){return Math.max(this.options.minZoom,Math.min(Math.floor(+I),this.options.maxZoom+1))}_cluster(I,C){const R=[],{radius:U,extent:j,reduce:X,minPoints:Z}=this.options,q=U/(j*Math.pow(2,C));for(let Q=0;Q<I.length;Q++){const oe=I[Q];if(oe.zoom<=C)continue;oe.zoom=C;const ye=this.trees[C+1],ce=ye.within(oe.x,oe.y,q),Ne=oe.numPoints||1;let je=Ne;for(const Re of ce){const qe=ye.points[Re];qe.zoom>C&&(je+=qe.numPoints||1)}if(je>Ne&&je>=Z){let Re=oe.x*Ne,qe=oe.y*Ne,st=X&&Ne>1?this._map(oe,!0):null;const St=(Q<<5)+(C+1)+this.points.length;for(const ot of ce){const ct=ye.points[ot];if(ct.zoom<=C)continue;ct.zoom=C;const It=ct.numPoints||1;Re+=ct.x*It,qe+=ct.y*It,ct.parentId=St,X&&(st||(st=this._map(oe,!0)),X(st,this._map(ct)))}oe.parentId=St,R.push(fn(Re/je,qe/je,St,je,st))}else if(R.push(oe),je>1)for(const Re of ce){const qe=ye.points[Re];qe.zoom<=C||(qe.zoom=C,R.push(qe))}}return R}_getOriginId(I){return I-this.points.length>>5}_getOriginZoom(I){return(I-this.points.length)%32}_map(I,C){if(I.numPoints)return C?di({},I.properties):I.properties;const R=this.points[I.index].properties,U=this.options.map(R);return C&&U===R?di({},U):U}}function fn(B,I,C,R,U){return{x:Vr(B),y:Vr(I),zoom:1/0,id:C,parentId:-1,numPoints:R,properties:U}}function $r(B,I){const[C,R]=B.geometry.coordinates;return{x:Vr(le(C)),y:Vr(Se(R)),zoom:1/0,index:I,parentId:-1}}function Gr(B){return{type:"Feature",id:B.id,properties:Ir(B),geometry:{type:"Point",coordinates:[(I=B.x,360*(I-.5)),Gn(B.y)]}};var I}function Ir(B){const I=B.numPoints,C=I>=1e4?`${Math.round(I/1e3)}k`:I>=1e3?Math.round(I/100)/10+"k":I;return di(di({},B.properties),{cluster:!0,cluster_id:B.id,point_count:I,point_count_abbreviated:C})}function le(B){return B/360+.5}function Se(B){const I=Math.sin(B*Math.PI/180),C=.5-.25*Math.log((1+I)/(1-I))/Math.PI;return C<0?0:C>1?1:C}function Gn(B){const I=(180-360*B)*Math.PI/180;return 360*Math.atan(Math.exp(I))/Math.PI-90}function di(B,I){for(const C in I)B[C]=I[C];return B}function bt(B){return B.x}function Wi(B){return B.y}function pi(B,I,C,R){for(var U,j=R,X=C-I>>1,Z=C-I,q=B[I],Q=B[I+1],oe=B[C],ye=B[C+1],ce=I+3;ce<C;ce+=3){var Ne=jr(B[ce],B[ce+1],q,Q,oe,ye);if(Ne>j)U=ce,j=Ne;else if(Ne===j){var je=Math.abs(ce-X);je<Z&&(U=ce,Z=je)}}j>R&&(U-I>3&&pi(B,I,U,R),B[U+2]=j,C-U>3&&pi(B,U,C,R))}function jr(B,I,C,R,U,j){var X=U-C,Z=j-R;if(X!==0||Z!==0){var q=((B-C)*X+(I-R)*Z)/(X*X+Z*Z);q>1?(C=U,R=j):q>0&&(C+=X*q,R+=Z*q)}return(X=B-C)*X+(Z=I-R)*Z}function Hi(B,I,C,R){var U={id:B===void 0?null:B,type:I,geometry:C,tags:R,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(j){var X=j.geometry,Z=j.type;if(Z==="Point"||Z==="MultiPoint"||Z==="LineString")Ee(j,X);else if(Z==="Polygon"||Z==="MultiLineString")for(var q=0;q<X.length;q++)Ee(j,X[q]);else if(Z==="MultiPolygon")for(q=0;q<X.length;q++)for(var Q=0;Q<X[q].length;Q++)Ee(j,X[q][Q])}(U),U}function Ee(B,I){for(var C=0;C<I.length;C+=3)B.minX=Math.min(B.minX,I[C]),B.minY=Math.min(B.minY,I[C+1]),B.maxX=Math.max(B.maxX,I[C]),B.maxY=Math.max(B.maxY,I[C+1])}function Qe(B,I,C,R){if(I.geometry){var U=I.geometry.coordinates,j=I.geometry.type,X=Math.pow(C.tolerance/((1<<C.maxZoom)*C.extent),2),Z=[],q=I.id;if(C.promoteId?q=I.properties[C.promoteId]:C.generateId&&(q=R||0),j==="Point")Je(U,Z);else if(j==="MultiPoint")for(var Q=0;Q<U.length;Q++)Je(U[Q],Z);else if(j==="LineString")Ti(U,Z,X,!1);else if(j==="MultiLineString"){if(C.lineMetrics){for(Q=0;Q<U.length;Q++)Ti(U[Q],Z=[],X,!1),B.push(Hi(q,"LineString",Z,I.properties));return}sr(U,Z,X,!1)}else if(j==="Polygon")sr(U,Z,X,!0);else{if(j!=="MultiPolygon"){if(j==="GeometryCollection"){for(Q=0;Q<I.geometry.geometries.length;Q++)Qe(B,{id:q,geometry:I.geometry.geometries[Q],properties:I.properties},C,R);return}throw new Error("Input data is not a valid GeoJSON object.")}for(Q=0;Q<U.length;Q++){var oe=[];sr(U[Q],oe,X,!0),Z.push(oe)}}B.push(Hi(q,j,Z,I.properties))}}function Je(B,I){I.push(Xe(B[0])),I.push(Ar(B[1])),I.push(0)}function Ti(B,I,C,R){for(var U,j,X=0,Z=0;Z<B.length;Z++){var q=Xe(B[Z][0]),Q=Ar(B[Z][1]);I.push(q),I.push(Q),I.push(0),Z>0&&(X+=R?(U*Q-q*j)/2:Math.sqrt(Math.pow(q-U,2)+Math.pow(Q-j,2))),U=q,j=Q}var oe=I.length-3;I[2]=1,pi(I,0,oe,C),I[oe+2]=1,I.size=Math.abs(X),I.start=0,I.end=I.size}function sr(B,I,C,R){for(var U=0;U<B.length;U++){var j=[];Ti(B[U],j,C,R),I.push(j)}}function Xe(B){return B/360+.5}function Ar(B){var I=Math.sin(B*Math.PI/180),C=.5-.25*Math.log((1+I)/(1-I))/Math.PI;return C<0?0:C>1?1:C}function ri(B,I,C,R,U,j,X,Z){if(R/=I,j>=(C/=I)&&X<R)return B;if(X<C||j>=R)return null;for(var q=[],Q=0;Q<B.length;Q++){var oe=B[Q],ye=oe.geometry,ce=oe.type,Ne=U===0?oe.minX:oe.minY,je=U===0?oe.maxX:oe.maxY;if(Ne>=C&&je<R)q.push(oe);else if(!(je<C||Ne>=R)){var Re=[];if(ce==="Point"||ce==="MultiPoint")qr(ye,Re,C,R,U);else if(ce==="LineString")Mi(ye,Re,C,R,U,!1,Z.lineMetrics);else if(ce==="MultiLineString")yt(ye,Re,C,R,U,!1);else if(ce==="Polygon")yt(ye,Re,C,R,U,!0);else if(ce==="MultiPolygon")for(var qe=0;qe<ye.length;qe++){var st=[];yt(ye[qe],st,C,R,U,!0),st.length&&Re.push(st)}if(Re.length){if(Z.lineMetrics&&ce==="LineString"){for(qe=0;qe<Re.length;qe++)q.push(Hi(oe.id,ce,Re[qe],oe.tags));continue}ce!=="LineString"&&ce!=="MultiLineString"||(Re.length===1?(ce="LineString",Re=Re[0]):ce="MultiLineString"),ce!=="Point"&&ce!=="MultiPoint"||(ce=Re.length===3?"Point":"MultiPoint"),q.push(Hi(oe.id,ce,Re,oe.tags))}}}return q.length?q:null}function qr(B,I,C,R,U){for(var j=0;j<B.length;j+=3){var X=B[j+U];X>=C&&X<=R&&(I.push(B[j]),I.push(B[j+1]),I.push(B[j+2]))}}function Mi(B,I,C,R,U,j,X){for(var Z,q,Q=mi(B),oe=U===0?Zr:_n,ye=B.start,ce=0;ce<B.length-3;ce+=3){var Ne=B[ce],je=B[ce+1],Re=B[ce+2],qe=B[ce+3],st=B[ce+4],St=U===0?Ne:je,ot=U===0?qe:st,ct=!1;X&&(Z=Math.sqrt(Math.pow(Ne-qe,2)+Math.pow(je-st,2))),St<C?ot>C&&(q=oe(Q,Ne,je,qe,st,C),X&&(Q.start=ye+Z*q)):St>R?ot<R&&(q=oe(Q,Ne,je,qe,st,R),X&&(Q.start=ye+Z*q)):gn(Q,Ne,je,Re),ot<C&&St>=C&&(q=oe(Q,Ne,je,qe,st,C),ct=!0),ot>R&&St<=R&&(q=oe(Q,Ne,je,qe,st,R),ct=!0),!j&&ct&&(X&&(Q.end=ye+Z*q),I.push(Q),Q=mi(B)),X&&(ye+=Z)}var It=B.length-3;Ne=B[It],je=B[It+1],Re=B[It+2],(St=U===0?Ne:je)>=C&&St<=R&&gn(Q,Ne,je,Re),It=Q.length-3,j&&It>=3&&(Q[It]!==Q[0]||Q[It+1]!==Q[1])&&gn(Q,Q[0],Q[1],Q[2]),Q.length&&I.push(Q)}function mi(B){var I=[];return I.size=B.size,I.start=B.start,I.end=B.end,I}function yt(B,I,C,R,U,j){for(var X=0;X<B.length;X++)Mi(B[X],I,C,R,U,j,!1)}function gn(B,I,C,R){B.push(I),B.push(C),B.push(R)}function Zr(B,I,C,R,U,j){var X=(j-I)/(R-I);return B.push(j),B.push(C+(U-C)*X),B.push(1),X}function _n(B,I,C,R,U,j){var X=(j-C)/(U-C);return B.push(I+(R-I)*X),B.push(j),B.push(1),X}function lt(B,I){for(var C=[],R=0;R<B.length;R++){var U,j=B[R],X=j.type;if(X==="Point"||X==="MultiPoint"||X==="LineString")U=Cr(j.geometry,I);else if(X==="MultiLineString"||X==="Polygon"){U=[];for(var Z=0;Z<j.geometry.length;Z++)U.push(Cr(j.geometry[Z],I))}else if(X==="MultiPolygon")for(U=[],Z=0;Z<j.geometry.length;Z++){for(var q=[],Q=0;Q<j.geometry[Z].length;Q++)q.push(Cr(j.geometry[Z][Q],I));U.push(q)}C.push(Hi(j.id,X,U,j.tags))}return C}function Cr(B,I){var C=[];C.size=B.size,B.start!==void 0&&(C.start=B.start,C.end=B.end);for(var R=0;R<B.length;R+=3)C.push(B[R]+I,B[R+1],B[R+2]);return C}function yn(B,I){if(B.transformed)return B;var C,R,U,j=1<<B.z,X=B.x,Z=B.y;for(C=0;C<B.features.length;C++){var q=B.features[C],Q=q.geometry,oe=q.type;if(q.geometry=[],oe===1)for(R=0;R<Q.length;R+=2)q.geometry.push(Xr(Q[R],Q[R+1],I,j,X,Z));else for(R=0;R<Q.length;R++){var ye=[];for(U=0;U<Q[R].length;U+=2)ye.push(Xr(Q[R][U],Q[R][U+1],I,j,X,Z));q.geometry.push(ye)}}return B.transformed=!0,B}function Xr(B,I,C,R,U,j){return[Math.round(C*(B*R-U)),Math.round(C*(I*R-j))]}function jn(B,I,C,R,U){for(var j=I===U.maxZoom?0:U.tolerance/((1<<I)*U.extent),X={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:C,y:R,z:I,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},Z=0;Z<B.length;Z++){X.numFeatures++,_r(X,B[Z],j,U);var q=B[Z].minX,Q=B[Z].minY,oe=B[Z].maxX,ye=B[Z].maxY;q<X.minX&&(X.minX=q),Q<X.minY&&(X.minY=Q),oe>X.maxX&&(X.maxX=oe),ye>X.maxY&&(X.maxY=ye)}return X}function _r(B,I,C,R){var U=I.geometry,j=I.type,X=[];if(j==="Point"||j==="MultiPoint")for(var Z=0;Z<U.length;Z+=3)X.push(U[Z]),X.push(U[Z+1]),B.numPoints++,B.numSimplified++;else if(j==="LineString")Mr(X,U,B,C,!1,!1);else if(j==="MultiLineString"||j==="Polygon")for(Z=0;Z<U.length;Z++)Mr(X,U[Z],B,C,j==="Polygon",Z===0);else if(j==="MultiPolygon")for(var q=0;q<U.length;q++){var Q=U[q];for(Z=0;Z<Q.length;Z++)Mr(X,Q[Z],B,C,!0,Z===0)}if(X.length){var oe=I.tags||null;if(j==="LineString"&&R.lineMetrics){for(var ye in oe={},I.tags)oe[ye]=I.tags[ye];oe.mapbox_clip_start=U.start/U.size,oe.mapbox_clip_end=U.end/U.size}var ce={geometry:X,type:j==="Polygon"||j==="MultiPolygon"?3:j==="LineString"||j==="MultiLineString"?2:1,tags:oe};I.id!==null&&(ce.id=I.id),B.features.push(ce)}}function Mr(B,I,C,R,U,j){var X=R*R;if(R>0&&I.size<(U?X:R))C.numPoints+=I.length/3;else{for(var Z=[],q=0;q<I.length;q+=3)(R===0||I[q+2]>X)&&(C.numSimplified++,Z.push(I[q]),Z.push(I[q+1])),C.numPoints++;U&&function(Q,oe){for(var ye=0,ce=0,Ne=Q.length,je=Ne-2;ce<Ne;je=ce,ce+=2)ye+=(Q[ce]-Q[je])*(Q[ce+1]+Q[je+1]);if(ye>0===oe)for(ce=0,Ne=Q.length;ce<Ne/2;ce+=2){var Re=Q[ce],qe=Q[ce+1];Q[ce]=Q[Ne-2-ce],Q[ce+1]=Q[Ne-1-ce],Q[Ne-2-ce]=Re,Q[Ne-1-ce]=qe}}(Z,j),B.push(Z)}}function ut(B,I){var C=(I=this.options=function(U,j){for(var X in j)U[X]=j[X];return U}(Object.create(this.options),I)).debug;if(C&&console.time("preprocess data"),I.maxZoom<0||I.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(I.promoteId&&I.generateId)throw new Error("promoteId and generateId cannot be used together.");var R=function(U,j){var X=[];if(U.type==="FeatureCollection")for(var Z=0;Z<U.features.length;Z++)Qe(X,U.features[Z],j,Z);else Qe(X,U.type==="Feature"?U:{geometry:U},j);return X}(B,I);this.tiles={},this.tileCoords=[],C&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",I.indexMaxZoom,I.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),R=function(U,j){var X=j.buffer/j.extent,Z=U,q=ri(U,1,-1-X,X,0,-1,2,j),Q=ri(U,1,1-X,2+X,0,-1,2,j);return(q||Q)&&(Z=ri(U,1,-X,1+X,0,-1,2,j)||[],q&&(Z=lt(q,1).concat(Z)),Q&&(Z=Z.concat(lt(Q,-1)))),Z}(R,I),R.length&&this.splitTile(R,0,0,0),C&&(R.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)))}function Wr(B,I,C){return 32*((1<<B)*C+I)+B}function Vi(B,I){return I?B.properties[I]:B.id}function ei(B,I){if(B==null)return!0;if(B.type==="Feature")return Vi(B,I)!=null;if(B.type==="FeatureCollection"){const C=new Set;for(const R of B.features){const U=Vi(R,I);if(U==null||C.has(U))return!1;C.add(U)}return!0}return!1}function Yt(B,I){const C=new Map;if(B!=null)if(B.type==="Feature")C.set(Vi(B,I),B);else for(const R of B.features)C.set(Vi(R,I),R);return C}function fi(B,I){const C=B.tileID.canonical;if(!this._geoJSONIndex)return I(null,null);const R=this._geoJSONIndex.getTile(C.z,C.x,C.y);if(!R)return I(null,null);const U=new class{constructor(X){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=h.EXTENT,this.length=X.length,this._features=X}feature(X){return new class{constructor(Z){this._feature=Z,this.extent=h.EXTENT,this.type=Z.type,this.properties=Z.tags,"id"in Z&&!isNaN(Z.id)&&(this.id=parseInt(Z.id,10))}loadGeometry(){if(this._feature.type===1){const Z=[];for(const q of this._feature.geometry)Z.push([new h.pointGeometry(q[0],q[1])]);return Z}{const Z=[];for(const q of this._feature.geometry){const Q=[];for(const oe of q)Q.push(new h.pointGeometry(oe[0],oe[1]));Z.push(Q)}return Z}}toGeoJSON(Z,q,Q){return Or.call(this,Z,q,Q)}}(this._features[X])}}(R.features);let j=dt(U);j.byteOffset===0&&j.byteLength===j.buffer.byteLength||(j=new Uint8Array(j)),I(null,{vectorTile:U,rawData:j.buffer})}ut.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},ut.prototype.splitTile=function(B,I,C,R,U,j,X){for(var Z=[B,I,C,R],q=this.options,Q=q.debug;Z.length;){R=Z.pop(),C=Z.pop(),I=Z.pop(),B=Z.pop();var oe=1<<I,ye=Wr(I,C,R),ce=this.tiles[ye];if(!ce&&(Q>1&&console.time("creation"),ce=this.tiles[ye]=jn(B,I,C,R,q),this.tileCoords.push({z:I,x:C,y:R}),Q)){Q>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",I,C,R,ce.numFeatures,ce.numPoints,ce.numSimplified),console.timeEnd("creation"));var Ne="z"+I;this.stats[Ne]=(this.stats[Ne]||0)+1,this.total++}if(ce.source=B,U){if(I===q.maxZoom||I===U)continue;var je=1<<U-I;if(C!==Math.floor(j/je)||R!==Math.floor(X/je))continue}else if(I===q.indexMaxZoom||ce.numPoints<=q.indexMaxPoints)continue;if(ce.source=null,B.length!==0){Q>1&&console.time("clipping");var Re,qe,st,St,ot,ct,It=.5*q.buffer/q.extent,$t=.5-It,ti=.5+It,Wt=1+It;Re=qe=st=St=null,ot=ri(B,oe,C-It,C+ti,0,ce.minX,ce.maxX,q),ct=ri(B,oe,C+$t,C+Wt,0,ce.minX,ce.maxX,q),B=null,ot&&(Re=ri(ot,oe,R-It,R+ti,1,ce.minY,ce.maxY,q),qe=ri(ot,oe,R+$t,R+Wt,1,ce.minY,ce.maxY,q),ot=null),ct&&(st=ri(ct,oe,R-It,R+ti,1,ce.minY,ce.maxY,q),St=ri(ct,oe,R+$t,R+Wt,1,ce.minY,ce.maxY,q),ct=null),Q>1&&console.timeEnd("clipping"),Z.push(Re||[],I+1,2*C,2*R),Z.push(qe||[],I+1,2*C,2*R+1),Z.push(st||[],I+1,2*C+1,2*R),Z.push(St||[],I+1,2*C+1,2*R+1)}}},ut.prototype.getTile=function(B,I,C){var R=this.options,U=R.extent,j=R.debug;if(B<0||B>24)return null;var X=1<<B,Z=Wr(B,I=(I%X+X)%X,C);if(this.tiles[Z])return yn(this.tiles[Z],U);j>1&&console.log("drilling down to z%d-%d-%d",B,I,C);for(var q,Q=B,oe=I,ye=C;!q&&Q>0;)Q--,oe=Math.floor(oe/2),ye=Math.floor(ye/2),q=this.tiles[Wr(Q,oe,ye)];return q&&q.source?(j>1&&console.log("found parent tile z%d-%d-%d",Q,oe,ye),j>1&&console.time("drilling down"),this.splitTile(q.source,Q,oe,ye,B,I,C),j>1&&console.timeEnd("drilling down"),this.tiles[Z]?yn(this.tiles[Z],U):null):null};class gi extends Ct{constructor(I,C,R,U){super(I,C,R,fi),this._dataUpdateable=new Map,this.loadGeoJSON=(j,X)=>{const{promoteId:Z}=j;if(j.request)return h.getJSON(j.request,(q,Q,oe,ye)=>{this._dataUpdateable=ei(Q,Z)?Yt(Q,Z):void 0,X(q,Q,oe,ye)});if(typeof j.data=="string")try{const q=JSON.parse(j.data);this._dataUpdateable=ei(q,Z)?Yt(q,Z):void 0,X(null,q)}catch{X(new Error(`Input data given to '${j.source}' is not a valid GeoJSON object.`))}else j.dataDiff?this._dataUpdateable?(function(q,Q,oe){var ye,ce,Ne,je;if(Q.removeAll&&q.clear(),Q.remove)for(const Re of Q.remove)q.delete(Re);if(Q.add)for(const Re of Q.add){const qe=Vi(Re,oe);qe!=null&&q.set(qe,Re)}if(Q.update)for(const Re of Q.update){let qe=q.get(Re.id);if(qe==null)continue;const st=!Re.removeAllProperties&&(((ye=Re.removeProperties)===null||ye===void 0?void 0:ye.length)>0||((ce=Re.addOrUpdateProperties)===null||ce===void 0?void 0:ce.length)>0);if((Re.newGeometry||Re.removeAllProperties||st)&&(qe={...qe},q.set(Re.id,qe),st&&(qe.properties={...qe.properties})),Re.newGeometry&&(qe.geometry=Re.newGeometry),Re.removeAllProperties)qe.properties={};else if(((Ne=Re.removeProperties)===null||Ne===void 0?void 0:Ne.length)>0)for(const St of Re.removeProperties)Object.prototype.hasOwnProperty.call(qe.properties,St)&&delete qe.properties[St];if(((je=Re.addOrUpdateProperties)===null||je===void 0?void 0:je.length)>0)for(const{key:St,value:ot}of Re.addOrUpdateProperties)qe.properties[St]=ot}}(this._dataUpdateable,j.dataDiff,Z),X(null,{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())})):X(new Error(`Cannot update existing geojson data in ${j.source}`)):X(new Error(`Input data given to '${j.source}' is not a valid GeoJSON object.`));return{cancel:()=>{}}},U&&(this.loadGeoJSON=U)}loadData(I,C){var R;(R=this._pendingRequest)===null||R===void 0||R.cancel(),this._pendingCallback&&this._pendingCallback(null,{abandoned:!0});const U=!!(I&&I.request&&I.request.collectResourceTiming)&&new h.RequestPerformance(I.request);this._pendingCallback=C,this._pendingRequest=this.loadGeoJSON(I,(j,X)=>{if(delete this._pendingCallback,delete this._pendingRequest,j||!X)return C(j);if(typeof X!="object")return C(new Error(`Input data given to '${I.source}' is not a valid GeoJSON object.`));{mr(X,!0);try{if(I.filter){const q=h.createExpression(I.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(q.result==="error")throw new Error(q.value.map(oe=>`${oe.key}: ${oe.message}`).join(", "));X={type:"FeatureCollection",features:X.features.filter(oe=>q.value.evaluate({zoom:0},oe))}}this._geoJSONIndex=I.cluster?new Nr(function({superclusterOptions:q,clusterProperties:Q}){if(!Q||!q)return q;const oe={},ye={},ce={accumulated:null,zoom:0},Ne={properties:null},je=Object.keys(Q);for(const Re of je){const[qe,st]=Q[Re],St=h.createExpression(st),ot=h.createExpression(typeof qe=="string"?[qe,["accumulated"],["get",Re]]:qe);oe[Re]=St.value,ye[Re]=ot.value}return q.map=Re=>{Ne.properties=Re;const qe={};for(const st of je)qe[st]=oe[st].evaluate(ce,Ne);return qe},q.reduce=(Re,qe)=>{Ne.properties=qe;for(const st of je)ce.accumulated=Re[st],Re[st]=ye[st].evaluate(ce,Ne)},q}(I)).load(X.features):function(q,Q){return new ut(q,Q)}(X,I.geojsonVtOptions)}catch(q){return C(q)}this.loaded={};const Z={};if(U){const q=U.finish();q&&(Z.resourceTiming={},Z.resourceTiming[I.source]=JSON.parse(JSON.stringify(q)))}C(null,Z)}})}reloadTile(I,C){const R=this.loaded;return R&&R[I.uid]?super.reloadTile(I,C):this.loadTile(I,C)}removeSource(I,C){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),C()}getClusterExpansionZoom(I,C){try{C(null,this._geoJSONIndex.getClusterExpansionZoom(I.clusterId))}catch(R){C(R)}}getClusterChildren(I,C){try{C(null,this._geoJSONIndex.getChildren(I.clusterId))}catch(R){C(R)}}getClusterLeaves(I,C){try{C(null,this._geoJSONIndex.getLeaves(I.clusterId,I.limit,I.offset))}catch(R){C(R)}}}class yr{constructor(I){this.self=I,this.actor=new h.Actor(I,this),this.layerIndexes={},this.availableImages={},this.workerSourceTypes={vector:Ct,geojson:gi},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(C,R)=>{if(this.workerSourceTypes[C])throw new Error(`Worker source with name "${C}" already registered.`);this.workerSourceTypes[C]=R},this.self.registerRTLTextPlugin=C=>{if(h.plugin.isParsed())throw new Error("RTL text plugin already registered.");h.plugin.applyArabicShaping=C.applyArabicShaping,h.plugin.processBidirectionalText=C.processBidirectionalText,h.plugin.processStyledBidirectionalText=C.processStyledBidirectionalText}}setReferrer(I,C){this.referrer=C}setImages(I,C,R){this.availableImages[I]=C;for(const U in this.workerSources[I]){const j=this.workerSources[I][U];for(const X in j)j[X].availableImages=C}R()}setLayers(I,C,R){this.getLayerIndex(I).replace(C),R()}updateLayers(I,C,R){this.getLayerIndex(I).update(C.layers,C.removedIds),R()}loadTile(I,C,R){this.getWorkerSource(I,C.type,C.source).loadTile(C,R)}loadDEMTile(I,C,R){this.getDEMWorkerSource(I,C.source).loadTile(C,R)}reloadTile(I,C,R){this.getWorkerSource(I,C.type,C.source).reloadTile(C,R)}abortTile(I,C,R){this.getWorkerSource(I,C.type,C.source).abortTile(C,R)}removeTile(I,C,R){this.getWorkerSource(I,C.type,C.source).removeTile(C,R)}removeDEMTile(I,C){this.getDEMWorkerSource(I,C.source).removeTile(C)}removeSource(I,C,R){if(!this.workerSources[I]||!this.workerSources[I][C.type]||!this.workerSources[I][C.type][C.source])return;const U=this.workerSources[I][C.type][C.source];delete this.workerSources[I][C.type][C.source],U.removeSource!==void 0?U.removeSource(C,R):R()}loadWorkerSource(I,C,R){try{this.self.importScripts(C.url),R()}catch(U){R(U.toString())}}syncRTLPluginState(I,C,R){try{h.plugin.setState(C);const U=h.plugin.getPluginURL();if(h.plugin.isLoaded()&&!h.plugin.isParsed()&&U!=null){this.self.importScripts(U);const j=h.plugin.isParsed();R(j?void 0:new Error(`RTL Text Plugin failed to import scripts from ${U}`),j)}}catch(U){R(U.toString())}}getAvailableImages(I){let C=this.availableImages[I];return C||(C=[]),C}getLayerIndex(I){let C=this.layerIndexes[I];return C||(C=this.layerIndexes[I]=new et),C}getWorkerSource(I,C,R){if(this.workerSources[I]||(this.workerSources[I]={}),this.workerSources[I][C]||(this.workerSources[I][C]={}),!this.workerSources[I][C][R]){const U={send:(j,X,Z)=>{this.actor.send(j,X,Z,I)}};this.workerSources[I][C][R]=new this.workerSourceTypes[C](U,this.getLayerIndex(I),this.getAvailableImages(I))}return this.workerSources[I][C][R]}getDEMWorkerSource(I,C){return this.demWorkerSources[I]||(this.demWorkerSources[I]={}),this.demWorkerSources[I][C]||(this.demWorkerSources[I][C]=new Ft),this.demWorkerSources[I][C]}}return h.isWorker()&&(self.worker=new yr(self)),yr}),de(["./shared"],function(h){var ve=Ge;function Ge(o){return!function(t){return typeof window>"u"||typeof document>"u"?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var s,l,d=new Blob([""],{type:"text/javascript"}),m=URL.createObjectURL(d);try{l=new Worker(m),s=!0}catch{s=!1}return l&&l.terminate(),URL.revokeObjectURL(m),s}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var s=document.createElement("canvas");s.width=s.height=1;var l=s.getContext("2d");if(!l)return!1;var d=l.getImageData(0,0,1,1);return d&&d.width===s.width}()?(et[n=t&&t.failIfMajorPerformanceCaveat]===void 0&&(et[n]=function(s){var l,d=function(m){var g=document.createElement("canvas"),y=Object.create(Ge.webGLContextAttributes);return y.failIfMajorPerformanceCaveat=m,g.getContext("webgl",y)||g.getContext("experimental-webgl",y)}(s);if(!d)return!1;try{l=d.createShader(d.VERTEX_SHADER)}catch{return!1}return!(!l||d.isContextLost())&&(d.shaderSource(l,"void main() {}"),d.compileShader(l),d.getShaderParameter(l,d.COMPILE_STATUS)===!0)}(n)),et[n]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var n}(o)}var et={};Ge.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};var Ye="3.0.0-pre.4";function pe(o,t){if(Array.isArray(o)){if(!Array.isArray(t)||o.length!==t.length)return!1;for(let n=0;n<o.length;n++)if(!pe(o[n],t[n]))return!1;return!0}if(typeof o=="object"&&o!==null&&t!==null){if(typeof t!="object"||Object.keys(o).length!==Object.keys(t).length)return!1;for(const n in o)if(!pe(o[n],t[n]))return!1;return!0}return o===t}class ee{static testProp(t){if(!ee.docStyle)return t[0];for(let n=0;n<t.length;n++)if(t[n]in ee.docStyle)return t[n];return t[0]}static create(t,n,s){const l=window.document.createElement(t);return n!==void 0&&(l.className=n),s&&s.appendChild(l),l}static createNS(t,n){return window.document.createElementNS(t,n)}static disableDrag(){ee.docStyle&&ee.selectProp&&(ee.userSelect=ee.docStyle[ee.selectProp],ee.docStyle[ee.selectProp]="none")}static enableDrag(){ee.docStyle&&ee.selectProp&&(ee.docStyle[ee.selectProp]=ee.userSelect)}static setTransform(t,n){t.style[ee.transformProp]=n}static addEventListener(t,n,s,l={}){t.addEventListener(n,s,"passive"in l?l:l.capture)}static removeEventListener(t,n,s,l={}){t.removeEventListener(n,s,"passive"in l?l:l.capture)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",ee.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",ee.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",ee.suppressClickInternal,!0)},0)}static mousePos(t,n){const s=t.getBoundingClientRect();return new h.pointGeometry(n.clientX-s.left-t.clientLeft,n.clientY-s.top-t.clientTop)}static touchPos(t,n){const s=t.getBoundingClientRect(),l=[];for(let d=0;d<n.length;d++)l.push(new h.pointGeometry(n[d].clientX-s.left-t.clientLeft,n[d].clientY-s.top-t.clientTop));return l}static mouseButton(t){return t.button}static remove(t){t.parentNode&&t.parentNode.removeChild(t)}}ee.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,ee.selectProp=ee.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),ee.transformProp=ee.testProp(["transform","WebkitTransform"]);const Be={supported:!1,testSupport:function(o){!mr&&Ft&&(dn?Ci(o):Ct=o)}};let Ct,Ft,mr=!1,dn=!1;function Ci(o){const t=o.createTexture();o.bindTexture(o.TEXTURE_2D,t);try{if(o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,Ft),o.isContextLost())return;Be.supported=!0}catch{}o.deleteTexture(t),mr=!0}var Or;typeof document<"u"&&(Ft=document.createElement("img"),Ft.onload=function(){Ct&&Ci(Ct),Ct=null,dn=!0},Ft.onerror=function(){mr=!0,Ct=null},Ft.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(o){let t,n,s,l;o.resetRequestQueue=()=>{t=[],n=0,s=0,l={}},o.addThrottleControl=g=>{const y=s++;return l[y]=g,y},o.removeThrottleControl=g=>{delete l[g]};const d=()=>{const g=Object.keys(l);let y=!1;if(g.length>0){for(const x of g)if(y=l[x](),y)break}return y};o.getImage=(g,y)=>{Be.supported&&(g.headers||(g.headers={}),g.headers.accept="image/webp,*/*");const x={requestParameters:g,callback:y,cancelled:!1,completed:!1,cancel:()=>{}};return t.push(x),d()||o.processQueue(),x};const m=g=>{const{requestParameters:y,callback:x}=g;return h.getArrayBuffer(y,(S,T,M,F)=>{S?x(S):T&&((O,D)=>{typeof createImageBitmap=="function"?h.arrayBufferToImageBitmap(O,D):h.arrayBufferToImage(O,D)})(T,(O,D)=>{O!=null?x(O):D!=null&&x(null,D,{cacheControl:M,expires:F})}),g.cancelled||(g.completed=!0,n--,d()||o.processQueue())})};o.processQueue=(g=0)=>{g<=0&&(g=d()?h.config.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:h.config.MAX_PARALLEL_IMAGE_REQUESTS);for(let y=n;y<g&&t.length>0;y++){const x=t.shift();if(x.cancelled)continue;const S=m(x);n++,x.innerRequest=S,x.cancel=()=>{var T;(T=x).completed||T.cancelled||(n--,T.cancelled=!0,T.innerRequest.cancel(),o.processQueue())}}return t.length}}(Or||(Or={})),Or.resetRequestQueue();var dt,Qt=Or;(function(o){o.Glyphs="Glyphs",o.Image="Image",o.Source="Source",o.SpriteImage="SpriteImage",o.SpriteJSON="SpriteJSON",o.Style="Style",o.Tile="Tile",o.Unknown="Unknown"})(dt||(dt={}));class us{constructor(t){this._transformRequestFn=t}transformRequest(t,n){return this._transformRequestFn&&this._transformRequestFn(t,n)||{url:t}}normalizeSpriteURL(t,n,s){const l=function(d){const m=d.match(Oi);if(!m)throw new Error(`Unable to parse URL "${d}"`);return{protocol:m[1],authority:m[2],path:m[3]||"/",params:m[4]?m[4].split("&"):[]}}(t);return l.path+=`${n}${s}`,function(d){const m=d.params.length?`?${d.params.join("&")}`:"";return`${d.protocol}://${d.authority}${d.path}${m}`}(l)}setTransformRequest(t){this._transformRequestFn=t}}const Oi=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function pn(o){var t=new h.ARRAY_TYPE(3);return t[0]=o[0],t[1]=o[1],t[2]=o[2],t}var fr,gr=function(o,t,n){return o[0]=t[0]-n[0],o[1]=t[1]-n[1],o[2]=t[2]-n[2],o};fr=new h.ARRAY_TYPE(3),h.ARRAY_TYPE!=Float32Array&&(fr[0]=0,fr[1]=0,fr[2]=0);var da=function(o){var t=o[0],n=o[1];return t*t+n*n};function nr(o){return typeof o=="string"?[{id:"default",url:o}]:o??[]}(function(){var o=new h.ARRAY_TYPE(2);h.ARRAY_TYPE!=Float32Array&&(o[0]=0,o[1]=0)})();class Mt{constructor(t,n,s,l){this.context=t,this.format=s,this.texture=t.gl.createTexture(),this.update(n,l)}update(t,n,s){const{width:l,height:d}=t,m=!(this.size&&this.size[0]===l&&this.size[1]===d||s),{context:g}=this,{gl:y}=g;if(this.useMipmap=!!(n&&n.useMipmap),y.bindTexture(y.TEXTURE_2D,this.texture),g.pixelStoreUnpackFlipY.set(!1),g.pixelStoreUnpack.set(1),g.pixelStoreUnpackPremultiplyAlpha.set(this.format===y.RGBA&&(!n||n.premultiply!==!1)),m)this.size=[l,d],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||h.isImageBitmap(t)?y.texImage2D(y.TEXTURE_2D,0,this.format,this.format,y.UNSIGNED_BYTE,t):y.texImage2D(y.TEXTURE_2D,0,this.format,l,d,0,this.format,y.UNSIGNED_BYTE,t.data);else{const{x,y:S}=s||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||h.isImageBitmap(t)?y.texSubImage2D(y.TEXTURE_2D,0,x,S,y.RGBA,y.UNSIGNED_BYTE,t):y.texSubImage2D(y.TEXTURE_2D,0,x,S,l,d,y.RGBA,y.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&y.generateMipmap(y.TEXTURE_2D)}bind(t,n,s){const{context:l}=this,{gl:d}=l;d.bindTexture(d.TEXTURE_2D,this.texture),s!==d.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(s=d.LINEAR),t!==this.filter&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,t),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,s||t),this.filter=t),n!==this.wrap&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,n),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,n),this.wrap=n)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}function pa(o){const{userImage:t}=o;return!!(t&&t.render&&t.render())&&(o.data.replace(new Uint8Array(t.data.buffer)),!0)}class He extends h.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new h.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:n,callback:s}of this.requestors)this._notify(n,s);this.requestors=[]}}getImage(t){const n=this.images[t];if(n&&!n.data&&n.spriteData){const s=n.spriteData;n.data=new h.RGBAImage({width:s.width,height:s.height},s.context.getImageData(s.x,s.y,s.width,s.height).data),n.spriteData=null}return n}addImage(t,n){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,n)&&(this.images[t]=n)}_validate(t,n){let s=!0;const l=n.data||n.spriteData;return this._validateStretch(n.stretchX,l&&l.width)||(this.fire(new h.ErrorEvent(new Error(`Image "${t}" has invalid "stretchX" value`))),s=!1),this._validateStretch(n.stretchY,l&&l.height)||(this.fire(new h.ErrorEvent(new Error(`Image "${t}" has invalid "stretchY" value`))),s=!1),this._validateContent(n.content,n)||(this.fire(new h.ErrorEvent(new Error(`Image "${t}" has invalid "content" value`))),s=!1),s}_validateStretch(t,n){if(!t)return!0;let s=0;for(const l of t){if(l[0]<s||l[1]<l[0]||n<l[1])return!1;s=l[1]}return!0}_validateContent(t,n){if(!t)return!0;if(t.length!==4)return!1;const s=n.spriteData,l=s&&s.width||n.data.width,d=s&&s.height||n.data.height;return!(t[0]<0||l<t[0]||t[1]<0||d<t[1]||t[2]<0||l<t[2]||t[3]<0||d<t[3]||t[2]<t[0]||t[3]<t[1])}updateImage(t,n,s=!0){const l=this.getImage(t);if(s&&(l.data.width!==n.data.width||l.data.height!==n.data.height))throw new Error(`size mismatch between old image (${l.data.width}x${l.data.height}) and new image (${n.data.width}x${n.data.height}).`);n.version=l.version+1,this.images[t]=n,this.updatedImages[t]=!0}removeImage(t){const n=this.images[t];delete this.images[t],delete this.patterns[t],n.userImage&&n.userImage.onRemove&&n.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t,n){let s=!0;if(!this.isLoaded())for(const l of t)this.images[l]||(s=!1);this.isLoaded()||s?this._notify(t,n):this.requestors.push({ids:t,callback:n})}_notify(t,n){const s={};for(const l of t){const d=this.getImage(l);d?s[l]={data:d.data.clone(),pixelRatio:d.pixelRatio,sdf:d.sdf,version:d.version,stretchX:d.stretchX,stretchY:d.stretchY,content:d.content,hasRenderCallback:!!(d.userImage&&d.userImage.render)}:(this.fire(new h.Event("styleimagemissing",{id:l})),h.warnOnce(`Image "${l}" 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.`))}n(null,s)}getPixelSize(){const{width:t,height:n}=this.atlasImage;return{width:t,height:n}}getPattern(t){const n=this.patterns[t],s=this.getImage(t);if(!s)return null;if(n&&n.position.version===s.version)return n.position;if(n)n.position.version=s.version;else{const l={w:s.data.width+2,h:s.data.height+2,x:0,y:0},d=new h.ImagePosition(l,s);this.patterns[t]={bin:l,position:d}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const n=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new Mt(t,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const d in this.patterns)t.push(this.patterns[d].bin);const{w:n,h:s}=h.potpack(t),l=this.atlasImage;l.resize({width:n||1,height:s||1});for(const d in this.patterns){const{bin:m}=this.patterns[d],g=m.x+1,y=m.y+1,x=this.getImage(d).data,S=x.width,T=x.height;h.RGBAImage.copy(x,l,{x:0,y:0},{x:g,y},{width:S,height:T}),h.RGBAImage.copy(x,l,{x:0,y:T-1},{x:g,y:y-1},{width:S,height:1}),h.RGBAImage.copy(x,l,{x:0,y:0},{x:g,y:y+T},{width:S,height:1}),h.RGBAImage.copy(x,l,{x:S-1,y:0},{x:g-1,y},{width:1,height:T}),h.RGBAImage.copy(x,l,{x:0,y:0},{x:g+S,y},{width:1,height:T})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const n of t){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;const s=this.getImage(n);s||h.warnOnce(`Image with ID: "${n}" was not found`),pa(s)&&this.updateImage(n,s)}}}const Ui=1e20;function Ur(o,t,n,s,l,d,m,g,y){for(let x=t;x<t+s;x++)Er(o,n*d+x,d,l,m,g,y);for(let x=n;x<n+l;x++)Er(o,x*d+t,1,s,m,g,y)}function Er(o,t,n,s,l,d,m){d[0]=0,m[0]=-Ui,m[1]=Ui,l[0]=o[t];for(let g=1,y=0,x=0;g<s;g++){l[g]=o[t+g*n];const S=g*g;do{const T=d[y];x=(l[g]-l[T]+S-T*T)/(g-T)/2}while(x<=m[y]&&--y>-1);y++,d[y]=g,m[y]=x,m[y+1]=Ui}for(let g=0,y=0;g<s;g++){for(;m[y+1]<g;)y++;const x=d[y],S=g-x;o[t+g*n]=l[x]+S*S}}class ar{constructor(t,n){this.requestManager=t,this.localIdeographFontFamily=n,this.entries={}}setURL(t){this.url=t}getGlyphs(t,n){const s=[];for(const l in t)for(const d of t[l])s.push({stack:l,id:d});h.asyncAll(s,({stack:l,id:d},m)=>{let g=this.entries[l];g||(g=this.entries[l]={glyphs:{},requests:{},ranges:{}});let y=g.glyphs[d];if(y!==void 0)return void m(null,{stack:l,id:d,glyph:y});if(y=this._tinySDF(g,l,d),y)return g.glyphs[d]=y,void m(null,{stack:l,id:d,glyph:y});const x=Math.floor(d/256);if(256*x>65535)return void m(new Error("glyphs > 65535 not supported"));if(g.ranges[x])return void m(null,{stack:l,id:d,glyph:y});if(!this.url)return void m(new Error("glyphsUrl is not set"));let S=g.requests[x];S||(S=g.requests[x]=[],ar.loadGlyphRange(l,x,this.url,this.requestManager,(T,M)=>{if(M){for(const F in M)this._doesCharSupportLocalGlyph(+F)||(g.glyphs[+F]=M[+F]);g.ranges[x]=!0}for(const F of S)F(T,M);delete g.requests[x]})),S.push((T,M)=>{T?m(T):M&&m(null,{stack:l,id:d,glyph:M[d]||null})})},(l,d)=>{if(l)n(l);else if(d){const m={};for(const{stack:g,id:y,glyph:x}of d)(m[g]||(m[g]={}))[y]=x&&{id:x.id,bitmap:x.bitmap.clone(),metrics:x.metrics};n(null,m)}})}_doesCharSupportLocalGlyph(t){return!!this.localIdeographFontFamily&&(h.unicodeBlockLookup["CJK Unified Ideographs"](t)||h.unicodeBlockLookup["Hangul Syllables"](t)||h.unicodeBlockLookup.Hiragana(t)||h.unicodeBlockLookup.Katakana(t))}_tinySDF(t,n,s){const l=this.localIdeographFontFamily;if(!l||!this._doesCharSupportLocalGlyph(s))return;let d=t.tinySDF;if(!d){let g="400";/bold/i.test(n)?g="900":/medium/i.test(n)?g="500":/light/i.test(n)&&(g="200"),d=t.tinySDF=new ar.TinySDF({fontSize:24,buffer:3,radius:8,cutoff:.25,fontFamily:l,fontWeight:g})}const m=d.draw(String.fromCharCode(s));return{id:s,bitmap:new h.AlphaImage({width:m.width||30,height:m.height||30},m.data),metrics:{width:m.glyphWidth||24,height:m.glyphHeight||24,left:m.glyphLeft||0,top:m.glyphTop-27||-8,advance:m.glyphAdvance||24}}}}ar.loadGlyphRange=function(o,t,n,s,l){const d=256*t,m=d+255,g=s.transformRequest(n.replace("{fontstack}",o).replace("{range}",`${d}-${m}`),dt.Glyphs);h.getArrayBuffer(g,(y,x)=>{if(y)l(y);else if(x){const S={};for(const T of h.parseGlyphPbf(x))S[T.id]=T;l(null,S)}})},ar.TinySDF=class{constructor({fontSize:o=24,buffer:t=3,radius:n=8,cutoff:s=.25,fontFamily:l="sans-serif",fontWeight:d="normal",fontStyle:m="normal"}={}){this.buffer=t,this.cutoff=s,this.radius=n;const g=this.size=o+4*t,y=this._createCanvas(g),x=this.ctx=y.getContext("2d",{willReadFrequently:!0});x.font=`${m} ${d} ${o}px ${l}`,x.textBaseline="alphabetic",x.textAlign="left",x.fillStyle="black",this.gridOuter=new Float64Array(g*g),this.gridInner=new Float64Array(g*g),this.f=new Float64Array(g),this.z=new Float64Array(g+1),this.v=new Uint16Array(g)}_createCanvas(o){const t=document.createElement("canvas");return t.width=t.height=o,t}draw(o){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:s,actualBoundingBoxLeft:l,actualBoundingBoxRight:d}=this.ctx.measureText(o),m=Math.ceil(n),g=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(d-l))),y=Math.min(this.size-this.buffer,m+Math.ceil(s)),x=g+2*this.buffer,S=y+2*this.buffer,T=Math.max(x*S,0),M=new Uint8ClampedArray(T),F={data:M,width:x,height:S,glyphWidth:g,glyphHeight:y,glyphTop:m,glyphLeft:0,glyphAdvance:t};if(g===0||y===0)return F;const{ctx:O,buffer:D,gridInner:G,gridOuter:Y}=this;O.clearRect(D,D,g,y),O.fillText(o,D,D+m);const H=O.getImageData(D,D,g,y);Y.fill(Ui,0,T),G.fill(0,0,T);for(let V=0;V<y;V++)for(let te=0;te<g;te++){const ae=H.data[4*(V*g+te)+3]/255;if(ae===0)continue;const se=(V+D)*x+te+D;if(ae===1)Y[se]=0,G[se]=Ui;else{const ue=.5-ae;Y[se]=ue>0?ue*ue:0,G[se]=ue<0?ue*ue:0}}Ur(Y,0,0,x,S,x,this.f,this.v,this.z),Ur(G,D,D,g,y,x,this.f,this.v,this.z);for(let V=0;V<T;V++){const te=Math.sqrt(Y[V])-Math.sqrt(G[V]);M[V]=Math.round(255-255*(te/this.radius+this.cutoff))}return F}};const ma=new h.Properties({anchor:new h.DataConstantProperty(h.spec.light.anchor),position:new class{constructor(){this.specification=h.spec.light.position}possiblyEvaluate(o,t){return h.sphericalToCartesian(o.expression.evaluate(t))}interpolate(o,t,n){return{x:h.number(o.x,t.x,n),y:h.number(o.y,t.y,n),z:h.number(o.z,t.z,n)}}},color:new h.DataConstantProperty(h.spec.light.color),intensity:new h.DataConstantProperty(h.spec.light.intensity)}),mn="-transition";class Vr extends h.Evented{constructor(t){super(),this._transitionable=new h.Transitionable(ma),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,n={}){if(!this._validate(h.validateLight,t,n))for(const s in t){const l=t[s];s.endsWith(mn)?this._transitionable.setTransition(s.slice(0,-mn.length),l):this._transitionable.setValue(s,l)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,n,s){return(!s||s.validate!==!1)&&h.emitValidationErrors(this,t.call(h.validateStyle,h.extend({value:n,style:{glyphs:!0,sprite:!0},styleSpec:h.spec})))}}class $n{constructor(t,n){this.width=t,this.height=n,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,n){const s=t.join(",")+String(n);return this.dashEntry[s]||(this.dashEntry[s]=this.addDash(t,n)),this.dashEntry[s]}getDashRanges(t,n,s){const l=[];let d=t.length%2==1?-t[t.length-1]*s:0,m=t[0]*s,g=!0;l.push({left:d,right:m,isDash:g,zeroLength:t[0]===0});let y=t[0];for(let x=1;x<t.length;x++){g=!g;const S=t[x];d=y*s,y+=S,m=y*s,l.push({left:d,right:m,isDash:g,zeroLength:S===0})}return l}addRoundDash(t,n,s){const l=n/2;for(let d=-s;d<=s;d++){const m=this.width*(this.nextRow+s+d);let g=0,y=t[g];for(let x=0;x<this.width;x++){x/y.right>1&&(y=t[++g]);const S=Math.abs(x-y.left),T=Math.abs(x-y.right),M=Math.min(S,T);let F;const O=d/s*(l+1);if(y.isDash){const D=l-Math.abs(O);F=Math.sqrt(M*M+D*D)}else F=l-Math.sqrt(M*M+O*O);this.data[m+x]=Math.max(0,Math.min(255,F+128))}}}addRegularDash(t){for(let g=t.length-1;g>=0;--g){const y=t[g],x=t[g+1];y.zeroLength?t.splice(g,1):x&&x.isDash===y.isDash&&(x.left=y.left,t.splice(g,1))}const n=t[0],s=t[t.length-1];n.isDash===s.isDash&&(n.left=s.left-this.width,s.right=n.right+this.width);const l=this.width*this.nextRow;let d=0,m=t[d];for(let g=0;g<this.width;g++){g/m.right>1&&(m=t[++d]);const y=Math.abs(g-m.left),x=Math.abs(g-m.right),S=Math.min(y,x);this.data[l+g]=Math.max(0,Math.min(255,(m.isDash?S:-S)+128))}}addDash(t,n){const s=n?7:0,l=2*s+1;if(this.nextRow+l>this.height)return h.warnOnce("LineAtlas out of space"),null;let d=0;for(let g=0;g<t.length;g++)d+=t[g];if(d!==0){const g=this.width/d,y=this.getDashRanges(t,this.width,g);n?this.addRoundDash(y,g,s):this.addRegularDash(y)}const m={y:(this.nextRow+s+.5)/this.height,height:2*s/this.height,width:d};return this.nextRow+=l,this.dirty=!0,m}bind(t){const n=t.gl;this.texture?(n.bindTexture(n.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,n.texSubImage2D(n.TEXTURE_2D,0,0,0,this.width,this.height,n.ALPHA,n.UNSIGNED_BYTE,this.data))):(this.texture=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this.texture),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texImage2D(n.TEXTURE_2D,0,n.ALPHA,this.width,this.height,0,n.ALPHA,n.UNSIGNED_BYTE,this.data))}}class Nr{constructor(t,n,s){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=s;const l=this.workerPool.acquire(s);for(let d=0;d<l.length;d++){const m=new Nr.Actor(l[d],n,s);m.name=`Worker ${d}`,this.actors.push(m)}if(!this.actors.length)throw new Error("No actors found")}broadcast(t,n,s){h.asyncAll(this.actors,(l,d)=>{l.send(t,n,d)},s=s||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.actors.forEach(n=>{n.remove()}),this.actors=[],t&&this.workerPool.release(this.id)}}function fn(o,t,n){const s=function(l,d){if(l)return n(l);if(d){const m=h.pick(h.extend(d,o),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);d.vector_layers&&(m.vectorLayers=d.vector_layers,m.vectorLayerIds=m.vectorLayers.map(g=>g.id)),n(null,m)}};return o.url?h.getJSON(t.transformRequest(o.url,dt.Source),s):h.exported.frame(()=>s(null,o))}Nr.Actor=h.Actor;class $r{constructor(t,n,s){this.bounds=h.LngLatBounds.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=s||24}validateBounds(t){return Array.isArray(t)&&t.length===4?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const n=Math.pow(2,t.z),s=Math.floor(h.mercatorXfromLng(this.bounds.getWest())*n),l=Math.floor(h.mercatorYfromLat(this.bounds.getNorth())*n),d=Math.ceil(h.mercatorXfromLng(this.bounds.getEast())*n),m=Math.ceil(h.mercatorYfromLat(this.bounds.getSouth())*n);return t.x>=s&&t.x<d&&t.y>=l&&t.y<m}}class Gr extends h.Evented{constructor(t,n,s,l){if(super(),this.id=t,this.dispatcher=s,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,h.extend(this,h.pick(n,["url","scheme","tileSize","promoteId"])),this._options=h.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(l)}load(){this._loaded=!1,this.fire(new h.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=fn(this._options,this.map._requestManager,(t,n)=>{this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),t?this.fire(new h.ErrorEvent(t)):n&&(h.extend(this,n),n.bounds&&(this.tileBounds=new $r(n.bounds,this.minzoom,this.maxzoom)),this.fire(new h.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new h.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.load()}setTiles(t){return this.setSourceProperty(()=>{this._options.tiles=t}),this}setUrl(t){return this.setSourceProperty(()=>{this.url=t,this._options.url=t}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return h.extend({},this._options)}loadTile(t,n){const s=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),l={request:this.map._requestManager.transformRequest(s,dt.Tile),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};function d(m,g){return delete t.request,t.aborted?n(null):m&&m.status!==404?n(m):(g&&g.resourceTiming&&(t.resourceTiming=g.resourceTiming),this.map._refreshExpiredTiles&&g&&t.setExpiryData(g),t.loadVectorData(g,this.map.painter),n(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}l.request.collectResourceTiming=this._collectResourceTiming,t.actor&&t.state!=="expired"?t.state==="loading"?t.reloadCallback=n:t.request=t.actor.send("reloadTile",l,d.bind(this)):(t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",l,d.bind(this)))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id},void 0)}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id},void 0)}hasTransition(){return!1}}class Ir extends h.Evented{constructor(t,n,s,l){super(),this.id=t,this.dispatcher=s,this.setEventedParent(l),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=h.extend({type:"raster"},n),h.extend(this,h.pick(n,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new h.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=fn(this._options,this.map._requestManager,(t,n)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new h.ErrorEvent(t)):n&&(h.extend(this,n),n.bounds&&(this.tileBounds=new $r(n.bounds,this.minzoom,this.maxzoom)),this.fire(new h.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new h.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return h.extend({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t,n){const s=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.request=Qt.getImage(this.map._requestManager.transformRequest(s,dt.Tile),(l,d,m)=>{if(delete t.request,t.aborted)t.state="unloaded",n(null);else if(l)t.state="errored",n(l);else if(d){this.map._refreshExpiredTiles&&t.setExpiryData(m);const g=this.map.painter.context,y=g.gl;t.texture=this.map.painter.getTileTexture(d.width),t.texture?t.texture.update(d,{useMipmap:!0}):(t.texture=new Mt(g,d,y.RGBA,{useMipmap:!0}),t.texture.bind(y.LINEAR,y.CLAMP_TO_EDGE,y.LINEAR_MIPMAP_NEAREST),g.extTextureFilterAnisotropic&&y.texParameterf(y.TEXTURE_2D,g.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,g.extTextureFilterAnisotropicMax)),t.state="loaded",n(null)}})}abortTile(t,n){t.request&&(t.request.cancel(),delete t.request),n()}unloadTile(t,n){t.texture&&this.map.painter.saveTileTexture(t.texture),n()}hasTransition(){return!1}}let le;class Se extends Ir{constructor(t,n,s,l){super(t,n,s,l),this.type="raster-dem",this.maxzoom=22,this._options=h.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}serialize(){return{type:"raster-dem",url:this.url,tileSize:this.tileSize,tiles:this.tiles,bounds:this.bounds,encoding:this.encoding}}loadTile(t,n){const s=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);function l(d,m){d&&(t.state="errored",n(d)),m&&(t.dem=m,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded",n(null))}t.request=Qt.getImage(this.map._requestManager.transformRequest(s,dt.Tile),function(d,m){if(delete t.request,t.aborted)t.state="unloaded",n(null);else if(d)t.state="errored",n(d);else if(m){this.map._refreshExpiredTiles&&t.setExpiryData(m),delete m.cacheControl,delete m.expires;const g=h.isImageBitmap(m)&&(le==null&&(le=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),le)?m:h.exported.getImageData(m,1),y={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:g,encoding:this.encoding};t.actor&&t.state!=="expired"||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",y,l.bind(this)))}}.bind(this)),t.neighboringTiles=this._getNeighboringTiles(t.tileID)}_getNeighboringTiles(t){const n=t.canonical,s=Math.pow(2,n.z),l=(n.x-1+s)%s,d=n.x===0?t.wrap-1:t.wrap,m=(n.x+1+s)%s,g=n.x+1===s?t.wrap+1:t.wrap,y={};return y[new h.OverscaledTileID(t.overscaledZ,d,n.z,l,n.y).key]={backfilled:!1},y[new h.OverscaledTileID(t.overscaledZ,g,n.z,m,n.y).key]={backfilled:!1},n.y>0&&(y[new h.OverscaledTileID(t.overscaledZ,d,n.z,l,n.y-1).key]={backfilled:!1},y[new h.OverscaledTileID(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},y[new h.OverscaledTileID(t.overscaledZ,g,n.z,m,n.y-1).key]={backfilled:!1}),n.y+1<s&&(y[new h.OverscaledTileID(t.overscaledZ,d,n.z,l,n.y+1).key]={backfilled:!1},y[new h.OverscaledTileID(t.overscaledZ,t.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},y[new h.OverscaledTileID(t.overscaledZ,g,n.z,m,n.y+1).key]={backfilled:!1}),y}unloadTile(t){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded",t.actor&&t.actor.send("removeDEMTile",{uid:t.uid,source:this.id})}}class Gn extends h.Evented{constructor(t,n,s,l){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._pendingLoads=0,this.actor=s.getActor(),this.setEventedParent(l),this._data=n.data,this._options=h.extend({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId;const d=h.EXTENT/this.tileSize;this.workerOptions=h.extend({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:(n.buffer!==void 0?n.buffer:128)*d,tolerance:(n.tolerance!==void 0?n.tolerance:.375)*d,extent:h.EXTENT,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1},superclusterOptions:{maxZoom:n.clusterMaxZoom!==void 0?n.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,n.clusterMinPoints||2),extent:h.EXTENT,radius:(n.clusterRadius||50)*d,log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}load(){this._updateWorkerData()}onAdd(t){this.map=t,this.load()}setData(t){return this._data=t,this._updateWorkerData(),this}updateData(t){return this._updateWorkerData(t),this}setClusterOptions(t){return this.workerOptions.cluster=t.cluster,t&&(t.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=t.clusterRadius),t.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=t.clusterMaxZoom)),this._updateWorkerData(),this}getClusterExpansionZoom(t,n){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},n),this}getClusterChildren(t,n){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},n),this}getClusterLeaves(t,n,s,l){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:n,offset:s},l),this}_updateWorkerData(t){const n=h.extend({},this.workerOptions);t?n.dataDiff=t:typeof this._data=="string"?(n.request=this.map._requestManager.transformRequest(h.exported.resolveURL(this._data),dt.Source),n.request.collectResourceTiming=this._collectResourceTiming):n.data=JSON.stringify(this._data),this._pendingLoads++,this.fire(new h.Event("dataloading",{dataType:"source"})),this.actor.send(`${this.type}.loadData`,n,(s,l)=>{if(this._pendingLoads--,this._removed||l&&l.abandoned)return void this.fire(new h.Event("dataabort",{dataType:"source"}));let d=null;if(l&&l.resourceTiming&&l.resourceTiming[this.id]&&(d=l.resourceTiming[this.id].slice(0)),s)return void this.fire(new h.ErrorEvent(s));const m={dataType:"source"};this._collectResourceTiming&&d&&d.length>0&&h.extend(m,{resourceTiming:d}),this.fire(new h.Event("data",{...m,sourceDataType:"metadata"})),this.fire(new h.Event("data",{...m,sourceDataType:"content"}))})}loaded(){return this._pendingLoads===0}loadTile(t,n){const s=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const l={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};t.request=this.actor.send(s,l,(d,m)=>(delete t.request,t.unloadVectorData(),t.aborted?n(null):d?n(d):(t.loadVectorData(m,this.map.painter,s==="reloadTile"),n(null))))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._removed=!0,this.actor.send("removeSource",{type:this.type,source:this.id})}serialize(){return h.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var di=h.createLayout([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class bt extends h.Evented{constructor(t,n,s,l){super(),this.id=t,this.dispatcher=s,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(l),this.options=n}load(t,n){this._loaded=!1,this.fire(new h.Event("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=Qt.getImage(this.map._requestManager.transformRequest(this.url,dt.Image),(s,l)=>{this._request=null,this._loaded=!0,s?this.fire(new h.ErrorEvent(s)):l&&(this.image=l,t&&(this.coordinates=t),n&&n(),this._finishLoading())})}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.cancel(),this._request=null),this.options.url=t.url,this.load(t.coordinates,()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new h.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.cancel(),this._request=null)}setCoordinates(t){this.coordinates=t;const n=t.map(h.MercatorCoordinate.fromLngLat);this.tileID=function(l){let d=1/0,m=1/0,g=-1/0,y=-1/0;for(const M of l)d=Math.min(d,M.x),m=Math.min(m,M.y),g=Math.max(g,M.x),y=Math.max(y,M.y);const x=Math.max(g-d,y-m),S=Math.max(0,Math.floor(-Math.log(x)/Math.LN2)),T=Math.pow(2,S);return new h.CanonicalTileID(S,Math.floor((d+g)/2*T),Math.floor((m+y)/2*T))}(n),this.minzoom=this.maxzoom=this.tileID.z;const s=n.map(l=>this.tileID.getTilePoint(l)._round());return this._boundsArray=new h.RasterBoundsArray,this._boundsArray.emplaceBack(s[0].x,s[0].y,0,0),this._boundsArray.emplaceBack(s[1].x,s[1].y,h.EXTENT,0),this._boundsArray.emplaceBack(s[3].x,s[3].y,0,h.EXTENT),this._boundsArray.emplaceBack(s[2].x,s[2].y,h.EXTENT,h.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new h.Event("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const t=this.map.painter.context,n=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,di.members)),this.boundsSegments||(this.boundsSegments=h.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new Mt(t,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));for(const s in this.tiles){const l=this.tiles[s];l.state!=="loaded"&&(l.state="loaded",l.texture=this.texture)}}loadTile(t,n){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},n(null)):(t.state="errored",n(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class Wi extends bt{constructor(t,n,s,l){super(t,n,s,l),this.roundZoom=!0,this.type="video",this.options=n}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const n of t.urls)this.urls.push(this.map._requestManager.transformRequest(n,dt.Source).url);h.getVideo(this.urls,(n,s)=>{this._loaded=!0,n?this.fire(new h.ErrorEvent(n)):s&&(this.video=s,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const n=this.video.seekable;t<n.start(0)||t>n.end(0)?this.fire(new h.ErrorEvent(new h.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const t=this.map.painter.context,n=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,di.members)),this.boundsSegments||(this.boundsSegments=h.SegmentVector.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new Mt(t,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));for(const s in this.tiles){const l=this.tiles[s];l.state!=="loaded"&&(l.state="loaded",l.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class pi extends bt{constructor(t,n,s,l){super(t,n,s,l),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some(d=>!Array.isArray(d)||d.length!==2||d.some(m=>typeof m!="number"))||this.fire(new h.ErrorEvent(new h.ValidationError(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new h.ErrorEvent(new h.ValidationError(`sources.${t}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new h.ErrorEvent(new h.ValidationError(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new h.ErrorEvent(new h.ValidationError(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new h.ErrorEvent(new h.ValidationError(`sources.${t}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){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 h.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const n=this.map.painter.context,s=n.gl;this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,di.members)),this.boundsSegments||(this.boundsSegments=h.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new Mt(n,this.canvas,s.RGBA,{premultiply:!0});for(const l in this.tiles){const d=this.tiles[l];d.state!=="loaded"&&(d.state="loaded",d.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const jr={vector:Gr,raster:Ir,"raster-dem":Se,geojson:Gn,video:Wi,image:bt,canvas:pi};function Hi(o,t){const n=h.create();return h.translate(n,n,[1,1,0]),h.scale(n,n,[.5*o.width,.5*o.height,1]),h.multiply(n,n,o.calculatePosMatrix(t.toUnwrapped()))}function Ee(o,t,n,s,l,d){const m=function(T,M,F){if(T)for(const O of T){const D=M[O];if(D&&D.source===F&&D.type==="fill-extrusion")return!0}else for(const O in M){const D=M[O];if(D.source===F&&D.type==="fill-extrusion")return!0}return!1}(l&&l.layers,t,o.id),g=d.maxPitchScaleFactor(),y=o.tilesIn(s,g,m);y.sort(Qe);const x=[];for(const T of y)x.push({wrappedTileID:T.tileID.wrapped().key,queryResults:T.tile.queryRenderedFeatures(t,n,o._state,T.queryGeometry,T.cameraQueryGeometry,T.scale,l,d,g,Hi(o.transform,T.tileID))});const S=function(T){const M={},F={};for(const O of T){const D=O.queryResults,G=O.wrappedTileID,Y=F[G]=F[G]||{};for(const H in D){const V=D[H],te=Y[H]=Y[H]||{},ae=M[H]=M[H]||[];for(const se of V)te[se.featureIndex]||(te[se.featureIndex]=!0,ae.push(se))}}return M}(x);for(const T in S)S[T].forEach(M=>{const F=M.feature,O=o.getFeatureState(F.layer["source-layer"],F.id);F.source=F.layer.source,F.layer["source-layer"]&&(F.sourceLayer=F.layer["source-layer"]),F.state=O});return S}function Qe(o,t){const n=o.tileID,s=t.tileID;return n.overscaledZ-s.overscaledZ||n.canonical.y-s.canonical.y||n.wrap-s.wrap||n.canonical.x-s.canonical.x}class Je{constructor(t,n){this.tileID=t,this.uid=h.uniqueId(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(t){const n=t+this.timeAdded;n<h.exported.now()||this.fadeEndTime&&n<this.fadeEndTime||(this.fadeEndTime=n)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(t,n,s){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(l,d){const m={};if(!d)return m;for(const g of l){const y=g.layerIds.map(x=>d.getLayer(x)).filter(Boolean);if(y.length!==0){g.layers=y,g.stateDependentLayerIds&&(g.stateDependentLayers=g.stateDependentLayerIds.map(x=>y.filter(S=>S.id===x)[0]));for(const x of y)m[x.id]=g}}return m}(t.buckets,n.style),this.hasSymbolBuckets=!1;for(const l in this.buckets){const d=this.buckets[l];if(d instanceof h.SymbolBucket){if(this.hasSymbolBuckets=!0,!s)break;d.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const l in this.buckets){const d=this.buckets[l];if(d instanceof h.SymbolBucket&&d.hasRTLText){this.hasRTLText=!0,h.lazyLoadRTLTextPlugin();break}}this.queryPadding=0;for(const l in this.buckets){const d=this.buckets[l];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(l).queryRadius(d))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage)}else this.collisionBoxArray=new h.CollisionBoxArray}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const s in this.buckets){const l=this.buckets[s];l.uploadPending()&&l.upload(t)}const n=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Mt(t,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Mt(t,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,n,s,l,d,m,g,y,x,S){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:l,cameraQueryGeometry:d,scale:m,tileSize:this.tileSize,pixelPosMatrix:S,transform:y,params:g,queryPadding:this.queryPadding*x},t,n,s):{}}querySourceFeatures(t,n){const s=this.latestFeatureIndex;if(!s||!s.rawTileData)return;const l=s.loadVTLayers(),d=n&&n.sourceLayer?n.sourceLayer:"",m=l._geojsonTileLayer||l[d];if(!m)return;const g=h.createFilter(n&&n.filter),{z:y,x,y:S}=this.tileID.canonical,T={z:y,x,y:S};for(let M=0;M<m.length;M++){const F=m.feature(M);if(g.needGeometry){const G=h.toEvaluationFeature(F,!0);if(!g.filter(new h.EvaluationParameters(this.tileID.overscaledZ),G,this.tileID.canonical))continue}else if(!g.filter(new h.EvaluationParameters(this.tileID.overscaledZ),F))continue;const O=s.getId(F,d),D=new h.GeoJSONFeature(F,y,x,S,O);D.tile=T,t.push(D)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const n=this.expirationTime;if(t.cacheControl){const s=h.parseCacheControl(t.cacheControl);s["max-age"]&&(this.expirationTime=Date.now()+1e3*s["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const s=Date.now();let l=!1;if(this.expirationTime>s)l=!1;else if(n)if(this.expirationTime<n)l=!0;else{const d=this.expirationTime-n;d?this.expirationTime=s+Math.max(d,3e4):l=!0}else l=!0;l?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(t,n){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(t).length===0)return;const s=this.latestFeatureIndex.loadVTLayers();for(const l in this.buckets){if(!n.style.hasLayer(l))continue;const d=this.buckets[l],m=d.layers[0].sourceLayer||"_geojsonTileLayer",g=s[m],y=t[m];if(!g||!y||Object.keys(y).length===0)continue;d.update(y,g,this.imageAtlas&&this.imageAtlas.patternPositions||{});const x=n&&n.style&&n.style.getLayer(l);x&&(this.queryPadding=Math.max(this.queryPadding,x.queryRadius(d)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<h.exported.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=h.exported.now()+t}setDependencies(t,n){const s={};for(const l of n)s[l]=!0;this.dependencies[t]=s}hasDependency(t,n){for(const s of t){const l=this.dependencies[s];if(l){for(const d of n)if(l[d])return!0}}return!1}}class Ti{constructor(t,n){this.max=t,this.onRemove=n,this.reset()}reset(){for(const t in this.data)for(const n of this.data[t])n.timeout&&clearTimeout(n.timeout),this.onRemove(n.value);return this.data={},this.order=[],this}add(t,n,s){const l=t.wrapped().key;this.data[l]===void 0&&(this.data[l]=[]);const d={value:n,timeout:void 0};if(s!==void 0&&(d.timeout=setTimeout(()=>{this.remove(t,d)},s)),this.data[l].push(d),this.order.push(l),this.order.length>this.max){const m=this._getAndRemoveByKey(this.order[0]);m&&this.onRemove(m)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const n=this.data[t].shift();return n.timeout&&clearTimeout(n.timeout),this.data[t].length===0&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),n.value}getByKey(t){const n=this.data[t];return n?n[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,n){if(!this.has(t))return this;const s=t.wrapped().key,l=n===void 0?0:this.data[s].indexOf(n),d=this.data[s][l];return this.data[s].splice(l,1),d.timeout&&clearTimeout(d.timeout),this.data[s].length===0&&delete this.data[s],this.onRemove(d.value),this.order.splice(this.order.indexOf(s),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}filter(t){const n=[];for(const s in this.data)for(const l of this.data[s])t(l.value)||n.push(l);for(const s of n)this.remove(s.value.tileID,s)}}class sr{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,n,s){const l=String(n);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][l]=this.stateChanges[t][l]||{},h.extend(this.stateChanges[t][l],s),this.deletedStates[t]===null){this.deletedStates[t]={};for(const d in this.state[t])d!==l&&(this.deletedStates[t][d]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][l]===null){this.deletedStates[t][l]={};for(const d in this.state[t][l])s[d]||(this.deletedStates[t][l][d]=null)}else for(const d in s)this.deletedStates[t]&&this.deletedStates[t][l]&&this.deletedStates[t][l][d]===null&&delete this.deletedStates[t][l][d]}removeFeatureState(t,n,s){if(this.deletedStates[t]===null)return;const l=String(n);if(this.deletedStates[t]=this.deletedStates[t]||{},s&&n!==void 0)this.deletedStates[t][l]!==null&&(this.deletedStates[t][l]=this.deletedStates[t][l]||{},this.deletedStates[t][l][s]=null);else if(n!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][l])for(s in this.deletedStates[t][l]={},this.stateChanges[t][l])this.deletedStates[t][l][s]=null;else this.deletedStates[t][l]=null;else this.deletedStates[t]=null}getState(t,n){const s=String(n),l=h.extend({},(this.state[t]||{})[s],(this.stateChanges[t]||{})[s]);if(this.deletedStates[t]===null)return{};if(this.deletedStates[t]){const d=this.deletedStates[t][n];if(d===null)return{};for(const m in d)delete l[m]}return l}initializeTileState(t,n){t.setFeatureState(this.state,n)}coalesceChanges(t,n){const s={};for(const l in this.stateChanges){this.state[l]=this.state[l]||{};const d={};for(const m in this.stateChanges[l])this.state[l][m]||(this.state[l][m]={}),h.extend(this.state[l][m],this.stateChanges[l][m]),d[m]=this.state[l][m];s[l]=d}for(const l in this.deletedStates){this.state[l]=this.state[l]||{};const d={};if(this.deletedStates[l]===null)for(const m in this.state[l])d[m]={},this.state[l][m]={};else for(const m in this.deletedStates[l]){if(this.deletedStates[l][m]===null)this.state[l][m]={};else for(const g of Object.keys(this.deletedStates[l][m]))delete this.state[l][m][g];d[m]=this.state[l][m]}s[l]=s[l]||{},h.extend(s[l],d)}if(this.stateChanges={},this.deletedStates={},Object.keys(s).length!==0)for(const l in t)t[l].setFeatureState(s,n)}}class Xe extends h.Evented{constructor(t,n,s){super(),this.id=t,this.dispatcher=s,this.on("data",l=>{l.dataType==="source"&&l.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&l.dataType==="source"&&l.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain))}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=function(l,d,m,g){const y=new jr[d.type](l,d,m,g);if(y.id!==l)throw new Error(`Expected Source id to be ${l} instead of ${y.id}`);return h.bindAll(["load","abort","unload","serialize","prepare"],y),y}(t,n,s,this),this._tiles={},this._cache=new Ti(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new sr}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const t in this._tiles){const n=this._tiles[t];if(n.state!=="loaded"&&n.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(t,n){return this._source.loadTile(t,n)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,()=>{})}_abortTile(t){this._source.abortTile&&this._source.abortTile(t,()=>{}),this._source.fire(new h.Event("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const n in this._tiles){const s=this._tiles[n];s.upload(t),s.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(t=>t.tileID).sort(Ar).map(t=>t.key)}getRenderableIds(t){const n=[];for(const s in this._tiles)this._isIdRenderable(s,t)&&n.push(this._tiles[s]);return t?n.sort((s,l)=>{const d=s.tileID,m=l.tileID,g=new h.pointGeometry(d.canonical.x,d.canonical.y)._rotate(this.transform.angle),y=new h.pointGeometry(m.canonical.x,m.canonical.y)._rotate(this.transform.angle);return d.overscaledZ-m.overscaledZ||y.y-g.y||y.x-g.x}).map(s=>s.tileID.key):n.map(s=>s.tileID).sort(Ar).map(s=>s.key)}hasRenderableParent(t){const n=this.findLoadedParent(t,0);return!!n&&this._isIdRenderable(n.tileID.key)}_isIdRenderable(t,n){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(n||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)this._tiles[t].state!=="errored"&&this._reloadTile(t,"reloading")}}_reloadTile(t,n){const s=this._tiles[t];s&&(s.state!=="loading"&&(s.state=n),this._loadTile(s,this._tileLoaded.bind(this,s,t,n)))}_tileLoaded(t,n,s,l){if(l)return t.state="errored",void(l.status!==404?this._source.fire(new h.ErrorEvent(l,{tile:t})):this.update(this.transform,this.terrain));t.timeAdded=h.exported.now(),s==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(n,t),this.getSource().type==="raster-dem"&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new h.Event("data",{dataType:"source",tile:t,coord:t.tileID}))}_backfillDEM(t){const n=this.getRenderableIds();for(let l=0;l<n.length;l++){const d=n[l];if(t.neighboringTiles&&t.neighboringTiles[d]){const m=this.getTileByID(d);s(t,m),s(m,t)}}function s(l,d){l.needsHillshadePrepare=!0,l.needsTerrainPrepare=!0;let m=d.tileID.canonical.x-l.tileID.canonical.x;const g=d.tileID.canonical.y-l.tileID.canonical.y,y=Math.pow(2,l.tileID.canonical.z),x=d.tileID.key;m===0&&g===0||Math.abs(g)>1||(Math.abs(m)>1&&(Math.abs(m+y)===1?m+=y:Math.abs(m-y)===1&&(m-=y)),d.dem&&l.dem&&(l.dem.backfillBorder(d.dem,m,g),l.neighboringTiles&&l.neighboringTiles[x]&&(l.neighboringTiles[x].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,n,s,l){for(const d in this._tiles){let m=this._tiles[d];if(l[d]||!m.hasData()||m.tileID.overscaledZ<=n||m.tileID.overscaledZ>s)continue;let g=m.tileID;for(;m&&m.tileID.overscaledZ>n+1;){const x=m.tileID.scaledTo(m.tileID.overscaledZ-1);m=this._tiles[x.key],m&&m.hasData()&&(g=x)}let y=g;for(;y.overscaledZ>n;)if(y=y.scaledTo(y.overscaledZ-1),t[y.key]){l[g.key]=g;break}}}findLoadedParent(t,n){if(t.key in this._loadedParentTiles){const s=this._loadedParentTiles[t.key];return s&&s.tileID.overscaledZ>=n?s:null}for(let s=t.overscaledZ-1;s>=n;s--){const l=t.scaledTo(s),d=this._getLoadedTile(l);if(d)return d}}_getLoadedTile(t){const n=this._tiles[t.key];return n&&n.hasData()?n:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const n=Math.ceil(t.width/this._source.tileSize)+1,s=Math.ceil(t.height/this._source.tileSize)+1,l=Math.floor(n*s*5),d=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,l):l;this._cache.setMaxSize(d)}handleWrapJump(t){const n=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);if(this._prevLng=t,n){const s={};for(const l in this._tiles){const d=this._tiles[l];d.tileID=d.tileID.unwrapTo(d.tileID.wrap+n),s[d.tileID.key]=d}this._tiles=s;for(const l in this._timers)clearTimeout(this._timers[l]),delete this._timers[l];for(const l in this._tiles)this._setTileReloadTimer(l,this._tiles[l])}}update(t,n){if(this.transform=t,this.terrain=n,!this._sourceLoaded||this._paused)return;let s;this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?s=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(x=>new h.OverscaledTileID(x.canonical.z,x.wrap,x.canonical.z,x.canonical.x,x.canonical.y)):(s=t.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n}),this._source.hasTile&&(s=s.filter(x=>this._source.hasTile(x)))):s=[];const l=t.coveringZoomLevel(this._source),d=Math.max(l-Xe.maxOverzooming,this._source.minzoom),m=Math.max(l+Xe.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const x={};for(const S of s)if(S.canonical.z>this._source.minzoom){const T=S.scaledTo(S.canonical.z-1);x[T.key]=T;const M=S.scaledTo(Math.max(this._source.minzoom,Math.min(S.canonical.z,5)));x[M.key]=M}s=s.concat(Object.values(x))}const g=this._updateRetainedTiles(s,l);if(ri(this._source.type)){const x={},S={},T=Object.keys(g);for(const M of T){const F=g[M],O=this._tiles[M];if(!O||O.fadeEndTime&&O.fadeEndTime<=h.exported.now())continue;const D=this.findLoadedParent(F,d);D&&(this._addTile(D.tileID),x[D.tileID.key]=D.tileID),S[M]=F}this._retainLoadedChildren(S,l,m,g);for(const M in x)g[M]||(this._coveredTiles[M]=!0,g[M]=x[M]);if(n){const M={},F={};for(const O of s)this._tiles[O.key].hasData()?M[O.key]=O:F[O.key]=O;for(const O in F){const D=F[O].children(this._source.maxzoom);this._tiles[D[0].key]&&this._tiles[D[1].key]&&this._tiles[D[2].key]&&this._tiles[D[3].key]&&(M[D[0].key]=g[D[0].key]=D[0],M[D[1].key]=g[D[1].key]=D[1],M[D[2].key]=g[D[2].key]=D[2],M[D[3].key]=g[D[3].key]=D[3],delete F[O])}for(const O in F){const D=this.findLoadedParent(F[O],this._source.minzoom);if(D){M[D.tileID.key]=g[D.tileID.key]=D.tileID;for(const G in M)M[G].isChildOf(D.tileID)&&delete M[G]}}for(const O in this._tiles)M[O]||(this._coveredTiles[O]=!0)}}for(const x in g)this._tiles[x].clearFadeHold();const y=h.keysDifference(this._tiles,g);for(const x of y){const S=this._tiles[x];S.hasSymbolBuckets&&!S.holdingForFade()?S.setHoldDuration(this.map._fadeDuration):S.hasSymbolBuckets&&!S.symbolFadeFinished()||this._removeTile(x)}this._updateLoadedParentTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,n){const s={},l={},d=Math.max(n-Xe.maxOverzooming,this._source.minzoom),m=Math.max(n+Xe.maxUnderzooming,this._source.minzoom),g={};for(const y of t){const x=this._addTile(y);s[y.key]=y,x.hasData()||n<this._source.maxzoom&&(g[y.key]=y)}this._retainLoadedChildren(g,n,m,s);for(const y of t){let x=this._tiles[y.key];if(x.hasData())continue;if(n+1>this._source.maxzoom){const T=y.children(this._source.maxzoom)[0],M=this.getTile(T);if(M&&M.hasData()){s[T.key]=T;continue}}else{const T=y.children(this._source.maxzoom);if(s[T[0].key]&&s[T[1].key]&&s[T[2].key]&&s[T[3].key])continue}let S=x.wasRequested();for(let T=y.overscaledZ-1;T>=d;--T){const M=y.scaledTo(T);if(l[M.key]||(l[M.key]=!0,x=this.getTile(M),!x&&S&&(x=this._addTile(M)),x&&(s[M.key]=M,S=x.wasRequested(),x.hasData())))break}}return s}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const n=[];let s,l=this._tiles[t].tileID;for(;l.overscaledZ>0;){if(l.key in this._loadedParentTiles){s=this._loadedParentTiles[l.key];break}n.push(l.key);const d=l.scaledTo(l.overscaledZ-1);if(s=this._getLoadedTile(d),s)break;l=d}for(const d of n)this._loadedParentTiles[d]=s}}_addTile(t){let n=this._tiles[t.key];if(n)return n;n=this._cache.getAndRemove(t),n&&(this._setTileReloadTimer(t.key,n),n.tileID=t,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,n)));const s=n;return n||(n=new Je(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(n,this._tileLoaded.bind(this,n,t.key,n.state))),n.uses++,this._tiles[t.key]=n,s||this._source.fire(new h.Event("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(t,n){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const s=n.getExpiryTimeout();s&&(this._timers[t]=setTimeout(()=>{this._reloadTile(t,"expired"),delete this._timers[t]},s))}_removeTile(t){const n=this._tiles[t];n&&(n.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._cache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(t,n,s){const l=[],d=this.transform;if(!d)return l;const m=s?d.getCameraQueryGeometry(t):t,g=t.map(O=>d.pointCoordinate(O,this.terrain)),y=m.map(O=>d.pointCoordinate(O,this.terrain)),x=this.getIds();let S=1/0,T=1/0,M=-1/0,F=-1/0;for(const O of y)S=Math.min(S,O.x),T=Math.min(T,O.y),M=Math.max(M,O.x),F=Math.max(F,O.y);for(let O=0;O<x.length;O++){const D=this._tiles[x[O]];if(D.holdingForFade())continue;const G=D.tileID,Y=Math.pow(2,d.zoom-D.tileID.overscaledZ),H=n*D.queryPadding*h.EXTENT/D.tileSize/Y,V=[G.getTilePoint(new h.MercatorCoordinate(S,T)),G.getTilePoint(new h.MercatorCoordinate(M,F))];if(V[0].x-H<h.EXTENT&&V[0].y-H<h.EXTENT&&V[1].x+H>=0&&V[1].y+H>=0){const te=g.map(se=>G.getTilePoint(se)),ae=y.map(se=>G.getTilePoint(se));l.push({tile:D,tileID:G,queryGeometry:te,cameraQueryGeometry:ae,scale:Y})}}return l}getVisibleCoordinates(t){const n=this.getRenderableIds(t).map(s=>this._tiles[s].tileID);for(const s of n)s.posMatrix=this.transform.calculatePosMatrix(s.toUnwrapped());return n}hasTransition(){if(this._source.hasTransition())return!0;if(ri(this._source.type))for(const t in this._tiles){const n=this._tiles[t];if(n.fadeEndTime!==void 0&&n.fadeEndTime>=h.exported.now())return!0}return!1}setFeatureState(t,n,s){this._state.updateState(t=t||"_geojsonTileLayer",n,s)}removeFeatureState(t,n,s){this._state.removeFeatureState(t=t||"_geojsonTileLayer",n,s)}getFeatureState(t,n){return this._state.getState(t=t||"_geojsonTileLayer",n)}setDependencies(t,n,s){const l=this._tiles[t];l&&l.setDependencies(n,s)}reloadTilesForDependencies(t,n){for(const s in this._tiles)this._tiles[s].hasDependency(t,n)&&this._reloadTile(s,"reloading");this._cache.filter(s=>!s.hasDependency(t,n))}}function Ar(o,t){const n=Math.abs(2*o.wrap)-+(o.wrap<0),s=Math.abs(2*t.wrap)-+(t.wrap<0);return o.overscaledZ-t.overscaledZ||s-n||t.canonical.y-o.canonical.y||t.canonical.x-o.canonical.x}function ri(o){return o==="raster"||o==="image"||o==="video"}Xe.maxOverzooming=10,Xe.maxUnderzooming=3;const qr="mapboxgl_preloaded_worker_pool";class Mi{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<Mi.workerCount;)this.workers.push(new Worker(Dr.workerUrl));return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],this.numActive()===0&&(this.workers.forEach(n=>{n.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[qr]}numActive(){return Object.keys(this.active).length}}const mi=Math.floor(h.exported.hardwareConcurrency/2);let yt;function gn(){return yt||(yt=new Mi),yt}function Zr(o,t){const n={};for(const s in o)s!=="ref"&&(n[s]=o[s]);return h.refProperties.forEach(s=>{s in t&&(n[s]=t[s])}),n}function _n(o){o=o.slice();const t=Object.create(null);for(let n=0;n<o.length;n++)t[o[n].id]=o[n];for(let n=0;n<o.length;n++)"ref"in o[n]&&(o[n]=Zr(o[n],t[o[n].ref]));return o}Mi.workerCount=Math.max(Math.min(mi,6),1);const lt={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight"};function Cr(o,t,n){n.push({command:lt.addSource,args:[o,t[o]]})}function yn(o,t,n){t.push({command:lt.removeSource,args:[o]}),n[o]=!0}function Xr(o,t,n,s){yn(o,n,s),Cr(o,t,n)}function jn(o,t,n){let s;for(s in o[n])if(Object.prototype.hasOwnProperty.call(o[n],s)&&s!=="data"&&!pe(o[n][s],t[n][s]))return!1;for(s in t[n])if(Object.prototype.hasOwnProperty.call(t[n],s)&&s!=="data"&&!pe(o[n][s],t[n][s]))return!1;return!0}function _r(o,t,n,s,l,d){let m;for(m in t=t||{},o=o||{})Object.prototype.hasOwnProperty.call(o,m)&&(pe(o[m],t[m])||n.push({command:d,args:[s,m,t[m],l]}));for(m in t)Object.prototype.hasOwnProperty.call(t,m)&&!Object.prototype.hasOwnProperty.call(o,m)&&(pe(o[m],t[m])||n.push({command:d,args:[s,m,t[m],l]}))}function Mr(o){return o.id}function ut(o,t){return o[t.id]=t,o}class Wr{constructor(t,n){this.reset(t,n)}reset(t,n){this.points=t||[],this._distances=[0];for(let s=1;s<this.points.length;s++)this._distances[s]=this._distances[s-1]+this.points[s].dist(this.points[s-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(n||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(this.points.length===1)return this.points[0];t=h.clamp(t,0,1);let n=1,s=this._distances[n];const l=t*this.paddedLength+this.padding;for(;s<l&&n<this._distances.length;)s=this._distances[++n];const d=n-1,m=this._distances[d],g=s-m,y=g>0?(l-m)/g:0;return this.points[d].mult(1-y).add(this.points[n].mult(y))}}function Vi(o,t){let n=!0;return o==="always"||o!=="never"&&t!=="never"||(n=!1),n}class ei{constructor(t,n,s){const l=this.boxCells=[],d=this.circleCells=[];this.xCellCount=Math.ceil(t/s),this.yCellCount=Math.ceil(n/s);for(let m=0;m<this.xCellCount*this.yCellCount;m++)l.push([]),d.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=n,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/n,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,n,s,l,d){this._forEachCell(n,s,l,d,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(n),this.bboxes.push(s),this.bboxes.push(l),this.bboxes.push(d)}insertCircle(t,n,s,l){this._forEachCell(n-l,s-l,n+l,s+l,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(n),this.circles.push(s),this.circles.push(l)}_insertBoxCell(t,n,s,l,d,m){this.boxCells[d].push(m)}_insertCircleCell(t,n,s,l,d,m){this.circleCells[d].push(m)}_query(t,n,s,l,d,m,g){if(s<0||t>this.width||l<0||n>this.height)return[];const y=[];if(t<=0&&n<=0&&this.width<=s&&this.height<=l){if(d)return[{key:null,x1:t,y1:n,x2:s,y2:l}];for(let x=0;x<this.boxKeys.length;x++)y.push({key:this.boxKeys[x],x1:this.bboxes[4*x],y1:this.bboxes[4*x+1],x2:this.bboxes[4*x+2],y2:this.bboxes[4*x+3]});for(let x=0;x<this.circleKeys.length;x++){const S=this.circles[3*x],T=this.circles[3*x+1],M=this.circles[3*x+2];y.push({key:this.circleKeys[x],x1:S-M,y1:T-M,x2:S+M,y2:T+M})}}else this._forEachCell(t,n,s,l,this._queryCell,y,{hitTest:d,overlapMode:m,seenUids:{box:{},circle:{}}},g);return y}query(t,n,s,l){return this._query(t,n,s,l,!1,null)}hitTest(t,n,s,l,d,m){return this._query(t,n,s,l,!0,d,m).length>0}hitTestCircle(t,n,s,l,d){const m=t-s,g=t+s,y=n-s,x=n+s;if(g<0||m>this.width||x<0||y>this.height)return!1;const S=[];return this._forEachCell(m,y,g,x,this._queryCellCircle,S,{hitTest:!0,overlapMode:l,circle:{x:t,y:n,radius:s},seenUids:{box:{},circle:{}}},d),S.length>0}_queryCell(t,n,s,l,d,m,g,y){const{seenUids:x,hitTest:S,overlapMode:T}=g,M=this.boxCells[d];if(M!==null){const O=this.bboxes;for(const D of M)if(!x.box[D]){x.box[D]=!0;const G=4*D,Y=this.boxKeys[D];if(t<=O[G+2]&&n<=O[G+3]&&s>=O[G+0]&&l>=O[G+1]&&(!y||y(Y))&&(!S||!Vi(T,Y.overlapMode))&&(m.push({key:Y,x1:O[G],y1:O[G+1],x2:O[G+2],y2:O[G+3]}),S))return!0}}const F=this.circleCells[d];if(F!==null){const O=this.circles;for(const D of F)if(!x.circle[D]){x.circle[D]=!0;const G=3*D,Y=this.circleKeys[D];if(this._circleAndRectCollide(O[G],O[G+1],O[G+2],t,n,s,l)&&(!y||y(Y))&&(!S||!Vi(T,Y.overlapMode))){const H=O[G],V=O[G+1],te=O[G+2];if(m.push({key:Y,x1:H-te,y1:V-te,x2:H+te,y2:V+te}),S)return!0}}}return!1}_queryCellCircle(t,n,s,l,d,m,g,y){const{circle:x,seenUids:S,overlapMode:T}=g,M=this.boxCells[d];if(M!==null){const O=this.bboxes;for(const D of M)if(!S.box[D]){S.box[D]=!0;const G=4*D,Y=this.boxKeys[D];if(this._circleAndRectCollide(x.x,x.y,x.radius,O[G+0],O[G+1],O[G+2],O[G+3])&&(!y||y(Y))&&!Vi(T,Y.overlapMode))return m.push(!0),!0}}const F=this.circleCells[d];if(F!==null){const O=this.circles;for(const D of F)if(!S.circle[D]){S.circle[D]=!0;const G=3*D,Y=this.circleKeys[D];if(this._circlesCollide(O[G],O[G+1],O[G+2],x.x,x.y,x.radius)&&(!y||y(Y))&&!Vi(T,Y.overlapMode))return m.push(!0),!0}}}_forEachCell(t,n,s,l,d,m,g,y){const x=this._convertToXCellCoord(t),S=this._convertToYCellCoord(n),T=this._convertToXCellCoord(s),M=this._convertToYCellCoord(l);for(let F=x;F<=T;F++)for(let O=S;O<=M;O++)if(d.call(this,t,n,s,l,this.xCellCount*O+F,m,g,y))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,n,s,l,d,m){const g=l-t,y=d-n,x=s+m;return x*x>g*g+y*y}_circleAndRectCollide(t,n,s,l,d,m,g){const y=(m-l)/2,x=Math.abs(t-(l+y));if(x>y+s)return!1;const S=(g-d)/2,T=Math.abs(n-(d+S));if(T>S+s)return!1;if(x<=y||T<=S)return!0;const M=x-y,F=T-S;return M*M+F*F<=s*s}}function Yt(o,t,n,s,l){const d=h.create();return t?(h.scale(d,d,[1/l,1/l,1]),n||h.rotateZ(d,d,s.angle)):h.multiply(d,s.labelPlaneMatrix,o),d}function fi(o,t,n,s,l){if(t){const d=h.clone(o);return h.scale(d,d,[l,l,1]),n||h.rotateZ(d,d,-s.angle),d}return s.glCoordMatrix}function gi(o,t,n){let s;n?(s=[o.x,o.y,n(o.x,o.y),1],h.transformMat4(s,s,t)):(s=[o.x,o.y,0,1],Q(s,s,t));const l=s[3];return{point:new h.pointGeometry(s[0]/l,s[1]/l),signedDistanceFromCamera:l}}function yr(o,t){return .5+o/t*.5}function B(o,t){const n=o[0]/o[3],s=o[1]/o[3];return n>=-t[0]&&n<=t[0]&&s>=-t[1]&&s<=t[1]}function I(o,t,n,s,l,d,m,g,y,x){const S=s?o.textSizeData:o.iconSizeData,T=h.evaluateSizeForZoom(S,n.transform.zoom),M=[256/n.width*2+1,256/n.height*2+1],F=s?o.text.dynamicLayoutVertexArray:o.icon.dynamicLayoutVertexArray;F.clear();const O=o.lineVertexArray,D=s?o.text.placedSymbolArray:o.icon.placedSymbolArray,G=n.transform.width/n.transform.height;let Y=!1;for(let H=0;H<D.length;H++){const V=D.get(H);if(V.hidden||V.writingMode===h.WritingMode.vertical&&!Y){q(V.numGlyphs,F);continue}let te;if(Y=!1,x?(te=[V.anchorX,V.anchorY,x(V.anchorX,V.anchorY),1],h.transformMat4(te,te,t)):(te=[V.anchorX,V.anchorY,0,1],Q(te,te,t)),!B(te,M)){q(V.numGlyphs,F);continue}const ae=yr(n.transform.cameraToCenterDistance,te[3]),se=h.evaluateSizeForFeature(S,T,V),ue=m?se/ae:se*ae,me=new h.pointGeometry(V.anchorX,V.anchorY),xe=gi(me,l,x).point,_e={},we=U(V,ue,!1,g,t,l,d,o.glyphOffsetArray,O,F,xe,me,_e,G,y,x);Y=we.useVertical,(we.notEnoughRoom||Y||we.needsFlipping&&U(V,ue,!0,g,t,l,d,o.glyphOffsetArray,O,F,xe,me,_e,G,y,x).notEnoughRoom)&&q(V.numGlyphs,F)}s?o.text.dynamicLayoutVertexBuffer.updateData(F):o.icon.dynamicLayoutVertexBuffer.updateData(F)}function C(o,t,n,s,l,d,m,g,y,x,S,T,M){const F=g.glyphStartIndex+g.numGlyphs,O=g.lineStartIndex,D=g.lineStartIndex+g.lineLength,G=t.getoffsetX(g.glyphStartIndex),Y=t.getoffsetX(F-1),H=X(o*G,n,s,l,d,m,g.segment,O,D,y,x,S,T,M);if(!H)return null;const V=X(o*Y,n,s,l,d,m,g.segment,O,D,y,x,S,T,M);return V?{first:H,last:V}:null}function R(o,t,n,s){return o===h.WritingMode.horizontal&&Math.abs(n.y-t.y)>Math.abs(n.x-t.x)*s?{useVertical:!0}:(o===h.WritingMode.vertical?t.y<n.y:t.x>n.x)?{needsFlipping:!0}:null}function U(o,t,n,s,l,d,m,g,y,x,S,T,M,F,O,D){const G=t/24,Y=o.lineOffsetX*G,H=o.lineOffsetY*G;let V;if(o.numGlyphs>1){const te=o.glyphStartIndex+o.numGlyphs,ae=o.lineStartIndex,se=o.lineStartIndex+o.lineLength,ue=C(G,g,Y,H,n,S,T,o,y,d,M,O,D);if(!ue)return{notEnoughRoom:!0};const me=gi(ue.first.point,m,D).point,xe=gi(ue.last.point,m,D).point;if(s&&!n){const _e=R(o.writingMode,me,xe,F);if(_e)return _e}V=[ue.first];for(let _e=o.glyphStartIndex+1;_e<te-1;_e++)V.push(X(G*g.getoffsetX(_e),Y,H,n,S,T,o.segment,ae,se,y,d,M,O,D));V.push(ue.last)}else{if(s&&!n){const ae=gi(T,l,D).point,se=o.lineStartIndex+o.segment+1,ue=new h.pointGeometry(y.getx(se),y.gety(se)),me=gi(ue,l,D),xe=me.signedDistanceFromCamera>0?me.point:j(T,ue,ae,1,l,D),_e=R(o.writingMode,ae,xe,F);if(_e)return _e}const te=X(G*g.getoffsetX(o.glyphStartIndex),Y,H,n,S,T,o.segment,o.lineStartIndex,o.lineStartIndex+o.lineLength,y,d,M,O,D);if(!te)return{notEnoughRoom:!0};V=[te]}for(const te of V)h.addDynamicAttributes(x,te.point,te.angle);return{}}function j(o,t,n,s,l,d){const m=gi(o.add(o.sub(t)._unit()),l,d).point,g=n.sub(m);return n.add(g._mult(s/g.mag()))}function X(o,t,n,s,l,d,m,g,y,x,S,T,M,F){const O=s?o-t:o+t;let D=O>0?1:-1,G=0;s&&(D*=-1,G=Math.PI),D<0&&(G+=Math.PI);let Y=D>0?g+m:g+m+1,H=l,V=l,te=0,ae=0;const se=Math.abs(O),ue=[];for(;te+ae<=se;){if(Y+=D,Y<g||Y>=y)return null;if(V=H,ue.push(H),H=T[Y],H===void 0){const ze=new h.pointGeometry(x.getx(Y),x.gety(Y)),We=gi(ze,S,F);if(We.signedDistanceFromCamera>0)H=T[Y]=We.point;else{const Ke=Y-D;H=j(te===0?d:new h.pointGeometry(x.getx(Ke),x.gety(Ke)),ze,V,se-te+1,S,F)}}te+=ae,ae=V.dist(H)}const me=(se-te)/ae,xe=H.sub(V),_e=xe.mult(me)._add(V);_e._add(xe._unit()._perp()._mult(n*D));const we=G+Math.atan2(H.y-V.y,H.x-V.x);return ue.push(_e),{point:_e,angle:M?we:0,path:ue}}const Z=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function q(o,t){for(let n=0;n<o;n++){const s=t.length;t.resize(s+4),t.float32.set(Z,3*s)}}function Q(o,t,n){const s=t[0],l=t[1];return o[0]=n[0]*s+n[4]*l+n[12],o[1]=n[1]*s+n[5]*l+n[13],o[3]=n[3]*s+n[7]*l+n[15],o}const oe=100;class ye{constructor(t,n=new ei(t.width+200,t.height+200,25),s=new ei(t.width+200,t.height+200,25)){this.transform=t,this.grid=n,this.ignoredGrid=s,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+oe,this.screenBottomBoundary=t.height+oe,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,n,s,l,d,m){const g=this.projectAndGetPerspectiveRatio(l,t.anchorPointX,t.anchorPointY,m),y=s*g.perspectiveRatio,x=t.x1*y+g.point.x,S=t.y1*y+g.point.y,T=t.x2*y+g.point.x,M=t.y2*y+g.point.y;return!this.isInsideGrid(x,S,T,M)||n!=="always"&&this.grid.hitTest(x,S,T,M,n,d)||g.perspectiveRatio<this.perspectiveRatioCutoff?{box:[],offscreen:!1}:{box:[x,S,T,M],offscreen:this.isOffscreen(x,S,T,M)}}placeCollisionCircles(t,n,s,l,d,m,g,y,x,S,T,M,F,O){const D=[],G=new h.pointGeometry(n.anchorX,n.anchorY),Y=gi(G,m,O),H=yr(this.transform.cameraToCenterDistance,Y.signedDistanceFromCamera),V=(S?d/H:d*H)/h.ONE_EM,te=gi(G,g,O).point,ae=C(V,l,n.lineOffsetX*V,n.lineOffsetY*V,!1,te,G,n,s,g,{},!1,O);let se=!1,ue=!1,me=!0;if(ae){const xe=.5*M*H+F,_e=new h.pointGeometry(-100,-100),we=new h.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),ze=new Wr,We=ae.first,Ke=ae.last;let Le=[];for(let tt=We.path.length-1;tt>=1;tt--)Le.push(We.path[tt]);for(let tt=1;tt<Ke.path.length;tt++)Le.push(Ke.path[tt]);const mt=2.5*xe;if(y){const tt=Le.map(ht=>gi(ht,y,O));Le=tt.some(ht=>ht.signedDistanceFromCamera<=0)?[]:tt.map(ht=>ht.point)}let ft=[];if(Le.length>0){const tt=Le[0].clone(),ht=Le[0].clone();for(let wt=1;wt<Le.length;wt++)tt.x=Math.min(tt.x,Le[wt].x),tt.y=Math.min(tt.y,Le[wt].y),ht.x=Math.max(ht.x,Le[wt].x),ht.y=Math.max(ht.y,Le[wt].y);ft=tt.x>=_e.x&&ht.x<=we.x&&tt.y>=_e.y&&ht.y<=we.y?[Le]:ht.x<_e.x||tt.x>we.x||ht.y<_e.y||tt.y>we.y?[]:h.clipLine([Le],_e.x,_e.y,we.x,we.y)}for(const tt of ft){ze.reset(tt,.25*xe);let ht=0;ht=ze.length<=.5*xe?1:Math.ceil(ze.paddedLength/mt)+1;for(let wt=0;wt<ht;wt++){const gt=wt/Math.max(ht-1,1),ji=ze.lerp(gt),qi=ji.x+oe,ni=ji.y+oe;D.push(qi,ni,xe,0);const ki=qi-xe,_i=ni-xe,Ji=qi+xe,Rr=ni+xe;if(me=me&&this.isOffscreen(ki,_i,Ji,Rr),ue=ue||this.isInsideGrid(ki,_i,Ji,Rr),t!=="always"&&this.grid.hitTestCircle(qi,ni,xe,t,T)&&(se=!0,!x))return{circles:[],offscreen:!1,collisionDetected:se}}}}return{circles:!x&&se||!ue||H<this.perspectiveRatioCutoff?[]:D,offscreen:me,collisionDetected:se}}queryRenderedSymbols(t){if(t.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const n=[];let s=1/0,l=1/0,d=-1/0,m=-1/0;for(const S of t){const T=new h.pointGeometry(S.x+oe,S.y+oe);s=Math.min(s,T.x),l=Math.min(l,T.y),d=Math.max(d,T.x),m=Math.max(m,T.y),n.push(T)}const g=this.grid.query(s,l,d,m).concat(this.ignoredGrid.query(s,l,d,m)),y={},x={};for(const S of g){const T=S.key;if(y[T.bucketInstanceId]===void 0&&(y[T.bucketInstanceId]={}),y[T.bucketInstanceId][T.featureIndex])continue;const M=[new h.pointGeometry(S.x1,S.y1),new h.pointGeometry(S.x2,S.y1),new h.pointGeometry(S.x2,S.y2),new h.pointGeometry(S.x1,S.y2)];h.polygonIntersectsPolygon(n,M)&&(y[T.bucketInstanceId][T.featureIndex]=!0,x[T.bucketInstanceId]===void 0&&(x[T.bucketInstanceId]=[]),x[T.bucketInstanceId].push(T.featureIndex))}return x}insertCollisionBox(t,n,s,l,d,m){(s?this.ignoredGrid:this.grid).insert({bucketInstanceId:l,featureIndex:d,collisionGroupID:m,overlapMode:n},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,n,s,l,d,m){const g=s?this.ignoredGrid:this.grid,y={bucketInstanceId:l,featureIndex:d,collisionGroupID:m,overlapMode:n};for(let x=0;x<t.length;x+=4)g.insertCircle(y,t[x],t[x+1],t[x+2])}projectAndGetPerspectiveRatio(t,n,s,l){let d;return l?(d=[n,s,l(n,s),1],h.transformMat4(d,d,t)):(d=[n,s,0,1],Q(d,d,t)),{point:new h.pointGeometry((d[0]/d[3]+1)/2*this.transform.width+oe,(-d[1]/d[3]+1)/2*this.transform.height+oe),perspectiveRatio:.5+this.transform.cameraToCenterDistance/d[3]*.5}}isOffscreen(t,n,s,l){return s<oe||t>=this.screenRightBoundary||l<oe||n>this.screenBottomBoundary}isInsideGrid(t,n,s,l){return s>=0&&t<this.gridRightBoundary&&l>=0&&n<this.gridBottomBoundary}getViewportMatrix(){const t=h.identity([]);return h.translate(t,t,[-100,-100,0]),t}}function ce(o,t,n){return t*(h.EXTENT/(o.tileSize*Math.pow(2,n-o.tileID.overscaledZ)))}class Ne{constructor(t,n,s,l){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?n:-n))):l&&s?1:0,this.placed=s}isHidden(){return this.opacity===0&&!this.placed}}class je{constructor(t,n,s,l,d){this.text=new Ne(t?t.text:null,n,s,d),this.icon=new Ne(t?t.icon:null,n,l,d)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Re{constructor(t,n,s){this.text=t,this.icon=n,this.skipFade=s}}class qe{constructor(){this.invProjMatrix=h.create(),this.viewportMatrix=h.create(),this.circles=[]}}class st{constructor(t,n,s,l,d){this.bucketInstanceId=t,this.featureIndex=n,this.sourceLayerIndex=s,this.bucketIndex=l,this.tileID=d}}class St{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const n=++this.maxGroupID;this.collisionGroups[t]={ID:n,predicate:s=>s.collisionGroupID===n}}return this.collisionGroups[t]}}function ot(o,t,n,s,l){const{horizontalAlign:d,verticalAlign:m}=h.getAnchorAlignment(o),g=-(d-.5)*t,y=-(m-.5)*n,x=h.evaluateVariableOffset(o,s);return new h.pointGeometry(g+x[0]*l,y+x[1]*l)}function ct(o,t,n,s,l,d){const{x1:m,x2:g,y1:y,y2:x,anchorPointX:S,anchorPointY:T}=o,M=new h.pointGeometry(t,n);return s&&M._rotate(l?d:-d),{x1:m+M.x,y1:y+M.y,x2:g+M.x,y2:x+M.y,anchorPointX:S,anchorPointY:T}}class It{constructor(t,n,s,l,d){this.transform=t.clone(),this.terrain=n,this.collisionIndex=new ye(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=s,this.retainedQueryData={},this.collisionGroups=new St(l),this.collisionCircleArrays={},this.prevPlacement=d,d&&(d.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,n,s,l){const d=s.getBucket(n),m=s.latestFeatureIndex;if(!d||!m||n.id!==d.layerIds[0])return;const g=s.collisionBoxArray,y=d.layers[0].layout,x=Math.pow(2,this.transform.zoom-s.tileID.overscaledZ),S=s.tileSize/h.EXTENT,T=this.transform.calculatePosMatrix(s.tileID.toUnwrapped()),M=y.get("text-pitch-alignment")==="map",F=y.get("text-rotation-alignment")==="map",O=ce(s,1,this.transform.zoom),D=Yt(T,M,F,this.transform,O);let G=null;if(M){const H=fi(T,M,F,this.transform,O);G=h.multiply([],this.transform.labelPlaneMatrix,H)}this.retainedQueryData[d.bucketInstanceId]=new st(d.bucketInstanceId,m,d.sourceLayerIndex,d.index,s.tileID);const Y={bucket:d,layout:y,posMatrix:T,textLabelPlaneMatrix:D,labelToScreenMatrix:G,scale:x,textPixelRatio:S,holdingForFade:s.holdingForFade(),collisionBoxArray:g,partiallyEvaluatedTextSize:h.evaluateSizeForZoom(d.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(d.sourceID)};if(l)for(const H of d.sortKeyRanges){const{sortKey:V,symbolInstanceStart:te,symbolInstanceEnd:ae}=H;t.push({sortKey:V,symbolInstanceStart:te,symbolInstanceEnd:ae,parameters:Y})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:d.symbolInstances.length,parameters:Y})}attemptAnchorPlacement(t,n,s,l,d,m,g,y,x,S,T,M,F,O,D,G){const Y=[M.textOffset0,M.textOffset1],H=ot(t,s,l,Y,d),V=this.collisionIndex.placeCollisionBox(ct(n,H.x,H.y,m,g,this.transform.angle),T,y,x,S.predicate,G);if((!D||this.collisionIndex.placeCollisionBox(ct(D,H.x,H.y,m,g,this.transform.angle),T,y,x,S.predicate,G).box.length!==0)&&V.box.length>0){let te;if(this.prevPlacement&&this.prevPlacement.variableOffsets[M.crossTileID]&&this.prevPlacement.placements[M.crossTileID]&&this.prevPlacement.placements[M.crossTileID].text&&(te=this.prevPlacement.variableOffsets[M.crossTileID].anchor),M.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[M.crossTileID]={textOffset:Y,width:s,height:l,anchor:t,textBoxScale:d,prevAnchor:te},this.markUsedJustification(F,t,M,O),F.allowVerticalPlacement&&(this.markUsedOrientation(F,O,M),this.placedOrientations[M.crossTileID]=O),{shift:H,placedGlyphBoxes:V}}}placeLayerBucketPart(t,n,s){const{bucket:l,layout:d,posMatrix:m,textLabelPlaneMatrix:g,labelToScreenMatrix:y,textPixelRatio:x,holdingForFade:S,collisionBoxArray:T,partiallyEvaluatedTextSize:M,collisionGroup:F}=t.parameters,O=d.get("text-optional"),D=d.get("icon-optional"),G=h.getOverlapMode(d,"text-overlap","text-allow-overlap"),Y=G==="always",H=h.getOverlapMode(d,"icon-overlap","icon-allow-overlap"),V=H==="always",te=d.get("text-rotation-alignment")==="map",ae=d.get("text-pitch-alignment")==="map",se=d.get("icon-text-fit")!=="none",ue=d.get("symbol-z-order")==="viewport-y",me=Y&&(V||!l.hasIconData()||D),xe=V&&(Y||!l.hasTextData()||O);!l.collisionArrays&&T&&l.deserializeCollisionBoxes(T);const _e=(we,ze)=>{if(n[we.crossTileID])return;if(S)return void(this.placements[we.crossTileID]=new Re(!1,!1,!1));let We=!1,Ke=!1,Le=!0,mt=null,ft={box:null,offscreen:null},tt={box:null,offscreen:null},ht=null,wt=null,gt=null,ji=0,qi=0,ni=0;ze.textFeatureIndex?ji=ze.textFeatureIndex:we.useRuntimeCollisionCircles&&(ji=we.featureIndex),ze.verticalTextFeatureIndex&&(qi=ze.verticalTextFeatureIndex);const ki=this.retainedQueryData[l.bucketInstanceId].tileID,_i=this.terrain?(qt,Dt)=>this.terrain.getElevation(ki,qt,Dt):null;for(const qt of["textBox","verticalTextBox","iconBox","verticalIconBox"]){const Dt=ze[qt];Dt&&(Dt.elevation=_i?_i(Dt.anchorPointX,Dt.anchorPointY):0)}const Ji=ze.textBox;if(Ji){const qt=_t=>{let yi=h.WritingMode.horizontal;if(l.allowVerticalPlacement&&!_t&&this.prevPlacement){const xi=this.prevPlacement.placedOrientations[we.crossTileID];xi&&(this.placedOrientations[we.crossTileID]=xi,yi=xi,this.markUsedOrientation(l,yi,we))}return yi},Dt=(_t,yi)=>{if(l.allowVerticalPlacement&&we.numVerticalGlyphVertices>0&&ze.verticalTextBox){for(const xi of l.writingModes)if(xi===h.WritingMode.vertical?(ft=yi(),tt=ft):ft=_t(),ft&&ft.box&&ft.box.length)break}else ft=_t()};if(d.get("text-variable-anchor")){let _t=d.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[we.crossTileID]){const Rt=this.prevPlacement.variableOffsets[we.crossTileID];_t.indexOf(Rt.anchor)>0&&(_t=_t.filter(cr=>cr!==Rt.anchor),_t.unshift(Rt.anchor))}const yi=(Rt,cr,Qi)=>{const oo=Rt.x2-Rt.x1,nn=Rt.y2-Rt.y1,Ya=we.textBoxScale,Ja=se&&H==="never"?cr:null;let sa={box:[],offscreen:!1};const mc=G!=="never"?2*_t.length:_t.length;for(let Ht=0;Ht<mc;++Ht){const Br=this.attemptAnchorPlacement(_t[Ht%_t.length],Rt,oo,nn,Ya,te,ae,x,m,F,Ht>=_t.length?G:"never",we,l,Qi,Ja,_i);if(Br&&(sa=Br.placedGlyphBoxes,sa&&sa.box&&sa.box.length)){We=!0,mt=Br.shift;break}}return sa};Dt(()=>yi(Ji,ze.iconBox,h.WritingMode.horizontal),()=>{const Rt=ze.verticalTextBox;return l.allowVerticalPlacement&&!(ft&&ft.box&&ft.box.length)&&we.numVerticalGlyphVertices>0&&Rt?yi(Rt,ze.verticalIconBox,h.WritingMode.vertical):{box:null,offscreen:null}}),ft&&(We=ft.box,Le=ft.offscreen);const xi=qt(ft&&ft.box);if(!We&&this.prevPlacement){const Rt=this.prevPlacement.variableOffsets[we.crossTileID];Rt&&(this.variableOffsets[we.crossTileID]=Rt,this.markUsedJustification(l,Rt.anchor,we,xi))}}else{const _t=(yi,xi)=>{const Rt=this.collisionIndex.placeCollisionBox(yi,G,x,m,F.predicate,_i);return Rt&&Rt.box&&Rt.box.length&&(this.markUsedOrientation(l,xi,we),this.placedOrientations[we.crossTileID]=xi),Rt};Dt(()=>_t(Ji,h.WritingMode.horizontal),()=>{const yi=ze.verticalTextBox;return l.allowVerticalPlacement&&we.numVerticalGlyphVertices>0&&yi?_t(yi,h.WritingMode.vertical):{box:null,offscreen:null}}),qt(ft&&ft.box&&ft.box.length)}}if(ht=ft,We=ht&&ht.box&&ht.box.length>0,Le=ht&&ht.offscreen,we.useRuntimeCollisionCircles){const qt=l.text.placedSymbolArray.get(we.centerJustifiedTextSymbolIndex),Dt=h.evaluateSizeForFeature(l.textSizeData,M,qt),_t=d.get("text-padding");wt=this.collisionIndex.placeCollisionCircles(G,qt,l.lineVertexArray,l.glyphOffsetArray,Dt,m,g,y,s,ae,F.predicate,we.collisionCircleDiameter,_t,_i),wt.circles.length&&wt.collisionDetected&&!s&&h.warnOnce("Collisions detected, but collision boxes are not shown"),We=Y||wt.circles.length>0&&!wt.collisionDetected,Le=Le&&wt.offscreen}if(ze.iconFeatureIndex&&(ni=ze.iconFeatureIndex),ze.iconBox){const qt=Dt=>{const _t=se&&mt?ct(Dt,mt.x,mt.y,te,ae,this.transform.angle):Dt;return this.collisionIndex.placeCollisionBox(_t,H,x,m,F.predicate,_i)};tt&&tt.box&&tt.box.length&&ze.verticalIconBox?(gt=qt(ze.verticalIconBox),Ke=gt.box.length>0):(gt=qt(ze.iconBox),Ke=gt.box.length>0),Le=Le&&gt.offscreen}const Rr=O||we.numHorizontalGlyphVertices===0&&we.numVerticalGlyphVertices===0,Ka=D||we.numIconVertices===0;if(Rr||Ka?Ka?Rr||(Ke=Ke&&We):We=Ke&&We:Ke=We=Ke&&We,We&&ht&&ht.box&&this.collisionIndex.insertCollisionBox(ht.box,G,d.get("text-ignore-placement"),l.bucketInstanceId,tt&&tt.box&&qi?qi:ji,F.ID),Ke&&gt&&this.collisionIndex.insertCollisionBox(gt.box,H,d.get("icon-ignore-placement"),l.bucketInstanceId,ni,F.ID),wt&&(We&&this.collisionIndex.insertCollisionCircles(wt.circles,G,d.get("text-ignore-placement"),l.bucketInstanceId,ji,F.ID),s)){const qt=l.bucketInstanceId;let Dt=this.collisionCircleArrays[qt];Dt===void 0&&(Dt=this.collisionCircleArrays[qt]=new qe);for(let _t=0;_t<wt.circles.length;_t+=4)Dt.circles.push(wt.circles[_t+0]),Dt.circles.push(wt.circles[_t+1]),Dt.circles.push(wt.circles[_t+2]),Dt.circles.push(wt.collisionDetected?1:0)}if(we.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(l.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[we.crossTileID]=new Re(We||me,Ke||xe,Le||l.justReloaded),n[we.crossTileID]=!0};if(ue){if(t.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const we=l.getSortedSymbolIndexes(this.transform.angle);for(let ze=we.length-1;ze>=0;--ze){const We=we[ze];_e(l.symbolInstances.get(We),l.collisionArrays[We])}}else for(let we=t.symbolInstanceStart;we<t.symbolInstanceEnd;we++)_e(l.symbolInstances.get(we),l.collisionArrays[we]);if(s&&l.bucketInstanceId in this.collisionCircleArrays){const we=this.collisionCircleArrays[l.bucketInstanceId];h.invert(we.invProjMatrix,m),we.viewportMatrix=this.collisionIndex.getViewportMatrix()}l.justReloaded=!1}markUsedJustification(t,n,s,l){let d;d=l===h.WritingMode.vertical?s.verticalPlacedTextSymbolIndex:{left:s.leftJustifiedTextSymbolIndex,center:s.centerJustifiedTextSymbolIndex,right:s.rightJustifiedTextSymbolIndex}[h.getAnchorJustification(n)];const m=[s.leftJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.rightJustifiedTextSymbolIndex,s.verticalPlacedTextSymbolIndex];for(const g of m)g>=0&&(t.text.placedSymbolArray.get(g).crossTileID=d>=0&&g!==d?0:s.crossTileID)}markUsedOrientation(t,n,s){const l=n===h.WritingMode.horizontal||n===h.WritingMode.horizontalOnly?n:0,d=n===h.WritingMode.vertical?n:0,m=[s.leftJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.rightJustifiedTextSymbolIndex];for(const g of m)t.text.placedSymbolArray.get(g).placedOrientation=l;s.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(s.verticalPlacedTextSymbolIndex).placedOrientation=d)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let s=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const l=n?n.symbolFadeChange(t):1,d=n?n.opacities:{},m=n?n.variableOffsets:{},g=n?n.placedOrientations:{};for(const y in this.placements){const x=this.placements[y],S=d[y];S?(this.opacities[y]=new je(S,l,x.text,x.icon),s=s||x.text!==S.text.placed||x.icon!==S.icon.placed):(this.opacities[y]=new je(null,l,x.text,x.icon,x.skipFade),s=s||x.text||x.icon)}for(const y in d){const x=d[y];if(!this.opacities[y]){const S=new je(x,l,!1,!1);S.isHidden()||(this.opacities[y]=S,s=s||x.text.placed||x.icon.placed)}}for(const y in m)this.variableOffsets[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.variableOffsets[y]=m[y]);for(const y in g)this.placedOrientations[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.placedOrientations[y]=g[y]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");s?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:t)}updateLayerOpacities(t,n){const s={};for(const l of n){const d=l.getBucket(t);d&&l.latestFeatureIndex&&t.id===d.layerIds[0]&&this.updateBucketOpacities(d,s,l.collisionBoxArray)}}updateBucketOpacities(t,n,s){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const l=t.layers[0].layout,d=new je(null,0,!1,!1,!0),m=l.get("text-allow-overlap"),g=l.get("icon-allow-overlap"),y=l.get("text-variable-anchor"),x=l.get("text-rotation-alignment")==="map",S=l.get("text-pitch-alignment")==="map",T=l.get("icon-text-fit")!=="none",M=new je(null,0,m&&(g||!t.hasIconData()||l.get("icon-optional")),g&&(m||!t.hasTextData()||l.get("text-optional")),!0);!t.collisionArrays&&s&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(s);const F=(O,D,G)=>{for(let Y=0;Y<D/4;Y++)O.opacityVertexArray.emplaceBack(G);O.hasVisibleVertices=O.hasVisibleVertices||G!==Pr};for(let O=0;O<t.symbolInstances.length;O++){const D=t.symbolInstances.get(O),{numHorizontalGlyphVertices:G,numVerticalGlyphVertices:Y,crossTileID:H}=D;let V=this.opacities[H];n[H]?V=d:V||(V=M,this.opacities[H]=V),n[H]=!0;const te=D.numIconVertices>0,ae=this.placedOrientations[D.crossTileID],se=ae===h.WritingMode.vertical,ue=ae===h.WritingMode.horizontal||ae===h.WritingMode.horizontalOnly;if(G>0||Y>0){const me=vn(V.text);F(t.text,G,se?Pr:me),F(t.text,Y,ue?Pr:me);const xe=V.text.isHidden();[D.rightJustifiedTextSymbolIndex,D.centerJustifiedTextSymbolIndex,D.leftJustifiedTextSymbolIndex].forEach(ze=>{ze>=0&&(t.text.placedSymbolArray.get(ze).hidden=xe||se?1:0)}),D.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(D.verticalPlacedTextSymbolIndex).hidden=xe||ue?1:0);const _e=this.variableOffsets[D.crossTileID];_e&&this.markUsedJustification(t,_e.anchor,D,ae);const we=this.placedOrientations[D.crossTileID];we&&(this.markUsedJustification(t,"left",D,we),this.markUsedOrientation(t,we,D))}if(te){const me=vn(V.icon),xe=!(T&&D.verticalPlacedIconSymbolIndex&&se);D.placedIconSymbolIndex>=0&&(F(t.icon,D.numIconVertices,xe?me:Pr),t.icon.placedSymbolArray.get(D.placedIconSymbolIndex).hidden=V.icon.isHidden()),D.verticalPlacedIconSymbolIndex>=0&&(F(t.icon,D.numVerticalIconVertices,xe?Pr:me),t.icon.placedSymbolArray.get(D.verticalPlacedIconSymbolIndex).hidden=V.icon.isHidden())}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const me=t.collisionArrays[O];if(me){let xe=new h.pointGeometry(0,0);if(me.textBox||me.verticalTextBox){let we=!0;if(y){const ze=this.variableOffsets[H];ze?(xe=ot(ze.anchor,ze.width,ze.height,ze.textOffset,ze.textBoxScale),x&&xe._rotate(S?this.transform.angle:-this.transform.angle)):we=!1}me.textBox&&$t(t.textCollisionBox.collisionVertexArray,V.text.placed,!we||se,xe.x,xe.y),me.verticalTextBox&&$t(t.textCollisionBox.collisionVertexArray,V.text.placed,!we||ue,xe.x,xe.y)}const _e=!!(!ue&&me.verticalIconBox);me.iconBox&&$t(t.iconCollisionBox.collisionVertexArray,V.icon.placed,_e,T?xe.x:0,T?xe.y:0),me.verticalIconBox&&$t(t.iconCollisionBox.collisionVertexArray,V.icon.placed,!_e,T?xe.x:0,T?xe.y:0)}}}if(t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);if(t.bucketInstanceId in this.collisionCircleArrays){const O=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=O.invProjMatrix,t.placementViewportMatrix=O.viewportMatrix,t.collisionCircleArray=O.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return this.fadeDuration===0?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,n){const s=this.zoomAtLastRecencyCheck===n?1-this.zoomAdjustment(n):1;return this.zoomAtLastRecencyCheck=n,this.commitTime+this.fadeDuration*s>t}setStale(){this.stale=!0}}function $t(o,t,n,s,l){o.emplaceBack(t?1:0,n?1:0,s||0,l||0),o.emplaceBack(t?1:0,n?1:0,s||0,l||0),o.emplaceBack(t?1:0,n?1:0,s||0,l||0),o.emplaceBack(t?1:0,n?1:0,s||0,l||0)}const ti=Math.pow(2,25),Wt=Math.pow(2,24),xn=Math.pow(2,17),Ro=Math.pow(2,16),Bo=Math.pow(2,9),Hr=Math.pow(2,8),fa=Math.pow(2,1);function vn(o){if(o.opacity===0&&!o.placed)return 0;if(o.opacity===1&&o.placed)return 4294967295;const t=o.placed?1:0,n=Math.floor(127*o.opacity);return n*ti+t*Wt+n*xn+t*Ro+n*Bo+t*Hr+n*fa+t}const Pr=0;class ga{constructor(t){this._sortAcrossTiles=t.layout.get("symbol-z-order")!=="viewport-y"&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,n,s,l,d){const m=this._bucketParts;for(;this._currentTileIndex<t.length;)if(n.getBucketParts(m,l,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,d())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,m.sort((g,y)=>g.sortKey-y.sortKey));this._currentPartIndex<m.length;)if(n.placeLayerBucketPart(m[this._currentPartIndex],this._seenCrossTileIDs,s),this._currentPartIndex++,d())return!0;return!1}}class ds{constructor(t,n,s,l,d,m,g,y){this.placement=new It(t,n,m,g,y),this._currentPlacementIndex=s.length-1,this._forceFullPlacement=l,this._showCollisionBoxes=d,this._done=!1}isDone(){return this._done}continuePlacement(t,n,s){const l=h.exported.now(),d=()=>{const m=h.exported.now()-l;return!this._forceFullPlacement&&m>2};for(;this._currentPlacementIndex>=0;){const m=n[t[this._currentPlacementIndex]],g=this.placement.collisionIndex.transform.zoom;if(m.type==="symbol"&&(!m.minzoom||m.minzoom<=g)&&(!m.maxzoom||m.maxzoom>g)){if(this._inProgressLayer||(this._inProgressLayer=new ga(m)),this._inProgressLayer.continuePlacement(s[m.source],this.placement,this._showCollisionBoxes,m,d))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const bn=512/h.EXTENT/2;class ps{constructor(t,n,s){this.tileID=t,this.bucketInstanceId=s,this._symbolsByKey={};const l=new Map;for(let d=0;d<n.length;d++){const m=n.get(d),g=m.key,y=l.get(g);y?y.push(m):l.set(g,[m])}for(const[d,m]of l){const g={positions:m.map(y=>({x:Math.floor(y.anchorX*bn),y:Math.floor(y.anchorY*bn)})),crossTileIDs:m.map(y=>y.crossTileID)};if(g.positions.length>128){const y=new h.KDBush(g.positions,x=>x.x,x=>x.y,16,Uint16Array);delete y.points,delete g.positions,g.index=y}this._symbolsByKey[d]=g}}getScaledCoordinates(t,n){const{x:s,y:l,z:d}=this.tileID.canonical,{x:m,y:g,z:y}=n.canonical,x=bn/Math.pow(2,y-d),S=(g*h.EXTENT+t.anchorY)*x,T=l*h.EXTENT*bn;return{x:Math.floor((m*h.EXTENT+t.anchorX)*x-s*h.EXTENT*bn),y:Math.floor(S-T)}}findMatches(t,n,s){const l=this.tileID.canonical.z<n.canonical.z?1:Math.pow(2,this.tileID.canonical.z-n.canonical.z);for(let d=0;d<t.length;d++){const m=t.get(d);if(m.crossTileID)continue;const g=this._symbolsByKey[m.key];if(!g)continue;const y=this.getScaledCoordinates(m,n);if(g.index){const x=g.index.range(y.x-l,y.y-l,y.x+l,y.y+l).sort();for(const S of x){const T=g.crossTileIDs[S];if(!s[T]){s[T]=!0,m.crossTileID=T;break}}}else if(g.positions)for(let x=0;x<g.positions.length;x++){const S=g.positions[x],T=g.crossTileIDs[x];if(Math.abs(S.x-y.x)<=l&&Math.abs(S.y-y.y)<=l&&!s[T]){s[T]=!0,m.crossTileID=T;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:t})=>t)}}class _a{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class qn{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const n=Math.round((t-this.lng)/360);if(n!==0)for(const s in this.indexes){const l=this.indexes[s],d={};for(const m in l){const g=l[m];g.tileID=g.tileID.unwrapTo(g.tileID.wrap+n),d[g.tileID.key]=g}this.indexes[s]=d}this.lng=t}addBucket(t,n,s){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let d=0;d<n.symbolInstances.length;d++)n.symbolInstances.get(d).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const l=this.usedCrossTileIDs[t.overscaledZ];for(const d in this.indexes){const m=this.indexes[d];if(Number(d)>t.overscaledZ)for(const g in m){const y=m[g];y.tileID.isChildOf(t)&&y.findMatches(n.symbolInstances,t,l)}else{const g=m[t.scaledTo(Number(d)).key];g&&g.findMatches(n.symbolInstances,t,l)}}for(let d=0;d<n.symbolInstances.length;d++){const m=n.symbolInstances.get(d);m.crossTileID||(m.crossTileID=s.generate(),l[m.crossTileID]=!0)}return this.indexes[t.overscaledZ]===void 0&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new ps(t,n.symbolInstances,n.bucketInstanceId),!0}removeBucketCrossTileIDs(t,n){for(const s of n.getCrossTileIDsLists())for(const l of s)delete this.usedCrossTileIDs[t][l]}removeStaleBuckets(t){let n=!1;for(const s in this.indexes){const l=this.indexes[s];for(const d in l)t[l[d].bucketInstanceId]||(this.removeBucketCrossTileIDs(s,l[d]),delete l[d],n=!0)}return n}}class zt{constructor(){this.layerIndexes={},this.crossTileIDs=new _a,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,n,s){let l=this.layerIndexes[t.id];l===void 0&&(l=this.layerIndexes[t.id]=new qn);let d=!1;const m={};l.handleWrapJump(s);for(const g of n){const y=g.getBucket(t);y&&t.id===y.layerIds[0]&&(y.bucketInstanceId||(y.bucketInstanceId=++this.maxBucketInstanceId),l.addBucket(g.tileID,y,this.crossTileIDs)&&(d=!0),m[y.bucketInstanceId]=!0)}return l.removeStaleBuckets(m)&&(d=!0),d}pruneUnusedLayers(t){const n={};t.forEach(s=>{n[s]=!0});for(const s in this.layerIndexes)n[s]||delete this.layerIndexes[s]}}const Kr=(o,t)=>h.emitValidationErrors(o,t&&t.filter(n=>n.identifier!=="source.canvas")),Fo=h.pick(lt,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setGlyphs","setSprite"]),Oo=h.pick(lt,["setCenter","setZoom","setBearing","setPitch"]),Uo=function(){const o={},t=h.spec.$version;for(const n in h.spec.$root){const s=h.spec.$root[n];if(s.required){let l=null;l=n==="version"?t:s.type==="array"?[]:{},l!=null&&(o[n]=l)}}return o}();class Ni extends h.Evented{constructor(t,n={}){super(),this.map=t,this.dispatcher=new Nr(gn(),this,t._getMapId()),this.imageManager=new He,this.imageManager.setEventedParent(this),this.glyphManager=new ar(t._requestManager,n.localIdeographFontFamily),this.lineAtlas=new $n(256,512),this.crossTileSymbolIndex=new zt,this._spritesImagesIds={},this._layers={},this._serializedLayers={},this._order=[],this.sourceCaches={},this.zoomHistory=new h.ZoomHistory,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("setReferrer",h.getReferrer());const s=this;this._rtlTextPluginCallback=Ni.registerForPluginStateChange(l=>{s.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:l.pluginStatus,pluginURL:l.pluginURL},(d,m)=>{if(h.triggerPluginCompletionEvent(d),m&&m.every(g=>g))for(const g in s.sourceCaches)s.sourceCaches[g].reload()})}),this.on("data",l=>{if(l.dataType!=="source"||l.sourceDataType!=="metadata")return;const d=this.sourceCaches[l.sourceId];if(!d)return;const m=d.getSource();if(m&&m.vectorLayerIds)for(const g in this._layers){const y=this._layers[g];y.source===m.id&&this._validateLayer(y)}})}loadURL(t,n={},s){this.fire(new h.Event("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const l=this.map._requestManager.transformRequest(t,dt.Style);this._request=h.getJSON(l,(d,m)=>{this._request=null,d?this.fire(new h.ErrorEvent(d)):m&&this._load(m,n,s)})}loadJSON(t,n={},s){this.fire(new h.Event("dataloading",{dataType:"style"})),this._request=h.exported.frame(()=>{this._request=null,n.validate=n.validate!==!1,this._load(t,n,s)})}loadEmpty(){this.fire(new h.Event("dataloading",{dataType:"style"})),this._load(Uo,{validate:!1})}_load(t,n,s){const l=n.transformStyle?n.transformStyle(s,t):t;if(n.validate&&Kr(this,h.validateStyle(l)))return;this._loaded=!0,this.stylesheet=l;for(const m in l.sources)this.addSource(m,l.sources[m],{validate:!1});l.sprite?this._loadSprite(l.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(l.glyphs);const d=_n(this.stylesheet.layers);this._order=d.map(m=>m.id),this._layers={},this._serializedLayers={};for(let m of d)m=h.createStyleLayer(m),m.setEventedParent(this,{layer:{id:m.id}}),this._layers[m.id]=m,this._serializedLayers[m.id]=m.serialize();this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new Vr(this.stylesheet.light),this.map.setTerrain(this.stylesheet.terrain),this.fire(new h.Event("data",{dataType:"style"})),this.fire(new h.Event("style.load"))}_loadSprite(t,n=!1,s){this.imageManager.setLoaded(!1),this._spriteRequest=function(l,d,m,g){const y=nr(l),x=m>1?"@2x":"";let S;const T=[],M=[],F={},O={};for(const{id:G,url:Y}of y){const H=T.push(h.getJSON(d.transformRequest(d.normalizeSpriteURL(Y,x,".json"),dt.SpriteJSON),(te,ae)=>{T.splice(H,1),S||(S=te,F[G]=ae,D())})),V=M.push(Qt.getImage(d.transformRequest(d.normalizeSpriteURL(Y,x,".png"),dt.SpriteImage),(te,ae)=>{M.splice(V,1),S||(S=te,O[G]=ae,D())}))}function D(){const G=Object.values(F).length,Y=Object.values(O).length;if(S)g(S);else if(y.length===G&&G===Y){const H={};for(const V in F){H[V]={};const te=h.exported.getImageCanvasContext(O[V]),ae=F[V];for(const se in ae){const{width:ue,height:me,x:xe,y:_e,sdf:we,pixelRatio:ze,stretchX:We,stretchY:Ke,content:Le}=ae[se];H[V][se]={data:null,pixelRatio:ze,sdf:we,stretchX:We,stretchY:Ke,content:Le,spriteData:{width:ue,height:me,x:xe,y:_e,context:te}}}}g(null,H)}}return{cancel(){if(T.length)for(const G of T)G.cancel(),T.splice(T.indexOf(G),1);if(M.length)for(const G of M)G.cancel(),M.splice(M.indexOf(G),1)}}}(t,this.map._requestManager,this.map.getPixelRatio(),(l,d)=>{if(this._spriteRequest=null,l)this.fire(new h.ErrorEvent(l));else if(d)for(const m in d){this._spritesImagesIds[m]=[];const g=this._spritesImagesIds[m]?this._spritesImagesIds[m].filter(y=>!(y in d)):[];for(const y of g)this.imageManager.removeImage(y),this._changedImages[y]=!0;for(const y in d[m]){const x=m==="default"?y:`${m}:${y}`;this._spritesImagesIds[m].push(x),x in this.imageManager.images?this.imageManager.updateImage(x,d[m][y],!1):this.imageManager.addImage(x,d[m][y]),n&&(this._changedImages[x]=!0)}}this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new h.Event("data",{dataType:"style"})),s&&s(l)})}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new h.Event("data",{dataType:"style"}))}_validateLayer(t){const n=this.sourceCaches[t.source];if(!n)return;const s=t.sourceLayer;if(!s)return;const l=n.getSource();(l.type==="geojson"||l.vectorLayerIds&&l.vectorLayerIds.indexOf(s)===-1)&&this.fire(new h.ErrorEvent(new Error(`Source layer "${s}" does not exist on source "${l.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(t){const n=[];for(const s of t){const l=this._layers[s];l.type!=="custom"&&n.push(l.serialize())}return n}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;for(const t in this.sourceCaches)if(this.sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const n=this._changed;if(this._changed){const l=Object.keys(this._updatedLayers),d=Object.keys(this._removedLayers);(l.length||d.length)&&this._updateWorkerLayers(l,d);for(const m in this._updatedSources){const g=this._updatedSources[m];if(g==="reload")this._reloadSource(m);else{if(g!=="clear")throw new Error(`Invalid action ${g}`);this._clearSource(m)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const m in this._updatedPaintProps)this._layers[m].updateTransitions(t);this.light.updateTransitions(t),this._resetUpdates()}const s={};for(const l in this.sourceCaches){const d=this.sourceCaches[l];s[l]=d.used,d.used=!1}for(const l of this._order){const d=this._layers[l];d.recalculate(t,this._availableImages),!d.isHidden(t.zoom)&&d.source&&(this.sourceCaches[d.source].used=!0)}for(const l in s){const d=this.sourceCaches[l];s[l]!==d.used&&d.fire(new h.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:l}))}this.light.recalculate(t),this.z=t.zoom,n&&this.fire(new h.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const n in this.sourceCaches)this.sourceCaches[n].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,n){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(t),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,n={}){if(this._checkLoaded(),t=n.transformStyle?n.transformStyle(this.serialize(),t):t,Kr(this,h.validateStyle(t)))return!1;(t=h.clone$1(t)).layers=_n(t.layers);const s=function(d,m){if(!d)return[{command:lt.setStyle,args:[m]}];let g=[];try{if(!pe(d.version,m.version))return[{command:lt.setStyle,args:[m]}];pe(d.center,m.center)||g.push({command:lt.setCenter,args:[m.center]}),pe(d.zoom,m.zoom)||g.push({command:lt.setZoom,args:[m.zoom]}),pe(d.bearing,m.bearing)||g.push({command:lt.setBearing,args:[m.bearing]}),pe(d.pitch,m.pitch)||g.push({command:lt.setPitch,args:[m.pitch]}),pe(d.sprite,m.sprite)||g.push({command:lt.setSprite,args:[m.sprite]}),pe(d.glyphs,m.glyphs)||g.push({command:lt.setGlyphs,args:[m.glyphs]}),pe(d.transition,m.transition)||g.push({command:lt.setTransition,args:[m.transition]}),pe(d.light,m.light)||g.push({command:lt.setLight,args:[m.light]});const y={},x=[];(function(T,M,F,O){let D;for(D in M=M||{},T=T||{})Object.prototype.hasOwnProperty.call(T,D)&&(Object.prototype.hasOwnProperty.call(M,D)||yn(D,F,O));for(D in M)Object.prototype.hasOwnProperty.call(M,D)&&(Object.prototype.hasOwnProperty.call(T,D)?pe(T[D],M[D])||(T[D].type==="geojson"&&M[D].type==="geojson"&&jn(T,M,D)?F.push({command:lt.setGeoJSONSourceData,args:[D,M[D].data]}):Xr(D,M,F,O)):Cr(D,M,F))})(d.sources,m.sources,x,y);const S=[];d.layers&&d.layers.forEach(T=>{y[T.source]?g.push({command:lt.removeLayer,args:[T.id]}):S.push(T)}),g=g.concat(x),function(T,M,F){M=M||[];const O=(T=T||[]).map(Mr),D=M.map(Mr),G=T.reduce(ut,{}),Y=M.reduce(ut,{}),H=O.slice(),V=Object.create(null);let te,ae,se,ue,me,xe,_e;for(te=0,ae=0;te<O.length;te++)se=O[te],Object.prototype.hasOwnProperty.call(Y,se)?ae++:(F.push({command:lt.removeLayer,args:[se]}),H.splice(H.indexOf(se,ae),1));for(te=0,ae=0;te<D.length;te++)se=D[D.length-1-te],H[H.length-1-te]!==se&&(Object.prototype.hasOwnProperty.call(G,se)?(F.push({command:lt.removeLayer,args:[se]}),H.splice(H.lastIndexOf(se,H.length-ae),1)):ae++,xe=H[H.length-te],F.push({command:lt.addLayer,args:[Y[se],xe]}),H.splice(H.length-te,0,se),V[se]=!0);for(te=0;te<D.length;te++)if(se=D[te],ue=G[se],me=Y[se],!V[se]&&!pe(ue,me))if(pe(ue.source,me.source)&&pe(ue["source-layer"],me["source-layer"])&&pe(ue.type,me.type)){for(_e in _r(ue.layout,me.layout,F,se,null,lt.setLayoutProperty),_r(ue.paint,me.paint,F,se,null,lt.setPaintProperty),pe(ue.filter,me.filter)||F.push({command:lt.setFilter,args:[se,me.filter]}),pe(ue.minzoom,me.minzoom)&&pe(ue.maxzoom,me.maxzoom)||F.push({command:lt.setLayerZoomRange,args:[se,me.minzoom,me.maxzoom]}),ue)Object.prototype.hasOwnProperty.call(ue,_e)&&_e!=="layout"&&_e!=="paint"&&_e!=="filter"&&_e!=="metadata"&&_e!=="minzoom"&&_e!=="maxzoom"&&(_e.indexOf("paint.")===0?_r(ue[_e],me[_e],F,se,_e.slice(6),lt.setPaintProperty):pe(ue[_e],me[_e])||F.push({command:lt.setLayerProperty,args:[se,_e,me[_e]]}));for(_e in me)Object.prototype.hasOwnProperty.call(me,_e)&&!Object.prototype.hasOwnProperty.call(ue,_e)&&_e!=="layout"&&_e!=="paint"&&_e!=="filter"&&_e!=="metadata"&&_e!=="minzoom"&&_e!=="maxzoom"&&(_e.indexOf("paint.")===0?_r(ue[_e],me[_e],F,se,_e.slice(6),lt.setPaintProperty):pe(ue[_e],me[_e])||F.push({command:lt.setLayerProperty,args:[se,_e,me[_e]]}))}else F.push({command:lt.removeLayer,args:[se]}),xe=H[H.lastIndexOf(se)+1],F.push({command:lt.addLayer,args:[me,xe]})}(S,m.layers,g)}catch(y){console.warn("Unable to compute style diff:",y),g=[{command:lt.setStyle,args:[m]}]}return g}(this.serialize(),t).filter(d=>!(d.command in Oo));if(s.length===0)return!1;const l=s.filter(d=>!(d.command in Fo));if(l.length>0)throw new Error(`Unimplemented: ${l.map(d=>d.command).join(", ")}.`);return s.forEach(d=>{d.command!=="setTransition"&&this[d.command].apply(this,d.args)}),this.stylesheet=t,!0}addImage(t,n){if(this.getImage(t))return this.fire(new h.ErrorEvent(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,n),this._afterImageUpdated(t)}updateImage(t,n){this.imageManager.updateImage(t,n)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new h.ErrorEvent(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new h.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,n,s={}){if(this._checkLoaded(),this.sourceCaches[t]!==void 0)throw new Error(`Source "${t}" already exists.`);if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(h.validateStyle.source,`sources.${t}`,n,null,s))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const l=this.sourceCaches[t]=new Xe(t,n,this.dispatcher);l.style=this,l.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:l.serialize(),sourceId:t})),l.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),this.sourceCaches[t]===void 0)throw new Error("There is no source with this ID");for(const s in this._layers)if(this._layers[s].source===t)return this.fire(new h.ErrorEvent(new Error(`Source "${t}" cannot be removed while layer "${s}" is using it.`)));const n=this.sourceCaches[t];delete this.sourceCaches[t],delete this._updatedSources[t],n.fire(new h.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,n){if(this._checkLoaded(),this.sourceCaches[t]===void 0)throw new Error(`There is no source with this ID=${t}`);const s=this.sourceCaches[t].getSource();if(s.type!=="geojson")throw new Error(`geojsonSource.type is ${s.type}, which is !== 'geojson`);s.setData(n),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(t,n,s={}){this._checkLoaded();const l=t.id;if(this.getLayer(l))return void this.fire(new h.ErrorEvent(new Error(`Layer "${l}" already exists on this map.`)));let d;if(t.type==="custom"){if(Kr(this,h.validateCustomStyleLayer(t)))return;d=h.createStyleLayer(t)}else{if(typeof t.source=="object"&&(this.addSource(l,t.source),t=h.clone$1(t),t=h.extend(t,{source:l})),this._validate(h.validateStyle.layer,`layers.${l}`,t,{arrayIndex:-1},s))return;d=h.createStyleLayer(t),this._validateLayer(d),d.setEventedParent(this,{layer:{id:l}}),this._serializedLayers[d.id]=d.serialize()}const m=n?this._order.indexOf(n):this._order.length;if(n&&m===-1)this.fire(new h.ErrorEvent(new Error(`Cannot add layer "${l}" before non-existing layer "${n}".`)));else{if(this._order.splice(m,0,l),this._layerOrderChanged=!0,this._layers[l]=d,this._removedLayers[l]&&d.source&&d.type!=="custom"){const g=this._removedLayers[l];delete this._removedLayers[l],g.type!==d.type?this._updatedSources[d.source]="clear":(this._updatedSources[d.source]="reload",this.sourceCaches[d.source].pause())}this._updateLayer(d),d.onAdd&&d.onAdd(this.map)}}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new h.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===n)return;const s=this._order.indexOf(t);this._order.splice(s,1);const l=n?this._order.indexOf(n):this._order.length;n&&l===-1?this.fire(new h.ErrorEvent(new Error(`Cannot move layer "${t}" before non-existing layer "${n}".`))):(this._order.splice(l,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const n=this._layers[t];if(!n)return void this.fire(new h.ErrorEvent(new Error(`Cannot remove non-existing layer "${t}".`)));n.setEventedParent(null);const s=this._order.indexOf(t);this._order.splice(s,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map)}getLayer(t){return this._layers[t]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,n,s){this._checkLoaded();const l=this.getLayer(t);l?l.minzoom===n&&l.maxzoom===s||(n!=null&&(l.minzoom=n),s!=null&&(l.maxzoom=s),this._updateLayer(l)):this.fire(new h.ErrorEvent(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,n,s={}){this._checkLoaded();const l=this.getLayer(t);if(l){if(!pe(l.filter,n))return n==null?(l.filter=void 0,void this._updateLayer(l)):void(this._validate(h.validateStyle.filter,`layers.${l.id}.filter`,n,null,s)||(l.filter=h.clone$1(n),this._updateLayer(l)))}else this.fire(new h.ErrorEvent(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return h.clone$1(this.getLayer(t).filter)}setLayoutProperty(t,n,s,l={}){this._checkLoaded();const d=this.getLayer(t);d?pe(d.getLayoutProperty(n),s)||(d.setLayoutProperty(n,s,l),this._updateLayer(d)):this.fire(new h.ErrorEvent(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,n){const s=this.getLayer(t);if(s)return s.getLayoutProperty(n);this.fire(new h.ErrorEvent(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,n,s,l={}){this._checkLoaded();const d=this.getLayer(t);d?pe(d.getPaintProperty(n),s)||(d.setPaintProperty(n,s,l)&&this._updateLayer(d),this._changed=!0,this._updatedPaintProps[t]=!0):this.fire(new h.ErrorEvent(new Error(`Cannot style non-existing layer "${t}".`)))}getPaintProperty(t,n){return this.getLayer(t).getPaintProperty(n)}setFeatureState(t,n){this._checkLoaded();const s=t.source,l=t.sourceLayer,d=this.sourceCaches[s];if(d===void 0)return void this.fire(new h.ErrorEvent(new Error(`The source '${s}' does not exist in the map's style.`)));const m=d.getSource().type;m==="geojson"&&l?this.fire(new h.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):m!=="vector"||l?(t.id===void 0&&this.fire(new h.ErrorEvent(new Error("The feature id parameter must be provided."))),d.setFeatureState(l,t.id,n)):this.fire(new h.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,n){this._checkLoaded();const s=t.source,l=this.sourceCaches[s];if(l===void 0)return void this.fire(new h.ErrorEvent(new Error(`The source '${s}' does not exist in the map's style.`)));const d=l.getSource().type,m=d==="vector"?t.sourceLayer:void 0;d!=="vector"||m?n&&typeof t.id!="string"&&typeof t.id!="number"?this.fire(new h.ErrorEvent(new Error("A feature id is required to remove its specific state property."))):l.removeFeatureState(m,t.id,n):this.fire(new h.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const n=t.source,s=t.sourceLayer,l=this.sourceCaches[n];if(l!==void 0)return l.getSource().type!=="vector"||s?(t.id===void 0&&this.fire(new h.ErrorEvent(new Error("The feature id parameter must be provided."))),l.getFeatureState(s,t.id)):void this.fire(new h.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new h.ErrorEvent(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return h.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){return h.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,sources:h.mapObject(this.sourceCaches,t=>t.serialize()),layers:this._serializeLayers(this._order)},t=>t!==void 0)}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&this.sourceCaches[t.source].getSource().type!=="raster"&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._changed=!0}_flattenAndSortRenderedFeatures(t){const n=m=>this._layers[m].type==="fill-extrusion",s={},l=[];for(let m=this._order.length-1;m>=0;m--){const g=this._order[m];if(n(g)){s[g]=m;for(const y of t){const x=y[g];if(x)for(const S of x)l.push(S)}}}l.sort((m,g)=>g.intersectionZ-m.intersectionZ);const d=[];for(let m=this._order.length-1;m>=0;m--){const g=this._order[m];if(n(g))for(let y=l.length-1;y>=0;y--){const x=l[y].feature;if(s[x.layer.id]<m)break;d.push(x),l.pop()}else for(const y of t){const x=y[g];if(x)for(const S of x)d.push(S.feature)}}return d}queryRenderedFeatures(t,n,s){n&&n.filter&&this._validate(h.validateStyle.filter,"queryRenderedFeatures.filter",n.filter,null,n);const l={};if(n&&n.layers){if(!Array.isArray(n.layers))return this.fire(new h.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const m of n.layers){const g=this._layers[m];if(!g)return this.fire(new h.ErrorEvent(new Error(`The layer '${m}' does not exist in the map's style and cannot be queried for features.`))),[];l[g.source]=!0}}const d=[];n.availableImages=this._availableImages;for(const m in this.sourceCaches)n.layers&&!l[m]||d.push(Ee(this.sourceCaches[m],this._layers,this._serializedLayers,t,n,s));return this.placement&&d.push(function(m,g,y,x,S,T,M){const F={},O=T.queryRenderedSymbols(x),D=[];for(const G of Object.keys(O).map(Number))D.push(M[G]);D.sort(Qe);for(const G of D){const Y=G.featureIndex.lookupSymbolFeatures(O[G.bucketInstanceId],g,G.bucketIndex,G.sourceLayerIndex,S.filter,S.layers,S.availableImages,m);for(const H in Y){const V=F[H]=F[H]||[],te=Y[H];te.sort((ae,se)=>{const ue=G.featureSortOrder;if(ue){const me=ue.indexOf(ae.featureIndex);return ue.indexOf(se.featureIndex)-me}return se.featureIndex-ae.featureIndex});for(const ae of te)V.push(ae)}}for(const G in F)F[G].forEach(Y=>{const H=Y.feature,V=y[m[G].source].getFeatureState(H.layer["source-layer"],H.id);H.source=H.layer.source,H.layer["source-layer"]&&(H.sourceLayer=H.layer["source-layer"]),H.state=V});return F}(this._layers,this._serializedLayers,this.sourceCaches,t,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(d)}querySourceFeatures(t,n){n&&n.filter&&this._validate(h.validateStyle.filter,"querySourceFeatures.filter",n.filter,null,n);const s=this.sourceCaches[t];return s?function(l,d){const m=l.getRenderableIds().map(x=>l.getTileByID(x)),g=[],y={};for(let x=0;x<m.length;x++){const S=m[x],T=S.tileID.canonical.key;y[T]||(y[T]=!0,S.querySourceFeatures(g,d))}return g}(s,n):[]}addSourceType(t,n,s){return Ni.getSourceType(t)?s(new Error(`A source type called "${t}" already exists.`)):(Ni.setSourceType(t,n),n.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:n.workerSourceURL},s):s(null,null))}getLight(){return this.light.getLight()}setLight(t,n={}){this._checkLoaded();const s=this.light.getLight();let l=!1;for(const m in t)if(!pe(t[m],s[m])){l=!0;break}if(!l)return;const d={now:h.exported.now(),transition:h.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,n),this.light.updateTransitions(d)}_validate(t,n,s,l,d={}){return(!d||d.validate!==!1)&&Kr(this,t.call(h.validateStyle,h.extend({key:n,style:this.serialize(),value:s,styleSpec:h.spec},l)))}_remove(t=!0){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),h.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const n in this._layers)this._layers[n].setEventedParent(null);for(const n in this.sourceCaches){const s=this.sourceCaches[n];s.setEventedParent(null),s.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove(t)}_clearSource(t){this.sourceCaches[t].clearTiles()}_reloadSource(t){this.sourceCaches[t].resume(),this.sourceCaches[t].reload()}_updateSources(t){for(const n in this.sourceCaches)this.sourceCaches[n].update(t,this.map.terrain)}_generateCollisionBoxes(){for(const t in this.sourceCaches)this._reloadSource(t)}_updatePlacement(t,n,s,l,d=!1){let m=!1,g=!1;const y={};for(const x of this._order){const S=this._layers[x];if(S.type!=="symbol")continue;if(!y[S.source]){const M=this.sourceCaches[S.source];y[S.source]=M.getRenderableIds(!0).map(F=>M.getTileByID(F)).sort((F,O)=>O.tileID.overscaledZ-F.tileID.overscaledZ||(F.tileID.isLessThan(O.tileID)?-1:1))}const T=this.crossTileSymbolIndex.addLayer(S,y[S.source],t.center.lng);m=m||T}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((d=d||this._layerOrderChanged||s===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(h.exported.now(),t.zoom))&&(this.pauseablePlacement=new ds(t,this.map.terrain,this._order,d,n,s,l,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(h.exported.now()),g=!0),m&&this.pauseablePlacement.placement.setStale()),g||m)for(const x of this._order){const S=this._layers[x];S.type==="symbol"&&this.placement.updateLayerOpacities(S,y[S.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(h.exported.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,n,s){this.imageManager.getImages(n.icons,s),this._updateTilesForChangedImages();const l=this.sourceCaches[n.source];l&&l.setDependencies(n.tileID.key,n.type,n.icons)}getGlyphs(t,n,s){this.glyphManager.getGlyphs(n.stacks,s);const l=this.sourceCaches[n.source];l&&l.setDependencies(n.tileID.key,n.type,[""])}getResource(t,n,s){return h.makeRequest(n,s)}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,n={}){this._checkLoaded(),t&&this._validate(h.validateStyle.glyphs,"glyphs",t,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}addSprite(t,n,s={},l){this._checkLoaded();const d=[{id:t,url:n}],m=[...nr(this.stylesheet.sprite),...d];this._validate(h.validateStyle.sprite,"sprite",m,null,s)||(this.stylesheet.sprite=m,this._loadSprite(d,!0,l))}removeSprite(t){this._checkLoaded();const n=nr(this.stylesheet.sprite);if(n.find(s=>s.id===t)){if(this._spritesImagesIds[t])for(const s of this._spritesImagesIds[t])this.imageManager.removeImage(s),this._changedImages[s]=!0;n.splice(n.findIndex(s=>s.id===t),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new h.Event("data",{dataType:"style"}))}else this.fire(new h.ErrorEvent(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return nr(this.stylesheet.sprite)}setSprite(t,n={},s){this._checkLoaded(),t&&this._validate(h.validateStyle.sprite,"sprite",t,null,n)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,s):(this._unloadSprite(),s(null)))}}Ni.getSourceType=function(o){return jr[o]},Ni.setSourceType=function(o,t){jr[o]=t},Ni.registerForPluginStateChange=h.registerForPluginStateChange;var ya=h.createLayout([{name:"a_pos",type:"Int16",components:2}]),ms="attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_depth;void main() {float extent=8192.0;float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/extent;gl_Position=u_matrix*vec4(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}";const Zn={prelude:xt(`#ifdef GL_ES
3
3
  precision mediump float;
4
4
  #else
5
5
  #if !defined(lowp)
@@ -573,7 +573,7 @@ uniform ${S} ${T} u_${M};
573
573
  #endif
574
574
  `}),staticAttributes:s,staticUniforms:m}}class fs{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,n,s,l,d,m,g,y,x){this.context=t;let S=this.boundPaintVertexBuffers.length!==l.length;for(let T=0;!S&&T<l.length;T++)this.boundPaintVertexBuffers[T]!==l[T]&&(S=!0);t.extVertexArrayObject&&this.vao&&this.boundProgram===n&&this.boundLayoutVertexBuffer===s&&!S&&this.boundIndexBuffer===d&&this.boundVertexOffset===m&&this.boundDynamicVertexBuffer===g&&this.boundDynamicVertexBuffer2===y&&this.boundDynamicVertexBuffer3===x?(t.bindVertexArrayOES.set(this.vao),g&&g.bind(),d&&d.dynamicDraw&&d.bind(),y&&y.bind(),x&&x.bind()):this.freshBind(n,s,l,d,m,g,y,x)}freshBind(t,n,s,l,d,m,g,y){let x;const S=t.numAttributes,T=this.context,M=T.gl;if(T.extVertexArrayObject)this.vao&&this.destroy(),this.vao=T.extVertexArrayObject.createVertexArrayOES(),T.bindVertexArrayOES.set(this.vao),x=0,this.boundProgram=t,this.boundLayoutVertexBuffer=n,this.boundPaintVertexBuffers=s,this.boundIndexBuffer=l,this.boundVertexOffset=d,this.boundDynamicVertexBuffer=m,this.boundDynamicVertexBuffer2=g,this.boundDynamicVertexBuffer3=y;else{x=T.currentNumAttributes||0;for(let F=S;F<x;F++)M.disableVertexAttribArray(F)}n.enableAttributes(M,t);for(const F of s)F.enableAttributes(M,t);m&&m.enableAttributes(M,t),g&&g.enableAttributes(M,t),y&&y.enableAttributes(M,t),n.bind(),n.setVertexAttribPointers(M,t,d);for(const F of s)F.bind(),F.setVertexAttribPointers(M,t,d);m&&(m.bind(),m.setVertexAttribPointers(M,t,d)),l&&l.bind(),g&&(g.bind(),g.setVertexAttribPointers(M,t,d)),y&&(y.bind(),y.setVertexAttribPointers(M,t,d)),T.currentNumAttributes=S}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function Xn(o){const t=[];for(let n=0;n<o.length;n++){if(o[n]===null)continue;const s=o[n].split(" ");t.push(s.pop())}return t}class gs{constructor(t,n,s,l,d,m,g){const y=t.gl;this.program=y.createProgram();const x=Xn(s.staticAttributes),S=l?l.getBinderAttributes():[],T=x.concat(S),M=Zn.prelude.staticUniforms?Xn(Zn.prelude.staticUniforms):[],F=s.staticUniforms?Xn(s.staticUniforms):[],O=l?l.getBinderUniforms():[],D=M.concat(F).concat(O),G=[];for(const ue of D)G.indexOf(ue)<0&&G.push(ue);const Y=l?l.defines():[];m&&Y.push("#define OVERDRAW_INSPECTOR;"),g&&Y.push("#define TERRAIN3D;");const H=Y.concat(Zn.prelude.fragmentSource,s.fragmentSource).join(`
575
575
  `),V=Y.concat(Zn.prelude.vertexSource,s.vertexSource).join(`
576
- `),te=y.createShader(y.FRAGMENT_SHADER);if(y.isContextLost())return void(this.failedToCreate=!0);y.shaderSource(te,H),y.compileShader(te),y.attachShader(this.program,te);const ae=y.createShader(y.VERTEX_SHADER);if(y.isContextLost())return void(this.failedToCreate=!0);y.shaderSource(ae,V),y.compileShader(ae),y.attachShader(this.program,ae),this.attributes={};const se={};this.numAttributes=T.length;for(let ue=0;ue<this.numAttributes;ue++)T[ue]&&(y.bindAttribLocation(this.program,ue,T[ue]),this.attributes[T[ue]]=ue);y.linkProgram(this.program),y.deleteShader(ae),y.deleteShader(te);for(let ue=0;ue<G.length;ue++){const me=G[ue];if(me&&!se[me]){const xe=y.getUniformLocation(this.program,me);xe&&(se[me]=xe)}}this.fixedUniforms=d(t,se),this.terrainUniforms=((ue,me)=>({u_depth:new h.Uniform1i(ue,me.u_depth),u_terrain:new h.Uniform1i(ue,me.u_terrain),u_terrain_dim:new h.Uniform1f(ue,me.u_terrain_dim),u_terrain_matrix:new h.UniformMatrix4f(ue,me.u_terrain_matrix),u_terrain_unpack:new h.Uniform4f(ue,me.u_terrain_unpack),u_terrain_exaggeration:new h.Uniform1f(ue,me.u_terrain_exaggeration)}))(t,se),this.binderUniforms=l?l.getUniforms(t,se):[]}draw(t,n,s,l,d,m,g,y,x,S,T,M,F,O,D,G,Y,H){const V=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(s),t.setStencilMode(l),t.setColorMode(d),t.setCullFace(m),y){t.activeTexture.set(V.TEXTURE2),V.bindTexture(V.TEXTURE_2D,y.depthTexture),t.activeTexture.set(V.TEXTURE3),V.bindTexture(V.TEXTURE_2D,y.texture);for(const ae in this.terrainUniforms)this.terrainUniforms[ae].set(y[ae])}for(const ae in this.fixedUniforms)this.fixedUniforms[ae].set(g[ae]);D&&D.setUniforms(t,this.binderUniforms,F,{zoom:O});let te=0;switch(n){case V.LINES:te=2;break;case V.TRIANGLES:te=3;break;case V.LINE_STRIP:te=1}for(const ae of M.get()){const se=ae.vaos||(ae.vaos={});(se[x]||(se[x]=new fs)).bind(t,this,S,D?D.getPaintVertexBuffers():[],T,ae.vertexOffset,G,Y,H),V.drawElements(n,ae.primitiveLength*te,V.UNSIGNED_SHORT,ae.primitiveOffset*te*2)}}}function _s(o,t,n){const s=1/ce(n,1,t.transform.tileZoom),l=Math.pow(2,n.tileID.overscaledZ),d=n.tileSize*Math.pow(2,t.transform.tileZoom)/l,m=d*(n.tileID.canonical.x+n.tileID.wrap*l),g=d*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[s,o.fromScale,o.toScale],u_fade:o.t,u_pixel_coord_upper:[m>>16,g>>16],u_pixel_coord_lower:[65535&m,65535&g]}}const ys=(o,t,n,s)=>{const l=t.style.light,d=l.properties.get("position"),m=[d.x,d.y,d.z],g=function(){var x=new h.ARRAY_TYPE(9);return h.ARRAY_TYPE!=Float32Array&&(x[1]=0,x[2]=0,x[3]=0,x[5]=0,x[6]=0,x[7]=0),x[0]=1,x[4]=1,x[8]=1,x}();l.properties.get("anchor")==="viewport"&&function(x,S){var T=Math.sin(S),M=Math.cos(S);x[0]=M,x[1]=T,x[2]=0,x[3]=-T,x[4]=M,x[5]=0,x[6]=0,x[7]=0,x[8]=1}(g,-t.transform.angle),function(x,S,T){var M=S[0],F=S[1],O=S[2];x[0]=M*T[0]+F*T[3]+O*T[6],x[1]=M*T[1]+F*T[4]+O*T[7],x[2]=M*T[2]+F*T[5]+O*T[8]}(m,m,g);const y=l.properties.get("color");return{u_matrix:o,u_lightpos:m,u_lightintensity:l.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_vertical_gradient:+n,u_opacity:s}},Kl=(o,t,n,s,l,d,m)=>h.extend(ys(o,t,n,s),_s(d,t,m),{u_height_factor:-Math.pow(2,l.overscaledZ)/m.tileSize/8}),wn=o=>({u_matrix:o}),Tn=(o,t,n,s)=>h.extend(wn(o),_s(n,t,s)),Vo=(o,t)=>({u_matrix:o,u_world:t}),Pi=(o,t,n,s,l)=>h.extend(Tn(o,t,n,s),{u_world:l}),xs=(o,t,n,s)=>{const l=o.transform;let d,m;if(s.paint.get("circle-pitch-alignment")==="map"){const g=ce(n,1,l.zoom);d=!0,m=[g,g]}else d=!1,m=l.pixelsToGLUnits;return{u_camera_to_center_distance:l.cameraToCenterDistance,u_scale_with_map:+(s.paint.get("circle-pitch-scale")==="map"),u_matrix:o.translatePosMatrix(t.posMatrix,n,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_pitch_with_map:+d,u_device_pixel_ratio:o.pixelRatio,u_extrude_scale:m}},xa=(o,t,n)=>{const s=ce(n,1,t.zoom),l=Math.pow(2,t.zoom-n.tileID.overscaledZ),d=n.tileID.overscaleFactor();return{u_matrix:o,u_camera_to_center_distance:t.cameraToCenterDistance,u_pixels_to_tile_units:s,u_extrude_scale:[t.pixelsToGLUnits[0]/(s*l),t.pixelsToGLUnits[1]/(s*l)],u_overscale_factor:d}},Wn=(o,t,n=1)=>({u_matrix:o,u_color:t,u_overlay:0,u_overlay_scale:n}),va=o=>({u_matrix:o}),vs=(o,t,n,s)=>({u_matrix:o,u_extrude_scale:ce(t,1,n),u_intensity:s});function ba(o,t){const n=Math.pow(2,t.canonical.z),s=t.canonical.y;return[new h.MercatorCoordinate(0,s/n).toLngLat().lat,new h.MercatorCoordinate(0,(s+1)/n).toLngLat().lat]}const Hn=(o,t,n,s)=>{const l=o.transform;return{u_matrix:Yr(o,t,n,s),u_ratio:1/ce(t,1,l.zoom),u_device_pixel_ratio:o.pixelRatio,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]]}},bs=(o,t,n,s,l)=>h.extend(Hn(o,t,n,l),{u_image:0,u_image_height:s}),wa=(o,t,n,s,l)=>{const d=o.transform,m=ws(t,d);return{u_matrix:Yr(o,t,n,l),u_texsize:t.imageAtlasTexture.size,u_ratio:1/ce(t,1,d.zoom),u_device_pixel_ratio:o.pixelRatio,u_image:0,u_scale:[m,s.fromScale,s.toScale],u_fade:s.t,u_units_to_pixels:[1/d.pixelsToGLUnits[0],1/d.pixelsToGLUnits[1]]}},No=(o,t,n,s,l,d)=>{const m=o.lineAtlas,g=ws(t,o.transform),y=n.layout.get("line-cap")==="round",x=m.getDash(s.from,y),S=m.getDash(s.to,y),T=x.width*l.fromScale,M=S.width*l.toScale;return h.extend(Hn(o,t,n,d),{u_patternscale_a:[g/T,-x.height/2],u_patternscale_b:[g/M,-S.height/2],u_sdfgamma:m.width/(256*Math.min(T,M)*o.pixelRatio)/2,u_image:0,u_tex_y_a:x.y,u_tex_y_b:S.y,u_mix:l.t})};function ws(o,t){return 1/ce(o,1,t.tileZoom)}function Yr(o,t,n,s){return o.translatePosMatrix(s?s.posMatrix:t.tileID.posMatrix,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const Yl=(o,t,n,s,l)=>{return{u_matrix:o,u_tl_parent:t,u_scale_parent:n,u_buffer_scale:1,u_fade_t:s.mix,u_opacity:s.opacity*l.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:l.paint.get("raster-brightness-min"),u_brightness_high:l.paint.get("raster-brightness-max"),u_saturation_factor:(m=l.paint.get("raster-saturation"),m>0?1-1/(1.001-m):-m),u_contrast_factor:(d=l.paint.get("raster-contrast"),d>0?1/(1-d):1+d),u_spin_weights:Jl(l.paint.get("raster-hue-rotate"))};var d,m};function Jl(o){o*=Math.PI/180;const t=Math.sin(o),n=Math.cos(o);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const $o=(o,t,n,s,l,d,m,g,y,x)=>{const S=l.transform;return{u_is_size_zoom_constant:+(o==="constant"||o==="source"),u_is_size_feature_constant:+(o==="constant"||o==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:S.cameraToCenterDistance,u_pitch:S.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:S.width/S.height,u_fade_change:l.options.fadeDuration?l.symbolFadeChange:1,u_matrix:d,u_label_plane_matrix:m,u_coord_matrix:g,u_is_text:+y,u_pitch_with_map:+s,u_texsize:x,u_texture:0}},Go=(o,t,n,s,l,d,m,g,y,x,S)=>{const T=l.transform;return h.extend($o(o,t,n,s,l,d,m,g,y,x),{u_gamma_scale:s?Math.cos(T._pitch)*T.cameraToCenterDistance:1,u_device_pixel_ratio:l.pixelRatio,u_is_halo:+S})},Ql=(o,t,n,s,l,d,m,g,y,x)=>h.extend(Go(o,t,n,s,l,d,m,g,!0,y,!0),{u_texsize_icon:x,u_texture_icon:1}),ec=(o,t,n)=>({u_matrix:o,u_opacity:t,u_color:n}),Ts=(o,t,n,s,l,d)=>h.extend(function(m,g,y,x){const S=y.imageManager.getPattern(m.from.toString()),T=y.imageManager.getPattern(m.to.toString()),{width:M,height:F}=y.imageManager.getPixelSize(),O=Math.pow(2,x.tileID.overscaledZ),D=x.tileSize*Math.pow(2,y.transform.tileZoom)/O,G=D*(x.tileID.canonical.x+x.tileID.wrap*O),Y=D*x.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:S.tl,u_pattern_br_a:S.br,u_pattern_tl_b:T.tl,u_pattern_br_b:T.br,u_texsize:[M,F],u_mix:g.t,u_pattern_size_a:S.displaySize,u_pattern_size_b:T.displaySize,u_scale_a:g.fromScale,u_scale_b:g.toScale,u_tile_units_to_pixels:1/ce(x,1,y.transform.tileZoom),u_pixel_coord_upper:[G>>16,Y>>16],u_pixel_coord_lower:[65535&G,65535&Y]}}(s,d,n,l),{u_matrix:o,u_opacity:t}),Ta={fillExtrusion:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_lightpos:new h.Uniform3f(o,t.u_lightpos),u_lightintensity:new h.Uniform1f(o,t.u_lightintensity),u_lightcolor:new h.Uniform3f(o,t.u_lightcolor),u_vertical_gradient:new h.Uniform1f(o,t.u_vertical_gradient),u_opacity:new h.Uniform1f(o,t.u_opacity)}),fillExtrusionPattern:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_lightpos:new h.Uniform3f(o,t.u_lightpos),u_lightintensity:new h.Uniform1f(o,t.u_lightintensity),u_lightcolor:new h.Uniform3f(o,t.u_lightcolor),u_vertical_gradient:new h.Uniform1f(o,t.u_vertical_gradient),u_height_factor:new h.Uniform1f(o,t.u_height_factor),u_image:new h.Uniform1i(o,t.u_image),u_texsize:new h.Uniform2f(o,t.u_texsize),u_pixel_coord_upper:new h.Uniform2f(o,t.u_pixel_coord_upper),u_pixel_coord_lower:new h.Uniform2f(o,t.u_pixel_coord_lower),u_scale:new h.Uniform3f(o,t.u_scale),u_fade:new h.Uniform1f(o,t.u_fade),u_opacity:new h.Uniform1f(o,t.u_opacity)}),fill:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix)}),fillPattern:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_image:new h.Uniform1i(o,t.u_image),u_texsize:new h.Uniform2f(o,t.u_texsize),u_pixel_coord_upper:new h.Uniform2f(o,t.u_pixel_coord_upper),u_pixel_coord_lower:new h.Uniform2f(o,t.u_pixel_coord_lower),u_scale:new h.Uniform3f(o,t.u_scale),u_fade:new h.Uniform1f(o,t.u_fade)}),fillOutline:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_world:new h.Uniform2f(o,t.u_world)}),fillOutlinePattern:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_world:new h.Uniform2f(o,t.u_world),u_image:new h.Uniform1i(o,t.u_image),u_texsize:new h.Uniform2f(o,t.u_texsize),u_pixel_coord_upper:new h.Uniform2f(o,t.u_pixel_coord_upper),u_pixel_coord_lower:new h.Uniform2f(o,t.u_pixel_coord_lower),u_scale:new h.Uniform3f(o,t.u_scale),u_fade:new h.Uniform1f(o,t.u_fade)}),circle:(o,t)=>({u_camera_to_center_distance:new h.Uniform1f(o,t.u_camera_to_center_distance),u_scale_with_map:new h.Uniform1i(o,t.u_scale_with_map),u_pitch_with_map:new h.Uniform1i(o,t.u_pitch_with_map),u_extrude_scale:new h.Uniform2f(o,t.u_extrude_scale),u_device_pixel_ratio:new h.Uniform1f(o,t.u_device_pixel_ratio),u_matrix:new h.UniformMatrix4f(o,t.u_matrix)}),collisionBox:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_camera_to_center_distance:new h.Uniform1f(o,t.u_camera_to_center_distance),u_pixels_to_tile_units:new h.Uniform1f(o,t.u_pixels_to_tile_units),u_extrude_scale:new h.Uniform2f(o,t.u_extrude_scale),u_overscale_factor:new h.Uniform1f(o,t.u_overscale_factor)}),collisionCircle:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_inv_matrix:new h.UniformMatrix4f(o,t.u_inv_matrix),u_camera_to_center_distance:new h.Uniform1f(o,t.u_camera_to_center_distance),u_viewport_size:new h.Uniform2f(o,t.u_viewport_size)}),debug:(o,t)=>({u_color:new h.UniformColor(o,t.u_color),u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_overlay:new h.Uniform1i(o,t.u_overlay),u_overlay_scale:new h.Uniform1f(o,t.u_overlay_scale)}),clippingMask:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix)}),heatmap:(o,t)=>({u_extrude_scale:new h.Uniform1f(o,t.u_extrude_scale),u_intensity:new h.Uniform1f(o,t.u_intensity),u_matrix:new h.UniformMatrix4f(o,t.u_matrix)}),heatmapTexture:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_world:new h.Uniform2f(o,t.u_world),u_image:new h.Uniform1i(o,t.u_image),u_color_ramp:new h.Uniform1i(o,t.u_color_ramp),u_opacity:new h.Uniform1f(o,t.u_opacity)}),hillshade:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_image:new h.Uniform1i(o,t.u_image),u_latrange:new h.Uniform2f(o,t.u_latrange),u_light:new h.Uniform2f(o,t.u_light),u_shadow:new h.UniformColor(o,t.u_shadow),u_highlight:new h.UniformColor(o,t.u_highlight),u_accent:new h.UniformColor(o,t.u_accent)}),hillshadePrepare:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_image:new h.Uniform1i(o,t.u_image),u_dimension:new h.Uniform2f(o,t.u_dimension),u_zoom:new h.Uniform1f(o,t.u_zoom),u_unpack:new h.Uniform4f(o,t.u_unpack)}),line:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_ratio:new h.Uniform1f(o,t.u_ratio),u_device_pixel_ratio:new h.Uniform1f(o,t.u_device_pixel_ratio),u_units_to_pixels:new h.Uniform2f(o,t.u_units_to_pixels)}),lineGradient:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_ratio:new h.Uniform1f(o,t.u_ratio),u_device_pixel_ratio:new h.Uniform1f(o,t.u_device_pixel_ratio),u_units_to_pixels:new h.Uniform2f(o,t.u_units_to_pixels),u_image:new h.Uniform1i(o,t.u_image),u_image_height:new h.Uniform1f(o,t.u_image_height)}),linePattern:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_texsize:new h.Uniform2f(o,t.u_texsize),u_ratio:new h.Uniform1f(o,t.u_ratio),u_device_pixel_ratio:new h.Uniform1f(o,t.u_device_pixel_ratio),u_image:new h.Uniform1i(o,t.u_image),u_units_to_pixels:new h.Uniform2f(o,t.u_units_to_pixels),u_scale:new h.Uniform3f(o,t.u_scale),u_fade:new h.Uniform1f(o,t.u_fade)}),lineSDF:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_ratio:new h.Uniform1f(o,t.u_ratio),u_device_pixel_ratio:new h.Uniform1f(o,t.u_device_pixel_ratio),u_units_to_pixels:new h.Uniform2f(o,t.u_units_to_pixels),u_patternscale_a:new h.Uniform2f(o,t.u_patternscale_a),u_patternscale_b:new h.Uniform2f(o,t.u_patternscale_b),u_sdfgamma:new h.Uniform1f(o,t.u_sdfgamma),u_image:new h.Uniform1i(o,t.u_image),u_tex_y_a:new h.Uniform1f(o,t.u_tex_y_a),u_tex_y_b:new h.Uniform1f(o,t.u_tex_y_b),u_mix:new h.Uniform1f(o,t.u_mix)}),raster:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_tl_parent:new h.Uniform2f(o,t.u_tl_parent),u_scale_parent:new h.Uniform1f(o,t.u_scale_parent),u_buffer_scale:new h.Uniform1f(o,t.u_buffer_scale),u_fade_t:new h.Uniform1f(o,t.u_fade_t),u_opacity:new h.Uniform1f(o,t.u_opacity),u_image0:new h.Uniform1i(o,t.u_image0),u_image1:new h.Uniform1i(o,t.u_image1),u_brightness_low:new h.Uniform1f(o,t.u_brightness_low),u_brightness_high:new h.Uniform1f(o,t.u_brightness_high),u_saturation_factor:new h.Uniform1f(o,t.u_saturation_factor),u_contrast_factor:new h.Uniform1f(o,t.u_contrast_factor),u_spin_weights:new h.Uniform3f(o,t.u_spin_weights)}),symbolIcon:(o,t)=>({u_is_size_zoom_constant:new h.Uniform1i(o,t.u_is_size_zoom_constant),u_is_size_feature_constant:new h.Uniform1i(o,t.u_is_size_feature_constant),u_size_t:new h.Uniform1f(o,t.u_size_t),u_size:new h.Uniform1f(o,t.u_size),u_camera_to_center_distance:new h.Uniform1f(o,t.u_camera_to_center_distance),u_pitch:new h.Uniform1f(o,t.u_pitch),u_rotate_symbol:new h.Uniform1i(o,t.u_rotate_symbol),u_aspect_ratio:new h.Uniform1f(o,t.u_aspect_ratio),u_fade_change:new h.Uniform1f(o,t.u_fade_change),u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_label_plane_matrix:new h.UniformMatrix4f(o,t.u_label_plane_matrix),u_coord_matrix:new h.UniformMatrix4f(o,t.u_coord_matrix),u_is_text:new h.Uniform1i(o,t.u_is_text),u_pitch_with_map:new h.Uniform1i(o,t.u_pitch_with_map),u_texsize:new h.Uniform2f(o,t.u_texsize),u_texture:new h.Uniform1i(o,t.u_texture)}),symbolSDF:(o,t)=>({u_is_size_zoom_constant:new h.Uniform1i(o,t.u_is_size_zoom_constant),u_is_size_feature_constant:new h.Uniform1i(o,t.u_is_size_feature_constant),u_size_t:new h.Uniform1f(o,t.u_size_t),u_size:new h.Uniform1f(o,t.u_size),u_camera_to_center_distance:new h.Uniform1f(o,t.u_camera_to_center_distance),u_pitch:new h.Uniform1f(o,t.u_pitch),u_rotate_symbol:new h.Uniform1i(o,t.u_rotate_symbol),u_aspect_ratio:new h.Uniform1f(o,t.u_aspect_ratio),u_fade_change:new h.Uniform1f(o,t.u_fade_change),u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_label_plane_matrix:new h.UniformMatrix4f(o,t.u_label_plane_matrix),u_coord_matrix:new h.UniformMatrix4f(o,t.u_coord_matrix),u_is_text:new h.Uniform1i(o,t.u_is_text),u_pitch_with_map:new h.Uniform1i(o,t.u_pitch_with_map),u_texsize:new h.Uniform2f(o,t.u_texsize),u_texture:new h.Uniform1i(o,t.u_texture),u_gamma_scale:new h.Uniform1f(o,t.u_gamma_scale),u_device_pixel_ratio:new h.Uniform1f(o,t.u_device_pixel_ratio),u_is_halo:new h.Uniform1i(o,t.u_is_halo)}),symbolTextAndIcon:(o,t)=>({u_is_size_zoom_constant:new h.Uniform1i(o,t.u_is_size_zoom_constant),u_is_size_feature_constant:new h.Uniform1i(o,t.u_is_size_feature_constant),u_size_t:new h.Uniform1f(o,t.u_size_t),u_size:new h.Uniform1f(o,t.u_size),u_camera_to_center_distance:new h.Uniform1f(o,t.u_camera_to_center_distance),u_pitch:new h.Uniform1f(o,t.u_pitch),u_rotate_symbol:new h.Uniform1i(o,t.u_rotate_symbol),u_aspect_ratio:new h.Uniform1f(o,t.u_aspect_ratio),u_fade_change:new h.Uniform1f(o,t.u_fade_change),u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_label_plane_matrix:new h.UniformMatrix4f(o,t.u_label_plane_matrix),u_coord_matrix:new h.UniformMatrix4f(o,t.u_coord_matrix),u_is_text:new h.Uniform1i(o,t.u_is_text),u_pitch_with_map:new h.Uniform1i(o,t.u_pitch_with_map),u_texsize:new h.Uniform2f(o,t.u_texsize),u_texsize_icon:new h.Uniform2f(o,t.u_texsize_icon),u_texture:new h.Uniform1i(o,t.u_texture),u_texture_icon:new h.Uniform1i(o,t.u_texture_icon),u_gamma_scale:new h.Uniform1f(o,t.u_gamma_scale),u_device_pixel_ratio:new h.Uniform1f(o,t.u_device_pixel_ratio),u_is_halo:new h.Uniform1i(o,t.u_is_halo)}),background:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_opacity:new h.Uniform1f(o,t.u_opacity),u_color:new h.UniformColor(o,t.u_color)}),backgroundPattern:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_opacity:new h.Uniform1f(o,t.u_opacity),u_image:new h.Uniform1i(o,t.u_image),u_pattern_tl_a:new h.Uniform2f(o,t.u_pattern_tl_a),u_pattern_br_a:new h.Uniform2f(o,t.u_pattern_br_a),u_pattern_tl_b:new h.Uniform2f(o,t.u_pattern_tl_b),u_pattern_br_b:new h.Uniform2f(o,t.u_pattern_br_b),u_texsize:new h.Uniform2f(o,t.u_texsize),u_mix:new h.Uniform1f(o,t.u_mix),u_pattern_size_a:new h.Uniform2f(o,t.u_pattern_size_a),u_pattern_size_b:new h.Uniform2f(o,t.u_pattern_size_b),u_scale_a:new h.Uniform1f(o,t.u_scale_a),u_scale_b:new h.Uniform1f(o,t.u_scale_b),u_pixel_coord_upper:new h.Uniform2f(o,t.u_pixel_coord_upper),u_pixel_coord_lower:new h.Uniform2f(o,t.u_pixel_coord_lower),u_tile_units_to_pixels:new h.Uniform1f(o,t.u_tile_units_to_pixels)}),terrain:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_texture:new h.Uniform1i(o,t.u_texture),u_ele_delta:new h.Uniform1f(o,t.u_ele_delta)}),terrainDepth:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_ele_delta:new h.Uniform1f(o,t.u_ele_delta)}),terrainCoords:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_texture:new h.Uniform1i(o,t.u_texture),u_terrain_coords_id:new h.Uniform1f(o,t.u_terrain_coords_id),u_ele_delta:new h.Uniform1f(o,t.u_ele_delta)})};class Ss{constructor(t,n,s){this.context=t;const l=t.gl;this.buffer=l.createBuffer(),this.dynamicDraw=!!s,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),l.bufferData(l.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?l.DYNAMIC_DRAW:l.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Es={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Sn{constructor(t,n,s,l){this.length=n.length,this.attributes=s,this.itemSize=n.bytesPerElement,this.dynamicDraw=l,this.context=t;const d=t.gl;this.buffer=d.createBuffer(),t.bindVertexBuffer.set(this.buffer),d.bufferData(d.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?d.DYNAMIC_DRAW:d.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,n){for(let s=0;s<this.attributes.length;s++){const l=n.attributes[this.attributes[s].name];l!==void 0&&t.enableVertexAttribArray(l)}}setVertexAttribPointers(t,n,s){for(let l=0;l<this.attributes.length;l++){const d=this.attributes[l],m=n.attributes[d.name];m!==void 0&&t.vertexAttribPointer(m,d.components,t[Es[d.type]],!1,this.itemSize,d.offset+this.itemSize*(s||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class pt{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class jo extends pt{getDefault(){return h.Color.transparent}set(t){const n=this.current;(t.r!==n.r||t.g!==n.g||t.b!==n.b||t.a!==n.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Is extends pt{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class Jr extends pt{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class qo extends pt{getDefault(){return[!0,!0,!0,!0]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class En extends pt{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class In extends pt{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class Zo extends pt{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const n=this.current;(t.func!==n.func||t.ref!==n.ref||t.mask!==n.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class As extends pt{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class vt extends pt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),this.current=t,this.dirty=!1}}class Sa extends pt{getDefault(){return[0,1]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class tc extends pt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),this.current=t,this.dirty=!1}}class Xo extends pt{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class Kn extends pt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.BLEND):n.disable(n.BLEND),this.current=t,this.dirty=!1}}class ic extends pt{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class rc extends pt{getDefault(){return h.Color.transparent}set(t){const n=this.current;(t.r!==n.r||t.g!==n.g||t.b!==n.b||t.a!==n.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Wo extends pt{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class nc extends pt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.CULL_FACE):n.disable(n.CULL_FACE),this.current=t,this.dirty=!1}}class Cs extends pt{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Ea extends pt{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class Ia extends pt{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Ms extends pt{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class Ps extends pt{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Ho extends pt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindFramebuffer(n.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Aa extends pt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindRenderbuffer(n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Ca extends pt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindTexture(n.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class $i extends pt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindBuffer(n.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Ko extends pt{getDefault(){return null}set(t){const n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class ks extends pt{constructor(t){super(t),this.vao=t.extVertexArrayObject}getDefault(){return null}set(t){this.vao&&(t!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(t),this.current=t,this.dirty=!1)}}class Yo extends pt{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class An extends pt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class Ma extends pt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class Pa extends pt{constructor(t,n){super(t),this.context=t,this.parent=n}getDefault(){return null}}class ac extends Pa{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class zs extends Pa{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class sc{constructor(t,n,s,l){this.context=t,this.width=n,this.height=s;const d=t.gl,m=this.framebuffer=d.createFramebuffer();if(this.colorAttachment=new ac(t,m),l&&(this.depthAttachment=new zs(t,m)),d.checkFramebufferStatus(d.FRAMEBUFFER)!==d.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer is not complete")}destroy(){const t=this.context.gl,n=this.colorAttachment.get();if(n&&t.deleteTexture(n),this.depthAttachment){const s=this.depthAttachment.get();s&&t.deleteRenderbuffer(s)}t.deleteFramebuffer(this.framebuffer)}}class Ot{constructor(t,n,s){this.blendFunction=t,this.blendColor=n,this.mask=s}}Ot.Replace=[1,0],Ot.disabled=new Ot(Ot.Replace,h.Color.transparent,[!1,!1,!1,!1]),Ot.unblended=new Ot(Ot.Replace,h.Color.transparent,[!0,!0,!0,!0]),Ot.alphaBlended=new Ot([1,771],h.Color.transparent,[!0,!0,!0,!0]);class ka{constructor(t){this.gl=t,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new jo(this),this.clearDepth=new Is(this),this.clearStencil=new Jr(this),this.colorMask=new qo(this),this.depthMask=new En(this),this.stencilMask=new In(this),this.stencilFunc=new Zo(this),this.stencilOp=new As(this),this.stencilTest=new vt(this),this.depthRange=new Sa(this),this.depthTest=new tc(this),this.depthFunc=new Xo(this),this.blend=new Kn(this),this.blendFunc=new ic(this),this.blendColor=new rc(this),this.blendEquation=new Wo(this),this.cullFace=new nc(this),this.cullFaceSide=new Cs(this),this.frontFace=new Ea(this),this.program=new Ia(this),this.activeTexture=new Ms(this),this.viewport=new Ps(this),this.bindFramebuffer=new Ho(this),this.bindRenderbuffer=new Aa(this),this.bindTexture=new Ca(this),this.bindVertexBuffer=new $i(this),this.bindElementBuffer=new Ko(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new ks(this),this.pixelStoreUnpack=new Yo(this),this.pixelStoreUnpackPremultiplyAlpha=new An(this),this.pixelStoreUnpackFlipY=new Ma(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureHalfFloat=t.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(t.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float")),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE)}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.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,n){return new Ss(this,t,n)}createVertexBuffer(t,n,s){return new Sn(this,t,n,s)}createRenderbuffer(t,n,s){const l=this.gl,d=l.createRenderbuffer();return this.bindRenderbuffer.set(d),l.renderbufferStorage(l.RENDERBUFFER,t,n,s),this.bindRenderbuffer.set(null),d}createFramebuffer(t,n,s){return new sc(this,t,n,s)}clear({color:t,depth:n}){const s=this.gl;let l=0;t&&(l|=s.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),n!==void 0&&(l|=s.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),s.clear(l)}setCullFace(t){t.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){pe(t.blendFunction,Ot.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class at{constructor(t,n,s){this.func=t,this.mask=n,this.range=s}}at.ReadOnly=!1,at.ReadWrite=!0,at.disabled=new at(519,at.ReadOnly,[0,1]);const za=7680;class Lt{constructor(t,n,s,l,d,m){this.test=t,this.ref=n,this.mask=s,this.fail=l,this.depthFail=d,this.pass=m}}Lt.disabled=new Lt({func:519,mask:0},0,0,za,za,za);class Et{constructor(t,n,s){this.enable=t,this.mode=n,this.frontFace=s}}let Cn;function Ls(o,t,n,s,l,d,m){const g=o.context,y=g.gl,x=o.useProgram("collisionBox"),S=[];let T=0,M=0;for(let V=0;V<s.length;V++){const te=s[V],ae=t.getTile(te),se=ae.getBucket(n);if(!se)continue;let ue=te.posMatrix;l[0]===0&&l[1]===0||(ue=o.translatePosMatrix(te.posMatrix,ae,l,d));const me=m?se.textCollisionBox:se.iconCollisionBox,xe=se.collisionCircleArray;if(xe.length>0){const _e=h.create(),we=ue;h.mul(_e,se.placementInvProjMatrix,o.transform.glCoordMatrix),h.mul(_e,_e,se.placementViewportMatrix),S.push({circleArray:xe,circleOffset:M,transform:we,invTransform:_e,coord:te}),T+=xe.length/4,M=T}me&&x.draw(g,y.LINES,at.disabled,Lt.disabled,o.colorModeForRenderPass(),Et.disabled,xa(ue,o.transform,ae),o.style.map.terrain&&o.style.map.terrain.getTerrainData(te),n.id,me.layoutVertexBuffer,me.indexBuffer,me.segments,null,o.transform.zoom,null,null,me.collisionVertexBuffer)}if(!m||!S.length)return;const F=o.useProgram("collisionCircle"),O=new h.CollisionCircleLayoutArray;O.resize(4*T),O._trim();let D=0;for(const V of S)for(let te=0;te<V.circleArray.length/4;te++){const ae=4*te,se=V.circleArray[ae+0],ue=V.circleArray[ae+1],me=V.circleArray[ae+2],xe=V.circleArray[ae+3];O.emplace(D++,se,ue,me,xe,0),O.emplace(D++,se,ue,me,xe,1),O.emplace(D++,se,ue,me,xe,2),O.emplace(D++,se,ue,me,xe,3)}(!Cn||Cn.length<2*T)&&(Cn=function(V){const te=2*V,ae=new h.QuadTriangleArray;ae.resize(te),ae._trim();for(let se=0;se<te;se++){const ue=6*se;ae.uint16[ue+0]=4*se+0,ae.uint16[ue+1]=4*se+1,ae.uint16[ue+2]=4*se+2,ae.uint16[ue+3]=4*se+2,ae.uint16[ue+4]=4*se+3,ae.uint16[ue+5]=4*se+0}return ae}(T));const G=g.createIndexBuffer(Cn,!0),Y=g.createVertexBuffer(O,h.collisionCircleLayout.members,!0);for(const V of S){const te={u_matrix:V.transform,u_inv_matrix:V.invTransform,u_camera_to_center_distance:(H=o.transform).cameraToCenterDistance,u_viewport_size:[H.width,H.height]};F.draw(g,y.TRIANGLES,at.disabled,Lt.disabled,o.colorModeForRenderPass(),Et.disabled,te,o.style.map.terrain&&o.style.map.terrain.getTerrainData(V.coord),n.id,Y,G,h.SegmentVector.simpleSegment(0,2*V.circleOffset,V.circleArray.length,V.circleArray.length/2),null,o.transform.zoom,null,null,null)}var H;Y.destroy(),G.destroy()}Et.disabled=new Et(!1,1029,2305),Et.backCCW=new Et(!0,1029,2305);const Jo=h.identity(new Float32Array(16));function Qo(o,t,n,s,l,d){const{horizontalAlign:m,verticalAlign:g}=h.getAnchorAlignment(o),y=-(m-.5)*t,x=-(g-.5)*n,S=h.evaluateVariableOffset(o,s);return new h.pointGeometry((y/l+S[0])*d,(x/l+S[1])*d)}function el(o,t,n,s,l,d,m,g,y,x,S){const T=o.text.placedSymbolArray,M=o.text.dynamicLayoutVertexArray,F=o.icon.dynamicLayoutVertexArray,O={};M.clear();for(let D=0;D<T.length;D++){const G=T.get(D),Y=G.hidden||!G.crossTileID||o.allowVerticalPlacement&&!G.placedOrientation?null:s[G.crossTileID];if(Y){const H=new h.pointGeometry(G.anchorX,G.anchorY),V=gi(H,n?m:d,S),te=yr(l.cameraToCenterDistance,V.signedDistanceFromCamera);let ae=h.evaluateSizeForFeature(o.textSizeData,y,G)*te/h.ONE_EM;n&&(ae*=o.tilePixelRatio/g);const{width:se,height:ue,anchor:me,textOffset:xe,textBoxScale:_e}=Y,we=Qo(me,se,ue,xe,_e,ae),ze=n?gi(H.add(we),d,S).point:V.point.add(t?we.rotate(-l.angle):we),We=o.allowVerticalPlacement&&G.placedOrientation===h.WritingMode.vertical?Math.PI/2:0;for(let Ke=0;Ke<G.numGlyphs;Ke++)h.addDynamicAttributes(M,ze,We);x&&G.associatedIconIndex>=0&&(O[G.associatedIconIndex]={shiftedAnchor:ze,angle:We})}else q(G.numGlyphs,M)}if(x){F.clear();const D=o.icon.placedSymbolArray;for(let G=0;G<D.length;G++){const Y=D.get(G);if(Y.hidden)q(Y.numGlyphs,F);else{const H=O[G];if(H)for(let V=0;V<Y.numGlyphs;V++)h.addDynamicAttributes(F,H.shiftedAnchor,H.angle);else q(Y.numGlyphs,F)}}o.icon.dynamicLayoutVertexBuffer.updateData(F)}o.text.dynamicLayoutVertexBuffer.updateData(M)}function tl(o,t,n){return n.iconsInText&&t?"symbolTextAndIcon":o?"symbolSDF":"symbolIcon"}function kr(o,t,n,s,l,d,m,g,y,x,S,T){const M=o.context,F=M.gl,O=o.transform,D=g==="map",G=y==="map",Y=g!=="viewport"&&n.layout.get("symbol-placement")!=="point",H=D&&!G&&!Y,V=!n.layout.get("symbol-sort-key").isConstant();let te=!1;const ae=o.depthModeForSublayer(0,at.ReadOnly),se=n.layout.get("text-variable-anchor"),ue=[];for(const me of s){const xe=t.getTile(me),_e=xe.getBucket(n);if(!_e)continue;const we=l?_e.text:_e.icon;if(!we||!we.segments.get().length||!we.hasVisibleVertices)continue;const ze=we.programConfigurations.get(n.id),We=l||_e.sdfIcons,Ke=l?_e.textSizeData:_e.iconSizeData,Le=G||O.pitch!==0,mt=o.useProgram(tl(We,l,_e),ze),ft=h.evaluateSizeForZoom(Ke,O.zoom),tt=o.style.map.terrain&&o.style.map.terrain.getTerrainData(me);let ht,wt,gt,ji,qi=[0,0],ni=null;if(l)wt=xe.glyphAtlasTexture,gt=F.LINEAR,ht=xe.glyphAtlasTexture.size,_e.iconsInText&&(qi=xe.imageAtlasTexture.size,ni=xe.imageAtlasTexture,ji=Le||o.options.rotating||o.options.zooming||Ke.kind==="composite"||Ke.kind==="camera"?F.LINEAR:F.NEAREST);else{const cr=n.layout.get("icon-size").constantOr(0)!==1||_e.iconsNeedLinear;wt=xe.imageAtlasTexture,gt=We||o.options.rotating||o.options.zooming||cr||Le?F.LINEAR:F.NEAREST,ht=xe.imageAtlasTexture.size}const ki=ce(xe,1,o.transform.zoom),_i=Yt(me.posMatrix,G,D,o.transform,ki),Ji=fi(me.posMatrix,G,D,o.transform,ki),Rr=se&&_e.hasTextData(),Ka=n.layout.get("icon-text-fit")!=="none"&&Rr&&_e.hasIconData();if(Y){const cr=o.style.map.terrain?(oo,nn)=>o.style.map.terrain.getElevation(me,oo,nn):null,Qi=n.layout.get("text-rotation-alignment")==="map";I(_e,me.posMatrix,o,l,_i,Ji,G,x,Qi,cr)}const qt=o.translatePosMatrix(me.posMatrix,xe,d,m),Dt=Y||l&&se||Ka?Jo:_i,_t=o.translatePosMatrix(Ji,xe,d,m,!0),yi=We&&n.paint.get(l?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let xi;xi=We?_e.iconsInText?Ql(Ke.kind,ft,H,G,o,qt,Dt,_t,ht,qi):Go(Ke.kind,ft,H,G,o,qt,Dt,_t,l,ht,!0):$o(Ke.kind,ft,H,G,o,qt,Dt,_t,l,ht);const Rt={program:mt,buffers:we,uniformValues:xi,atlasTexture:wt,atlasTextureIcon:ni,atlasInterpolation:gt,atlasInterpolationIcon:ji,isSDF:We,hasHalo:yi};if(V&&_e.canOverlap){te=!0;const cr=we.segments.get();for(const Qi of cr)ue.push({segments:new h.SegmentVector([Qi]),sortKey:Qi.sortKey,state:Rt,terrainData:tt})}else ue.push({segments:we.segments,sortKey:0,state:Rt,terrainData:tt})}te&&ue.sort((me,xe)=>me.sortKey-xe.sortKey);for(const me of ue){const xe=me.state;if(M.activeTexture.set(F.TEXTURE0),xe.atlasTexture.bind(xe.atlasInterpolation,F.CLAMP_TO_EDGE),xe.atlasTextureIcon&&(M.activeTexture.set(F.TEXTURE1),xe.atlasTextureIcon&&xe.atlasTextureIcon.bind(xe.atlasInterpolationIcon,F.CLAMP_TO_EDGE)),xe.isSDF){const _e=xe.uniformValues;xe.hasHalo&&(_e.u_is_halo=1,Ds(xe.buffers,me.segments,n,o,xe.program,ae,S,T,_e,me.terrainData)),_e.u_is_halo=0}Ds(xe.buffers,me.segments,n,o,xe.program,ae,S,T,xe.uniformValues,me.terrainData)}}function Ds(o,t,n,s,l,d,m,g,y,x){const S=s.context;l.draw(S,S.gl.TRIANGLES,d,m,g,Et.disabled,y,x,n.id,o.layoutVertexBuffer,o.indexBuffer,t,n.paint,s.transform.zoom,o.programConfigurations.get(n.id),o.dynamicLayoutVertexBuffer,o.opacityVertexBuffer)}function Rs(o,t,n,s,l){if(!n||!s||!s.imageAtlas)return;const d=s.imageAtlas.patternPositions;let m=d[n.to.toString()],g=d[n.from.toString()];if(!m||!g){const y=l.getPaintProperty(t);m=d[y],g=d[y]}m&&g&&o.setConstantPatternPositions(m,g)}function Bs(o,t,n,s,l,d,m){const g=o.context.gl,y="fill-pattern",x=n.paint.get(y),S=x&&x.constantOr(1),T=n.getCrossfadeParameters();let M,F,O,D,G;m?(F=S&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",M=g.LINES):(F=S?"fillPattern":"fill",M=g.TRIANGLES);const Y=x.constantOr(null);for(const H of s){const V=t.getTile(H);if(S&&!V.patternsLoaded())continue;const te=V.getBucket(n);if(!te)continue;const ae=te.programConfigurations.get(n.id),se=o.useProgram(F,ae),ue=o.style.map.terrain&&o.style.map.terrain.getTerrainData(H);S&&(o.context.activeTexture.set(g.TEXTURE0),V.imageAtlasTexture.bind(g.LINEAR,g.CLAMP_TO_EDGE),ae.updatePaintBuffers(T)),Rs(ae,y,Y,V,n);const me=ue?H:null,xe=o.translatePosMatrix(me?me.posMatrix:H.posMatrix,V,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(m){D=te.indexBuffer2,G=te.segments2;const _e=[g.drawingBufferWidth,g.drawingBufferHeight];O=F==="fillOutlinePattern"&&S?Pi(xe,o,T,V,_e):Vo(xe,_e)}else D=te.indexBuffer,G=te.segments,O=S?Tn(xe,o,T,V):wn(xe);se.draw(o.context,M,l,o.stencilModeForClipping(H),d,Et.disabled,O,ue,n.id,te.layoutVertexBuffer,D,G,n.paint,o.transform.zoom,ae)}}function La(o,t,n,s,l,d,m){const g=o.context,y=g.gl,x="fill-extrusion-pattern",S=n.paint.get(x),T=S.constantOr(1),M=n.getCrossfadeParameters(),F=n.paint.get("fill-extrusion-opacity"),O=S.constantOr(null);for(const D of s){const G=t.getTile(D),Y=G.getBucket(n);if(!Y)continue;const H=o.style.map.terrain&&o.style.map.terrain.getTerrainData(D),V=Y.programConfigurations.get(n.id),te=o.useProgram(T?"fillExtrusionPattern":"fillExtrusion",V);T&&(o.context.activeTexture.set(y.TEXTURE0),G.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),V.updatePaintBuffers(M)),Rs(V,x,O,G,n);const ae=o.translatePosMatrix(D.posMatrix,G,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),se=n.paint.get("fill-extrusion-vertical-gradient"),ue=T?Kl(ae,o,se,F,D,M,G):ys(ae,o,se,F);te.draw(g,g.gl.TRIANGLES,l,d,m,Et.backCCW,ue,H,n.id,Y.layoutVertexBuffer,Y.indexBuffer,Y.segments,n.paint,o.transform.zoom,V,o.style.map.terrain&&Y.centroidVertexBuffer)}}function il(o,t,n,s,l,d,m){const g=o.context,y=g.gl,x=n.fbo;if(!x)return;const S=o.useProgram("hillshade"),T=o.style.map.terrain&&o.style.map.terrain.getTerrainData(t);g.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,x.colorAttachment.get()),S.draw(g,y.TRIANGLES,l,d,m,Et.disabled,((M,F,O,D)=>{const G=O.paint.get("hillshade-shadow-color"),Y=O.paint.get("hillshade-highlight-color"),H=O.paint.get("hillshade-accent-color");let V=O.paint.get("hillshade-illumination-direction")*(Math.PI/180);O.paint.get("hillshade-illumination-anchor")==="viewport"&&(V-=M.transform.angle);const te=!M.options.moving;return{u_matrix:D?D.posMatrix:M.transform.calculatePosMatrix(F.tileID.toUnwrapped(),te),u_image:0,u_latrange:ba(0,F.tileID),u_light:[O.paint.get("hillshade-exaggeration"),V],u_shadow:G,u_highlight:Y,u_accent:H}})(o,n,s,T?t:null),T,s.id,o.rasterBoundsBuffer,o.quadTriangleIndexBuffer,o.rasterBoundsSegments)}function rl(o,t,n,s,l,d){const m=o.context,g=m.gl,y=t.dem;if(y&&y.data){const x=y.dim,S=y.stride,T=y.getPixels();if(m.activeTexture.set(g.TEXTURE1),m.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||o.getTileTexture(S),t.demTexture){const F=t.demTexture;F.update(T,{premultiply:!1}),F.bind(g.NEAREST,g.CLAMP_TO_EDGE)}else t.demTexture=new Mt(m,T,g.RGBA,{premultiply:!1}),t.demTexture.bind(g.NEAREST,g.CLAMP_TO_EDGE);m.activeTexture.set(g.TEXTURE0);let M=t.fbo;if(!M){const F=new Mt(m,{width:x,height:x,data:null},g.RGBA);F.bind(g.LINEAR,g.CLAMP_TO_EDGE),M=t.fbo=m.createFramebuffer(x,x,!0),M.colorAttachment.set(F.texture)}m.bindFramebuffer.set(M.framebuffer),m.viewport.set([0,0,x,x]),o.useProgram("hillshadePrepare").draw(m,g.TRIANGLES,s,l,d,Et.disabled,((F,O)=>{const D=O.stride,G=h.create();return h.ortho(G,0,h.EXTENT,-h.EXTENT,0,0,1),h.translate(G,G,[0,-h.EXTENT,0]),{u_matrix:G,u_image:1,u_dimension:[D,D],u_zoom:F.overscaledZ,u_unpack:O.getUnpackVector()}})(t.tileID,y),null,n.id,o.rasterBoundsBuffer,o.quadTriangleIndexBuffer,o.rasterBoundsSegments),t.needsHillshadePrepare=!1}}function Yn(o,t,n,s,l,d){const m=s.paint.get("raster-fade-duration");if(!d&&m>0){const g=h.exported.now(),y=(g-o.timeAdded)/m,x=t?(g-t.timeAdded)/m:-1,S=n.getSource(),T=l.coveringZoomLevel({tileSize:S.tileSize,roundZoom:S.roundZoom}),M=!t||Math.abs(t.tileID.overscaledZ-T)>Math.abs(o.tileID.overscaledZ-T),F=M&&o.refreshedUponExpiration?1:h.clamp(M?y:1-x,0,1);return o.refreshedUponExpiration&&y>=1&&(o.refreshedUponExpiration=!1),t?{opacity:1,mix:1-F}:{opacity:F,mix:0}}return{opacity:1,mix:0}}const nl=new h.Color(1,0,0,1),or=new h.Color(0,1,0,1),xr=new h.Color(0,0,1,1),al=new h.Color(1,0,1,1),vr=new h.Color(0,1,1,1);function Mn(o,t,n,s){Da(o,0,t+n/2,o.transform.width,n,s)}function sl(o,t,n,s){Da(o,t-n/2,0,n,o.transform.height,s)}function Da(o,t,n,s,l,d){const m=o.context,g=m.gl;g.enable(g.SCISSOR_TEST),g.scissor(t*o.pixelRatio,n*o.pixelRatio,s*o.pixelRatio,l*o.pixelRatio),m.clear({color:d}),g.disable(g.SCISSOR_TEST)}function oc(o,t,n){const s=o.context,l=s.gl,d=n.posMatrix,m=o.useProgram("debug"),g=at.disabled,y=Lt.disabled,x=o.colorModeForRenderPass(),S="$debug",T=o.style.map.terrain&&o.style.map.terrain.getTerrainData(n);s.activeTexture.set(l.TEXTURE0),o.emptyTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE);const M=t.getTileByID(n.key).latestRawTileData,F=Math.floor((M&&M.byteLength||0)/1024),O=t.getTile(n).tileSize,D=512/Math.min(O,512)*(n.overscaledZ/o.transform.zoom)*.5;let G=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(G+=` => ${n.overscaledZ}`),function(Y,H){Y.initDebugOverlayCanvas();const V=Y.debugOverlayCanvas,te=Y.context.gl,ae=Y.debugOverlayCanvas.getContext("2d");ae.clearRect(0,0,V.width,V.height),ae.shadowColor="white",ae.shadowBlur=2,ae.lineWidth=1.5,ae.strokeStyle="white",ae.textBaseline="top",ae.font="bold 36px Open Sans, sans-serif",ae.fillText(H,5,5),ae.strokeText(H,5,5),Y.debugOverlayTexture.update(V),Y.debugOverlayTexture.bind(te.LINEAR,te.CLAMP_TO_EDGE)}(o,`${G} ${F}kB`),m.draw(s,l.TRIANGLES,g,y,Ot.alphaBlended,Et.disabled,Wn(d,h.Color.transparent,D),null,S,o.debugBuffer,o.quadTriangleIndexBuffer,o.debugSegments),m.draw(s,l.LINE_STRIP,g,y,x,Et.disabled,Wn(d,h.Color.red),T,S,o.debugBuffer,o.tileBorderIndexBuffer,o.debugSegments)}function Fs(o,t,n){const s=o.context,l=s.gl,d=o.colorModeForRenderPass(),m=new at(l.LEQUAL,at.ReadWrite,o.depthRangeFor3D),g=o.useProgram("terrain"),y=t.getTerrainMesh();s.bindFramebuffer.set(null),s.viewport.set([0,0,o.width,o.height]);for(const x of n){const S=o.renderToTexture.getTexture(x),T=t.getTerrainData(x.tileID);s.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,S.texture);const M={u_matrix:o.transform.calculatePosMatrix(x.tileID.toUnwrapped()),u_texture:0,u_ele_delta:t.getMeshFrameDelta(o.transform.zoom)};g.draw(s,l.TRIANGLES,m,Lt.disabled,d,Et.backCCW,M,T,"terrain",y.vertexBuffer,y.indexBuffer,y.segments)}}const Pn={symbol:function(o,t,n,s,l){if(o.renderPass!=="translucent")return;const d=Lt.disabled,m=o.colorModeForRenderPass();n.layout.get("text-variable-anchor")&&function(g,y,x,S,T,M,F){const O=y.transform,D=T==="map",G=M==="map";for(const Y of g){const H=S.getTile(Y),V=H.getBucket(x);if(!V||!V.text||!V.text.segments.get().length)continue;const te=h.evaluateSizeForZoom(V.textSizeData,O.zoom),ae=ce(H,1,y.transform.zoom),se=Yt(Y.posMatrix,G,D,y.transform,ae),ue=x.layout.get("icon-text-fit")!=="none"&&V.hasIconData();if(te){const me=Math.pow(2,O.zoom-H.tileID.overscaledZ);el(V,D,G,F,O,se,Y.posMatrix,me,te,ue,y.style.map.terrain?(xe,_e)=>y.style.map.terrain.getElevation(Y,xe,_e):null)}}}(s,o,n,t,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),l),n.paint.get("icon-opacity").constantOr(1)!==0&&kr(o,t,n,s,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright"),d,m),n.paint.get("text-opacity").constantOr(1)!==0&&kr(o,t,n,s,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright"),d,m),t.map.showCollisionBoxes&&(Ls(o,t,n,s,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),!0),Ls(o,t,n,s,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),!1))},circle:function(o,t,n,s){if(o.renderPass!=="translucent")return;const l=n.paint.get("circle-opacity"),d=n.paint.get("circle-stroke-width"),m=n.paint.get("circle-stroke-opacity"),g=!n.layout.get("circle-sort-key").isConstant();if(l.constantOr(1)===0&&(d.constantOr(1)===0||m.constantOr(1)===0))return;const y=o.context,x=y.gl,S=o.depthModeForSublayer(0,at.ReadOnly),T=Lt.disabled,M=o.colorModeForRenderPass(),F=[];for(let O=0;O<s.length;O++){const D=s[O],G=t.getTile(D),Y=G.getBucket(n);if(!Y)continue;const H=Y.programConfigurations.get(n.id),V=o.useProgram("circle",H),te=Y.layoutVertexBuffer,ae=Y.indexBuffer,se=o.style.map.terrain&&o.style.map.terrain.getTerrainData(D),ue={programConfiguration:H,program:V,layoutVertexBuffer:te,indexBuffer:ae,uniformValues:xs(o,D,G,n),terrainData:se};if(g){const me=Y.segments.get();for(const xe of me)F.push({segments:new h.SegmentVector([xe]),sortKey:xe.sortKey,state:ue})}else F.push({segments:Y.segments,sortKey:0,state:ue})}g&&F.sort((O,D)=>O.sortKey-D.sortKey);for(const O of F){const{programConfiguration:D,program:G,layoutVertexBuffer:Y,indexBuffer:H,uniformValues:V,terrainData:te}=O.state;G.draw(y,x.TRIANGLES,S,T,M,Et.disabled,V,te,n.id,Y,H,O.segments,n.paint,o.transform.zoom,D)}},heatmap:function(o,t,n,s){if(n.paint.get("heatmap-opacity")!==0)if(o.renderPass==="offscreen"){const l=o.context,d=l.gl,m=Lt.disabled,g=new Ot([d.ONE,d.ONE],h.Color.transparent,[!0,!0,!0,!0]);(function(y,x,S){const T=y.gl;y.activeTexture.set(T.TEXTURE1),y.viewport.set([0,0,x.width/4,x.height/4]);let M=S.heatmapFbo;if(M)T.bindTexture(T.TEXTURE_2D,M.colorAttachment.get()),y.bindFramebuffer.set(M.framebuffer);else{const F=T.createTexture();T.bindTexture(T.TEXTURE_2D,F),T.texParameteri(T.TEXTURE_2D,T.TEXTURE_WRAP_S,T.CLAMP_TO_EDGE),T.texParameteri(T.TEXTURE_2D,T.TEXTURE_WRAP_T,T.CLAMP_TO_EDGE),T.texParameteri(T.TEXTURE_2D,T.TEXTURE_MIN_FILTER,T.LINEAR),T.texParameteri(T.TEXTURE_2D,T.TEXTURE_MAG_FILTER,T.LINEAR),M=S.heatmapFbo=y.createFramebuffer(x.width/4,x.height/4,!1),function(O,D,G,Y){const H=O.gl;H.texImage2D(H.TEXTURE_2D,0,H.RGBA,D.width/4,D.height/4,0,H.RGBA,O.extRenderToTextureHalfFloat?O.extTextureHalfFloat.HALF_FLOAT_OES:H.UNSIGNED_BYTE,null),Y.colorAttachment.set(G)}(y,x,F,M)}})(l,o,n),l.clear({color:h.Color.transparent});for(let y=0;y<s.length;y++){const x=s[y];if(t.hasRenderableParent(x))continue;const S=t.getTile(x),T=S.getBucket(n);if(!T)continue;const M=T.programConfigurations.get(n.id),F=o.useProgram("heatmap",M),{zoom:O}=o.transform;F.draw(l,d.TRIANGLES,at.disabled,m,g,Et.disabled,vs(x.posMatrix,S,O,n.paint.get("heatmap-intensity")),null,n.id,T.layoutVertexBuffer,T.indexBuffer,T.segments,n.paint,o.transform.zoom,M)}l.viewport.set([0,0,o.width,o.height])}else o.renderPass==="translucent"&&(o.context.setColorMode(o.colorModeForRenderPass()),function(l,d){const m=l.context,g=m.gl,y=d.heatmapFbo;if(!y)return;m.activeTexture.set(g.TEXTURE0),g.bindTexture(g.TEXTURE_2D,y.colorAttachment.get()),m.activeTexture.set(g.TEXTURE1);let x=d.colorRampTexture;x||(x=d.colorRampTexture=new Mt(m,d.colorRamp,g.RGBA)),x.bind(g.LINEAR,g.CLAMP_TO_EDGE),l.useProgram("heatmapTexture").draw(m,g.TRIANGLES,at.disabled,Lt.disabled,l.colorModeForRenderPass(),Et.disabled,((S,T,M,F)=>{const O=h.create();h.ortho(O,0,S.width,S.height,0,0,1);const D=S.context.gl;return{u_matrix:O,u_world:[D.drawingBufferWidth,D.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:T.paint.get("heatmap-opacity")}})(l,d),null,d.id,l.viewportBuffer,l.quadTriangleIndexBuffer,l.viewportSegments,d.paint,l.transform.zoom)}(o,n))},line:function(o,t,n,s){if(o.renderPass!=="translucent")return;const l=n.paint.get("line-opacity"),d=n.paint.get("line-width");if(l.constantOr(1)===0||d.constantOr(1)===0)return;const m=o.depthModeForSublayer(0,at.ReadOnly),g=o.colorModeForRenderPass(),y=n.paint.get("line-dasharray"),x=n.paint.get("line-pattern"),S=x.constantOr(1),T=n.paint.get("line-gradient"),M=n.getCrossfadeParameters(),F=S?"linePattern":y?"lineSDF":T?"lineGradient":"line",O=o.context,D=O.gl;let G=!0;for(const Y of s){const H=t.getTile(Y);if(S&&!H.patternsLoaded())continue;const V=H.getBucket(n);if(!V)continue;const te=V.programConfigurations.get(n.id),ae=o.context.program.get(),se=o.useProgram(F,te),ue=G||se.program!==ae,me=o.style.map.terrain&&o.style.map.terrain.getTerrainData(Y),xe=x.constantOr(null);if(xe&&H.imageAtlas){const ze=H.imageAtlas,We=ze.patternPositions[xe.to.toString()],Ke=ze.patternPositions[xe.from.toString()];We&&Ke&&te.setConstantPatternPositions(We,Ke)}const _e=me?Y:null,we=S?wa(o,H,n,M,_e):y?No(o,H,n,y,M,_e):T?bs(o,H,n,V.lineClipsArray.length,_e):Hn(o,H,n,_e);if(S)O.activeTexture.set(D.TEXTURE0),H.imageAtlasTexture.bind(D.LINEAR,D.CLAMP_TO_EDGE),te.updatePaintBuffers(M);else if(y&&(ue||o.lineAtlas.dirty))O.activeTexture.set(D.TEXTURE0),o.lineAtlas.bind(O);else if(T){const ze=V.gradients[n.id];let We=ze.texture;if(n.gradientVersion!==ze.version){let Ke=256;if(n.stepInterpolant){const Le=t.getSource().maxzoom,mt=Y.canonical.z===Le?Math.ceil(1<<o.transform.maxZoom-Y.canonical.z):1;Ke=h.clamp(h.nextPowerOfTwo(V.maxLineLength/h.EXTENT*1024*mt),256,O.maxTextureSize)}ze.gradient=h.renderColorRamp({expression:n.gradientExpression(),evaluationKey:"lineProgress",resolution:Ke,image:ze.gradient||void 0,clips:V.lineClipsArray}),ze.texture?ze.texture.update(ze.gradient):ze.texture=new Mt(O,ze.gradient,D.RGBA),ze.version=n.gradientVersion,We=ze.texture}O.activeTexture.set(D.TEXTURE0),We.bind(n.stepInterpolant?D.NEAREST:D.LINEAR,D.CLAMP_TO_EDGE)}se.draw(O,D.TRIANGLES,m,o.stencilModeForClipping(Y),g,Et.disabled,we,me,n.id,V.layoutVertexBuffer,V.indexBuffer,V.segments,n.paint,o.transform.zoom,te,V.layoutVertexBuffer2),G=!1}},fill:function(o,t,n,s){const l=n.paint.get("fill-color"),d=n.paint.get("fill-opacity");if(d.constantOr(1)===0)return;const m=o.colorModeForRenderPass(),g=n.paint.get("fill-pattern"),y=o.opaquePassEnabledForLayer()&&!g.constantOr(1)&&l.constantOr(h.Color.transparent).a===1&&d.constantOr(0)===1?"opaque":"translucent";if(o.renderPass===y){const x=o.depthModeForSublayer(1,o.renderPass==="opaque"?at.ReadWrite:at.ReadOnly);Bs(o,t,n,s,x,m,!1)}if(o.renderPass==="translucent"&&n.paint.get("fill-antialias")){const x=o.depthModeForSublayer(n.getPaintProperty("fill-outline-color")?2:0,at.ReadOnly);Bs(o,t,n,s,x,m,!0)}},"fill-extrusion":function(o,t,n,s){const l=n.paint.get("fill-extrusion-opacity");if(l!==0&&o.renderPass==="translucent"){const d=new at(o.context.gl.LEQUAL,at.ReadWrite,o.depthRangeFor3D);if(l!==1||n.paint.get("fill-extrusion-pattern").constantOr(1))La(o,t,n,s,d,Lt.disabled,Ot.disabled),La(o,t,n,s,d,o.stencilModeFor3D(),o.colorModeForRenderPass());else{const m=o.colorModeForRenderPass();La(o,t,n,s,d,Lt.disabled,m)}}},hillshade:function(o,t,n,s){if(o.renderPass!=="offscreen"&&o.renderPass!=="translucent")return;const l=o.context,d=o.depthModeForSublayer(0,at.ReadOnly),m=o.colorModeForRenderPass(),[g,y]=o.renderPass==="translucent"?o.stencilConfigForOverlap(s):[{},s];for(const x of y){const S=t.getTile(x);S.needsHillshadePrepare!==void 0&&S.needsHillshadePrepare&&o.renderPass==="offscreen"?rl(o,S,n,d,Lt.disabled,m):o.renderPass==="translucent"&&il(o,x,S,n,d,g[x.overscaledZ],m)}l.viewport.set([0,0,o.width,o.height])},raster:function(o,t,n,s){if(o.renderPass!=="translucent"||n.paint.get("raster-opacity")===0||!s.length)return;const l=o.context,d=l.gl,m=t.getSource(),g=o.useProgram("raster"),y=o.colorModeForRenderPass(),[x,S]=m instanceof bt?[{},s]:o.stencilConfigForOverlap(s),T=S[S.length-1].overscaledZ,M=!o.options.moving;for(const F of S){const O=o.depthModeForSublayer(F.overscaledZ-T,n.paint.get("raster-opacity")===1?at.ReadWrite:at.ReadOnly,d.LESS),D=t.getTile(F);D.registerFadeDuration(n.paint.get("raster-fade-duration"));const G=t.findLoadedParent(F,0),Y=Yn(D,G,t,n,o.transform,o.style.map.terrain);let H,V;const te=n.paint.get("raster-resampling")==="nearest"?d.NEAREST:d.LINEAR;l.activeTexture.set(d.TEXTURE0),D.texture.bind(te,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),l.activeTexture.set(d.TEXTURE1),G?(G.texture.bind(te,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),H=Math.pow(2,G.tileID.overscaledZ-D.tileID.overscaledZ),V=[D.tileID.canonical.x*H%1,D.tileID.canonical.y*H%1]):D.texture.bind(te,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST);const ae=o.style.map.terrain&&o.style.map.terrain.getTerrainData(F),se=ae?F:null,ue=se?se.posMatrix:o.transform.calculatePosMatrix(F.toUnwrapped(),M),me=Yl(ue,V||[0,0],H||1,Y,n);m instanceof bt?g.draw(l,d.TRIANGLES,O,Lt.disabled,y,Et.disabled,me,ae,n.id,m.boundsBuffer,o.quadTriangleIndexBuffer,m.boundsSegments):g.draw(l,d.TRIANGLES,O,x[F.overscaledZ],y,Et.disabled,me,ae,n.id,o.rasterBoundsBuffer,o.quadTriangleIndexBuffer,o.rasterBoundsSegments)}},background:function(o,t,n,s){const l=n.paint.get("background-color"),d=n.paint.get("background-opacity");if(d===0)return;const m=o.context,g=m.gl,y=o.transform,x=y.tileSize,S=n.paint.get("background-pattern");if(o.isPatternMissing(S))return;const T=!S&&l.a===1&&d===1&&o.opaquePassEnabledForLayer()?"opaque":"translucent";if(o.renderPass!==T)return;const M=Lt.disabled,F=o.depthModeForSublayer(0,T==="opaque"?at.ReadWrite:at.ReadOnly),O=o.colorModeForRenderPass(),D=o.useProgram(S?"backgroundPattern":"background"),G=s||y.coveringTiles({tileSize:x,terrain:o.style.map.terrain});S&&(m.activeTexture.set(g.TEXTURE0),o.imageManager.bind(o.context));const Y=n.getCrossfadeParameters();for(const H of G){const V=s?H.posMatrix:o.transform.calculatePosMatrix(H.toUnwrapped()),te=S?Ts(V,d,o,S,{tileID:H,tileSize:x},Y):ec(V,d,l),ae=o.style.map.terrain&&o.style.map.terrain.getTerrainData(H);D.draw(m,g.TRIANGLES,F,M,O,Et.disabled,te,ae,n.id,o.tileExtentBuffer,o.quadTriangleIndexBuffer,o.tileExtentSegments)}},debug:function(o,t,n){for(let s=0;s<n.length;s++)oc(o,t,n[s])},custom:function(o,t,n){const s=o.context,l=n.implementation;if(o.renderPass==="offscreen"){const d=l.prerender;d&&(o.setCustomLayerDefaults(),s.setColorMode(o.colorModeForRenderPass()),d.call(l,s.gl,o.transform.customLayerMatrix()),s.setDirty(),o.setBaseState())}else if(o.renderPass==="translucent"){o.setCustomLayerDefaults(),s.setColorMode(o.colorModeForRenderPass()),s.setStencilMode(Lt.disabled);const d=l.renderingMode==="3d"?new at(o.context.gl.LEQUAL,at.ReadWrite,o.depthRangeFor3D):o.depthModeForSublayer(0,at.ReadOnly);s.setDepthMode(d),l.render(s.gl,o.transform.customLayerMatrix()),s.setDirty(),o.setBaseState(),s.bindFramebuffer.set(null)}}};class zr{constructor(t,n){this.context=new ka(t),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:h.create(),renderTime:0},this.setup(),this.numSublayers=Xe.maxUnderzooming+Xe.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new zt,this.gpuTimers={}}resize(t,n,s){if(this.width=t*s,this.height=n*s,this.pixelRatio=s,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const l of this.style._order)this.style._layers[l].resize()}setup(){const t=this.context,n=new h.PosArray;n.emplaceBack(0,0),n.emplaceBack(h.EXTENT,0),n.emplaceBack(0,h.EXTENT),n.emplaceBack(h.EXTENT,h.EXTENT),this.tileExtentBuffer=t.createVertexBuffer(n,ya.members),this.tileExtentSegments=h.SegmentVector.simpleSegment(0,0,4,2);const s=new h.PosArray;s.emplaceBack(0,0),s.emplaceBack(h.EXTENT,0),s.emplaceBack(0,h.EXTENT),s.emplaceBack(h.EXTENT,h.EXTENT),this.debugBuffer=t.createVertexBuffer(s,ya.members),this.debugSegments=h.SegmentVector.simpleSegment(0,0,4,5);const l=new h.RasterBoundsArray;l.emplaceBack(0,0,0,0),l.emplaceBack(h.EXTENT,0,h.EXTENT,0),l.emplaceBack(0,h.EXTENT,0,h.EXTENT),l.emplaceBack(h.EXTENT,h.EXTENT,h.EXTENT,h.EXTENT),this.rasterBoundsBuffer=t.createVertexBuffer(l,di.members),this.rasterBoundsSegments=h.SegmentVector.simpleSegment(0,0,4,2);const d=new h.PosArray;d.emplaceBack(0,0),d.emplaceBack(1,0),d.emplaceBack(0,1),d.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(d,ya.members),this.viewportSegments=h.SegmentVector.simpleSegment(0,0,4,2);const m=new h.LineStripIndexArray;m.emplaceBack(0),m.emplaceBack(1),m.emplaceBack(3),m.emplaceBack(2),m.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(m);const g=new h.TriangleIndexArray;g.emplaceBack(0,1,2),g.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(g),this.emptyTexture=new Mt(t,{width:1,height:1,data:new Uint8Array([0,0,0,0])},t.gl.RGBA);const y=this.context.gl;this.stencilClearMode=new Lt({func:y.ALWAYS,mask:0},0,255,y.ZERO,y.ZERO,y.ZERO)}clearStencil(){const t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const s=h.create();h.ortho(s,0,this.width,this.height,0,0,1),h.scale(s,s,[n.drawingBufferWidth,n.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,n.TRIANGLES,at.disabled,this.stencilClearMode,Ot.disabled,Et.disabled,va(s),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,n){if(this.currentStencilSource===t.source||!t.isTileClipped()||!n||!n.length)return;this.currentStencilSource=t.source;const s=this.context,l=s.gl;this.nextStencilID+n.length>256&&this.clearStencil(),s.setColorMode(Ot.disabled),s.setDepthMode(at.disabled);const d=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const m of n){const g=this._tileClippingMaskIDs[m.key]=this.nextStencilID++,y=this.style.map.terrain&&this.style.map.terrain.getTerrainData(m);d.draw(s,l.TRIANGLES,at.disabled,new Lt({func:l.ALWAYS,mask:0},g,255,l.KEEP,l.KEEP,l.REPLACE),Ot.disabled,Et.disabled,va(m.posMatrix),y,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,n=this.context.gl;return new Lt({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){const n=this.context.gl;return new Lt({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(t){const n=this.context.gl,s=t.sort((m,g)=>g.overscaledZ-m.overscaledZ),l=s[s.length-1].overscaledZ,d=s[0].overscaledZ-l+1;if(d>1){this.currentStencilSource=void 0,this.nextStencilID+d>256&&this.clearStencil();const m={};for(let g=0;g<d;g++)m[g+l]=new Lt({func:n.GEQUAL,mask:255},g+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=d,[m,s]}return[{[l]:Lt.disabled},s]}colorModeForRenderPass(){const t=this.context.gl;return this._showOverdrawInspector?new Ot([t.CONSTANT_COLOR,t.ONE],new h.Color(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?Ot.unblended:Ot.alphaBlended}depthModeForSublayer(t,n,s){if(!this.opaquePassEnabledForLayer())return at.disabled;const l=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new at(s||this.context.gl.LEQUAL,n,[l,l])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,n){this.style=t,this.options=n,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(h.exported.now()),this.imageManager.beginFrame();const s=this.style._order,l=this.style.sourceCaches,d={},m={},g={};for(const y in l){const x=l[y];x.used&&x.prepare(this.context),d[y]=x.getVisibleCoordinates(),m[y]=d[y].slice().reverse(),g[y]=x.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let y=0;y<s.length;y++)if(this.style._layers[s[y]].is3D()){this.opaquePassCutoff=y;break}if(this.renderToTexture){this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0;const y=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime);(this.terrainFacilitator.dirty||!h.equals(this.terrainFacilitator.matrix,this.transform.projMatrix)||y.length)&&(h.copy(this.terrainFacilitator.matrix,this.transform.projMatrix),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(x,S){const T=x.context,M=T.gl,F=Ot.unblended,O=new at(M.LEQUAL,at.ReadWrite,[0,1]),D=S.getTerrainMesh(),G=S.sourceCache.getRenderableTiles(),Y=x.useProgram("terrainDepth");T.bindFramebuffer.set(S.getFramebuffer("depth").framebuffer),T.viewport.set([0,0,x.width/devicePixelRatio,x.height/devicePixelRatio]),T.clear({color:h.Color.transparent,depth:1});for(const H of G){const V=S.getTerrainData(H.tileID),te={u_matrix:x.transform.calculatePosMatrix(H.tileID.toUnwrapped()),u_ele_delta:S.getMeshFrameDelta(x.transform.zoom)};Y.draw(T,M.TRIANGLES,O,Lt.disabled,F,Et.backCCW,te,V,"terrain",D.vertexBuffer,D.indexBuffer,D.segments)}T.bindFramebuffer.set(null),T.viewport.set([0,0,x.width,x.height])}(this,this.style.map.terrain),function(x,S){const T=x.context,M=T.gl,F=Ot.unblended,O=new at(M.LEQUAL,at.ReadWrite,[0,1]),D=S.getTerrainMesh(),G=S.getCoordsTexture(),Y=S.sourceCache.getRenderableTiles(),H=x.useProgram("terrainCoords");T.bindFramebuffer.set(S.getFramebuffer("coords").framebuffer),T.viewport.set([0,0,x.width/devicePixelRatio,x.height/devicePixelRatio]),T.clear({color:h.Color.transparent,depth:1}),S.coordsIndex=[];for(const V of Y){const te=S.getTerrainData(V.tileID);T.activeTexture.set(M.TEXTURE0),M.bindTexture(M.TEXTURE_2D,G.texture);const ae={u_matrix:x.transform.calculatePosMatrix(V.tileID.toUnwrapped()),u_terrain_coords_id:(255-S.coordsIndex.length)/255,u_texture:0,u_ele_delta:S.getMeshFrameDelta(x.transform.zoom)};H.draw(T,M.TRIANGLES,O,Lt.disabled,F,Et.backCCW,ae,te,"terrain",D.vertexBuffer,D.indexBuffer,D.segments),S.coordsIndex.push(V.tileID.key)}T.bindFramebuffer.set(null),T.viewport.set([0,0,x.width,x.height])}(this,this.style.map.terrain))}this.renderPass="offscreen";for(const y of s){const x=this.style._layers[y];if(!x.hasOffscreenPass()||x.isHidden(this.transform.zoom))continue;const S=m[x.source];(x.type==="custom"||S.length)&&this.renderLayer(this,l[x.source],x,S)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?h.Color.black:h.Color.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=s.length-1;this.currentLayer>=0;this.currentLayer--){const y=this.style._layers[s[this.currentLayer]],x=l[y.source],S=d[y.source];this._renderTileClippingMasks(y,S),this.renderLayer(this,x,y,S)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<s.length;this.currentLayer++){const y=this.style._layers[s[this.currentLayer]],x=l[y.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(y))continue;const S=(y.type==="symbol"?g:m)[y.source];this._renderTileClippingMasks(y,d[y.source]),this.renderLayer(this,x,y,S)}if(this.options.showTileBoundaries){const y=function(x,S){let T=null;const M=Object.values(x._layers).flatMap(G=>G.source&&!G.isHidden(S)?[x.sourceCaches[G.source]]:[]),F=M.filter(G=>G.getSource().type==="vector"),O=M.filter(G=>G.getSource().type!=="vector"),D=G=>{(!T||T.getSource().maxzoom<G.getSource().maxzoom)&&(T=G)};return F.forEach(G=>D(G)),T||O.forEach(G=>D(G)),T}(this.style,this.transform.zoom);y&&Pn.debug(this,y,y.getVisibleCoordinates())}this.options.showPadding&&function(y){const x=y.transform.padding;Mn(y,y.transform.height-(x.top||0),3,nl),Mn(y,x.bottom||0,3,or),sl(y,x.left||0,3,xr),sl(y,y.transform.width-(x.right||0),3,al);const S=y.transform.centerPoint;(function(T,M,F,O){Da(T,M-1,F-10,2,20,O),Da(T,M-10,F-1,20,2,O)})(y,S.x,y.transform.height-S.y,vr)}(this),this.context.setDefault()}renderLayer(t,n,s,l){s.isHidden(this.transform.zoom)||(s.type==="background"||s.type==="custom"||(l||[]).length)&&(this.id=s.id,this.gpuTimingStart(s),Pn[s.type](t,n,s,l,this.style.placement.variableOffsets),this.gpuTimingEnd())}gpuTimingStart(t){if(!this.options.gpuTiming)return;const n=this.context.extTimerQuery;let s=this.gpuTimers[t.id];s||(s=this.gpuTimers[t.id]={calls:0,cpuTime:0,query:n.createQueryEXT()}),s.calls++,n.beginQueryEXT(n.TIME_ELAPSED_EXT,s.query)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery;t.endQueryEXT(t.TIME_ELAPSED_EXT)}collectGpuTimers(){const t=this.gpuTimers;return this.gpuTimers={},t}queryGpuTimers(t){const n={};for(const s in t){const l=t[s],d=this.context.extTimerQuery,m=d.getQueryObjectEXT(l.query,d.QUERY_RESULT_EXT)/1e6;d.deleteQueryEXT(l.query),n[s]=m}return n}translatePosMatrix(t,n,s,l,d){if(!s[0]&&!s[1])return t;const m=d?l==="map"?this.transform.angle:0:l==="viewport"?-this.transform.angle:0;if(m){const x=Math.sin(m),S=Math.cos(m);s=[s[0]*S-s[1]*x,s[0]*x+s[1]*S]}const g=[d?s[0]:ce(n,s[0],this.transform.zoom),d?s[1]:ce(n,s[1],this.transform.zoom),0],y=new Float32Array(16);return h.translate(y,t,g),y}saveTileTexture(t){const n=this._tileTextures[t.size[0]];n?n.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const n=this._tileTextures[t];return n&&n.length>0?n.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const n=this.imageManager.getPattern(t.from.toString()),s=this.imageManager.getPattern(t.to.toString());return!n||!s}useProgram(t,n){this.cache=this.cache||{};const s=t+(n?n.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[s]||(this.cache[s]=new gs(this.context,t,Zn[t],n,Ta[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[s]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new Mt(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}}class ke{constructor(t,n){this.points=t,this.planes=n}static fromInvProjectionMatrix(t,n,s){const l=Math.pow(2,s),d=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(g=>{const y=1/(g=h.transformMat4([],g,t))[3]/n*l;return h.mul$1(g,g,[y,y,1/g[3],y])}),m=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(g=>{const y=function(M,F){var O=F[0],D=F[1],G=F[2],Y=O*O+D*D+G*G;return Y>0&&(Y=1/Math.sqrt(Y)),M[0]=F[0]*Y,M[1]=F[1]*Y,M[2]=F[2]*Y,M}([],function(M,F,O){var D=F[0],G=F[1],Y=F[2],H=O[0],V=O[1],te=O[2];return M[0]=G*te-Y*V,M[1]=Y*H-D*te,M[2]=D*V-G*H,M}([],gr([],d[g[0]],d[g[1]]),gr([],d[g[2]],d[g[1]]))),x=-((S=y)[0]*(T=d[g[1]])[0]+S[1]*T[1]+S[2]*T[2]);var S,T;return y.concat(x)});return new ke(d,m)}}class Jn{constructor(t,n){this.min=t,this.max=n,this.center=function(s,l,d){return s[0]=.5*l[0],s[1]=.5*l[1],s[2]=.5*l[2],s}([],function(s,l,d){return s[0]=l[0]+d[0],s[1]=l[1]+d[1],s[2]=l[2]+d[2],s}([],this.min,this.max))}quadrant(t){const n=[t%2==0,t<2],s=pn(this.min),l=pn(this.max);for(let d=0;d<n.length;d++)s[d]=n[d]?this.min[d]:this.center[d],l[d]=n[d]?this.center[d]:this.max[d];return l[2]=this.max[2],new Jn(s,l)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersects(t){const n=[[this.min[0],this.min[1],this.min[2],1],[this.max[0],this.min[1],this.min[2],1],[this.max[0],this.max[1],this.min[2],1],[this.min[0],this.max[1],this.min[2],1],[this.min[0],this.min[1],this.max[2],1],[this.max[0],this.min[1],this.max[2],1],[this.max[0],this.max[1],this.max[2],1],[this.min[0],this.max[1],this.max[2],1]];let s=!0;for(let l=0;l<t.planes.length;l++){const d=t.planes[l];let m=0;for(let g=0;g<n.length;g++)h.dot(d,n[g])>=0&&m++;if(m===0)return 0;m!==n.length&&(s=!1)}if(s)return 2;for(let l=0;l<3;l++){let d=Number.MAX_VALUE,m=-Number.MAX_VALUE;for(let g=0;g<t.points.length;g++){const y=t.points[g][l]-this.min[l];d=Math.min(d,y),m=Math.max(m,y)}if(m<0||d>this.max[l]-this.min[l])return 0}return 1}}class Qr{constructor(t=0,n=0,s=0,l=0){if(isNaN(t)||t<0||isNaN(n)||n<0||isNaN(s)||s<0||isNaN(l)||l<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=n,this.left=s,this.right=l}interpolate(t,n,s){return n.top!=null&&t.top!=null&&(this.top=h.number(t.top,n.top,s)),n.bottom!=null&&t.bottom!=null&&(this.bottom=h.number(t.bottom,n.bottom,s)),n.left!=null&&t.left!=null&&(this.left=h.number(t.left,n.left,s)),n.right!=null&&t.right!=null&&(this.right=h.number(t.right,n.right,s)),this}getCenter(t,n){const s=h.clamp((this.left+t-this.right)/2,0,t),l=h.clamp((this.top+n-this.bottom)/2,0,n);return new h.pointGeometry(s,l)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Qr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class en{constructor(t,n,s,l,d){this.tileSize=512,this.maxValidLatitude=85.051129,this.freezeElevation=!1,this._renderWorldCopies=d===void 0||!!d,this._minZoom=t||0,this._maxZoom=n||22,this._minPitch=s??0,this._maxPitch=l??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new h.LngLat(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Qr,this._posMatrixCache={},this._alignedPosMatrixCache={}}clone(){const t=new en(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.tileSize=this.tileSize,t.latRange=this.latRange,t.width=this.width,t.height=this.height,t._center=this._center,t._elevation=this._elevation,t.zoom=this.zoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._calcMatrices(),t}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(t){t===void 0?t=!0:t===null&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new h.pointGeometry(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){const n=-h.wrap(t,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=function(){var s=new h.ARRAY_TYPE(4);return h.ARRAY_TYPE!=Float32Array&&(s[1]=0,s[2]=0),s[0]=1,s[3]=1,s}(),function(s,l,d){var m=l[0],g=l[1],y=l[2],x=l[3],S=Math.sin(d),T=Math.cos(d);s[0]=m*T+y*S,s[1]=g*T+x*S,s[2]=m*-S+y*T,s[3]=g*-S+x*T}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const n=h.clamp(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(t){const n=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this.tileZoom=Math.max(0,Math.floor(n)),this.scale=this.zoomScale(n),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,n,s){this._unmodified=!1,this._edgeInsets.interpolate(t,n,s),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const n=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,n)}getVisibleUnwrappedCoordinates(t){const n=[new h.UnwrappedTileID(0,t)];if(this._renderWorldCopies){const s=this.pointCoordinate(new h.pointGeometry(0,0)),l=this.pointCoordinate(new h.pointGeometry(this.width,0)),d=this.pointCoordinate(new h.pointGeometry(this.width,this.height)),m=this.pointCoordinate(new h.pointGeometry(0,this.height)),g=Math.floor(Math.min(s.x,l.x,d.x,m.x)),y=Math.floor(Math.max(s.x,l.x,d.x,m.x)),x=1;for(let S=g-x;S<=y+x;S++)S!==0&&n.push(new h.UnwrappedTileID(S,t))}return n}coveringTiles(t){var n,s;let l=this.coveringZoomLevel(t);const d=l;if(t.minzoom!==void 0&&l<t.minzoom)return[];t.maxzoom!==void 0&&l>t.maxzoom&&(l=t.maxzoom);const m=this.pointCoordinate(this.getCameraPoint()),g=h.MercatorCoordinate.fromLngLat(this.center),y=Math.pow(2,l),x=[y*m.x,y*m.y,0],S=[y*g.x,y*g.y,0],T=ke.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,l);let M=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(M=l);const F=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,O=V=>({aabb:new Jn([V*y,0,0],[(V+1)*y,y,0]),zoom:0,x:0,y:0,wrap:V,fullyVisible:!1}),D=[],G=[],Y=l,H=t.reparseOverscaled?d:l;if(this._renderWorldCopies)for(let V=1;V<=3;V++)D.push(O(-V)),D.push(O(V));for(D.push(O(0));D.length>0;){const V=D.pop(),te=V.x,ae=V.y;let se=V.fullyVisible;if(!se){const we=V.aabb.intersects(T);if(we===0)continue;se=we===2}const ue=t.terrain?x:S,me=V.aabb.distanceX(ue),xe=V.aabb.distanceY(ue),_e=Math.max(Math.abs(me),Math.abs(xe));if(V.zoom===Y||_e>F+(1<<Y-V.zoom)-2&&V.zoom>=M){const we=Y-V.zoom,ze=x[0]-.5-(te<<we),We=x[1]-.5-(ae<<we);G.push({tileID:new h.OverscaledTileID(V.zoom===Y?H:V.zoom,V.wrap,V.zoom,te,ae),distanceSq:da([S[0]-.5-te,S[1]-.5-ae]),tileDistanceToCamera:Math.sqrt(ze*ze+We*We)})}else for(let we=0;we<4;we++){const ze=(te<<1)+we%2,We=(ae<<1)+(we>>1),Ke=V.zoom+1;let Le=V.aabb.quadrant(we);if(t.terrain){const mt=new h.OverscaledTileID(Ke,V.wrap,Ke,ze,We),ft=t.terrain.getMinMaxElevation(mt),tt=(n=ft.minElevation)!==null&&n!==void 0?n:this.elevation,ht=(s=ft.maxElevation)!==null&&s!==void 0?s:this.elevation;Le=new Jn([Le.min[0],Le.min[1],tt],[Le.max[0],Le.max[1],ht])}D.push({aabb:Le,zoom:Ke,x:ze,y:We,wrap:V.wrap,fullyVisible:se})}}return G.sort((V,te)=>V.distanceSq-te.distanceSq).map(V=>V.tileID)}resize(t,n){this.width=t,this.height=n,this.pixelsToGLUnits=[2/t,-2/n],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){const n=h.clamp(t.lat,-this.maxValidLatitude,this.maxValidLatitude);return new h.pointGeometry(h.mercatorXfromLng(t.lng)*this.worldSize,h.mercatorYfromLat(n)*this.worldSize)}unproject(t){return new h.MercatorCoordinate(t.x/this.worldSize,t.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}updateElevation(t){this.freezeElevation||(this.elevation=t?this.getElevation(this._center,t):0)}getElevation(t,n){const s=h.MercatorCoordinate.fromLngLat(t),l=(1<<this.tileZoom)*h.EXTENT,d=s.x*l,m=s.y*l,g=Math.floor(d/h.EXTENT),y=Math.floor(m/h.EXTENT),x=new h.OverscaledTileID(this.tileZoom,0,this.tileZoom,g,y);return n.getElevation(x,d%h.EXTENT,m%h.EXTENT,h.EXTENT)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(t){const n=this.pointLocation(this.centerPoint,t),s=this.getElevation(n,t);if(!(this.elevation-s))return;const l=this.getCameraPosition(),d=h.MercatorCoordinate.fromLngLat(l.lngLat,l.altitude),m=h.MercatorCoordinate.fromLngLat(n,s),g=d.x-m.x,y=d.y-m.y,x=d.z-m.z,S=Math.sqrt(g*g+y*y+x*x),T=this.scaleZoom(this.cameraToCenterDistance/S/this.tileSize);this._elevation=s,this._center=n,this.zoom=T}setLocationAtPoint(t,n){const s=this.pointCoordinate(n),l=this.pointCoordinate(this.centerPoint),d=this.locationCoordinate(t),m=new h.MercatorCoordinate(d.x-(s.x-l.x),d.y-(s.y-l.y));this.center=this.coordinateLocation(m),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,n){return n?this.coordinatePoint(this.locationCoordinate(t),this.getElevation(t,n),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,n){return this.coordinateLocation(this.pointCoordinate(t,n))}locationCoordinate(t){return h.MercatorCoordinate.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,n){if(n){const M=n.pointCoordinate(t);if(M!=null)return M}const s=[t.x,t.y,0,1],l=[t.x,t.y,1,1];h.transformMat4(s,s,this.pixelMatrixInverse),h.transformMat4(l,l,this.pixelMatrixInverse);const d=s[3],m=l[3],g=s[1]/d,y=l[1]/m,x=s[2]/d,S=l[2]/m,T=x===S?0:(0-x)/(S-x);return new h.MercatorCoordinate(h.number(s[0]/d,l[0]/m,T)/this.worldSize,h.number(g,y,T)/this.worldSize)}coordinatePoint(t,n=0,s=this.pixelMatrix){const l=[t.x*this.worldSize,t.y*this.worldSize,n,1];return h.transformMat4(l,l,s),new h.pointGeometry(l[0]/l[3],l[1]/l[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return new h.LngLatBounds().extend(this.pointLocation(new h.pointGeometry(0,t))).extend(this.pointLocation(new h.pointGeometry(this.width,t))).extend(this.pointLocation(new h.pointGeometry(this.width,this.height))).extend(this.pointLocation(new h.pointGeometry(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new h.LngLatBounds([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-this.maxValidLatitude,this.maxValidLatitude])}calculatePosMatrix(t,n=!1){const s=t.key,l=n?this._alignedPosMatrixCache:this._posMatrixCache;if(l[s])return l[s];const d=t.canonical,m=this.worldSize/this.zoomScale(d.z),g=d.x+Math.pow(2,d.z)*t.wrap,y=h.identity(new Float64Array(16));return h.translate(y,y,[g*m,d.y*m,0]),h.scale(y,y,[m/h.EXTENT,m/h.EXTENT,1]),h.multiply(y,n?this.alignedProjMatrix:this.projMatrix,y),l[s]=new Float32Array(y),l[s]}customLayerMatrix(){return this.mercatorMatrix.slice()}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let t,n,s,l,d=-90,m=90,g=-180,y=180;const x=this.size,S=this._unmodified;if(this.latRange){const F=this.latRange;d=h.mercatorYfromLat(F[1])*this.worldSize,m=h.mercatorYfromLat(F[0])*this.worldSize,t=m-d<x.y?x.y/(m-d):0}if(this.lngRange){const F=this.lngRange;g=h.wrap(h.mercatorXfromLng(F[0])*this.worldSize,0,this.worldSize),y=h.wrap(h.mercatorXfromLng(F[1])*this.worldSize,0,this.worldSize),y<g&&(y+=this.worldSize),n=y-g<x.x?x.x/(y-g):0}const T=this.point,M=Math.max(n||0,t||0);if(M)return this.center=this.unproject(new h.pointGeometry(n?(y+g)/2:T.x,t?(m+d)/2:T.y)),this.zoom+=this.scaleZoom(M),this._unmodified=S,void(this._constraining=!1);if(this.latRange){const F=T.y,O=x.y/2;F-O<d&&(l=d+O),F+O>m&&(l=m-O)}if(this.lngRange){const F=(g+y)/2,O=h.wrap(T.x,F-this.worldSize/2,F+this.worldSize/2),D=x.x/2;O-D<g&&(s=g+D),O+D>y&&(s=y-D)}s===void 0&&l===void 0||(this.center=this.unproject(new h.pointGeometry(s!==void 0?s:T.x,l!==void 0?l:T.y)).wrap()),this._unmodified=S,this._constraining=!1}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,n=this.point.x,s=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=h.mercatorZfromAltitude(1,this.center.lat)*this.worldSize;let l=h.identity(new Float64Array(16));h.scale(l,l,[this.width/2,-this.height/2,1]),h.translate(l,l,[1,-1,0]),this.labelPlaneMatrix=l,l=h.identity(new Float64Array(16)),h.scale(l,l,[1,-1,1]),h.translate(l,l,[-1,-1,0]),h.scale(l,l,[2/this.width,2/this.height,1]),this.glCoordMatrix=l,this.cameraToSeaLevelDistance=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch);const d=this._elevation<0?this.cameraToCenterDistance:this.cameraToSeaLevelDistance,m=Math.PI/2+this._pitch,g=this._fov*(.5+t.y/this.height),y=Math.sin(g)*d/Math.sin(h.clamp(Math.PI-m-g,.01,Math.PI-.01)),x=this.getHorizon(),S=2*Math.atan(x/this.cameraToCenterDistance)*(.5+t.y/(2*x)),T=Math.sin(S)*d/Math.sin(h.clamp(Math.PI-m-S,.01,Math.PI-.01)),M=Math.min(y,T),F=1.01*(Math.cos(Math.PI/2-this._pitch)*M+d),O=this.height/50;l=new Float64Array(16),h.perspective(l,this._fov,this.width/this.height,O,F),l[8]=2*-t.x/this.width,l[9]=2*t.y/this.height,h.scale(l,l,[1,-1,1]),h.translate(l,l,[0,0,-this.cameraToCenterDistance]),h.rotateX(l,l,this._pitch),h.rotateZ(l,l,this.angle),h.translate(l,l,[-n,-s,0]),this.mercatorMatrix=h.scale([],l,[this.worldSize,this.worldSize,this.worldSize]),h.scale(l,l,[1,1,this._pixelPerMeter]),this.pixelMatrix=h.multiply(new Float64Array(16),this.labelPlaneMatrix,l),h.translate(l,l,[0,0,-this.elevation]),this.projMatrix=l,this.invProjMatrix=h.invert([],l),this.pixelMatrix3D=h.multiply(new Float64Array(16),this.labelPlaneMatrix,l);const D=this.width%2/2,G=this.height%2/2,Y=Math.cos(this.angle),H=Math.sin(this.angle),V=n-Math.round(n)+Y*D+H*G,te=s-Math.round(s)+Y*G+H*D,ae=new Float64Array(l);if(h.translate(ae,ae,[V>.5?V-1:V,te>.5?te-1:te,0]),this.alignedProjMatrix=ae,l=h.invert(new Float64Array(16),this.pixelMatrix),!l)throw new Error("failed to invert matrix");this.pixelMatrixInverse=l,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const t=this.pointCoordinate(new h.pointGeometry(0,0)),n=[t.x*this.worldSize,t.y*this.worldSize,0,1];return h.transformMat4(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new h.pointGeometry(0,t))}getCameraQueryGeometry(t){const n=this.getCameraPoint();if(t.length===1)return[t[0],n];{let s=n.x,l=n.y,d=n.x,m=n.y;for(const g of t)s=Math.min(s,g.x),l=Math.min(l,g.y),d=Math.max(d,g.x),m=Math.max(m,g.y);return[new h.pointGeometry(s,l),new h.pointGeometry(d,l),new h.pointGeometry(d,m),new h.pointGeometry(s,m),new h.pointGeometry(s,l)]}}}class ol{constructor(t){this._hashName=t&&encodeURIComponent(t),h.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=function(n,s){let l=!1,d=null;const m=()=>{d=null,l&&(n(),d=setTimeout(m,300),l=!1)};return()=>(l=!0,d||m(),d)}(this._updateHashUnthrottled.bind(this))}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(t){const n=this._map.getCenter(),s=Math.round(100*this._map.getZoom())/100,l=Math.ceil((s*Math.LN2+Math.log(512/360/.5))/Math.LN10),d=Math.pow(10,l),m=Math.round(n.lng*d)/d,g=Math.round(n.lat*d)/d,y=this._map.getBearing(),x=this._map.getPitch();let S="";if(S+=t?`/${m}/${g}/${s}`:`${s}/${g}/${m}`,(y||x)&&(S+="/"+Math.round(10*y)/10),x&&(S+=`/${Math.round(x)}`),this._hashName){const T=this._hashName;let M=!1;const F=window.location.hash.slice(1).split("&").map(O=>{const D=O.split("=")[0];return D===T?(M=!0,`${D}=${S}`):O}).filter(O=>O);return M||F.push(`${T}=${S}`),`#${F.join("&")}`}return`#${S}`}_getCurrentHash(){const t=window.location.hash.replace("#","");if(this._hashName){let n;return t.split("&").map(s=>s.split("=")).forEach(s=>{s[0]===this._hashName&&(n=s)}),(n&&n[1]||"").split("/")}return t.split("/")}_onHashChange(){const t=this._getCurrentHash();if(t.length>=3&&!t.some(n=>isNaN(n))){const n=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:n,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){const t=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,t)}catch{}}}const Ae={linearity:.3,easing:h.bezier(0,0,.3,1)},Os=h.extend({deceleration:2500,maxSpeed:1400},Ae),lc=h.extend({deceleration:20,maxSpeed:1400},Ae),cc=h.extend({deceleration:1e3,maxSpeed:360},Ae),Us=h.extend({deceleration:1e3,maxSpeed:90},Ae);class ll{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:h.exported.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=h.exported.now();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new h.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:d}of this._inertiaBuffer)n.zoom+=d.zoomDelta||0,n.bearing+=d.bearingDelta||0,n.pitch+=d.pitchDelta||0,d.panDelta&&n.pan._add(d.panDelta),d.around&&(n.around=d.around),d.pinchAround&&(n.pinchAround=d.pinchAround);const s=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,l={};if(n.pan.mag()){const d=Ra(n.pan.mag(),s,h.extend({},Os,t||{}));l.offset=n.pan.mult(d.amount/n.pan.mag()),l.center=this._map.transform.center,Qn(l,d)}if(n.zoom){const d=Ra(n.zoom,s,lc);l.zoom=this._map.transform.zoom+d.amount,Qn(l,d)}if(n.bearing){const d=Ra(n.bearing,s,cc);l.bearing=this._map.transform.bearing+h.clamp(d.amount,-179,179),Qn(l,d)}if(n.pitch){const d=Ra(n.pitch,s,Us);l.pitch=this._map.transform.pitch+d.amount,Qn(l,d)}if(l.zoom||l.bearing){const d=n.pinchAround===void 0?n.around:n.pinchAround;l.around=d?this._map.unproject(d):this._map.getCenter()}return this.clear(),h.extend(l,{noMoveStart:!0})}}function Qn(o,t){(!o.duration||o.duration<t.duration)&&(o.duration=t.duration,o.easing=t.easing)}function Ra(o,t,n){const{maxSpeed:s,linearity:l,deceleration:d}=n,m=h.clamp(o*l/(t/1e3),-s,s),g=Math.abs(m)/(d*l);return{easing:n.easing,duration:1e3*g,amount:m*(g/2)}}class Gi extends h.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,s,l={}){const d=ee.mousePos(n.getCanvasContainer(),s),m=n.unproject(d);super(t,h.extend({point:d,lngLat:m,originalEvent:s},l)),this._defaultPrevented=!1,this.target=n}}class kn extends h.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,s){const l=t==="touchend"?s.changedTouches:s.touches,d=ee.touchPos(n.getCanvasContainer(),l),m=d.map(y=>n.unproject(y)),g=d.reduce((y,x,S,T)=>y.add(x.div(T.length)),new h.pointGeometry(0,0));super(t,{points:d,point:g,lngLats:m,lngLat:n.unproject(g),originalEvent:s}),this._defaultPrevented=!1}}class Vs extends h.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,s){super(t,{originalEvent:s}),this._defaultPrevented=!1}}class Ns{constructor(t,n){this._map=t,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new Vs(t.type,this._map,t))}mousedown(t,n){return this._mousedownPos=n,this._firePreventable(new Gi(t.type,this._map,t))}mouseup(t){this._map.fire(new Gi(t.type,this._map,t))}click(t,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new Gi(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Gi(t.type,this._map,t))}mouseover(t){this._map.fire(new Gi(t.type,this._map,t))}mouseout(t){this._map.fire(new Gi(t.type,this._map,t))}touchstart(t){return this._firePreventable(new kn(t.type,this._map,t))}touchmove(t){this._map.fire(new kn(t.type,this._map,t))}touchend(t){this._map.fire(new kn(t.type,this._map,t))}touchcancel(t){this._map.fire(new kn(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class $s{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Gi(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Gi("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Gi(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Si{constructor(t,n){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,n){this.isEnabled()&&t.shiftKey&&t.button===0&&(ee.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(t,n){if(!this._active)return;const s=n;if(this._lastPos.equals(s)||!this._box&&s.dist(this._startPos)<this._clickTolerance)return;const l=this._startPos;this._lastPos=s,this._box||(this._box=ee.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));const d=Math.min(l.x,s.x),m=Math.max(l.x,s.x),g=Math.min(l.y,s.y),y=Math.max(l.y,s.y);ee.setTransform(this._box,`translate(${d}px,${g}px)`),this._box.style.width=m-d+"px",this._box.style.height=y-g+"px"}mouseupWindow(t,n){if(!this._active||t.button!==0)return;const s=this._startPos,l=n;if(this.reset(),ee.suppressClick(),s.x!==l.x||s.y!==l.y)return this._map.fire(new h.Event("boxzoomend",{originalEvent:t})),{cameraAnimation:d=>d.fitScreenCoordinates(s,l,this._map.getBearing(),{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&t.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(ee.remove(this._box),this._box=null),ee.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new h.Event(t,{originalEvent:n}))}}function lr(o,t){if(o.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${o.length}, points ${t.length}`);const n={};for(let s=0;s<o.length;s++)n[o[s].identifier]=t[s];return n}class cl{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,n,s){(this.centroid||s.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=t.timeStamp),s.length===this.numTouches&&(this.centroid=function(l){const d=new h.pointGeometry(0,0);for(const m of l)d._add(m);return d.div(l.length)}(n),this.touches=lr(s,n)))}touchmove(t,n,s){if(this.aborted||!this.centroid)return;const l=lr(s,n);for(const d in this.touches){const m=l[d];(!m||m.dist(this.touches[d])>30)&&(this.aborted=!0)}}touchend(t,n,s){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),s.length===0){const l=!this.aborted&&this.centroid;if(this.reset(),l)return l}}}class ea{constructor(t){this.singleTap=new cl(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,n,s){this.singleTap.touchstart(t,n,s)}touchmove(t,n,s){this.singleTap.touchmove(t,n,s)}touchend(t,n,s){const l=this.singleTap.touchend(t,n,s);if(l){const d=t.timeStamp-this.lastTime<500,m=!this.lastTap||this.lastTap.dist(l)<30;if(d&&m||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=l,this.count===this.numTaps)return this.reset(),l}}}class Gs{constructor(){this._zoomIn=new ea({numTouches:1,numTaps:2}),this._zoomOut=new ea({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,n,s){this._zoomIn.touchstart(t,n,s),this._zoomOut.touchstart(t,n,s)}touchmove(t,n,s){this._zoomIn.touchmove(t,n,s),this._zoomOut.touchmove(t,n,s)}touchend(t,n,s){const l=this._zoomIn.touchend(t,n,s),d=this._zoomOut.touchend(t,n,s);return l?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:m=>m.easeTo({duration:300,zoom:m.getZoom()+1,around:m.unproject(l)},{originalEvent:t})}):d?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:m=>m.easeTo({duration:300,zoom:m.getZoom()-1,around:m.unproject(d)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class tn{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const n=this._moveFunction(...t);if(n.bearingDelta||n.pitchDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(t,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=n.length?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,n){if(!this.isEnabled())return;const s=this._lastPoint;if(!s)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const l=n.length?n[0]:n;return!this._moved&&l.dist(s)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=l,this._move(s,l))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&ee.suppressClick(),this.reset(t))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const hl={0:1,2:2};class Ei{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){const n=ee.mouseButton(t);this._eventButton=n}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!function(n,s){const l=hl[s];return n.buttons===void 0||(n.buttons&l)!==l}(t,this._eventButton)}isValidEndEvent(t){return ee.mouseButton(t)===this._eventButton}}class Pt{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return t.targetTouches.length===1}_isSameTouchEvent(t){return t.targetTouches[0].identifier===this._firstTouch}startMove(t){this._firstTouch=t.targetTouches[0].identifier}endMove(t){delete this._firstTouch}isValidStartEvent(t){return this._isOneFingerTouch(t)}isValidMoveEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}isValidEndEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}}const zn=o=>{o.mousedown=o.dragStart,o.mousemoveWindow=o.dragMove,o.mouseup=o.dragEnd,o.contextmenu=function(t){t.preventDefault()}},Ba=({enable:o,clickTolerance:t,bearingDegreesPerPixelMoved:n=.8})=>{const s=new Ei({checkCorrectEvent:l=>ee.mouseButton(l)===0&&l.ctrlKey||ee.mouseButton(l)===2});return new tn({clickTolerance:t,move:(l,d)=>({bearingDelta:(d.x-l.x)*n}),moveStateManager:s,enable:o,assignEvents:zn})},js=({enable:o,clickTolerance:t,pitchDegreesPerPixelMoved:n=-.5})=>{const s=new Ei({checkCorrectEvent:l=>ee.mouseButton(l)===0&&l.ctrlKey||ee.mouseButton(l)===2});return new tn({clickTolerance:t,move:(l,d)=>({pitchDelta:(d.y-l.y)*n}),moveStateManager:s,enable:o,assignEvents:zn})};class ul{constructor(t,n){this._minTouches=t.cooperativeGestures?2:1,this._clickTolerance=t.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new h.pointGeometry(0,0),setTimeout(()=>{this._cancelCooperativeMessage=!1},200)}touchstart(t,n,s){return this._calculateTransform(t,n,s)}touchmove(t,n,s){if(this._map._cooperativeGestures&&(this._minTouches===2&&s.length<2&&!this._cancelCooperativeMessage?this._map._onCooperativeGesture(t,!1,s.length):this._cancelCooperativeMessage||(this._cancelCooperativeMessage=!0)),this._active&&!(s.length<this._minTouches))return t.preventDefault(),this._calculateTransform(t,n,s)}touchend(t,n,s){this._calculateTransform(t,n,s),this._active&&s.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,n,s){s.length>0&&(this._active=!0);const l=lr(s,n),d=new h.pointGeometry(0,0),m=new h.pointGeometry(0,0);let g=0;for(const x in l){const S=l[x],T=this._touches[x];T&&(d._add(S),m._add(S.sub(T)),g++,l[x]=S)}if(this._touches=l,g<this._minTouches||!m.mag())return;const y=m.div(g);return this._sum._add(y),this._sum.mag()<this._clickTolerance?void 0:{around:d.div(g),panDelta:y}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Fa{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}_start(t){}_move(t,n,s){return{}}touchstart(t,n,s){this._firstTwoTouches||s.length<2||(this._firstTwoTouches=[s[0].identifier,s[1].identifier],this._start([n[0],n[1]]))}touchmove(t,n,s){if(!this._firstTwoTouches)return;t.preventDefault();const[l,d]=this._firstTwoTouches,m=Oa(s,n,l),g=Oa(s,n,d);if(!m||!g)return;const y=this._aroundCenter?null:m.add(g).div(2);return this._move([m,g],y,t)}touchend(t,n,s){if(!this._firstTwoTouches)return;const[l,d]=this._firstTwoTouches,m=Oa(s,n,l),g=Oa(s,n,d);m&&g||(this._active&&ee.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&t.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Oa(o,t,n){for(let s=0;s<o.length;s++)if(o[s].identifier===n)return t[s]}function Ki(o,t){return Math.log(o/t)/Math.LN2}class Ua extends Fa{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,n){const s=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(Ki(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Ki(this._distance,s),pinchAround:n}}}function Oe(o,t){return 180*o.angleWith(t)/Math.PI}class Ze extends Fa{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,n){const s=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Oe(this._vector,s),pinchAround:n}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const n=25/(Math.PI*this._minDiameter)*360,s=Oe(t,this._startVector);return Math.abs(s)<n}}function Ln(o){return Math.abs(o.y)>Math.abs(o.x)}class qs extends Fa{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,n,s){super.touchstart(t,n,s),this._currentTouchCount=s.length}_start(t){this._lastPoints=t,Ln(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,n,s){if(this._map._cooperativeGestures&&this._currentTouchCount<3)return;const l=t[0].sub(this._lastPoints[0]),d=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(l,d,s.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(l.y+d.y)/2*-.5}):void 0}gestureBeginsVertically(t,n,s){if(this._valid!==void 0)return this._valid;const l=t.mag()>=2,d=n.mag()>=2;if(!l&&!d)return;if(!l||!d)return this._firstMove===void 0&&(this._firstMove=s),s-this._firstMove<100&&void 0;const m=t.y>0==n.y>0;return Ln(t)&&Ln(n)&&m}}const Zs={panStep:100,bearingStep:15,pitchStep:10};class Ii{constructor(){const t=Zs;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=0,s=0,l=0,d=0,m=0;switch(t.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:t.shiftKey?s=-1:(t.preventDefault(),d=-1);break;case 39:t.shiftKey?s=1:(t.preventDefault(),d=1);break;case 38:t.shiftKey?l=1:(t.preventDefault(),m=-1);break;case 40:t.shiftKey?l=-1:(t.preventDefault(),m=1);break;default:return}return this._rotationDisabled&&(s=0,l=0),{cameraAnimation:g=>{const y=g.getZoom();g.easeTo({duration:300,easeId:"keyboardHandler",easing:Va,zoom:n?Math.round(y)+n*(t.shiftKey?2:1):y,bearing:g.getBearing()+s*this._bearingStep,pitch:g.getPitch()+l*this._pitchStep,offset:[-d*this._panStep,-m*this._panStep],center:g.getCenter()},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Va(o){return o*(2-o)}const Yi=4.000244140625;class hc{constructor(t,n){this._map=t,this._el=t.getCanvasContainer(),this._handler=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,h.bindAll(["_onTimeout"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=t&&t.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!this._map._metaPress)return;t.preventDefault()}let n=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const s=h.exported.now(),l=s-(this._lastWheelEventTime||0);this._lastWheelEventTime=s,n!==0&&n%Yi==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":l>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(l*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const n=ee.mousePos(this._el,t);this._around=h.LngLat.convert(this._aroundCenter?this._map.getCenter():this._map.unproject(n)),this._aroundPoint=this._map.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const t=this._map.transform;if(this._delta!==0){const g=this._type==="wheel"&&Math.abs(this._delta)>Yi?this._wheelZoomRate:this._defaultZoomRate;let y=2/(1+Math.exp(-Math.abs(this._delta*g)));this._delta<0&&y!==0&&(y=1/y);const x=typeof this._targetZoom=="number"?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(x*y))),this._type==="wheel"&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom=="number"?this._targetZoom:t.zoom,s=this._startZoom,l=this._easing;let d,m=!1;if(this._type==="wheel"&&s&&l){const g=Math.min((h.exported.now()-this._lastWheelEventTime)/200,1),y=l(g);d=h.number(s,n,y),g<1?this._frameId||(this._frameId=!0):m=!0}else d=n,m=!0;return this._active=!0,m&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!m,zoomDelta:d-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=h.ease;if(this._prevEase){const s=this._prevEase,l=(h.exported.now()-s.start)/s.duration,d=s.easing(l+.01)-s.easing(l),m=.27/Math.sqrt(d*d+1e-4)*.01,g=Math.sqrt(.0729-m*m);n=h.bezier(m,g,.25,1)}return this._prevEase={start:h.exported.now(),duration:t,easing:n},n}reset(){this._active=!1}}class Na{constructor(t,n){this._clickZoom=t,this._tapZoom=n}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Ut{constructor(){this.reset()}reset(){this._active=!1}dblclick(t,n){return t.preventDefault(),{cameraAnimation:s=>{s.easeTo({duration:300,zoom:s.getZoom()+(t.shiftKey?-1:1),around:s.unproject(n)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class jt{constructor(){this._tap=new ea({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(t,n,s){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?s.length>0&&(this._swipePoint=n[0],this._swipeTouch=s[0].identifier):this._tap.touchstart(t,n,s))}touchmove(t,n,s){if(this._tapTime){if(this._swipePoint){if(s[0].identifier!==this._swipeTouch)return;const l=n[0],d=l.y-this._swipePoint.y;return this._swipePoint=l,t.preventDefault(),this._active=!0,{zoomDelta:d/128}}}else this._tap.touchmove(t,n,s)}touchend(t,n,s){this._tapTime?this._swipePoint&&s.length===0&&this.reset():this._tap.touchend(t,n,s)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class dl{constructor(t,n,s){this._el=t,this._mousePan=n,this._touchPan=s}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class ta{constructor(t,n,s){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=n,this._mousePitch=s}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class $a{constructor(t,n,s,l){this._el=t,this._touchZoom=n,this._touchRotate=s,this._tapDragZoom=l,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Dn=o=>o.zoom||o.drag||o.pitch||o.rotate;class Xs extends h.Event{}function ia(o){return o.panDelta&&o.panDelta.mag()||o.zoomDelta||o.bearingDelta||o.pitchDelta}class ra{constructor(t,n){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ll(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n),h.bindAll(["handleEvent","handleWindowEvent"],this);const s=this._el;this._listeners=[[s,"touchstart",{passive:!0}],[s,"touchmove",{passive:!1}],[s,"touchend",void 0],[s,"touchcancel",void 0],[s,"mousedown",void 0],[s,"mousemove",void 0],[s,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[s,"mouseover",void 0],[s,"mouseout",void 0],[s,"dblclick",void 0],[s,"click",void 0],[s,"keydown",{capture:!1}],[s,"keyup",void 0],[s,"wheel",{passive:!1}],[s,"contextmenu",void 0],[window,"blur",void 0]];for(const[l,d,m]of this._listeners)ee.addEventListener(l,d,l===document?this.handleWindowEvent:this.handleEvent,m)}destroy(){for(const[t,n,s]of this._listeners)ee.removeEventListener(t,n,t===document?this.handleWindowEvent:this.handleEvent,s)}_addDefaultHandlers(t){const n=this._map,s=n.getCanvasContainer();this._add("mapEvent",new Ns(n,t));const l=n.boxZoom=new Si(n,t);this._add("boxZoom",l);const d=new Gs,m=new Ut;n.doubleClickZoom=new Na(m,d),this._add("tapZoom",d),this._add("clickZoom",m);const g=new jt;this._add("tapDragZoom",g);const y=n.touchPitch=new qs(n);this._add("touchPitch",y);const x=Ba(t),S=js(t);n.dragRotate=new ta(t,x,S),this._add("mouseRotate",x,["mousePitch"]),this._add("mousePitch",S,["mouseRotate"]);const T=(({enable:Y,clickTolerance:H})=>{const V=new Ei({checkCorrectEvent:te=>ee.mouseButton(te)===0&&!te.ctrlKey});return new tn({clickTolerance:H,move:(te,ae)=>({around:ae,panDelta:ae.sub(te)}),activateOnStart:!0,moveStateManager:V,enable:Y,assignEvents:zn})})(t),M=new ul(t,n);n.dragPan=new dl(s,T,M),this._add("mousePan",T),this._add("touchPan",M,["touchZoom","touchRotate"]);const F=new Ze,O=new Ua;n.touchZoomRotate=new $a(s,O,F,g),this._add("touchRotate",F,["touchPan","touchZoom"]),this._add("touchZoom",O,["touchPan","touchRotate"]);const D=n.scrollZoom=new hc(n,this);this._add("scrollZoom",D,["mousePan"]);const G=n.keyboard=new Ii;this._add("keyboard",G),this._add("blockableMapEvent",new $s(n));for(const Y of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[Y]&&n[Y].enable(t[Y])}_add(t,n,s){this._handlers.push({handlerName:t,handler:n,allowed:s}),this._handlersById[t]=n}stop(t){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Dn(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,n,s){for(const l in t)if(l!==s&&(!n||n.indexOf(l)<0))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){const n=[];for(const s of t)this._el.contains(s.target)&&n.push(s);return n}handleEvent(t,n){if(t.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const s=t.type==="renderFrame"?void 0:t,l={needsRenderFrame:!1},d={},m={},g=t.touches,y=g?this._getMapTouches(g):void 0,x=y?ee.touchPos(this._el,y):ee.mousePos(this._el,t);for(const{handlerName:M,handler:F,allowed:O}of this._handlers){if(!F.isEnabled())continue;let D;this._blockedByActive(m,O,M)?F.reset():F[n||t.type]&&(D=F[n||t.type](t,x,y),this.mergeHandlerResult(l,d,D,M,s),D&&D.needsRenderFrame&&this._triggerRenderFrame()),(D||F.isActive())&&(m[M]=F)}const S={};for(const M in this._previousActiveHandlers)m[M]||(S[M]=s);this._previousActiveHandlers=m,(Object.keys(S).length||ia(l))&&(this._changes.push([l,d,S]),this._triggerRenderFrame()),(Object.keys(m).length||ia(l))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:T}=l;T&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],T(this._map))}mergeHandlerResult(t,n,s,l,d){if(!s)return;h.extend(t,s);const m={handlerName:l,originalEvent:s.originalEvent||d};s.zoomDelta!==void 0&&(n.zoom=m),s.panDelta!==void 0&&(n.drag=m),s.pitchDelta!==void 0&&(n.pitch=m),s.bearingDelta!==void 0&&(n.rotate=m)}_applyChanges(){const t={},n={},s={};for(const[l,d,m]of this._changes)l.panDelta&&(t.panDelta=(t.panDelta||new h.pointGeometry(0,0))._add(l.panDelta)),l.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+l.zoomDelta),l.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+l.bearingDelta),l.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+l.pitchDelta),l.around!==void 0&&(t.around=l.around),l.pinchAround!==void 0&&(t.pinchAround=l.pinchAround),l.noInertia&&(t.noInertia=l.noInertia),h.extend(n,d),h.extend(s,m);this._updateMapTransform(t,n,s),this._changes=[]}_updateMapTransform(t,n,s){const l=this._map,d=l.transform,m=l.terrain;if(!(ia(t)||m&&this._terrainMovement))return this._fireEvents(n,s,!0);let{panDelta:g,zoomDelta:y,bearingDelta:x,pitchDelta:S,around:T,pinchAround:M}=t;M!==void 0&&(T=M),l._stop(!0),T=T||l.transform.centerPoint;const F=d.pointLocation(g?T.sub(g):T);x&&(d.bearing+=x),S&&(d.pitch+=S),y&&(d.zoom+=y),m?this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?d.center=d.pointLocation(d.centerPoint.sub(g)):d.setLocationAtPoint(F,T):(this._terrainMovement=!0,d.freezeElevation=!0,d.setLocationAtPoint(F,T),this._map.once("moveend",()=>{d.freezeElevation=!1,this._terrainMovement=!1,d.recalculateZoom(l.terrain)})):d.setLocationAtPoint(F,T),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,s,!0)}_fireEvents(t,n,s){const l=Dn(this._eventsInProgress),d=Dn(t),m={};for(const S in t){const{originalEvent:T}=t[S];this._eventsInProgress[S]||(m[`${S}start`]=T),this._eventsInProgress[S]=t[S]}!l&&d&&this._fireEvent("movestart",d.originalEvent);for(const S in m)this._fireEvent(S,m[S]);d&&this._fireEvent("move",d.originalEvent);for(const S in t){const{originalEvent:T}=t[S];this._fireEvent(S,T)}const g={};let y;for(const S in this._eventsInProgress){const{handlerName:T,originalEvent:M}=this._eventsInProgress[S];this._handlersById[T].isActive()||(delete this._eventsInProgress[S],y=n[T]||M,g[`${S}end`]=y)}for(const S in g)this._fireEvent(S,g[S]);const x=Dn(this._eventsInProgress);if(s&&(l||d)&&!x){this._updatingCamera=!0;const S=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),T=M=>M!==0&&-this._bearingSnap<M&&M<this._bearingSnap;S?(T(S.bearing||this._map.getBearing())&&(S.bearing=0),S.freezeElevation=!0,this._map.easeTo(S,{originalEvent:y})):(this._map.fire(new h.Event("moveend",{originalEvent:y})),T(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,n){this._map.fire(new h.Event(t,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(t=>{delete this._frameId,this.handleEvent(new Xs("renderFrame",{timeStamp:t})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const Ws={extend:(o,...t)=>h.extend(o,...t),run(o){o()},logToElement(o,t=!1,n="log"){const s=window.document.getElementById(n);s&&(t&&(s.innerHTML=""),s.innerHTML+=`<br>${o}`)}};class Hs extends h.Evented{constructor(t,n){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=n.bearingSnap,h.bindAll(["_renderFrameCallback"],this)}getCenter(){return new h.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(t,n){return this.jumpTo({center:t},n)}panBy(t,n,s){return t=h.pointGeometry.convert(t).mult(-1),this.panTo(this.transform.center,h.extend({offset:t},n),s)}panTo(t,n,s){return this.easeTo(h.extend({center:t},n),s)}getZoom(){return this.transform.zoom}setZoom(t,n){return this.jumpTo({zoom:t},n),this}zoomTo(t,n,s){return this.easeTo(h.extend({zoom:t},n),s)}zoomIn(t,n){return this.zoomTo(this.getZoom()+1,t,n),this}zoomOut(t,n){return this.zoomTo(this.getZoom()-1,t,n),this}getBearing(){return this.transform.bearing}setBearing(t,n){return this.jumpTo({bearing:t},n),this}getPadding(){return this.transform.padding}setPadding(t,n){return this.jumpTo({padding:t},n),this}rotateTo(t,n,s){return this.easeTo(h.extend({bearing:t},n),s)}resetNorth(t,n){return this.rotateTo(0,h.extend({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(h.extend({bearing:0,pitch:0,duration:1e3},t),n),this}snapToNorth(t,n){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,n):this}getPitch(){return this.transform.pitch}setPitch(t,n){return this.jumpTo({pitch:t},n),this}cameraForBounds(t,n){t=h.LngLatBounds.convert(t);const s=n&&n.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),s,n)}_cameraForBoxAndBearing(t,n,s,l){const d={top:0,bottom:0,right:0,left:0};if(typeof(l=h.extend({padding:d,offset:[0,0],maxZoom:this.transform.maxZoom},l)).padding=="number"){const ae=l.padding;l.padding={top:ae,bottom:ae,right:ae,left:ae}}l.padding=h.extend(d,l.padding);const m=this.transform,g=m.padding,y=m.project(h.LngLat.convert(t)),x=m.project(h.LngLat.convert(n)),S=y.rotate(-s*Math.PI/180),T=x.rotate(-s*Math.PI/180),M=new h.pointGeometry(Math.max(S.x,T.x),Math.max(S.y,T.y)),F=new h.pointGeometry(Math.min(S.x,T.x),Math.min(S.y,T.y)),O=M.sub(F),D=(m.width-(g.left+g.right+l.padding.left+l.padding.right))/O.x,G=(m.height-(g.top+g.bottom+l.padding.top+l.padding.bottom))/O.y;if(G<0||D<0)return void h.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const Y=Math.min(m.scaleZoom(m.scale*Math.min(D,G)),l.maxZoom),H=h.pointGeometry.convert(l.offset),V=new h.pointGeometry((l.padding.left-l.padding.right)/2,(l.padding.top-l.padding.bottom)/2).rotate(s*Math.PI/180),te=H.add(V).mult(m.scale/m.zoomScale(Y));return{center:m.unproject(y.add(x).div(2).sub(te)),zoom:Y,bearing:s}}fitBounds(t,n,s){return this._fitInternal(this.cameraForBounds(t,n),n,s)}fitScreenCoordinates(t,n,s,l,d){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(h.pointGeometry.convert(t)),this.transform.pointLocation(h.pointGeometry.convert(n)),s,l),l,d)}_fitInternal(t,n,s){return t?(delete(n=h.extend(t,n)).padding,n.linear?this.easeTo(n,s):this.flyTo(n,s)):this}jumpTo(t,n){this.stop();const s=this.transform;let l=!1,d=!1,m=!1;return"zoom"in t&&s.zoom!==+t.zoom&&(l=!0,s.zoom=+t.zoom),t.center!==void 0&&(s.center=h.LngLat.convert(t.center)),"bearing"in t&&s.bearing!==+t.bearing&&(d=!0,s.bearing=+t.bearing),"pitch"in t&&s.pitch!==+t.pitch&&(m=!0,s.pitch=+t.pitch),t.padding==null||s.isPaddingEqual(t.padding)||(s.padding=t.padding),this.fire(new h.Event("movestart",n)).fire(new h.Event("move",n)),l&&this.fire(new h.Event("zoomstart",n)).fire(new h.Event("zoom",n)).fire(new h.Event("zoomend",n)),d&&this.fire(new h.Event("rotatestart",n)).fire(new h.Event("rotate",n)).fire(new h.Event("rotateend",n)),m&&this.fire(new h.Event("pitchstart",n)).fire(new h.Event("pitch",n)).fire(new h.Event("pitchend",n)),this.fire(new h.Event("moveend",n))}calculateCameraOptionsFromTo(t,n,s,l=0){const d=h.MercatorCoordinate.fromLngLat(t,n),m=h.MercatorCoordinate.fromLngLat(s,l),g=m.x-d.x,y=m.y-d.y,x=m.z-d.z,S=Math.hypot(g,y,x);if(S===0)throw new Error("Can't calculate camera options with same From and To");const T=Math.hypot(g,y),M=this.transform.scaleZoom(this.transform.cameraToCenterDistance/S/this.transform.tileSize),F=180*Math.atan2(g,-y)/Math.PI;let O=180*Math.acos(T/S)/Math.PI;return O=x<0?90-O:90+O,{center:m.toLngLat(),zoom:M,pitch:O,bearing:F}}easeTo(t,n){this._stop(!1,t.easeId),((t=h.extend({offset:[0,0],duration:500,easing:h.ease},t)).animate===!1||!t.essential&&h.exported.prefersReducedMotion)&&(t.duration=0);const s=this.transform,l=this.getZoom(),d=this.getBearing(),m=this.getPitch(),g=this.getPadding(),y="zoom"in t?+t.zoom:l,x="bearing"in t?this._normalizeBearing(t.bearing,d):d,S="pitch"in t?+t.pitch:m,T="padding"in t?t.padding:s.padding,M=h.pointGeometry.convert(t.offset);let F=s.centerPoint.add(M);const O=s.pointLocation(F),D=h.LngLat.convert(t.center||O);this._normalizeCenter(D);const G=s.project(O),Y=s.project(D).sub(G),H=s.zoomScale(y-l);let V,te;t.around&&(V=h.LngLat.convert(t.around),te=s.locationPoint(V));const ae={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||y!==l,this._rotating=this._rotating||d!==x,this._pitching=this._pitching||S!==m,this._padding=!s.isPaddingEqual(T),this._easeId=t.easeId,this._prepareEase(n,t.noMoveStart,ae),this.terrain&&this._prepareElevation(D),this._ease(se=>{if(this._zooming&&(s.zoom=h.number(l,y,se)),this._rotating&&(s.bearing=h.number(d,x,se)),this._pitching&&(s.pitch=h.number(m,S,se)),this._padding&&(s.interpolatePadding(g,T,se),F=s.centerPoint.add(M)),this.terrain&&!t.freezeElevation&&this._updateElevation(se),V)s.setLocationAtPoint(V,te);else{const ue=s.zoomScale(s.zoom-l),me=y>l?Math.min(2,H):Math.max(.5,H),xe=Math.pow(me,1-se),_e=s.unproject(G.add(Y.mult(se*xe)).mult(ue));s.setLocationAtPoint(s.renderWorldCopies?_e.wrap():_e,F)}this._fireMoveEvents(n)},se=>{this.terrain&&this._finalizeElevation(),this._afterEase(n,se)},t),this}_prepareEase(t,n,s={}){this._moving=!0,n||s.moving||this.fire(new h.Event("movestart",t)),this._zooming&&!s.zooming&&this.fire(new h.Event("zoomstart",t)),this._rotating&&!s.rotating&&this.fire(new h.Event("rotatestart",t)),this._pitching&&!s.pitching&&this.fire(new h.Event("pitchstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.transform.getElevation(t,this.terrain),this.transform.freezeElevation=!0}_updateElevation(t){const n=this.transform.getElevation(this._elevationCenter,this.terrain);if(t<1&&n!==this._elevationTarget){const s=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(s-(n-(s*t+this._elevationStart))/(1-t)),this._elevationTarget=n}this.transform.elevation=h.number(this._elevationStart,this._elevationTarget,t)}_finalizeElevation(){this.transform.freezeElevation=!1,this.transform.recalculateZoom(this.terrain)}_fireMoveEvents(t){this.fire(new h.Event("move",t)),this._zooming&&this.fire(new h.Event("zoom",t)),this._rotating&&this.fire(new h.Event("rotate",t)),this._pitching&&this.fire(new h.Event("pitch",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const s=this._zooming,l=this._rotating,d=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,s&&this.fire(new h.Event("zoomend",t)),l&&this.fire(new h.Event("rotateend",t)),d&&this.fire(new h.Event("pitchend",t)),this.fire(new h.Event("moveend",t))}flyTo(t,n){if(!t.essential&&h.exported.prefersReducedMotion){const Le=h.pick(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Le,n)}this.stop(),t=h.extend({offset:[0,0],speed:1.2,curve:1.42,easing:h.ease},t);const s=this.transform,l=this.getZoom(),d=this.getBearing(),m=this.getPitch(),g=this.getPadding(),y="zoom"in t?h.clamp(+t.zoom,s.minZoom,s.maxZoom):l,x="bearing"in t?this._normalizeBearing(t.bearing,d):d,S="pitch"in t?+t.pitch:m,T="padding"in t?t.padding:s.padding,M=s.zoomScale(y-l),F=h.pointGeometry.convert(t.offset);let O=s.centerPoint.add(F);const D=s.pointLocation(O),G=h.LngLat.convert(t.center||D);this._normalizeCenter(G);const Y=s.project(D),H=s.project(G).sub(Y);let V=t.curve;const te=Math.max(s.width,s.height),ae=te/M,se=H.mag();if("minZoom"in t){const Le=h.clamp(Math.min(t.minZoom,l,y),s.minZoom,s.maxZoom),mt=te/s.zoomScale(Le-l);V=Math.sqrt(mt/se*2)}const ue=V*V;function me(Le){const mt=(ae*ae-te*te+(Le?-1:1)*ue*ue*se*se)/(2*(Le?ae:te)*ue*se);return Math.log(Math.sqrt(mt*mt+1)-mt)}function xe(Le){return(Math.exp(Le)-Math.exp(-Le))/2}function _e(Le){return(Math.exp(Le)+Math.exp(-Le))/2}const we=me(0);let ze=function(Le){return _e(we)/_e(we+V*Le)},We=function(Le){return te*((_e(we)*(xe(mt=we+V*Le)/_e(mt))-xe(we))/ue)/se;var mt},Ke=(me(1)-we)/V;if(Math.abs(se)<1e-6||!isFinite(Ke)){if(Math.abs(te-ae)<1e-6)return this.easeTo(t,n);const Le=ae<te?-1:1;Ke=Math.abs(Math.log(ae/te))/V,We=function(){return 0},ze=function(mt){return Math.exp(Le*V*mt)}}return t.duration="duration"in t?+t.duration:1e3*Ke/("screenSpeed"in t?+t.screenSpeed/V:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=d!==x,this._pitching=S!==m,this._padding=!s.isPaddingEqual(T),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(G),this._ease(Le=>{const mt=Le*Ke,ft=1/ze(mt);s.zoom=Le===1?y:l+s.scaleZoom(ft),this._rotating&&(s.bearing=h.number(d,x,Le)),this._pitching&&(s.pitch=h.number(m,S,Le)),this._padding&&(s.interpolatePadding(g,T,Le),O=s.centerPoint.add(F)),this.terrain&&!t.freezeElevation&&this._updateElevation(Le);const tt=Le===1?G:s.unproject(Y.add(H.mult(We(mt))).mult(ft));s.setLocationAtPoint(s.renderWorldCopies?tt.wrap():tt,O),this._fireMoveEvents(n)},()=>{this.terrain&&this._finalizeElevation(),this._afterEase(n)},t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,n){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const s=this._onEaseEnd;delete this._onEaseEnd,s.call(this,n)}if(!t){const s=this.handlers;s&&s.stop(!1)}return this}_ease(t,n,s){s.animate===!1||s.duration===0?(t(1),n()):(this._easeStart=h.exported.now(),this._easeOptions=s,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((h.exported.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,n){t=h.wrap(t,-180,180);const s=Math.abs(t-n);return Math.abs(t-360-n)<s&&(t-=360),Math.abs(t+360-n)<s&&(t+=360),t}_normalizeCenter(t){const n=this.transform;if(!n.renderWorldCopies||n.lngRange)return;const s=t.lng-n.center.lng;t.lng+=s>180?-360:s<-180?360:0}}class Ga{constructor(t={}){this.options=t,h.bindAll(["_toggleAttribution","_updateData","_updateCompact","_updateCompactMinimize"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options&&this.options.compact,this._container=ee.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=ee.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=ee.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(){ee.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,n){const s=this._map._getUIString(`AttributionControl.${n}`);t.title=s,t.setAttribute("aria-label",s)}_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")))}_updateData(t){!t||t.sourceDataType!=="metadata"&&t.sourceDataType!=="visibility"&&t.dataType!=="style"&&t.type!=="terrain"||this._updateAttributions()}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map(l=>typeof l!="string"?"":l)):typeof this.options.customAttribution=="string"&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const l=this._map.style.stylesheet;this.styleOwner=l.owner,this.styleId=l.id}const n=this._map.style.sourceCaches;for(const l in n){const d=n[l];if(d.used||d.usedForTerrain){const m=d.getSource();m.attribution&&t.indexOf(m.attribution)<0&&t.push(m.attribution)}}t=t.filter(l=>String(l).trim()),t.sort((l,d)=>l.length-d.length),t=t.filter((l,d)=>{for(let m=d+1;m<t.length;m++)if(t[m].indexOf(l)>=0)return!1;return!0});const s=t.join(" | ");s!==this._attribHTML&&(this._attribHTML=s,t.length?(this._innerContainer.innerHTML=s,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}_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"))}_updateCompactMinimize(){this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")}}class ja{constructor(t={}){this.options=t,h.bindAll(["_updateCompact"],this)}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=ee.create("div","maplibregl-ctrl");const n=ee.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){ee.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}_updateCompact(){const t=this._container.children;if(t.length){const n=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&n.classList.add("maplibregl-compact"):n.classList.remove("maplibregl-compact")}}}class Ks{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const n=++this._id;return this._queue.push({callback:t,id:n,cancelled:!1}),n}remove(t){const n=this._currentlyRunning,s=n?this._queue.concat(n):this._queue;for(const l of s)if(l.id===t)return void(l.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const s of n)if(!s.cancelled&&(s.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}const Ys={"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":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.enableTerrain":"Enable terrain","TerrainControl.disableTerrain":"Disable terrain"};var Js=h.createLayout([{name:"a_pos3d",type:"Int16",components:3}]);class Qs extends h.Evented{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(t,n){this.sourceCache.update(t,n),this._renderableTilesKeys=[];const s={};for(const l of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n}))s[l.key]=!0,this._renderableTilesKeys.push(l.key),this._tiles[l.key]||(l.posMatrix=new Float64Array(16),h.ortho(l.posMatrix,0,h.EXTENT,0,h.EXTENT,0,1),this._tiles[l.key]=new Je(l,this.tileSize));for(const l in this._tiles)s[l]||delete this._tiles[l]}freeRtt(t){for(const n in this._tiles){const s=this._tiles[n];(!t||s.tileID.equals(t)||s.tileID.isChildOf(t)||t.isChildOf(s.tileID))&&(s.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(t=>this.getTileByID(t))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){const n={};for(const s of this._renderableTilesKeys){const l=this._tiles[s].tileID;if(l.canonical.equals(t.canonical)){const d=t.clone();d.posMatrix=new Float64Array(16),h.ortho(d.posMatrix,0,h.EXTENT,0,h.EXTENT,0,1),n[s]=d}else if(l.canonical.isChildOf(t.canonical)){const d=t.clone();d.posMatrix=new Float64Array(16);const m=l.canonical.z-t.canonical.z,g=l.canonical.x-(l.canonical.x>>m<<m),y=l.canonical.y-(l.canonical.y>>m<<m),x=h.EXTENT>>m;h.ortho(d.posMatrix,0,x,0,x,0,1),h.translate(d.posMatrix,d.posMatrix,[-g*x,-y*x,0]),n[s]=d}else if(t.canonical.isChildOf(l.canonical)){const d=t.clone();d.posMatrix=new Float64Array(16);const m=t.canonical.z-l.canonical.z,g=t.canonical.x-(t.canonical.x>>m<<m),y=t.canonical.y-(t.canonical.y>>m<<m),x=h.EXTENT>>m;h.ortho(d.posMatrix,0,h.EXTENT,0,h.EXTENT,0,1),h.translate(d.posMatrix,d.posMatrix,[g*x,y*x,0]),h.scale(d.posMatrix,d.posMatrix,[1/2**m,1/2**m,0]),n[s]=d}}return n}getSourceTile(t,n){const s=this.sourceCache._source;let l=t.overscaledZ-this.deltaZoom;if(l>s.maxzoom&&(l=s.maxzoom),l<s.minzoom)return null;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(l).key);let d=this.sourceCache.getTileByID(this._sourceTileCache[t.key]);if((!d||!d.dem)&&n)for(;l>=s.minzoom&&(!d||!d.dem);)d=this.sourceCache.getTileByID(t.scaledTo(l--).key);return d}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter(n=>n.timeAdded>=t)}}class qa{constructor(t,n,s){this.painter=t,this.sourceCache=new Qs(n),this.options=s,this.exaggeration=typeof s.exaggeration=="number"?s.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,n,s,l=h.EXTENT){if(!(n>=0&&n<l&&s>=0&&s<l))return 0;let d=0;const m=this.getTerrainData(t);if(m.tile&&m.tile.dem){const g=function(O,D,G){var Y=D[0],H=D[1];return O[0]=G[0]*Y+G[4]*H+G[12],O[1]=G[1]*Y+G[5]*H+G[13],O}([],[n/l*h.EXTENT,s/l*h.EXTENT],m.u_terrain_matrix),y=[g[0]*m.tile.dem.dim,g[1]*m.tile.dem.dim],x=[Math.floor(y[0]),Math.floor(y[1])],S=m.tile.dem.get(x[0],x[1]),T=m.tile.dem.get(x[0],x[1]+1),M=m.tile.dem.get(x[0]+1,x[1]),F=m.tile.dem.get(x[0]+1,x[1]+1);d=h.number(h.number(S,T,y[0]-x[0]),h.number(M,F,y[0]-x[0]),y[1]-x[1])}return d}getElevation(t,n,s,l=h.EXTENT){return this.getDEMElevation(t,n,s,l)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){const l=this.painter.context,d=new h.RGBAImage({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new Mt(l,d,l.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Mt(l,new h.RGBAImage({width:1,height:1}),l.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(l.gl.NEAREST,l.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=h.identity([])}const n=this.sourceCache.getSourceTile(t,!0);if(n&&n.dem&&(!n.demTexture||n.needsTerrainPrepare)){const l=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new Mt(l,n.dem.getPixels(),l.gl.RGBA,{premultiply:!1}),n.demTexture.bind(l.gl.NEAREST,l.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}const s=n&&n+n.tileID.key+t.key;if(s&&!this._demMatrixCache[s]){const l=this.sourceCache.sourceCache._source.maxzoom;let d=t.canonical.z-n.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=l?d=t.canonical.z-l:h.warnOnce("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const m=t.canonical.x-(t.canonical.x>>d<<d),g=t.canonical.y-(t.canonical.y>>d<<d),y=h.fromScaling(new Float64Array(16),[1/(h.EXTENT<<d),1/(h.EXTENT<<d),0]);h.translate(y,y,[m*h.EXTENT,g*h.EXTENT,0]),this._demMatrixCache[t.key]={matrix:y,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:n&&n.dem&&n.dem.dim||1,u_terrain_matrix:s?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:n&&n.dem&&n.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(n&&n.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:n}}getFramebuffer(t){const n=this.painter,s=n.width/devicePixelRatio,l=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===s&&this._fbo.height===l||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new Mt(n.context,{width:s,height:l,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Mt(n.context,{width:s,height:l,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=n.context.createFramebuffer(s,l,!0),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,s,l))),this._fbo.colorAttachment.set(t==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let d=0,m=0;d<this._coordsTextureSize;d++)for(let g=0;g<this._coordsTextureSize;g++,m+=4)n[m+0]=255&g,n[m+1]=255&d,n[m+2]=g>>8<<4|d>>8,n[m+3]=0;const s=new h.RGBAImage({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),l=new Mt(t,s,t.gl.RGBA,{premultiply:!1});return l.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=l,l}pointCoordinate(t){const n=new Uint8Array(4),s=this.painter.context,l=s.gl;s.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),l.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,l.RGBA,l.UNSIGNED_BYTE,n),s.bindFramebuffer.set(null);const d=n[0]+(n[2]>>4<<8),m=n[1]+((15&n[2])<<8),g=this.coordsIndex[255-n[3]],y=g&&this.sourceCache.getTileByID(g);if(!y)return null;const x=this._coordsTextureSize,S=(1<<y.tileID.canonical.z)*x;return new h.MercatorCoordinate((y.tileID.canonical.x*x+d)/S,(y.tileID.canonical.y*x+m)/S,this.getElevation(y.tileID,d,m,x))}getTerrainMesh(){if(this._mesh)return this._mesh;const t=this.painter.context,n=new h.Pos3dArray,s=new h.TriangleIndexArray,l=this.meshSize,d=h.EXTENT/l,m=l*l;for(let T=0;T<=l;T++)for(let M=0;M<=l;M++)n.emplaceBack(M*d,T*d,0);for(let T=0;T<m;T+=l+1)for(let M=0;M<l;M++)s.emplaceBack(M+T,l+M+T+1,l+M+T+2),s.emplaceBack(M+T,l+M+T+2,M+T+1);const g=n.length,y=g+2*(l+1);for(const T of[0,1])for(let M=0;M<=l;M++)for(const F of[0,1])n.emplaceBack(M*d,T*h.EXTENT,F);for(let T=0;T<2*l;T+=2)s.emplaceBack(y+T,y+T+1,y+T+3),s.emplaceBack(y+T,y+T+3,y+T+2),s.emplaceBack(g+T,g+T+3,g+T+1),s.emplaceBack(g+T,g+T+2,g+T+3);const x=n.length,S=x+2*(l+1);for(const T of[0,1])for(let M=0;M<=l;M++)for(const F of[0,1])n.emplaceBack(T*h.EXTENT,M*d,F);for(let T=0;T<2*l;T+=2)s.emplaceBack(x+T,x+T+1,x+T+3),s.emplaceBack(x+T,x+T+3,x+T+2),s.emplaceBack(S+T,S+T+3,S+T+1),s.emplaceBack(S+T,S+T+2,S+T+3);return this._mesh={indexBuffer:t.createIndexBuffer(s),vertexBuffer:t.createVertexBuffer(n,Js.members),segments:h.SegmentVector.simpleSegment(0,0,n.length,s.length)},this._mesh}getMeshFrameDelta(t){return 2*Math.PI*h.earthRadius/Math.pow(2,t)/5}getMinMaxElevation(t){const n=this.getTerrainData(t).tile,s={minElevation:null,maxElevation:null};return n&&n.dem&&(s.minElevation=n.dem.min*this.exaggeration,s.maxElevation=n.dem.max*this.exaggeration),s}}class eo{constructor(t,n,s){this._context=t,this._size=n,this._tileSize=s,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0),s=new Mt(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return s.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_COMPONENT16,this._tileSize,this._tileSize)),n.colorAttachment.set(s.texture),{id:t,fbo:n,texture:s,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(n=>t.id!==n),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length<this._size)&&this._objects.some(t=>!t.inUse)===!1}}const Lr={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Za{constructor(t,n){this.painter=t,this.terrain=n,this.pool=new eo(t.context,30,n.sourceCache.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter(s=>!t._layers[s].isHidden(n)),this._coordsDescendingInv={};for(const s in t.sourceCaches){this._coordsDescendingInv[s]={};const l=t.sourceCaches[s].getVisibleCoordinates();for(const d of l){const m=this.terrain.sourceCache.getTerrainCoords(d);for(const g in m)this._coordsDescendingInv[s][g]||(this._coordsDescendingInv[s][g]=[]),this._coordsDescendingInv[s][g].push(m[g])}}this._coordsDescendingInvStr={};for(const s of t._order){const l=t._layers[s],d=l.source;if(Lr[l.type]&&!this._coordsDescendingInvStr[d]){this._coordsDescendingInvStr[d]={};for(const m in this._coordsDescendingInv[d])this._coordsDescendingInvStr[d][m]=this._coordsDescendingInv[d][m].map(g=>g.key).sort().join()}}for(const s of this._renderableTiles)for(const l in this._coordsDescendingInvStr){const d=this._coordsDescendingInvStr[l][s.tileID.key];d&&d!==s.rttCoords[l]&&(s.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;const n=t.type,s=this.painter,l=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(Lr[n]&&(this._prevType&&Lr[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(t.id),!l))return!0;if(Lr[this._prevType]||Lr[n]&&l){this._prevType=n;const d=this._stacks.length-1,m=this._stacks[d]||[];for(const g of this._renderableTiles){if(this.pool.isFull()&&(Fs(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(g),g.rtt[d]){const x=this.pool.getObjectForId(g.rtt[d].id);if(x.stamp===g.rtt[d].stamp){this.pool.useObject(x);continue}}const y=this.pool.getOrCreateFreeObject();this.pool.useObject(y),this.pool.stampObject(y),g.rtt[d]={id:y.id,stamp:y.stamp},s.context.bindFramebuffer.set(y.fbo.framebuffer),s.context.clear({color:h.Color.transparent});for(let x=0;x<m.length;x++){const S=s.style._layers[m[x]],T=S.source?this._coordsDescendingInv[S.source][g.tileID.key]:[g.tileID];s.context.viewport.set([0,0,y.fbo.width,y.fbo.height]),s._renderTileClippingMasks(S,T),s.renderLayer(s,s.style.sourceCaches[S.source],S,T),S.source&&(g.rttCoords[S.source]=this._coordsDescendingInvStr[S.source][g.tileID.key])}}return Fs(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),Lr[n]}return!1}}const to=Ye,io={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:void 0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",transformRequest:null,fadeDuration:300,crossSourceCollisions:!0},Xa=o=>{o.touchstart=o.dragStart,o.touchmoveWindow=o.dragMove,o.touchend=o.dragEnd},ro={showCompass:!0,showZoom:!0,visualizePitch:!1};class pl{constructor(t,n,s=!1){this._clickTolerance=10;const l=t.dragRotate._mouseRotate.getClickTolerance(),d=t.dragRotate._mousePitch.getClickTolerance();this.element=n,this.mouseRotate=Ba({clickTolerance:l,enable:!0}),this.touchRotate=(({enable:m,clickTolerance:g,bearingDegreesPerPixelMoved:y=.8})=>{const x=new Pt;return new tn({clickTolerance:g,move:(S,T)=>({bearingDelta:(T.x-S.x)*y}),moveStateManager:x,enable:m,assignEvents:Xa})})({clickTolerance:l,enable:!0}),this.map=t,s&&(this.mousePitch=js({clickTolerance:d,enable:!0}),this.touchPitch=(({enable:m,clickTolerance:g,pitchDegreesPerPixelMoved:y=-.5})=>{const x=new Pt;return new tn({clickTolerance:g,move:(S,T)=>({pitchDelta:(T.y-S.y)*y}),moveStateManager:x,enable:m,assignEvents:Xa})})({clickTolerance:d,enable:!0})),h.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),ee.addEventListener(n,"mousedown",this.mousedown),ee.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),ee.addEventListener(n,"touchcancel",this.reset)}startMouse(t,n){this.mouseRotate.dragStart(t,n),this.mousePitch&&this.mousePitch.dragStart(t,n),ee.disableDrag()}startTouch(t,n){this.touchRotate.dragStart(t,n),this.touchPitch&&this.touchPitch.dragStart(t,n),ee.disableDrag()}moveMouse(t,n){const s=this.map,{bearingDelta:l}=this.mouseRotate.dragMove(t,n)||{};if(l&&s.setBearing(s.getBearing()+l),this.mousePitch){const{pitchDelta:d}=this.mousePitch.dragMove(t,n)||{};d&&s.setPitch(s.getPitch()+d)}}moveTouch(t,n){const s=this.map,{bearingDelta:l}=this.touchRotate.dragMove(t,n)||{};if(l&&s.setBearing(s.getBearing()+l),this.touchPitch){const{pitchDelta:d}=this.touchPitch.dragMove(t,n)||{};d&&s.setPitch(s.getPitch()+d)}}off(){const t=this.element;ee.removeEventListener(t,"mousedown",this.mousedown),ee.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),ee.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),ee.removeEventListener(window,"touchend",this.touchend),ee.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){ee.enableDrag(),ee.removeEventListener(window,"mousemove",this.mousemove),ee.removeEventListener(window,"mouseup",this.mouseup),ee.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),ee.removeEventListener(window,"touchend",this.touchend)}mousedown(t){this.startMouse(h.extend({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),ee.mousePos(this.element,t)),ee.addEventListener(window,"mousemove",this.mousemove),ee.addEventListener(window,"mouseup",this.mouseup)}mousemove(t){this.moveMouse(t,ee.mousePos(this.element,t))}mouseup(t){this.mouseRotate.dragEnd(t),this.mousePitch&&this.mousePitch.dragEnd(t),this.offTemp()}touchstart(t){t.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=ee.touchPos(this.element,t.targetTouches)[0],this.startTouch(t,this._startPos),ee.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),ee.addEventListener(window,"touchend",this.touchend))}touchmove(t){t.targetTouches.length!==1?this.reset():(this._lastPos=ee.touchPos(this.element,t.targetTouches)[0],this.moveTouch(t,this._lastPos))}touchend(t){t.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()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}function no(o,t,n){if(o=new h.LngLat(o.lng,o.lat),t){const s=new h.LngLat(o.lng-360,o.lat),l=new h.LngLat(o.lng+360,o.lat),d=n.locationPoint(o).distSqr(t);n.locationPoint(s).distSqr(t)<d?o=s:n.locationPoint(l).distSqr(t)<d&&(o=l)}for(;Math.abs(o.lng-n.center.lng)>180;){const s=n.locationPoint(o);if(s.x>=0&&s.y>=0&&s.x<=n.width&&s.y<=n.height)break;o.lng>n.center.lng?o.lng-=360:o.lng+=360}return o}const Wa={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 ao(o,t,n){const s=o.classList;for(const l in Wa)s.remove(`maplibregl-${n}-anchor-${l}`);s.add(`maplibregl-${n}-anchor-${t}`)}class Ha extends h.Evented{constructor(t,n){if(super(),(t instanceof HTMLElement||n)&&(t=h.extend({element:t},n)),h.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress"],this),this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment!=="auto"?t.pitchAlignment:this._rotationAlignment,t&&t.element)this._element=t.element,this._offset=h.pointGeometry.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=ee.create("div"),this._element.setAttribute("aria-label","Map marker");const s=ee.createNS("http://www.w3.org/2000/svg","svg"),l=41,d=27;s.setAttributeNS(null,"display","block"),s.setAttributeNS(null,"height",`${l}px`),s.setAttributeNS(null,"width",`${d}px`),s.setAttributeNS(null,"viewBox",`0 0 ${d} ${l}`);const m=ee.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"stroke","none"),m.setAttributeNS(null,"stroke-width","1"),m.setAttributeNS(null,"fill","none"),m.setAttributeNS(null,"fill-rule","evenodd");const g=ee.createNS("http://www.w3.org/2000/svg","g");g.setAttributeNS(null,"fill-rule","nonzero");const y=ee.createNS("http://www.w3.org/2000/svg","g");y.setAttributeNS(null,"transform","translate(3.0, 29.0)"),y.setAttributeNS(null,"fill","#000000");const x=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const H of x){const V=ee.createNS("http://www.w3.org/2000/svg","ellipse");V.setAttributeNS(null,"opacity","0.04"),V.setAttributeNS(null,"cx","10.5"),V.setAttributeNS(null,"cy","5.80029008"),V.setAttributeNS(null,"rx",H.rx),V.setAttributeNS(null,"ry",H.ry),y.appendChild(V)}const S=ee.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"fill",this._color);const T=ee.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"),S.appendChild(T);const M=ee.createNS("http://www.w3.org/2000/svg","g");M.setAttributeNS(null,"opacity","0.25"),M.setAttributeNS(null,"fill","#000000");const F=ee.createNS("http://www.w3.org/2000/svg","path");F.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"),M.appendChild(F);const O=ee.createNS("http://www.w3.org/2000/svg","g");O.setAttributeNS(null,"transform","translate(6.0, 7.0)"),O.setAttributeNS(null,"fill","#FFFFFF");const D=ee.createNS("http://www.w3.org/2000/svg","g");D.setAttributeNS(null,"transform","translate(8.0, 8.0)");const G=ee.createNS("http://www.w3.org/2000/svg","circle");G.setAttributeNS(null,"fill","#000000"),G.setAttributeNS(null,"opacity","0.25"),G.setAttributeNS(null,"cx","5.5"),G.setAttributeNS(null,"cy","5.5"),G.setAttributeNS(null,"r","5.4999962");const Y=ee.createNS("http://www.w3.org/2000/svg","circle");Y.setAttributeNS(null,"fill","#FFFFFF"),Y.setAttributeNS(null,"cx","5.5"),Y.setAttributeNS(null,"cy","5.5"),Y.setAttributeNS(null,"r","5.4999962"),D.appendChild(G),D.appendChild(Y),g.appendChild(y),g.appendChild(S),g.appendChild(M),g.appendChild(O),g.appendChild(D),s.appendChild(g),s.setAttributeNS(null,"height",l*this._scale+"px"),s.setAttributeNS(null,"width",d*this._scale+"px"),this._element.appendChild(s),this._offset=h.pointGeometry.convert(t&&t.offset||[0,-14])}this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",s=>{s.preventDefault()}),this._element.addEventListener("mousedown",s=>{s.preventDefault()}),ao(this._element,this._anchor,"marker"),this._popup=null}addTo(t){return this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",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("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),ee.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=h.LngLat.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const l=Math.sqrt(Math.pow(13.5,2)/2);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[l,-1*(38.1-13.5+l)],"bottom-right":[-l,-1*(38.1-13.5+l)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=t,this._lngLat&&this._popup.setLngLat(this._lngLat),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}_onKeyPress(t){const n=t.code,s=t.charCode||t.keyCode;n!=="Space"&&n!=="Enter"&&s!==32&&s!==13||this.togglePopup()}_onMapClick(t){const n=t.originalEvent.target,s=this._element;this._popup&&(n===s||s.contains(n))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?t.remove():t.addTo(this._map),this):this}_update(t){if(!this._map)return;this._map.transform.renderWorldCopies&&(this._lngLat=no(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._offset);let n="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?n=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(n=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let s="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?s="rotateX(0deg)":this._pitchAlignment==="map"&&(s=`rotateX(${this._map.getPitch()}deg)`),t&&t.type!=="moveend"||(this._pos=this._pos.round()),ee.setTransform(this._element,`${Wa[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${s} ${n}`),this._map.terrain&&!this._opacityTimeout&&(this._opacityTimeout=setTimeout(()=>{const l=this._map.unproject(this._pos),d=40075016686e-3*Math.abs(Math.cos(this._lngLat.lat*Math.PI/180))/Math.pow(2,this._map.transform.tileZoom+8);this._element.style.opacity=l.distanceTo(this._lngLat)>20*d?"0.2":"1.0",this._opacityTimeout=null},100))}getOffset(){return this._offset}setOffset(t){return this._offset=h.pointGeometry.convert(t),this._update(),this}_onMove(t){if(!this._isDragging){const n=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=n}this._isDragging&&(this._pos=t.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 h.Event("dragstart"))),this.fire(new h.Event("drag")))}_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 h.Event("dragend")),this._state="inactive"}_addDragHandler(t){this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.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))}setDraggable(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&t!=="auto"?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}const ml={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let rn,na=0,Rn=!1;const fl={maxWidth:100,unit:"metric"};function so(o,t,n){const s=n&&n.maxWidth||100,l=o._container.clientHeight/2,d=o.unproject([0,l]),m=o.unproject([s,l]),g=d.distanceTo(m);if(n&&n.unit==="imperial"){const y=3.2808*g;y>5280?aa(t,s,y/5280,o._getUIString("ScaleControl.Miles")):aa(t,s,y,o._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?aa(t,s,g/1852,o._getUIString("ScaleControl.NauticalMiles")):g>=1e3?aa(t,s,g/1e3,o._getUIString("ScaleControl.Kilometers")):aa(t,s,g,o._getUIString("ScaleControl.Meters"))}function aa(o,t,n,s){const l=function(d){const m=Math.pow(10,`${Math.floor(d)}`.length-1);let g=d/m;return g=g>=10?10:g>=5?5:g>=3?3:g>=2?2:g>=1?1:function(y){const x=Math.pow(10,Math.ceil(-Math.log(y)/Math.LN10));return Math.round(y*x)/x}(g),m*g}(n);o.style.width=t*(l/n)+"px",o.innerHTML=`${l}&nbsp;${s}`}const uc={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},dc=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function gl(o){if(o){if(typeof o=="number"){const t=Math.round(Math.sqrt(.5*Math.pow(o,2)));return{center:new h.pointGeometry(0,0),top:new h.pointGeometry(0,o),"top-left":new h.pointGeometry(t,t),"top-right":new h.pointGeometry(-t,t),bottom:new h.pointGeometry(0,-o),"bottom-left":new h.pointGeometry(t,-t),"bottom-right":new h.pointGeometry(-t,-t),left:new h.pointGeometry(o,0),right:new h.pointGeometry(-o,0)}}if(o instanceof h.pointGeometry||Array.isArray(o)){const t=h.pointGeometry.convert(o);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:h.pointGeometry.convert(o.center||[0,0]),top:h.pointGeometry.convert(o.top||[0,0]),"top-left":h.pointGeometry.convert(o["top-left"]||[0,0]),"top-right":h.pointGeometry.convert(o["top-right"]||[0,0]),bottom:h.pointGeometry.convert(o.bottom||[0,0]),"bottom-left":h.pointGeometry.convert(o["bottom-left"]||[0,0]),"bottom-right":h.pointGeometry.convert(o["bottom-right"]||[0,0]),left:h.pointGeometry.convert(o.left||[0,0]),right:h.pointGeometry.convert(o.right||[0,0])}}return gl(new h.pointGeometry(0,0))}const pc=Ye,Dr={supported:ve,setRTLTextPlugin:h.setRTLTextPlugin,getRTLTextPluginStatus:h.getRTLTextPluginStatus,Map:class extends Hs{constructor(o){var t;if(h.PerformanceUtils.mark(h.PerformanceMarkers.create),(o=h.extend({},io,o)).minZoom!=null&&o.maxZoom!=null&&o.minZoom>o.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(o.minPitch!=null&&o.maxPitch!=null&&o.minPitch>o.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(o.minPitch!=null&&o.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(o.maxPitch!=null&&o.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new en(o.minZoom,o.maxZoom,o.minPitch,o.maxPitch,o.renderWorldCopies),{bearingSnap:o.bearingSnap}),this._interactive=o.interactive,this._cooperativeGestures=o.cooperativeGestures,this._maxTileCacheSize=o.maxTileCacheSize,this._failIfMajorPerformanceCaveat=o.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=o.preserveDrawingBuffer,this._antialias=o.antialias,this._trackResize=o.trackResize,this._bearingSnap=o.bearingSnap,this._refreshExpiredTiles=o.refreshExpiredTiles,this._fadeDuration=o.fadeDuration,this._crossSourceCollisions=o.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=o.collectResourceTiming,this._renderTaskQueue=new Ks,this._controls=[],this._mapId=h.uniqueId(),this._locale=h.extend({},Ys,o.locale),this._clickTolerance=o.clickTolerance,this._pixelRatio=(t=o.pixelRatio)!==null&&t!==void 0?t:devicePixelRatio,this._imageQueueHandle=Qt.addThrottleControl(()=>this.isMoving()),this._requestManager=new us(o.transformRequest),typeof o.container=="string"){if(this._container=document.getElementById(o.container),!this._container)throw new Error(`Container '${o.container}' not found.`)}else{if(!(o.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=o.container}o.maxBounds&&this.setMaxBounds(o.maxBounds),h.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),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)}),typeof window<"u"&&(addEventListener("online",this._onWindowOnline,!1),addEventListener("resize",this._onWindowResize,!1),addEventListener("orientationchange",this._onWindowResize,!1)),this.handlers=new ra(this,o),this._cooperativeGestures&&this._setupCooperativeGestures(),this._hash=o.hash&&new ol(typeof o.hash=="string"&&o.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:o.center,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch}),o.bounds&&(this.resize(),this.fitBounds(o.bounds,h.extend({},o.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=o.localIdeographFontFamily,o.style&&this.setStyle(o.style,{localIdeographFontFamily:o.localIdeographFontFamily}),o.attributionControl&&this.addControl(new Ga({customAttribution:o.customAttribution})),o.maplibreLogo&&this.addControl(new ja,o.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",n=>{this._update(n.dataType==="style"),this.fire(new h.Event(`${n.dataType}data`,n))}),this.on("dataloading",n=>{this.fire(new h.Event(`${n.dataType}dataloading`,n))}),this.on("dataabort",n=>{this.fire(new h.Event("sourcedataabort",n))})}_getMapId(){return this._mapId}addControl(o,t){if(t===void 0&&(t=o.getDefaultPosition?o.getDefaultPosition():"top-right"),!o||!o.onAdd)return this.fire(new h.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=o.onAdd(this);this._controls.push(o);const s=this._controlPositions[t];return t.indexOf("bottom")!==-1?s.insertBefore(n,s.firstChild):s.appendChild(n),this}removeControl(o){if(!o||!o.onRemove)return this.fire(new h.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(o);return t>-1&&this._controls.splice(t,1),o.onRemove(this),this}hasControl(o){return this._controls.indexOf(o)>-1}calculateCameraOptionsFromTo(o,t,n,s){return s==null&&this.terrain&&(s=this.transform.getElevation(n,this.terrain)),super.calculateCameraOptionsFromTo(o,t,n,s)}resize(o){const t=this._containerDimensions(),n=t[0],s=t[1];this._resizeCanvas(n,s,this.getPixelRatio()),this.transform.resize(n,s),this.painter.resize(n,s,this.getPixelRatio());const l=!this._moving;return l&&(this.stop(),this.fire(new h.Event("movestart",o)).fire(new h.Event("move",o))),this.fire(new h.Event("resize",o)),l&&this.fire(new h.Event("moveend",o)),this}getPixelRatio(){return this._pixelRatio}setPixelRatio(o){const[t,n]=this._containerDimensions();this._pixelRatio=o,this._resizeCanvas(t,n,o),this.painter.resize(t,n,o)}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(o){return this.transform.setMaxBounds(h.LngLatBounds.convert(o)),this._update()}setMinZoom(o){if((o=o??-2)>=-2&&o<=this.transform.maxZoom)return this.transform.minZoom=o,this._update(),this.getZoom()<o&&this.setZoom(o),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(o){if((o=o??22)>=this.transform.minZoom)return this.transform.maxZoom=o,this._update(),this.getZoom()>o&&this.setZoom(o),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(o){if((o=o??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(o>=0&&o<=this.transform.maxPitch)return this.transform.minPitch=o,this._update(),this.getPitch()<o&&this.setPitch(o),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(o){if((o=o??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(o>=this.transform.minPitch)return this.transform.maxPitch=o,this._update(),this.getPitch()>o&&this.setPitch(o),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(o){return this.transform.renderWorldCopies=o,this._update()}project(o){return this.transform.locationPoint(h.LngLat.convert(o),this.style&&this.terrain)}unproject(o){return this.transform.pointLocation(h.pointGeometry.convert(o),this.terrain)}isMoving(){var o;return this._moving||((o=this.handlers)===null||o===void 0?void 0:o.isMoving())}isZooming(){var o;return this._zooming||((o=this.handlers)===null||o===void 0?void 0:o.isZooming())}isRotating(){var o;return this._rotating||((o=this.handlers)===null||o===void 0?void 0:o.isRotating())}_createDelegatedListener(o,t,n){if(o==="mouseenter"||o==="mouseover"){let s=!1;return{layer:t,listener:n,delegates:{mousemove:d=>{const m=this.getLayer(t)?this.queryRenderedFeatures(d.point,{layers:[t]}):[];m.length?s||(s=!0,n.call(this,new Gi(o,this,d.originalEvent,{features:m}))):s=!1},mouseout:()=>{s=!1}}}}if(o==="mouseleave"||o==="mouseout"){let s=!1;return{layer:t,listener:n,delegates:{mousemove:m=>{(this.getLayer(t)?this.queryRenderedFeatures(m.point,{layers:[t]}):[]).length?s=!0:s&&(s=!1,n.call(this,new Gi(o,this,m.originalEvent)))},mouseout:m=>{s&&(s=!1,n.call(this,new Gi(o,this,m.originalEvent)))}}}}{const s=l=>{const d=this.getLayer(t)?this.queryRenderedFeatures(l.point,{layers:[t]}):[];d.length&&(l.features=d,n.call(this,l),delete l.features)};return{layer:t,listener:n,delegates:{[o]:s}}}}on(o,t,n){if(n===void 0)return super.on(o,t);const s=this._createDelegatedListener(o,t,n);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[o]=this._delegatedListeners[o]||[],this._delegatedListeners[o].push(s);for(const l in s.delegates)this.on(l,s.delegates[l]);return this}once(o,t,n){if(n===void 0)return super.once(o,t);const s=this._createDelegatedListener(o,t,n);for(const l in s.delegates)this.once(l,s.delegates[l]);return this}off(o,t,n){return n===void 0?super.off(o,t):(this._delegatedListeners&&this._delegatedListeners[o]&&(s=>{const l=this._delegatedListeners[o];for(let d=0;d<l.length;d++){const m=l[d];if(m.layer===t&&m.listener===n){for(const g in m.delegates)this.off(g,m.delegates[g]);return l.splice(d,1),this}}})(),this)}queryRenderedFeatures(o,t){if(!this.style)return[];let n;const s=o instanceof h.pointGeometry||Array.isArray(o),l=s?o:[[0,0],[this.transform.width,this.transform.height]];if(t=t||(s?{}:o)||{},l instanceof h.pointGeometry||typeof l[0]=="number")n=[h.pointGeometry.convert(l)];else{const d=h.pointGeometry.convert(l[0]),m=h.pointGeometry.convert(l[1]);n=[d,new h.pointGeometry(m.x,d.y),m,new h.pointGeometry(d.x,m.y),d]}return this.style.queryRenderedFeatures(n,t,this.transform)}querySourceFeatures(o,t){return this.style.querySourceFeatures(o,t)}setStyle(o,t){return(t=h.extend({},{localIdeographFontFamily:this._localIdeographFontFamily},t)).diff!==!1&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&o?(this._diffStyle(o,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(o,t))}setTransformRequest(o){return this._requestManager.setTransformRequest(o),this}_getUIString(o){const t=this._locale[o];if(t==null)throw new Error(`Missing UI string '${o}'`);return t}_updateStyle(o,t){if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(o,t));const n=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!o)),o?(this.style=new Ni(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof o=="string"?this.style.loadURL(o,t,n):this.style.loadJSON(o,t,n),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Ni(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(o,t){if(typeof o=="string"){const n=this._requestManager.transformRequest(o,dt.Style);h.getJSON(n,(s,l)=>{s?this.fire(new h.ErrorEvent(s)):l&&this._updateDiff(l,t)})}else typeof o=="object"&&this._updateDiff(o,t)}_updateDiff(o,t){try{this.style.setState(o,t)&&this._update(!0)}catch(n){h.warnOnce(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(o,t)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():h.warnOnce("There is no style added to the map.")}addSource(o,t){return this._lazyInitEmptyStyle(),this.style.addSource(o,t),this._update(!0)}isSourceLoaded(o){const t=this.style&&this.style.sourceCaches[o];if(t!==void 0)return t.loaded();this.fire(new h.ErrorEvent(new Error(`There is no source with ID '${o}'`)))}setTerrain(o){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),o){const t=this.style.sourceCaches[o.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${o.source}`);this.terrain=new qa(this.painter,t,o),this.painter.renderToTexture=new Za(this.painter,this.terrain),this.transform.updateElevation(this.terrain),this._terrainDataCallback=n=>{n.dataType==="style"?this.terrain.sourceCache.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId===o.source&&this.transform.updateElevation(this.terrain),this.terrain.sourceCache.freeRtt(n.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.updateElevation(this.terrain);return this.fire(new h.Event("terrain",{terrain:o})),this}getTerrain(){return this.terrain&&this.terrain.options}areTilesLoaded(){const o=this.style&&this.style.sourceCaches;for(const t in o){const n=o[t]._tiles;for(const s in n){const l=n[s];if(l.state!=="loaded"&&l.state!=="errored")return!1}}return!0}addSourceType(o,t,n){return this._lazyInitEmptyStyle(),this.style.addSourceType(o,t,n)}removeSource(o){return this.style.removeSource(o),this._update(!0)}getSource(o){return this.style.getSource(o)}addImage(o,t,{pixelRatio:n=1,sdf:s=!1,stretchX:l,stretchY:d,content:m}={}){if(this._lazyInitEmptyStyle(),t instanceof HTMLImageElement||h.isImageBitmap(t)){const{width:g,height:y,data:x}=h.exported.getImageData(t);this.style.addImage(o,{data:new h.RGBAImage({width:g,height:y},x),pixelRatio:n,stretchX:l,stretchY:d,content:m,sdf:s,version:0})}else{if(t.width===void 0||t.height===void 0)return this.fire(new h.ErrorEvent(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:g,height:y,data:x}=t,S=t;this.style.addImage(o,{data:new h.RGBAImage({width:g,height:y},new Uint8Array(x)),pixelRatio:n,stretchX:l,stretchY:d,content:m,sdf:s,version:0,userImage:S}),S.onAdd&&S.onAdd(this,o)}}}updateImage(o,t){const n=this.style.getImage(o);if(!n)return this.fire(new h.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const s=t instanceof HTMLImageElement||h.isImageBitmap(t)?h.exported.getImageData(t):t,{width:l,height:d,data:m}=s;if(l===void 0||d===void 0)return this.fire(new h.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(l!==n.data.width||d!==n.data.height)return this.fire(new h.ErrorEvent(new Error("The width and height of the updated image must be that same as the previous version of the image")));const g=!(t instanceof HTMLImageElement||h.isImageBitmap(t));n.data.replace(m,g),this.style.updateImage(o,n)}hasImage(o){return o?!!this.style.getImage(o):(this.fire(new h.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(o){this.style.removeImage(o)}loadImage(o,t){Qt.getImage(this._requestManager.transformRequest(o,dt.Image),t)}listImages(){return this.style.listImages()}addLayer(o,t){return this._lazyInitEmptyStyle(),this.style.addLayer(o,t),this._update(!0)}moveLayer(o,t){return this.style.moveLayer(o,t),this._update(!0)}removeLayer(o){return this.style.removeLayer(o),this._update(!0)}getLayer(o){return this.style.getLayer(o)}setLayerZoomRange(o,t,n){return this.style.setLayerZoomRange(o,t,n),this._update(!0)}setFilter(o,t,n={}){return this.style.setFilter(o,t,n),this._update(!0)}getFilter(o){return this.style.getFilter(o)}setPaintProperty(o,t,n,s={}){return this.style.setPaintProperty(o,t,n,s),this._update(!0)}getPaintProperty(o,t){return this.style.getPaintProperty(o,t)}setLayoutProperty(o,t,n,s={}){return this.style.setLayoutProperty(o,t,n,s),this._update(!0)}getLayoutProperty(o,t){return this.style.getLayoutProperty(o,t)}setGlyphs(o,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(o,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(o,t,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(o,t,n,s=>{s||this._update(!0)}),this}removeSprite(o){return this._lazyInitEmptyStyle(),this.style.removeSprite(o),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(o,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(o,t,n=>{n||this._update(!0)}),this}setLight(o,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(o,t),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(o,t){return this.style.setFeatureState(o,t),this._update()}removeFeatureState(o,t){return this.style.removeFeatureState(o,t),this._update()}getFeatureState(o){return this.style.getFeatureState(o)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let o=0,t=0;return this._container&&(o=this._container.clientWidth||400,t=this._container.clientHeight||300),[o,t]}_setupContainer(){const o=this._container;o.classList.add("maplibregl-map");const t=this._canvasContainer=ee.create("div","maplibregl-canvas-container",o);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=ee.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region");const n=this._containerDimensions();this._resizeCanvas(n[0],n[1],this.getPixelRatio());const s=this._controlContainer=ee.create("div","maplibregl-control-container",o),l=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(d=>{l[d]=ee.create("div",`maplibregl-ctrl-${d} `,s)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_setupCooperativeGestures(){const o=this._container;this._metaPress=!1,this._cooperativeGesturesScreen=ee.create("div","maplibregl-cooperative-gesture-screen",o);let t="Control",n=typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.windowsHelpText?this._cooperativeGestures.windowsHelpText:"Use Ctrl + scroll to zoom the map";navigator.platform.indexOf("Mac")===0&&(n=typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.macHelpText?this._cooperativeGestures.macHelpText:"Use \u2318 + scroll to zoom the map",t="Meta"),this._cooperativeGesturesScreen.innerHTML=`
576
+ `),te=y.createShader(y.FRAGMENT_SHADER);if(y.isContextLost())return void(this.failedToCreate=!0);y.shaderSource(te,H),y.compileShader(te),y.attachShader(this.program,te);const ae=y.createShader(y.VERTEX_SHADER);if(y.isContextLost())return void(this.failedToCreate=!0);y.shaderSource(ae,V),y.compileShader(ae),y.attachShader(this.program,ae),this.attributes={};const se={};this.numAttributes=T.length;for(let ue=0;ue<this.numAttributes;ue++)T[ue]&&(y.bindAttribLocation(this.program,ue,T[ue]),this.attributes[T[ue]]=ue);y.linkProgram(this.program),y.deleteShader(ae),y.deleteShader(te);for(let ue=0;ue<G.length;ue++){const me=G[ue];if(me&&!se[me]){const xe=y.getUniformLocation(this.program,me);xe&&(se[me]=xe)}}this.fixedUniforms=d(t,se),this.terrainUniforms=((ue,me)=>({u_depth:new h.Uniform1i(ue,me.u_depth),u_terrain:new h.Uniform1i(ue,me.u_terrain),u_terrain_dim:new h.Uniform1f(ue,me.u_terrain_dim),u_terrain_matrix:new h.UniformMatrix4f(ue,me.u_terrain_matrix),u_terrain_unpack:new h.Uniform4f(ue,me.u_terrain_unpack),u_terrain_exaggeration:new h.Uniform1f(ue,me.u_terrain_exaggeration)}))(t,se),this.binderUniforms=l?l.getUniforms(t,se):[]}draw(t,n,s,l,d,m,g,y,x,S,T,M,F,O,D,G,Y,H){const V=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(s),t.setStencilMode(l),t.setColorMode(d),t.setCullFace(m),y){t.activeTexture.set(V.TEXTURE2),V.bindTexture(V.TEXTURE_2D,y.depthTexture),t.activeTexture.set(V.TEXTURE3),V.bindTexture(V.TEXTURE_2D,y.texture);for(const ae in this.terrainUniforms)this.terrainUniforms[ae].set(y[ae])}for(const ae in this.fixedUniforms)this.fixedUniforms[ae].set(g[ae]);D&&D.setUniforms(t,this.binderUniforms,F,{zoom:O});let te=0;switch(n){case V.LINES:te=2;break;case V.TRIANGLES:te=3;break;case V.LINE_STRIP:te=1}for(const ae of M.get()){const se=ae.vaos||(ae.vaos={});(se[x]||(se[x]=new fs)).bind(t,this,S,D?D.getPaintVertexBuffers():[],T,ae.vertexOffset,G,Y,H),V.drawElements(n,ae.primitiveLength*te,V.UNSIGNED_SHORT,ae.primitiveOffset*te*2)}}}function _s(o,t,n){const s=1/ce(n,1,t.transform.tileZoom),l=Math.pow(2,n.tileID.overscaledZ),d=n.tileSize*Math.pow(2,t.transform.tileZoom)/l,m=d*(n.tileID.canonical.x+n.tileID.wrap*l),g=d*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[s,o.fromScale,o.toScale],u_fade:o.t,u_pixel_coord_upper:[m>>16,g>>16],u_pixel_coord_lower:[65535&m,65535&g]}}const ys=(o,t,n,s)=>{const l=t.style.light,d=l.properties.get("position"),m=[d.x,d.y,d.z],g=function(){var x=new h.ARRAY_TYPE(9);return h.ARRAY_TYPE!=Float32Array&&(x[1]=0,x[2]=0,x[3]=0,x[5]=0,x[6]=0,x[7]=0),x[0]=1,x[4]=1,x[8]=1,x}();l.properties.get("anchor")==="viewport"&&function(x,S){var T=Math.sin(S),M=Math.cos(S);x[0]=M,x[1]=T,x[2]=0,x[3]=-T,x[4]=M,x[5]=0,x[6]=0,x[7]=0,x[8]=1}(g,-t.transform.angle),function(x,S,T){var M=S[0],F=S[1],O=S[2];x[0]=M*T[0]+F*T[3]+O*T[6],x[1]=M*T[1]+F*T[4]+O*T[7],x[2]=M*T[2]+F*T[5]+O*T[8]}(m,m,g);const y=l.properties.get("color");return{u_matrix:o,u_lightpos:m,u_lightintensity:l.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_vertical_gradient:+n,u_opacity:s}},Kl=(o,t,n,s,l,d,m)=>h.extend(ys(o,t,n,s),_s(d,t,m),{u_height_factor:-Math.pow(2,l.overscaledZ)/m.tileSize/8}),wn=o=>({u_matrix:o}),Tn=(o,t,n,s)=>h.extend(wn(o),_s(n,t,s)),Vo=(o,t)=>({u_matrix:o,u_world:t}),Pi=(o,t,n,s,l)=>h.extend(Tn(o,t,n,s),{u_world:l}),xs=(o,t,n,s)=>{const l=o.transform;let d,m;if(s.paint.get("circle-pitch-alignment")==="map"){const g=ce(n,1,l.zoom);d=!0,m=[g,g]}else d=!1,m=l.pixelsToGLUnits;return{u_camera_to_center_distance:l.cameraToCenterDistance,u_scale_with_map:+(s.paint.get("circle-pitch-scale")==="map"),u_matrix:o.translatePosMatrix(t.posMatrix,n,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_pitch_with_map:+d,u_device_pixel_ratio:o.pixelRatio,u_extrude_scale:m}},xa=(o,t,n)=>{const s=ce(n,1,t.zoom),l=Math.pow(2,t.zoom-n.tileID.overscaledZ),d=n.tileID.overscaleFactor();return{u_matrix:o,u_camera_to_center_distance:t.cameraToCenterDistance,u_pixels_to_tile_units:s,u_extrude_scale:[t.pixelsToGLUnits[0]/(s*l),t.pixelsToGLUnits[1]/(s*l)],u_overscale_factor:d}},Wn=(o,t,n=1)=>({u_matrix:o,u_color:t,u_overlay:0,u_overlay_scale:n}),va=o=>({u_matrix:o}),vs=(o,t,n,s)=>({u_matrix:o,u_extrude_scale:ce(t,1,n),u_intensity:s});function ba(o,t){const n=Math.pow(2,t.canonical.z),s=t.canonical.y;return[new h.MercatorCoordinate(0,s/n).toLngLat().lat,new h.MercatorCoordinate(0,(s+1)/n).toLngLat().lat]}const Hn=(o,t,n,s)=>{const l=o.transform;return{u_matrix:Yr(o,t,n,s),u_ratio:1/ce(t,1,l.zoom),u_device_pixel_ratio:o.pixelRatio,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]]}},bs=(o,t,n,s,l)=>h.extend(Hn(o,t,n,l),{u_image:0,u_image_height:s}),wa=(o,t,n,s,l)=>{const d=o.transform,m=ws(t,d);return{u_matrix:Yr(o,t,n,l),u_texsize:t.imageAtlasTexture.size,u_ratio:1/ce(t,1,d.zoom),u_device_pixel_ratio:o.pixelRatio,u_image:0,u_scale:[m,s.fromScale,s.toScale],u_fade:s.t,u_units_to_pixels:[1/d.pixelsToGLUnits[0],1/d.pixelsToGLUnits[1]]}},No=(o,t,n,s,l,d)=>{const m=o.lineAtlas,g=ws(t,o.transform),y=n.layout.get("line-cap")==="round",x=m.getDash(s.from,y),S=m.getDash(s.to,y),T=x.width*l.fromScale,M=S.width*l.toScale;return h.extend(Hn(o,t,n,d),{u_patternscale_a:[g/T,-x.height/2],u_patternscale_b:[g/M,-S.height/2],u_sdfgamma:m.width/(256*Math.min(T,M)*o.pixelRatio)/2,u_image:0,u_tex_y_a:x.y,u_tex_y_b:S.y,u_mix:l.t})};function ws(o,t){return 1/ce(o,1,t.tileZoom)}function Yr(o,t,n,s){return o.translatePosMatrix(s?s.posMatrix:t.tileID.posMatrix,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const Yl=(o,t,n,s,l)=>{return{u_matrix:o,u_tl_parent:t,u_scale_parent:n,u_buffer_scale:1,u_fade_t:s.mix,u_opacity:s.opacity*l.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:l.paint.get("raster-brightness-min"),u_brightness_high:l.paint.get("raster-brightness-max"),u_saturation_factor:(m=l.paint.get("raster-saturation"),m>0?1-1/(1.001-m):-m),u_contrast_factor:(d=l.paint.get("raster-contrast"),d>0?1/(1-d):1+d),u_spin_weights:Jl(l.paint.get("raster-hue-rotate"))};var d,m};function Jl(o){o*=Math.PI/180;const t=Math.sin(o),n=Math.cos(o);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const $o=(o,t,n,s,l,d,m,g,y,x)=>{const S=l.transform;return{u_is_size_zoom_constant:+(o==="constant"||o==="source"),u_is_size_feature_constant:+(o==="constant"||o==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:S.cameraToCenterDistance,u_pitch:S.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:S.width/S.height,u_fade_change:l.options.fadeDuration?l.symbolFadeChange:1,u_matrix:d,u_label_plane_matrix:m,u_coord_matrix:g,u_is_text:+y,u_pitch_with_map:+s,u_texsize:x,u_texture:0}},Go=(o,t,n,s,l,d,m,g,y,x,S)=>{const T=l.transform;return h.extend($o(o,t,n,s,l,d,m,g,y,x),{u_gamma_scale:s?Math.cos(T._pitch)*T.cameraToCenterDistance:1,u_device_pixel_ratio:l.pixelRatio,u_is_halo:+S})},Ql=(o,t,n,s,l,d,m,g,y,x)=>h.extend(Go(o,t,n,s,l,d,m,g,!0,y,!0),{u_texsize_icon:x,u_texture_icon:1}),ec=(o,t,n)=>({u_matrix:o,u_opacity:t,u_color:n}),Ts=(o,t,n,s,l,d)=>h.extend(function(m,g,y,x){const S=y.imageManager.getPattern(m.from.toString()),T=y.imageManager.getPattern(m.to.toString()),{width:M,height:F}=y.imageManager.getPixelSize(),O=Math.pow(2,x.tileID.overscaledZ),D=x.tileSize*Math.pow(2,y.transform.tileZoom)/O,G=D*(x.tileID.canonical.x+x.tileID.wrap*O),Y=D*x.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:S.tl,u_pattern_br_a:S.br,u_pattern_tl_b:T.tl,u_pattern_br_b:T.br,u_texsize:[M,F],u_mix:g.t,u_pattern_size_a:S.displaySize,u_pattern_size_b:T.displaySize,u_scale_a:g.fromScale,u_scale_b:g.toScale,u_tile_units_to_pixels:1/ce(x,1,y.transform.tileZoom),u_pixel_coord_upper:[G>>16,Y>>16],u_pixel_coord_lower:[65535&G,65535&Y]}}(s,d,n,l),{u_matrix:o,u_opacity:t}),Ta={fillExtrusion:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_lightpos:new h.Uniform3f(o,t.u_lightpos),u_lightintensity:new h.Uniform1f(o,t.u_lightintensity),u_lightcolor:new h.Uniform3f(o,t.u_lightcolor),u_vertical_gradient:new h.Uniform1f(o,t.u_vertical_gradient),u_opacity:new h.Uniform1f(o,t.u_opacity)}),fillExtrusionPattern:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_lightpos:new h.Uniform3f(o,t.u_lightpos),u_lightintensity:new h.Uniform1f(o,t.u_lightintensity),u_lightcolor:new h.Uniform3f(o,t.u_lightcolor),u_vertical_gradient:new h.Uniform1f(o,t.u_vertical_gradient),u_height_factor:new h.Uniform1f(o,t.u_height_factor),u_image:new h.Uniform1i(o,t.u_image),u_texsize:new h.Uniform2f(o,t.u_texsize),u_pixel_coord_upper:new h.Uniform2f(o,t.u_pixel_coord_upper),u_pixel_coord_lower:new h.Uniform2f(o,t.u_pixel_coord_lower),u_scale:new h.Uniform3f(o,t.u_scale),u_fade:new h.Uniform1f(o,t.u_fade),u_opacity:new h.Uniform1f(o,t.u_opacity)}),fill:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix)}),fillPattern:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_image:new h.Uniform1i(o,t.u_image),u_texsize:new h.Uniform2f(o,t.u_texsize),u_pixel_coord_upper:new h.Uniform2f(o,t.u_pixel_coord_upper),u_pixel_coord_lower:new h.Uniform2f(o,t.u_pixel_coord_lower),u_scale:new h.Uniform3f(o,t.u_scale),u_fade:new h.Uniform1f(o,t.u_fade)}),fillOutline:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_world:new h.Uniform2f(o,t.u_world)}),fillOutlinePattern:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_world:new h.Uniform2f(o,t.u_world),u_image:new h.Uniform1i(o,t.u_image),u_texsize:new h.Uniform2f(o,t.u_texsize),u_pixel_coord_upper:new h.Uniform2f(o,t.u_pixel_coord_upper),u_pixel_coord_lower:new h.Uniform2f(o,t.u_pixel_coord_lower),u_scale:new h.Uniform3f(o,t.u_scale),u_fade:new h.Uniform1f(o,t.u_fade)}),circle:(o,t)=>({u_camera_to_center_distance:new h.Uniform1f(o,t.u_camera_to_center_distance),u_scale_with_map:new h.Uniform1i(o,t.u_scale_with_map),u_pitch_with_map:new h.Uniform1i(o,t.u_pitch_with_map),u_extrude_scale:new h.Uniform2f(o,t.u_extrude_scale),u_device_pixel_ratio:new h.Uniform1f(o,t.u_device_pixel_ratio),u_matrix:new h.UniformMatrix4f(o,t.u_matrix)}),collisionBox:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_camera_to_center_distance:new h.Uniform1f(o,t.u_camera_to_center_distance),u_pixels_to_tile_units:new h.Uniform1f(o,t.u_pixels_to_tile_units),u_extrude_scale:new h.Uniform2f(o,t.u_extrude_scale),u_overscale_factor:new h.Uniform1f(o,t.u_overscale_factor)}),collisionCircle:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_inv_matrix:new h.UniformMatrix4f(o,t.u_inv_matrix),u_camera_to_center_distance:new h.Uniform1f(o,t.u_camera_to_center_distance),u_viewport_size:new h.Uniform2f(o,t.u_viewport_size)}),debug:(o,t)=>({u_color:new h.UniformColor(o,t.u_color),u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_overlay:new h.Uniform1i(o,t.u_overlay),u_overlay_scale:new h.Uniform1f(o,t.u_overlay_scale)}),clippingMask:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix)}),heatmap:(o,t)=>({u_extrude_scale:new h.Uniform1f(o,t.u_extrude_scale),u_intensity:new h.Uniform1f(o,t.u_intensity),u_matrix:new h.UniformMatrix4f(o,t.u_matrix)}),heatmapTexture:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_world:new h.Uniform2f(o,t.u_world),u_image:new h.Uniform1i(o,t.u_image),u_color_ramp:new h.Uniform1i(o,t.u_color_ramp),u_opacity:new h.Uniform1f(o,t.u_opacity)}),hillshade:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_image:new h.Uniform1i(o,t.u_image),u_latrange:new h.Uniform2f(o,t.u_latrange),u_light:new h.Uniform2f(o,t.u_light),u_shadow:new h.UniformColor(o,t.u_shadow),u_highlight:new h.UniformColor(o,t.u_highlight),u_accent:new h.UniformColor(o,t.u_accent)}),hillshadePrepare:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_image:new h.Uniform1i(o,t.u_image),u_dimension:new h.Uniform2f(o,t.u_dimension),u_zoom:new h.Uniform1f(o,t.u_zoom),u_unpack:new h.Uniform4f(o,t.u_unpack)}),line:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_ratio:new h.Uniform1f(o,t.u_ratio),u_device_pixel_ratio:new h.Uniform1f(o,t.u_device_pixel_ratio),u_units_to_pixels:new h.Uniform2f(o,t.u_units_to_pixels)}),lineGradient:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_ratio:new h.Uniform1f(o,t.u_ratio),u_device_pixel_ratio:new h.Uniform1f(o,t.u_device_pixel_ratio),u_units_to_pixels:new h.Uniform2f(o,t.u_units_to_pixels),u_image:new h.Uniform1i(o,t.u_image),u_image_height:new h.Uniform1f(o,t.u_image_height)}),linePattern:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_texsize:new h.Uniform2f(o,t.u_texsize),u_ratio:new h.Uniform1f(o,t.u_ratio),u_device_pixel_ratio:new h.Uniform1f(o,t.u_device_pixel_ratio),u_image:new h.Uniform1i(o,t.u_image),u_units_to_pixels:new h.Uniform2f(o,t.u_units_to_pixels),u_scale:new h.Uniform3f(o,t.u_scale),u_fade:new h.Uniform1f(o,t.u_fade)}),lineSDF:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_ratio:new h.Uniform1f(o,t.u_ratio),u_device_pixel_ratio:new h.Uniform1f(o,t.u_device_pixel_ratio),u_units_to_pixels:new h.Uniform2f(o,t.u_units_to_pixels),u_patternscale_a:new h.Uniform2f(o,t.u_patternscale_a),u_patternscale_b:new h.Uniform2f(o,t.u_patternscale_b),u_sdfgamma:new h.Uniform1f(o,t.u_sdfgamma),u_image:new h.Uniform1i(o,t.u_image),u_tex_y_a:new h.Uniform1f(o,t.u_tex_y_a),u_tex_y_b:new h.Uniform1f(o,t.u_tex_y_b),u_mix:new h.Uniform1f(o,t.u_mix)}),raster:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_tl_parent:new h.Uniform2f(o,t.u_tl_parent),u_scale_parent:new h.Uniform1f(o,t.u_scale_parent),u_buffer_scale:new h.Uniform1f(o,t.u_buffer_scale),u_fade_t:new h.Uniform1f(o,t.u_fade_t),u_opacity:new h.Uniform1f(o,t.u_opacity),u_image0:new h.Uniform1i(o,t.u_image0),u_image1:new h.Uniform1i(o,t.u_image1),u_brightness_low:new h.Uniform1f(o,t.u_brightness_low),u_brightness_high:new h.Uniform1f(o,t.u_brightness_high),u_saturation_factor:new h.Uniform1f(o,t.u_saturation_factor),u_contrast_factor:new h.Uniform1f(o,t.u_contrast_factor),u_spin_weights:new h.Uniform3f(o,t.u_spin_weights)}),symbolIcon:(o,t)=>({u_is_size_zoom_constant:new h.Uniform1i(o,t.u_is_size_zoom_constant),u_is_size_feature_constant:new h.Uniform1i(o,t.u_is_size_feature_constant),u_size_t:new h.Uniform1f(o,t.u_size_t),u_size:new h.Uniform1f(o,t.u_size),u_camera_to_center_distance:new h.Uniform1f(o,t.u_camera_to_center_distance),u_pitch:new h.Uniform1f(o,t.u_pitch),u_rotate_symbol:new h.Uniform1i(o,t.u_rotate_symbol),u_aspect_ratio:new h.Uniform1f(o,t.u_aspect_ratio),u_fade_change:new h.Uniform1f(o,t.u_fade_change),u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_label_plane_matrix:new h.UniformMatrix4f(o,t.u_label_plane_matrix),u_coord_matrix:new h.UniformMatrix4f(o,t.u_coord_matrix),u_is_text:new h.Uniform1i(o,t.u_is_text),u_pitch_with_map:new h.Uniform1i(o,t.u_pitch_with_map),u_texsize:new h.Uniform2f(o,t.u_texsize),u_texture:new h.Uniform1i(o,t.u_texture)}),symbolSDF:(o,t)=>({u_is_size_zoom_constant:new h.Uniform1i(o,t.u_is_size_zoom_constant),u_is_size_feature_constant:new h.Uniform1i(o,t.u_is_size_feature_constant),u_size_t:new h.Uniform1f(o,t.u_size_t),u_size:new h.Uniform1f(o,t.u_size),u_camera_to_center_distance:new h.Uniform1f(o,t.u_camera_to_center_distance),u_pitch:new h.Uniform1f(o,t.u_pitch),u_rotate_symbol:new h.Uniform1i(o,t.u_rotate_symbol),u_aspect_ratio:new h.Uniform1f(o,t.u_aspect_ratio),u_fade_change:new h.Uniform1f(o,t.u_fade_change),u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_label_plane_matrix:new h.UniformMatrix4f(o,t.u_label_plane_matrix),u_coord_matrix:new h.UniformMatrix4f(o,t.u_coord_matrix),u_is_text:new h.Uniform1i(o,t.u_is_text),u_pitch_with_map:new h.Uniform1i(o,t.u_pitch_with_map),u_texsize:new h.Uniform2f(o,t.u_texsize),u_texture:new h.Uniform1i(o,t.u_texture),u_gamma_scale:new h.Uniform1f(o,t.u_gamma_scale),u_device_pixel_ratio:new h.Uniform1f(o,t.u_device_pixel_ratio),u_is_halo:new h.Uniform1i(o,t.u_is_halo)}),symbolTextAndIcon:(o,t)=>({u_is_size_zoom_constant:new h.Uniform1i(o,t.u_is_size_zoom_constant),u_is_size_feature_constant:new h.Uniform1i(o,t.u_is_size_feature_constant),u_size_t:new h.Uniform1f(o,t.u_size_t),u_size:new h.Uniform1f(o,t.u_size),u_camera_to_center_distance:new h.Uniform1f(o,t.u_camera_to_center_distance),u_pitch:new h.Uniform1f(o,t.u_pitch),u_rotate_symbol:new h.Uniform1i(o,t.u_rotate_symbol),u_aspect_ratio:new h.Uniform1f(o,t.u_aspect_ratio),u_fade_change:new h.Uniform1f(o,t.u_fade_change),u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_label_plane_matrix:new h.UniformMatrix4f(o,t.u_label_plane_matrix),u_coord_matrix:new h.UniformMatrix4f(o,t.u_coord_matrix),u_is_text:new h.Uniform1i(o,t.u_is_text),u_pitch_with_map:new h.Uniform1i(o,t.u_pitch_with_map),u_texsize:new h.Uniform2f(o,t.u_texsize),u_texsize_icon:new h.Uniform2f(o,t.u_texsize_icon),u_texture:new h.Uniform1i(o,t.u_texture),u_texture_icon:new h.Uniform1i(o,t.u_texture_icon),u_gamma_scale:new h.Uniform1f(o,t.u_gamma_scale),u_device_pixel_ratio:new h.Uniform1f(o,t.u_device_pixel_ratio),u_is_halo:new h.Uniform1i(o,t.u_is_halo)}),background:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_opacity:new h.Uniform1f(o,t.u_opacity),u_color:new h.UniformColor(o,t.u_color)}),backgroundPattern:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_opacity:new h.Uniform1f(o,t.u_opacity),u_image:new h.Uniform1i(o,t.u_image),u_pattern_tl_a:new h.Uniform2f(o,t.u_pattern_tl_a),u_pattern_br_a:new h.Uniform2f(o,t.u_pattern_br_a),u_pattern_tl_b:new h.Uniform2f(o,t.u_pattern_tl_b),u_pattern_br_b:new h.Uniform2f(o,t.u_pattern_br_b),u_texsize:new h.Uniform2f(o,t.u_texsize),u_mix:new h.Uniform1f(o,t.u_mix),u_pattern_size_a:new h.Uniform2f(o,t.u_pattern_size_a),u_pattern_size_b:new h.Uniform2f(o,t.u_pattern_size_b),u_scale_a:new h.Uniform1f(o,t.u_scale_a),u_scale_b:new h.Uniform1f(o,t.u_scale_b),u_pixel_coord_upper:new h.Uniform2f(o,t.u_pixel_coord_upper),u_pixel_coord_lower:new h.Uniform2f(o,t.u_pixel_coord_lower),u_tile_units_to_pixels:new h.Uniform1f(o,t.u_tile_units_to_pixels)}),terrain:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_texture:new h.Uniform1i(o,t.u_texture),u_ele_delta:new h.Uniform1f(o,t.u_ele_delta)}),terrainDepth:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_ele_delta:new h.Uniform1f(o,t.u_ele_delta)}),terrainCoords:(o,t)=>({u_matrix:new h.UniformMatrix4f(o,t.u_matrix),u_texture:new h.Uniform1i(o,t.u_texture),u_terrain_coords_id:new h.Uniform1f(o,t.u_terrain_coords_id),u_ele_delta:new h.Uniform1f(o,t.u_ele_delta)})};class Ss{constructor(t,n,s){this.context=t;const l=t.gl;this.buffer=l.createBuffer(),this.dynamicDraw=!!s,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),l.bufferData(l.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?l.DYNAMIC_DRAW:l.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Es={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Sn{constructor(t,n,s,l){this.length=n.length,this.attributes=s,this.itemSize=n.bytesPerElement,this.dynamicDraw=l,this.context=t;const d=t.gl;this.buffer=d.createBuffer(),t.bindVertexBuffer.set(this.buffer),d.bufferData(d.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?d.DYNAMIC_DRAW:d.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,n){for(let s=0;s<this.attributes.length;s++){const l=n.attributes[this.attributes[s].name];l!==void 0&&t.enableVertexAttribArray(l)}}setVertexAttribPointers(t,n,s){for(let l=0;l<this.attributes.length;l++){const d=this.attributes[l],m=n.attributes[d.name];m!==void 0&&t.vertexAttribPointer(m,d.components,t[Es[d.type]],!1,this.itemSize,d.offset+this.itemSize*(s||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class pt{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class jo extends pt{getDefault(){return h.Color.transparent}set(t){const n=this.current;(t.r!==n.r||t.g!==n.g||t.b!==n.b||t.a!==n.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Is extends pt{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class Jr extends pt{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class qo extends pt{getDefault(){return[!0,!0,!0,!0]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class En extends pt{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class In extends pt{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class Zo extends pt{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const n=this.current;(t.func!==n.func||t.ref!==n.ref||t.mask!==n.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class As extends pt{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class vt extends pt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),this.current=t,this.dirty=!1}}class Sa extends pt{getDefault(){return[0,1]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class tc extends pt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),this.current=t,this.dirty=!1}}class Xo extends pt{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class Kn extends pt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.BLEND):n.disable(n.BLEND),this.current=t,this.dirty=!1}}class ic extends pt{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class rc extends pt{getDefault(){return h.Color.transparent}set(t){const n=this.current;(t.r!==n.r||t.g!==n.g||t.b!==n.b||t.a!==n.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Wo extends pt{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class nc extends pt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.CULL_FACE):n.disable(n.CULL_FACE),this.current=t,this.dirty=!1}}class Cs extends pt{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Ea extends pt{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class Ia extends pt{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Ms extends pt{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class Ps extends pt{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Ho extends pt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindFramebuffer(n.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Aa extends pt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindRenderbuffer(n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Ca extends pt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindTexture(n.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class $i extends pt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindBuffer(n.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Ko extends pt{getDefault(){return null}set(t){const n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class ks extends pt{constructor(t){super(t),this.vao=t.extVertexArrayObject}getDefault(){return null}set(t){this.vao&&(t!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(t),this.current=t,this.dirty=!1)}}class Yo extends pt{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class An extends pt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class Ma extends pt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class Pa extends pt{constructor(t,n){super(t),this.context=t,this.parent=n}getDefault(){return null}}class ac extends Pa{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class zs extends Pa{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class sc{constructor(t,n,s,l){this.context=t,this.width=n,this.height=s;const d=t.gl,m=this.framebuffer=d.createFramebuffer();if(this.colorAttachment=new ac(t,m),l&&(this.depthAttachment=new zs(t,m)),d.checkFramebufferStatus(d.FRAMEBUFFER)!==d.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer is not complete")}destroy(){const t=this.context.gl,n=this.colorAttachment.get();if(n&&t.deleteTexture(n),this.depthAttachment){const s=this.depthAttachment.get();s&&t.deleteRenderbuffer(s)}t.deleteFramebuffer(this.framebuffer)}}class Ot{constructor(t,n,s){this.blendFunction=t,this.blendColor=n,this.mask=s}}Ot.Replace=[1,0],Ot.disabled=new Ot(Ot.Replace,h.Color.transparent,[!1,!1,!1,!1]),Ot.unblended=new Ot(Ot.Replace,h.Color.transparent,[!0,!0,!0,!0]),Ot.alphaBlended=new Ot([1,771],h.Color.transparent,[!0,!0,!0,!0]);class ka{constructor(t){this.gl=t,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new jo(this),this.clearDepth=new Is(this),this.clearStencil=new Jr(this),this.colorMask=new qo(this),this.depthMask=new En(this),this.stencilMask=new In(this),this.stencilFunc=new Zo(this),this.stencilOp=new As(this),this.stencilTest=new vt(this),this.depthRange=new Sa(this),this.depthTest=new tc(this),this.depthFunc=new Xo(this),this.blend=new Kn(this),this.blendFunc=new ic(this),this.blendColor=new rc(this),this.blendEquation=new Wo(this),this.cullFace=new nc(this),this.cullFaceSide=new Cs(this),this.frontFace=new Ea(this),this.program=new Ia(this),this.activeTexture=new Ms(this),this.viewport=new Ps(this),this.bindFramebuffer=new Ho(this),this.bindRenderbuffer=new Aa(this),this.bindTexture=new Ca(this),this.bindVertexBuffer=new $i(this),this.bindElementBuffer=new Ko(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new ks(this),this.pixelStoreUnpack=new Yo(this),this.pixelStoreUnpackPremultiplyAlpha=new An(this),this.pixelStoreUnpackFlipY=new Ma(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureHalfFloat=t.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(t.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float")),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE)}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.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,n){return new Ss(this,t,n)}createVertexBuffer(t,n,s){return new Sn(this,t,n,s)}createRenderbuffer(t,n,s){const l=this.gl,d=l.createRenderbuffer();return this.bindRenderbuffer.set(d),l.renderbufferStorage(l.RENDERBUFFER,t,n,s),this.bindRenderbuffer.set(null),d}createFramebuffer(t,n,s){return new sc(this,t,n,s)}clear({color:t,depth:n}){const s=this.gl;let l=0;t&&(l|=s.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),n!==void 0&&(l|=s.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),s.clear(l)}setCullFace(t){t.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){pe(t.blendFunction,Ot.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class at{constructor(t,n,s){this.func=t,this.mask=n,this.range=s}}at.ReadOnly=!1,at.ReadWrite=!0,at.disabled=new at(519,at.ReadOnly,[0,1]);const za=7680;class Lt{constructor(t,n,s,l,d,m){this.test=t,this.ref=n,this.mask=s,this.fail=l,this.depthFail=d,this.pass=m}}Lt.disabled=new Lt({func:519,mask:0},0,0,za,za,za);class Et{constructor(t,n,s){this.enable=t,this.mode=n,this.frontFace=s}}let Cn;function Ls(o,t,n,s,l,d,m){const g=o.context,y=g.gl,x=o.useProgram("collisionBox"),S=[];let T=0,M=0;for(let V=0;V<s.length;V++){const te=s[V],ae=t.getTile(te),se=ae.getBucket(n);if(!se)continue;let ue=te.posMatrix;l[0]===0&&l[1]===0||(ue=o.translatePosMatrix(te.posMatrix,ae,l,d));const me=m?se.textCollisionBox:se.iconCollisionBox,xe=se.collisionCircleArray;if(xe.length>0){const _e=h.create(),we=ue;h.mul(_e,se.placementInvProjMatrix,o.transform.glCoordMatrix),h.mul(_e,_e,se.placementViewportMatrix),S.push({circleArray:xe,circleOffset:M,transform:we,invTransform:_e,coord:te}),T+=xe.length/4,M=T}me&&x.draw(g,y.LINES,at.disabled,Lt.disabled,o.colorModeForRenderPass(),Et.disabled,xa(ue,o.transform,ae),o.style.map.terrain&&o.style.map.terrain.getTerrainData(te),n.id,me.layoutVertexBuffer,me.indexBuffer,me.segments,null,o.transform.zoom,null,null,me.collisionVertexBuffer)}if(!m||!S.length)return;const F=o.useProgram("collisionCircle"),O=new h.CollisionCircleLayoutArray;O.resize(4*T),O._trim();let D=0;for(const V of S)for(let te=0;te<V.circleArray.length/4;te++){const ae=4*te,se=V.circleArray[ae+0],ue=V.circleArray[ae+1],me=V.circleArray[ae+2],xe=V.circleArray[ae+3];O.emplace(D++,se,ue,me,xe,0),O.emplace(D++,se,ue,me,xe,1),O.emplace(D++,se,ue,me,xe,2),O.emplace(D++,se,ue,me,xe,3)}(!Cn||Cn.length<2*T)&&(Cn=function(V){const te=2*V,ae=new h.QuadTriangleArray;ae.resize(te),ae._trim();for(let se=0;se<te;se++){const ue=6*se;ae.uint16[ue+0]=4*se+0,ae.uint16[ue+1]=4*se+1,ae.uint16[ue+2]=4*se+2,ae.uint16[ue+3]=4*se+2,ae.uint16[ue+4]=4*se+3,ae.uint16[ue+5]=4*se+0}return ae}(T));const G=g.createIndexBuffer(Cn,!0),Y=g.createVertexBuffer(O,h.collisionCircleLayout.members,!0);for(const V of S){const te={u_matrix:V.transform,u_inv_matrix:V.invTransform,u_camera_to_center_distance:(H=o.transform).cameraToCenterDistance,u_viewport_size:[H.width,H.height]};F.draw(g,y.TRIANGLES,at.disabled,Lt.disabled,o.colorModeForRenderPass(),Et.disabled,te,o.style.map.terrain&&o.style.map.terrain.getTerrainData(V.coord),n.id,Y,G,h.SegmentVector.simpleSegment(0,2*V.circleOffset,V.circleArray.length,V.circleArray.length/2),null,o.transform.zoom,null,null,null)}var H;Y.destroy(),G.destroy()}Et.disabled=new Et(!1,1029,2305),Et.backCCW=new Et(!0,1029,2305);const Jo=h.identity(new Float32Array(16));function Qo(o,t,n,s,l,d){const{horizontalAlign:m,verticalAlign:g}=h.getAnchorAlignment(o),y=-(m-.5)*t,x=-(g-.5)*n,S=h.evaluateVariableOffset(o,s);return new h.pointGeometry((y/l+S[0])*d,(x/l+S[1])*d)}function el(o,t,n,s,l,d,m,g,y,x,S){const T=o.text.placedSymbolArray,M=o.text.dynamicLayoutVertexArray,F=o.icon.dynamicLayoutVertexArray,O={};M.clear();for(let D=0;D<T.length;D++){const G=T.get(D),Y=G.hidden||!G.crossTileID||o.allowVerticalPlacement&&!G.placedOrientation?null:s[G.crossTileID];if(Y){const H=new h.pointGeometry(G.anchorX,G.anchorY),V=gi(H,n?m:d,S),te=yr(l.cameraToCenterDistance,V.signedDistanceFromCamera);let ae=h.evaluateSizeForFeature(o.textSizeData,y,G)*te/h.ONE_EM;n&&(ae*=o.tilePixelRatio/g);const{width:se,height:ue,anchor:me,textOffset:xe,textBoxScale:_e}=Y,we=Qo(me,se,ue,xe,_e,ae),ze=n?gi(H.add(we),d,S).point:V.point.add(t?we.rotate(-l.angle):we),We=o.allowVerticalPlacement&&G.placedOrientation===h.WritingMode.vertical?Math.PI/2:0;for(let Ke=0;Ke<G.numGlyphs;Ke++)h.addDynamicAttributes(M,ze,We);x&&G.associatedIconIndex>=0&&(O[G.associatedIconIndex]={shiftedAnchor:ze,angle:We})}else q(G.numGlyphs,M)}if(x){F.clear();const D=o.icon.placedSymbolArray;for(let G=0;G<D.length;G++){const Y=D.get(G);if(Y.hidden)q(Y.numGlyphs,F);else{const H=O[G];if(H)for(let V=0;V<Y.numGlyphs;V++)h.addDynamicAttributes(F,H.shiftedAnchor,H.angle);else q(Y.numGlyphs,F)}}o.icon.dynamicLayoutVertexBuffer.updateData(F)}o.text.dynamicLayoutVertexBuffer.updateData(M)}function tl(o,t,n){return n.iconsInText&&t?"symbolTextAndIcon":o?"symbolSDF":"symbolIcon"}function kr(o,t,n,s,l,d,m,g,y,x,S,T){const M=o.context,F=M.gl,O=o.transform,D=g==="map",G=y==="map",Y=g!=="viewport"&&n.layout.get("symbol-placement")!=="point",H=D&&!G&&!Y,V=!n.layout.get("symbol-sort-key").isConstant();let te=!1;const ae=o.depthModeForSublayer(0,at.ReadOnly),se=n.layout.get("text-variable-anchor"),ue=[];for(const me of s){const xe=t.getTile(me),_e=xe.getBucket(n);if(!_e)continue;const we=l?_e.text:_e.icon;if(!we||!we.segments.get().length||!we.hasVisibleVertices)continue;const ze=we.programConfigurations.get(n.id),We=l||_e.sdfIcons,Ke=l?_e.textSizeData:_e.iconSizeData,Le=G||O.pitch!==0,mt=o.useProgram(tl(We,l,_e),ze),ft=h.evaluateSizeForZoom(Ke,O.zoom),tt=o.style.map.terrain&&o.style.map.terrain.getTerrainData(me);let ht,wt,gt,ji,qi=[0,0],ni=null;if(l)wt=xe.glyphAtlasTexture,gt=F.LINEAR,ht=xe.glyphAtlasTexture.size,_e.iconsInText&&(qi=xe.imageAtlasTexture.size,ni=xe.imageAtlasTexture,ji=Le||o.options.rotating||o.options.zooming||Ke.kind==="composite"||Ke.kind==="camera"?F.LINEAR:F.NEAREST);else{const cr=n.layout.get("icon-size").constantOr(0)!==1||_e.iconsNeedLinear;wt=xe.imageAtlasTexture,gt=We||o.options.rotating||o.options.zooming||cr||Le?F.LINEAR:F.NEAREST,ht=xe.imageAtlasTexture.size}const ki=ce(xe,1,o.transform.zoom),_i=Yt(me.posMatrix,G,D,o.transform,ki),Ji=fi(me.posMatrix,G,D,o.transform,ki),Rr=se&&_e.hasTextData(),Ka=n.layout.get("icon-text-fit")!=="none"&&Rr&&_e.hasIconData();if(Y){const cr=o.style.map.terrain?(oo,nn)=>o.style.map.terrain.getElevation(me,oo,nn):null,Qi=n.layout.get("text-rotation-alignment")==="map";I(_e,me.posMatrix,o,l,_i,Ji,G,x,Qi,cr)}const qt=o.translatePosMatrix(me.posMatrix,xe,d,m),Dt=Y||l&&se||Ka?Jo:_i,_t=o.translatePosMatrix(Ji,xe,d,m,!0),yi=We&&n.paint.get(l?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let xi;xi=We?_e.iconsInText?Ql(Ke.kind,ft,H,G,o,qt,Dt,_t,ht,qi):Go(Ke.kind,ft,H,G,o,qt,Dt,_t,l,ht,!0):$o(Ke.kind,ft,H,G,o,qt,Dt,_t,l,ht);const Rt={program:mt,buffers:we,uniformValues:xi,atlasTexture:wt,atlasTextureIcon:ni,atlasInterpolation:gt,atlasInterpolationIcon:ji,isSDF:We,hasHalo:yi};if(V&&_e.canOverlap){te=!0;const cr=we.segments.get();for(const Qi of cr)ue.push({segments:new h.SegmentVector([Qi]),sortKey:Qi.sortKey,state:Rt,terrainData:tt})}else ue.push({segments:we.segments,sortKey:0,state:Rt,terrainData:tt})}te&&ue.sort((me,xe)=>me.sortKey-xe.sortKey);for(const me of ue){const xe=me.state;if(M.activeTexture.set(F.TEXTURE0),xe.atlasTexture.bind(xe.atlasInterpolation,F.CLAMP_TO_EDGE),xe.atlasTextureIcon&&(M.activeTexture.set(F.TEXTURE1),xe.atlasTextureIcon&&xe.atlasTextureIcon.bind(xe.atlasInterpolationIcon,F.CLAMP_TO_EDGE)),xe.isSDF){const _e=xe.uniformValues;xe.hasHalo&&(_e.u_is_halo=1,Ds(xe.buffers,me.segments,n,o,xe.program,ae,S,T,_e,me.terrainData)),_e.u_is_halo=0}Ds(xe.buffers,me.segments,n,o,xe.program,ae,S,T,xe.uniformValues,me.terrainData)}}function Ds(o,t,n,s,l,d,m,g,y,x){const S=s.context;l.draw(S,S.gl.TRIANGLES,d,m,g,Et.disabled,y,x,n.id,o.layoutVertexBuffer,o.indexBuffer,t,n.paint,s.transform.zoom,o.programConfigurations.get(n.id),o.dynamicLayoutVertexBuffer,o.opacityVertexBuffer)}function Rs(o,t,n,s,l){if(!n||!s||!s.imageAtlas)return;const d=s.imageAtlas.patternPositions;let m=d[n.to.toString()],g=d[n.from.toString()];if(!m||!g){const y=l.getPaintProperty(t);m=d[y],g=d[y]}m&&g&&o.setConstantPatternPositions(m,g)}function Bs(o,t,n,s,l,d,m){const g=o.context.gl,y="fill-pattern",x=n.paint.get(y),S=x&&x.constantOr(1),T=n.getCrossfadeParameters();let M,F,O,D,G;m?(F=S&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",M=g.LINES):(F=S?"fillPattern":"fill",M=g.TRIANGLES);const Y=x.constantOr(null);for(const H of s){const V=t.getTile(H);if(S&&!V.patternsLoaded())continue;const te=V.getBucket(n);if(!te)continue;const ae=te.programConfigurations.get(n.id),se=o.useProgram(F,ae),ue=o.style.map.terrain&&o.style.map.terrain.getTerrainData(H);S&&(o.context.activeTexture.set(g.TEXTURE0),V.imageAtlasTexture.bind(g.LINEAR,g.CLAMP_TO_EDGE),ae.updatePaintBuffers(T)),Rs(ae,y,Y,V,n);const me=ue?H:null,xe=o.translatePosMatrix(me?me.posMatrix:H.posMatrix,V,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(m){D=te.indexBuffer2,G=te.segments2;const _e=[g.drawingBufferWidth,g.drawingBufferHeight];O=F==="fillOutlinePattern"&&S?Pi(xe,o,T,V,_e):Vo(xe,_e)}else D=te.indexBuffer,G=te.segments,O=S?Tn(xe,o,T,V):wn(xe);se.draw(o.context,M,l,o.stencilModeForClipping(H),d,Et.disabled,O,ue,n.id,te.layoutVertexBuffer,D,G,n.paint,o.transform.zoom,ae)}}function La(o,t,n,s,l,d,m){const g=o.context,y=g.gl,x="fill-extrusion-pattern",S=n.paint.get(x),T=S.constantOr(1),M=n.getCrossfadeParameters(),F=n.paint.get("fill-extrusion-opacity"),O=S.constantOr(null);for(const D of s){const G=t.getTile(D),Y=G.getBucket(n);if(!Y)continue;const H=o.style.map.terrain&&o.style.map.terrain.getTerrainData(D),V=Y.programConfigurations.get(n.id),te=o.useProgram(T?"fillExtrusionPattern":"fillExtrusion",V);T&&(o.context.activeTexture.set(y.TEXTURE0),G.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),V.updatePaintBuffers(M)),Rs(V,x,O,G,n);const ae=o.translatePosMatrix(D.posMatrix,G,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),se=n.paint.get("fill-extrusion-vertical-gradient"),ue=T?Kl(ae,o,se,F,D,M,G):ys(ae,o,se,F);te.draw(g,g.gl.TRIANGLES,l,d,m,Et.backCCW,ue,H,n.id,Y.layoutVertexBuffer,Y.indexBuffer,Y.segments,n.paint,o.transform.zoom,V,o.style.map.terrain&&Y.centroidVertexBuffer)}}function il(o,t,n,s,l,d,m){const g=o.context,y=g.gl,x=n.fbo;if(!x)return;const S=o.useProgram("hillshade"),T=o.style.map.terrain&&o.style.map.terrain.getTerrainData(t);g.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,x.colorAttachment.get()),S.draw(g,y.TRIANGLES,l,d,m,Et.disabled,((M,F,O,D)=>{const G=O.paint.get("hillshade-shadow-color"),Y=O.paint.get("hillshade-highlight-color"),H=O.paint.get("hillshade-accent-color");let V=O.paint.get("hillshade-illumination-direction")*(Math.PI/180);O.paint.get("hillshade-illumination-anchor")==="viewport"&&(V-=M.transform.angle);const te=!M.options.moving;return{u_matrix:D?D.posMatrix:M.transform.calculatePosMatrix(F.tileID.toUnwrapped(),te),u_image:0,u_latrange:ba(0,F.tileID),u_light:[O.paint.get("hillshade-exaggeration"),V],u_shadow:G,u_highlight:Y,u_accent:H}})(o,n,s,T?t:null),T,s.id,o.rasterBoundsBuffer,o.quadTriangleIndexBuffer,o.rasterBoundsSegments)}function rl(o,t,n,s,l,d){const m=o.context,g=m.gl,y=t.dem;if(y&&y.data){const x=y.dim,S=y.stride,T=y.getPixels();if(m.activeTexture.set(g.TEXTURE1),m.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||o.getTileTexture(S),t.demTexture){const F=t.demTexture;F.update(T,{premultiply:!1}),F.bind(g.NEAREST,g.CLAMP_TO_EDGE)}else t.demTexture=new Mt(m,T,g.RGBA,{premultiply:!1}),t.demTexture.bind(g.NEAREST,g.CLAMP_TO_EDGE);m.activeTexture.set(g.TEXTURE0);let M=t.fbo;if(!M){const F=new Mt(m,{width:x,height:x,data:null},g.RGBA);F.bind(g.LINEAR,g.CLAMP_TO_EDGE),M=t.fbo=m.createFramebuffer(x,x,!0),M.colorAttachment.set(F.texture)}m.bindFramebuffer.set(M.framebuffer),m.viewport.set([0,0,x,x]),o.useProgram("hillshadePrepare").draw(m,g.TRIANGLES,s,l,d,Et.disabled,((F,O)=>{const D=O.stride,G=h.create();return h.ortho(G,0,h.EXTENT,-h.EXTENT,0,0,1),h.translate(G,G,[0,-h.EXTENT,0]),{u_matrix:G,u_image:1,u_dimension:[D,D],u_zoom:F.overscaledZ,u_unpack:O.getUnpackVector()}})(t.tileID,y),null,n.id,o.rasterBoundsBuffer,o.quadTriangleIndexBuffer,o.rasterBoundsSegments),t.needsHillshadePrepare=!1}}function Yn(o,t,n,s,l,d){const m=s.paint.get("raster-fade-duration");if(!d&&m>0){const g=h.exported.now(),y=(g-o.timeAdded)/m,x=t?(g-t.timeAdded)/m:-1,S=n.getSource(),T=l.coveringZoomLevel({tileSize:S.tileSize,roundZoom:S.roundZoom}),M=!t||Math.abs(t.tileID.overscaledZ-T)>Math.abs(o.tileID.overscaledZ-T),F=M&&o.refreshedUponExpiration?1:h.clamp(M?y:1-x,0,1);return o.refreshedUponExpiration&&y>=1&&(o.refreshedUponExpiration=!1),t?{opacity:1,mix:1-F}:{opacity:F,mix:0}}return{opacity:1,mix:0}}const nl=new h.Color(1,0,0,1),or=new h.Color(0,1,0,1),xr=new h.Color(0,0,1,1),al=new h.Color(1,0,1,1),vr=new h.Color(0,1,1,1);function Mn(o,t,n,s){Da(o,0,t+n/2,o.transform.width,n,s)}function sl(o,t,n,s){Da(o,t-n/2,0,n,o.transform.height,s)}function Da(o,t,n,s,l,d){const m=o.context,g=m.gl;g.enable(g.SCISSOR_TEST),g.scissor(t*o.pixelRatio,n*o.pixelRatio,s*o.pixelRatio,l*o.pixelRatio),m.clear({color:d}),g.disable(g.SCISSOR_TEST)}function oc(o,t,n){const s=o.context,l=s.gl,d=n.posMatrix,m=o.useProgram("debug"),g=at.disabled,y=Lt.disabled,x=o.colorModeForRenderPass(),S="$debug",T=o.style.map.terrain&&o.style.map.terrain.getTerrainData(n);s.activeTexture.set(l.TEXTURE0),o.emptyTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE);const M=t.getTileByID(n.key).latestRawTileData,F=Math.floor((M&&M.byteLength||0)/1024),O=t.getTile(n).tileSize,D=512/Math.min(O,512)*(n.overscaledZ/o.transform.zoom)*.5;let G=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(G+=` => ${n.overscaledZ}`),function(Y,H){Y.initDebugOverlayCanvas();const V=Y.debugOverlayCanvas,te=Y.context.gl,ae=Y.debugOverlayCanvas.getContext("2d");ae.clearRect(0,0,V.width,V.height),ae.shadowColor="white",ae.shadowBlur=2,ae.lineWidth=1.5,ae.strokeStyle="white",ae.textBaseline="top",ae.font="bold 36px Open Sans, sans-serif",ae.fillText(H,5,5),ae.strokeText(H,5,5),Y.debugOverlayTexture.update(V),Y.debugOverlayTexture.bind(te.LINEAR,te.CLAMP_TO_EDGE)}(o,`${G} ${F}kB`),m.draw(s,l.TRIANGLES,g,y,Ot.alphaBlended,Et.disabled,Wn(d,h.Color.transparent,D),null,S,o.debugBuffer,o.quadTriangleIndexBuffer,o.debugSegments),m.draw(s,l.LINE_STRIP,g,y,x,Et.disabled,Wn(d,h.Color.red),T,S,o.debugBuffer,o.tileBorderIndexBuffer,o.debugSegments)}function Fs(o,t,n){const s=o.context,l=s.gl,d=o.colorModeForRenderPass(),m=new at(l.LEQUAL,at.ReadWrite,o.depthRangeFor3D),g=o.useProgram("terrain"),y=t.getTerrainMesh();s.bindFramebuffer.set(null),s.viewport.set([0,0,o.width,o.height]);for(const x of n){const S=o.renderToTexture.getTexture(x),T=t.getTerrainData(x.tileID);s.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,S.texture);const M={u_matrix:o.transform.calculatePosMatrix(x.tileID.toUnwrapped()),u_texture:0,u_ele_delta:t.getMeshFrameDelta(o.transform.zoom)};g.draw(s,l.TRIANGLES,m,Lt.disabled,d,Et.backCCW,M,T,"terrain",y.vertexBuffer,y.indexBuffer,y.segments)}}const Pn={symbol:function(o,t,n,s,l){if(o.renderPass!=="translucent")return;const d=Lt.disabled,m=o.colorModeForRenderPass();n.layout.get("text-variable-anchor")&&function(g,y,x,S,T,M,F){const O=y.transform,D=T==="map",G=M==="map";for(const Y of g){const H=S.getTile(Y),V=H.getBucket(x);if(!V||!V.text||!V.text.segments.get().length)continue;const te=h.evaluateSizeForZoom(V.textSizeData,O.zoom),ae=ce(H,1,y.transform.zoom),se=Yt(Y.posMatrix,G,D,y.transform,ae),ue=x.layout.get("icon-text-fit")!=="none"&&V.hasIconData();if(te){const me=Math.pow(2,O.zoom-H.tileID.overscaledZ);el(V,D,G,F,O,se,Y.posMatrix,me,te,ue,y.style.map.terrain?(xe,_e)=>y.style.map.terrain.getElevation(Y,xe,_e):null)}}}(s,o,n,t,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),l),n.paint.get("icon-opacity").constantOr(1)!==0&&kr(o,t,n,s,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright"),d,m),n.paint.get("text-opacity").constantOr(1)!==0&&kr(o,t,n,s,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright"),d,m),t.map.showCollisionBoxes&&(Ls(o,t,n,s,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),!0),Ls(o,t,n,s,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),!1))},circle:function(o,t,n,s){if(o.renderPass!=="translucent")return;const l=n.paint.get("circle-opacity"),d=n.paint.get("circle-stroke-width"),m=n.paint.get("circle-stroke-opacity"),g=!n.layout.get("circle-sort-key").isConstant();if(l.constantOr(1)===0&&(d.constantOr(1)===0||m.constantOr(1)===0))return;const y=o.context,x=y.gl,S=o.depthModeForSublayer(0,at.ReadOnly),T=Lt.disabled,M=o.colorModeForRenderPass(),F=[];for(let O=0;O<s.length;O++){const D=s[O],G=t.getTile(D),Y=G.getBucket(n);if(!Y)continue;const H=Y.programConfigurations.get(n.id),V=o.useProgram("circle",H),te=Y.layoutVertexBuffer,ae=Y.indexBuffer,se=o.style.map.terrain&&o.style.map.terrain.getTerrainData(D),ue={programConfiguration:H,program:V,layoutVertexBuffer:te,indexBuffer:ae,uniformValues:xs(o,D,G,n),terrainData:se};if(g){const me=Y.segments.get();for(const xe of me)F.push({segments:new h.SegmentVector([xe]),sortKey:xe.sortKey,state:ue})}else F.push({segments:Y.segments,sortKey:0,state:ue})}g&&F.sort((O,D)=>O.sortKey-D.sortKey);for(const O of F){const{programConfiguration:D,program:G,layoutVertexBuffer:Y,indexBuffer:H,uniformValues:V,terrainData:te}=O.state;G.draw(y,x.TRIANGLES,S,T,M,Et.disabled,V,te,n.id,Y,H,O.segments,n.paint,o.transform.zoom,D)}},heatmap:function(o,t,n,s){if(n.paint.get("heatmap-opacity")!==0)if(o.renderPass==="offscreen"){const l=o.context,d=l.gl,m=Lt.disabled,g=new Ot([d.ONE,d.ONE],h.Color.transparent,[!0,!0,!0,!0]);(function(y,x,S){const T=y.gl;y.activeTexture.set(T.TEXTURE1),y.viewport.set([0,0,x.width/4,x.height/4]);let M=S.heatmapFbo;if(M)T.bindTexture(T.TEXTURE_2D,M.colorAttachment.get()),y.bindFramebuffer.set(M.framebuffer);else{const F=T.createTexture();T.bindTexture(T.TEXTURE_2D,F),T.texParameteri(T.TEXTURE_2D,T.TEXTURE_WRAP_S,T.CLAMP_TO_EDGE),T.texParameteri(T.TEXTURE_2D,T.TEXTURE_WRAP_T,T.CLAMP_TO_EDGE),T.texParameteri(T.TEXTURE_2D,T.TEXTURE_MIN_FILTER,T.LINEAR),T.texParameteri(T.TEXTURE_2D,T.TEXTURE_MAG_FILTER,T.LINEAR),M=S.heatmapFbo=y.createFramebuffer(x.width/4,x.height/4,!1),function(O,D,G,Y){const H=O.gl;H.texImage2D(H.TEXTURE_2D,0,H.RGBA,D.width/4,D.height/4,0,H.RGBA,O.extRenderToTextureHalfFloat?O.extTextureHalfFloat.HALF_FLOAT_OES:H.UNSIGNED_BYTE,null),Y.colorAttachment.set(G)}(y,x,F,M)}})(l,o,n),l.clear({color:h.Color.transparent});for(let y=0;y<s.length;y++){const x=s[y];if(t.hasRenderableParent(x))continue;const S=t.getTile(x),T=S.getBucket(n);if(!T)continue;const M=T.programConfigurations.get(n.id),F=o.useProgram("heatmap",M),{zoom:O}=o.transform;F.draw(l,d.TRIANGLES,at.disabled,m,g,Et.disabled,vs(x.posMatrix,S,O,n.paint.get("heatmap-intensity")),null,n.id,T.layoutVertexBuffer,T.indexBuffer,T.segments,n.paint,o.transform.zoom,M)}l.viewport.set([0,0,o.width,o.height])}else o.renderPass==="translucent"&&(o.context.setColorMode(o.colorModeForRenderPass()),function(l,d){const m=l.context,g=m.gl,y=d.heatmapFbo;if(!y)return;m.activeTexture.set(g.TEXTURE0),g.bindTexture(g.TEXTURE_2D,y.colorAttachment.get()),m.activeTexture.set(g.TEXTURE1);let x=d.colorRampTexture;x||(x=d.colorRampTexture=new Mt(m,d.colorRamp,g.RGBA)),x.bind(g.LINEAR,g.CLAMP_TO_EDGE),l.useProgram("heatmapTexture").draw(m,g.TRIANGLES,at.disabled,Lt.disabled,l.colorModeForRenderPass(),Et.disabled,((S,T,M,F)=>{const O=h.create();h.ortho(O,0,S.width,S.height,0,0,1);const D=S.context.gl;return{u_matrix:O,u_world:[D.drawingBufferWidth,D.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:T.paint.get("heatmap-opacity")}})(l,d),null,d.id,l.viewportBuffer,l.quadTriangleIndexBuffer,l.viewportSegments,d.paint,l.transform.zoom)}(o,n))},line:function(o,t,n,s){if(o.renderPass!=="translucent")return;const l=n.paint.get("line-opacity"),d=n.paint.get("line-width");if(l.constantOr(1)===0||d.constantOr(1)===0)return;const m=o.depthModeForSublayer(0,at.ReadOnly),g=o.colorModeForRenderPass(),y=n.paint.get("line-dasharray"),x=n.paint.get("line-pattern"),S=x.constantOr(1),T=n.paint.get("line-gradient"),M=n.getCrossfadeParameters(),F=S?"linePattern":y?"lineSDF":T?"lineGradient":"line",O=o.context,D=O.gl;let G=!0;for(const Y of s){const H=t.getTile(Y);if(S&&!H.patternsLoaded())continue;const V=H.getBucket(n);if(!V)continue;const te=V.programConfigurations.get(n.id),ae=o.context.program.get(),se=o.useProgram(F,te),ue=G||se.program!==ae,me=o.style.map.terrain&&o.style.map.terrain.getTerrainData(Y),xe=x.constantOr(null);if(xe&&H.imageAtlas){const ze=H.imageAtlas,We=ze.patternPositions[xe.to.toString()],Ke=ze.patternPositions[xe.from.toString()];We&&Ke&&te.setConstantPatternPositions(We,Ke)}const _e=me?Y:null,we=S?wa(o,H,n,M,_e):y?No(o,H,n,y,M,_e):T?bs(o,H,n,V.lineClipsArray.length,_e):Hn(o,H,n,_e);if(S)O.activeTexture.set(D.TEXTURE0),H.imageAtlasTexture.bind(D.LINEAR,D.CLAMP_TO_EDGE),te.updatePaintBuffers(M);else if(y&&(ue||o.lineAtlas.dirty))O.activeTexture.set(D.TEXTURE0),o.lineAtlas.bind(O);else if(T){const ze=V.gradients[n.id];let We=ze.texture;if(n.gradientVersion!==ze.version){let Ke=256;if(n.stepInterpolant){const Le=t.getSource().maxzoom,mt=Y.canonical.z===Le?Math.ceil(1<<o.transform.maxZoom-Y.canonical.z):1;Ke=h.clamp(h.nextPowerOfTwo(V.maxLineLength/h.EXTENT*1024*mt),256,O.maxTextureSize)}ze.gradient=h.renderColorRamp({expression:n.gradientExpression(),evaluationKey:"lineProgress",resolution:Ke,image:ze.gradient||void 0,clips:V.lineClipsArray}),ze.texture?ze.texture.update(ze.gradient):ze.texture=new Mt(O,ze.gradient,D.RGBA),ze.version=n.gradientVersion,We=ze.texture}O.activeTexture.set(D.TEXTURE0),We.bind(n.stepInterpolant?D.NEAREST:D.LINEAR,D.CLAMP_TO_EDGE)}se.draw(O,D.TRIANGLES,m,o.stencilModeForClipping(Y),g,Et.disabled,we,me,n.id,V.layoutVertexBuffer,V.indexBuffer,V.segments,n.paint,o.transform.zoom,te,V.layoutVertexBuffer2),G=!1}},fill:function(o,t,n,s){const l=n.paint.get("fill-color"),d=n.paint.get("fill-opacity");if(d.constantOr(1)===0)return;const m=o.colorModeForRenderPass(),g=n.paint.get("fill-pattern"),y=o.opaquePassEnabledForLayer()&&!g.constantOr(1)&&l.constantOr(h.Color.transparent).a===1&&d.constantOr(0)===1?"opaque":"translucent";if(o.renderPass===y){const x=o.depthModeForSublayer(1,o.renderPass==="opaque"?at.ReadWrite:at.ReadOnly);Bs(o,t,n,s,x,m,!1)}if(o.renderPass==="translucent"&&n.paint.get("fill-antialias")){const x=o.depthModeForSublayer(n.getPaintProperty("fill-outline-color")?2:0,at.ReadOnly);Bs(o,t,n,s,x,m,!0)}},"fill-extrusion":function(o,t,n,s){const l=n.paint.get("fill-extrusion-opacity");if(l!==0&&o.renderPass==="translucent"){const d=new at(o.context.gl.LEQUAL,at.ReadWrite,o.depthRangeFor3D);if(l!==1||n.paint.get("fill-extrusion-pattern").constantOr(1))La(o,t,n,s,d,Lt.disabled,Ot.disabled),La(o,t,n,s,d,o.stencilModeFor3D(),o.colorModeForRenderPass());else{const m=o.colorModeForRenderPass();La(o,t,n,s,d,Lt.disabled,m)}}},hillshade:function(o,t,n,s){if(o.renderPass!=="offscreen"&&o.renderPass!=="translucent")return;const l=o.context,d=o.depthModeForSublayer(0,at.ReadOnly),m=o.colorModeForRenderPass(),[g,y]=o.renderPass==="translucent"?o.stencilConfigForOverlap(s):[{},s];for(const x of y){const S=t.getTile(x);S.needsHillshadePrepare!==void 0&&S.needsHillshadePrepare&&o.renderPass==="offscreen"?rl(o,S,n,d,Lt.disabled,m):o.renderPass==="translucent"&&il(o,x,S,n,d,g[x.overscaledZ],m)}l.viewport.set([0,0,o.width,o.height])},raster:function(o,t,n,s){if(o.renderPass!=="translucent"||n.paint.get("raster-opacity")===0||!s.length)return;const l=o.context,d=l.gl,m=t.getSource(),g=o.useProgram("raster"),y=o.colorModeForRenderPass(),[x,S]=m instanceof bt?[{},s]:o.stencilConfigForOverlap(s),T=S[S.length-1].overscaledZ,M=!o.options.moving;for(const F of S){const O=o.depthModeForSublayer(F.overscaledZ-T,n.paint.get("raster-opacity")===1?at.ReadWrite:at.ReadOnly,d.LESS),D=t.getTile(F);D.registerFadeDuration(n.paint.get("raster-fade-duration"));const G=t.findLoadedParent(F,0),Y=Yn(D,G,t,n,o.transform,o.style.map.terrain);let H,V;const te=n.paint.get("raster-resampling")==="nearest"?d.NEAREST:d.LINEAR;l.activeTexture.set(d.TEXTURE0),D.texture.bind(te,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),l.activeTexture.set(d.TEXTURE1),G?(G.texture.bind(te,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),H=Math.pow(2,G.tileID.overscaledZ-D.tileID.overscaledZ),V=[D.tileID.canonical.x*H%1,D.tileID.canonical.y*H%1]):D.texture.bind(te,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST);const ae=o.style.map.terrain&&o.style.map.terrain.getTerrainData(F),se=ae?F:null,ue=se?se.posMatrix:o.transform.calculatePosMatrix(F.toUnwrapped(),M),me=Yl(ue,V||[0,0],H||1,Y,n);m instanceof bt?g.draw(l,d.TRIANGLES,O,Lt.disabled,y,Et.disabled,me,ae,n.id,m.boundsBuffer,o.quadTriangleIndexBuffer,m.boundsSegments):g.draw(l,d.TRIANGLES,O,x[F.overscaledZ],y,Et.disabled,me,ae,n.id,o.rasterBoundsBuffer,o.quadTriangleIndexBuffer,o.rasterBoundsSegments)}},background:function(o,t,n,s){const l=n.paint.get("background-color"),d=n.paint.get("background-opacity");if(d===0)return;const m=o.context,g=m.gl,y=o.transform,x=y.tileSize,S=n.paint.get("background-pattern");if(o.isPatternMissing(S))return;const T=!S&&l.a===1&&d===1&&o.opaquePassEnabledForLayer()?"opaque":"translucent";if(o.renderPass!==T)return;const M=Lt.disabled,F=o.depthModeForSublayer(0,T==="opaque"?at.ReadWrite:at.ReadOnly),O=o.colorModeForRenderPass(),D=o.useProgram(S?"backgroundPattern":"background"),G=s||y.coveringTiles({tileSize:x,terrain:o.style.map.terrain});S&&(m.activeTexture.set(g.TEXTURE0),o.imageManager.bind(o.context));const Y=n.getCrossfadeParameters();for(const H of G){const V=s?H.posMatrix:o.transform.calculatePosMatrix(H.toUnwrapped()),te=S?Ts(V,d,o,S,{tileID:H,tileSize:x},Y):ec(V,d,l),ae=o.style.map.terrain&&o.style.map.terrain.getTerrainData(H);D.draw(m,g.TRIANGLES,F,M,O,Et.disabled,te,ae,n.id,o.tileExtentBuffer,o.quadTriangleIndexBuffer,o.tileExtentSegments)}},debug:function(o,t,n){for(let s=0;s<n.length;s++)oc(o,t,n[s])},custom:function(o,t,n){const s=o.context,l=n.implementation;if(o.renderPass==="offscreen"){const d=l.prerender;d&&(o.setCustomLayerDefaults(),s.setColorMode(o.colorModeForRenderPass()),d.call(l,s.gl,o.transform.customLayerMatrix()),s.setDirty(),o.setBaseState())}else if(o.renderPass==="translucent"){o.setCustomLayerDefaults(),s.setColorMode(o.colorModeForRenderPass()),s.setStencilMode(Lt.disabled);const d=l.renderingMode==="3d"?new at(o.context.gl.LEQUAL,at.ReadWrite,o.depthRangeFor3D):o.depthModeForSublayer(0,at.ReadOnly);s.setDepthMode(d),l.render(s.gl,o.transform.customLayerMatrix()),s.setDirty(),o.setBaseState(),s.bindFramebuffer.set(null)}}};class zr{constructor(t,n){this.context=new ka(t),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:h.create(),renderTime:0},this.setup(),this.numSublayers=Xe.maxUnderzooming+Xe.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new zt,this.gpuTimers={}}resize(t,n,s){if(this.width=t*s,this.height=n*s,this.pixelRatio=s,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const l of this.style._order)this.style._layers[l].resize()}setup(){const t=this.context,n=new h.PosArray;n.emplaceBack(0,0),n.emplaceBack(h.EXTENT,0),n.emplaceBack(0,h.EXTENT),n.emplaceBack(h.EXTENT,h.EXTENT),this.tileExtentBuffer=t.createVertexBuffer(n,ya.members),this.tileExtentSegments=h.SegmentVector.simpleSegment(0,0,4,2);const s=new h.PosArray;s.emplaceBack(0,0),s.emplaceBack(h.EXTENT,0),s.emplaceBack(0,h.EXTENT),s.emplaceBack(h.EXTENT,h.EXTENT),this.debugBuffer=t.createVertexBuffer(s,ya.members),this.debugSegments=h.SegmentVector.simpleSegment(0,0,4,5);const l=new h.RasterBoundsArray;l.emplaceBack(0,0,0,0),l.emplaceBack(h.EXTENT,0,h.EXTENT,0),l.emplaceBack(0,h.EXTENT,0,h.EXTENT),l.emplaceBack(h.EXTENT,h.EXTENT,h.EXTENT,h.EXTENT),this.rasterBoundsBuffer=t.createVertexBuffer(l,di.members),this.rasterBoundsSegments=h.SegmentVector.simpleSegment(0,0,4,2);const d=new h.PosArray;d.emplaceBack(0,0),d.emplaceBack(1,0),d.emplaceBack(0,1),d.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(d,ya.members),this.viewportSegments=h.SegmentVector.simpleSegment(0,0,4,2);const m=new h.LineStripIndexArray;m.emplaceBack(0),m.emplaceBack(1),m.emplaceBack(3),m.emplaceBack(2),m.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(m);const g=new h.TriangleIndexArray;g.emplaceBack(0,1,2),g.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(g),this.emptyTexture=new Mt(t,{width:1,height:1,data:new Uint8Array([0,0,0,0])},t.gl.RGBA);const y=this.context.gl;this.stencilClearMode=new Lt({func:y.ALWAYS,mask:0},0,255,y.ZERO,y.ZERO,y.ZERO)}clearStencil(){const t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const s=h.create();h.ortho(s,0,this.width,this.height,0,0,1),h.scale(s,s,[n.drawingBufferWidth,n.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,n.TRIANGLES,at.disabled,this.stencilClearMode,Ot.disabled,Et.disabled,va(s),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,n){if(this.currentStencilSource===t.source||!t.isTileClipped()||!n||!n.length)return;this.currentStencilSource=t.source;const s=this.context,l=s.gl;this.nextStencilID+n.length>256&&this.clearStencil(),s.setColorMode(Ot.disabled),s.setDepthMode(at.disabled);const d=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const m of n){const g=this._tileClippingMaskIDs[m.key]=this.nextStencilID++,y=this.style.map.terrain&&this.style.map.terrain.getTerrainData(m);d.draw(s,l.TRIANGLES,at.disabled,new Lt({func:l.ALWAYS,mask:0},g,255,l.KEEP,l.KEEP,l.REPLACE),Ot.disabled,Et.disabled,va(m.posMatrix),y,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,n=this.context.gl;return new Lt({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){const n=this.context.gl;return new Lt({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(t){const n=this.context.gl,s=t.sort((m,g)=>g.overscaledZ-m.overscaledZ),l=s[s.length-1].overscaledZ,d=s[0].overscaledZ-l+1;if(d>1){this.currentStencilSource=void 0,this.nextStencilID+d>256&&this.clearStencil();const m={};for(let g=0;g<d;g++)m[g+l]=new Lt({func:n.GEQUAL,mask:255},g+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=d,[m,s]}return[{[l]:Lt.disabled},s]}colorModeForRenderPass(){const t=this.context.gl;return this._showOverdrawInspector?new Ot([t.CONSTANT_COLOR,t.ONE],new h.Color(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?Ot.unblended:Ot.alphaBlended}depthModeForSublayer(t,n,s){if(!this.opaquePassEnabledForLayer())return at.disabled;const l=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new at(s||this.context.gl.LEQUAL,n,[l,l])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,n){this.style=t,this.options=n,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(h.exported.now()),this.imageManager.beginFrame();const s=this.style._order,l=this.style.sourceCaches,d={},m={},g={};for(const y in l){const x=l[y];x.used&&x.prepare(this.context),d[y]=x.getVisibleCoordinates(),m[y]=d[y].slice().reverse(),g[y]=x.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let y=0;y<s.length;y++)if(this.style._layers[s[y]].is3D()){this.opaquePassCutoff=y;break}if(this.renderToTexture){this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0;const y=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime);(this.terrainFacilitator.dirty||!h.equals(this.terrainFacilitator.matrix,this.transform.projMatrix)||y.length)&&(h.copy(this.terrainFacilitator.matrix,this.transform.projMatrix),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(x,S){const T=x.context,M=T.gl,F=Ot.unblended,O=new at(M.LEQUAL,at.ReadWrite,[0,1]),D=S.getTerrainMesh(),G=S.sourceCache.getRenderableTiles(),Y=x.useProgram("terrainDepth");T.bindFramebuffer.set(S.getFramebuffer("depth").framebuffer),T.viewport.set([0,0,x.width/devicePixelRatio,x.height/devicePixelRatio]),T.clear({color:h.Color.transparent,depth:1});for(const H of G){const V=S.getTerrainData(H.tileID),te={u_matrix:x.transform.calculatePosMatrix(H.tileID.toUnwrapped()),u_ele_delta:S.getMeshFrameDelta(x.transform.zoom)};Y.draw(T,M.TRIANGLES,O,Lt.disabled,F,Et.backCCW,te,V,"terrain",D.vertexBuffer,D.indexBuffer,D.segments)}T.bindFramebuffer.set(null),T.viewport.set([0,0,x.width,x.height])}(this,this.style.map.terrain),function(x,S){const T=x.context,M=T.gl,F=Ot.unblended,O=new at(M.LEQUAL,at.ReadWrite,[0,1]),D=S.getTerrainMesh(),G=S.getCoordsTexture(),Y=S.sourceCache.getRenderableTiles(),H=x.useProgram("terrainCoords");T.bindFramebuffer.set(S.getFramebuffer("coords").framebuffer),T.viewport.set([0,0,x.width/devicePixelRatio,x.height/devicePixelRatio]),T.clear({color:h.Color.transparent,depth:1}),S.coordsIndex=[];for(const V of Y){const te=S.getTerrainData(V.tileID);T.activeTexture.set(M.TEXTURE0),M.bindTexture(M.TEXTURE_2D,G.texture);const ae={u_matrix:x.transform.calculatePosMatrix(V.tileID.toUnwrapped()),u_terrain_coords_id:(255-S.coordsIndex.length)/255,u_texture:0,u_ele_delta:S.getMeshFrameDelta(x.transform.zoom)};H.draw(T,M.TRIANGLES,O,Lt.disabled,F,Et.backCCW,ae,te,"terrain",D.vertexBuffer,D.indexBuffer,D.segments),S.coordsIndex.push(V.tileID.key)}T.bindFramebuffer.set(null),T.viewport.set([0,0,x.width,x.height])}(this,this.style.map.terrain))}this.renderPass="offscreen";for(const y of s){const x=this.style._layers[y];if(!x.hasOffscreenPass()||x.isHidden(this.transform.zoom))continue;const S=m[x.source];(x.type==="custom"||S.length)&&this.renderLayer(this,l[x.source],x,S)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?h.Color.black:h.Color.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=s.length-1;this.currentLayer>=0;this.currentLayer--){const y=this.style._layers[s[this.currentLayer]],x=l[y.source],S=d[y.source];this._renderTileClippingMasks(y,S),this.renderLayer(this,x,y,S)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<s.length;this.currentLayer++){const y=this.style._layers[s[this.currentLayer]],x=l[y.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(y))continue;const S=(y.type==="symbol"?g:m)[y.source];this._renderTileClippingMasks(y,d[y.source]),this.renderLayer(this,x,y,S)}if(this.options.showTileBoundaries){const y=function(x,S){let T=null;const M=Object.values(x._layers).flatMap(G=>G.source&&!G.isHidden(S)?[x.sourceCaches[G.source]]:[]),F=M.filter(G=>G.getSource().type==="vector"),O=M.filter(G=>G.getSource().type!=="vector"),D=G=>{(!T||T.getSource().maxzoom<G.getSource().maxzoom)&&(T=G)};return F.forEach(G=>D(G)),T||O.forEach(G=>D(G)),T}(this.style,this.transform.zoom);y&&Pn.debug(this,y,y.getVisibleCoordinates())}this.options.showPadding&&function(y){const x=y.transform.padding;Mn(y,y.transform.height-(x.top||0),3,nl),Mn(y,x.bottom||0,3,or),sl(y,x.left||0,3,xr),sl(y,y.transform.width-(x.right||0),3,al);const S=y.transform.centerPoint;(function(T,M,F,O){Da(T,M-1,F-10,2,20,O),Da(T,M-10,F-1,20,2,O)})(y,S.x,y.transform.height-S.y,vr)}(this),this.context.setDefault()}renderLayer(t,n,s,l){s.isHidden(this.transform.zoom)||(s.type==="background"||s.type==="custom"||(l||[]).length)&&(this.id=s.id,this.gpuTimingStart(s),Pn[s.type](t,n,s,l,this.style.placement.variableOffsets),this.gpuTimingEnd())}gpuTimingStart(t){if(!this.options.gpuTiming)return;const n=this.context.extTimerQuery;let s=this.gpuTimers[t.id];s||(s=this.gpuTimers[t.id]={calls:0,cpuTime:0,query:n.createQueryEXT()}),s.calls++,n.beginQueryEXT(n.TIME_ELAPSED_EXT,s.query)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery;t.endQueryEXT(t.TIME_ELAPSED_EXT)}collectGpuTimers(){const t=this.gpuTimers;return this.gpuTimers={},t}queryGpuTimers(t){const n={};for(const s in t){const l=t[s],d=this.context.extTimerQuery,m=d.getQueryObjectEXT(l.query,d.QUERY_RESULT_EXT)/1e6;d.deleteQueryEXT(l.query),n[s]=m}return n}translatePosMatrix(t,n,s,l,d){if(!s[0]&&!s[1])return t;const m=d?l==="map"?this.transform.angle:0:l==="viewport"?-this.transform.angle:0;if(m){const x=Math.sin(m),S=Math.cos(m);s=[s[0]*S-s[1]*x,s[0]*x+s[1]*S]}const g=[d?s[0]:ce(n,s[0],this.transform.zoom),d?s[1]:ce(n,s[1],this.transform.zoom),0],y=new Float32Array(16);return h.translate(y,t,g),y}saveTileTexture(t){const n=this._tileTextures[t.size[0]];n?n.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const n=this._tileTextures[t];return n&&n.length>0?n.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const n=this.imageManager.getPattern(t.from.toString()),s=this.imageManager.getPattern(t.to.toString());return!n||!s}useProgram(t,n){this.cache=this.cache||{};const s=t+(n?n.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[s]||(this.cache[s]=new gs(this.context,t,Zn[t],n,Ta[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[s]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new Mt(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}}class ke{constructor(t,n){this.points=t,this.planes=n}static fromInvProjectionMatrix(t,n,s){const l=Math.pow(2,s),d=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(g=>{const y=1/(g=h.transformMat4([],g,t))[3]/n*l;return h.mul$1(g,g,[y,y,1/g[3],y])}),m=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(g=>{const y=function(M,F){var O=F[0],D=F[1],G=F[2],Y=O*O+D*D+G*G;return Y>0&&(Y=1/Math.sqrt(Y)),M[0]=F[0]*Y,M[1]=F[1]*Y,M[2]=F[2]*Y,M}([],function(M,F,O){var D=F[0],G=F[1],Y=F[2],H=O[0],V=O[1],te=O[2];return M[0]=G*te-Y*V,M[1]=Y*H-D*te,M[2]=D*V-G*H,M}([],gr([],d[g[0]],d[g[1]]),gr([],d[g[2]],d[g[1]]))),x=-((S=y)[0]*(T=d[g[1]])[0]+S[1]*T[1]+S[2]*T[2]);var S,T;return y.concat(x)});return new ke(d,m)}}class Jn{constructor(t,n){this.min=t,this.max=n,this.center=function(s,l,d){return s[0]=.5*l[0],s[1]=.5*l[1],s[2]=.5*l[2],s}([],function(s,l,d){return s[0]=l[0]+d[0],s[1]=l[1]+d[1],s[2]=l[2]+d[2],s}([],this.min,this.max))}quadrant(t){const n=[t%2==0,t<2],s=pn(this.min),l=pn(this.max);for(let d=0;d<n.length;d++)s[d]=n[d]?this.min[d]:this.center[d],l[d]=n[d]?this.center[d]:this.max[d];return l[2]=this.max[2],new Jn(s,l)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersects(t){const n=[[this.min[0],this.min[1],this.min[2],1],[this.max[0],this.min[1],this.min[2],1],[this.max[0],this.max[1],this.min[2],1],[this.min[0],this.max[1],this.min[2],1],[this.min[0],this.min[1],this.max[2],1],[this.max[0],this.min[1],this.max[2],1],[this.max[0],this.max[1],this.max[2],1],[this.min[0],this.max[1],this.max[2],1]];let s=!0;for(let l=0;l<t.planes.length;l++){const d=t.planes[l];let m=0;for(let g=0;g<n.length;g++)h.dot(d,n[g])>=0&&m++;if(m===0)return 0;m!==n.length&&(s=!1)}if(s)return 2;for(let l=0;l<3;l++){let d=Number.MAX_VALUE,m=-Number.MAX_VALUE;for(let g=0;g<t.points.length;g++){const y=t.points[g][l]-this.min[l];d=Math.min(d,y),m=Math.max(m,y)}if(m<0||d>this.max[l]-this.min[l])return 0}return 1}}class Qr{constructor(t=0,n=0,s=0,l=0){if(isNaN(t)||t<0||isNaN(n)||n<0||isNaN(s)||s<0||isNaN(l)||l<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=n,this.left=s,this.right=l}interpolate(t,n,s){return n.top!=null&&t.top!=null&&(this.top=h.number(t.top,n.top,s)),n.bottom!=null&&t.bottom!=null&&(this.bottom=h.number(t.bottom,n.bottom,s)),n.left!=null&&t.left!=null&&(this.left=h.number(t.left,n.left,s)),n.right!=null&&t.right!=null&&(this.right=h.number(t.right,n.right,s)),this}getCenter(t,n){const s=h.clamp((this.left+t-this.right)/2,0,t),l=h.clamp((this.top+n-this.bottom)/2,0,n);return new h.pointGeometry(s,l)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Qr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class en{constructor(t,n,s,l,d){this.tileSize=512,this.maxValidLatitude=85.051129,this.freezeElevation=!1,this._renderWorldCopies=d===void 0||!!d,this._minZoom=t||0,this._maxZoom=n||22,this._minPitch=s??0,this._maxPitch=l??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new h.LngLat(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Qr,this._posMatrixCache={},this._alignedPosMatrixCache={}}clone(){const t=new en(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.tileSize=this.tileSize,t.latRange=this.latRange,t.width=this.width,t.height=this.height,t._center=this._center,t._elevation=this._elevation,t.zoom=this.zoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._calcMatrices(),t}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(t){t===void 0?t=!0:t===null&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new h.pointGeometry(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){const n=-h.wrap(t,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=function(){var s=new h.ARRAY_TYPE(4);return h.ARRAY_TYPE!=Float32Array&&(s[1]=0,s[2]=0),s[0]=1,s[3]=1,s}(),function(s,l,d){var m=l[0],g=l[1],y=l[2],x=l[3],S=Math.sin(d),T=Math.cos(d);s[0]=m*T+y*S,s[1]=g*T+x*S,s[2]=m*-S+y*T,s[3]=g*-S+x*T}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const n=h.clamp(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(t){const n=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this.tileZoom=Math.max(0,Math.floor(n)),this.scale=this.zoomScale(n),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,n,s){this._unmodified=!1,this._edgeInsets.interpolate(t,n,s),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const n=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,n)}getVisibleUnwrappedCoordinates(t){const n=[new h.UnwrappedTileID(0,t)];if(this._renderWorldCopies){const s=this.pointCoordinate(new h.pointGeometry(0,0)),l=this.pointCoordinate(new h.pointGeometry(this.width,0)),d=this.pointCoordinate(new h.pointGeometry(this.width,this.height)),m=this.pointCoordinate(new h.pointGeometry(0,this.height)),g=Math.floor(Math.min(s.x,l.x,d.x,m.x)),y=Math.floor(Math.max(s.x,l.x,d.x,m.x)),x=1;for(let S=g-x;S<=y+x;S++)S!==0&&n.push(new h.UnwrappedTileID(S,t))}return n}coveringTiles(t){var n,s;let l=this.coveringZoomLevel(t);const d=l;if(t.minzoom!==void 0&&l<t.minzoom)return[];t.maxzoom!==void 0&&l>t.maxzoom&&(l=t.maxzoom);const m=this.pointCoordinate(this.getCameraPoint()),g=h.MercatorCoordinate.fromLngLat(this.center),y=Math.pow(2,l),x=[y*m.x,y*m.y,0],S=[y*g.x,y*g.y,0],T=ke.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,l);let M=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(M=l);const F=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,O=V=>({aabb:new Jn([V*y,0,0],[(V+1)*y,y,0]),zoom:0,x:0,y:0,wrap:V,fullyVisible:!1}),D=[],G=[],Y=l,H=t.reparseOverscaled?d:l;if(this._renderWorldCopies)for(let V=1;V<=3;V++)D.push(O(-V)),D.push(O(V));for(D.push(O(0));D.length>0;){const V=D.pop(),te=V.x,ae=V.y;let se=V.fullyVisible;if(!se){const we=V.aabb.intersects(T);if(we===0)continue;se=we===2}const ue=t.terrain?x:S,me=V.aabb.distanceX(ue),xe=V.aabb.distanceY(ue),_e=Math.max(Math.abs(me),Math.abs(xe));if(V.zoom===Y||_e>F+(1<<Y-V.zoom)-2&&V.zoom>=M){const we=Y-V.zoom,ze=x[0]-.5-(te<<we),We=x[1]-.5-(ae<<we);G.push({tileID:new h.OverscaledTileID(V.zoom===Y?H:V.zoom,V.wrap,V.zoom,te,ae),distanceSq:da([S[0]-.5-te,S[1]-.5-ae]),tileDistanceToCamera:Math.sqrt(ze*ze+We*We)})}else for(let we=0;we<4;we++){const ze=(te<<1)+we%2,We=(ae<<1)+(we>>1),Ke=V.zoom+1;let Le=V.aabb.quadrant(we);if(t.terrain){const mt=new h.OverscaledTileID(Ke,V.wrap,Ke,ze,We),ft=t.terrain.getMinMaxElevation(mt),tt=(n=ft.minElevation)!==null&&n!==void 0?n:this.elevation,ht=(s=ft.maxElevation)!==null&&s!==void 0?s:this.elevation;Le=new Jn([Le.min[0],Le.min[1],tt],[Le.max[0],Le.max[1],ht])}D.push({aabb:Le,zoom:Ke,x:ze,y:We,wrap:V.wrap,fullyVisible:se})}}return G.sort((V,te)=>V.distanceSq-te.distanceSq).map(V=>V.tileID)}resize(t,n){this.width=t,this.height=n,this.pixelsToGLUnits=[2/t,-2/n],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){const n=h.clamp(t.lat,-this.maxValidLatitude,this.maxValidLatitude);return new h.pointGeometry(h.mercatorXfromLng(t.lng)*this.worldSize,h.mercatorYfromLat(n)*this.worldSize)}unproject(t){return new h.MercatorCoordinate(t.x/this.worldSize,t.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}updateElevation(t){this.freezeElevation||(this.elevation=t?this.getElevation(this._center,t):0)}getElevation(t,n){const s=h.MercatorCoordinate.fromLngLat(t),l=(1<<this.tileZoom)*h.EXTENT,d=s.x*l,m=s.y*l,g=Math.floor(d/h.EXTENT),y=Math.floor(m/h.EXTENT),x=new h.OverscaledTileID(this.tileZoom,0,this.tileZoom,g,y);return n.getElevation(x,d%h.EXTENT,m%h.EXTENT,h.EXTENT)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(t){const n=this.pointLocation(this.centerPoint,t),s=this.getElevation(n,t);if(!(this.elevation-s))return;const l=this.getCameraPosition(),d=h.MercatorCoordinate.fromLngLat(l.lngLat,l.altitude),m=h.MercatorCoordinate.fromLngLat(n,s),g=d.x-m.x,y=d.y-m.y,x=d.z-m.z,S=Math.sqrt(g*g+y*y+x*x),T=this.scaleZoom(this.cameraToCenterDistance/S/this.tileSize);this._elevation=s,this._center=n,this.zoom=T}setLocationAtPoint(t,n){const s=this.pointCoordinate(n),l=this.pointCoordinate(this.centerPoint),d=this.locationCoordinate(t),m=new h.MercatorCoordinate(d.x-(s.x-l.x),d.y-(s.y-l.y));this.center=this.coordinateLocation(m),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,n){return n?this.coordinatePoint(this.locationCoordinate(t),this.getElevation(t,n),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,n){return this.coordinateLocation(this.pointCoordinate(t,n))}locationCoordinate(t){return h.MercatorCoordinate.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,n){if(n){const M=n.pointCoordinate(t);if(M!=null)return M}const s=[t.x,t.y,0,1],l=[t.x,t.y,1,1];h.transformMat4(s,s,this.pixelMatrixInverse),h.transformMat4(l,l,this.pixelMatrixInverse);const d=s[3],m=l[3],g=s[1]/d,y=l[1]/m,x=s[2]/d,S=l[2]/m,T=x===S?0:(0-x)/(S-x);return new h.MercatorCoordinate(h.number(s[0]/d,l[0]/m,T)/this.worldSize,h.number(g,y,T)/this.worldSize)}coordinatePoint(t,n=0,s=this.pixelMatrix){const l=[t.x*this.worldSize,t.y*this.worldSize,n,1];return h.transformMat4(l,l,s),new h.pointGeometry(l[0]/l[3],l[1]/l[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return new h.LngLatBounds().extend(this.pointLocation(new h.pointGeometry(0,t))).extend(this.pointLocation(new h.pointGeometry(this.width,t))).extend(this.pointLocation(new h.pointGeometry(this.width,this.height))).extend(this.pointLocation(new h.pointGeometry(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new h.LngLatBounds([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-this.maxValidLatitude,this.maxValidLatitude])}calculatePosMatrix(t,n=!1){const s=t.key,l=n?this._alignedPosMatrixCache:this._posMatrixCache;if(l[s])return l[s];const d=t.canonical,m=this.worldSize/this.zoomScale(d.z),g=d.x+Math.pow(2,d.z)*t.wrap,y=h.identity(new Float64Array(16));return h.translate(y,y,[g*m,d.y*m,0]),h.scale(y,y,[m/h.EXTENT,m/h.EXTENT,1]),h.multiply(y,n?this.alignedProjMatrix:this.projMatrix,y),l[s]=new Float32Array(y),l[s]}customLayerMatrix(){return this.mercatorMatrix.slice()}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let t,n,s,l,d=-90,m=90,g=-180,y=180;const x=this.size,S=this._unmodified;if(this.latRange){const F=this.latRange;d=h.mercatorYfromLat(F[1])*this.worldSize,m=h.mercatorYfromLat(F[0])*this.worldSize,t=m-d<x.y?x.y/(m-d):0}if(this.lngRange){const F=this.lngRange;g=h.wrap(h.mercatorXfromLng(F[0])*this.worldSize,0,this.worldSize),y=h.wrap(h.mercatorXfromLng(F[1])*this.worldSize,0,this.worldSize),y<g&&(y+=this.worldSize),n=y-g<x.x?x.x/(y-g):0}const T=this.point,M=Math.max(n||0,t||0);if(M)return this.center=this.unproject(new h.pointGeometry(n?(y+g)/2:T.x,t?(m+d)/2:T.y)),this.zoom+=this.scaleZoom(M),this._unmodified=S,void(this._constraining=!1);if(this.latRange){const F=T.y,O=x.y/2;F-O<d&&(l=d+O),F+O>m&&(l=m-O)}if(this.lngRange){const F=(g+y)/2,O=h.wrap(T.x,F-this.worldSize/2,F+this.worldSize/2),D=x.x/2;O-D<g&&(s=g+D),O+D>y&&(s=y-D)}s===void 0&&l===void 0||(this.center=this.unproject(new h.pointGeometry(s!==void 0?s:T.x,l!==void 0?l:T.y)).wrap()),this._unmodified=S,this._constraining=!1}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,n=this.point.x,s=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=h.mercatorZfromAltitude(1,this.center.lat)*this.worldSize;let l=h.identity(new Float64Array(16));h.scale(l,l,[this.width/2,-this.height/2,1]),h.translate(l,l,[1,-1,0]),this.labelPlaneMatrix=l,l=h.identity(new Float64Array(16)),h.scale(l,l,[1,-1,1]),h.translate(l,l,[-1,-1,0]),h.scale(l,l,[2/this.width,2/this.height,1]),this.glCoordMatrix=l,this.cameraToSeaLevelDistance=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch);const d=this._elevation<0?this.cameraToCenterDistance:this.cameraToSeaLevelDistance,m=Math.PI/2+this._pitch,g=this._fov*(.5+t.y/this.height),y=Math.sin(g)*d/Math.sin(h.clamp(Math.PI-m-g,.01,Math.PI-.01)),x=this.getHorizon(),S=2*Math.atan(x/this.cameraToCenterDistance)*(.5+t.y/(2*x)),T=Math.sin(S)*d/Math.sin(h.clamp(Math.PI-m-S,.01,Math.PI-.01)),M=Math.min(y,T),F=1.01*(Math.cos(Math.PI/2-this._pitch)*M+d),O=this.height/50;l=new Float64Array(16),h.perspective(l,this._fov,this.width/this.height,O,F),l[8]=2*-t.x/this.width,l[9]=2*t.y/this.height,h.scale(l,l,[1,-1,1]),h.translate(l,l,[0,0,-this.cameraToCenterDistance]),h.rotateX(l,l,this._pitch),h.rotateZ(l,l,this.angle),h.translate(l,l,[-n,-s,0]),this.mercatorMatrix=h.scale([],l,[this.worldSize,this.worldSize,this.worldSize]),h.scale(l,l,[1,1,this._pixelPerMeter]),this.pixelMatrix=h.multiply(new Float64Array(16),this.labelPlaneMatrix,l),h.translate(l,l,[0,0,-this.elevation]),this.projMatrix=l,this.invProjMatrix=h.invert([],l),this.pixelMatrix3D=h.multiply(new Float64Array(16),this.labelPlaneMatrix,l);const D=this.width%2/2,G=this.height%2/2,Y=Math.cos(this.angle),H=Math.sin(this.angle),V=n-Math.round(n)+Y*D+H*G,te=s-Math.round(s)+Y*G+H*D,ae=new Float64Array(l);if(h.translate(ae,ae,[V>.5?V-1:V,te>.5?te-1:te,0]),this.alignedProjMatrix=ae,l=h.invert(new Float64Array(16),this.pixelMatrix),!l)throw new Error("failed to invert matrix");this.pixelMatrixInverse=l,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const t=this.pointCoordinate(new h.pointGeometry(0,0)),n=[t.x*this.worldSize,t.y*this.worldSize,0,1];return h.transformMat4(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new h.pointGeometry(0,t))}getCameraQueryGeometry(t){const n=this.getCameraPoint();if(t.length===1)return[t[0],n];{let s=n.x,l=n.y,d=n.x,m=n.y;for(const g of t)s=Math.min(s,g.x),l=Math.min(l,g.y),d=Math.max(d,g.x),m=Math.max(m,g.y);return[new h.pointGeometry(s,l),new h.pointGeometry(d,l),new h.pointGeometry(d,m),new h.pointGeometry(s,m),new h.pointGeometry(s,l)]}}}class ol{constructor(t){this._hashName=t&&encodeURIComponent(t),h.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=function(n,s){let l=!1,d=null;const m=()=>{d=null,l&&(n(),d=setTimeout(m,300),l=!1)};return()=>(l=!0,d||m(),d)}(this._updateHashUnthrottled.bind(this))}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(t){const n=this._map.getCenter(),s=Math.round(100*this._map.getZoom())/100,l=Math.ceil((s*Math.LN2+Math.log(512/360/.5))/Math.LN10),d=Math.pow(10,l),m=Math.round(n.lng*d)/d,g=Math.round(n.lat*d)/d,y=this._map.getBearing(),x=this._map.getPitch();let S="";if(S+=t?`/${m}/${g}/${s}`:`${s}/${g}/${m}`,(y||x)&&(S+="/"+Math.round(10*y)/10),x&&(S+=`/${Math.round(x)}`),this._hashName){const T=this._hashName;let M=!1;const F=window.location.hash.slice(1).split("&").map(O=>{const D=O.split("=")[0];return D===T?(M=!0,`${D}=${S}`):O}).filter(O=>O);return M||F.push(`${T}=${S}`),`#${F.join("&")}`}return`#${S}`}_getCurrentHash(){const t=window.location.hash.replace("#","");if(this._hashName){let n;return t.split("&").map(s=>s.split("=")).forEach(s=>{s[0]===this._hashName&&(n=s)}),(n&&n[1]||"").split("/")}return t.split("/")}_onHashChange(){const t=this._getCurrentHash();if(t.length>=3&&!t.some(n=>isNaN(n))){const n=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:n,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){const t=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,t)}catch{}}}const Ae={linearity:.3,easing:h.bezier(0,0,.3,1)},Os=h.extend({deceleration:2500,maxSpeed:1400},Ae),lc=h.extend({deceleration:20,maxSpeed:1400},Ae),cc=h.extend({deceleration:1e3,maxSpeed:360},Ae),Us=h.extend({deceleration:1e3,maxSpeed:90},Ae);class ll{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:h.exported.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=h.exported.now();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new h.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:d}of this._inertiaBuffer)n.zoom+=d.zoomDelta||0,n.bearing+=d.bearingDelta||0,n.pitch+=d.pitchDelta||0,d.panDelta&&n.pan._add(d.panDelta),d.around&&(n.around=d.around),d.pinchAround&&(n.pinchAround=d.pinchAround);const s=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,l={};if(n.pan.mag()){const d=Ra(n.pan.mag(),s,h.extend({},Os,t||{}));l.offset=n.pan.mult(d.amount/n.pan.mag()),l.center=this._map.transform.center,Qn(l,d)}if(n.zoom){const d=Ra(n.zoom,s,lc);l.zoom=this._map.transform.zoom+d.amount,Qn(l,d)}if(n.bearing){const d=Ra(n.bearing,s,cc);l.bearing=this._map.transform.bearing+h.clamp(d.amount,-179,179),Qn(l,d)}if(n.pitch){const d=Ra(n.pitch,s,Us);l.pitch=this._map.transform.pitch+d.amount,Qn(l,d)}if(l.zoom||l.bearing){const d=n.pinchAround===void 0?n.around:n.pinchAround;l.around=d?this._map.unproject(d):this._map.getCenter()}return this.clear(),h.extend(l,{noMoveStart:!0})}}function Qn(o,t){(!o.duration||o.duration<t.duration)&&(o.duration=t.duration,o.easing=t.easing)}function Ra(o,t,n){const{maxSpeed:s,linearity:l,deceleration:d}=n,m=h.clamp(o*l/(t/1e3),-s,s),g=Math.abs(m)/(d*l);return{easing:n.easing,duration:1e3*g,amount:m*(g/2)}}class Gi extends h.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,s,l={}){const d=ee.mousePos(n.getCanvasContainer(),s),m=n.unproject(d);super(t,h.extend({point:d,lngLat:m,originalEvent:s},l)),this._defaultPrevented=!1,this.target=n}}class kn extends h.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,s){const l=t==="touchend"?s.changedTouches:s.touches,d=ee.touchPos(n.getCanvasContainer(),l),m=d.map(y=>n.unproject(y)),g=d.reduce((y,x,S,T)=>y.add(x.div(T.length)),new h.pointGeometry(0,0));super(t,{points:d,point:g,lngLats:m,lngLat:n.unproject(g),originalEvent:s}),this._defaultPrevented=!1}}class Vs extends h.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,s){super(t,{originalEvent:s}),this._defaultPrevented=!1}}class Ns{constructor(t,n){this._map=t,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new Vs(t.type,this._map,t))}mousedown(t,n){return this._mousedownPos=n,this._firePreventable(new Gi(t.type,this._map,t))}mouseup(t){this._map.fire(new Gi(t.type,this._map,t))}click(t,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new Gi(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Gi(t.type,this._map,t))}mouseover(t){this._map.fire(new Gi(t.type,this._map,t))}mouseout(t){this._map.fire(new Gi(t.type,this._map,t))}touchstart(t){return this._firePreventable(new kn(t.type,this._map,t))}touchmove(t){this._map.fire(new kn(t.type,this._map,t))}touchend(t){this._map.fire(new kn(t.type,this._map,t))}touchcancel(t){this._map.fire(new kn(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class $s{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Gi(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Gi("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Gi(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Si{constructor(t,n){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,n){this.isEnabled()&&t.shiftKey&&t.button===0&&(ee.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(t,n){if(!this._active)return;const s=n;if(this._lastPos.equals(s)||!this._box&&s.dist(this._startPos)<this._clickTolerance)return;const l=this._startPos;this._lastPos=s,this._box||(this._box=ee.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));const d=Math.min(l.x,s.x),m=Math.max(l.x,s.x),g=Math.min(l.y,s.y),y=Math.max(l.y,s.y);ee.setTransform(this._box,`translate(${d}px,${g}px)`),this._box.style.width=m-d+"px",this._box.style.height=y-g+"px"}mouseupWindow(t,n){if(!this._active||t.button!==0)return;const s=this._startPos,l=n;if(this.reset(),ee.suppressClick(),s.x!==l.x||s.y!==l.y)return this._map.fire(new h.Event("boxzoomend",{originalEvent:t})),{cameraAnimation:d=>d.fitScreenCoordinates(s,l,this._map.getBearing(),{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&t.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(ee.remove(this._box),this._box=null),ee.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new h.Event(t,{originalEvent:n}))}}function lr(o,t){if(o.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${o.length}, points ${t.length}`);const n={};for(let s=0;s<o.length;s++)n[o[s].identifier]=t[s];return n}class cl{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,n,s){(this.centroid||s.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=t.timeStamp),s.length===this.numTouches&&(this.centroid=function(l){const d=new h.pointGeometry(0,0);for(const m of l)d._add(m);return d.div(l.length)}(n),this.touches=lr(s,n)))}touchmove(t,n,s){if(this.aborted||!this.centroid)return;const l=lr(s,n);for(const d in this.touches){const m=l[d];(!m||m.dist(this.touches[d])>30)&&(this.aborted=!0)}}touchend(t,n,s){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),s.length===0){const l=!this.aborted&&this.centroid;if(this.reset(),l)return l}}}class ea{constructor(t){this.singleTap=new cl(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,n,s){this.singleTap.touchstart(t,n,s)}touchmove(t,n,s){this.singleTap.touchmove(t,n,s)}touchend(t,n,s){const l=this.singleTap.touchend(t,n,s);if(l){const d=t.timeStamp-this.lastTime<500,m=!this.lastTap||this.lastTap.dist(l)<30;if(d&&m||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=l,this.count===this.numTaps)return this.reset(),l}}}class Gs{constructor(){this._zoomIn=new ea({numTouches:1,numTaps:2}),this._zoomOut=new ea({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,n,s){this._zoomIn.touchstart(t,n,s),this._zoomOut.touchstart(t,n,s)}touchmove(t,n,s){this._zoomIn.touchmove(t,n,s),this._zoomOut.touchmove(t,n,s)}touchend(t,n,s){const l=this._zoomIn.touchend(t,n,s),d=this._zoomOut.touchend(t,n,s);return l?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:m=>m.easeTo({duration:300,zoom:m.getZoom()+1,around:m.unproject(l)},{originalEvent:t})}):d?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:m=>m.easeTo({duration:300,zoom:m.getZoom()-1,around:m.unproject(d)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class tn{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const n=this._moveFunction(...t);if(n.bearingDelta||n.pitchDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(t,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=n.length?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,n){if(!this.isEnabled())return;const s=this._lastPoint;if(!s)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const l=n.length?n[0]:n;return!this._moved&&l.dist(s)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=l,this._move(s,l))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&ee.suppressClick(),this.reset(t))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const hl={0:1,2:2};class Ei{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){const n=ee.mouseButton(t);this._eventButton=n}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!function(n,s){const l=hl[s];return n.buttons===void 0||(n.buttons&l)!==l}(t,this._eventButton)}isValidEndEvent(t){return ee.mouseButton(t)===this._eventButton}}class Pt{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return t.targetTouches.length===1}_isSameTouchEvent(t){return t.targetTouches[0].identifier===this._firstTouch}startMove(t){this._firstTouch=t.targetTouches[0].identifier}endMove(t){delete this._firstTouch}isValidStartEvent(t){return this._isOneFingerTouch(t)}isValidMoveEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}isValidEndEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}}const zn=o=>{o.mousedown=o.dragStart,o.mousemoveWindow=o.dragMove,o.mouseup=o.dragEnd,o.contextmenu=function(t){t.preventDefault()}},Ba=({enable:o,clickTolerance:t,bearingDegreesPerPixelMoved:n=.8})=>{const s=new Ei({checkCorrectEvent:l=>ee.mouseButton(l)===0&&l.ctrlKey||ee.mouseButton(l)===2});return new tn({clickTolerance:t,move:(l,d)=>({bearingDelta:(d.x-l.x)*n}),moveStateManager:s,enable:o,assignEvents:zn})},js=({enable:o,clickTolerance:t,pitchDegreesPerPixelMoved:n=-.5})=>{const s=new Ei({checkCorrectEvent:l=>ee.mouseButton(l)===0&&l.ctrlKey||ee.mouseButton(l)===2});return new tn({clickTolerance:t,move:(l,d)=>({pitchDelta:(d.y-l.y)*n}),moveStateManager:s,enable:o,assignEvents:zn})};class ul{constructor(t,n){this._minTouches=t.cooperativeGestures?2:1,this._clickTolerance=t.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new h.pointGeometry(0,0),setTimeout(()=>{this._cancelCooperativeMessage=!1},200)}touchstart(t,n,s){return this._calculateTransform(t,n,s)}touchmove(t,n,s){if(this._map._cooperativeGestures&&(this._minTouches===2&&s.length<2&&!this._cancelCooperativeMessage?this._map._onCooperativeGesture(t,!1,s.length):this._cancelCooperativeMessage||(this._cancelCooperativeMessage=!0)),this._active&&!(s.length<this._minTouches))return t.preventDefault(),this._calculateTransform(t,n,s)}touchend(t,n,s){this._calculateTransform(t,n,s),this._active&&s.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,n,s){s.length>0&&(this._active=!0);const l=lr(s,n),d=new h.pointGeometry(0,0),m=new h.pointGeometry(0,0);let g=0;for(const x in l){const S=l[x],T=this._touches[x];T&&(d._add(S),m._add(S.sub(T)),g++,l[x]=S)}if(this._touches=l,g<this._minTouches||!m.mag())return;const y=m.div(g);return this._sum._add(y),this._sum.mag()<this._clickTolerance?void 0:{around:d.div(g),panDelta:y}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Fa{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}_start(t){}_move(t,n,s){return{}}touchstart(t,n,s){this._firstTwoTouches||s.length<2||(this._firstTwoTouches=[s[0].identifier,s[1].identifier],this._start([n[0],n[1]]))}touchmove(t,n,s){if(!this._firstTwoTouches)return;t.preventDefault();const[l,d]=this._firstTwoTouches,m=Oa(s,n,l),g=Oa(s,n,d);if(!m||!g)return;const y=this._aroundCenter?null:m.add(g).div(2);return this._move([m,g],y,t)}touchend(t,n,s){if(!this._firstTwoTouches)return;const[l,d]=this._firstTwoTouches,m=Oa(s,n,l),g=Oa(s,n,d);m&&g||(this._active&&ee.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&t.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Oa(o,t,n){for(let s=0;s<o.length;s++)if(o[s].identifier===n)return t[s]}function Ki(o,t){return Math.log(o/t)/Math.LN2}class Ua extends Fa{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,n){const s=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(Ki(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Ki(this._distance,s),pinchAround:n}}}function Ue(o,t){return 180*o.angleWith(t)/Math.PI}class Ze extends Fa{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,n){const s=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Ue(this._vector,s),pinchAround:n}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const n=25/(Math.PI*this._minDiameter)*360,s=Ue(t,this._startVector);return Math.abs(s)<n}}function Ln(o){return Math.abs(o.y)>Math.abs(o.x)}class qs extends Fa{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,n,s){super.touchstart(t,n,s),this._currentTouchCount=s.length}_start(t){this._lastPoints=t,Ln(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,n,s){if(this._map._cooperativeGestures&&this._currentTouchCount<3)return;const l=t[0].sub(this._lastPoints[0]),d=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(l,d,s.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(l.y+d.y)/2*-.5}):void 0}gestureBeginsVertically(t,n,s){if(this._valid!==void 0)return this._valid;const l=t.mag()>=2,d=n.mag()>=2;if(!l&&!d)return;if(!l||!d)return this._firstMove===void 0&&(this._firstMove=s),s-this._firstMove<100&&void 0;const m=t.y>0==n.y>0;return Ln(t)&&Ln(n)&&m}}const Zs={panStep:100,bearingStep:15,pitchStep:10};class Ii{constructor(){const t=Zs;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=0,s=0,l=0,d=0,m=0;switch(t.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:t.shiftKey?s=-1:(t.preventDefault(),d=-1);break;case 39:t.shiftKey?s=1:(t.preventDefault(),d=1);break;case 38:t.shiftKey?l=1:(t.preventDefault(),m=-1);break;case 40:t.shiftKey?l=-1:(t.preventDefault(),m=1);break;default:return}return this._rotationDisabled&&(s=0,l=0),{cameraAnimation:g=>{const y=g.getZoom();g.easeTo({duration:300,easeId:"keyboardHandler",easing:Va,zoom:n?Math.round(y)+n*(t.shiftKey?2:1):y,bearing:g.getBearing()+s*this._bearingStep,pitch:g.getPitch()+l*this._pitchStep,offset:[-d*this._panStep,-m*this._panStep],center:g.getCenter()},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Va(o){return o*(2-o)}const Yi=4.000244140625;class hc{constructor(t,n){this._map=t,this._el=t.getCanvasContainer(),this._handler=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,h.bindAll(["_onTimeout"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=t&&t.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!this._map._metaPress)return;t.preventDefault()}let n=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const s=h.exported.now(),l=s-(this._lastWheelEventTime||0);this._lastWheelEventTime=s,n!==0&&n%Yi==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":l>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(l*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const n=ee.mousePos(this._el,t);this._around=h.LngLat.convert(this._aroundCenter?this._map.getCenter():this._map.unproject(n)),this._aroundPoint=this._map.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const t=this._map.transform;if(this._delta!==0){const g=this._type==="wheel"&&Math.abs(this._delta)>Yi?this._wheelZoomRate:this._defaultZoomRate;let y=2/(1+Math.exp(-Math.abs(this._delta*g)));this._delta<0&&y!==0&&(y=1/y);const x=typeof this._targetZoom=="number"?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(x*y))),this._type==="wheel"&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom=="number"?this._targetZoom:t.zoom,s=this._startZoom,l=this._easing;let d,m=!1;if(this._type==="wheel"&&s&&l){const g=Math.min((h.exported.now()-this._lastWheelEventTime)/200,1),y=l(g);d=h.number(s,n,y),g<1?this._frameId||(this._frameId=!0):m=!0}else d=n,m=!0;return this._active=!0,m&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!m,zoomDelta:d-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=h.ease;if(this._prevEase){const s=this._prevEase,l=(h.exported.now()-s.start)/s.duration,d=s.easing(l+.01)-s.easing(l),m=.27/Math.sqrt(d*d+1e-4)*.01,g=Math.sqrt(.0729-m*m);n=h.bezier(m,g,.25,1)}return this._prevEase={start:h.exported.now(),duration:t,easing:n},n}reset(){this._active=!1}}class Na{constructor(t,n){this._clickZoom=t,this._tapZoom=n}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Ut{constructor(){this.reset()}reset(){this._active=!1}dblclick(t,n){return t.preventDefault(),{cameraAnimation:s=>{s.easeTo({duration:300,zoom:s.getZoom()+(t.shiftKey?-1:1),around:s.unproject(n)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class jt{constructor(){this._tap=new ea({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(t,n,s){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?s.length>0&&(this._swipePoint=n[0],this._swipeTouch=s[0].identifier):this._tap.touchstart(t,n,s))}touchmove(t,n,s){if(this._tapTime){if(this._swipePoint){if(s[0].identifier!==this._swipeTouch)return;const l=n[0],d=l.y-this._swipePoint.y;return this._swipePoint=l,t.preventDefault(),this._active=!0,{zoomDelta:d/128}}}else this._tap.touchmove(t,n,s)}touchend(t,n,s){this._tapTime?this._swipePoint&&s.length===0&&this.reset():this._tap.touchend(t,n,s)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class dl{constructor(t,n,s){this._el=t,this._mousePan=n,this._touchPan=s}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class ta{constructor(t,n,s){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=n,this._mousePitch=s}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class $a{constructor(t,n,s,l){this._el=t,this._touchZoom=n,this._touchRotate=s,this._tapDragZoom=l,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Dn=o=>o.zoom||o.drag||o.pitch||o.rotate;class Xs extends h.Event{}function ia(o){return o.panDelta&&o.panDelta.mag()||o.zoomDelta||o.bearingDelta||o.pitchDelta}class ra{constructor(t,n){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ll(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n),h.bindAll(["handleEvent","handleWindowEvent"],this);const s=this._el;this._listeners=[[s,"touchstart",{passive:!0}],[s,"touchmove",{passive:!1}],[s,"touchend",void 0],[s,"touchcancel",void 0],[s,"mousedown",void 0],[s,"mousemove",void 0],[s,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[s,"mouseover",void 0],[s,"mouseout",void 0],[s,"dblclick",void 0],[s,"click",void 0],[s,"keydown",{capture:!1}],[s,"keyup",void 0],[s,"wheel",{passive:!1}],[s,"contextmenu",void 0],[window,"blur",void 0]];for(const[l,d,m]of this._listeners)ee.addEventListener(l,d,l===document?this.handleWindowEvent:this.handleEvent,m)}destroy(){for(const[t,n,s]of this._listeners)ee.removeEventListener(t,n,t===document?this.handleWindowEvent:this.handleEvent,s)}_addDefaultHandlers(t){const n=this._map,s=n.getCanvasContainer();this._add("mapEvent",new Ns(n,t));const l=n.boxZoom=new Si(n,t);this._add("boxZoom",l);const d=new Gs,m=new Ut;n.doubleClickZoom=new Na(m,d),this._add("tapZoom",d),this._add("clickZoom",m);const g=new jt;this._add("tapDragZoom",g);const y=n.touchPitch=new qs(n);this._add("touchPitch",y);const x=Ba(t),S=js(t);n.dragRotate=new ta(t,x,S),this._add("mouseRotate",x,["mousePitch"]),this._add("mousePitch",S,["mouseRotate"]);const T=(({enable:Y,clickTolerance:H})=>{const V=new Ei({checkCorrectEvent:te=>ee.mouseButton(te)===0&&!te.ctrlKey});return new tn({clickTolerance:H,move:(te,ae)=>({around:ae,panDelta:ae.sub(te)}),activateOnStart:!0,moveStateManager:V,enable:Y,assignEvents:zn})})(t),M=new ul(t,n);n.dragPan=new dl(s,T,M),this._add("mousePan",T),this._add("touchPan",M,["touchZoom","touchRotate"]);const F=new Ze,O=new Ua;n.touchZoomRotate=new $a(s,O,F,g),this._add("touchRotate",F,["touchPan","touchZoom"]),this._add("touchZoom",O,["touchPan","touchRotate"]);const D=n.scrollZoom=new hc(n,this);this._add("scrollZoom",D,["mousePan"]);const G=n.keyboard=new Ii;this._add("keyboard",G),this._add("blockableMapEvent",new $s(n));for(const Y of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[Y]&&n[Y].enable(t[Y])}_add(t,n,s){this._handlers.push({handlerName:t,handler:n,allowed:s}),this._handlersById[t]=n}stop(t){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Dn(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,n,s){for(const l in t)if(l!==s&&(!n||n.indexOf(l)<0))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){const n=[];for(const s of t)this._el.contains(s.target)&&n.push(s);return n}handleEvent(t,n){if(t.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const s=t.type==="renderFrame"?void 0:t,l={needsRenderFrame:!1},d={},m={},g=t.touches,y=g?this._getMapTouches(g):void 0,x=y?ee.touchPos(this._el,y):ee.mousePos(this._el,t);for(const{handlerName:M,handler:F,allowed:O}of this._handlers){if(!F.isEnabled())continue;let D;this._blockedByActive(m,O,M)?F.reset():F[n||t.type]&&(D=F[n||t.type](t,x,y),this.mergeHandlerResult(l,d,D,M,s),D&&D.needsRenderFrame&&this._triggerRenderFrame()),(D||F.isActive())&&(m[M]=F)}const S={};for(const M in this._previousActiveHandlers)m[M]||(S[M]=s);this._previousActiveHandlers=m,(Object.keys(S).length||ia(l))&&(this._changes.push([l,d,S]),this._triggerRenderFrame()),(Object.keys(m).length||ia(l))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:T}=l;T&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],T(this._map))}mergeHandlerResult(t,n,s,l,d){if(!s)return;h.extend(t,s);const m={handlerName:l,originalEvent:s.originalEvent||d};s.zoomDelta!==void 0&&(n.zoom=m),s.panDelta!==void 0&&(n.drag=m),s.pitchDelta!==void 0&&(n.pitch=m),s.bearingDelta!==void 0&&(n.rotate=m)}_applyChanges(){const t={},n={},s={};for(const[l,d,m]of this._changes)l.panDelta&&(t.panDelta=(t.panDelta||new h.pointGeometry(0,0))._add(l.panDelta)),l.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+l.zoomDelta),l.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+l.bearingDelta),l.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+l.pitchDelta),l.around!==void 0&&(t.around=l.around),l.pinchAround!==void 0&&(t.pinchAround=l.pinchAround),l.noInertia&&(t.noInertia=l.noInertia),h.extend(n,d),h.extend(s,m);this._updateMapTransform(t,n,s),this._changes=[]}_updateMapTransform(t,n,s){const l=this._map,d=l.transform,m=l.terrain;if(!(ia(t)||m&&this._terrainMovement))return this._fireEvents(n,s,!0);let{panDelta:g,zoomDelta:y,bearingDelta:x,pitchDelta:S,around:T,pinchAround:M}=t;M!==void 0&&(T=M),l._stop(!0),T=T||l.transform.centerPoint;const F=d.pointLocation(g?T.sub(g):T);x&&(d.bearing+=x),S&&(d.pitch+=S),y&&(d.zoom+=y),m?this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?d.center=d.pointLocation(d.centerPoint.sub(g)):d.setLocationAtPoint(F,T):(this._terrainMovement=!0,d.freezeElevation=!0,d.setLocationAtPoint(F,T),this._map.once("moveend",()=>{d.freezeElevation=!1,this._terrainMovement=!1,d.recalculateZoom(l.terrain)})):d.setLocationAtPoint(F,T),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,s,!0)}_fireEvents(t,n,s){const l=Dn(this._eventsInProgress),d=Dn(t),m={};for(const S in t){const{originalEvent:T}=t[S];this._eventsInProgress[S]||(m[`${S}start`]=T),this._eventsInProgress[S]=t[S]}!l&&d&&this._fireEvent("movestart",d.originalEvent);for(const S in m)this._fireEvent(S,m[S]);d&&this._fireEvent("move",d.originalEvent);for(const S in t){const{originalEvent:T}=t[S];this._fireEvent(S,T)}const g={};let y;for(const S in this._eventsInProgress){const{handlerName:T,originalEvent:M}=this._eventsInProgress[S];this._handlersById[T].isActive()||(delete this._eventsInProgress[S],y=n[T]||M,g[`${S}end`]=y)}for(const S in g)this._fireEvent(S,g[S]);const x=Dn(this._eventsInProgress);if(s&&(l||d)&&!x){this._updatingCamera=!0;const S=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),T=M=>M!==0&&-this._bearingSnap<M&&M<this._bearingSnap;S?(T(S.bearing||this._map.getBearing())&&(S.bearing=0),S.freezeElevation=!0,this._map.easeTo(S,{originalEvent:y})):(this._map.fire(new h.Event("moveend",{originalEvent:y})),T(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,n){this._map.fire(new h.Event(t,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(t=>{delete this._frameId,this.handleEvent(new Xs("renderFrame",{timeStamp:t})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const Ws={extend:(o,...t)=>h.extend(o,...t),run(o){o()},logToElement(o,t=!1,n="log"){const s=window.document.getElementById(n);s&&(t&&(s.innerHTML=""),s.innerHTML+=`<br>${o}`)}};class Hs extends h.Evented{constructor(t,n){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=n.bearingSnap,h.bindAll(["_renderFrameCallback"],this)}getCenter(){return new h.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(t,n){return this.jumpTo({center:t},n)}panBy(t,n,s){return t=h.pointGeometry.convert(t).mult(-1),this.panTo(this.transform.center,h.extend({offset:t},n),s)}panTo(t,n,s){return this.easeTo(h.extend({center:t},n),s)}getZoom(){return this.transform.zoom}setZoom(t,n){return this.jumpTo({zoom:t},n),this}zoomTo(t,n,s){return this.easeTo(h.extend({zoom:t},n),s)}zoomIn(t,n){return this.zoomTo(this.getZoom()+1,t,n),this}zoomOut(t,n){return this.zoomTo(this.getZoom()-1,t,n),this}getBearing(){return this.transform.bearing}setBearing(t,n){return this.jumpTo({bearing:t},n),this}getPadding(){return this.transform.padding}setPadding(t,n){return this.jumpTo({padding:t},n),this}rotateTo(t,n,s){return this.easeTo(h.extend({bearing:t},n),s)}resetNorth(t,n){return this.rotateTo(0,h.extend({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(h.extend({bearing:0,pitch:0,duration:1e3},t),n),this}snapToNorth(t,n){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,n):this}getPitch(){return this.transform.pitch}setPitch(t,n){return this.jumpTo({pitch:t},n),this}cameraForBounds(t,n){t=h.LngLatBounds.convert(t);const s=n&&n.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),s,n)}_cameraForBoxAndBearing(t,n,s,l){const d={top:0,bottom:0,right:0,left:0};if(typeof(l=h.extend({padding:d,offset:[0,0],maxZoom:this.transform.maxZoom},l)).padding=="number"){const ae=l.padding;l.padding={top:ae,bottom:ae,right:ae,left:ae}}l.padding=h.extend(d,l.padding);const m=this.transform,g=m.padding,y=m.project(h.LngLat.convert(t)),x=m.project(h.LngLat.convert(n)),S=y.rotate(-s*Math.PI/180),T=x.rotate(-s*Math.PI/180),M=new h.pointGeometry(Math.max(S.x,T.x),Math.max(S.y,T.y)),F=new h.pointGeometry(Math.min(S.x,T.x),Math.min(S.y,T.y)),O=M.sub(F),D=(m.width-(g.left+g.right+l.padding.left+l.padding.right))/O.x,G=(m.height-(g.top+g.bottom+l.padding.top+l.padding.bottom))/O.y;if(G<0||D<0)return void h.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const Y=Math.min(m.scaleZoom(m.scale*Math.min(D,G)),l.maxZoom),H=h.pointGeometry.convert(l.offset),V=new h.pointGeometry((l.padding.left-l.padding.right)/2,(l.padding.top-l.padding.bottom)/2).rotate(s*Math.PI/180),te=H.add(V).mult(m.scale/m.zoomScale(Y));return{center:m.unproject(y.add(x).div(2).sub(te)),zoom:Y,bearing:s}}fitBounds(t,n,s){return this._fitInternal(this.cameraForBounds(t,n),n,s)}fitScreenCoordinates(t,n,s,l,d){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(h.pointGeometry.convert(t)),this.transform.pointLocation(h.pointGeometry.convert(n)),s,l),l,d)}_fitInternal(t,n,s){return t?(delete(n=h.extend(t,n)).padding,n.linear?this.easeTo(n,s):this.flyTo(n,s)):this}jumpTo(t,n){this.stop();const s=this.transform;let l=!1,d=!1,m=!1;return"zoom"in t&&s.zoom!==+t.zoom&&(l=!0,s.zoom=+t.zoom),t.center!==void 0&&(s.center=h.LngLat.convert(t.center)),"bearing"in t&&s.bearing!==+t.bearing&&(d=!0,s.bearing=+t.bearing),"pitch"in t&&s.pitch!==+t.pitch&&(m=!0,s.pitch=+t.pitch),t.padding==null||s.isPaddingEqual(t.padding)||(s.padding=t.padding),this.fire(new h.Event("movestart",n)).fire(new h.Event("move",n)),l&&this.fire(new h.Event("zoomstart",n)).fire(new h.Event("zoom",n)).fire(new h.Event("zoomend",n)),d&&this.fire(new h.Event("rotatestart",n)).fire(new h.Event("rotate",n)).fire(new h.Event("rotateend",n)),m&&this.fire(new h.Event("pitchstart",n)).fire(new h.Event("pitch",n)).fire(new h.Event("pitchend",n)),this.fire(new h.Event("moveend",n))}calculateCameraOptionsFromTo(t,n,s,l=0){const d=h.MercatorCoordinate.fromLngLat(t,n),m=h.MercatorCoordinate.fromLngLat(s,l),g=m.x-d.x,y=m.y-d.y,x=m.z-d.z,S=Math.hypot(g,y,x);if(S===0)throw new Error("Can't calculate camera options with same From and To");const T=Math.hypot(g,y),M=this.transform.scaleZoom(this.transform.cameraToCenterDistance/S/this.transform.tileSize),F=180*Math.atan2(g,-y)/Math.PI;let O=180*Math.acos(T/S)/Math.PI;return O=x<0?90-O:90+O,{center:m.toLngLat(),zoom:M,pitch:O,bearing:F}}easeTo(t,n){this._stop(!1,t.easeId),((t=h.extend({offset:[0,0],duration:500,easing:h.ease},t)).animate===!1||!t.essential&&h.exported.prefersReducedMotion)&&(t.duration=0);const s=this.transform,l=this.getZoom(),d=this.getBearing(),m=this.getPitch(),g=this.getPadding(),y="zoom"in t?+t.zoom:l,x="bearing"in t?this._normalizeBearing(t.bearing,d):d,S="pitch"in t?+t.pitch:m,T="padding"in t?t.padding:s.padding,M=h.pointGeometry.convert(t.offset);let F=s.centerPoint.add(M);const O=s.pointLocation(F),D=h.LngLat.convert(t.center||O);this._normalizeCenter(D);const G=s.project(O),Y=s.project(D).sub(G),H=s.zoomScale(y-l);let V,te;t.around&&(V=h.LngLat.convert(t.around),te=s.locationPoint(V));const ae={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||y!==l,this._rotating=this._rotating||d!==x,this._pitching=this._pitching||S!==m,this._padding=!s.isPaddingEqual(T),this._easeId=t.easeId,this._prepareEase(n,t.noMoveStart,ae),this.terrain&&this._prepareElevation(D),this._ease(se=>{if(this._zooming&&(s.zoom=h.number(l,y,se)),this._rotating&&(s.bearing=h.number(d,x,se)),this._pitching&&(s.pitch=h.number(m,S,se)),this._padding&&(s.interpolatePadding(g,T,se),F=s.centerPoint.add(M)),this.terrain&&!t.freezeElevation&&this._updateElevation(se),V)s.setLocationAtPoint(V,te);else{const ue=s.zoomScale(s.zoom-l),me=y>l?Math.min(2,H):Math.max(.5,H),xe=Math.pow(me,1-se),_e=s.unproject(G.add(Y.mult(se*xe)).mult(ue));s.setLocationAtPoint(s.renderWorldCopies?_e.wrap():_e,F)}this._fireMoveEvents(n)},se=>{this.terrain&&this._finalizeElevation(),this._afterEase(n,se)},t),this}_prepareEase(t,n,s={}){this._moving=!0,n||s.moving||this.fire(new h.Event("movestart",t)),this._zooming&&!s.zooming&&this.fire(new h.Event("zoomstart",t)),this._rotating&&!s.rotating&&this.fire(new h.Event("rotatestart",t)),this._pitching&&!s.pitching&&this.fire(new h.Event("pitchstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.transform.getElevation(t,this.terrain),this.transform.freezeElevation=!0}_updateElevation(t){const n=this.transform.getElevation(this._elevationCenter,this.terrain);if(t<1&&n!==this._elevationTarget){const s=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(s-(n-(s*t+this._elevationStart))/(1-t)),this._elevationTarget=n}this.transform.elevation=h.number(this._elevationStart,this._elevationTarget,t)}_finalizeElevation(){this.transform.freezeElevation=!1,this.transform.recalculateZoom(this.terrain)}_fireMoveEvents(t){this.fire(new h.Event("move",t)),this._zooming&&this.fire(new h.Event("zoom",t)),this._rotating&&this.fire(new h.Event("rotate",t)),this._pitching&&this.fire(new h.Event("pitch",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const s=this._zooming,l=this._rotating,d=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,s&&this.fire(new h.Event("zoomend",t)),l&&this.fire(new h.Event("rotateend",t)),d&&this.fire(new h.Event("pitchend",t)),this.fire(new h.Event("moveend",t))}flyTo(t,n){if(!t.essential&&h.exported.prefersReducedMotion){const Le=h.pick(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Le,n)}this.stop(),t=h.extend({offset:[0,0],speed:1.2,curve:1.42,easing:h.ease},t);const s=this.transform,l=this.getZoom(),d=this.getBearing(),m=this.getPitch(),g=this.getPadding(),y="zoom"in t?h.clamp(+t.zoom,s.minZoom,s.maxZoom):l,x="bearing"in t?this._normalizeBearing(t.bearing,d):d,S="pitch"in t?+t.pitch:m,T="padding"in t?t.padding:s.padding,M=s.zoomScale(y-l),F=h.pointGeometry.convert(t.offset);let O=s.centerPoint.add(F);const D=s.pointLocation(O),G=h.LngLat.convert(t.center||D);this._normalizeCenter(G);const Y=s.project(D),H=s.project(G).sub(Y);let V=t.curve;const te=Math.max(s.width,s.height),ae=te/M,se=H.mag();if("minZoom"in t){const Le=h.clamp(Math.min(t.minZoom,l,y),s.minZoom,s.maxZoom),mt=te/s.zoomScale(Le-l);V=Math.sqrt(mt/se*2)}const ue=V*V;function me(Le){const mt=(ae*ae-te*te+(Le?-1:1)*ue*ue*se*se)/(2*(Le?ae:te)*ue*se);return Math.log(Math.sqrt(mt*mt+1)-mt)}function xe(Le){return(Math.exp(Le)-Math.exp(-Le))/2}function _e(Le){return(Math.exp(Le)+Math.exp(-Le))/2}const we=me(0);let ze=function(Le){return _e(we)/_e(we+V*Le)},We=function(Le){return te*((_e(we)*(xe(mt=we+V*Le)/_e(mt))-xe(we))/ue)/se;var mt},Ke=(me(1)-we)/V;if(Math.abs(se)<1e-6||!isFinite(Ke)){if(Math.abs(te-ae)<1e-6)return this.easeTo(t,n);const Le=ae<te?-1:1;Ke=Math.abs(Math.log(ae/te))/V,We=function(){return 0},ze=function(mt){return Math.exp(Le*V*mt)}}return t.duration="duration"in t?+t.duration:1e3*Ke/("screenSpeed"in t?+t.screenSpeed/V:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=d!==x,this._pitching=S!==m,this._padding=!s.isPaddingEqual(T),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(G),this._ease(Le=>{const mt=Le*Ke,ft=1/ze(mt);s.zoom=Le===1?y:l+s.scaleZoom(ft),this._rotating&&(s.bearing=h.number(d,x,Le)),this._pitching&&(s.pitch=h.number(m,S,Le)),this._padding&&(s.interpolatePadding(g,T,Le),O=s.centerPoint.add(F)),this.terrain&&!t.freezeElevation&&this._updateElevation(Le);const tt=Le===1?G:s.unproject(Y.add(H.mult(We(mt))).mult(ft));s.setLocationAtPoint(s.renderWorldCopies?tt.wrap():tt,O),this._fireMoveEvents(n)},()=>{this.terrain&&this._finalizeElevation(),this._afterEase(n)},t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,n){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const s=this._onEaseEnd;delete this._onEaseEnd,s.call(this,n)}if(!t){const s=this.handlers;s&&s.stop(!1)}return this}_ease(t,n,s){s.animate===!1||s.duration===0?(t(1),n()):(this._easeStart=h.exported.now(),this._easeOptions=s,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((h.exported.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,n){t=h.wrap(t,-180,180);const s=Math.abs(t-n);return Math.abs(t-360-n)<s&&(t-=360),Math.abs(t+360-n)<s&&(t+=360),t}_normalizeCenter(t){const n=this.transform;if(!n.renderWorldCopies||n.lngRange)return;const s=t.lng-n.center.lng;t.lng+=s>180?-360:s<-180?360:0}}class Ga{constructor(t={}){this.options=t,h.bindAll(["_toggleAttribution","_updateData","_updateCompact","_updateCompactMinimize"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options&&this.options.compact,this._container=ee.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=ee.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=ee.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(){ee.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,n){const s=this._map._getUIString(`AttributionControl.${n}`);t.title=s,t.setAttribute("aria-label",s)}_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")))}_updateData(t){!t||t.sourceDataType!=="metadata"&&t.sourceDataType!=="visibility"&&t.dataType!=="style"&&t.type!=="terrain"||this._updateAttributions()}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map(l=>typeof l!="string"?"":l)):typeof this.options.customAttribution=="string"&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const l=this._map.style.stylesheet;this.styleOwner=l.owner,this.styleId=l.id}const n=this._map.style.sourceCaches;for(const l in n){const d=n[l];if(d.used||d.usedForTerrain){const m=d.getSource();m.attribution&&t.indexOf(m.attribution)<0&&t.push(m.attribution)}}t=t.filter(l=>String(l).trim()),t.sort((l,d)=>l.length-d.length),t=t.filter((l,d)=>{for(let m=d+1;m<t.length;m++)if(t[m].indexOf(l)>=0)return!1;return!0});const s=t.join(" | ");s!==this._attribHTML&&(this._attribHTML=s,t.length?(this._innerContainer.innerHTML=s,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}_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"))}_updateCompactMinimize(){this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")}}class ja{constructor(t={}){this.options=t,h.bindAll(["_updateCompact"],this)}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=ee.create("div","maplibregl-ctrl");const n=ee.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){ee.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}_updateCompact(){const t=this._container.children;if(t.length){const n=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&n.classList.add("maplibregl-compact"):n.classList.remove("maplibregl-compact")}}}class Ks{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const n=++this._id;return this._queue.push({callback:t,id:n,cancelled:!1}),n}remove(t){const n=this._currentlyRunning,s=n?this._queue.concat(n):this._queue;for(const l of s)if(l.id===t)return void(l.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const s of n)if(!s.cancelled&&(s.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}const Ys={"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":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.enableTerrain":"Enable terrain","TerrainControl.disableTerrain":"Disable terrain"};var Js=h.createLayout([{name:"a_pos3d",type:"Int16",components:3}]);class Qs extends h.Evented{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(t,n){this.sourceCache.update(t,n),this._renderableTilesKeys=[];const s={};for(const l of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n}))s[l.key]=!0,this._renderableTilesKeys.push(l.key),this._tiles[l.key]||(l.posMatrix=new Float64Array(16),h.ortho(l.posMatrix,0,h.EXTENT,0,h.EXTENT,0,1),this._tiles[l.key]=new Je(l,this.tileSize));for(const l in this._tiles)s[l]||delete this._tiles[l]}freeRtt(t){for(const n in this._tiles){const s=this._tiles[n];(!t||s.tileID.equals(t)||s.tileID.isChildOf(t)||t.isChildOf(s.tileID))&&(s.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(t=>this.getTileByID(t))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){const n={};for(const s of this._renderableTilesKeys){const l=this._tiles[s].tileID;if(l.canonical.equals(t.canonical)){const d=t.clone();d.posMatrix=new Float64Array(16),h.ortho(d.posMatrix,0,h.EXTENT,0,h.EXTENT,0,1),n[s]=d}else if(l.canonical.isChildOf(t.canonical)){const d=t.clone();d.posMatrix=new Float64Array(16);const m=l.canonical.z-t.canonical.z,g=l.canonical.x-(l.canonical.x>>m<<m),y=l.canonical.y-(l.canonical.y>>m<<m),x=h.EXTENT>>m;h.ortho(d.posMatrix,0,x,0,x,0,1),h.translate(d.posMatrix,d.posMatrix,[-g*x,-y*x,0]),n[s]=d}else if(t.canonical.isChildOf(l.canonical)){const d=t.clone();d.posMatrix=new Float64Array(16);const m=t.canonical.z-l.canonical.z,g=t.canonical.x-(t.canonical.x>>m<<m),y=t.canonical.y-(t.canonical.y>>m<<m),x=h.EXTENT>>m;h.ortho(d.posMatrix,0,h.EXTENT,0,h.EXTENT,0,1),h.translate(d.posMatrix,d.posMatrix,[g*x,y*x,0]),h.scale(d.posMatrix,d.posMatrix,[1/2**m,1/2**m,0]),n[s]=d}}return n}getSourceTile(t,n){const s=this.sourceCache._source;let l=t.overscaledZ-this.deltaZoom;if(l>s.maxzoom&&(l=s.maxzoom),l<s.minzoom)return null;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(l).key);let d=this.sourceCache.getTileByID(this._sourceTileCache[t.key]);if((!d||!d.dem)&&n)for(;l>=s.minzoom&&(!d||!d.dem);)d=this.sourceCache.getTileByID(t.scaledTo(l--).key);return d}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter(n=>n.timeAdded>=t)}}class qa{constructor(t,n,s){this.painter=t,this.sourceCache=new Qs(n),this.options=s,this.exaggeration=typeof s.exaggeration=="number"?s.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,n,s,l=h.EXTENT){if(!(n>=0&&n<l&&s>=0&&s<l))return 0;let d=0;const m=this.getTerrainData(t);if(m.tile&&m.tile.dem){const g=function(O,D,G){var Y=D[0],H=D[1];return O[0]=G[0]*Y+G[4]*H+G[12],O[1]=G[1]*Y+G[5]*H+G[13],O}([],[n/l*h.EXTENT,s/l*h.EXTENT],m.u_terrain_matrix),y=[g[0]*m.tile.dem.dim,g[1]*m.tile.dem.dim],x=[Math.floor(y[0]),Math.floor(y[1])],S=m.tile.dem.get(x[0],x[1]),T=m.tile.dem.get(x[0],x[1]+1),M=m.tile.dem.get(x[0]+1,x[1]),F=m.tile.dem.get(x[0]+1,x[1]+1);d=h.number(h.number(S,T,y[0]-x[0]),h.number(M,F,y[0]-x[0]),y[1]-x[1])}return d}getElevation(t,n,s,l=h.EXTENT){return this.getDEMElevation(t,n,s,l)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){const l=this.painter.context,d=new h.RGBAImage({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new Mt(l,d,l.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Mt(l,new h.RGBAImage({width:1,height:1}),l.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(l.gl.NEAREST,l.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=h.identity([])}const n=this.sourceCache.getSourceTile(t,!0);if(n&&n.dem&&(!n.demTexture||n.needsTerrainPrepare)){const l=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new Mt(l,n.dem.getPixels(),l.gl.RGBA,{premultiply:!1}),n.demTexture.bind(l.gl.NEAREST,l.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}const s=n&&n+n.tileID.key+t.key;if(s&&!this._demMatrixCache[s]){const l=this.sourceCache.sourceCache._source.maxzoom;let d=t.canonical.z-n.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=l?d=t.canonical.z-l:h.warnOnce("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const m=t.canonical.x-(t.canonical.x>>d<<d),g=t.canonical.y-(t.canonical.y>>d<<d),y=h.fromScaling(new Float64Array(16),[1/(h.EXTENT<<d),1/(h.EXTENT<<d),0]);h.translate(y,y,[m*h.EXTENT,g*h.EXTENT,0]),this._demMatrixCache[t.key]={matrix:y,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:n&&n.dem&&n.dem.dim||1,u_terrain_matrix:s?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:n&&n.dem&&n.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(n&&n.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:n}}getFramebuffer(t){const n=this.painter,s=n.width/devicePixelRatio,l=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===s&&this._fbo.height===l||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new Mt(n.context,{width:s,height:l,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Mt(n.context,{width:s,height:l,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=n.context.createFramebuffer(s,l,!0),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,s,l))),this._fbo.colorAttachment.set(t==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let d=0,m=0;d<this._coordsTextureSize;d++)for(let g=0;g<this._coordsTextureSize;g++,m+=4)n[m+0]=255&g,n[m+1]=255&d,n[m+2]=g>>8<<4|d>>8,n[m+3]=0;const s=new h.RGBAImage({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),l=new Mt(t,s,t.gl.RGBA,{premultiply:!1});return l.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=l,l}pointCoordinate(t){const n=new Uint8Array(4),s=this.painter.context,l=s.gl;s.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),l.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,l.RGBA,l.UNSIGNED_BYTE,n),s.bindFramebuffer.set(null);const d=n[0]+(n[2]>>4<<8),m=n[1]+((15&n[2])<<8),g=this.coordsIndex[255-n[3]],y=g&&this.sourceCache.getTileByID(g);if(!y)return null;const x=this._coordsTextureSize,S=(1<<y.tileID.canonical.z)*x;return new h.MercatorCoordinate((y.tileID.canonical.x*x+d)/S,(y.tileID.canonical.y*x+m)/S,this.getElevation(y.tileID,d,m,x))}getTerrainMesh(){if(this._mesh)return this._mesh;const t=this.painter.context,n=new h.Pos3dArray,s=new h.TriangleIndexArray,l=this.meshSize,d=h.EXTENT/l,m=l*l;for(let T=0;T<=l;T++)for(let M=0;M<=l;M++)n.emplaceBack(M*d,T*d,0);for(let T=0;T<m;T+=l+1)for(let M=0;M<l;M++)s.emplaceBack(M+T,l+M+T+1,l+M+T+2),s.emplaceBack(M+T,l+M+T+2,M+T+1);const g=n.length,y=g+2*(l+1);for(const T of[0,1])for(let M=0;M<=l;M++)for(const F of[0,1])n.emplaceBack(M*d,T*h.EXTENT,F);for(let T=0;T<2*l;T+=2)s.emplaceBack(y+T,y+T+1,y+T+3),s.emplaceBack(y+T,y+T+3,y+T+2),s.emplaceBack(g+T,g+T+3,g+T+1),s.emplaceBack(g+T,g+T+2,g+T+3);const x=n.length,S=x+2*(l+1);for(const T of[0,1])for(let M=0;M<=l;M++)for(const F of[0,1])n.emplaceBack(T*h.EXTENT,M*d,F);for(let T=0;T<2*l;T+=2)s.emplaceBack(x+T,x+T+1,x+T+3),s.emplaceBack(x+T,x+T+3,x+T+2),s.emplaceBack(S+T,S+T+3,S+T+1),s.emplaceBack(S+T,S+T+2,S+T+3);return this._mesh={indexBuffer:t.createIndexBuffer(s),vertexBuffer:t.createVertexBuffer(n,Js.members),segments:h.SegmentVector.simpleSegment(0,0,n.length,s.length)},this._mesh}getMeshFrameDelta(t){return 2*Math.PI*h.earthRadius/Math.pow(2,t)/5}getMinMaxElevation(t){const n=this.getTerrainData(t).tile,s={minElevation:null,maxElevation:null};return n&&n.dem&&(s.minElevation=n.dem.min*this.exaggeration,s.maxElevation=n.dem.max*this.exaggeration),s}}class eo{constructor(t,n,s){this._context=t,this._size=n,this._tileSize=s,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0),s=new Mt(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return s.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_COMPONENT16,this._tileSize,this._tileSize)),n.colorAttachment.set(s.texture),{id:t,fbo:n,texture:s,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(n=>t.id!==n),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length<this._size)&&this._objects.some(t=>!t.inUse)===!1}}const Lr={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Za{constructor(t,n){this.painter=t,this.terrain=n,this.pool=new eo(t.context,30,n.sourceCache.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter(s=>!t._layers[s].isHidden(n)),this._coordsDescendingInv={};for(const s in t.sourceCaches){this._coordsDescendingInv[s]={};const l=t.sourceCaches[s].getVisibleCoordinates();for(const d of l){const m=this.terrain.sourceCache.getTerrainCoords(d);for(const g in m)this._coordsDescendingInv[s][g]||(this._coordsDescendingInv[s][g]=[]),this._coordsDescendingInv[s][g].push(m[g])}}this._coordsDescendingInvStr={};for(const s of t._order){const l=t._layers[s],d=l.source;if(Lr[l.type]&&!this._coordsDescendingInvStr[d]){this._coordsDescendingInvStr[d]={};for(const m in this._coordsDescendingInv[d])this._coordsDescendingInvStr[d][m]=this._coordsDescendingInv[d][m].map(g=>g.key).sort().join()}}for(const s of this._renderableTiles)for(const l in this._coordsDescendingInvStr){const d=this._coordsDescendingInvStr[l][s.tileID.key];d&&d!==s.rttCoords[l]&&(s.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;const n=t.type,s=this.painter,l=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(Lr[n]&&(this._prevType&&Lr[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(t.id),!l))return!0;if(Lr[this._prevType]||Lr[n]&&l){this._prevType=n;const d=this._stacks.length-1,m=this._stacks[d]||[];for(const g of this._renderableTiles){if(this.pool.isFull()&&(Fs(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(g),g.rtt[d]){const x=this.pool.getObjectForId(g.rtt[d].id);if(x.stamp===g.rtt[d].stamp){this.pool.useObject(x);continue}}const y=this.pool.getOrCreateFreeObject();this.pool.useObject(y),this.pool.stampObject(y),g.rtt[d]={id:y.id,stamp:y.stamp},s.context.bindFramebuffer.set(y.fbo.framebuffer),s.context.clear({color:h.Color.transparent});for(let x=0;x<m.length;x++){const S=s.style._layers[m[x]],T=S.source?this._coordsDescendingInv[S.source][g.tileID.key]:[g.tileID];s.context.viewport.set([0,0,y.fbo.width,y.fbo.height]),s._renderTileClippingMasks(S,T),s.renderLayer(s,s.style.sourceCaches[S.source],S,T),S.source&&(g.rttCoords[S.source]=this._coordsDescendingInvStr[S.source][g.tileID.key])}}return Fs(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),Lr[n]}return!1}}const to=Ye,io={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:void 0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",transformRequest:null,fadeDuration:300,crossSourceCollisions:!0},Xa=o=>{o.touchstart=o.dragStart,o.touchmoveWindow=o.dragMove,o.touchend=o.dragEnd},ro={showCompass:!0,showZoom:!0,visualizePitch:!1};class pl{constructor(t,n,s=!1){this._clickTolerance=10;const l=t.dragRotate._mouseRotate.getClickTolerance(),d=t.dragRotate._mousePitch.getClickTolerance();this.element=n,this.mouseRotate=Ba({clickTolerance:l,enable:!0}),this.touchRotate=(({enable:m,clickTolerance:g,bearingDegreesPerPixelMoved:y=.8})=>{const x=new Pt;return new tn({clickTolerance:g,move:(S,T)=>({bearingDelta:(T.x-S.x)*y}),moveStateManager:x,enable:m,assignEvents:Xa})})({clickTolerance:l,enable:!0}),this.map=t,s&&(this.mousePitch=js({clickTolerance:d,enable:!0}),this.touchPitch=(({enable:m,clickTolerance:g,pitchDegreesPerPixelMoved:y=-.5})=>{const x=new Pt;return new tn({clickTolerance:g,move:(S,T)=>({pitchDelta:(T.y-S.y)*y}),moveStateManager:x,enable:m,assignEvents:Xa})})({clickTolerance:d,enable:!0})),h.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),ee.addEventListener(n,"mousedown",this.mousedown),ee.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),ee.addEventListener(n,"touchcancel",this.reset)}startMouse(t,n){this.mouseRotate.dragStart(t,n),this.mousePitch&&this.mousePitch.dragStart(t,n),ee.disableDrag()}startTouch(t,n){this.touchRotate.dragStart(t,n),this.touchPitch&&this.touchPitch.dragStart(t,n),ee.disableDrag()}moveMouse(t,n){const s=this.map,{bearingDelta:l}=this.mouseRotate.dragMove(t,n)||{};if(l&&s.setBearing(s.getBearing()+l),this.mousePitch){const{pitchDelta:d}=this.mousePitch.dragMove(t,n)||{};d&&s.setPitch(s.getPitch()+d)}}moveTouch(t,n){const s=this.map,{bearingDelta:l}=this.touchRotate.dragMove(t,n)||{};if(l&&s.setBearing(s.getBearing()+l),this.touchPitch){const{pitchDelta:d}=this.touchPitch.dragMove(t,n)||{};d&&s.setPitch(s.getPitch()+d)}}off(){const t=this.element;ee.removeEventListener(t,"mousedown",this.mousedown),ee.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),ee.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),ee.removeEventListener(window,"touchend",this.touchend),ee.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){ee.enableDrag(),ee.removeEventListener(window,"mousemove",this.mousemove),ee.removeEventListener(window,"mouseup",this.mouseup),ee.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),ee.removeEventListener(window,"touchend",this.touchend)}mousedown(t){this.startMouse(h.extend({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),ee.mousePos(this.element,t)),ee.addEventListener(window,"mousemove",this.mousemove),ee.addEventListener(window,"mouseup",this.mouseup)}mousemove(t){this.moveMouse(t,ee.mousePos(this.element,t))}mouseup(t){this.mouseRotate.dragEnd(t),this.mousePitch&&this.mousePitch.dragEnd(t),this.offTemp()}touchstart(t){t.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=ee.touchPos(this.element,t.targetTouches)[0],this.startTouch(t,this._startPos),ee.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),ee.addEventListener(window,"touchend",this.touchend))}touchmove(t){t.targetTouches.length!==1?this.reset():(this._lastPos=ee.touchPos(this.element,t.targetTouches)[0],this.moveTouch(t,this._lastPos))}touchend(t){t.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()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}function no(o,t,n){if(o=new h.LngLat(o.lng,o.lat),t){const s=new h.LngLat(o.lng-360,o.lat),l=new h.LngLat(o.lng+360,o.lat),d=n.locationPoint(o).distSqr(t);n.locationPoint(s).distSqr(t)<d?o=s:n.locationPoint(l).distSqr(t)<d&&(o=l)}for(;Math.abs(o.lng-n.center.lng)>180;){const s=n.locationPoint(o);if(s.x>=0&&s.y>=0&&s.x<=n.width&&s.y<=n.height)break;o.lng>n.center.lng?o.lng-=360:o.lng+=360}return o}const Wa={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 ao(o,t,n){const s=o.classList;for(const l in Wa)s.remove(`maplibregl-${n}-anchor-${l}`);s.add(`maplibregl-${n}-anchor-${t}`)}class Ha extends h.Evented{constructor(t,n){if(super(),(t instanceof HTMLElement||n)&&(t=h.extend({element:t},n)),h.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress"],this),this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment!=="auto"?t.pitchAlignment:this._rotationAlignment,t&&t.element)this._element=t.element,this._offset=h.pointGeometry.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=ee.create("div"),this._element.setAttribute("aria-label","Map marker");const s=ee.createNS("http://www.w3.org/2000/svg","svg"),l=41,d=27;s.setAttributeNS(null,"display","block"),s.setAttributeNS(null,"height",`${l}px`),s.setAttributeNS(null,"width",`${d}px`),s.setAttributeNS(null,"viewBox",`0 0 ${d} ${l}`);const m=ee.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"stroke","none"),m.setAttributeNS(null,"stroke-width","1"),m.setAttributeNS(null,"fill","none"),m.setAttributeNS(null,"fill-rule","evenodd");const g=ee.createNS("http://www.w3.org/2000/svg","g");g.setAttributeNS(null,"fill-rule","nonzero");const y=ee.createNS("http://www.w3.org/2000/svg","g");y.setAttributeNS(null,"transform","translate(3.0, 29.0)"),y.setAttributeNS(null,"fill","#000000");const x=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const H of x){const V=ee.createNS("http://www.w3.org/2000/svg","ellipse");V.setAttributeNS(null,"opacity","0.04"),V.setAttributeNS(null,"cx","10.5"),V.setAttributeNS(null,"cy","5.80029008"),V.setAttributeNS(null,"rx",H.rx),V.setAttributeNS(null,"ry",H.ry),y.appendChild(V)}const S=ee.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"fill",this._color);const T=ee.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"),S.appendChild(T);const M=ee.createNS("http://www.w3.org/2000/svg","g");M.setAttributeNS(null,"opacity","0.25"),M.setAttributeNS(null,"fill","#000000");const F=ee.createNS("http://www.w3.org/2000/svg","path");F.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"),M.appendChild(F);const O=ee.createNS("http://www.w3.org/2000/svg","g");O.setAttributeNS(null,"transform","translate(6.0, 7.0)"),O.setAttributeNS(null,"fill","#FFFFFF");const D=ee.createNS("http://www.w3.org/2000/svg","g");D.setAttributeNS(null,"transform","translate(8.0, 8.0)");const G=ee.createNS("http://www.w3.org/2000/svg","circle");G.setAttributeNS(null,"fill","#000000"),G.setAttributeNS(null,"opacity","0.25"),G.setAttributeNS(null,"cx","5.5"),G.setAttributeNS(null,"cy","5.5"),G.setAttributeNS(null,"r","5.4999962");const Y=ee.createNS("http://www.w3.org/2000/svg","circle");Y.setAttributeNS(null,"fill","#FFFFFF"),Y.setAttributeNS(null,"cx","5.5"),Y.setAttributeNS(null,"cy","5.5"),Y.setAttributeNS(null,"r","5.4999962"),D.appendChild(G),D.appendChild(Y),g.appendChild(y),g.appendChild(S),g.appendChild(M),g.appendChild(O),g.appendChild(D),s.appendChild(g),s.setAttributeNS(null,"height",l*this._scale+"px"),s.setAttributeNS(null,"width",d*this._scale+"px"),this._element.appendChild(s),this._offset=h.pointGeometry.convert(t&&t.offset||[0,-14])}this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",s=>{s.preventDefault()}),this._element.addEventListener("mousedown",s=>{s.preventDefault()}),ao(this._element,this._anchor,"marker"),this._popup=null}addTo(t){return this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",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("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),ee.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=h.LngLat.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const l=Math.sqrt(Math.pow(13.5,2)/2);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[l,-1*(38.1-13.5+l)],"bottom-right":[-l,-1*(38.1-13.5+l)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=t,this._lngLat&&this._popup.setLngLat(this._lngLat),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}_onKeyPress(t){const n=t.code,s=t.charCode||t.keyCode;n!=="Space"&&n!=="Enter"&&s!==32&&s!==13||this.togglePopup()}_onMapClick(t){const n=t.originalEvent.target,s=this._element;this._popup&&(n===s||s.contains(n))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?t.remove():t.addTo(this._map),this):this}_update(t){if(!this._map)return;this._map.transform.renderWorldCopies&&(this._lngLat=no(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._offset);let n="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?n=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(n=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let s="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?s="rotateX(0deg)":this._pitchAlignment==="map"&&(s=`rotateX(${this._map.getPitch()}deg)`),t&&t.type!=="moveend"||(this._pos=this._pos.round()),ee.setTransform(this._element,`${Wa[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${s} ${n}`),this._map.terrain&&!this._opacityTimeout&&(this._opacityTimeout=setTimeout(()=>{const l=this._map.unproject(this._pos),d=40075016686e-3*Math.abs(Math.cos(this._lngLat.lat*Math.PI/180))/Math.pow(2,this._map.transform.tileZoom+8);this._element.style.opacity=l.distanceTo(this._lngLat)>20*d?"0.2":"1.0",this._opacityTimeout=null},100))}getOffset(){return this._offset}setOffset(t){return this._offset=h.pointGeometry.convert(t),this._update(),this}_onMove(t){if(!this._isDragging){const n=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=n}this._isDragging&&(this._pos=t.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 h.Event("dragstart"))),this.fire(new h.Event("drag")))}_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 h.Event("dragend")),this._state="inactive"}_addDragHandler(t){this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.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))}setDraggable(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&t!=="auto"?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}const ml={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let rn,na=0,Rn=!1;const fl={maxWidth:100,unit:"metric"};function so(o,t,n){const s=n&&n.maxWidth||100,l=o._container.clientHeight/2,d=o.unproject([0,l]),m=o.unproject([s,l]),g=d.distanceTo(m);if(n&&n.unit==="imperial"){const y=3.2808*g;y>5280?aa(t,s,y/5280,o._getUIString("ScaleControl.Miles")):aa(t,s,y,o._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?aa(t,s,g/1852,o._getUIString("ScaleControl.NauticalMiles")):g>=1e3?aa(t,s,g/1e3,o._getUIString("ScaleControl.Kilometers")):aa(t,s,g,o._getUIString("ScaleControl.Meters"))}function aa(o,t,n,s){const l=function(d){const m=Math.pow(10,`${Math.floor(d)}`.length-1);let g=d/m;return g=g>=10?10:g>=5?5:g>=3?3:g>=2?2:g>=1?1:function(y){const x=Math.pow(10,Math.ceil(-Math.log(y)/Math.LN10));return Math.round(y*x)/x}(g),m*g}(n);o.style.width=t*(l/n)+"px",o.innerHTML=`${l}&nbsp;${s}`}const uc={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},dc=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function gl(o){if(o){if(typeof o=="number"){const t=Math.round(Math.sqrt(.5*Math.pow(o,2)));return{center:new h.pointGeometry(0,0),top:new h.pointGeometry(0,o),"top-left":new h.pointGeometry(t,t),"top-right":new h.pointGeometry(-t,t),bottom:new h.pointGeometry(0,-o),"bottom-left":new h.pointGeometry(t,-t),"bottom-right":new h.pointGeometry(-t,-t),left:new h.pointGeometry(o,0),right:new h.pointGeometry(-o,0)}}if(o instanceof h.pointGeometry||Array.isArray(o)){const t=h.pointGeometry.convert(o);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:h.pointGeometry.convert(o.center||[0,0]),top:h.pointGeometry.convert(o.top||[0,0]),"top-left":h.pointGeometry.convert(o["top-left"]||[0,0]),"top-right":h.pointGeometry.convert(o["top-right"]||[0,0]),bottom:h.pointGeometry.convert(o.bottom||[0,0]),"bottom-left":h.pointGeometry.convert(o["bottom-left"]||[0,0]),"bottom-right":h.pointGeometry.convert(o["bottom-right"]||[0,0]),left:h.pointGeometry.convert(o.left||[0,0]),right:h.pointGeometry.convert(o.right||[0,0])}}return gl(new h.pointGeometry(0,0))}const pc=Ye,Dr={supported:ve,setRTLTextPlugin:h.setRTLTextPlugin,getRTLTextPluginStatus:h.getRTLTextPluginStatus,Map:class extends Hs{constructor(o){var t;if(h.PerformanceUtils.mark(h.PerformanceMarkers.create),(o=h.extend({},io,o)).minZoom!=null&&o.maxZoom!=null&&o.minZoom>o.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(o.minPitch!=null&&o.maxPitch!=null&&o.minPitch>o.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(o.minPitch!=null&&o.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(o.maxPitch!=null&&o.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new en(o.minZoom,o.maxZoom,o.minPitch,o.maxPitch,o.renderWorldCopies),{bearingSnap:o.bearingSnap}),this._interactive=o.interactive,this._cooperativeGestures=o.cooperativeGestures,this._maxTileCacheSize=o.maxTileCacheSize,this._failIfMajorPerformanceCaveat=o.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=o.preserveDrawingBuffer,this._antialias=o.antialias,this._trackResize=o.trackResize,this._bearingSnap=o.bearingSnap,this._refreshExpiredTiles=o.refreshExpiredTiles,this._fadeDuration=o.fadeDuration,this._crossSourceCollisions=o.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=o.collectResourceTiming,this._renderTaskQueue=new Ks,this._controls=[],this._mapId=h.uniqueId(),this._locale=h.extend({},Ys,o.locale),this._clickTolerance=o.clickTolerance,this._pixelRatio=(t=o.pixelRatio)!==null&&t!==void 0?t:devicePixelRatio,this._imageQueueHandle=Qt.addThrottleControl(()=>this.isMoving()),this._requestManager=new us(o.transformRequest),typeof o.container=="string"){if(this._container=document.getElementById(o.container),!this._container)throw new Error(`Container '${o.container}' not found.`)}else{if(!(o.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=o.container}o.maxBounds&&this.setMaxBounds(o.maxBounds),h.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),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)}),typeof window<"u"&&(addEventListener("online",this._onWindowOnline,!1),addEventListener("resize",this._onWindowResize,!1),addEventListener("orientationchange",this._onWindowResize,!1)),this.handlers=new ra(this,o),this._cooperativeGestures&&this._setupCooperativeGestures(),this._hash=o.hash&&new ol(typeof o.hash=="string"&&o.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:o.center,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch}),o.bounds&&(this.resize(),this.fitBounds(o.bounds,h.extend({},o.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=o.localIdeographFontFamily,o.style&&this.setStyle(o.style,{localIdeographFontFamily:o.localIdeographFontFamily}),o.attributionControl&&this.addControl(new Ga({customAttribution:o.customAttribution})),o.maplibreLogo&&this.addControl(new ja,o.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",n=>{this._update(n.dataType==="style"),this.fire(new h.Event(`${n.dataType}data`,n))}),this.on("dataloading",n=>{this.fire(new h.Event(`${n.dataType}dataloading`,n))}),this.on("dataabort",n=>{this.fire(new h.Event("sourcedataabort",n))})}_getMapId(){return this._mapId}addControl(o,t){if(t===void 0&&(t=o.getDefaultPosition?o.getDefaultPosition():"top-right"),!o||!o.onAdd)return this.fire(new h.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=o.onAdd(this);this._controls.push(o);const s=this._controlPositions[t];return t.indexOf("bottom")!==-1?s.insertBefore(n,s.firstChild):s.appendChild(n),this}removeControl(o){if(!o||!o.onRemove)return this.fire(new h.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(o);return t>-1&&this._controls.splice(t,1),o.onRemove(this),this}hasControl(o){return this._controls.indexOf(o)>-1}calculateCameraOptionsFromTo(o,t,n,s){return s==null&&this.terrain&&(s=this.transform.getElevation(n,this.terrain)),super.calculateCameraOptionsFromTo(o,t,n,s)}resize(o){const t=this._containerDimensions(),n=t[0],s=t[1];this._resizeCanvas(n,s,this.getPixelRatio()),this.transform.resize(n,s),this.painter.resize(n,s,this.getPixelRatio());const l=!this._moving;return l&&(this.stop(),this.fire(new h.Event("movestart",o)).fire(new h.Event("move",o))),this.fire(new h.Event("resize",o)),l&&this.fire(new h.Event("moveend",o)),this}getPixelRatio(){return this._pixelRatio}setPixelRatio(o){const[t,n]=this._containerDimensions();this._pixelRatio=o,this._resizeCanvas(t,n,o),this.painter.resize(t,n,o)}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(o){return this.transform.setMaxBounds(h.LngLatBounds.convert(o)),this._update()}setMinZoom(o){if((o=o??-2)>=-2&&o<=this.transform.maxZoom)return this.transform.minZoom=o,this._update(),this.getZoom()<o&&this.setZoom(o),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(o){if((o=o??22)>=this.transform.minZoom)return this.transform.maxZoom=o,this._update(),this.getZoom()>o&&this.setZoom(o),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(o){if((o=o??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(o>=0&&o<=this.transform.maxPitch)return this.transform.minPitch=o,this._update(),this.getPitch()<o&&this.setPitch(o),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(o){if((o=o??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(o>=this.transform.minPitch)return this.transform.maxPitch=o,this._update(),this.getPitch()>o&&this.setPitch(o),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(o){return this.transform.renderWorldCopies=o,this._update()}project(o){return this.transform.locationPoint(h.LngLat.convert(o),this.style&&this.terrain)}unproject(o){return this.transform.pointLocation(h.pointGeometry.convert(o),this.terrain)}isMoving(){var o;return this._moving||((o=this.handlers)===null||o===void 0?void 0:o.isMoving())}isZooming(){var o;return this._zooming||((o=this.handlers)===null||o===void 0?void 0:o.isZooming())}isRotating(){var o;return this._rotating||((o=this.handlers)===null||o===void 0?void 0:o.isRotating())}_createDelegatedListener(o,t,n){if(o==="mouseenter"||o==="mouseover"){let s=!1;return{layer:t,listener:n,delegates:{mousemove:d=>{const m=this.getLayer(t)?this.queryRenderedFeatures(d.point,{layers:[t]}):[];m.length?s||(s=!0,n.call(this,new Gi(o,this,d.originalEvent,{features:m}))):s=!1},mouseout:()=>{s=!1}}}}if(o==="mouseleave"||o==="mouseout"){let s=!1;return{layer:t,listener:n,delegates:{mousemove:m=>{(this.getLayer(t)?this.queryRenderedFeatures(m.point,{layers:[t]}):[]).length?s=!0:s&&(s=!1,n.call(this,new Gi(o,this,m.originalEvent)))},mouseout:m=>{s&&(s=!1,n.call(this,new Gi(o,this,m.originalEvent)))}}}}{const s=l=>{const d=this.getLayer(t)?this.queryRenderedFeatures(l.point,{layers:[t]}):[];d.length&&(l.features=d,n.call(this,l),delete l.features)};return{layer:t,listener:n,delegates:{[o]:s}}}}on(o,t,n){if(n===void 0)return super.on(o,t);const s=this._createDelegatedListener(o,t,n);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[o]=this._delegatedListeners[o]||[],this._delegatedListeners[o].push(s);for(const l in s.delegates)this.on(l,s.delegates[l]);return this}once(o,t,n){if(n===void 0)return super.once(o,t);const s=this._createDelegatedListener(o,t,n);for(const l in s.delegates)this.once(l,s.delegates[l]);return this}off(o,t,n){return n===void 0?super.off(o,t):(this._delegatedListeners&&this._delegatedListeners[o]&&(s=>{const l=this._delegatedListeners[o];for(let d=0;d<l.length;d++){const m=l[d];if(m.layer===t&&m.listener===n){for(const g in m.delegates)this.off(g,m.delegates[g]);return l.splice(d,1),this}}})(),this)}queryRenderedFeatures(o,t){if(!this.style)return[];let n;const s=o instanceof h.pointGeometry||Array.isArray(o),l=s?o:[[0,0],[this.transform.width,this.transform.height]];if(t=t||(s?{}:o)||{},l instanceof h.pointGeometry||typeof l[0]=="number")n=[h.pointGeometry.convert(l)];else{const d=h.pointGeometry.convert(l[0]),m=h.pointGeometry.convert(l[1]);n=[d,new h.pointGeometry(m.x,d.y),m,new h.pointGeometry(d.x,m.y),d]}return this.style.queryRenderedFeatures(n,t,this.transform)}querySourceFeatures(o,t){return this.style.querySourceFeatures(o,t)}setStyle(o,t){return(t=h.extend({},{localIdeographFontFamily:this._localIdeographFontFamily},t)).diff!==!1&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&o?(this._diffStyle(o,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(o,t))}setTransformRequest(o){return this._requestManager.setTransformRequest(o),this}_getUIString(o){const t=this._locale[o];if(t==null)throw new Error(`Missing UI string '${o}'`);return t}_updateStyle(o,t){if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(o,t));const n=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!o)),o?(this.style=new Ni(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof o=="string"?this.style.loadURL(o,t,n):this.style.loadJSON(o,t,n),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Ni(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(o,t){if(typeof o=="string"){const n=this._requestManager.transformRequest(o,dt.Style);h.getJSON(n,(s,l)=>{s?this.fire(new h.ErrorEvent(s)):l&&this._updateDiff(l,t)})}else typeof o=="object"&&this._updateDiff(o,t)}_updateDiff(o,t){try{this.style.setState(o,t)&&this._update(!0)}catch(n){h.warnOnce(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(o,t)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():h.warnOnce("There is no style added to the map.")}addSource(o,t){return this._lazyInitEmptyStyle(),this.style.addSource(o,t),this._update(!0)}isSourceLoaded(o){const t=this.style&&this.style.sourceCaches[o];if(t!==void 0)return t.loaded();this.fire(new h.ErrorEvent(new Error(`There is no source with ID '${o}'`)))}setTerrain(o){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),o){const t=this.style.sourceCaches[o.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${o.source}`);this.terrain=new qa(this.painter,t,o),this.painter.renderToTexture=new Za(this.painter,this.terrain),this.transform.updateElevation(this.terrain),this._terrainDataCallback=n=>{n.dataType==="style"?this.terrain.sourceCache.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId===o.source&&this.transform.updateElevation(this.terrain),this.terrain.sourceCache.freeRtt(n.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.updateElevation(this.terrain);return this.fire(new h.Event("terrain",{terrain:o})),this}getTerrain(){return this.terrain&&this.terrain.options}areTilesLoaded(){const o=this.style&&this.style.sourceCaches;for(const t in o){const n=o[t]._tiles;for(const s in n){const l=n[s];if(l.state!=="loaded"&&l.state!=="errored")return!1}}return!0}addSourceType(o,t,n){return this._lazyInitEmptyStyle(),this.style.addSourceType(o,t,n)}removeSource(o){return this.style.removeSource(o),this._update(!0)}getSource(o){return this.style.getSource(o)}addImage(o,t,{pixelRatio:n=1,sdf:s=!1,stretchX:l,stretchY:d,content:m}={}){if(this._lazyInitEmptyStyle(),t instanceof HTMLImageElement||h.isImageBitmap(t)){const{width:g,height:y,data:x}=h.exported.getImageData(t);this.style.addImage(o,{data:new h.RGBAImage({width:g,height:y},x),pixelRatio:n,stretchX:l,stretchY:d,content:m,sdf:s,version:0})}else{if(t.width===void 0||t.height===void 0)return this.fire(new h.ErrorEvent(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:g,height:y,data:x}=t,S=t;this.style.addImage(o,{data:new h.RGBAImage({width:g,height:y},new Uint8Array(x)),pixelRatio:n,stretchX:l,stretchY:d,content:m,sdf:s,version:0,userImage:S}),S.onAdd&&S.onAdd(this,o)}}}updateImage(o,t){const n=this.style.getImage(o);if(!n)return this.fire(new h.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const s=t instanceof HTMLImageElement||h.isImageBitmap(t)?h.exported.getImageData(t):t,{width:l,height:d,data:m}=s;if(l===void 0||d===void 0)return this.fire(new h.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(l!==n.data.width||d!==n.data.height)return this.fire(new h.ErrorEvent(new Error("The width and height of the updated image must be that same as the previous version of the image")));const g=!(t instanceof HTMLImageElement||h.isImageBitmap(t));n.data.replace(m,g),this.style.updateImage(o,n)}hasImage(o){return o?!!this.style.getImage(o):(this.fire(new h.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(o){this.style.removeImage(o)}loadImage(o,t){Qt.getImage(this._requestManager.transformRequest(o,dt.Image),t)}listImages(){return this.style.listImages()}addLayer(o,t){return this._lazyInitEmptyStyle(),this.style.addLayer(o,t),this._update(!0)}moveLayer(o,t){return this.style.moveLayer(o,t),this._update(!0)}removeLayer(o){return this.style.removeLayer(o),this._update(!0)}getLayer(o){return this.style.getLayer(o)}setLayerZoomRange(o,t,n){return this.style.setLayerZoomRange(o,t,n),this._update(!0)}setFilter(o,t,n={}){return this.style.setFilter(o,t,n),this._update(!0)}getFilter(o){return this.style.getFilter(o)}setPaintProperty(o,t,n,s={}){return this.style.setPaintProperty(o,t,n,s),this._update(!0)}getPaintProperty(o,t){return this.style.getPaintProperty(o,t)}setLayoutProperty(o,t,n,s={}){return this.style.setLayoutProperty(o,t,n,s),this._update(!0)}getLayoutProperty(o,t){return this.style.getLayoutProperty(o,t)}setGlyphs(o,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(o,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(o,t,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(o,t,n,s=>{s||this._update(!0)}),this}removeSprite(o){return this._lazyInitEmptyStyle(),this.style.removeSprite(o),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(o,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(o,t,n=>{n||this._update(!0)}),this}setLight(o,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(o,t),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(o,t){return this.style.setFeatureState(o,t),this._update()}removeFeatureState(o,t){return this.style.removeFeatureState(o,t),this._update()}getFeatureState(o){return this.style.getFeatureState(o)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let o=0,t=0;return this._container&&(o=this._container.clientWidth||400,t=this._container.clientHeight||300),[o,t]}_setupContainer(){const o=this._container;o.classList.add("maplibregl-map");const t=this._canvasContainer=ee.create("div","maplibregl-canvas-container",o);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=ee.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region");const n=this._containerDimensions();this._resizeCanvas(n[0],n[1],this.getPixelRatio());const s=this._controlContainer=ee.create("div","maplibregl-control-container",o),l=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(d=>{l[d]=ee.create("div",`maplibregl-ctrl-${d} `,s)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_setupCooperativeGestures(){const o=this._container;this._metaPress=!1,this._cooperativeGesturesScreen=ee.create("div","maplibregl-cooperative-gesture-screen",o);let t="Control",n=typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.windowsHelpText?this._cooperativeGestures.windowsHelpText:"Use Ctrl + scroll to zoom the map";navigator.platform.indexOf("Mac")===0&&(n=typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.macHelpText?this._cooperativeGestures.macHelpText:"Use \u2318 + scroll to zoom the map",t="Meta"),this._cooperativeGesturesScreen.innerHTML=`
577
577
  <div class="maplibregl-desktop-message">${n}</div>
578
578
  <div class="maplibregl-mobile-message">${typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.mobileHelpText?this._cooperativeGestures.mobileHelpText:"Use two fingers to move the map"}</div>
579
- `,document.addEventListener("keydown",s=>{s.key===t&&(this._metaPress=!0)}),document.addEventListener("keyup",s=>{s.key===t&&(this._metaPress=!1)}),this._canvasContainer.addEventListener("wheel",s=>{this._onCooperativeGesture(s,this._metaPress,1)},!1),this._canvasContainer.classList.remove("maplibregl-touch-drag-pan")}_resizeCanvas(o,t,n){this._canvas.width=n*o,this._canvas.height=n*t,this._canvas.style.width=`${o}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const o=h.extend({},ve.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1});let t=null;this._canvas.addEventListener("webglcontextcreationerror",s=>{t={requestedAttributes:o},s&&(t.statusMessage=s.statusMessage,t.type=s.type)},{once:!0});const n=this._canvas.getContext("webgl",o)||this._canvas.getContext("experimental-webgl",o);if(!n){const s="Failed to initialize WebGL";throw t?(t.message=s,new Error(JSON.stringify(t))):new Error(s)}this.painter=new zr(n,this.transform),Be.testSupport(n)}_contextLost(o){o.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new h.Event("webglcontextlost",{originalEvent:o}))}_contextRestored(o){this._setupPainter(),this.resize(),this._update(),this.fire(new h.Event("webglcontextrestored",{originalEvent:o}))}_onMapScroll(o){if(o.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}_onCooperativeGesture(o,t,n){return!t&&n<2&&(this._cooperativeGesturesScreen.classList.add("maplibregl-show"),setTimeout(()=>{this._cooperativeGesturesScreen.classList.remove("maplibregl-show")},100)),!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(o){return this.style?(this._styleDirty=this._styleDirty||o,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(o){return this._update(),this._renderTaskQueue.add(o)}_cancelRenderFrame(o){this._renderTaskQueue.remove(o)}_render(o){let t,n=0;const s=this.painter.context.extTimerQuery;if(this.listens("gpu-timing-frame")&&(t=s.createQueryEXT(),s.beginQueryEXT(s.TIME_ELAPSED_EXT,t),n=h.exported.now()),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(o),this._removed)return;let l=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const m=this.transform.zoom,g=h.exported.now();this.style.zoomHistory.update(m,g);const y=new h.EvaluationParameters(m,{now:g,fadeDuration:this._fadeDuration,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),x=y.crossFadingFactor();x===1&&x===this._crossFadingFactor||(l=!0,this._crossFadingFactor=x),this.style.update(y)}if(this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain&&this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.updateElevation(this.terrain),this._imageQueueDirty=Qt.processQueue()>0,this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,this._fadeDuration,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:this._fadeDuration,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer")}),this.fire(new h.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,h.PerformanceUtils.mark(h.PerformanceMarkers.load),this.fire(new h.Event("load"))),this.style&&(this.style.hasTransitions()||l)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const m=h.exported.now()-n;s.endQueryEXT(s.TIME_ELAPSED_EXT,t),setTimeout(()=>{const g=s.getQueryObjectEXT(t,s.QUERY_RESULT_EXT)/1e6;s.deleteQueryEXT(t),this.fire(new h.Event("gpu-timing-frame",{cpuTime:m,gpuTime:g}))},50)}if(this.listens("gpu-timing-layer")){const m=this.painter.collectGpuTimers();setTimeout(()=>{const g=this.painter.queryGpuTimers(m);this.fire(new h.Event("gpu-timing-layer",{layerTimes:g}))},50)}const d=this._sourcesDirty||this._styleDirty||this._placementDirty||this._imageQueueDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new h.Event("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,h.PerformanceUtils.mark(h.PerformanceMarkers.fullLoad)),this}redraw(){return this.style&&(this._frame&&(this._frame.cancel(),this._frame=null),this._render(0)),this}remove(){this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&(removeEventListener("resize",this._onWindowResize,!1),removeEventListener("orientationchange",this._onWindowResize,!1),removeEventListener("online",this._onWindowOnline,!1)),Qt.removeThrottleControl(this._imageQueueHandle);const o=this.painter.context.gl.getExtension("WEBGL_lose_context");o&&o.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),ee.remove(this._canvasContainer),ee.remove(this._controlContainer),this._cooperativeGestures&&ee.remove(this._cooperativeGesturesScreen),this._container.classList.remove("maplibregl-map"),h.PerformanceUtils.clearMetrics(),this._removed=!0,this.fire(new h.Event("remove"))}triggerRepaint(){this.style&&!this._frame&&(this._frame=h.exported.frame(o=>{h.PerformanceUtils.frame(o),this._frame=null,this._render(o)}))}_onWindowOnline(){this._update()}_onWindowResize(o){this._trackResize&&this.resize({originalEvent:o})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(o){this._showTileBoundaries!==o&&(this._showTileBoundaries=o,this._update())}get showPadding(){return!!this._showPadding}set showPadding(o){this._showPadding!==o&&(this._showPadding=o,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(o){this._showCollisionBoxes!==o&&(this._showCollisionBoxes=o,o?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(o){this._showOverdrawInspector!==o&&(this._showOverdrawInspector=o,this._update())}get repaint(){return!!this._repaint}set repaint(o){this._repaint!==o&&(this._repaint=o,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(o){this._vertices=o,this._update()}get version(){return to}getCameraTargetElevation(){return this.transform.elevation}},NavigationControl:class{constructor(o){this.options=h.extend({},ro,o),this._container=ee.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(h.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",t=>this._map.zoomIn({},{originalEvent:t})),ee.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",t=>this._map.zoomOut({},{originalEvent:t})),ee.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(h.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("maplibregl-ctrl-compass",t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})}),this._compassIcon=ee.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const o=this._map.getZoom(),t=o===this._map.getMaxZoom(),n=o===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",n.toString())}_rotateCompassArrow(){const o=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=o}onAdd(o){return this._map=o,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new pl(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){ee.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(o,t){const n=ee.create("button",o,this._container);return n.type="button",n.addEventListener("click",t),n}_setButtonTitle(o,t){const n=this._map._getUIString(`NavigationControl.${t}`);o.title=n,o.setAttribute("aria-label",n)}},GeolocateControl:class extends h.Evented{constructor(o){super(),this.options=h.extend({},ml,o),h.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker"],this)}onAdd(o){var t;return this._map=o,this._container=ee.create("div","maplibregl-ctrl maplibregl-ctrl-group"),t=this._setupUI,rn!==void 0?t(rn):window.navigator.permissions!==void 0?window.navigator.permissions.query({name:"geolocation"}).then(n=>{rn=n.state!=="denied",t(rn)}):(rn=!!window.navigator.geolocation,t(rn)),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(),ee.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,na=0,Rn=!1}_isOutOfMapMaxBounds(o){const t=this._map.getMaxBounds(),n=o.coords;return t&&(n.longitude<t.getWest()||n.longitude>t.getEast()||n.latitude<t.getSouth()||n.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_onSuccess(o){if(this._map){if(this._isOutOfMapMaxBounds(o))return this._setErrorState(),this.fire(new h.Event("outofmaxbounds",o)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=o,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(o),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(o),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new h.Event("geolocate",o)),this._finish()}}_updateCamera(o){const t=new h.LngLat(o.coords.longitude,o.coords.latitude),n=o.coords.accuracy,s=this._map.getBearing(),l=h.extend({bearing:s},this.options.fitBoundsOptions);this._map.fitBounds(t.toBounds(n),l,{geolocateSource:!0})}_updateMarker(o){if(o){const t=new h.LngLat(o.coords.longitude,o.coords.latitude);this._accuracyCircleMarker.setLngLat(t).addTo(this._map),this._userLocationDotMarker.setLngLat(t).addTo(this._map),this._accuracy=o.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const o=this._map._container.clientHeight/2,t=this._map.unproject([0,o]),n=this._map.unproject([1,o]),s=t.distanceTo(n),l=Math.ceil(2*this._accuracy/s);this._circleElement.style.width=`${l}px`,this._circleElement.style.height=`${l}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_onError(o){if(this._map){if(this.options.trackUserLocation)if(o.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 t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(o.code===3&&Rn)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new h.Event("error",o)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(o){if(this._container.addEventListener("contextmenu",t=>t.preventDefault()),this._geolocateButton=ee.create("button","maplibregl-ctrl-geolocate",this._container),ee.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",o===!1){h.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=ee.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ha(this._dotElement),this._circleElement=ee.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ha({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",t=>{t.geolocateSource||this._watchState!=="ACTIVE_LOCK"||t.originalEvent&&t.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 h.Event("trackuserlocationend")))})}trigger(){if(!this._setup)return h.warnOnce("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 h.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":na--,Rn=!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 h.Event("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 h.Event("trackuserlocationstart"));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 o;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),na++,na>1?(o={maximumAge:6e5,timeout:0},Rn=!0):(o=this.options.positionOptions,Rn=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,o)}}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)}},AttributionControl:Ga,LogoControl:ja,ScaleControl:class{constructor(o){this.options=h.extend({},fl,o),h.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){so(this._map,this._container,this.options)}onAdd(o){return this._map=o,this._container=ee.create("div","maplibregl-ctrl maplibregl-ctrl-scale",o.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){ee.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}setUnit(o){this.options.unit=o,so(this._map,this._container,this.options)}},FullscreenControl:class extends h.Evented{constructor(o={}){super(),this._onFullscreenChange=()=>{(window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement)===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,o&&o.container&&(o.container instanceof HTMLElement?this._container=o.container:h.warnOnce("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(o){return this._map=o,this._container||(this._container=this._map.getContainer()),this._controlContainer=ee.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){ee.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const o=this._fullscreenButton=ee.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);ee.create("span","maplibregl-ctrl-icon",o).setAttribute("aria-hidden","true"),o.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const o=this._getTitle();this._fullscreenButton.setAttribute("aria-label",o),this._fullscreenButton.title=o}_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.fire(new h.Event(this._fullscreen?"fullscreenstart":"fullscreenend"))}_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()}},TerrainControl:class{constructor(o){this.options=o,h.bindAll(["_toggleTerrain","_updateTerrainIcon"],this)}onAdd(o){return this._map=o,this._container=ee.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=ee.create("button","maplibregl-ctrl-terrain",this._container),ee.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(){ee.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}_toggleTerrain(){this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()}_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.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))}},Popup:class extends h.Evented{constructor(o){super(),this.options=h.extend(Object.create(uc),o),h.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag"],this)}addTo(o){return this._map&&this.remove(),this._map=o,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 h.Event("open")),this}isOpen(){return!!this._map}remove(){return this._content&&ee.remove(this._content),this._container&&(ee.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),delete this._map),this.fire(new h.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(o){return this._lngLat=h.LngLat.convert(o),this._pos=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._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(o){return this.setDOMContent(document.createTextNode(o))}setHTML(o){const t=document.createDocumentFragment(),n=document.createElement("body");let s;for(n.innerHTML=o;s=n.firstChild,s;)t.appendChild(s);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(o){return this.options.maxWidth=o,this._update(),this}setDOMContent(o){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=ee.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(o),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(o){this._container&&this._container.classList.add(o)}removeClassName(o){this._container&&this._container.classList.remove(o)}setOffset(o){return this.options.offset=o,this._update(),this}toggleClassName(o){if(this._container)return this._container.classList.toggle(o)}_createCloseButton(){this.options.closeButton&&(this._closeButton=ee.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_onMouseUp(o){this._update(o.point)}_onMouseMove(o){this._update(o.point)}_onDrag(o){this._update(o.point)}_update(o){if(!this._map||!this._lngLat&&!this._trackPointer||!this._content||(this._container||(this._container=ee.create("div","maplibregl-popup",this._map.getContainer()),this._tip=ee.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className&&this.options.className.split(" ").forEach(d=>this._container.classList.add(d)),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")),this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=no(this._lngLat,this._pos,this._map.transform)),this._trackPointer&&!o))return;const t=this._pos=this._trackPointer&&o?o:this._map.project(this._lngLat);let n=this.options.anchor;const s=gl(this.options.offset);if(!n){const d=this._container.offsetWidth,m=this._container.offsetHeight;let g;g=t.y+s.bottom.y<m?["top"]:t.y>this._map.transform.height-m?["bottom"]:[],t.x<d/2?g.push("left"):t.x>this._map.transform.width-d/2&&g.push("right"),n=g.length===0?"bottom":g.join("-")}const l=t.add(s[n]).round();ee.setTransform(this._container,`${Wa[n]} translate(${l.x}px,${l.y}px)`),ao(this._container,n,"popup")}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const o=this._container.querySelector(dc);o&&o.focus()}_onClose(){this.remove()}},Marker:Ha,Style:Ni,LngLat:h.LngLat,LngLatBounds:h.LngLatBounds,Point:h.pointGeometry,MercatorCoordinate:h.MercatorCoordinate,Evented:h.Evented,AJAXError:h.AJAXError,config:h.config,CanvasSource:pi,GeoJSONSource:Gn,ImageSource:bt,RasterDEMTileSource:Se,RasterTileSource:Ir,VectorTileSource:Gr,VideoSource:Wi,prewarm:function(){gn().acquire(qr)},clearPrewarmedResources:function(){const o=yt;o&&(o.isPreloaded()&&o.numActive()===1?(o.release(qr),yt=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()"))},get version(){return pc},get workerCount(){return Mi.workerCount},set workerCount(o){Mi.workerCount=o},get maxParallelImageRequests(){return h.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(o){h.config.MAX_PARALLEL_IMAGE_REQUESTS=o},workerUrl:"",addProtocol(o,t){h.config.REGISTERED_PROTOCOLS[o]=t},removeProtocol(o){delete h.config.REGISTERED_PROTOCOLS[o]}};return Ws.extend(Dr,{isSafari:h.isSafari,getPerformanceMetrics:h.PerformanceUtils.getPerformanceMetrics}),Dr});var he=ie;return he})})(Jc);var dd=Jc.exports,nt=Yc(dd);const Qc="3.7.5",pd=Qc,md=typeof atob=="function",fd=typeof btoa=="function",ca=typeof Buffer=="function",eh=typeof TextDecoder=="function"?new TextDecoder:void 0,th=typeof TextEncoder=="function"?new TextEncoder:void 0,gd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",ls=Array.prototype.slice.call(gd),Io=(A=>{let b={};return A.forEach((z,W)=>b[z]=W),b})(ls),_d=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,hi=String.fromCharCode.bind(String),ih=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):A=>new Uint8Array(Array.prototype.slice.call(A,0)),rh=A=>A.replace(/=/g,"").replace(/[+\/]/g,b=>b=="+"?"-":"_"),nh=A=>A.replace(/[^A-Za-z0-9\+\/]/g,""),ah=A=>{let b,z,W,ie,de="";const he=A.length%3;for(let h=0;h<A.length;){if((z=A.charCodeAt(h++))>255||(W=A.charCodeAt(h++))>255||(ie=A.charCodeAt(h++))>255)throw new TypeError("invalid character found");b=z<<16|W<<8|ie,de+=ls[b>>18&63]+ls[b>>12&63]+ls[b>>6&63]+ls[b&63]}return he?de.slice(0,he-3)+"===".substring(he):de},Rl=fd?A=>btoa(A):ca?A=>Buffer.from(A,"binary").toString("base64"):ah,Bl=ca?A=>Buffer.from(A).toString("base64"):A=>{let z=[];for(let W=0,ie=A.length;W<ie;W+=4096)z.push(hi.apply(null,A.subarray(W,W+4096)));return Rl(z.join(""))},Ao=(A,b=!1)=>b?rh(Bl(A)):Bl(A),yd=A=>{if(A.length<2){var b=A.charCodeAt(0);return b<128?A:b<2048?hi(192|b>>>6)+hi(128|b&63):hi(224|b>>>12&15)+hi(128|b>>>6&63)+hi(128|b&63)}else{var b=65536+(A.charCodeAt(0)-55296)*1024+(A.charCodeAt(1)-56320);return hi(240|b>>>18&7)+hi(128|b>>>12&63)+hi(128|b>>>6&63)+hi(128|b&63)}},xd=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,sh=A=>A.replace(xd,yd),oh=ca?A=>Buffer.from(A,"utf8").toString("base64"):th?A=>Bl(th.encode(A)):A=>Rl(sh(A)),ha=(A,b=!1)=>b?rh(oh(A)):oh(A),lh=A=>ha(A,!0),vd=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,bd=A=>{switch(A.length){case 4:var b=(7&A.charCodeAt(0))<<18|(63&A.charCodeAt(1))<<12|(63&A.charCodeAt(2))<<6|63&A.charCodeAt(3),z=b-65536;return hi((z>>>10)+55296)+hi((z&1023)+56320);case 3:return hi((15&A.charCodeAt(0))<<12|(63&A.charCodeAt(1))<<6|63&A.charCodeAt(2));default:return hi((31&A.charCodeAt(0))<<6|63&A.charCodeAt(1))}},ch=A=>A.replace(vd,bd),hh=A=>{if(A=A.replace(/\s+/g,""),!_d.test(A))throw new TypeError("malformed base64.");A+="==".slice(2-(A.length&3));let b,z="",W,ie;for(let de=0;de<A.length;)b=Io[A.charAt(de++)]<<18|Io[A.charAt(de++)]<<12|(W=Io[A.charAt(de++)])<<6|(ie=Io[A.charAt(de++)]),z+=W===64?hi(b>>16&255):ie===64?hi(b>>16&255,b>>8&255):hi(b>>16&255,b>>8&255,b&255);return z},Fl=md?A=>atob(nh(A)):ca?A=>Buffer.from(A,"base64").toString("binary"):hh,uh=ca?A=>ih(Buffer.from(A,"base64")):A=>ih(Fl(A).split("").map(b=>b.charCodeAt(0))),dh=A=>uh(ph(A)),wd=ca?A=>Buffer.from(A,"base64").toString("utf8"):eh?A=>eh.decode(uh(A)):A=>ch(Fl(A)),ph=A=>nh(A.replace(/[-_]/g,b=>b=="-"?"+":"/")),Ol=A=>wd(ph(A)),Td=A=>{if(typeof A!="string")return!1;const b=A.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(b)||!/[^\s0-9a-zA-Z\-_]/.test(b)},mh=A=>({value:A,enumerable:!1,writable:!0,configurable:!0}),fh=function(){const A=(b,z)=>Object.defineProperty(String.prototype,b,mh(z));A("fromBase64",function(){return Ol(this)}),A("toBase64",function(b){return ha(this,b)}),A("toBase64URI",function(){return ha(this,!0)}),A("toBase64URL",function(){return ha(this,!0)}),A("toUint8Array",function(){return dh(this)})},gh=function(){const A=(b,z)=>Object.defineProperty(Uint8Array.prototype,b,mh(z));A("toBase64",function(b){return Ao(this,b)}),A("toBase64URI",function(){return Ao(this,!0)}),A("toBase64URL",function(){return Ao(this,!0)})},Sd={version:Qc,VERSION:pd,atob:Fl,atobPolyfill:hh,btoa:Rl,btoaPolyfill:ah,fromBase64:Ol,toBase64:ha,encode:ha,encodeURI:lh,encodeURL:lh,utob:sh,btou:ch,decode:Ol,isValid:Td,fromUint8Array:Ao,toUint8Array:dh,extendString:fh,extendUint8Array:gh,extendBuiltins:()=>{fh(),gh()}};let Co;const Ed=new Uint8Array(16);function Id(){if(!Co&&(Co=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Co))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Co(Ed)}const ui=[];for(let A=0;A<256;++A)ui.push((A+256).toString(16).slice(1));function Ad(A,b=0){return(ui[A[b+0]]+ui[A[b+1]]+ui[A[b+2]]+ui[A[b+3]]+"-"+ui[A[b+4]]+ui[A[b+5]]+"-"+ui[A[b+6]]+ui[A[b+7]]+"-"+ui[A[b+8]]+ui[A[b+9]]+"-"+ui[A[b+10]]+ui[A[b+11]]+ui[A[b+12]]+ui[A[b+13]]+ui[A[b+14]]+ui[A[b+15]]).toLowerCase()}var _h={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Cd(A,b,z){if(_h.randomUUID&&!b&&!A)return _h.randomUUID();A=A||{};const W=A.random||(A.rng||Id)();if(W[6]=W[6]&15|64,W[8]=W[8]&63|128,b){z=z||0;for(let ie=0;ie<16;++ie)b[z+ie]=W[ie];return b}return Ad(W)}var Ul={exports:{}},ua=typeof Reflect=="object"?Reflect:null,yh=ua&&typeof ua.apply=="function"?ua.apply:function(b,z,W){return Function.prototype.apply.call(b,z,W)},Mo;ua&&typeof ua.ownKeys=="function"?Mo=ua.ownKeys:Object.getOwnPropertySymbols?Mo=function(b){return Object.getOwnPropertyNames(b).concat(Object.getOwnPropertySymbols(b))}:Mo=function(b){return Object.getOwnPropertyNames(b)};function Md(A){console&&console.warn&&console.warn(A)}var xh=Number.isNaN||function(b){return b!==b};function At(){At.init.call(this)}Ul.exports=At,Ul.exports.once=Ld,At.EventEmitter=At,At.prototype._events=void 0,At.prototype._eventsCount=0,At.prototype._maxListeners=void 0;var vh=10;function Po(A){if(typeof A!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof A)}Object.defineProperty(At,"defaultMaxListeners",{enumerable:!0,get:function(){return vh},set:function(A){if(typeof A!="number"||A<0||xh(A))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+A+".");vh=A}}),At.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},At.prototype.setMaxListeners=function(b){if(typeof b!="number"||b<0||xh(b))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+b+".");return this._maxListeners=b,this};function bh(A){return A._maxListeners===void 0?At.defaultMaxListeners:A._maxListeners}At.prototype.getMaxListeners=function(){return bh(this)},At.prototype.emit=function(b){for(var z=[],W=1;W<arguments.length;W++)z.push(arguments[W]);var ie=b==="error",de=this._events;if(de!==void 0)ie=ie&&de.error===void 0;else if(!ie)return!1;if(ie){var he;if(z.length>0&&(he=z[0]),he instanceof Error)throw he;var h=new Error("Unhandled error."+(he?" ("+he.message+")":""));throw h.context=he,h}var ve=de[b];if(ve===void 0)return!1;if(typeof ve=="function")yh(ve,this,z);else for(var Ge=ve.length,et=Ih(ve,Ge),W=0;W<Ge;++W)yh(et[W],this,z);return!0};function wh(A,b,z,W){var ie,de,he;if(Po(z),de=A._events,de===void 0?(de=A._events=Object.create(null),A._eventsCount=0):(de.newListener!==void 0&&(A.emit("newListener",b,z.listener?z.listener:z),de=A._events),he=de[b]),he===void 0)he=de[b]=z,++A._eventsCount;else if(typeof he=="function"?he=de[b]=W?[z,he]:[he,z]:W?he.unshift(z):he.push(z),ie=bh(A),ie>0&&he.length>ie&&!he.warned){he.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+he.length+" "+String(b)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=A,h.type=b,h.count=he.length,Md(h)}return A}At.prototype.addListener=function(b,z){return wh(this,b,z,!1)},At.prototype.on=At.prototype.addListener,At.prototype.prependListener=function(b,z){return wh(this,b,z,!0)};function Pd(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Th(A,b,z){var W={fired:!1,wrapFn:void 0,target:A,type:b,listener:z},ie=Pd.bind(W);return ie.listener=z,W.wrapFn=ie,ie}At.prototype.once=function(b,z){return Po(z),this.on(b,Th(this,b,z)),this},At.prototype.prependOnceListener=function(b,z){return Po(z),this.prependListener(b,Th(this,b,z)),this},At.prototype.removeListener=function(b,z){var W,ie,de,he,h;if(Po(z),ie=this._events,ie===void 0)return this;if(W=ie[b],W===void 0)return this;if(W===z||W.listener===z)--this._eventsCount===0?this._events=Object.create(null):(delete ie[b],ie.removeListener&&this.emit("removeListener",b,W.listener||z));else if(typeof W!="function"){for(de=-1,he=W.length-1;he>=0;he--)if(W[he]===z||W[he].listener===z){h=W[he].listener,de=he;break}if(de<0)return this;de===0?W.shift():kd(W,de),W.length===1&&(ie[b]=W[0]),ie.removeListener!==void 0&&this.emit("removeListener",b,h||z)}return this},At.prototype.off=At.prototype.removeListener,At.prototype.removeAllListeners=function(b){var z,W,ie;if(W=this._events,W===void 0)return this;if(W.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):W[b]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete W[b]),this;if(arguments.length===0){var de=Object.keys(W),he;for(ie=0;ie<de.length;++ie)he=de[ie],he!=="removeListener"&&this.removeAllListeners(he);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(z=W[b],typeof z=="function")this.removeListener(b,z);else if(z!==void 0)for(ie=z.length-1;ie>=0;ie--)this.removeListener(b,z[ie]);return this};function Sh(A,b,z){var W=A._events;if(W===void 0)return[];var ie=W[b];return ie===void 0?[]:typeof ie=="function"?z?[ie.listener||ie]:[ie]:z?zd(ie):Ih(ie,ie.length)}At.prototype.listeners=function(b){return Sh(this,b,!0)},At.prototype.rawListeners=function(b){return Sh(this,b,!1)},At.listenerCount=function(A,b){return typeof A.listenerCount=="function"?A.listenerCount(b):Eh.call(A,b)},At.prototype.listenerCount=Eh;function Eh(A){var b=this._events;if(b!==void 0){var z=b[A];if(typeof z=="function")return 1;if(z!==void 0)return z.length}return 0}At.prototype.eventNames=function(){return this._eventsCount>0?Mo(this._events):[]};function Ih(A,b){for(var z=new Array(b),W=0;W<b;++W)z[W]=A[W];return z}function kd(A,b){for(;b+1<A.length;b++)A[b]=A[b+1];A.pop()}function zd(A){for(var b=new Array(A.length),z=0;z<b.length;++z)b[z]=A[z].listener||A[z];return b}function Ld(A,b){return new Promise(function(z,W){function ie(he){A.removeListener(b,de),W(he)}function de(){typeof A.removeListener=="function"&&A.removeListener("error",ie),z([].slice.call(arguments))}Ah(A,b,de,{once:!0}),b!=="error"&&Dd(A,ie,{once:!0})})}function Dd(A,b,z){typeof A.on=="function"&&Ah(A,"error",b,z)}function Ah(A,b,z,W){if(typeof A.on=="function")W.once?A.once(b,z):A.on(b,z);else if(typeof A.addEventListener=="function")A.addEventListener(b,function ie(de){W.once&&A.removeEventListener(b,ie),z(de)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof A)}var Rd=Ul.exports,Bd=Yc(Rd);const Sr={AUTO:"auto",LATIN:"latin",NON_LATIN:"nonlatin",LOCAL:"",ALBANIAN:"sq",AMHARIC:"am",ARABIC:"ar",ARMENIAN:"hy",AZERBAIJANI:"az",BASQUE:"eu",BELORUSSIAN:"be",BOSNIAN:"bs",BRETON:"br",BULGARIAN:"bg",CATALAN:"ca",CHINESE:"zh",CORSICAN:"co",CROATIAN:"hr",CZECH:"cs",DANISH:"da",DUTCH:"nl",ENGLISH:"en",ESPERANTO:"eo",ESTONIAN:"et",FINNISH:"fi",FRENCH:"fr",FRISIAN:"fy",GEORGIAN:"ka",GERMAN:"de",GREEK:"el",HEBREW:"he",HINDI:"hi",HUNGARIAN:"hu",ICELANDIC:"is",INDONESIAN:"id",IRISH:"ga",ITALIAN:"it",JAPANESE:"ja",JAPANESE_HIRAGANA:"ja-Hira",JAPANESE_KANA:"ja_kana",JAPANESE_LATIN:"ja_rm",JAPANESE_2018:"ja-Latn",KANNADA:"kn",KAZAKH:"kk",KOREAN:"ko",KOREAN_LATIN:"ko-Latn",KURDISH:"ku",ROMAN_LATIN:"la",LATVIAN:"lv",LITHUANIAN:"lt",LUXEMBOURGISH:"lb",MACEDONIAN:"mk",MALAYALAM:"ml",MALTESE:"mt",NORWEGIAN:"no",OCCITAN:"oc",POLISH:"pl",PORTUGUESE:"pt",ROMANIAN:"ro",ROMANSH:"rm",RUSSIAN:"ru",SCOTTISH_GAELIC:"gd",SERBIAN_CYRILLIC:"sr",SERBIAN_LATIN:"sr-Latn",SLOVAK:"sk",SLOVENE:"sl",SPANISH:"es",SWEDISH:"sv",TAMIL:"ta",TELUGU:"te",THAI:"th",TURKISH:"tr",UKRAINIAN:"uk",WELSH:"cy"},Fd=new Set(Object.values(Sr));function Ch(A){return Fd.has(A)}const Od=new Set(Object.values(Sr));function Vl(){if(typeof navigator>"u")return Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];const A=Array.from(new Set(navigator.languages.map(b=>b.split("-")[0]))).filter(b=>Od.has(b));return A.length?A[0]:Sr.LATIN}function Ud(){return typeof self<"u"?fetch.bind(self):typeof global<"u"&&global.fetch?global.fetch:null}class Vd{constructor(){this._apiKey="",this._fetch=Ud()}set apiKey(b){this._apiKey=b}get apiKey(){return this._apiKey}set fetch(b){this._fetch=b}get fetch(){return this._fetch}}const Xi=new Vd,cs={AUTO:"auto",ALBANIAN:"sq",ARABIC:"ar",ARMENIAN:"hy",AZERBAIJANI:"az",BELORUSSIAN:"be",BOSNIAN:"bs",BRETON:"br",BULGARIAN:"bg",CATALAN:"ca",CHINESE:"zh",CROATIAN:"hr",CZECH:"cs",DANISH:"da",DUTCH:"nl",ENGLISH:"en",ESPERANTO:"eo",ESTONIAN:"et",FINNISH:"fi",FRENCH:"fr",FRISIAN:"fy",GEORGIAN:"ka",GERMAN:"de",GREEK:"el",HEBREW:"he",HUNGARIAN:"hu",ICELANDIC:"is",IRISH:"ga",ITALIAN:"it",JAPANESE:"ja",KANNADA:"kn",KAZAKH:"kk",KOREAN:"ko",ROMAN_LATIN:"la",LATVIAN:"lv",LITHUANIAN:"lt",LUXEMBOURGISH:"lb",MACEDONIAN:"mk",MALTESE:"mt",NORWEGIAN:"no",POLISH:"pl",PORTUGUESE:"pt",ROMANIAN:"ro",ROMANSH:"rm",RUSSIAN:"ru",SCOTTISH_GAELIC:"gd",SERBIAN_CYRILLIC:"sr",SLOVAK:"sk",SLOVENE:"sl",SPANISH:"es",SWEDISH:"sv",THAI:"th",TURKISH:"tr",UKRAINIAN:"uk",WELSH:"cy"},Nd=new Set(Object.values(cs));function $d(){if(typeof navigator>"u")return Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];const A=Array.from(new Set(navigator.languages.map(b=>b.split("-")[0]))).filter(b=>Nd.has(b));return A.length?A[0]:cs.ENGLISH}var Gd=(A,b,z)=>new Promise((W,ie)=>{var de=ve=>{try{h(z.next(ve))}catch(Ge){ie(Ge)}},he=ve=>{try{h(z.throw(ve))}catch(Ge){ie(Ge)}},h=ve=>ve.done?W(ve.value):Promise.resolve(ve.value).then(de,he);h((z=z.apply(A,b)).next())});function Vn(A){return Gd(this,arguments,function*(b,z={}){if(Xi.fetch===null)throw new Error("The fetch function was not found. If on NodeJS < 18 please specify the fetch function with config.fetch");if(new URL(b).searchParams.get("key").trim()==="")throw new Error("The MapTiler Cloud API key is missing. Set it in `config.apiKey` or get one for free at https://maptiler.com");return Xi.fetch(b,z)})}const dr={maptilerApiURL:"https://api.maptiler.com/",mapStyle:"streets-v2"};Object.freeze(dr);class hn extends Error{constructor(b,z=""){super(`Call to enpoint ${b.url} failed with the status code ${b.status}. ${z}`),this.res=b}}var Nl=(A,b,z)=>new Promise((W,ie)=>{var de=ve=>{try{h(z.next(ve))}catch(Ge){ie(Ge)}},he=ve=>{try{h(z.throw(ve))}catch(Ge){ie(Ge)}},h=ve=>ve.done?W(ve.value):Promise.resolve(ve.value).then(de,he);h((z=z.apply(A,b)).next())});const $l={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function Mh(A,b){if(b.language==null)return;const z=Array.from(new Set((Array.isArray(b.language)?b.language:[b.language]).map(W=>W===cs.AUTO?$d():W))).join(",");A.set("language",z)}function Ph(A,b){var z;A.set("key",(z=b.apiKey)!=null?z:Xi.apiKey),b.limit!=null&&A.set("limit",String(b.limit)),b.types!=null&&A.set("types",b.types.join(",")),Mh(A,b)}function jd(A){return Nl(this,arguments,function*(b,z={}){var W;if(typeof b!="string"||b.trim().length===0)throw new Error("The query must be a non-empty string");const ie=new URL(`geocoding/${encodeURIComponent(b)}.json`,dr.maptilerApiURL),{searchParams:de}=ie;Ph(de,z),z.bbox!=null&&de.set("bbox",z.bbox.join(",")),z.proximity!=null&&de.set("proximity",z.proximity.join(",")),z.country!=null&&de.set("country",z.country.join(",")),z.fuzzyMatch!=null&&de.set("fuzzyMatch",z.fuzzyMatch?"true":"false"),z.autocomplete!=null&&de.set("autocomplete",z.autocomplete?"true":"false");const he=ie.toString(),h=yield Vn(he);if(!h.ok)throw new hn(h,(W=$l[h.status])!=null?W:"");return yield h.json()})}function qd(A){return Nl(this,arguments,function*(b,z={}){var W;if(!Array.isArray(b)||b.length<2)throw new Error("The position must be an array of form [lng, lat].");const ie=new URL(`geocoding/${b[0]},${b[1]}.json`,dr.maptilerApiURL);Ph(ie.searchParams,z);const de=ie.toString(),he=yield Vn(de);if(!he.ok)throw new hn(he,(W=$l[he.status])!=null?W:"");return yield he.json()})}function Zd(A){return Nl(this,arguments,function*(b,z={}){var W;const ie=new URL(`geocoding/${b}.json`,dr.maptilerApiURL);Mh(ie.searchParams,z);const de=ie.toString(),he=yield Vn(de);if(!he.ok)throw new hn(he,(W=$l[he.status])!=null?W:"");return yield he.json()})}const Xd={forward:jd,reverse:qd,byId:Zd,language:cs};var Wd=(A,b,z)=>new Promise((W,ie)=>{var de=ve=>{try{h(z.next(ve))}catch(Ge){ie(Ge)}},he=ve=>{try{h(z.throw(ve))}catch(Ge){ie(Ge)}},h=ve=>ve.done?W(ve.value):Promise.resolve(ve.value).then(de,he);h((z=z.apply(A,b)).next())});const kh={403:"Key is missing, invalid or restricted"};function Hd(){return Wd(this,arguments,function*(A={}){var b;const z=new URL("geolocation/ip.json",dr.maptilerApiURL);z.searchParams.set("key",(b=A.apiKey)!=null?b:Xi.apiKey);const W=z.toString(),ie=yield Vn(W);if(!ie.ok)throw new hn(ie,ie.status in kh?kh[ie.status]:"");return yield ie.json()})}const Gl={info:Hd};var zh=(A,b,z)=>new Promise((W,ie)=>{var de=ve=>{try{h(z.next(ve))}catch(Ge){ie(Ge)}},he=ve=>{try{h(z.throw(ve))}catch(Ge){ie(Ge)}},h=ve=>ve.done?W(ve.value):Promise.resolve(ve.value).then(de,he);h((z=z.apply(A,b)).next())});const ko={403:"Key is missing, invalid or restricted"};function Kd(A){return zh(this,arguments,function*(b,z={}){var W;if(typeof b!="string"||b.trim().length===0)throw new Error("The query must be a non-empty string");const ie=new URL(`coordinates/search/${b}.json`,dr.maptilerApiURL);ie.searchParams.set("key",(W=z.apiKey)!=null?W:Xi.apiKey),"limit"in z&&ie.searchParams.set("limit",z.limit.toString()),"transformations"in z&&ie.searchParams.set("transformations",z.transformations.toString()),"exports"in z&&ie.searchParams.set("exports",z.exports.toString());const de=ie.toString(),he=yield Vn(de);if(!he.ok)throw new hn(he,he.status in ko?ko[he.status]:"");return yield he.json()})}function Yd(A){return zh(this,arguments,function*(b,z={}){var W;const ie=(Array.isArray(b[0])?b:[b]).map(Ge=>`${Ge[0]},${Ge[1]}`).join(";"),de=new URL(`coordinates/transform/${ie}.json`,dr.maptilerApiURL);de.searchParams.set("key",(W=z.apiKey)!=null?W:Xi.apiKey),"sourceCrs"in z&&de.searchParams.set("s_srs",z.sourceCrs.toString()),"targetCrs"in z&&de.searchParams.set("t_srs",z.targetCrs.toString()),"operations"in z&&de.searchParams.set("ops",(Array.isArray(z.operations)?z.operations:[z.operations]).join("|"));const he=de.toString(),h=yield Vn(he);if(!h.ok)throw new hn(h,h.status in ko?ko[h.status]:"");return yield h.json()})}const Jd={search:Kd,transform:Yd};var Qd=(A,b,z)=>new Promise((W,ie)=>{var de=ve=>{try{h(z.next(ve))}catch(Ge){ie(Ge)}},he=ve=>{try{h(z.throw(ve))}catch(Ge){ie(Ge)}},h=ve=>ve.done?W(ve.value):Promise.resolve(ve.value).then(de,he);h((z=z.apply(A,b)).next())});const Lh={403:"Key is missing, invalid or restricted"};function ep(A){return Qd(this,arguments,function*(b,z={}){var W;if(typeof b!="string"||b.trim().length===0)throw new Error("The data ID must be a non-empty string");const ie=new URL(`data/${encodeURIComponent(b)}/features.json`,dr.maptilerApiURL);ie.searchParams.set("key",(W=z.apiKey)!=null?W:Xi.apiKey);const de=ie.toString(),he=yield Vn(de);if(!he.ok)throw new hn(he,he.status in Lh?Lh[he.status]:"");return yield he.json()})}const tp={get:ep};function Dh(A){const b=/^maptiler:\/\/(.*)/;let z;const W=A.trim();let ie;return W.startsWith("http://")||W.startsWith("https://")?ie=W:(z=b.exec(W))!==null?ie=`https://api.maptiler.com/maps/${z[1]}/style.json`:ie=`https://api.maptiler.com/maps/${W}/style.json`,ie}class zo{constructor(b,z,W,ie,de,he){this.name=b,this.variantType=z,this.id=W,this.referenceStyle=ie,this.description=de,this.imageURL=he}getName(){return this.name}getFullName(){return`${this.referenceStyle.getName()} ${this.name}`}getType(){return this.variantType}getId(){return this.id}getDescription(){return this.description}getReferenceStyle(){return this.referenceStyle}hasVariant(b){return this.referenceStyle.hasVariant(b)}getVariant(b){return this.referenceStyle.getVariant(b)}getVariants(){return this.referenceStyle.getVariants().filter(b=>b!==this)}getImageURL(){return this.imageURL}getExpandedStyleURL(){return Dh(this.getId())}}class Lo{constructor(b,z){this.name=b,this.id=z,this.variants={},this.orderedVariants=[]}getName(){return this.name}getId(){return this.id}addVariant(b){this.variants[b.getType()]=b,this.orderedVariants.push(b)}hasVariant(b){return b in this.variants}getVariant(b){return b in this.variants?this.variants[b]:this.orderedVariants[0]}getVariants(){return Object.values(this.variants)}getDefaultVariant(){return this.orderedVariants[0]}}const Do=[{referenceStyleID:"STREETS",name:"Streets",description:"",variants:[{id:"streets-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"streets-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"streets-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"streets-v2-night",name:"Night",variantType:"NIGHT",description:"",imageURL:""},{id:"streets-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"OUTDOOR",name:"Outdoor",description:"",variants:[{id:"outdoor-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"outdoor-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"WINTER",name:"Winter",description:"",variants:[{id:"winter-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"winter-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"SATELLITE",name:"Satellite",description:"",variants:[{id:"satellite",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"HYBRID",name:"Hybrid",description:"",variants:[{id:"hybrid",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"BASIC",name:"Basic",description:"",variants:[{id:"basic-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"basic-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"basic-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"BRIGHT",name:"Bright",description:"",variants:[{id:"bright-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"bright-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"bright-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"bright-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"OPENSTREETMAP",name:"OpenStreetMap",description:"",variants:[{id:"openstreetmap",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"TOPO",name:"Topo",description:"",variants:[{id:"topo-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"topo-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"topo-v2-shiny",name:"Shiny",variantType:"SHINY",description:"",imageURL:""},{id:"topo-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""},{id:"topo-v2-topographique",name:"Topographique",variantType:"TOPOGRAPHIQUE",description:"",imageURL:""}]},{referenceStyleID:"VOYAGER",name:"Voyager",description:"",variants:[{id:"voyager-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"voyager-v2-darkmatter",name:"Darkmatter",variantType:"DARK",description:"",imageURL:""},{id:"voyager-v2-positron",name:"Positron",variantType:"LIGHT",description:"",imageURL:""},{id:"voyager-v2-vintage",name:"Vintage",variantType:"VINTAGE",description:"",imageURL:""}]},{referenceStyleID:"TONER",name:"Toner",description:"",variants:[{id:"toner-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"toner-v2-background",name:"Background",variantType:"BACKGROUND",description:"",imageURL:""},{id:"toner-v2-lite",name:"Lite",variantType:"LITE",description:"",imageURL:""},{id:"toner-v2-lines",name:"Lines",variantType:"LINES",description:"",imageURL:""}]},{referenceStyleID:"DATAVIZ",name:"Dataviz",description:"",variants:[{id:"dataviz",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"dataviz-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"dataviz-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"OCEAN",name:"Ocean",description:"",variants:[{id:"ocean",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]}];function ip(A){return new Proxy(A,{get(b,z,W){return b.hasVariant(z)?b.getVariant(z):z.toString().toUpperCase()===z?A.getDefaultVariant():Reflect.get(b,z,W)}})}function rp(){const A={};for(let b=0;b<Do.length;b+=1){const z=Do[b],W=ip(new Lo(z.name,z.referenceStyleID));for(let ie=0;ie<z.variants.length;ie+=1){const de=z.variants[ie],he=new zo(de.name,de.variantType,de.id,W,de.description,de.imageURL);W.addVariant(he)}A[z.referenceStyleID]=W}return A}function jl(A){if(!A)return ql[Do[0].referenceStyleID].getDefaultVariant().getId();if(typeof A=="string"||A instanceof String)return A.trim().toLowerCase();if(A instanceof zo)return A.getId();if(A instanceof Lo)return A.getDefaultVariant().getId()}const ql=rp();function np(A,b,z){let W=b[0],ie=b[1],de=z[0]-W,he=z[1]-ie;if(de!==0||he!==0){const h=((A[0]-W)*de+(A[1]-ie)*he)/(de*de+he*he);h>1?(W=z[0],ie=z[1]):h>0&&(W+=de*h,ie+=he*h)}return de=A[0]-W,he=A[1]-ie,de*de+he*he}function Zl(A,b,z,W,ie){let de=W,he;for(let h=b+1;h<z;h++){const ve=np(A[h],A[b],A[z]);ve>de&&(he=h,de=ve)}de>W&&(he-b>1&&Zl(A,b,he,W,ie),ie.push(A[he]),z-he>1&&Zl(A,he,z,W,ie))}function ap(A,b){const z=A.length-1,W=[A[0]];return Zl(A,0,z,b,W),W.push(A[z]),W}function sp(A,b){if(A.length<=2)return A;const z=b!==void 0?b*b:1;return ap(A,z)}function Xl(A,b=!0){let z=`${A[0]},${A[1]}`;return A.length===3&&b&&(z+=`,${A[2]}`),z}function Wl(A,b=3e3){let z=A.map(de=>de.join(",")).join("|"),W=5e-6;const ie=1e-5;for(;z.length>b;)z=sp(A,W).map(he=>`${he[0]},${he[1]}`).join("|"),W+=ie;return z}function op(A,b,z={}){var W,ie,de,he,h;const ve=jl(z.style),Ge=z.hiDPI?"@2x":"",et=(W=z.format)!=null?W:"png";let Ye=~~((ie=z.width)!=null?ie:1024),pe=~~((de=z.height)!=null?de:1024);z.hiDPI&&(Ye=~~(Ye/2),pe=~~(pe/2));const ee=new URL(`maps/${encodeURIComponent(ve)}/static/${A[0]},${A[1]},${b}/${Ye}x${pe}${Ge}.${et}`,dr.maptilerApiURL);if("attribution"in z&&ee.searchParams.set("attribution",z.attribution.toString()),"markers"in z){let Be="";const Ct="markerIcon"in z;Ct&&(Be+=`icon:${z.markerIcon}|`),Ct&&"markerAnchor"in z&&(Be+=`anchor:${z.markerAnchor}|`),Ct&&z.hiDPI&&(Be+="scale:2|");const Ft=Array.isArray(z.markers[0])?z.markers:[z.markers];Be+=Ft.map(mr=>Xl(mr,!Ct)).join("|"),ee.searchParams.set("markers",Be)}if("path"in z){let Be="";if(Be+=`fill:${(he=z.pathFillColor)!=null?he:"none"}|`,"pathStrokeColor"in z&&(Be+=`stroke:${z.pathStrokeColor}|`),"pathWidth"in z){const Ct=z.pathWidth/(z.hiDPI?2:1);Be+=`width:${Ct.toString()}|`}Be+=Wl(z.path),ee.searchParams.set("path",Be)}return ee.searchParams.set("key",(h=z.apiKey)!=null?h:Xi.apiKey),ee.toString()}function lp(A,b={}){var z,W,ie,de,he;const h=jl(b.style),ve=b.hiDPI?"@2x":"",Ge=(z=b.format)!=null?z:"png";let et=~~((W=b.width)!=null?W:1024),Ye=~~((ie=b.height)!=null?ie:1024);b.hiDPI&&(et=~~(et/2),Ye=~~(Ye/2));const pe=new URL(`maps/${encodeURIComponent(h)}/static/${A[0]},${A[1]},${A[2]},${A[3]}/${et}x${Ye}${ve}.${Ge}`,dr.maptilerApiURL);if("attribution"in b&&pe.searchParams.set("attribution",b.attribution.toString()),"padding"in b&&pe.searchParams.set("padding",b.padding.toString()),"markers"in b){let ee="";const Be="markerIcon"in b;Be&&(ee+=`icon:${b.markerIcon}|`),Be&&"markerAnchor"in b&&(ee+=`anchor:${b.markerAnchor}|`),Be&&b.hiDPI&&(ee+="scale:2|");const Ct=Array.isArray(b.markers[0])?b.markers:[b.markers];ee+=Ct.map(Ft=>Xl(Ft,!Be)).join("|"),pe.searchParams.set("markers",ee)}if("path"in b){let ee="";if(ee+=`fill:${(de=b.pathFillColor)!=null?de:"none"}|`,"pathStrokeColor"in b&&(ee+=`stroke:${b.pathStrokeColor}|`),"pathWidth"in b){const Be=b.pathWidth/(b.hiDPI?2:1);ee+=`width:${Be.toString()}|`}ee+=Wl(b.path),pe.searchParams.set("path",ee)}return pe.searchParams.set("key",(he=b.apiKey)!=null?he:Xi.apiKey),pe.toString()}function cp(A={}){var b,z,W,ie,de;if(!("markers"in A)&&!("path"in A))throw new Error("Automatic static maps require markers and/or path to be created.");const he=jl(A.style),h=A.hiDPI?"@2x":"",ve=(b=A.format)!=null?b:"png";let Ge=~~((z=A.width)!=null?z:1024),et=~~((W=A.height)!=null?W:1024);A.hiDPI&&(Ge=~~(Ge/2),et=~~(et/2));const Ye=new URL(`maps/${encodeURIComponent(he)}/static/auto/${Ge}x${et}${h}.${ve}`,dr.maptilerApiURL);if("attribution"in A&&Ye.searchParams.set("attribution",A.attribution.toString()),"padding"in A&&Ye.searchParams.set("padding",A.padding.toString()),"markers"in A){let pe="";const ee="markerIcon"in A;ee&&(pe+=`icon:${A.markerIcon}|`),ee&&"markerAnchor"in A&&(pe+=`anchor:${A.markerAnchor}|`),ee&&A.hiDPI&&(pe+="scale:2|");const Be=Array.isArray(A.markers[0])?A.markers:[A.markers];pe+=Be.map(Ct=>Xl(Ct,!ee)).join("|"),Ye.searchParams.set("markers",pe)}if("path"in A){let pe="";if(pe+=`fill:${(ie=A.pathFillColor)!=null?ie:"none"}|`,"pathStrokeColor"in A&&(pe+=`stroke:${A.pathStrokeColor}|`),"pathWidth"in A){const ee=A.pathWidth/(A.hiDPI?2:1);pe+=`width:${ee.toString()}|`}pe+=Wl(A.path),Ye.searchParams.set("path",pe)}return Ye.searchParams.set("key",(de=A.apiKey)!=null?de:Xi.apiKey),Ye.toString()}const hp={centered:op,bounded:lp,automatic:cp};let Rh=class extends Bd{constructor(){super(),this.primaryLanguage=Sr.AUTO,this.secondaryLanguage=null,this.session=!0,this._unit="metric",this._apiKey=""}set unit(b){this._unit=b,this.emit("unit",b)}get unit(){return this._unit}set apiKey(b){this._apiKey=b,Xi.apiKey=b,this.emit("apiKey",b)}get apiKey(){return this._apiKey}set fetch(b){Xi.fetch=b}get fetch(){return Xi.fetch}};const pr=new Rh,Fi={maptilerLogoURL:"https://api.maptiler.com/resources/logo.svg",maptilerURL:"https://www.maptiler.com/",maptilerApiHost:"api.maptiler.com",rtlPluginURL:"https://cdn.maptiler.com/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.min.js",primaryLanguage:Sr.AUTO,secondaryLanguage:Sr.LOCAL,terrainSourceURL:"https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json",terrainSourceId:"maptiler-terrain"};Object.freeze(Fi);class Bh extends nt.LogoControl{onAdd(b){return super.onAdd(b)}}class Hl extends Bh{constructor(b={}){var z,W;super(b),this.logoURL="",this.linkURL="",this.logoURL=(z=b.logoURL)!=null?z:Fi.maptilerLogoURL,this.linkURL=(W=b.linkURL)!=null?W:Fi.maptilerURL}onAdd(b){this._map=b,this._compact=this.options&&this.options.compact,this._container=window.document.createElement("div"),this._container.className="maplibregl-ctrl";const z=window.document.createElement("a");return z.style.backgroundRepeat="no-repeat",z.style.cursor="pointer",z.style.display="block",z.style.height="23px",z.style.margin="0 0 -4px -4px",z.style.overflow="hidden",z.style.width="88px",z.style.backgroundImage=`url(${this.logoURL})`,z.style.backgroundSize="100px 30px",z.style.width="100px",z.style.height="30px",z.target="_blank",z.rel="noopener nofollow",z.href=this.linkURL,z.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),z.setAttribute("rel","noopener nofollow"),this._container.appendChild(z),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}}function up(){nt.getRTLTextPluginStatus()==="unavailable"&&nt.setRTLTextPlugin(Fi.rtlPluginURL,null,!0)}function dp(A,b){A.forEach(z=>{b[z]&&(b[z]=b[z].bind(b))})}function Nn(A,b,z){const W=window.document.createElement(A);return b!==void 0&&(W.className=b),z&&z.appendChild(W),W}function pp(A){A.parentNode&&A.parentNode.removeChild(A)}function Fh(A){return A?typeof A=="string"||A instanceof String?!A.startsWith("http")&&A.toLowerCase().includes(".json")?A:Dh(A):A instanceof zo?A.getExpandedStyleURL():A instanceof Lo?A.getDefaultVariant().getExpandedStyleURL():A:ql[Do[0].referenceStyleID].getDefaultVariant().getExpandedStyleURL()}class Oh{constructor(){dp(["_toggleTerrain","_updateTerrainIcon"],this)}onAdd(b){return this._map=b,this._container=Nn("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=Nn("button","maplibregl-ctrl-terrain",this._container),Nn("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(){pp(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}_toggleTerrain(){this._map.hasTerrain()?this._map.disableTerrain():this._map.enableTerrain(),this._updateTerrainIcon()}_updateTerrainIcon(){this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.hasTerrain()?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))}}class Uh extends nt.NavigationControl{onAdd(b){return super.onAdd(b)}}class mp extends Uh{constructor(){super({showCompass:!0,showZoom:!0,visualizePitch:!0}),this._compass.removeEventListener("click",this._compass.clickFunction),this._compass.addEventListener("click",b=>{this._map.getPitch()===0?this._map.easeTo({pitch:Math.min(this._map.getMaxPitch(),80)}):this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:b}):this._map.resetNorth({},{originalEvent:b})})}_createButton(b,z){const W=super._createButton(b,z);return W.clickFunction=z,W}_rotateCompassArrow(){const b=this.options.visualizePitch?`scale(${Math.min(1.5,1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5))}) rotateX(${Math.min(70,this._map.transform.pitch)}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=b}}class Vh extends nt.GeolocateControl{onAdd(b){return super.onAdd(b)}}var fp=Object.defineProperty,gp=Object.defineProperties,_p=Object.getOwnPropertyDescriptors,Nh=Object.getOwnPropertySymbols,yp=Object.prototype.hasOwnProperty,xp=Object.prototype.propertyIsEnumerable,$h=(A,b,z)=>b in A?fp(A,b,{enumerable:!0,configurable:!0,writable:!0,value:z}):A[b]=z,vp=(A,b)=>{for(var z in b||(b={}))yp.call(b,z)&&$h(A,z,b[z]);if(Nh)for(var z of Nh(b))xp.call(b,z)&&$h(A,z,b[z]);return A},bp=(A,b)=>gp(A,_p(b));const Gh=nt.Marker,jh=nt.LngLat;class qh extends Vh{constructor(){super(...arguments),this.lastUpdatedCenter=new jh(0,0)}_updateCamera(b){const z=new jh(b.coords.longitude,b.coords.latitude),W=b.coords.accuracy,ie=this._map.getBearing(),de=bp(vp({bearing:ie},this.options.fitBoundsOptions),{linear:!0}),he=this._map.getZoom();he>this.options.fitBoundsOptions.maxZoom&&(de.zoom=he),this._map.fitBounds(z.toBounds(W),de,{geolocateSource:!0});let h=!1;const ve=()=>{h=!0};this._map.once("click",ve),this._map.once("dblclick",ve),this._map.once("dragstart",ve),this._map.once("mousedown",ve),this._map.once("touchstart",ve),this._map.once("wheel",ve),this._map.once("moveend",()=>{this._map.off("click",ve),this._map.off("dblclick",ve),this._map.off("dragstart",ve),this._map.off("mousedown",ve),this._map.off("touchstart",ve),this._map.off("wheel",ve),!h&&(this.lastUpdatedCenter=this._map.getCenter())})}_setupUI(b){if(this.lastUpdatedCenter=this._map.getCenter(),this._container.addEventListener("contextmenu",z=>z.preventDefault()),this._geolocateButton=Nn("button","maplibregl-ctrl-geolocate",this._container),Nn("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",b===!1){const z=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=z,this._geolocateButton.setAttribute("aria-label",z)}else{const z=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=z,this._geolocateButton.setAttribute("aria-label",z)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=Nn("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Gh(this._dotElement),this._circleElement=Nn("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Gh({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("move",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("moveend",z=>{const W=z.originalEvent&&z.originalEvent.type==="resize",ie=this.lastUpdatedCenter.distanceTo(this._map.getCenter());!z.geolocateSource&&this._watchState==="ACTIVE_LOCK"&&!W&&ie>1&&(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new Event("trackuserlocationend")))})}_updateCircleRadius(){if(this._watchState!=="BACKGROUND"&&this._watchState!=="ACTIVE_LOCK")return;const b=[this._lastKnownPosition.coords.longitude,this._lastKnownPosition.coords.latitude],z=this._map.project(b),W=this._map.unproject([z.x,z.y]),ie=this._map.unproject([z.x+20,z.y]),de=W.distanceTo(ie)/20,he=Math.ceil(2*this._accuracy/de);this._circleElement.style.width=`${he}px`,this._circleElement.style.height=`${he}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}}class Zh extends nt.AttributionControl{onAdd(b){return super.onAdd(b)}}class Xh extends nt.ScaleControl{onAdd(b){return super.onAdd(b)}}class Wh extends nt.FullscreenControl{onAdd(b){return super.onAdd(b)}}var wp=Object.defineProperty,Tp=Object.defineProperties,Sp=Object.getOwnPropertyDescriptors,Hh=Object.getOwnPropertySymbols,Ep=Object.prototype.hasOwnProperty,Ip=Object.prototype.propertyIsEnumerable,Kh=(A,b,z)=>b in A?wp(A,b,{enumerable:!0,configurable:!0,writable:!0,value:z}):A[b]=z,Ap=(A,b)=>{for(var z in b||(b={}))Ep.call(b,z)&&Kh(A,z,b[z]);if(Hh)for(var z of Hh(b))Ip.call(b,z)&&Kh(A,z,b[z]);return A},Cp=(A,b)=>Tp(A,Sp(b)),un=(A,b,z)=>new Promise((W,ie)=>{var de=ve=>{try{h(z.next(ve))}catch(Ge){ie(Ge)}},he=ve=>{try{h(z.throw(ve))}catch(Ge){ie(Ge)}},h=ve=>ve.done?W(ve.value):Promise.resolve(ve.value).then(de,he);h((z=z.apply(A,b)).next())});const Yh=Cd(),Jh={POINT:"POINT",COUNTRY:"COUNTRY"};let Mp=class extends nt.Map{constructor(b){var z,W,ie;b.apiKey&&(pr.apiKey=b.apiKey);const de=Fh(b.style),he=location.hash;pr.apiKey||console.warn("MapTiler Cloud API key is not set. Visit https://maptiler.com and try Cloud for free!"),super(Cp(Ap({},b),{style:de,maplibreLogo:!1,transformRequest:Ye=>{let pe=null;try{pe=new URL(Ye)}catch{return{url:Ye,headers:{}}}return pe.host===Fi.maptilerApiHost&&(pe.searchParams.has("key")||pe.searchParams.append("key",pr.apiKey),pr.session&&pe.searchParams.append("mtsid",Yh)),{url:pe.href,headers:{}}}})),this.isTerrainEnabled=!1,this.terrainExaggeration=1,this.primaryLanguage=null,this.secondaryLanguage=null,this.terrainGrowing=!1,this.terrainFlattening=!1,this.primaryLanguage=(z=b.language)!=null?z:pr.primaryLanguage,this.secondaryLanguage=pr.secondaryLanguage,this.terrainExaggeration=(W=b.terrainExaggeration)!=null?W:this.terrainExaggeration,this.once("styledata",()=>un(this,null,function*(){if(!b.geolocate||b.center||b.hash&&he)return;try{if(b.geolocate===Jh.COUNTRY){yield this.fitToIpBounds();return}}catch(pe){console.warn(pe.message)}let Ye=null;try{yield this.centerOnIpPoint(b.zoom),Ye=this.getCameraHash()}catch(pe){console.warn(pe.message)}(yield navigator.permissions.query({name:"geolocation"})).state==="granted"&&navigator.geolocation.getCurrentPosition(pe=>{Ye===this.getCameraHash()&&(this.terrain?this.easeTo({center:[pe.coords.longitude,pe.coords.latitude],zoom:b.zoom||12,duration:2e3}):this.once("terrain",()=>{this.easeTo({center:[pe.coords.longitude,pe.coords.latitude],zoom:b.zoom||12,duration:2e3})}))},null,{maximumAge:24*3600*1e3,timeout:5e3,enableHighAccuracy:!1})})),this.on("styledata",()=>{this.setPrimaryLanguage(this.primaryLanguage),this.setSecondaryLanguage(this.secondaryLanguage)}),this.on("styledata",()=>{this.getTerrain()===null&&this.isTerrainEnabled&&this.enableTerrain(this.terrainExaggeration)}),this.once("load",()=>un(this,null,function*(){up()})),this.once("load",()=>un(this,null,function*(){let Ye={logo:null};try{const pe=Object.keys(this.style.sourceCaches).map(Be=>this.getSource(Be)).filter(Be=>typeof Be.url=="string"&&Be.url.includes("tiles.json")),ee=new URL(pe[0].url);ee.searchParams.has("key")||ee.searchParams.append("key",pr.apiKey),Ye=yield(yield fetch(ee.href)).json()}catch{}if("logo"in Ye&&Ye.logo){const pe=Ye.logo;this.addControl(new Hl({logoURL:pe}),b.logoPosition),b.attributionControl===!1&&this.addControl(new Zh(b))}else b.maptilerLogo&&this.addControl(new Hl,b.logoPosition);if(b.scaleControl){const pe=b.scaleControl===!0||b.scaleControl===void 0?"bottom-right":b.scaleControl,ee=new Xh({unit:pr.unit});this.addControl(ee,pe),pr.on("unit",Be=>{ee.setUnit(Be)})}if(b.navigationControl!==!1){const pe=b.navigationControl===!0||b.navigationControl===void 0?"top-right":b.navigationControl;this.addControl(new mp,pe)}if(b.geolocateControl!==!1){const pe=b.geolocateControl===!0||b.geolocateControl===void 0?"top-right":b.geolocateControl;this.addControl(new qh({positionOptions:{enableHighAccuracy:!0,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!0,showAccuracyCircle:!0,showUserLocation:!0}),pe)}if(b.terrainControl){const pe=b.terrainControl===!0||b.terrainControl===void 0?"top-right":b.terrainControl;this.addControl(new Oh,pe)}if(b.fullscreenControl){const pe=b.fullscreenControl===!0||b.fullscreenControl===void 0?"top-right":b.fullscreenControl;this.addControl(new Wh({}),pe)}}));let h=!1,ve=!1,Ge=null;this.once("load",Ye=>{h=!0,ve&&this.fire("loadWithTerrain",Ge)});const et=Ye=>{Ye.terrain&&(ve=!0,Ge={type:"loadWithTerrain",target:this,terrain:Ye.terrain},this.off("terrain",et),h&&this.fire("loadWithTerrain",Ge))};this.on("terrain",et),b.terrain&&this.enableTerrain((ie=b.terrainExaggeration)!=null?ie:this.terrainExaggeration)}onLoadAsync(){return un(this,null,function*(){return new Promise((b,z)=>{if(this.loaded())return b(this);this.once("load",W=>{b(this)})})})}onLoadWithTerrainAsync(){return un(this,null,function*(){return new Promise((b,z)=>{if(this.loaded()&&this.terrain)return b(this);this.once("loadWithTerrain",W=>{b(this)})})})}setStyle(b,z){return super.setStyle(Fh(b),z)}setLanguage(b=Fi.primaryLanguage){if(b===Sr.AUTO)return this.setLanguage(Vl());this.setPrimaryLanguage(b)}setPrimaryLanguage(b=Fi.primaryLanguage){Ch(b)&&(this.primaryLanguage=b,this.onStyleReady(()=>{if(b===Sr.AUTO)return this.setPrimaryLanguage(Vl());const z=this.getStyle().layers,W=/^\s*{\s*name\s*(:\s*(\S*))?\s*}$/,ie=/^\s*name\s*(:\s*(\S*))?\s*$/,de=/^\s*{\s*name\s*(:\s*(\S*))?\s*}(\s*){\s*name\s*(:\s*(\S*))?\s*}$/,he=/^(.*)({\s*name\s*(:\s*(\S*))?\s*})(.*)$/,h=b?`name:${b}`:"name",ve=["case",["has",h],["get",h],["get","name:latin"]];for(let Ge=0;Ge<z.length;Ge+=1){const et=z[Ge],Ye=et.layout;if(!Ye||!Ye["text-field"])continue;const pe=this.getLayoutProperty(et.id,"text-field");let ee;if(Array.isArray(pe)&&pe.length>=2&&pe[0].trim().toLowerCase()==="concat"){const Be=pe.slice();for(let Ct=0;Ct<pe.length;Ct+=1){const Ft=pe[Ct];if((typeof Ft=="string"||Ft instanceof String)&&W.exec(Ft.toString())){Be[Ct]=ve;break}else if(Array.isArray(Ft)&&Ft.length>=2&&Ft[0].trim().toLowerCase()==="get"&&ie.exec(Ft[1].toString())){Be[Ct]=ve;break}else if(Array.isArray(Ft)&&Ft.length===4&&Ft[0].trim().toLowerCase()==="case"){Be[Ct]=ve;break}}this.setLayoutProperty(et.id,"text-field",Be)}else if(Array.isArray(pe)&&pe.length>=2&&pe[0].trim().toLowerCase()==="get"&&ie.exec(pe[1].toString())){const Be=ve;this.setLayoutProperty(et.id,"text-field",Be)}else if((typeof pe=="string"||pe instanceof String)&&W.exec(pe.toString())){const Be=ve;this.setLayoutProperty(et.id,"text-field",Be)}else if(Array.isArray(pe)&&pe.length===4&&pe[0].trim().toLowerCase()==="case"){const Be=ve;this.setLayoutProperty(et.id,"text-field",Be)}else if((typeof pe=="string"||pe instanceof String)&&(ee=de.exec(pe.toString()))!==null){const Be=`{${h}}${ee[3]}{name${ee[4]||""}}`;this.setLayoutProperty(et.id,"text-field",Be)}else if((typeof pe=="string"||pe instanceof String)&&(ee=he.exec(pe.toString()))!==null){const Be=`${ee[1]}{${h}}${ee[5]}`;this.setLayoutProperty(et.id,"text-field",Be)}}}))}setSecondaryLanguage(b=Fi.secondaryLanguage){Ch(b)&&(this.secondaryLanguage=b,this.onStyleReady(()=>{if(b===Sr.AUTO)return this.setSecondaryLanguage(Vl());const z=this.getStyle().layers,W=/^\s*{\s*name\s*(:\s*(\S*))?\s*}$/,ie=/^\s*name\s*(:\s*(\S*))?\s*$/,de=/^\s*{\s*name\s*(:\s*(\S*))?\s*}(\s*){\s*name\s*(:\s*(\S*))?\s*}$/;let he;for(let h=0;h<z.length;h+=1){const ve=z[h],Ge=ve.layout;if(!Ge||!Ge["text-field"])continue;const et=this.getLayoutProperty(ve.id,"text-field");let Ye;if(Array.isArray(et)&&et.length>=2&&et[0].trim().toLowerCase()==="concat"){Ye=et.slice();let pe=0;for(let ee=0;ee<et.length;ee+=1){const Be=et[ee];if((typeof Be=="string"||Be instanceof String)&&W.exec(Be.toString())){if(pe===1){Ye[ee]=`{name:${b}}`;break}pe+=1}else if(Array.isArray(Be)&&Be.length>=2&&Be[0].trim().toLowerCase()==="get"&&ie.exec(Be[1].toString())){if(pe===1){Ye[ee][1]=`name:${b}`;break}pe+=1}else if(Array.isArray(Be)&&Be.length===4&&Be[0].trim().toLowerCase()==="case"){if(pe===1){Ye[ee]=["get",`name:${b}`];break}pe+=1}}this.setLayoutProperty(ve.id,"text-field",Ye)}else if((typeof et=="string"||et instanceof String)&&(he=de.exec(et.toString()))!==null){const pe=b?`name:${b}`:"name";Ye=`{name${he[1]||""}}${he[3]}{${pe}}`,this.setLayoutProperty(ve.id,"text-field",Ye)}}}))}getPrimaryLanguage(){return this.primaryLanguage}getSecondaryLanguage(){return this.secondaryLanguage}getTerrainExaggeration(){return this.terrainExaggeration}hasTerrain(){return this.isTerrainEnabled}growTerrain(b,z=1e3){if(!this.terrain)return;const W=performance.now(),ie=this.terrain.exaggeration,de=b-ie,he=()=>{if(!this.terrain||this.terrainFlattening)return;const h=(performance.now()-W)/z;if(h<.99){const ve=1-Math.pow(1-h,4),Ge=ie+ve*de;this.terrain.exaggeration=Ge,requestAnimationFrame(he)}else this.terrainGrowing=!1,this.terrainFlattening=!1,this.terrain.exaggeration=b;this.triggerRepaint()};this.terrainGrowing=!0,this.terrainFlattening=!1,requestAnimationFrame(he)}enableTerrain(b=this.terrainExaggeration){if(b<0){console.warn("Terrain exaggeration cannot be negative.");return}const z=ie=>un(this,null,function*(){!this.terrain||ie.type!=="data"||ie.dataType!=="source"||!("source"in ie)||ie.sourceId!=="maptiler-terrain"||ie.source.type!=="raster-dem"||ie.isSourceLoaded&&(this.off("data",z),this.growTerrain(b))}),W=()=>{this.isTerrainEnabled=!0,this.terrainExaggeration=b,this.on("data",z),this.addSource(Fi.terrainSourceId,{type:"raster-dem",url:Fi.terrainSourceURL}),this.setTerrain({source:Fi.terrainSourceId,exaggeration:0})};if(this.getTerrain()){this.isTerrainEnabled=!0,this.growTerrain(b);return}this.loaded()||this.isTerrainEnabled?W():this.once("load",()=>{this.getTerrain()&&this.getSource(Fi.terrainSourceId)||W()})}disableTerrain(){if(!this.terrain)return;this.isTerrainEnabled=!1;const b=1*1e3,z=performance.now(),W=this.terrain.exaggeration,ie=()=>{if(!this.terrain||this.terrainGrowing)return;const de=(performance.now()-z)/b;if(de<.99){const he=Math.pow(1-de,4),h=W*he;this.terrain.exaggeration=h,requestAnimationFrame(ie)}else this.terrain.exaggeration=0,this.terrainGrowing=!1,this.terrainFlattening=!1,this.setTerrain(null),this.getSource(Fi.terrainSourceId)&&this.removeSource(Fi.terrainSourceId);this.triggerRepaint()};this.terrainGrowing=!1,this.terrainFlattening=!0,requestAnimationFrame(ie)}setTerrainExaggeration(b,z=!0){!z&&this.terrain?(this.terrainExaggeration=b,this.terrain.exaggeration=b,this.triggerRepaint()):this.enableTerrain(b)}onStyleReady(b){this.isStyleLoaded()?b():this.once("styledata",()=>{b()})}fitToIpBounds(){return un(this,null,function*(){const b=yield Gl.info();this.fitBounds(b.country_bounds,{duration:0,padding:100})})}centerOnIpPoint(b){return un(this,null,function*(){const z=yield Gl.info();this.jumpTo({center:[z.longitude,z.latitude],zoom:b||11})})}getCameraHash(){const b=new Float32Array(5),z=this.getCenter();return b[0]=z.lng,b[1]=z.lat,b[2]=this.getZoom(),b[3]=this.getPitch(),b[4]=this.getBearing(),Sd.fromUint8Array(new Uint8Array(b.buffer))}getSdkConfig(){return pr}getMaptilerSessionId(){return Yh}};class Pp extends nt.Marker{addTo(b){return super.addTo(b)}}class kp extends nt.Popup{addTo(b){return super.addTo(b)}}class zp extends nt.Style{constructor(b,z={}){super(b,z)}}class Lp extends nt.CanvasSource{onAdd(b){super.onAdd(b)}}class Dp extends nt.GeoJSONSource{onAdd(b){super.onAdd(b)}}class Rp extends nt.ImageSource{onAdd(b){super.onAdd(b)}}class Bp extends nt.RasterTileSource{onAdd(b){super.onAdd(b)}}class Fp extends nt.RasterDEMTileSource{onAdd(b){super.onAdd(b)}}class Op extends nt.VectorTileSource{onAdd(b){super.onAdd(b)}}class Up extends nt.VideoSource{onAdd(b){super.onAdd(b)}}class Vp extends nt.TerrainControl{onAdd(b){return super.onAdd(b)}}class hs{constructor(b,z){this.x=b,this.y=z}_matMult(b){const z=b[0]*this.x+b[1]*this.y,W=b[2]*this.x+b[3]*this.y;return this.x=z,this.y=W,this}_add(b){return this.x+=b.x,this.y+=b.y,this}_sub(b){return this.x-=b.x,this.y-=b.y,this}_mult(b){return this.x*=b,this.y*=b,this}_div(b){return this.x/=b,this.y/=b,this}_multByPoint(b){return this.x*=b.x,this.y*=b.y,this}_divByPoint(b){return this.x/=b.x,this.y/=b.y,this}_unit(){return this._div(this.mag()),this}_perp(){const b=this.y;return this.y=this.x,this.x=-b,this}_rotate(b){const z=Math.cos(b),W=Math.sin(b),ie=z*this.x-W*this.y,de=W*this.x+z*this.y;return this.x=ie,this.y=de,this}_rotateAround(b,z){const W=Math.cos(b),ie=Math.sin(b),de=z.x+W*(this.x-z.x)-ie*(this.y-z.y),he=z.y+ie*(this.x-z.x)+W*(this.y-z.y);return this.x=de,this.y=he,this}_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}clone(){return new hs(this.x,this.y)}add(b){return this.clone()._add(b)}sub(b){return this.clone()._sub(b)}multByPoint(b){return this.clone()._multByPoint(b)}divByPoint(b){return this.clone()._divByPoint(b)}mult(b){return this.clone()._mult(b)}div(b){return this.clone()._div(b)}rotate(b){return this.clone()._rotate(b)}rotateAround(b,z){return this.clone()._rotateAround(b,z)}matMult(b){return this.clone()._matMult(b)}unit(){return this.clone()._unit()}perp(){return this.clone()._perp()}round(){return this.clone()._round()}mag(){return Math.sqrt(this.x*this.x+this.y*this.y)}equals(b){return this.x===b.x&&this.y===b.y}dist(b){return Math.sqrt(this.distSqr(b))}distSqr(b){const z=b.x-this.x,W=b.y-this.y;return z*z+W*W}angle(){return Math.atan2(this.y,this.x)}angleTo(b){return Math.atan2(this.y-b.y,this.x-b.x)}angleWith(b){return this.angleWithSep(b.x,b.y)}angleWithSep(b,z){return Math.atan2(this.x*z-this.y*b,this.x*b+this.y*z)}static convert(b){return b instanceof hs?b:Array.isArray(b)?new hs(b[0],b[1]):b}}const{supported:Np,setRTLTextPlugin:$p,getRTLTextPluginStatus:Gp,LngLat:jp,LngLatBounds:qp,MercatorCoordinate:Zp,Evented:Xp,AJAXError:Wp,prewarm:Hp,clearPrewarmedResources:Kp,version:Yp,workerCount:Jp,maxParallelImageRequests:Qp,workerUrl:em,addProtocol:tm,removeProtocol:im}=nt,rm=nt.Map,nm=nt.Marker,am=nt.Popup,sm=nt.Style,om=nt.CanvasSource,lm=nt.GeoJSONSource,cm=nt.ImageSource,hm=nt.RasterTileSource,um=nt.RasterDEMTileSource,dm=nt.VectorTileSource,pm=nt.VideoSource;nt.NavigationControl,nt.GeolocateControl,nt.AttributionControl,nt.LogoControl,nt.ScaleControl,nt.FullscreenControl,nt.TerrainControl,Ve.AJAXError=Wp,Ve.AttributionControl=Zh,Ve.CanvasSource=Lp,Ve.CanvasSourceMLGL=om,Ve.Evented=Xp,Ve.FullscreenControl=Wh,Ve.GeoJSONSource=Dp,Ve.GeoJSONSourceMLGL=lm,Ve.GeolocateControl=Vh,Ve.GeolocationType=Jh,Ve.ImageSource=Rp,Ve.ImageSourceMLGL=cm,Ve.Language=Sr,Ve.LanguageGeocoding=cs,Ve.LngLat=jp,Ve.LngLatBounds=qp,Ve.LogoControl=Bh,Ve.Map=Mp,Ve.MapMLGL=rm,Ve.MapStyle=ql,Ve.MapStyleVariant=zo,Ve.MaptilerGeolocateControl=qh,Ve.MaptilerLogoControl=Hl,Ve.MaptilerTerrainControl=Oh,Ve.Marker=Pp,Ve.MarkerMLGL=nm,Ve.MercatorCoordinate=Zp,Ve.NavigationControl=Uh,Ve.Point=hs,Ve.Popup=kp,Ve.PopupMLGL=am,Ve.RasterDEMTileSource=Fp,Ve.RasterDEMTileSourceMLGL=um,Ve.RasterTileSource=Bp,Ve.RasterTileSourceMLGL=hm,Ve.ReferenceMapStyle=Lo,Ve.ScaleControl=Xh,Ve.SdkConfig=Rh,Ve.ServiceError=hn,Ve.Style=zp,Ve.StyleMLGL=sm,Ve.TerrainControl=Vp,Ve.VectorTileSource=Op,Ve.VectorTileSourceMLGL=dm,Ve.VideoSource=Up,Ve.VideoSourceMLGL=pm,Ve.addProtocol=tm,Ve.clearPrewarmedResources=Kp,Ve.config=pr,Ve.coordinates=Jd,Ve.data=tp,Ve.geocoding=Xd,Ve.geolocation=Gl,Ve.getRTLTextPluginStatus=Gp,Ve.maxParallelImageRequests=Qp,Ve.prewarm=Hp,Ve.removeProtocol=im,Ve.setRTLTextPlugin=$p,Ve.staticMaps=hp,Ve.supported=Np,Ve.version=Yp,Ve.workerCount=Jp,Ve.workerUrl=em});
579
+ `,document.addEventListener("keydown",s=>{s.key===t&&(this._metaPress=!0)}),document.addEventListener("keyup",s=>{s.key===t&&(this._metaPress=!1)}),this._canvasContainer.addEventListener("wheel",s=>{this._onCooperativeGesture(s,this._metaPress,1)},!1),this._canvasContainer.classList.remove("maplibregl-touch-drag-pan")}_resizeCanvas(o,t,n){this._canvas.width=n*o,this._canvas.height=n*t,this._canvas.style.width=`${o}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const o=h.extend({},ve.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1});let t=null;this._canvas.addEventListener("webglcontextcreationerror",s=>{t={requestedAttributes:o},s&&(t.statusMessage=s.statusMessage,t.type=s.type)},{once:!0});const n=this._canvas.getContext("webgl",o)||this._canvas.getContext("experimental-webgl",o);if(!n){const s="Failed to initialize WebGL";throw t?(t.message=s,new Error(JSON.stringify(t))):new Error(s)}this.painter=new zr(n,this.transform),Be.testSupport(n)}_contextLost(o){o.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new h.Event("webglcontextlost",{originalEvent:o}))}_contextRestored(o){this._setupPainter(),this.resize(),this._update(),this.fire(new h.Event("webglcontextrestored",{originalEvent:o}))}_onMapScroll(o){if(o.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}_onCooperativeGesture(o,t,n){return!t&&n<2&&(this._cooperativeGesturesScreen.classList.add("maplibregl-show"),setTimeout(()=>{this._cooperativeGesturesScreen.classList.remove("maplibregl-show")},100)),!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(o){return this.style?(this._styleDirty=this._styleDirty||o,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(o){return this._update(),this._renderTaskQueue.add(o)}_cancelRenderFrame(o){this._renderTaskQueue.remove(o)}_render(o){let t,n=0;const s=this.painter.context.extTimerQuery;if(this.listens("gpu-timing-frame")&&(t=s.createQueryEXT(),s.beginQueryEXT(s.TIME_ELAPSED_EXT,t),n=h.exported.now()),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(o),this._removed)return;let l=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const m=this.transform.zoom,g=h.exported.now();this.style.zoomHistory.update(m,g);const y=new h.EvaluationParameters(m,{now:g,fadeDuration:this._fadeDuration,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),x=y.crossFadingFactor();x===1&&x===this._crossFadingFactor||(l=!0,this._crossFadingFactor=x),this.style.update(y)}if(this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain&&this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.updateElevation(this.terrain),this._imageQueueDirty=Qt.processQueue()>0,this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,this._fadeDuration,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:this._fadeDuration,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer")}),this.fire(new h.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,h.PerformanceUtils.mark(h.PerformanceMarkers.load),this.fire(new h.Event("load"))),this.style&&(this.style.hasTransitions()||l)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const m=h.exported.now()-n;s.endQueryEXT(s.TIME_ELAPSED_EXT,t),setTimeout(()=>{const g=s.getQueryObjectEXT(t,s.QUERY_RESULT_EXT)/1e6;s.deleteQueryEXT(t),this.fire(new h.Event("gpu-timing-frame",{cpuTime:m,gpuTime:g}))},50)}if(this.listens("gpu-timing-layer")){const m=this.painter.collectGpuTimers();setTimeout(()=>{const g=this.painter.queryGpuTimers(m);this.fire(new h.Event("gpu-timing-layer",{layerTimes:g}))},50)}const d=this._sourcesDirty||this._styleDirty||this._placementDirty||this._imageQueueDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new h.Event("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,h.PerformanceUtils.mark(h.PerformanceMarkers.fullLoad)),this}redraw(){return this.style&&(this._frame&&(this._frame.cancel(),this._frame=null),this._render(0)),this}remove(){this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&(removeEventListener("resize",this._onWindowResize,!1),removeEventListener("orientationchange",this._onWindowResize,!1),removeEventListener("online",this._onWindowOnline,!1)),Qt.removeThrottleControl(this._imageQueueHandle);const o=this.painter.context.gl.getExtension("WEBGL_lose_context");o&&o.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),ee.remove(this._canvasContainer),ee.remove(this._controlContainer),this._cooperativeGestures&&ee.remove(this._cooperativeGesturesScreen),this._container.classList.remove("maplibregl-map"),h.PerformanceUtils.clearMetrics(),this._removed=!0,this.fire(new h.Event("remove"))}triggerRepaint(){this.style&&!this._frame&&(this._frame=h.exported.frame(o=>{h.PerformanceUtils.frame(o),this._frame=null,this._render(o)}))}_onWindowOnline(){this._update()}_onWindowResize(o){this._trackResize&&this.resize({originalEvent:o})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(o){this._showTileBoundaries!==o&&(this._showTileBoundaries=o,this._update())}get showPadding(){return!!this._showPadding}set showPadding(o){this._showPadding!==o&&(this._showPadding=o,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(o){this._showCollisionBoxes!==o&&(this._showCollisionBoxes=o,o?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(o){this._showOverdrawInspector!==o&&(this._showOverdrawInspector=o,this._update())}get repaint(){return!!this._repaint}set repaint(o){this._repaint!==o&&(this._repaint=o,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(o){this._vertices=o,this._update()}get version(){return to}getCameraTargetElevation(){return this.transform.elevation}},NavigationControl:class{constructor(o){this.options=h.extend({},ro,o),this._container=ee.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(h.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",t=>this._map.zoomIn({},{originalEvent:t})),ee.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",t=>this._map.zoomOut({},{originalEvent:t})),ee.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(h.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("maplibregl-ctrl-compass",t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})}),this._compassIcon=ee.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const o=this._map.getZoom(),t=o===this._map.getMaxZoom(),n=o===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",n.toString())}_rotateCompassArrow(){const o=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=o}onAdd(o){return this._map=o,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new pl(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){ee.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(o,t){const n=ee.create("button",o,this._container);return n.type="button",n.addEventListener("click",t),n}_setButtonTitle(o,t){const n=this._map._getUIString(`NavigationControl.${t}`);o.title=n,o.setAttribute("aria-label",n)}},GeolocateControl:class extends h.Evented{constructor(o){super(),this.options=h.extend({},ml,o),h.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker"],this)}onAdd(o){var t;return this._map=o,this._container=ee.create("div","maplibregl-ctrl maplibregl-ctrl-group"),t=this._setupUI,rn!==void 0?t(rn):window.navigator.permissions!==void 0?window.navigator.permissions.query({name:"geolocation"}).then(n=>{rn=n.state!=="denied",t(rn)}):(rn=!!window.navigator.geolocation,t(rn)),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(),ee.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,na=0,Rn=!1}_isOutOfMapMaxBounds(o){const t=this._map.getMaxBounds(),n=o.coords;return t&&(n.longitude<t.getWest()||n.longitude>t.getEast()||n.latitude<t.getSouth()||n.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_onSuccess(o){if(this._map){if(this._isOutOfMapMaxBounds(o))return this._setErrorState(),this.fire(new h.Event("outofmaxbounds",o)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=o,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(o),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(o),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new h.Event("geolocate",o)),this._finish()}}_updateCamera(o){const t=new h.LngLat(o.coords.longitude,o.coords.latitude),n=o.coords.accuracy,s=this._map.getBearing(),l=h.extend({bearing:s},this.options.fitBoundsOptions);this._map.fitBounds(t.toBounds(n),l,{geolocateSource:!0})}_updateMarker(o){if(o){const t=new h.LngLat(o.coords.longitude,o.coords.latitude);this._accuracyCircleMarker.setLngLat(t).addTo(this._map),this._userLocationDotMarker.setLngLat(t).addTo(this._map),this._accuracy=o.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const o=this._map._container.clientHeight/2,t=this._map.unproject([0,o]),n=this._map.unproject([1,o]),s=t.distanceTo(n),l=Math.ceil(2*this._accuracy/s);this._circleElement.style.width=`${l}px`,this._circleElement.style.height=`${l}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_onError(o){if(this._map){if(this.options.trackUserLocation)if(o.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 t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(o.code===3&&Rn)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new h.Event("error",o)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(o){if(this._container.addEventListener("contextmenu",t=>t.preventDefault()),this._geolocateButton=ee.create("button","maplibregl-ctrl-geolocate",this._container),ee.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",o===!1){h.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=ee.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ha(this._dotElement),this._circleElement=ee.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ha({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",t=>{t.geolocateSource||this._watchState!=="ACTIVE_LOCK"||t.originalEvent&&t.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 h.Event("trackuserlocationend")))})}trigger(){if(!this._setup)return h.warnOnce("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 h.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":na--,Rn=!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 h.Event("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 h.Event("trackuserlocationstart"));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 o;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),na++,na>1?(o={maximumAge:6e5,timeout:0},Rn=!0):(o=this.options.positionOptions,Rn=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,o)}}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)}},AttributionControl:Ga,LogoControl:ja,ScaleControl:class{constructor(o){this.options=h.extend({},fl,o),h.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){so(this._map,this._container,this.options)}onAdd(o){return this._map=o,this._container=ee.create("div","maplibregl-ctrl maplibregl-ctrl-scale",o.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){ee.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}setUnit(o){this.options.unit=o,so(this._map,this._container,this.options)}},FullscreenControl:class extends h.Evented{constructor(o={}){super(),this._onFullscreenChange=()=>{(window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement)===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,o&&o.container&&(o.container instanceof HTMLElement?this._container=o.container:h.warnOnce("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(o){return this._map=o,this._container||(this._container=this._map.getContainer()),this._controlContainer=ee.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){ee.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const o=this._fullscreenButton=ee.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);ee.create("span","maplibregl-ctrl-icon",o).setAttribute("aria-hidden","true"),o.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const o=this._getTitle();this._fullscreenButton.setAttribute("aria-label",o),this._fullscreenButton.title=o}_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.fire(new h.Event(this._fullscreen?"fullscreenstart":"fullscreenend"))}_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()}},TerrainControl:class{constructor(o){this.options=o,h.bindAll(["_toggleTerrain","_updateTerrainIcon"],this)}onAdd(o){return this._map=o,this._container=ee.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=ee.create("button","maplibregl-ctrl-terrain",this._container),ee.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(){ee.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}_toggleTerrain(){this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()}_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.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))}},Popup:class extends h.Evented{constructor(o){super(),this.options=h.extend(Object.create(uc),o),h.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag"],this)}addTo(o){return this._map&&this.remove(),this._map=o,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 h.Event("open")),this}isOpen(){return!!this._map}remove(){return this._content&&ee.remove(this._content),this._container&&(ee.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),delete this._map),this.fire(new h.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(o){return this._lngLat=h.LngLat.convert(o),this._pos=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._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(o){return this.setDOMContent(document.createTextNode(o))}setHTML(o){const t=document.createDocumentFragment(),n=document.createElement("body");let s;for(n.innerHTML=o;s=n.firstChild,s;)t.appendChild(s);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(o){return this.options.maxWidth=o,this._update(),this}setDOMContent(o){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=ee.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(o),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(o){this._container&&this._container.classList.add(o)}removeClassName(o){this._container&&this._container.classList.remove(o)}setOffset(o){return this.options.offset=o,this._update(),this}toggleClassName(o){if(this._container)return this._container.classList.toggle(o)}_createCloseButton(){this.options.closeButton&&(this._closeButton=ee.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_onMouseUp(o){this._update(o.point)}_onMouseMove(o){this._update(o.point)}_onDrag(o){this._update(o.point)}_update(o){if(!this._map||!this._lngLat&&!this._trackPointer||!this._content||(this._container||(this._container=ee.create("div","maplibregl-popup",this._map.getContainer()),this._tip=ee.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className&&this.options.className.split(" ").forEach(d=>this._container.classList.add(d)),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")),this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=no(this._lngLat,this._pos,this._map.transform)),this._trackPointer&&!o))return;const t=this._pos=this._trackPointer&&o?o:this._map.project(this._lngLat);let n=this.options.anchor;const s=gl(this.options.offset);if(!n){const d=this._container.offsetWidth,m=this._container.offsetHeight;let g;g=t.y+s.bottom.y<m?["top"]:t.y>this._map.transform.height-m?["bottom"]:[],t.x<d/2?g.push("left"):t.x>this._map.transform.width-d/2&&g.push("right"),n=g.length===0?"bottom":g.join("-")}const l=t.add(s[n]).round();ee.setTransform(this._container,`${Wa[n]} translate(${l.x}px,${l.y}px)`),ao(this._container,n,"popup")}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const o=this._container.querySelector(dc);o&&o.focus()}_onClose(){this.remove()}},Marker:Ha,Style:Ni,LngLat:h.LngLat,LngLatBounds:h.LngLatBounds,Point:h.pointGeometry,MercatorCoordinate:h.MercatorCoordinate,Evented:h.Evented,AJAXError:h.AJAXError,config:h.config,CanvasSource:pi,GeoJSONSource:Gn,ImageSource:bt,RasterDEMTileSource:Se,RasterTileSource:Ir,VectorTileSource:Gr,VideoSource:Wi,prewarm:function(){gn().acquire(qr)},clearPrewarmedResources:function(){const o=yt;o&&(o.isPreloaded()&&o.numActive()===1?(o.release(qr),yt=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()"))},get version(){return pc},get workerCount(){return Mi.workerCount},set workerCount(o){Mi.workerCount=o},get maxParallelImageRequests(){return h.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(o){h.config.MAX_PARALLEL_IMAGE_REQUESTS=o},workerUrl:"",addProtocol(o,t){h.config.REGISTERED_PROTOCOLS[o]=t},removeProtocol(o){delete h.config.REGISTERED_PROTOCOLS[o]}};return Ws.extend(Dr,{isSafari:h.isSafari,getPerformanceMetrics:h.PerformanceUtils.getPerformanceMetrics}),Dr});var he=ie;return he})})(Jc);var pd=Jc.exports,nt=Yc(pd);const Qc="3.7.5",md=Qc,fd=typeof atob=="function",gd=typeof btoa=="function",ca=typeof Buffer=="function",eh=typeof TextDecoder=="function"?new TextDecoder:void 0,th=typeof TextEncoder=="function"?new TextEncoder:void 0,_d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",ls=Array.prototype.slice.call(_d),Io=(A=>{let b={};return A.forEach((z,W)=>b[z]=W),b})(ls),yd=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,hi=String.fromCharCode.bind(String),ih=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):A=>new Uint8Array(Array.prototype.slice.call(A,0)),rh=A=>A.replace(/=/g,"").replace(/[+\/]/g,b=>b=="+"?"-":"_"),nh=A=>A.replace(/[^A-Za-z0-9\+\/]/g,""),ah=A=>{let b,z,W,ie,de="";const he=A.length%3;for(let h=0;h<A.length;){if((z=A.charCodeAt(h++))>255||(W=A.charCodeAt(h++))>255||(ie=A.charCodeAt(h++))>255)throw new TypeError("invalid character found");b=z<<16|W<<8|ie,de+=ls[b>>18&63]+ls[b>>12&63]+ls[b>>6&63]+ls[b&63]}return he?de.slice(0,he-3)+"===".substring(he):de},Rl=gd?A=>btoa(A):ca?A=>Buffer.from(A,"binary").toString("base64"):ah,Bl=ca?A=>Buffer.from(A).toString("base64"):A=>{let z=[];for(let W=0,ie=A.length;W<ie;W+=4096)z.push(hi.apply(null,A.subarray(W,W+4096)));return Rl(z.join(""))},Ao=(A,b=!1)=>b?rh(Bl(A)):Bl(A),xd=A=>{if(A.length<2){var b=A.charCodeAt(0);return b<128?A:b<2048?hi(192|b>>>6)+hi(128|b&63):hi(224|b>>>12&15)+hi(128|b>>>6&63)+hi(128|b&63)}else{var b=65536+(A.charCodeAt(0)-55296)*1024+(A.charCodeAt(1)-56320);return hi(240|b>>>18&7)+hi(128|b>>>12&63)+hi(128|b>>>6&63)+hi(128|b&63)}},vd=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,sh=A=>A.replace(vd,xd),oh=ca?A=>Buffer.from(A,"utf8").toString("base64"):th?A=>Bl(th.encode(A)):A=>Rl(sh(A)),ha=(A,b=!1)=>b?rh(oh(A)):oh(A),lh=A=>ha(A,!0),bd=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,wd=A=>{switch(A.length){case 4:var b=(7&A.charCodeAt(0))<<18|(63&A.charCodeAt(1))<<12|(63&A.charCodeAt(2))<<6|63&A.charCodeAt(3),z=b-65536;return hi((z>>>10)+55296)+hi((z&1023)+56320);case 3:return hi((15&A.charCodeAt(0))<<12|(63&A.charCodeAt(1))<<6|63&A.charCodeAt(2));default:return hi((31&A.charCodeAt(0))<<6|63&A.charCodeAt(1))}},ch=A=>A.replace(bd,wd),hh=A=>{if(A=A.replace(/\s+/g,""),!yd.test(A))throw new TypeError("malformed base64.");A+="==".slice(2-(A.length&3));let b,z="",W,ie;for(let de=0;de<A.length;)b=Io[A.charAt(de++)]<<18|Io[A.charAt(de++)]<<12|(W=Io[A.charAt(de++)])<<6|(ie=Io[A.charAt(de++)]),z+=W===64?hi(b>>16&255):ie===64?hi(b>>16&255,b>>8&255):hi(b>>16&255,b>>8&255,b&255);return z},Fl=fd?A=>atob(nh(A)):ca?A=>Buffer.from(A,"base64").toString("binary"):hh,uh=ca?A=>ih(Buffer.from(A,"base64")):A=>ih(Fl(A).split("").map(b=>b.charCodeAt(0))),dh=A=>uh(ph(A)),Td=ca?A=>Buffer.from(A,"base64").toString("utf8"):eh?A=>eh.decode(uh(A)):A=>ch(Fl(A)),ph=A=>nh(A.replace(/[-_]/g,b=>b=="-"?"+":"/")),Ol=A=>Td(ph(A)),Sd=A=>{if(typeof A!="string")return!1;const b=A.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(b)||!/[^\s0-9a-zA-Z\-_]/.test(b)},mh=A=>({value:A,enumerable:!1,writable:!0,configurable:!0}),fh=function(){const A=(b,z)=>Object.defineProperty(String.prototype,b,mh(z));A("fromBase64",function(){return Ol(this)}),A("toBase64",function(b){return ha(this,b)}),A("toBase64URI",function(){return ha(this,!0)}),A("toBase64URL",function(){return ha(this,!0)}),A("toUint8Array",function(){return dh(this)})},gh=function(){const A=(b,z)=>Object.defineProperty(Uint8Array.prototype,b,mh(z));A("toBase64",function(b){return Ao(this,b)}),A("toBase64URI",function(){return Ao(this,!0)}),A("toBase64URL",function(){return Ao(this,!0)})},Ed={version:Qc,VERSION:md,atob:Fl,atobPolyfill:hh,btoa:Rl,btoaPolyfill:ah,fromBase64:Ol,toBase64:ha,encode:ha,encodeURI:lh,encodeURL:lh,utob:sh,btou:ch,decode:Ol,isValid:Sd,fromUint8Array:Ao,toUint8Array:dh,extendString:fh,extendUint8Array:gh,extendBuiltins:()=>{fh(),gh()}};let Co;const Id=new Uint8Array(16);function Ad(){if(!Co&&(Co=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Co))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Co(Id)}const ui=[];for(let A=0;A<256;++A)ui.push((A+256).toString(16).slice(1));function Cd(A,b=0){return(ui[A[b+0]]+ui[A[b+1]]+ui[A[b+2]]+ui[A[b+3]]+"-"+ui[A[b+4]]+ui[A[b+5]]+"-"+ui[A[b+6]]+ui[A[b+7]]+"-"+ui[A[b+8]]+ui[A[b+9]]+"-"+ui[A[b+10]]+ui[A[b+11]]+ui[A[b+12]]+ui[A[b+13]]+ui[A[b+14]]+ui[A[b+15]]).toLowerCase()}var _h={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Md(A,b,z){if(_h.randomUUID&&!b&&!A)return _h.randomUUID();A=A||{};const W=A.random||(A.rng||Ad)();if(W[6]=W[6]&15|64,W[8]=W[8]&63|128,b){z=z||0;for(let ie=0;ie<16;++ie)b[z+ie]=W[ie];return b}return Cd(W)}var Ul={exports:{}},ua=typeof Reflect=="object"?Reflect:null,yh=ua&&typeof ua.apply=="function"?ua.apply:function(b,z,W){return Function.prototype.apply.call(b,z,W)},Mo;ua&&typeof ua.ownKeys=="function"?Mo=ua.ownKeys:Object.getOwnPropertySymbols?Mo=function(b){return Object.getOwnPropertyNames(b).concat(Object.getOwnPropertySymbols(b))}:Mo=function(b){return Object.getOwnPropertyNames(b)};function Pd(A){console&&console.warn&&console.warn(A)}var xh=Number.isNaN||function(b){return b!==b};function At(){At.init.call(this)}Ul.exports=At,Ul.exports.once=Dd,At.EventEmitter=At,At.prototype._events=void 0,At.prototype._eventsCount=0,At.prototype._maxListeners=void 0;var vh=10;function Po(A){if(typeof A!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof A)}Object.defineProperty(At,"defaultMaxListeners",{enumerable:!0,get:function(){return vh},set:function(A){if(typeof A!="number"||A<0||xh(A))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+A+".");vh=A}}),At.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},At.prototype.setMaxListeners=function(b){if(typeof b!="number"||b<0||xh(b))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+b+".");return this._maxListeners=b,this};function bh(A){return A._maxListeners===void 0?At.defaultMaxListeners:A._maxListeners}At.prototype.getMaxListeners=function(){return bh(this)},At.prototype.emit=function(b){for(var z=[],W=1;W<arguments.length;W++)z.push(arguments[W]);var ie=b==="error",de=this._events;if(de!==void 0)ie=ie&&de.error===void 0;else if(!ie)return!1;if(ie){var he;if(z.length>0&&(he=z[0]),he instanceof Error)throw he;var h=new Error("Unhandled error."+(he?" ("+he.message+")":""));throw h.context=he,h}var ve=de[b];if(ve===void 0)return!1;if(typeof ve=="function")yh(ve,this,z);else for(var Ge=ve.length,et=Ih(ve,Ge),W=0;W<Ge;++W)yh(et[W],this,z);return!0};function wh(A,b,z,W){var ie,de,he;if(Po(z),de=A._events,de===void 0?(de=A._events=Object.create(null),A._eventsCount=0):(de.newListener!==void 0&&(A.emit("newListener",b,z.listener?z.listener:z),de=A._events),he=de[b]),he===void 0)he=de[b]=z,++A._eventsCount;else if(typeof he=="function"?he=de[b]=W?[z,he]:[he,z]:W?he.unshift(z):he.push(z),ie=bh(A),ie>0&&he.length>ie&&!he.warned){he.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+he.length+" "+String(b)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=A,h.type=b,h.count=he.length,Pd(h)}return A}At.prototype.addListener=function(b,z){return wh(this,b,z,!1)},At.prototype.on=At.prototype.addListener,At.prototype.prependListener=function(b,z){return wh(this,b,z,!0)};function kd(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Th(A,b,z){var W={fired:!1,wrapFn:void 0,target:A,type:b,listener:z},ie=kd.bind(W);return ie.listener=z,W.wrapFn=ie,ie}At.prototype.once=function(b,z){return Po(z),this.on(b,Th(this,b,z)),this},At.prototype.prependOnceListener=function(b,z){return Po(z),this.prependListener(b,Th(this,b,z)),this},At.prototype.removeListener=function(b,z){var W,ie,de,he,h;if(Po(z),ie=this._events,ie===void 0)return this;if(W=ie[b],W===void 0)return this;if(W===z||W.listener===z)--this._eventsCount===0?this._events=Object.create(null):(delete ie[b],ie.removeListener&&this.emit("removeListener",b,W.listener||z));else if(typeof W!="function"){for(de=-1,he=W.length-1;he>=0;he--)if(W[he]===z||W[he].listener===z){h=W[he].listener,de=he;break}if(de<0)return this;de===0?W.shift():zd(W,de),W.length===1&&(ie[b]=W[0]),ie.removeListener!==void 0&&this.emit("removeListener",b,h||z)}return this},At.prototype.off=At.prototype.removeListener,At.prototype.removeAllListeners=function(b){var z,W,ie;if(W=this._events,W===void 0)return this;if(W.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):W[b]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete W[b]),this;if(arguments.length===0){var de=Object.keys(W),he;for(ie=0;ie<de.length;++ie)he=de[ie],he!=="removeListener"&&this.removeAllListeners(he);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(z=W[b],typeof z=="function")this.removeListener(b,z);else if(z!==void 0)for(ie=z.length-1;ie>=0;ie--)this.removeListener(b,z[ie]);return this};function Sh(A,b,z){var W=A._events;if(W===void 0)return[];var ie=W[b];return ie===void 0?[]:typeof ie=="function"?z?[ie.listener||ie]:[ie]:z?Ld(ie):Ih(ie,ie.length)}At.prototype.listeners=function(b){return Sh(this,b,!0)},At.prototype.rawListeners=function(b){return Sh(this,b,!1)},At.listenerCount=function(A,b){return typeof A.listenerCount=="function"?A.listenerCount(b):Eh.call(A,b)},At.prototype.listenerCount=Eh;function Eh(A){var b=this._events;if(b!==void 0){var z=b[A];if(typeof z=="function")return 1;if(z!==void 0)return z.length}return 0}At.prototype.eventNames=function(){return this._eventsCount>0?Mo(this._events):[]};function Ih(A,b){for(var z=new Array(b),W=0;W<b;++W)z[W]=A[W];return z}function zd(A,b){for(;b+1<A.length;b++)A[b]=A[b+1];A.pop()}function Ld(A){for(var b=new Array(A.length),z=0;z<b.length;++z)b[z]=A[z].listener||A[z];return b}function Dd(A,b){return new Promise(function(z,W){function ie(he){A.removeListener(b,de),W(he)}function de(){typeof A.removeListener=="function"&&A.removeListener("error",ie),z([].slice.call(arguments))}Ah(A,b,de,{once:!0}),b!=="error"&&Rd(A,ie,{once:!0})})}function Rd(A,b,z){typeof A.on=="function"&&Ah(A,"error",b,z)}function Ah(A,b,z,W){if(typeof A.on=="function")W.once?A.once(b,z):A.on(b,z);else if(typeof A.addEventListener=="function")A.addEventListener(b,function ie(de){W.once&&A.removeEventListener(b,ie),z(de)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof A)}var Bd=Ul.exports,Fd=Yc(Bd);const Sr={AUTO:"auto",LATIN:"latin",NON_LATIN:"nonlatin",LOCAL:"",ALBANIAN:"sq",AMHARIC:"am",ARABIC:"ar",ARMENIAN:"hy",AZERBAIJANI:"az",BASQUE:"eu",BELORUSSIAN:"be",BOSNIAN:"bs",BRETON:"br",BULGARIAN:"bg",CATALAN:"ca",CHINESE:"zh",CORSICAN:"co",CROATIAN:"hr",CZECH:"cs",DANISH:"da",DUTCH:"nl",ENGLISH:"en",ESPERANTO:"eo",ESTONIAN:"et",FINNISH:"fi",FRENCH:"fr",FRISIAN:"fy",GEORGIAN:"ka",GERMAN:"de",GREEK:"el",HEBREW:"he",HINDI:"hi",HUNGARIAN:"hu",ICELANDIC:"is",INDONESIAN:"id",IRISH:"ga",ITALIAN:"it",JAPANESE:"ja",JAPANESE_HIRAGANA:"ja-Hira",JAPANESE_KANA:"ja_kana",JAPANESE_LATIN:"ja_rm",JAPANESE_2018:"ja-Latn",KANNADA:"kn",KAZAKH:"kk",KOREAN:"ko",KOREAN_LATIN:"ko-Latn",KURDISH:"ku",ROMAN_LATIN:"la",LATVIAN:"lv",LITHUANIAN:"lt",LUXEMBOURGISH:"lb",MACEDONIAN:"mk",MALAYALAM:"ml",MALTESE:"mt",NORWEGIAN:"no",OCCITAN:"oc",POLISH:"pl",PORTUGUESE:"pt",ROMANIAN:"ro",ROMANSH:"rm",RUSSIAN:"ru",SCOTTISH_GAELIC:"gd",SERBIAN_CYRILLIC:"sr",SERBIAN_LATIN:"sr-Latn",SLOVAK:"sk",SLOVENE:"sl",SPANISH:"es",SWEDISH:"sv",TAMIL:"ta",TELUGU:"te",THAI:"th",TURKISH:"tr",UKRAINIAN:"uk",WELSH:"cy"},Od=new Set(Object.values(Sr));function Ch(A){return Od.has(A)}const Ud=new Set(Object.values(Sr));function Vl(){if(typeof navigator>"u")return Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];const A=Array.from(new Set(navigator.languages.map(b=>b.split("-")[0]))).filter(b=>Ud.has(b));return A.length?A[0]:Sr.LATIN}function Vd(){return typeof self<"u"?fetch.bind(self):typeof global<"u"&&global.fetch?global.fetch:null}class Nd{constructor(){this._apiKey="",this._fetch=Vd()}set apiKey(b){this._apiKey=b}get apiKey(){return this._apiKey}set fetch(b){this._fetch=b}get fetch(){return this._fetch}}const Xi=new Nd,cs={AUTO:"auto",ALBANIAN:"sq",ARABIC:"ar",ARMENIAN:"hy",AZERBAIJANI:"az",BELORUSSIAN:"be",BOSNIAN:"bs",BRETON:"br",BULGARIAN:"bg",CATALAN:"ca",CHINESE:"zh",CROATIAN:"hr",CZECH:"cs",DANISH:"da",DUTCH:"nl",ENGLISH:"en",ESPERANTO:"eo",ESTONIAN:"et",FINNISH:"fi",FRENCH:"fr",FRISIAN:"fy",GEORGIAN:"ka",GERMAN:"de",GREEK:"el",HEBREW:"he",HUNGARIAN:"hu",ICELANDIC:"is",IRISH:"ga",ITALIAN:"it",JAPANESE:"ja",KANNADA:"kn",KAZAKH:"kk",KOREAN:"ko",ROMAN_LATIN:"la",LATVIAN:"lv",LITHUANIAN:"lt",LUXEMBOURGISH:"lb",MACEDONIAN:"mk",MALTESE:"mt",NORWEGIAN:"no",POLISH:"pl",PORTUGUESE:"pt",ROMANIAN:"ro",ROMANSH:"rm",RUSSIAN:"ru",SCOTTISH_GAELIC:"gd",SERBIAN_CYRILLIC:"sr",SLOVAK:"sk",SLOVENE:"sl",SPANISH:"es",SWEDISH:"sv",THAI:"th",TURKISH:"tr",UKRAINIAN:"uk",WELSH:"cy"},$d=new Set(Object.values(cs));function Gd(){if(typeof navigator>"u")return Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];const A=Array.from(new Set(navigator.languages.map(b=>b.split("-")[0]))).filter(b=>$d.has(b));return A.length?A[0]:cs.ENGLISH}var jd=(A,b,z)=>new Promise((W,ie)=>{var de=ve=>{try{h(z.next(ve))}catch(Ge){ie(Ge)}},he=ve=>{try{h(z.throw(ve))}catch(Ge){ie(Ge)}},h=ve=>ve.done?W(ve.value):Promise.resolve(ve.value).then(de,he);h((z=z.apply(A,b)).next())});function Vn(A){return jd(this,arguments,function*(b,z={}){if(Xi.fetch===null)throw new Error("The fetch function was not found. If on NodeJS < 18 please specify the fetch function with config.fetch");if(new URL(b).searchParams.get("key").trim()==="")throw new Error("The MapTiler Cloud API key is missing. Set it in `config.apiKey` or get one for free at https://maptiler.com");return Xi.fetch(b,z)})}const dr={maptilerApiURL:"https://api.maptiler.com/",mapStyle:"streets-v2"};Object.freeze(dr);class hn extends Error{constructor(b,z=""){super(`Call to enpoint ${b.url} failed with the status code ${b.status}. ${z}`),this.res=b}}var Nl=(A,b,z)=>new Promise((W,ie)=>{var de=ve=>{try{h(z.next(ve))}catch(Ge){ie(Ge)}},he=ve=>{try{h(z.throw(ve))}catch(Ge){ie(Ge)}},h=ve=>ve.done?W(ve.value):Promise.resolve(ve.value).then(de,he);h((z=z.apply(A,b)).next())});const $l={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function Mh(A,b){if(b.language==null)return;const z=Array.from(new Set((Array.isArray(b.language)?b.language:[b.language]).map(W=>W===cs.AUTO?Gd():W))).join(",");A.set("language",z)}function Ph(A,b){var z;A.set("key",(z=b.apiKey)!=null?z:Xi.apiKey),b.limit!=null&&A.set("limit",String(b.limit)),b.types!=null&&A.set("types",b.types.join(",")),Mh(A,b)}function qd(A){return Nl(this,arguments,function*(b,z={}){var W;if(typeof b!="string"||b.trim().length===0)throw new Error("The query must be a non-empty string");const ie=new URL(`geocoding/${encodeURIComponent(b)}.json`,dr.maptilerApiURL),{searchParams:de}=ie;Ph(de,z),z.bbox!=null&&de.set("bbox",z.bbox.join(",")),z.proximity!=null&&de.set("proximity",z.proximity.join(",")),z.country!=null&&de.set("country",z.country.join(",")),z.fuzzyMatch!=null&&de.set("fuzzyMatch",z.fuzzyMatch?"true":"false"),z.autocomplete!=null&&de.set("autocomplete",z.autocomplete?"true":"false");const he=ie.toString(),h=yield Vn(he);if(!h.ok)throw new hn(h,(W=$l[h.status])!=null?W:"");return yield h.json()})}function Zd(A){return Nl(this,arguments,function*(b,z={}){var W;if(!Array.isArray(b)||b.length<2)throw new Error("The position must be an array of form [lng, lat].");const ie=new URL(`geocoding/${b[0]},${b[1]}.json`,dr.maptilerApiURL);Ph(ie.searchParams,z);const de=ie.toString(),he=yield Vn(de);if(!he.ok)throw new hn(he,(W=$l[he.status])!=null?W:"");return yield he.json()})}function Xd(A){return Nl(this,arguments,function*(b,z={}){var W;const ie=new URL(`geocoding/${b}.json`,dr.maptilerApiURL);Mh(ie.searchParams,z);const de=ie.toString(),he=yield Vn(de);if(!he.ok)throw new hn(he,(W=$l[he.status])!=null?W:"");return yield he.json()})}const Wd={forward:qd,reverse:Zd,byId:Xd,language:cs};var Hd=(A,b,z)=>new Promise((W,ie)=>{var de=ve=>{try{h(z.next(ve))}catch(Ge){ie(Ge)}},he=ve=>{try{h(z.throw(ve))}catch(Ge){ie(Ge)}},h=ve=>ve.done?W(ve.value):Promise.resolve(ve.value).then(de,he);h((z=z.apply(A,b)).next())});const kh={403:"Key is missing, invalid or restricted"};function Kd(){return Hd(this,arguments,function*(A={}){var b;const z=new URL("geolocation/ip.json",dr.maptilerApiURL);z.searchParams.set("key",(b=A.apiKey)!=null?b:Xi.apiKey);const W=z.toString(),ie=yield Vn(W);if(!ie.ok)throw new hn(ie,ie.status in kh?kh[ie.status]:"");return yield ie.json()})}const Gl={info:Kd};var zh=(A,b,z)=>new Promise((W,ie)=>{var de=ve=>{try{h(z.next(ve))}catch(Ge){ie(Ge)}},he=ve=>{try{h(z.throw(ve))}catch(Ge){ie(Ge)}},h=ve=>ve.done?W(ve.value):Promise.resolve(ve.value).then(de,he);h((z=z.apply(A,b)).next())});const ko={403:"Key is missing, invalid or restricted"};function Yd(A){return zh(this,arguments,function*(b,z={}){var W;if(typeof b!="string"||b.trim().length===0)throw new Error("The query must be a non-empty string");const ie=new URL(`coordinates/search/${b}.json`,dr.maptilerApiURL);ie.searchParams.set("key",(W=z.apiKey)!=null?W:Xi.apiKey),"limit"in z&&ie.searchParams.set("limit",z.limit.toString()),"transformations"in z&&ie.searchParams.set("transformations",z.transformations.toString()),"exports"in z&&ie.searchParams.set("exports",z.exports.toString());const de=ie.toString(),he=yield Vn(de);if(!he.ok)throw new hn(he,he.status in ko?ko[he.status]:"");return yield he.json()})}function Jd(A){return zh(this,arguments,function*(b,z={}){var W;const ie=(Array.isArray(b[0])?b:[b]).map(Ge=>`${Ge[0]},${Ge[1]}`).join(";"),de=new URL(`coordinates/transform/${ie}.json`,dr.maptilerApiURL);de.searchParams.set("key",(W=z.apiKey)!=null?W:Xi.apiKey),"sourceCrs"in z&&de.searchParams.set("s_srs",z.sourceCrs.toString()),"targetCrs"in z&&de.searchParams.set("t_srs",z.targetCrs.toString()),"operations"in z&&de.searchParams.set("ops",(Array.isArray(z.operations)?z.operations:[z.operations]).join("|"));const he=de.toString(),h=yield Vn(he);if(!h.ok)throw new hn(h,h.status in ko?ko[h.status]:"");return yield h.json()})}const Qd={search:Yd,transform:Jd};var ep=(A,b,z)=>new Promise((W,ie)=>{var de=ve=>{try{h(z.next(ve))}catch(Ge){ie(Ge)}},he=ve=>{try{h(z.throw(ve))}catch(Ge){ie(Ge)}},h=ve=>ve.done?W(ve.value):Promise.resolve(ve.value).then(de,he);h((z=z.apply(A,b)).next())});const Lh={403:"Key is missing, invalid or restricted"};function tp(A){return ep(this,arguments,function*(b,z={}){var W;if(typeof b!="string"||b.trim().length===0)throw new Error("The data ID must be a non-empty string");const ie=new URL(`data/${encodeURIComponent(b)}/features.json`,dr.maptilerApiURL);ie.searchParams.set("key",(W=z.apiKey)!=null?W:Xi.apiKey);const de=ie.toString(),he=yield Vn(de);if(!he.ok)throw new hn(he,he.status in Lh?Lh[he.status]:"");return yield he.json()})}const ip={get:tp};function Dh(A){const b=/^maptiler:\/\/(.*)/;let z;const W=A.trim();let ie;return W.startsWith("http://")||W.startsWith("https://")?ie=W:(z=b.exec(W))!==null?ie=`https://api.maptiler.com/maps/${z[1]}/style.json`:ie=`https://api.maptiler.com/maps/${W}/style.json`,ie}class zo{constructor(b,z,W,ie,de,he){this.name=b,this.variantType=z,this.id=W,this.referenceStyle=ie,this.description=de,this.imageURL=he}getName(){return this.name}getFullName(){return`${this.referenceStyle.getName()} ${this.name}`}getType(){return this.variantType}getId(){return this.id}getDescription(){return this.description}getReferenceStyle(){return this.referenceStyle}hasVariant(b){return this.referenceStyle.hasVariant(b)}getVariant(b){return this.referenceStyle.getVariant(b)}getVariants(){return this.referenceStyle.getVariants().filter(b=>b!==this)}getImageURL(){return this.imageURL}getExpandedStyleURL(){return Dh(this.getId())}}class Lo{constructor(b,z){this.name=b,this.id=z,this.variants={},this.orderedVariants=[]}getName(){return this.name}getId(){return this.id}addVariant(b){this.variants[b.getType()]=b,this.orderedVariants.push(b)}hasVariant(b){return b in this.variants}getVariant(b){return b in this.variants?this.variants[b]:this.orderedVariants[0]}getVariants(){return Object.values(this.variants)}getDefaultVariant(){return this.orderedVariants[0]}}const Do=[{referenceStyleID:"STREETS",name:"Streets",description:"",variants:[{id:"streets-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"streets-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"streets-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"streets-v2-night",name:"Night",variantType:"NIGHT",description:"",imageURL:""},{id:"streets-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"OUTDOOR",name:"Outdoor",description:"",variants:[{id:"outdoor-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"outdoor-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"WINTER",name:"Winter",description:"",variants:[{id:"winter-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"winter-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"SATELLITE",name:"Satellite",description:"",variants:[{id:"satellite",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"HYBRID",name:"Hybrid",description:"",variants:[{id:"hybrid",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"BASIC",name:"Basic",description:"",variants:[{id:"basic-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"basic-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"basic-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"BRIGHT",name:"Bright",description:"",variants:[{id:"bright-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"bright-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"bright-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"bright-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"OPENSTREETMAP",name:"OpenStreetMap",description:"",variants:[{id:"openstreetmap",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"TOPO",name:"Topo",description:"",variants:[{id:"topo-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"topo-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"topo-v2-shiny",name:"Shiny",variantType:"SHINY",description:"",imageURL:""},{id:"topo-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""},{id:"topo-v2-topographique",name:"Topographique",variantType:"TOPOGRAPHIQUE",description:"",imageURL:""}]},{referenceStyleID:"VOYAGER",name:"Voyager",description:"",variants:[{id:"voyager-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"voyager-v2-darkmatter",name:"Darkmatter",variantType:"DARK",description:"",imageURL:""},{id:"voyager-v2-positron",name:"Positron",variantType:"LIGHT",description:"",imageURL:""},{id:"voyager-v2-vintage",name:"Vintage",variantType:"VINTAGE",description:"",imageURL:""}]},{referenceStyleID:"TONER",name:"Toner",description:"",variants:[{id:"toner-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"toner-v2-background",name:"Background",variantType:"BACKGROUND",description:"",imageURL:""},{id:"toner-v2-lite",name:"Lite",variantType:"LITE",description:"",imageURL:""},{id:"toner-v2-lines",name:"Lines",variantType:"LINES",description:"",imageURL:""}]},{referenceStyleID:"DATAVIZ",name:"Dataviz",description:"",variants:[{id:"dataviz",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"dataviz-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"dataviz-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"OCEAN",name:"Ocean",description:"",variants:[{id:"ocean",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]}];function rp(A){return new Proxy(A,{get(b,z,W){return b.hasVariant(z)?b.getVariant(z):z.toString().toUpperCase()===z?A.getDefaultVariant():Reflect.get(b,z,W)}})}function np(){const A={};for(let b=0;b<Do.length;b+=1){const z=Do[b],W=rp(new Lo(z.name,z.referenceStyleID));for(let ie=0;ie<z.variants.length;ie+=1){const de=z.variants[ie],he=new zo(de.name,de.variantType,de.id,W,de.description,de.imageURL);W.addVariant(he)}A[z.referenceStyleID]=W}return A}function jl(A){if(!A)return ql[Do[0].referenceStyleID].getDefaultVariant().getId();if(typeof A=="string"||A instanceof String)return A.trim().toLowerCase();if(A instanceof zo)return A.getId();if(A instanceof Lo)return A.getDefaultVariant().getId()}const ql=np();function ap(A,b,z){let W=b[0],ie=b[1],de=z[0]-W,he=z[1]-ie;if(de!==0||he!==0){const h=((A[0]-W)*de+(A[1]-ie)*he)/(de*de+he*he);h>1?(W=z[0],ie=z[1]):h>0&&(W+=de*h,ie+=he*h)}return de=A[0]-W,he=A[1]-ie,de*de+he*he}function Zl(A,b,z,W,ie){let de=W,he;for(let h=b+1;h<z;h++){const ve=ap(A[h],A[b],A[z]);ve>de&&(he=h,de=ve)}de>W&&(he-b>1&&Zl(A,b,he,W,ie),ie.push(A[he]),z-he>1&&Zl(A,he,z,W,ie))}function sp(A,b){const z=A.length-1,W=[A[0]];return Zl(A,0,z,b,W),W.push(A[z]),W}function op(A,b){if(A.length<=2)return A;const z=b!==void 0?b*b:1;return sp(A,z)}function Xl(A,b=!0){let z=`${A[0]},${A[1]}`;return A.length===3&&b&&(z+=`,${A[2]}`),z}function Wl(A,b=3e3){let z=A.map(de=>de.join(",")).join("|"),W=5e-6;const ie=1e-5;for(;z.length>b;)z=op(A,W).map(he=>`${he[0]},${he[1]}`).join("|"),W+=ie;return z}function lp(A,b,z={}){var W,ie,de,he,h;const ve=jl(z.style),Ge=z.hiDPI?"@2x":"",et=(W=z.format)!=null?W:"png";let Ye=~~((ie=z.width)!=null?ie:1024),pe=~~((de=z.height)!=null?de:1024);z.hiDPI&&(Ye=~~(Ye/2),pe=~~(pe/2));const ee=new URL(`maps/${encodeURIComponent(ve)}/static/${A[0]},${A[1]},${b}/${Ye}x${pe}${Ge}.${et}`,dr.maptilerApiURL);if("attribution"in z&&ee.searchParams.set("attribution",z.attribution.toString()),"markers"in z){let Be="";const Ct="markerIcon"in z;Ct&&(Be+=`icon:${z.markerIcon}|`),Ct&&"markerAnchor"in z&&(Be+=`anchor:${z.markerAnchor}|`),Ct&&z.hiDPI&&(Be+="scale:2|");const Ft=Array.isArray(z.markers[0])?z.markers:[z.markers];Be+=Ft.map(mr=>Xl(mr,!Ct)).join("|"),ee.searchParams.set("markers",Be)}if("path"in z){let Be="";if(Be+=`fill:${(he=z.pathFillColor)!=null?he:"none"}|`,"pathStrokeColor"in z&&(Be+=`stroke:${z.pathStrokeColor}|`),"pathWidth"in z){const Ct=z.pathWidth/(z.hiDPI?2:1);Be+=`width:${Ct.toString()}|`}Be+=Wl(z.path),ee.searchParams.set("path",Be)}return ee.searchParams.set("key",(h=z.apiKey)!=null?h:Xi.apiKey),ee.toString()}function cp(A,b={}){var z,W,ie,de,he;const h=jl(b.style),ve=b.hiDPI?"@2x":"",Ge=(z=b.format)!=null?z:"png";let et=~~((W=b.width)!=null?W:1024),Ye=~~((ie=b.height)!=null?ie:1024);b.hiDPI&&(et=~~(et/2),Ye=~~(Ye/2));const pe=new URL(`maps/${encodeURIComponent(h)}/static/${A[0]},${A[1]},${A[2]},${A[3]}/${et}x${Ye}${ve}.${Ge}`,dr.maptilerApiURL);if("attribution"in b&&pe.searchParams.set("attribution",b.attribution.toString()),"padding"in b&&pe.searchParams.set("padding",b.padding.toString()),"markers"in b){let ee="";const Be="markerIcon"in b;Be&&(ee+=`icon:${b.markerIcon}|`),Be&&"markerAnchor"in b&&(ee+=`anchor:${b.markerAnchor}|`),Be&&b.hiDPI&&(ee+="scale:2|");const Ct=Array.isArray(b.markers[0])?b.markers:[b.markers];ee+=Ct.map(Ft=>Xl(Ft,!Be)).join("|"),pe.searchParams.set("markers",ee)}if("path"in b){let ee="";if(ee+=`fill:${(de=b.pathFillColor)!=null?de:"none"}|`,"pathStrokeColor"in b&&(ee+=`stroke:${b.pathStrokeColor}|`),"pathWidth"in b){const Be=b.pathWidth/(b.hiDPI?2:1);ee+=`width:${Be.toString()}|`}ee+=Wl(b.path),pe.searchParams.set("path",ee)}return pe.searchParams.set("key",(he=b.apiKey)!=null?he:Xi.apiKey),pe.toString()}function hp(A={}){var b,z,W,ie,de;if(!("markers"in A)&&!("path"in A))throw new Error("Automatic static maps require markers and/or path to be created.");const he=jl(A.style),h=A.hiDPI?"@2x":"",ve=(b=A.format)!=null?b:"png";let Ge=~~((z=A.width)!=null?z:1024),et=~~((W=A.height)!=null?W:1024);A.hiDPI&&(Ge=~~(Ge/2),et=~~(et/2));const Ye=new URL(`maps/${encodeURIComponent(he)}/static/auto/${Ge}x${et}${h}.${ve}`,dr.maptilerApiURL);if("attribution"in A&&Ye.searchParams.set("attribution",A.attribution.toString()),"padding"in A&&Ye.searchParams.set("padding",A.padding.toString()),"markers"in A){let pe="";const ee="markerIcon"in A;ee&&(pe+=`icon:${A.markerIcon}|`),ee&&"markerAnchor"in A&&(pe+=`anchor:${A.markerAnchor}|`),ee&&A.hiDPI&&(pe+="scale:2|");const Be=Array.isArray(A.markers[0])?A.markers:[A.markers];pe+=Be.map(Ct=>Xl(Ct,!ee)).join("|"),Ye.searchParams.set("markers",pe)}if("path"in A){let pe="";if(pe+=`fill:${(ie=A.pathFillColor)!=null?ie:"none"}|`,"pathStrokeColor"in A&&(pe+=`stroke:${A.pathStrokeColor}|`),"pathWidth"in A){const ee=A.pathWidth/(A.hiDPI?2:1);pe+=`width:${ee.toString()}|`}pe+=Wl(A.path),Ye.searchParams.set("path",pe)}return Ye.searchParams.set("key",(de=A.apiKey)!=null?de:Xi.apiKey),Ye.toString()}const up={centered:lp,bounded:cp,automatic:hp};let Rh=class extends Fd{constructor(){super(),this.primaryLanguage=Sr.AUTO,this.secondaryLanguage=null,this.session=!0,this._unit="metric",this._apiKey=""}set unit(b){this._unit=b,this.emit("unit",b)}get unit(){return this._unit}set apiKey(b){this._apiKey=b,Xi.apiKey=b,this.emit("apiKey",b)}get apiKey(){return this._apiKey}set fetch(b){Xi.fetch=b}get fetch(){return Xi.fetch}};const pr=new Rh,Fi={maptilerLogoURL:"https://api.maptiler.com/resources/logo.svg",maptilerURL:"https://www.maptiler.com/",maptilerApiHost:"api.maptiler.com",rtlPluginURL:"https://cdn.maptiler.com/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.min.js",primaryLanguage:Sr.AUTO,secondaryLanguage:Sr.LOCAL,terrainSourceURL:"https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json",terrainSourceId:"maptiler-terrain"};Object.freeze(Fi);class Bh extends nt.LogoControl{onAdd(b){return super.onAdd(b)}}class Hl extends Bh{constructor(b={}){var z,W;super(b),this.logoURL="",this.linkURL="",this.logoURL=(z=b.logoURL)!=null?z:Fi.maptilerLogoURL,this.linkURL=(W=b.linkURL)!=null?W:Fi.maptilerURL}onAdd(b){this._map=b,this._compact=this.options&&this.options.compact,this._container=window.document.createElement("div"),this._container.className="maplibregl-ctrl";const z=window.document.createElement("a");return z.style.backgroundRepeat="no-repeat",z.style.cursor="pointer",z.style.display="block",z.style.height="23px",z.style.margin="0 0 -4px -4px",z.style.overflow="hidden",z.style.width="88px",z.style.backgroundImage=`url(${this.logoURL})`,z.style.backgroundSize="100px 30px",z.style.width="100px",z.style.height="30px",z.target="_blank",z.rel="noopener nofollow",z.href=this.linkURL,z.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),z.setAttribute("rel","noopener nofollow"),this._container.appendChild(z),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}}function dp(){nt.getRTLTextPluginStatus()==="unavailable"&&nt.setRTLTextPlugin(Fi.rtlPluginURL,null,!0)}function pp(A,b){A.forEach(z=>{b[z]&&(b[z]=b[z].bind(b))})}function Nn(A,b,z){const W=window.document.createElement(A);return b!==void 0&&(W.className=b),z&&z.appendChild(W),W}function mp(A){A.parentNode&&A.parentNode.removeChild(A)}function Fh(A){return A?typeof A=="string"||A instanceof String?!A.startsWith("http")&&A.toLowerCase().includes(".json")?A:Dh(A):A instanceof zo?A.getExpandedStyleURL():A instanceof Lo?A.getDefaultVariant().getExpandedStyleURL():A:ql[Do[0].referenceStyleID].getDefaultVariant().getExpandedStyleURL()}class Oh{constructor(){pp(["_toggleTerrain","_updateTerrainIcon"],this)}onAdd(b){return this._map=b,this._container=Nn("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=Nn("button","maplibregl-ctrl-terrain",this._container),Nn("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(){mp(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}_toggleTerrain(){this._map.hasTerrain()?this._map.disableTerrain():this._map.enableTerrain(),this._updateTerrainIcon()}_updateTerrainIcon(){this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.hasTerrain()?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))}}class Uh extends nt.NavigationControl{onAdd(b){return super.onAdd(b)}}class Vh extends Uh{constructor(){super({showCompass:!0,showZoom:!0,visualizePitch:!0}),this._compass.removeEventListener("click",this._compass.clickFunction),this._compass.addEventListener("click",b=>{this._map.getPitch()===0?this._map.easeTo({pitch:Math.min(this._map.getMaxPitch(),80)}):this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:b}):this._map.resetNorth({},{originalEvent:b})})}_createButton(b,z){const W=super._createButton(b,z);return W.clickFunction=z,W}_rotateCompassArrow(){const b=this.options.visualizePitch?`scale(${Math.min(1.5,1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5))}) rotateX(${Math.min(70,this._map.transform.pitch)}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=b}}class Nh extends nt.GeolocateControl{onAdd(b){return super.onAdd(b)}}var fp=Object.defineProperty,gp=Object.defineProperties,_p=Object.getOwnPropertyDescriptors,$h=Object.getOwnPropertySymbols,yp=Object.prototype.hasOwnProperty,xp=Object.prototype.propertyIsEnumerable,Gh=(A,b,z)=>b in A?fp(A,b,{enumerable:!0,configurable:!0,writable:!0,value:z}):A[b]=z,vp=(A,b)=>{for(var z in b||(b={}))yp.call(b,z)&&Gh(A,z,b[z]);if($h)for(var z of $h(b))xp.call(b,z)&&Gh(A,z,b[z]);return A},bp=(A,b)=>gp(A,_p(b));const jh=nt.Marker,qh=nt.LngLat;class Zh extends Nh{constructor(){super(...arguments),this.lastUpdatedCenter=new qh(0,0)}_updateCamera(b){const z=new qh(b.coords.longitude,b.coords.latitude),W=b.coords.accuracy,ie=this._map.getBearing(),de=bp(vp({bearing:ie},this.options.fitBoundsOptions),{linear:!0}),he=this._map.getZoom();he>this.options.fitBoundsOptions.maxZoom&&(de.zoom=he),this._map.fitBounds(z.toBounds(W),de,{geolocateSource:!0});let h=!1;const ve=()=>{h=!0};this._map.once("click",ve),this._map.once("dblclick",ve),this._map.once("dragstart",ve),this._map.once("mousedown",ve),this._map.once("touchstart",ve),this._map.once("wheel",ve),this._map.once("moveend",()=>{this._map.off("click",ve),this._map.off("dblclick",ve),this._map.off("dragstart",ve),this._map.off("mousedown",ve),this._map.off("touchstart",ve),this._map.off("wheel",ve),!h&&(this.lastUpdatedCenter=this._map.getCenter())})}_setupUI(b){if(this.lastUpdatedCenter=this._map.getCenter(),this._container.addEventListener("contextmenu",z=>z.preventDefault()),this._geolocateButton=Nn("button","maplibregl-ctrl-geolocate",this._container),Nn("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",b===!1){const z=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=z,this._geolocateButton.setAttribute("aria-label",z)}else{const z=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=z,this._geolocateButton.setAttribute("aria-label",z)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=Nn("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new jh(this._dotElement),this._circleElement=Nn("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new jh({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("move",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("moveend",z=>{const W=z.originalEvent&&z.originalEvent.type==="resize",ie=this.lastUpdatedCenter.distanceTo(this._map.getCenter());!z.geolocateSource&&this._watchState==="ACTIVE_LOCK"&&!W&&ie>1&&(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new Event("trackuserlocationend")))})}_updateCircleRadius(){if(this._watchState!=="BACKGROUND"&&this._watchState!=="ACTIVE_LOCK")return;const b=[this._lastKnownPosition.coords.longitude,this._lastKnownPosition.coords.latitude],z=this._map.project(b),W=this._map.unproject([z.x,z.y]),ie=this._map.unproject([z.x+20,z.y]),de=W.distanceTo(ie)/20,he=Math.ceil(2*this._accuracy/de);this._circleElement.style.width=`${he}px`,this._circleElement.style.height=`${he}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}}class Xh extends nt.AttributionControl{onAdd(b){return super.onAdd(b)}}class Wh extends nt.ScaleControl{onAdd(b){return super.onAdd(b)}}class Hh extends nt.FullscreenControl{onAdd(b){return super.onAdd(b)}}var wp=Object.defineProperty,Tp=Object.defineProperties,Sp=Object.getOwnPropertyDescriptors,Kh=Object.getOwnPropertySymbols,Ep=Object.prototype.hasOwnProperty,Ip=Object.prototype.propertyIsEnumerable,Yh=(A,b,z)=>b in A?wp(A,b,{enumerable:!0,configurable:!0,writable:!0,value:z}):A[b]=z,Ap=(A,b)=>{for(var z in b||(b={}))Ep.call(b,z)&&Yh(A,z,b[z]);if(Kh)for(var z of Kh(b))Ip.call(b,z)&&Yh(A,z,b[z]);return A},Cp=(A,b)=>Tp(A,Sp(b)),un=(A,b,z)=>new Promise((W,ie)=>{var de=ve=>{try{h(z.next(ve))}catch(Ge){ie(Ge)}},he=ve=>{try{h(z.throw(ve))}catch(Ge){ie(Ge)}},h=ve=>ve.done?W(ve.value):Promise.resolve(ve.value).then(de,he);h((z=z.apply(A,b)).next())});const Jh=Md(),Qh={POINT:"POINT",COUNTRY:"COUNTRY"};let Mp=class extends nt.Map{constructor(b){var z,W,ie;b.apiKey&&(pr.apiKey=b.apiKey);const de=Fh(b.style),he=location.hash;pr.apiKey||console.warn("MapTiler Cloud API key is not set. Visit https://maptiler.com and try Cloud for free!"),super(Cp(Ap({},b),{style:de,maplibreLogo:!1,transformRequest:Ye=>{let pe=null;try{pe=new URL(Ye)}catch{return{url:Ye,headers:{}}}return pe.host===Fi.maptilerApiHost&&(pe.searchParams.has("key")||pe.searchParams.append("key",pr.apiKey),pr.session&&pe.searchParams.append("mtsid",Jh)),{url:pe.href,headers:{}}}})),this.isTerrainEnabled=!1,this.terrainExaggeration=1,this.primaryLanguage=null,this.secondaryLanguage=null,this.terrainGrowing=!1,this.terrainFlattening=!1,this.primaryLanguage=(z=b.language)!=null?z:pr.primaryLanguage,this.secondaryLanguage=pr.secondaryLanguage,this.terrainExaggeration=(W=b.terrainExaggeration)!=null?W:this.terrainExaggeration,this.once("styledata",()=>un(this,null,function*(){if(!b.geolocate||b.center||b.hash&&he)return;try{if(b.geolocate===Qh.COUNTRY){yield this.fitToIpBounds();return}}catch(pe){console.warn(pe.message)}let Ye=null;try{yield this.centerOnIpPoint(b.zoom),Ye=this.getCameraHash()}catch(pe){console.warn(pe.message)}(yield navigator.permissions.query({name:"geolocation"})).state==="granted"&&navigator.geolocation.getCurrentPosition(pe=>{Ye===this.getCameraHash()&&(this.terrain?this.easeTo({center:[pe.coords.longitude,pe.coords.latitude],zoom:b.zoom||12,duration:2e3}):this.once("terrain",()=>{this.easeTo({center:[pe.coords.longitude,pe.coords.latitude],zoom:b.zoom||12,duration:2e3})}))},null,{maximumAge:24*3600*1e3,timeout:5e3,enableHighAccuracy:!1})})),this.on("styledata",()=>{this.setPrimaryLanguage(this.primaryLanguage),this.setSecondaryLanguage(this.secondaryLanguage)}),this.on("styledata",()=>{this.getTerrain()===null&&this.isTerrainEnabled&&this.enableTerrain(this.terrainExaggeration)}),this.once("load",()=>un(this,null,function*(){dp()})),this.once("load",()=>un(this,null,function*(){let Ye={logo:null};try{const pe=Object.keys(this.style.sourceCaches).map(Be=>this.getSource(Be)).filter(Be=>typeof Be.url=="string"&&Be.url.includes("tiles.json")),ee=new URL(pe[0].url);ee.searchParams.has("key")||ee.searchParams.append("key",pr.apiKey),Ye=yield(yield fetch(ee.href)).json()}catch{}if("logo"in Ye&&Ye.logo){const pe=Ye.logo;this.addControl(new Hl({logoURL:pe}),b.logoPosition),b.attributionControl===!1&&this.addControl(new Xh(b))}else b.maptilerLogo&&this.addControl(new Hl,b.logoPosition);if(b.scaleControl){const pe=b.scaleControl===!0||b.scaleControl===void 0?"bottom-right":b.scaleControl,ee=new Wh({unit:pr.unit});this.addControl(ee,pe),pr.on("unit",Be=>{ee.setUnit(Be)})}if(b.navigationControl!==!1){const pe=b.navigationControl===!0||b.navigationControl===void 0?"top-right":b.navigationControl;this.addControl(new Vh,pe)}if(b.geolocateControl!==!1){const pe=b.geolocateControl===!0||b.geolocateControl===void 0?"top-right":b.geolocateControl;this.addControl(new Zh({positionOptions:{enableHighAccuracy:!0,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!0,showAccuracyCircle:!0,showUserLocation:!0}),pe)}if(b.terrainControl){const pe=b.terrainControl===!0||b.terrainControl===void 0?"top-right":b.terrainControl;this.addControl(new Oh,pe)}if(b.fullscreenControl){const pe=b.fullscreenControl===!0||b.fullscreenControl===void 0?"top-right":b.fullscreenControl;this.addControl(new Hh({}),pe)}}));let h=!1,ve=!1,Ge=null;this.once("load",Ye=>{h=!0,ve&&this.fire("loadWithTerrain",Ge)});const et=Ye=>{Ye.terrain&&(ve=!0,Ge={type:"loadWithTerrain",target:this,terrain:Ye.terrain},this.off("terrain",et),h&&this.fire("loadWithTerrain",Ge))};this.on("terrain",et),b.terrain&&this.enableTerrain((ie=b.terrainExaggeration)!=null?ie:this.terrainExaggeration)}onLoadAsync(){return un(this,null,function*(){return new Promise((b,z)=>{if(this.loaded())return b(this);this.once("load",W=>{b(this)})})})}onLoadWithTerrainAsync(){return un(this,null,function*(){return new Promise((b,z)=>{if(this.loaded()&&this.terrain)return b(this);this.once("loadWithTerrain",W=>{b(this)})})})}setStyle(b,z){return super.setStyle(Fh(b),z)}setLanguage(b=Fi.primaryLanguage){if(b===Sr.AUTO)return this.setLanguage(Vl());this.setPrimaryLanguage(b)}setPrimaryLanguage(b=Fi.primaryLanguage){Ch(b)&&(this.primaryLanguage=b,this.onStyleReady(()=>{if(b===Sr.AUTO)return this.setPrimaryLanguage(Vl());const z=this.getStyle().layers,W=/^\s*{\s*name\s*(:\s*(\S*))?\s*}$/,ie=/^\s*name\s*(:\s*(\S*))?\s*$/,de=/^\s*{\s*name\s*(:\s*(\S*))?\s*}(\s*){\s*name\s*(:\s*(\S*))?\s*}$/,he=/^(.*)({\s*name\s*(:\s*(\S*))?\s*})(.*)$/,h=b?`name:${b}`:"name",ve=["case",["has",h],["get",h],["get","name:latin"]];for(let Ge=0;Ge<z.length;Ge+=1){const et=z[Ge],Ye=et.layout;if(!Ye||!Ye["text-field"])continue;const pe=this.getLayoutProperty(et.id,"text-field");let ee;if(Array.isArray(pe)&&pe.length>=2&&pe[0].trim().toLowerCase()==="concat"){const Be=pe.slice();for(let Ct=0;Ct<pe.length;Ct+=1){const Ft=pe[Ct];if((typeof Ft=="string"||Ft instanceof String)&&W.exec(Ft.toString())){Be[Ct]=ve;break}else if(Array.isArray(Ft)&&Ft.length>=2&&Ft[0].trim().toLowerCase()==="get"&&ie.exec(Ft[1].toString())){Be[Ct]=ve;break}else if(Array.isArray(Ft)&&Ft.length===4&&Ft[0].trim().toLowerCase()==="case"){Be[Ct]=ve;break}}this.setLayoutProperty(et.id,"text-field",Be)}else if(Array.isArray(pe)&&pe.length>=2&&pe[0].trim().toLowerCase()==="get"&&ie.exec(pe[1].toString())){const Be=ve;this.setLayoutProperty(et.id,"text-field",Be)}else if((typeof pe=="string"||pe instanceof String)&&W.exec(pe.toString())){const Be=ve;this.setLayoutProperty(et.id,"text-field",Be)}else if(Array.isArray(pe)&&pe.length===4&&pe[0].trim().toLowerCase()==="case"){const Be=ve;this.setLayoutProperty(et.id,"text-field",Be)}else if((typeof pe=="string"||pe instanceof String)&&(ee=de.exec(pe.toString()))!==null){const Be=`{${h}}${ee[3]}{name${ee[4]||""}}`;this.setLayoutProperty(et.id,"text-field",Be)}else if((typeof pe=="string"||pe instanceof String)&&(ee=he.exec(pe.toString()))!==null){const Be=`${ee[1]}{${h}}${ee[5]}`;this.setLayoutProperty(et.id,"text-field",Be)}}}))}setSecondaryLanguage(b=Fi.secondaryLanguage){Ch(b)&&(this.secondaryLanguage=b,this.onStyleReady(()=>{if(b===Sr.AUTO)return this.setSecondaryLanguage(Vl());const z=this.getStyle().layers,W=/^\s*{\s*name\s*(:\s*(\S*))?\s*}$/,ie=/^\s*name\s*(:\s*(\S*))?\s*$/,de=/^\s*{\s*name\s*(:\s*(\S*))?\s*}(\s*){\s*name\s*(:\s*(\S*))?\s*}$/;let he;for(let h=0;h<z.length;h+=1){const ve=z[h],Ge=ve.layout;if(!Ge||!Ge["text-field"])continue;const et=this.getLayoutProperty(ve.id,"text-field");let Ye;if(Array.isArray(et)&&et.length>=2&&et[0].trim().toLowerCase()==="concat"){Ye=et.slice();let pe=0;for(let ee=0;ee<et.length;ee+=1){const Be=et[ee];if((typeof Be=="string"||Be instanceof String)&&W.exec(Be.toString())){if(pe===1){Ye[ee]=`{name:${b}}`;break}pe+=1}else if(Array.isArray(Be)&&Be.length>=2&&Be[0].trim().toLowerCase()==="get"&&ie.exec(Be[1].toString())){if(pe===1){Ye[ee][1]=`name:${b}`;break}pe+=1}else if(Array.isArray(Be)&&Be.length===4&&Be[0].trim().toLowerCase()==="case"){if(pe===1){Ye[ee]=["get",`name:${b}`];break}pe+=1}}this.setLayoutProperty(ve.id,"text-field",Ye)}else if((typeof et=="string"||et instanceof String)&&(he=de.exec(et.toString()))!==null){const pe=b?`name:${b}`:"name";Ye=`{name${he[1]||""}}${he[3]}{${pe}}`,this.setLayoutProperty(ve.id,"text-field",Ye)}}}))}getPrimaryLanguage(){return this.primaryLanguage}getSecondaryLanguage(){return this.secondaryLanguage}getTerrainExaggeration(){return this.terrainExaggeration}hasTerrain(){return this.isTerrainEnabled}growTerrain(b,z=1e3){if(!this.terrain)return;const W=performance.now(),ie=this.terrain.exaggeration,de=b-ie,he=()=>{if(!this.terrain||this.terrainFlattening)return;const h=(performance.now()-W)/z;if(h<.99){const ve=1-Math.pow(1-h,4),Ge=ie+ve*de;this.terrain.exaggeration=Ge,requestAnimationFrame(he)}else this.terrainGrowing=!1,this.terrainFlattening=!1,this.terrain.exaggeration=b;this.triggerRepaint()};this.terrainGrowing=!0,this.terrainFlattening=!1,requestAnimationFrame(he)}enableTerrain(b=this.terrainExaggeration){if(b<0){console.warn("Terrain exaggeration cannot be negative.");return}const z=ie=>un(this,null,function*(){!this.terrain||ie.type!=="data"||ie.dataType!=="source"||!("source"in ie)||ie.sourceId!=="maptiler-terrain"||ie.source.type!=="raster-dem"||ie.isSourceLoaded&&(this.off("data",z),this.growTerrain(b))}),W=()=>{this.isTerrainEnabled=!0,this.terrainExaggeration=b,this.on("data",z),this.addSource(Fi.terrainSourceId,{type:"raster-dem",url:Fi.terrainSourceURL}),this.setTerrain({source:Fi.terrainSourceId,exaggeration:0})};if(this.getTerrain()){this.isTerrainEnabled=!0,this.growTerrain(b);return}this.loaded()||this.isTerrainEnabled?W():this.once("load",()=>{this.getTerrain()&&this.getSource(Fi.terrainSourceId)||W()})}disableTerrain(){if(!this.terrain)return;this.isTerrainEnabled=!1;const b=1*1e3,z=performance.now(),W=this.terrain.exaggeration,ie=()=>{if(!this.terrain||this.terrainGrowing)return;const de=(performance.now()-z)/b;if(de<.99){const he=Math.pow(1-de,4),h=W*he;this.terrain.exaggeration=h,requestAnimationFrame(ie)}else this.terrain.exaggeration=0,this.terrainGrowing=!1,this.terrainFlattening=!1,this.setTerrain(null),this.getSource(Fi.terrainSourceId)&&this.removeSource(Fi.terrainSourceId);this.triggerRepaint()};this.terrainGrowing=!1,this.terrainFlattening=!0,requestAnimationFrame(ie)}setTerrainExaggeration(b,z=!0){!z&&this.terrain?(this.terrainExaggeration=b,this.terrain.exaggeration=b,this.triggerRepaint()):this.enableTerrain(b)}onStyleReady(b){this.isStyleLoaded()?b():this.once("styledata",()=>{b()})}fitToIpBounds(){return un(this,null,function*(){const b=yield Gl.info();this.fitBounds(b.country_bounds,{duration:0,padding:100})})}centerOnIpPoint(b){return un(this,null,function*(){const z=yield Gl.info();this.jumpTo({center:[z.longitude,z.latitude],zoom:b||11})})}getCameraHash(){const b=new Float32Array(5),z=this.getCenter();return b[0]=z.lng,b[1]=z.lat,b[2]=this.getZoom(),b[3]=this.getPitch(),b[4]=this.getBearing(),Ed.fromUint8Array(new Uint8Array(b.buffer))}getSdkConfig(){return pr}getMaptilerSessionId(){return Jh}};class Pp extends nt.Marker{addTo(b){return super.addTo(b)}}class kp extends nt.Popup{addTo(b){return super.addTo(b)}}class zp extends nt.Style{constructor(b,z={}){super(b,z)}}class Lp extends nt.CanvasSource{onAdd(b){super.onAdd(b)}}class Dp extends nt.GeoJSONSource{onAdd(b){super.onAdd(b)}}class Rp extends nt.ImageSource{onAdd(b){super.onAdd(b)}}class Bp extends nt.RasterTileSource{onAdd(b){super.onAdd(b)}}class Fp extends nt.RasterDEMTileSource{onAdd(b){super.onAdd(b)}}class Op extends nt.VectorTileSource{onAdd(b){super.onAdd(b)}}class Up extends nt.VideoSource{onAdd(b){super.onAdd(b)}}class Vp extends nt.TerrainControl{onAdd(b){return super.onAdd(b)}}class hs{constructor(b,z){this.x=b,this.y=z}_matMult(b){const z=b[0]*this.x+b[1]*this.y,W=b[2]*this.x+b[3]*this.y;return this.x=z,this.y=W,this}_add(b){return this.x+=b.x,this.y+=b.y,this}_sub(b){return this.x-=b.x,this.y-=b.y,this}_mult(b){return this.x*=b,this.y*=b,this}_div(b){return this.x/=b,this.y/=b,this}_multByPoint(b){return this.x*=b.x,this.y*=b.y,this}_divByPoint(b){return this.x/=b.x,this.y/=b.y,this}_unit(){return this._div(this.mag()),this}_perp(){const b=this.y;return this.y=this.x,this.x=-b,this}_rotate(b){const z=Math.cos(b),W=Math.sin(b),ie=z*this.x-W*this.y,de=W*this.x+z*this.y;return this.x=ie,this.y=de,this}_rotateAround(b,z){const W=Math.cos(b),ie=Math.sin(b),de=z.x+W*(this.x-z.x)-ie*(this.y-z.y),he=z.y+ie*(this.x-z.x)+W*(this.y-z.y);return this.x=de,this.y=he,this}_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}clone(){return new hs(this.x,this.y)}add(b){return this.clone()._add(b)}sub(b){return this.clone()._sub(b)}multByPoint(b){return this.clone()._multByPoint(b)}divByPoint(b){return this.clone()._divByPoint(b)}mult(b){return this.clone()._mult(b)}div(b){return this.clone()._div(b)}rotate(b){return this.clone()._rotate(b)}rotateAround(b,z){return this.clone()._rotateAround(b,z)}matMult(b){return this.clone()._matMult(b)}unit(){return this.clone()._unit()}perp(){return this.clone()._perp()}round(){return this.clone()._round()}mag(){return Math.sqrt(this.x*this.x+this.y*this.y)}equals(b){return this.x===b.x&&this.y===b.y}dist(b){return Math.sqrt(this.distSqr(b))}distSqr(b){const z=b.x-this.x,W=b.y-this.y;return z*z+W*W}angle(){return Math.atan2(this.y,this.x)}angleTo(b){return Math.atan2(this.y-b.y,this.x-b.x)}angleWith(b){return this.angleWithSep(b.x,b.y)}angleWithSep(b,z){return Math.atan2(this.x*z-this.y*b,this.x*b+this.y*z)}static convert(b){return b instanceof hs?b:Array.isArray(b)?new hs(b[0],b[1]):b}}const{supported:Np,setRTLTextPlugin:$p,getRTLTextPluginStatus:Gp,LngLat:jp,LngLatBounds:qp,MercatorCoordinate:Zp,Evented:Xp,AJAXError:Wp,prewarm:Hp,clearPrewarmedResources:Kp,version:Yp,workerCount:Jp,maxParallelImageRequests:Qp,workerUrl:em,addProtocol:tm,removeProtocol:im}=nt,rm=nt.Map,nm=nt.Marker,am=nt.Popup,sm=nt.Style,om=nt.CanvasSource,lm=nt.GeoJSONSource,cm=nt.ImageSource,hm=nt.RasterTileSource,um=nt.RasterDEMTileSource,dm=nt.VectorTileSource,pm=nt.VideoSource;nt.NavigationControl,nt.GeolocateControl,nt.AttributionControl,nt.LogoControl,nt.ScaleControl,nt.FullscreenControl,nt.TerrainControl,Oe.AJAXError=Wp,Oe.AttributionControl=Xh,Oe.CanvasSource=Lp,Oe.CanvasSourceMLGL=om,Oe.Evented=Xp,Oe.FullscreenControl=Hh,Oe.GeoJSONSource=Dp,Oe.GeoJSONSourceMLGL=lm,Oe.GeolocateControl=Nh,Oe.GeolocationType=Qh,Oe.ImageSource=Rp,Oe.ImageSourceMLGL=cm,Oe.Language=Sr,Oe.LanguageGeocoding=cs,Oe.LngLat=jp,Oe.LngLatBounds=qp,Oe.LogoControl=Bh,Oe.Map=Mp,Oe.MapMLGL=rm,Oe.MapStyle=ql,Oe.MapStyleVariant=zo,Oe.MaptilerGeolocateControl=Zh,Oe.MaptilerLogoControl=Hl,Oe.MaptilerNavigationControl=Vh,Oe.MaptilerTerrainControl=Oh,Oe.Marker=Pp,Oe.MarkerMLGL=nm,Oe.MercatorCoordinate=Zp,Oe.NavigationControl=Uh,Oe.Point=hs,Oe.Popup=kp,Oe.PopupMLGL=am,Oe.RasterDEMTileSource=Fp,Oe.RasterDEMTileSourceMLGL=um,Oe.RasterTileSource=Bp,Oe.RasterTileSourceMLGL=hm,Oe.ReferenceMapStyle=Lo,Oe.ScaleControl=Wh,Oe.SdkConfig=Rh,Oe.ServiceError=hn,Oe.Style=zp,Oe.StyleMLGL=sm,Oe.TerrainControl=Vp,Oe.VectorTileSource=Op,Oe.VectorTileSourceMLGL=dm,Oe.VideoSource=Up,Oe.VideoSourceMLGL=pm,Oe.addProtocol=tm,Oe.clearPrewarmedResources=Kp,Oe.config=pr,Oe.coordinates=Qd,Oe.data=ip,Oe.geocoding=Wd,Oe.geolocation=Gl,Oe.getRTLTextPluginStatus=Gp,Oe.maxParallelImageRequests=Qp,Oe.prewarm=Hp,Oe.removeProtocol=im,Oe.setRTLTextPlugin=$p,Oe.staticMaps=up,Oe.supported=Np,Oe.version=Yp,Oe.workerCount=Jp,Oe.workerUrl=em});