import{c as zp,a as Ep}from"./_commonjsHelpers-C4iS2aBk.js";import{cd as Dp,aK as Lp,u as Rp,av as Bp}from"./index-UvaAT40e.js";var Bu={exports:{}};/** * MapLibre GL JS * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v4.5.0/LICENSE.txt */(function(Eo,fa){(function(Vr,yr){Eo.exports=yr()})(zp,function(){var Vr={},yr={};function Do(L,p,Ti){if(yr[L]=Ti,L==="index"){var $i="var sharedModule = {}; ("+yr.shared+")(sharedModule); ("+yr.worker+")(sharedModule);",Jt={};return yr.shared(Jt),yr.index(Vr,Jt),typeof window<"u"&&Vr.setWorkerUrl(window.URL.createObjectURL(new Blob([$i],{type:"text/javascript"}))),Vr}}Do("shared",["exports"],function(L){function p(i,e,r,s){return new(r||(r=Promise))(function(o,c){function d(x){try{_(s.next(x))}catch(b){c(b)}}function f(x){try{_(s.throw(x))}catch(b){c(b)}}function _(x){var b;x.done?o(x.value):(b=x.value,b instanceof r?b:new r(function(w){w(b)})).then(d,f)}_((s=s.apply(i,e||[])).next())})}function Ti(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}typeof SuppressedError=="function"&&SuppressedError;var $i=Jt;function Jt(i,e){this.x=i,this.y=e}Jt.prototype={clone:function(){return new Jt(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),s=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=s,this},_rotateAround:function(i,e){var r=Math.cos(i),s=Math.sin(i),o=e.y+s*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-s*(this.y-e.y),this.y=o,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Jt.convert=function(i){return i instanceof Jt?i:Array.isArray(i)?new Jt(i[0],i[1]):i};var me=Ti($i),se=Nr;function Nr(i,e,r,s){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*(s-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=e,this.p2x=r,this.p2y=s}Nr.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,s=0;s<8;s++){var o=this.sampleCurveX(r)-i;if(Math.abs(o)<e)return r;var c=this.sampleCurveDerivativeX(r);if(Math.abs(c)<1e-6)break;r-=o/c}var d=0,f=1;for(r=i,s=0;s<20&&(o=this.sampleCurveX(r),!(Math.abs(o-i)<e));s++)i>o?d=r:f=r,r=.5*(f-d)+d;return r},solve:function(i,e){return this.sampleCurveY(this.solveCurveX(i,e))}};var xr=Ti(se);let qi,vr;function sr(){return qi==null&&(qi=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),qi}function Rn(){if(vr==null&&(vr=!1,sr())){const e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let s=0;s<5*5;s++){const o=4*s;e.fillStyle=`rgb(${o},${o+1},${o+2})`,e.fillRect(s%5,Math.floor(s/5),1,1)}const r=e.getImageData(0,0,5,5).data;for(let s=0;s<5*5*4;s++)if(s%4!=3&&r[s]!==s){vr=!0;break}}}return vr||!1}function pi(i,e,r,s){const o=new xr(i,e,r,s);return c=>o.solve(c)}const ma=pi(.25,.1,.25,1);function Mi(i,e,r){return Math.min(r,Math.max(e,i))}function Zi(i,e,r){const s=r-e,o=((i-e)%s+s)%s+e;return o===e?r:o}function Si(i,...e){for(const r of e)for(const s in r)i[s]=r[s];return i}let ys=1;function Gi(i,e,r){const s={};for(const o in i)s[o]=e.call(this,i[o],o,i);return s}function Bn(i,e,r){const s={};for(const o in i)e.call(this,i[o],o,i)&&(s[o]=i[o]);return s}function rt(i){return Array.isArray(i)?i.map(rt):typeof i=="object"&&i?Gi(i,rt):i}const xs={};function Ot(i){xs[i]||(typeof console<"u"&&console.warn(i),xs[i]=!0)}function Yt(i,e,r){return(r.y-i.y)*(e.x-i.x)>(e.y-i.y)*(r.x-i.x)}function ar(i){return typeof WorkerGlobalScope<"u"&&i!==void 0&&i instanceof WorkerGlobalScope}let ln=null;function Xi(i){return typeof ImageBitmap<"u"&&i instanceof ImageBitmap}const vs="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function jr(i,e,r,s,o){return p(this,void 0,void 0,function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");const c=new VideoFrame(i,{timestamp:0});try{const d=c==null?void 0:c.format;if(!d||!d.startsWith("BGR")&&!d.startsWith("RGB"))throw new Error(`Unrecognized format ${d}`);const f=d.startsWith("BGR"),_=new Uint8ClampedArray(s*o*4);if(yield c.copyTo(_,function(x,b,w,I,C){const k=4*Math.max(-b,0),D=(Math.max(0,w)-w)*I*4+k,F=4*I,$=Math.max(0,b),J=Math.max(0,w);return{rect:{x:$,y:J,width:Math.min(x.width,b+I)-$,height:Math.min(x.height,w+C)-J},layout:[{offset:D,stride:F}]}}(i,e,r,s,o)),f)for(let x=0;x<_.length;x+=4){const b=_[x];_[x]=_[x+2],_[x+2]=b}return _}finally{c.close()}})}let or,ni;const ki="AbortError";function cn(){return new Error(ki)}const br={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function Wi(i){return br.REGISTERED_PROTOCOLS[i.substring(0,i.indexOf("://"))]}const hn="global-dispatcher";class fi extends Error{constructor(e,r,s,o){super(`AJAXError: ${r} (${e}): ${s}`),this.status=e,this.statusText=r,this.url=s,this.body=o}}const zi=()=>ar(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,Ur=function(i,e){if(/:\/\//.test(i.url)&&!/^https?:|^file:/.test(i.url)){const s=Wi(i.url);if(s)return s(i,e);if(ar(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,targetMapId:hn},e)}if(!(/^file:/.test(r=i.url)||/^file:/.test(zi())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(s,o){return p(this,void 0,void 0,function*(){const c=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:zi(),signal:o.signal});s.type!=="json"||c.headers.has("Accept")||c.headers.set("Accept","application/json");const d=yield fetch(c);if(!d.ok){const x=yield d.blob();throw new fi(d.status,d.statusText,s.url,x)}let f;f=s.type==="arrayBuffer"||s.type==="image"?d.arrayBuffer():s.type==="json"?d.json():d.text();const _=yield f;if(o.signal.aborted)throw cn();return{data:_,cacheControl:d.headers.get("Cache-Control"),expires:d.headers.get("Expires")}})}(i,e);if(ar(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,mustQueue:!0,targetMapId:hn},e)}var r;return function(s,o){return new Promise((c,d)=>{var f;const _=new XMLHttpRequest;_.open(s.method||"GET",s.url,!0),s.type!=="arrayBuffer"&&s.type!=="image"||(_.responseType="arraybuffer");for(const x in s.headers)_.setRequestHeader(x,s.headers[x]);s.type==="json"&&(_.responseType="text",!((f=s.headers)===null||f===void 0)&&f.Accept||_.setRequestHeader("Accept","application/json")),_.withCredentials=s.credentials==="include",_.onerror=()=>{d(new Error(_.statusText))},_.onload=()=>{if(!o.signal.aborted)if((_.status>=200&&_.status<300||_.status===0)&&_.response!==null){let x=_.response;if(s.type==="json")try{x=JSON.parse(_.response)}catch(b){return void d(b)}c({data:x,cacheControl:_.getResponseHeader("Cache-Control"),expires:_.getResponseHeader("Expires")})}else{const x=new Blob([_.response],{type:_.getResponseHeader("Content-Type")});d(new fi(_.status,_.statusText,s.url,x))}},o.signal.addEventListener("abort",()=>{_.abort(),d(cn())}),_.send(s.body)})}(i,e)};function $r(i){if(!i||i.indexOf("://")<=0||i.indexOf("data:image/")===0||i.indexOf("blob:")===0)return!0;const e=new URL(i),r=window.location;return e.protocol===r.protocol&&e.host===r.host}function Fn(i,e,r){r[i]&&r[i].indexOf(e)!==-1||(r[i]=r[i]||[],r[i].push(e))}function lr(i,e,r){if(r&&r[i]){const s=r[i].indexOf(e);s!==-1&&r[i].splice(s,1)}}class wr{constructor(e,r={}){Si(this,r),this.type=e}}class Tr extends wr{constructor(e,r={}){super("error",Si({error:e},r))}}class un{on(e,r){return this._listeners=this._listeners||{},Fn(e,r,this._listeners),this}off(e,r){return lr(e,r,this._listeners),lr(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},Fn(e,r,this._oneTimeListeners),this):new Promise(s=>this.once(e,s))}fire(e,r){typeof e=="string"&&(e=new wr(e,r||{}));const s=e.type;if(this.listens(s)){e.target=this;const o=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(const f of o)f.call(this,e);const c=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(const f of c)lr(s,f,this._oneTimeListeners),f.call(this,e);const d=this._eventedParent;d&&(Si(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),d.fire(e))}else e instanceof Tr&&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 re={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"enum",default:"mercator",values:{mercator:{},globe:{}}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const qr=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function On(i,e){const r={};for(const s in i)s!=="ref"&&(r[s]=i[s]);return qr.forEach(s=>{s in e&&(r[s]=e[s])}),r}function Qe(i,e){if(Array.isArray(i)){if(!Array.isArray(e)||i.length!==e.length)return!1;for(let r=0;r<i.length;r++)if(!Qe(i[r],e[r]))return!1;return!0}if(typeof i=="object"&&i!==null&&e!==null){if(typeof e!="object"||Object.keys(i).length!==Object.keys(e).length)return!1;for(const r in i)if(!Qe(i[r],e[r]))return!1;return!0}return i===e}function vt(i,e){i.push(e)}function Vn(i,e,r){vt(r,{command:"addSource",args:[i,e[i]]})}function Sr(i,e,r){vt(e,{command:"removeSource",args:[i]}),r[i]=!0}function cr(i,e,r,s){Sr(i,r,s),Vn(i,e,r)}function dn(i,e,r){let s;for(s in i[r])if(Object.prototype.hasOwnProperty.call(i[r],s)&&s!=="data"&&!Qe(i[r][s],e[r][s]))return!1;for(s in e[r])if(Object.prototype.hasOwnProperty.call(e[r],s)&&s!=="data"&&!Qe(i[r][s],e[r][s]))return!1;return!0}function Ii(i,e,r,s,o,c){i=i||{},e=e||{};for(const d in i)Object.prototype.hasOwnProperty.call(i,d)&&(Qe(i[d],e[d])||r.push({command:c,args:[s,d,e[d],o]}));for(const d in e)Object.prototype.hasOwnProperty.call(e,d)&&!Object.prototype.hasOwnProperty.call(i,d)&&(Qe(i[d],e[d])||r.push({command:c,args:[s,d,e[d],o]}))}function Nn(i){return i.id}function jn(i,e){return i[e.id]=e,i}class pe{constructor(e,r,s,o){this.message=(e?`${e}: `:"")+s,o&&(this.identifier=o),r!=null&&r.__line__&&(this.line=r.__line__)}}function Hi(i,...e){for(const r of e)for(const s in r)i[s]=r[s];return i}class Qt extends Error{constructor(e,r){super(r),this.message=r,this.key=e}}class Ki{constructor(e,r=[]){this.parent=e,this.bindings={};for(const[s,o]of r)this.bindings[s]=o}concat(e){return new Ki(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 Ir={kind:"null"},ge={kind:"number"},Ze={kind:"string"},Fe={kind:"boolean"},si={kind:"color"},Ei={kind:"object"},je={kind:"value"},Ji={kind:"collator"},hr={kind:"formatted"},Pr={kind:"padding"},Yi={kind:"resolvedImage"},j={kind:"variableAnchorOffsetCollection"};function A(i,e){return{kind:"array",itemType:i,N:e}}function P(i){if(i.kind==="array"){const e=P(i.itemType);return typeof i.N=="number"?`array<${e}, ${i.N}>`:i.itemType.kind==="value"?"array":`array<${e}>`}return i.kind}const E=[Ir,ge,Ze,Fe,si,hr,Ei,A(je),Pr,Yi,j];function V(i,e){if(e.kind==="error")return null;if(i.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!V(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 E)if(!V(r,e))return null}}return`Expected ${P(i)} but found ${P(e)} instead.`}function X(i,e){return e.some(r=>r.kind===i.kind)}function W(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)}function Y(i,e){return i.kind==="array"&&e.kind==="array"?i.itemType.kind===e.itemType.kind&&typeof i.N=="number":i.kind===e.kind}const q=.96422,ne=.82521,le=4/29,te=6/29,fe=3*te*te,De=te*te*te,Re=Math.PI/180,$e=180/Math.PI;function Ke(i){return(i%=360)<0&&(i+=360),i}function Ue([i,e,r,s]){let o,c;const d=bt((.2225045*(i=ot(i))+.7168786*(e=ot(e))+.0606169*(r=ot(r)))/1);i===e&&e===r?o=c=d:(o=bt((.4360747*i+.3850649*e+.1430804*r)/q),c=bt((.0139322*i+.0971045*e+.7141733*r)/ne));const f=116*d-16;return[f<0?0:f,500*(o-d),200*(d-c),s]}function ot(i){return i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function bt(i){return i>De?Math.pow(i,1/3):i/fe+le}function At([i,e,r,s]){let o=(i+16)/116,c=isNaN(e)?o:o+e/500,d=isNaN(r)?o:o-r/200;return o=1*tt(o),c=q*tt(c),d=ne*tt(d),[Ge(3.1338561*c-1.6168667*o-.4906146*d),Ge(-.9787684*c+1.9161415*o+.033454*d),Ge(.0719453*c-.2289914*o+1.4052427*d),s]}function Ge(i){return(i=i<=.00304?12.92*i:1.055*Math.pow(i,1/2.4)-.055)<0?0:i>1?1:i}function tt(i){return i>te?i*i*i:fe*(i-le)}function gt(i){return parseInt(i.padEnd(2,i),16)/255}function kt(i,e){return Vt(e?i/100:i,0,1)}function Vt(i,e,r){return Math.min(Math.max(e,i),r)}function Nt(i){return!i.some(Number.isNaN)}const Un={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};class it{constructor(e,r,s,o=1,c=!0){this.r=e,this.g=r,this.b=s,this.a=o,c||(this.r*=o,this.g*=o,this.b*=o,o||this.overwriteGetter("rgb",[e,r,s,o]))}static parse(e){if(e instanceof it)return e;if(typeof e!="string")return;const r=function(s){if((s=s.toLowerCase().trim())==="transparent")return[0,0,0,0];const o=Un[s];if(o){const[d,f,_]=o;return[d/255,f/255,_/255,1]}if(s.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(s)){const d=s.length<6?1:2;let f=1;return[gt(s.slice(f,f+=d)),gt(s.slice(f,f+=d)),gt(s.slice(f,f+=d)),gt(s.slice(f,f+d)||"ff")]}if(s.startsWith("rgb")){const d=s.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(d){const[f,_,x,b,w,I,C,k,D,F,$,J]=d,Z=[b||" ",C||" ",F].join("");if(Z===" "||Z===" /"||Z===",,"||Z===",,,"){const K=[x,I,D].join(""),ie=K==="%%%"?100:K===""?255:0;if(ie){const ce=[Vt(+_/ie,0,1),Vt(+w/ie,0,1),Vt(+k/ie,0,1),$?kt(+$,J):1];if(Nt(ce))return ce}}return}}const c=s.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(c){const[d,f,_,x,b,w,I,C,k]=c,D=[_||" ",b||" ",I].join("");if(D===" "||D===" /"||D===",,"||D===",,,"){const F=[+f,Vt(+x,0,100),Vt(+w,0,100),C?kt(+C,k):1];if(Nt(F))return function([$,J,Z,K]){function ie(ce){const xe=(ce+$/30)%12,Le=J*Math.min(Z,1-Z);return Z-Le*Math.max(-1,Math.min(xe-3,9-xe,1))}return $=Ke($),J/=100,Z/=100,[ie(0),ie(8),ie(4),K]}(F)}}}(e);return r?new it(...r,!1):void 0}get rgb(){const{r:e,g:r,b:s,a:o}=this,c=o||1/0;return this.overwriteGetter("rgb",[e/c,r/c,s/c,o])}get hcl(){return this.overwriteGetter("hcl",function(e){const[r,s,o,c]=Ue(e),d=Math.sqrt(s*s+o*o);return[Math.round(1e4*d)?Ke(Math.atan2(o,s)*$e):NaN,d,r,c]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Ue(this.rgb))}overwriteGetter(e,r){return Object.defineProperty(this,e,{value:r}),r}toString(){const[e,r,s,o]=this.rgb;return`rgba(${[e,r,s].map(c=>Math.round(255*c)).join(",")},${o})`}}it.black=new it(0,0,0,1),it.white=new it(1,1,1,1),it.transparent=new it(0,0,0,0),it.red=new it(1,0,0,1);class _a{constructor(e,r,s){this.sensitivity=e?r?"variant":"case":r?"accent":"base",this.locale=s,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 ga{constructor(e,r,s,o,c){this.text=e,this.image=r,this.scale=s,this.fontStack=o,this.textColor=c}}class mi{constructor(e){this.sections=e}static fromString(e){return new mi([new ga(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 mi?e:mi.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}}class _i{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof _i)return e;if(typeof e=="number")return new _i([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 _i(e)}}toString(){return JSON.stringify(this.values)}}const Nl=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class gi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof gi)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let r=0;r<e.length;r+=2){const s=e[r],o=e[r+1];if(typeof s!="string"||!Nl.has(s)||!Array.isArray(o)||o.length!==2||typeof o[0]!="number"||typeof o[1]!="number")return}return new gi(e)}}toString(){return JSON.stringify(this.values)}}class jt{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new jt({name:e,available:!1}):null}}function bs(i,e,r,s){return typeof i=="number"&&i>=0&&i<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof r=="number"&&r>=0&&r<=255?s===void 0||typeof s=="number"&&s>=0&&s<=1?null:`Invalid rgba value [${[i,e,r,s].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof s=="number"?[i,e,r,s]:[i,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function $n(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof it||i instanceof _a||i instanceof mi||i instanceof _i||i instanceof gi||i instanceof jt)return!0;if(Array.isArray(i)){for(const e of i)if(!$n(e))return!1;return!0}if(typeof i=="object"){for(const e in i)if(!$n(i[e]))return!1;return!0}return!1}function Ct(i){if(i===null)return Ir;if(typeof i=="string")return Ze;if(typeof i=="boolean")return Fe;if(typeof i=="number")return ge;if(i instanceof it)return si;if(i instanceof _a)return Ji;if(i instanceof mi)return hr;if(i instanceof _i)return Pr;if(i instanceof gi)return j;if(i instanceof jt)return Yi;if(Array.isArray(i)){const e=i.length;let r;for(const s of i){const o=Ct(s);if(r){if(r===o)continue;r=je;break}r=o}return A(r||je,e)}return Ei}function ur(i){const e=typeof i;return i===null?"":e==="string"||e==="number"||e==="boolean"?String(i):i instanceof it||i instanceof mi||i instanceof _i||i instanceof gi||i instanceof jt?i.toString():JSON.stringify(i)}class Zr{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(!$n(e[1]))return r.error("invalid value");const s=e[1];let o=Ct(s);const c=r.expectedType;return o.kind!=="array"||o.N!==0||!c||c.kind!=="array"||typeof c.N=="number"&&c.N!==0||(o=c),new Zr(o,s)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class It{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const ws={string:Ze,number:ge,boolean:Fe,object:Ei};class Pi{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 s,o=1;const c=e[0];if(c==="array"){let f,_;if(e.length>2){const x=e[1];if(typeof x!="string"||!(x in ws)||x==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);f=ws[x],o++}else f=je;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],o++}s=A(f,_)}else{if(!ws[c])throw new Error(`Types doesn't contain name = ${c}`);s=ws[c]}const d=[];for(;o<e.length;o++){const f=r.parse(e[o],o,je);if(!f)return null;d.push(f)}return new Pi(s,d)}evaluate(e){for(let r=0;r<this.args.length;r++){const s=this.args[r].evaluate(e);if(!V(this.type,Ct(s)))return s;if(r===this.args.length-1)throw new It(`Expected value to be of type ${P(this.type)}, but found ${P(Ct(s))} instead.`)}throw new Error}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const qn={"to-boolean":Fe,"to-color":si,"to-number":ge,"to-string":Ze};class Ar{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 s=e[0];if(!qn[s])throw new Error(`Can't parse ${s} as it is not part of the known types`);if((s==="to-boolean"||s==="to-string")&&e.length!==2)return r.error("Expected one argument.");const o=qn[s],c=[];for(let d=1;d<e.length;d++){const f=r.parse(e[d],d,je);if(!f)return null;c.push(f)}return new Ar(o,c)}evaluate(e){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(e);case"color":{let r,s;for(const o of this.args){if(r=o.evaluate(e),s=null,r instanceof it)return r;if(typeof r=="string"){const c=e.parseColor(r);if(c)return c}else if(Array.isArray(r)&&(s=r.length<3||r.length>4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:bs(r[0],r[1],r[2],r[3]),!s))return new it(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new It(s||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"padding":{let r;for(const s of this.args){r=s.evaluate(e);const o=_i.parse(r);if(o)return o}throw new It(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"variableAnchorOffsetCollection":{let r;for(const s of this.args){r=s.evaluate(e);const o=gi.parse(r);if(o)return o}throw new It(`Could not parse variableAnchorOffsetCollection from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"number":{let r=null;for(const s of this.args){if(r=s.evaluate(e),r===null)return 0;const o=Number(r);if(!isNaN(o))return o}throw new It(`Could not convert ${JSON.stringify(r)} to number.`)}case"formatted":return mi.fromString(ur(this.args[0].evaluate(e)));case"resolvedImage":return jt.fromString(ur(this.args[0].evaluate(e)));default:return ur(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const ya=["Unknown","Point","LineString","Polygon"];class Zn{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"?ya[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]=it.parse(e)),r}}class Cr{constructor(e,r,s=[],o,c=new Ki,d=[]){this.registry=e,this.path=s,this.key=s.map(f=>`[${f}]`).join(""),this.scope=c,this.errors=d,this.expectedType=o,this._isConstant=r}parse(e,r,s,o,c={}){return r?this.concat(r,s,o)._parse(e,c):this._parse(e,c)}_parse(e,r){function s(o,c,d){return d==="assert"?new Pi(c,[o]):d==="coerce"?new Ar(c,[o]):o}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const o=e[0];if(typeof o!="string")return this.error(`Expression name must be a string, but found ${typeof o} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const c=this.registry[o];if(c){let d=c.parse(e,this);if(!d)return null;if(this.expectedType){const f=this.expectedType,_=d.type;if(f.kind!=="string"&&f.kind!=="number"&&f.kind!=="boolean"&&f.kind!=="object"&&f.kind!=="array"||_.kind!=="value")if(f.kind!=="color"&&f.kind!=="formatted"&&f.kind!=="resolvedImage"||_.kind!=="value"&&_.kind!=="string")if(f.kind!=="padding"||_.kind!=="value"&&_.kind!=="number"&&_.kind!=="array")if(f.kind!=="variableAnchorOffsetCollection"||_.kind!=="value"&&_.kind!=="array"){if(this.checkSubtype(f,_))return null}else d=s(d,f,r.typeAnnotation||"coerce");else d=s(d,f,r.typeAnnotation||"coerce");else d=s(d,f,r.typeAnnotation||"coerce");else d=s(d,f,r.typeAnnotation||"assert")}if(!(d instanceof Zr)&&d.type.kind!=="resolvedImage"&&this._isConstant(d)){const f=new Zn;try{d=new Zr(d.type,d.evaluate(f))}catch(_){return this.error(_.message),null}}return d}return this.error(`Unknown expression "${o}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,r,s){const o=typeof e=="number"?this.path.concat(e):this.path,c=s?this.scope.concat(s):this.scope;return new Cr(this.registry,this._isConstant,o,r||null,c,this.errors)}error(e,...r){const s=`${this.key}${r.map(o=>`[${o}]`).join("")}`;this.errors.push(new Qt(s,e))}checkSubtype(e,r){const s=V(e,r);return s&&this.error(s),s}}class et{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 s=[];for(let c=1;c<e.length-1;c+=2){const d=e[c];if(typeof d!="string")return r.error(`Expected string, but found ${typeof d} instead.`,c);if(/[^a-zA-Z0-9_]/.test(d))return r.error("Variable names must contain only alphanumeric characters or '_'.",c);const f=r.parse(e[c+1],c+1);if(!f)return null;s.push([d,f])}const o=r.parse(e[e.length-1],e.length-1,r.expectedType,s);return o?new et(s,o):null}outputDefined(){return this.result.outputDefined()}}class Ts{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 s=e[1];return r.scope.has(s)?new Ts(s,r.scope.get(s)):r.error(`Unknown variable "${s}". Make sure "${s}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class xa{constructor(e,r,s){this.type=e,this.index=r,this.input=s}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const s=r.parse(e[1],1,ge),o=r.parse(e[2],2,A(r.expectedType||je));return s&&o?new xa(o.type.itemType,s,o):null}evaluate(e){const r=this.index.evaluate(e),s=this.input.evaluate(e);if(r<0)throw new It(`Array index out of bounds: ${r} < 0.`);if(r>=s.length)throw new It(`Array index out of bounds: ${r} > ${s.length-1}.`);if(r!==Math.floor(r))throw new It(`Array index must be an integer, but found ${r} instead.`);return s[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class Gn{constructor(e,r){this.type=Fe,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 s=r.parse(e[1],1,je),o=r.parse(e[2],2,je);return s&&o?X(s.type,[Fe,Ze,ge,Ir,je])?new Gn(s,o):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${P(s.type)} instead`):null}evaluate(e){const r=this.needle.evaluate(e),s=this.haystack.evaluate(e);if(!s)return!1;if(!W(r,["boolean","string","number","null"]))throw new It(`Expected first argument to be of type boolean, string, number or null, but found ${P(Ct(r))} instead.`);if(!W(s,["string","array"]))throw new It(`Expected second argument to be of type array or string, but found ${P(Ct(s))} instead.`);return s.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class Ss{constructor(e,r,s){this.type=ge,this.needle=e,this.haystack=r,this.fromIndex=s}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 s=r.parse(e[1],1,je),o=r.parse(e[2],2,je);if(!s||!o)return null;if(!X(s.type,[Fe,Ze,ge,Ir,je]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${P(s.type)} instead`);if(e.length===4){const c=r.parse(e[3],3,ge);return c?new Ss(s,o,c):null}return new Ss(s,o)}evaluate(e){const r=this.needle.evaluate(e),s=this.haystack.evaluate(e);if(!W(r,["boolean","string","number","null"]))throw new It(`Expected first argument to be of type boolean, string, number or null, but found ${P(Ct(r))} instead.`);if(!W(s,["string","array"]))throw new It(`Expected second argument to be of type array or string, but found ${P(Ct(s))} instead.`);if(this.fromIndex){const o=this.fromIndex.evaluate(e);return s.indexOf(r,o)}return s.indexOf(r)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class Is{constructor(e,r,s,o,c,d){this.inputType=e,this.type=r,this.input=s,this.cases=o,this.outputs=c,this.otherwise=d}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 s,o;r.expectedType&&r.expectedType.kind!=="value"&&(o=r.expectedType);const c={},d=[];for(let x=2;x<e.length-1;x+=2){let b=e[x];const w=e[x+1];Array.isArray(b)||(b=[b]);const I=r.concat(x);if(b.length===0)return I.error("Expected at least one branch label.");for(const k of b){if(typeof k!="number"&&typeof k!="string")return I.error("Branch labels must be numbers or strings.");if(typeof k=="number"&&Math.abs(k)>Number.MAX_SAFE_INTEGER)return I.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof k=="number"&&Math.floor(k)!==k)return I.error("Numeric branch labels must be integer values.");if(s){if(I.checkSubtype(s,Ct(k)))return null}else s=Ct(k);if(c[String(k)]!==void 0)return I.error("Branch labels must be unique.");c[String(k)]=d.length}const C=r.parse(w,x,o);if(!C)return null;o=o||C.type,d.push(C)}const f=r.parse(e[1],1,je);if(!f)return null;const _=r.parse(e[e.length-1],e.length-1,o);return _?f.type.kind!=="value"&&r.concat(1).checkSubtype(s,f.type)?null:new Is(s,o,f,c,d,_):null}evaluate(e){const r=this.input.evaluate(e);return(Ct(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 Ps{constructor(e,r,s){this.type=e,this.branches=r,this.otherwise=s}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 s;r.expectedType&&r.expectedType.kind!=="value"&&(s=r.expectedType);const o=[];for(let d=1;d<e.length-1;d+=2){const f=r.parse(e[d],d,Fe);if(!f)return null;const _=r.parse(e[d+1],d+1,s);if(!_)return null;o.push([f,_]),s=s||_.type}const c=r.parse(e[e.length-1],e.length-1,s);if(!c)return null;if(!s)throw new Error("Can't infer output type");return new Ps(s,o,c)}evaluate(e){for(const[r,s]of this.branches)if(r.evaluate(e))return s.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[r,s]of this.branches)e(r),e(s);e(this.otherwise)}outputDefined(){return this.branches.every(([e,r])=>r.outputDefined())&&this.otherwise.outputDefined()}}class As{constructor(e,r,s,o){this.type=e,this.input=r,this.beginIndex=s,this.endIndex=o}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 s=r.parse(e[1],1,je),o=r.parse(e[2],2,ge);if(!s||!o)return null;if(!X(s.type,[A(je),Ze,je]))return r.error(`Expected first argument to be of type array or string, but found ${P(s.type)} instead`);if(e.length===4){const c=r.parse(e[3],3,ge);return c?new As(s.type,s,o,c):null}return new As(s.type,s,o)}evaluate(e){const r=this.input.evaluate(e),s=this.beginIndex.evaluate(e);if(!W(r,["string","array"]))throw new It(`Expected first argument to be of type array or string, but found ${P(Ct(r))} instead.`);if(this.endIndex){const o=this.endIndex.evaluate(e);return r.slice(s,o)}return r.slice(s)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function Xn(i,e){const r=i.length-1;let s,o,c=0,d=r,f=0;for(;c<=d;)if(f=Math.floor((c+d)/2),s=i[f],o=i[f+1],s<=e){if(f===r||e<o)return f;c=f+1}else{if(!(s>e))throw new It("Input is not a number.");d=f-1}return 0}class pn{constructor(e,r,s){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(const[o,c]of s)this.labels.push(o),this.outputs.push(c)}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 s=r.parse(e[1],1,ge);if(!s)return null;const o=[];let c=null;r.expectedType&&r.expectedType.kind!=="value"&&(c=r.expectedType);for(let d=1;d<e.length;d+=2){const f=d===1?-1/0:e[d],_=e[d+1],x=d,b=d+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.',x);if(o.length&&o[o.length-1][0]>=f)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',x);const w=r.parse(_,b,c);if(!w)return null;c=c||w.type,o.push([f,w])}return new pn(c,s,o)}evaluate(e){const r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(e);const o=this.input.evaluate(e);if(o<=r[0])return s[0].evaluate(e);const c=r.length;return o>=r[c-1]?s[c-1].evaluate(e):s[Xn(r,o)].evaluate(e)}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function jl(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Ul=Lo;function Lo(i,e,r,s){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*(s-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=e,this.p2x=r,this.p2y=s}Lo.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,s=0;s<8;s++){var o=this.sampleCurveX(r)-i;if(Math.abs(o)<e)return r;var c=this.sampleCurveDerivativeX(r);if(Math.abs(c)<1e-6)break;r-=o/c}var d=0,f=1;for(r=i,s=0;s<20&&(o=this.sampleCurveX(r),!(Math.abs(o-i)<e));s++)i>o?d=r:f=r,r=.5*(f-d)+d;return r},solve:function(i,e){return this.sampleCurveY(this.solveCurveX(i,e))}};var $l=jl(Ul);function Mr(i,e,r){return i+r*(e-i)}function Wn(i,e,r){return i.map((s,o)=>Mr(s,e[o],r))}const yi={number:Mr,color:function(i,e,r,s="rgb"){switch(s){case"rgb":{const[o,c,d,f]=Wn(i.rgb,e.rgb,r);return new it(o,c,d,f,!1)}case"hcl":{const[o,c,d,f]=i.hcl,[_,x,b,w]=e.hcl;let I,C;if(isNaN(o)||isNaN(_))isNaN(o)?isNaN(_)?I=NaN:(I=_,d!==1&&d!==0||(C=x)):(I=o,b!==1&&b!==0||(C=c));else{let J=_-o;_>o&&J>180?J-=360:_<o&&o-_>180&&(J+=360),I=o+r*J}const[k,D,F,$]=function([J,Z,K,ie]){return J=isNaN(J)?0:J*Re,At([K,Math.cos(J)*Z,Math.sin(J)*Z,ie])}([I,C??Mr(c,x,r),Mr(d,b,r),Mr(f,w,r)]);return new it(k,D,F,$,!1)}case"lab":{const[o,c,d,f]=At(Wn(i.lab,e.lab,r));return new it(o,c,d,f,!1)}}},array:Wn,padding:function(i,e,r){return new _i(Wn(i.values,e.values,r))},variableAnchorOffsetCollection:function(i,e,r){const s=i.values,o=e.values;if(s.length!==o.length)throw new It(`Cannot interpolate values of different length. from: ${i.toString()}, to: ${e.toString()}`);const c=[];for(let d=0;d<s.length;d+=2){if(s[d]!==o[d])throw new It(`Cannot interpolate values containing mismatched anchors. from[${d}]: ${s[d]}, to[${d}]: ${o[d]}`);c.push(s[d]);const[f,_]=s[d+1],[x,b]=o[d+1];c.push([Mr(f,x,r),Mr(_,b,r)])}return new gi(c)}};class xi{constructor(e,r,s,o,c){this.type=e,this.operator=r,this.interpolation=s,this.input=o,this.labels=[],this.outputs=[];for(const[d,f]of c)this.labels.push(d),this.outputs.push(f)}static interpolationFactor(e,r,s,o){let c=0;if(e.name==="exponential")c=Hn(r,e.base,s,o);else if(e.name==="linear")c=Hn(r,1,s,o);else if(e.name==="cubic-bezier"){const d=e.controlPoints;c=new $l(d[0],d[1],d[2],d[3]).solve(Hn(r,1,s,o))}return c}static parse(e,r){let[s,o,c,...d]=e;if(!Array.isArray(o)||o.length===0)return r.error("Expected an interpolation type expression.",1);if(o[0]==="linear")o={name:"linear"};else if(o[0]==="exponential"){const x=o[1];if(typeof x!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);o={name:"exponential",base:x}}else{if(o[0]!=="cubic-bezier")return r.error(`Unknown interpolation type ${String(o[0])}`,1,0);{const x=o.slice(1);if(x.length!==4||x.some(b=>typeof b!="number"||b<0||b>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);o={name:"cubic-bezier",controlPoints:x}}}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(c=r.parse(c,2,ge),!c)return null;const f=[];let _=null;s==="interpolate-hcl"||s==="interpolate-lab"?_=si:r.expectedType&&r.expectedType.kind!=="value"&&(_=r.expectedType);for(let x=0;x<d.length;x+=2){const b=d[x],w=d[x+1],I=x+3,C=x+4;if(typeof b!="number")return r.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',I);if(f.length&&f[f.length-1][0]>=b)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',I);const k=r.parse(w,C,_);if(!k)return null;_=_||k.type,f.push([b,k])}return Y(_,ge)||Y(_,si)||Y(_,Pr)||Y(_,j)||Y(_,A(ge))?new xi(_,s,o,c,f):r.error(`Type ${P(_)} is not interpolatable.`)}evaluate(e){const r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(e);const o=this.input.evaluate(e);if(o<=r[0])return s[0].evaluate(e);const c=r.length;if(o>=r[c-1])return s[c-1].evaluate(e);const d=Xn(r,o),f=xi.interpolationFactor(this.interpolation,o,r[d],r[d+1]),_=s[d].evaluate(e),x=s[d+1].evaluate(e);switch(this.operator){case"interpolate":return yi[this.type.kind](_,x,f);case"interpolate-hcl":return yi.color(_,x,f,"hcl");case"interpolate-lab":return yi.color(_,x,f,"lab")}}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function Hn(i,e,r,s){const o=s-r,c=i-r;return o===0?0:e===1?c/o:(Math.pow(e,c)-1)/(Math.pow(e,o)-1)}class Cs{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 s=null;const o=r.expectedType;o&&o.kind!=="value"&&(s=o);const c=[];for(const f of e.slice(1)){const _=r.parse(f,1+c.length,s,void 0,{typeAnnotation:"omit"});if(!_)return null;s=s||_.type,c.push(_)}if(!s)throw new Error("No output type");const d=o&&c.some(f=>V(o,f.type));return new Cs(d?je:s,c)}evaluate(e){let r,s=null,o=0;for(const c of this.args)if(o++,s=c.evaluate(e),s&&s instanceof jt&&!s.available&&(r||(r=s.name),s=null,o===this.args.length&&(s=r)),s!==null)break;return s}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}function Ro(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 Bo(i,e,r,s){return s.compare(e,r)===0}function Gr(i,e,r){const s=i!=="=="&&i!=="!=";return class Fu{constructor(c,d,f){this.type=Fe,this.lhs=c,this.rhs=d,this.collator=f,this.hasUntypedArgument=c.type.kind==="value"||d.type.kind==="value"}static parse(c,d){if(c.length!==3&&c.length!==4)return d.error("Expected two or three arguments.");const f=c[0];let _=d.parse(c[1],1,je);if(!_)return null;if(!Ro(f,_.type))return d.concat(1).error(`"${f}" comparisons are not supported for type '${P(_.type)}'.`);let x=d.parse(c[2],2,je);if(!x)return null;if(!Ro(f,x.type))return d.concat(2).error(`"${f}" comparisons are not supported for type '${P(x.type)}'.`);if(_.type.kind!==x.type.kind&&_.type.kind!=="value"&&x.type.kind!=="value")return d.error(`Cannot compare types '${P(_.type)}' and '${P(x.type)}'.`);s&&(_.type.kind==="value"&&x.type.kind!=="value"?_=new Pi(x.type,[_]):_.type.kind!=="value"&&x.type.kind==="value"&&(x=new Pi(_.type,[x])));let b=null;if(c.length===4){if(_.type.kind!=="string"&&x.type.kind!=="string"&&_.type.kind!=="value"&&x.type.kind!=="value")return d.error("Cannot use collator to compare non-string types.");if(b=d.parse(c[3],3,Ji),!b)return null}return new Fu(_,x,b)}evaluate(c){const d=this.lhs.evaluate(c),f=this.rhs.evaluate(c);if(s&&this.hasUntypedArgument){const _=Ct(d),x=Ct(f);if(_.kind!==x.kind||_.kind!=="string"&&_.kind!=="number")throw new It(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${_.kind}, ${x.kind}) instead.`)}if(this.collator&&!s&&this.hasUntypedArgument){const _=Ct(d),x=Ct(f);if(_.kind!=="string"||x.kind!=="string")return e(c,d,f)}return this.collator?r(c,d,f,this.collator.evaluate(c)):e(c,d,f)}eachChild(c){c(this.lhs),c(this.rhs),this.collator&&c(this.collator)}outputDefined(){return!0}}}const Fo=Gr("==",function(i,e,r){return e===r},Bo),ql=Gr("!=",function(i,e,r){return e!==r},function(i,e,r,s){return!Bo(0,e,r,s)}),Zl=Gr("<",function(i,e,r){return e<r},function(i,e,r,s){return s.compare(e,r)<0}),Oo=Gr(">",function(i,e,r){return e>r},function(i,e,r,s){return s.compare(e,r)>0}),Vo=Gr("<=",function(i,e,r){return e<=r},function(i,e,r,s){return s.compare(e,r)<=0}),Gl=Gr(">=",function(i,e,r){return e>=r},function(i,e,r,s){return s.compare(e,r)>=0});class Ms{constructor(e,r,s){this.type=Ji,this.locale=s,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error("Expected one argument.");const s=e[1];if(typeof s!="object"||Array.isArray(s))return r.error("Collator options argument must be an object.");const o=r.parse(s["case-sensitive"]!==void 0&&s["case-sensitive"],1,Fe);if(!o)return null;const c=r.parse(s["diacritic-sensitive"]!==void 0&&s["diacritic-sensitive"],1,Fe);if(!c)return null;let d=null;return s.locale&&(d=r.parse(s.locale,1,Ze),!d)?null:new Ms(o,c,d)}evaluate(e){return new _a(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class va{constructor(e,r,s,o,c){this.type=Ze,this.number=e,this.locale=r,this.currency=s,this.minFractionDigits=o,this.maxFractionDigits=c}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");const s=r.parse(e[1],1,ge);if(!s)return null;const o=e[2];if(typeof o!="object"||Array.isArray(o))return r.error("NumberFormat options argument must be an object.");let c=null;if(o.locale&&(c=r.parse(o.locale,1,Ze),!c))return null;let d=null;if(o.currency&&(d=r.parse(o.currency,1,Ze),!d))return null;let f=null;if(o["min-fraction-digits"]&&(f=r.parse(o["min-fraction-digits"],1,ge),!f))return null;let _=null;return o["max-fraction-digits"]&&(_=r.parse(o["max-fraction-digits"],1,ge),!_)?null:new va(s,c,d,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 ks{constructor(e){this.type=hr,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const s=e[1];if(!Array.isArray(s)&&typeof s=="object")return r.error("First argument must be an image or text section.");const o=[];let c=!1;for(let d=1;d<=e.length-1;++d){const f=e[d];if(c&&typeof f=="object"&&!Array.isArray(f)){c=!1;let _=null;if(f["font-scale"]&&(_=r.parse(f["font-scale"],1,ge),!_))return null;let x=null;if(f["text-font"]&&(x=r.parse(f["text-font"],1,A(Ze)),!x))return null;let b=null;if(f["text-color"]&&(b=r.parse(f["text-color"],1,si),!b))return null;const w=o[o.length-1];w.scale=_,w.font=x,w.textColor=b}else{const _=r.parse(e[d],1,je);if(!_)return null;const x=_.type.kind;if(x!=="string"&&x!=="value"&&x!=="null"&&x!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");c=!0,o.push({content:_,scale:null,font:null,textColor:null})}}return new ks(o)}evaluate(e){return new mi(this.sections.map(r=>{const s=r.content.evaluate(e);return Ct(s)===Yi?new ga("",s,null,null,null):new ga(ur(s),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 ba{constructor(e){this.type=Yi,this.input=e}static parse(e,r){if(e.length!==2)return r.error("Expected two arguments.");const s=r.parse(e[1],1,Ze);return s?new ba(s):r.error("No image name provided.")}evaluate(e){const r=this.input.evaluate(e),s=jt.fromString(r);return s&&e.availableImages&&(s.available=e.availableImages.indexOf(r)>-1),s}eachChild(e){e(this.input)}outputDefined(){return!1}}class wa{constructor(e){this.type=ge,this.input=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);const s=r.parse(e[1],1);return s?s.type.kind!=="array"&&s.type.kind!=="string"&&s.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${P(s.type)} instead.`):new wa(s):null}evaluate(e){const r=this.input.evaluate(e);if(typeof r=="string"||Array.isArray(r))return r.length;throw new It(`Expected value to be of type string or array, but found ${P(Ct(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Qi=8192;function Ta(i,e){const r=(180+i[0])/360,s=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,o=Math.pow(2,e.z);return[Math.round(r*o*Qi),Math.round(s*o*Qi)]}function fn(i,e){const r=Math.pow(2,e.z);return[(o=(i[0]/Qi+e.x)/r,360*o-180),(s=(i[1]/Qi+e.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90)];var s,o}function He(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 Kn(i,e){return!(i[0]<=e[0]||i[2]>=e[2]||i[1]<=e[1]||i[3]>=e[3])}function Xl(i,e,r){const s=i[0]-e[0],o=i[1]-e[1],c=i[0]-r[0],d=i[1]-r[1];return s*d-c*o==0&&s*c<=0&&o*d<=0}function zs(i,e,r,s){return(o=[s[0]-r[0],s[1]-r[1]])[0]*(c=[e[0]-i[0],e[1]-i[1]])[1]-o[1]*c[0]!=0&&!(!jo(i,e,r,s)||!jo(r,s,i,e));var o,c}function Wl(i,e,r){for(const s of r)for(let o=0;o<s.length-1;++o)if(zs(i,e,s[o],s[o+1]))return!0;return!1}function mn(i,e,r=!1){let s=!1;for(const f of e)for(let _=0;_<f.length-1;_++){if(Xl(i,f[_],f[_+1]))return r;(c=f[_])[1]>(o=i)[1]!=(d=f[_+1])[1]>o[1]&&o[0]<(d[0]-c[0])*(o[1]-c[1])/(d[1]-c[1])+c[0]&&(s=!s)}var o,c,d;return s}function Hl(i,e){for(const r of e)if(mn(i,r))return!0;return!1}function No(i,e){for(const r of i)if(!mn(r,e))return!1;for(let r=0;r<i.length-1;++r)if(Wl(i[r],i[r+1],e))return!1;return!0}function Kl(i,e){for(const r of e)if(No(i,r))return!0;return!1}function jo(i,e,r,s){const o=s[0]-r[0],c=s[1]-r[1],d=(i[0]-r[0])*c-o*(i[1]-r[1]),f=(e[0]-r[0])*c-o*(e[1]-r[1]);return d>0&&f<0||d<0&&f>0}function Sa(i,e,r){const s=[];for(let o=0;o<i.length;o++){const c=[];for(let d=0;d<i[o].length;d++){const f=Ta(i[o][d],r);He(e,f),c.push(f)}s.push(c)}return s}function Uo(i,e,r){const s=[];for(let o=0;o<i.length;o++){const c=Sa(i[o],e,r);s.push(c)}return s}function $o(i,e,r,s){if(i[0]<r[0]||i[0]>r[2]){const o=.5*s;let c=i[0]-r[0]>o?-s:r[0]-i[0]>o?s:0;c===0&&(c=i[0]-r[2]>o?-s:r[2]-i[0]>o?s:0),i[0]+=c}He(e,i)}function qo(i,e,r,s){const o=Math.pow(2,s.z)*Qi,c=[s.x*Qi,s.y*Qi],d=[];for(const f of i)for(const _ of f){const x=[_.x+c[0],_.y+c[1]];$o(x,e,r,o),d.push(x)}return d}function Zo(i,e,r,s){const o=Math.pow(2,s.z)*Qi,c=[s.x*Qi,s.y*Qi],d=[];for(const _ of i){const x=[];for(const b of _){const w=[b.x+c[0],b.y+c[1]];He(e,w),x.push(w)}d.push(x)}if(e[2]-e[0]<=o/2){(f=e)[0]=f[1]=1/0,f[2]=f[3]=-1/0;for(const _ of d)for(const x of _)$o(x,e,r,o)}var f;return d}class Xr{constructor(e,r){this.type=Fe,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($n(e[1])){const s=e[1];if(s.type==="FeatureCollection"){const o=[];for(const c of s.features){const{type:d,coordinates:f}=c.geometry;d==="Polygon"&&o.push(f),d==="MultiPolygon"&&o.push(...f)}if(o.length)return new Xr(s,{type:"MultiPolygon",coordinates:o})}else if(s.type==="Feature"){const o=s.geometry.type;if(o==="Polygon"||o==="MultiPolygon")return new Xr(s,s.geometry)}else if(s.type==="Polygon"||s.type==="MultiPolygon")return new Xr(s,s)}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,s){const o=[1/0,1/0,-1/0,-1/0],c=[1/0,1/0,-1/0,-1/0],d=r.canonicalID();if(s.type==="Polygon"){const f=Sa(s.coordinates,c,d),_=qo(r.geometry(),o,c,d);if(!Kn(o,c))return!1;for(const x of _)if(!mn(x,f))return!1}if(s.type==="MultiPolygon"){const f=Uo(s.coordinates,c,d),_=qo(r.geometry(),o,c,d);if(!Kn(o,c))return!1;for(const x of _)if(!Hl(x,f))return!1}return!0}(e,this.geometries);if(e.geometryType()==="LineString")return function(r,s){const o=[1/0,1/0,-1/0,-1/0],c=[1/0,1/0,-1/0,-1/0],d=r.canonicalID();if(s.type==="Polygon"){const f=Sa(s.coordinates,c,d),_=Zo(r.geometry(),o,c,d);if(!Kn(o,c))return!1;for(const x of _)if(!No(x,f))return!1}if(s.type==="MultiPolygon"){const f=Uo(s.coordinates,c,d),_=Zo(r.geometry(),o,c,d);if(!Kn(o,c))return!1;for(const x of _)if(!Kl(x,f))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Go=class{constructor(i=[],e=Jl){if(this.data=i,this.length=this.data.length,this.compare=e,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const i=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:e,compare:r}=this,s=e[i];for(;i>0;){const o=i-1>>1,c=e[o];if(r(s,c)>=0)break;e[i]=c,i=o}e[i]=s}_down(i){const{data:e,compare:r}=this,s=this.length>>1,o=e[i];for(;i<s;){let c=1+(i<<1),d=e[c];const f=c+1;if(f<this.length&&r(e[f],d)<0&&(c=f,d=e[f]),r(d,o)>=0)break;e[i]=d,i=c}e[i]=o}};function Jl(i,e){return i<e?-1:i>e?1:0}function Yl(i,e,r,s,o){Xo(i,e,r,s||i.length-1,o||Ql)}function Xo(i,e,r,s,o){for(;s>r;){if(s-r>600){var c=s-r+1,d=e-r+1,f=Math.log(c),_=.5*Math.exp(2*f/3),x=.5*Math.sqrt(f*_*(c-_)/c)*(d-c/2<0?-1:1);Xo(i,e,Math.max(r,Math.floor(e-d*_/c+x)),Math.min(s,Math.floor(e+(c-d)*_/c+x)),o)}var b=i[e],w=r,I=s;for(Jn(i,r,e),o(i[s],b)>0&&Jn(i,r,s);w<I;){for(Jn(i,w,I),w++,I--;o(i[w],b)<0;)w++;for(;o(i[I],b)>0;)I--}o(i[r],b)===0?Jn(i,r,I):Jn(i,++I,s),I<=e&&(r=I+1),e<=I&&(s=I-1)}}function Jn(i,e,r){var s=i[e];i[e]=i[r],i[r]=s}function Ql(i,e){return i<e?-1:i>e?1:0}function Es(i,e){if(i.length<=1)return[i];const r=[];let s,o;for(const c of i){const d=tc(c);d!==0&&(c.area=Math.abs(d),o===void 0&&(o=d<0),o===d<0?(s&&r.push(s),s=[c]):s.push(c))}if(s&&r.push(s),e>1)for(let c=0;c<r.length;c++)r[c].length<=e||(Yl(r[c],e,1,r[c].length-1,ec),r[c]=r[c].slice(0,e));return r}function ec(i,e){return e.area-i.area}function tc(i){let e=0;for(let r,s,o=0,c=i.length,d=c-1;o<c;d=o++)r=i[o],s=i[d],e+=(s.x-r.x)*(r.y+s.y);return e}const Wo=1/298.257223563,Ho=Wo*(2-Wo),Ko=Math.PI/180;class Ia{constructor(e){const r=6378.137*Ko*1e3,s=Math.cos(e*Ko),o=1/(1-Ho*(1-s*s)),c=Math.sqrt(o);this.kx=r*c*s,this.ky=r*c*o*(1-Ho)}distance(e,r){const s=this.wrap(e[0]-r[0])*this.kx,o=(e[1]-r[1])*this.ky;return Math.sqrt(s*s+o*o)}pointOnLine(e,r){let s,o,c,d,f=1/0;for(let _=0;_<e.length-1;_++){let x=e[_][0],b=e[_][1],w=this.wrap(e[_+1][0]-x)*this.kx,I=(e[_+1][1]-b)*this.ky,C=0;w===0&&I===0||(C=(this.wrap(r[0]-x)*this.kx*w+(r[1]-b)*this.ky*I)/(w*w+I*I),C>1?(x=e[_+1][0],b=e[_+1][1]):C>0&&(x+=w/this.kx*C,b+=I/this.ky*C)),w=this.wrap(r[0]-x)*this.kx,I=(r[1]-b)*this.ky;const k=w*w+I*I;k<f&&(f=k,s=x,o=b,c=_,d=C)}return{point:[s,o],index:c,t:Math.max(0,Math.min(1,d))}}wrap(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}}function Jo(i,e){return e[0]-i[0]}function Ds(i){return i[1]-i[0]+1}function dr(i,e){return i[1]>=i[0]&&i[1]<e}function Yn(i,e){if(i[0]>i[1])return[null,null];const r=Ds(i);if(e){if(r===2)return[i,null];const o=Math.floor(r/2);return[[i[0],i[0]+o],[i[0]+o,i[1]]]}if(r===1)return[i,null];const s=Math.floor(r/2)-1;return[[i[0],i[0]+s],[i[0]+s+1,i[1]]]}function Pa(i,e){if(!dr(e,i.length))return[1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let s=e[0];s<=e[1];++s)He(r,i[s]);return r}function Aa(i){const e=[1/0,1/0,-1/0,-1/0];for(const r of i)for(const s of r)He(e,s);return e}function Yo(i){return i[0]!==-1/0&&i[1]!==-1/0&&i[2]!==1/0&&i[3]!==1/0}function Ca(i,e,r){if(!Yo(i)||!Yo(e))return NaN;let s=0,o=0;return i[2]<e[0]&&(s=e[0]-i[2]),i[0]>e[2]&&(s=i[0]-e[2]),i[1]>e[3]&&(o=i[1]-e[3]),i[3]<e[1]&&(o=e[1]-i[3]),r.distance([0,0],[s,o])}function lt(i,e,r){const s=r.pointOnLine(e,i);return r.distance(i,s.point)}function Ma(i,e,r,s,o){const c=Math.min(lt(i,[r,s],o),lt(e,[r,s],o)),d=Math.min(lt(r,[i,e],o),lt(s,[i,e],o));return Math.min(c,d)}function Xe(i,e,r,s,o){if(!dr(e,i.length)||!dr(s,r.length))return 1/0;let c=1/0;for(let d=e[0];d<e[1];++d){const f=i[d],_=i[d+1];for(let x=s[0];x<s[1];++x){const b=r[x],w=r[x+1];if(zs(f,_,b,w))return 0;c=Math.min(c,Ma(f,_,b,w,o))}}return c}function ka(i,e,r,s,o){if(!dr(e,i.length)||!dr(s,r.length))return NaN;let c=1/0;for(let d=e[0];d<=e[1];++d)for(let f=s[0];f<=s[1];++f)if(c=Math.min(c,o.distance(i[d],r[f])),c===0)return c;return c}function yt(i,e,r){if(mn(i,e,!0))return 0;let s=1/0;for(const o of e){const c=o[0],d=o[o.length-1];if(c!==d&&(s=Math.min(s,lt(i,[d,c],r)),s===0))return s;const f=r.pointOnLine(o,i);if(s=Math.min(s,r.distance(i,f.point)),s===0)return s}return s}function ut(i,e,r,s){if(!dr(e,i.length))return NaN;for(let c=e[0];c<=e[1];++c)if(mn(i[c],r,!0))return 0;let o=1/0;for(let c=e[0];c<e[1];++c){const d=i[c],f=i[c+1];for(const _ of r)for(let x=0,b=_.length,w=b-1;x<b;w=x++){const I=_[w],C=_[x];if(zs(d,f,I,C))return 0;o=Math.min(o,Ma(d,f,I,C,s))}}return o}function Qn(i,e){for(const r of i)for(const s of r)if(mn(s,e,!0))return!0;return!1}function Qo(i,e,r,s=1/0){const o=Aa(i),c=Aa(e);if(s!==1/0&&Ca(o,c,r)>=s)return s;if(Kn(o,c)){if(Qn(i,e))return 0}else if(Qn(e,i))return 0;let d=1/0;for(const f of i)for(let _=0,x=f.length,b=x-1;_<x;b=_++){const w=f[b],I=f[_];for(const C of e)for(let k=0,D=C.length,F=D-1;k<D;F=k++){const $=C[F],J=C[k];if(zs(w,I,$,J))return 0;d=Math.min(d,Ma(w,I,$,J,r))}}return d}function za(i,e,r,s,o,c){if(!c)return;const d=Ca(Pa(s,c),o,r);d<e&&i.push([d,c,[0,0]])}function Ls(i,e,r,s,o,c,d){if(!c||!d)return;const f=Ca(Pa(s,c),Pa(o,d),r);f<e&&i.push([f,c,d])}function Rs(i,e,r,s,o=1/0){let c=Math.min(s.distance(i[0],r[0][0]),o);if(c===0)return c;const d=new Go([[0,[0,i.length-1],[0,0]]],Jo),f=Aa(r);for(;d.length>0;){const _=d.pop();if(_[0]>=c)continue;const x=_[1],b=e?50:100;if(Ds(x)<=b){if(!dr(x,i.length))return NaN;if(e){const w=ut(i,x,r,s);if(isNaN(w)||w===0)return w;c=Math.min(c,w)}else for(let w=x[0];w<=x[1];++w){const I=yt(i[w],r,s);if(c=Math.min(c,I),c===0)return 0}}else{const w=Yn(x,e);za(d,c,s,i,f,w[0]),za(d,c,s,i,f,w[1])}}return c}function Bs(i,e,r,s,o,c=1/0){let d=Math.min(c,o.distance(i[0],r[0]));if(d===0)return d;const f=new Go([[0,[0,i.length-1],[0,r.length-1]]],Jo);for(;f.length>0;){const _=f.pop();if(_[0]>=d)continue;const x=_[1],b=_[2],w=e?50:100,I=s?50:100;if(Ds(x)<=w&&Ds(b)<=I){if(!dr(x,i.length)&&dr(b,r.length))return NaN;let C;if(e&&s)C=Xe(i,x,r,b,o),d=Math.min(d,C);else if(e&&!s){const k=i.slice(x[0],x[1]+1);for(let D=b[0];D<=b[1];++D)if(C=lt(r[D],k,o),d=Math.min(d,C),d===0)return d}else if(!e&&s){const k=r.slice(b[0],b[1]+1);for(let D=x[0];D<=x[1];++D)if(C=lt(i[D],k,o),d=Math.min(d,C),d===0)return d}else C=ka(i,x,r,b,o),d=Math.min(d,C)}else{const C=Yn(x,e),k=Yn(b,s);Ls(f,d,o,i,r,C[0],k[0]),Ls(f,d,o,i,r,C[0],k[1]),Ls(f,d,o,i,r,C[1],k[0]),Ls(f,d,o,i,r,C[1],k[1])}}return d}function Ea(i){return i.type==="MultiPolygon"?i.coordinates.map(e=>({type:"Polygon",coordinates:e})):i.type==="MultiLineString"?i.coordinates.map(e=>({type:"LineString",coordinates:e})):i.type==="MultiPoint"?i.coordinates.map(e=>({type:"Point",coordinates:e})):[i]}class kr{constructor(e,r){this.type=ge,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if($n(e[1])){const s=e[1];if(s.type==="FeatureCollection")return new kr(s,s.features.map(o=>Ea(o.geometry)).flat());if(s.type==="Feature")return new kr(s,Ea(s.geometry));if("type"in s&&"coordinates"in s)return new kr(s,Ea(s))}return r.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return function(r,s){const o=r.geometry(),c=o.flat().map(_=>fn([_.x,_.y],r.canonical));if(o.length===0)return NaN;const d=new Ia(c[0][1]);let f=1/0;for(const _ of s){switch(_.type){case"Point":f=Math.min(f,Bs(c,!1,[_.coordinates],!1,d,f));break;case"LineString":f=Math.min(f,Bs(c,!1,_.coordinates,!0,d,f));break;case"Polygon":f=Math.min(f,Rs(c,!1,_.coordinates,d,f))}if(f===0)return f}return f}(e,this.geometries);if(e.geometryType()==="LineString")return function(r,s){const o=r.geometry(),c=o.flat().map(_=>fn([_.x,_.y],r.canonical));if(o.length===0)return NaN;const d=new Ia(c[0][1]);let f=1/0;for(const _ of s){switch(_.type){case"Point":f=Math.min(f,Bs(c,!0,[_.coordinates],!1,d,f));break;case"LineString":f=Math.min(f,Bs(c,!0,_.coordinates,!0,d,f));break;case"Polygon":f=Math.min(f,Rs(c,!0,_.coordinates,d,f))}if(f===0)return f}return f}(e,this.geometries);if(e.geometryType()==="Polygon")return function(r,s){const o=r.geometry();if(o.length===0||o[0].length===0)return NaN;const c=Es(o,0).map(_=>_.map(x=>x.map(b=>fn([b.x,b.y],r.canonical)))),d=new Ia(c[0][0][0][1]);let f=1/0;for(const _ of s)for(const x of c){switch(_.type){case"Point":f=Math.min(f,Rs([_.coordinates],!1,x,d,f));break;case"LineString":f=Math.min(f,Rs(_.coordinates,!0,x,d,f));break;case"Polygon":f=Math.min(f,Qo(x,_.coordinates,d,f))}if(f===0)return f}return f}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}const Wr={"==":Fo,"!=":ql,">":Oo,"<":Zl,">=":Gl,"<=":Vo,array:Pi,at:xa,boolean:Pi,case:Ps,coalesce:Cs,collator:Ms,format:ks,image:ba,in:Gn,"index-of":Ss,interpolate:xi,"interpolate-hcl":xi,"interpolate-lab":xi,length:wa,let:et,literal:Zr,match:Is,number:Pi,"number-format":va,object:Pi,slice:As,step:pn,string:Pi,"to-boolean":Ar,"to-color":Ar,"to-number":Ar,"to-string":Ar,var:Ts,within:Xr,distance:kr};class vi{constructor(e,r,s,o){this.name=e,this.type=r,this._evaluate=s,this.args=o}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,r){const s=e[0],o=vi.definitions[s];if(!o)return r.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0);const c=Array.isArray(o)?o[0]:o.type,d=Array.isArray(o)?[[o[1],o[2]]]:o.overloads,f=d.filter(([x])=>!Array.isArray(x)||x.length===e.length-1);let _=null;for(const[x,b]of f){_=new Cr(r.registry,Os,r.path,null,r.scope);const w=[];let I=!1;for(let C=1;C<e.length;C++){const k=e[C],D=Array.isArray(x)?x[C-1]:x.type,F=_.parse(k,1+w.length,D);if(!F){I=!0;break}w.push(F)}if(!I)if(Array.isArray(x)&&x.length!==w.length)_.error(`Expected ${x.length} arguments, but found ${w.length} instead.`);else{for(let C=0;C<w.length;C++){const k=Array.isArray(x)?x[C]:x.type,D=w[C];_.concat(C+1).checkSubtype(k,D.type)}if(_.errors.length===0)return new vi(s,c,b,w)}}if(f.length===1)r.errors.push(..._.errors);else{const x=(f.length?f:d).map(([w])=>{return I=w,Array.isArray(I)?`(${I.map(P).join(", ")})`:`(${P(I.type)}...)`;var I}).join(" | "),b=[];for(let w=1;w<e.length;w++){const I=r.parse(e[w],1+b.length);if(!I)return null;b.push(P(I.type))}r.error(`Expected arguments of type ${x}, but found (${b.join(", ")}) instead.`)}return null}static register(e,r){vi.definitions=r;for(const s in r)e[s]=vi}}function Da(i,[e,r,s,o]){e=e.evaluate(i),r=r.evaluate(i),s=s.evaluate(i);const c=o?o.evaluate(i):1,d=bs(e,r,s,c);if(d)throw new It(d);return new it(e/255,r/255,s/255,c,!1)}function Fs(i,e){return i in e}function La(i,e){const r=e[i];return r===void 0?null:r}function Hr(i){return{type:i}}function Os(i){if(i instanceof Ts)return Os(i.boundExpression);if(i instanceof vi&&i.name==="error"||i instanceof Ms||i instanceof Xr||i instanceof kr)return!1;const e=i instanceof Ar||i instanceof Pi;let r=!0;return i.eachChild(s=>{r=e?r&&Os(s):r&&s instanceof Zr}),!!r&&Vs(i)&&Ns(i,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Vs(i){if(i instanceof vi&&(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 Xr||i instanceof kr)return!1;let e=!0;return i.eachChild(r=>{e&&!Vs(r)&&(e=!1)}),e}function es(i){if(i instanceof vi&&i.name==="feature-state")return!1;let e=!0;return i.eachChild(r=>{e&&!es(r)&&(e=!1)}),e}function Ns(i,e){if(i instanceof vi&&e.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild(s=>{r&&!Ns(s,e)&&(r=!1)}),r}function el(i){return{result:"success",value:i}}function _n(i){return{result:"error",value:i}}function Kr(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function Ra(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function gn(i){return!!i.expression&&i.expression.interpolated}function Je(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":i===null?"null":typeof i}function ts(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function tl(i){return i}function il(i,e){const r=e.type==="color",s=i.stops&&typeof i.stops[0][0]=="object",o=s||!(s||i.property!==void 0),c=i.type||(gn(e)?"exponential":"interval");if(r||e.type==="padding"){const b=r?it.parse:_i.parse;(i=Hi({},i)).stops&&(i.stops=i.stops.map(w=>[w[0],b(w[1])])),i.default=b(i.default?i.default:e.default)}if(i.colorSpace&&(d=i.colorSpace)!=="rgb"&&d!=="hcl"&&d!=="lab")throw new Error(`Unknown color space: "${i.colorSpace}"`);var d;let f,_,x;if(c==="exponential")f=Ba;else if(c==="interval")f=Us;else if(c==="categorical"){f=js,_=Object.create(null);for(const b of i.stops)_[b[0]]=b[1];x=typeof i.stops[0][0]}else{if(c!=="identity")throw new Error(`Unknown function type "${c}"`);f=Fa}if(s){const b={},w=[];for(let k=0;k<i.stops.length;k++){const D=i.stops[k],F=D[0].zoom;b[F]===void 0&&(b[F]={zoom:F,type:i.type,property:i.property,default:i.default,stops:[]},w.push(F)),b[F].stops.push([D[0].value,D[1]])}const I=[];for(const k of w)I.push([b[k].zoom,il(b[k],e)]);const C={name:"linear"};return{kind:"composite",interpolationType:C,interpolationFactor:xi.interpolationFactor.bind(void 0,C),zoomStops:I.map(k=>k[0]),evaluate:({zoom:k},D)=>Ba({stops:I,base:i.base},e,k).evaluate(k,D)}}if(o){const b=c==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:b,interpolationFactor:xi.interpolationFactor.bind(void 0,b),zoomStops:i.stops.map(w=>w[0]),evaluate:({zoom:w})=>f(i,e,w,_,x)}}return{kind:"source",evaluate(b,w){const I=w&&w.properties?w.properties[i.property]:void 0;return I===void 0?Jr(i.default,e.default):f(i,e,I,_,x)}}}function Jr(i,e,r){return i!==void 0?i:e!==void 0?e:r!==void 0?r:void 0}function js(i,e,r,s,o){return Jr(typeof r===o?s[r]:void 0,i.default,e.default)}function Us(i,e,r){if(Je(r)!=="number")return Jr(i.default,e.default);const s=i.stops.length;if(s===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[s-1][0])return i.stops[s-1][1];const o=Xn(i.stops.map(c=>c[0]),r);return i.stops[o][1]}function Ba(i,e,r){const s=i.base!==void 0?i.base:1;if(Je(r)!=="number")return Jr(i.default,e.default);const o=i.stops.length;if(o===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[o-1][0])return i.stops[o-1][1];const c=Xn(i.stops.map(b=>b[0]),r),d=function(b,w,I,C){const k=C-I,D=b-I;return k===0?0:w===1?D/k:(Math.pow(w,D)-1)/(Math.pow(w,k)-1)}(r,s,i.stops[c][0],i.stops[c+1][0]),f=i.stops[c][1],_=i.stops[c+1][1],x=yi[e.type]||tl;return typeof f.evaluate=="function"?{evaluate(...b){const w=f.evaluate.apply(void 0,b),I=_.evaluate.apply(void 0,b);if(w!==void 0&&I!==void 0)return x(w,I,d,i.colorSpace)}}:x(f,_,d,i.colorSpace)}function Fa(i,e,r){switch(e.type){case"color":r=it.parse(r);break;case"formatted":r=mi.fromString(r.toString());break;case"resolvedImage":r=jt.fromString(r.toString());break;case"padding":r=_i.parse(r);break;default:Je(r)===e.type||e.type==="enum"&&e.values[r]||(r=void 0)}return Jr(r,i.default,e.default)}vi.register(Wr,{error:[{kind:"error"},[Ze],(i,[e])=>{throw new It(e.evaluate(i))}],typeof:[Ze,[je],(i,[e])=>P(Ct(e.evaluate(i)))],"to-rgba":[A(ge,4),[si],(i,[e])=>{const[r,s,o,c]=e.evaluate(i).rgb;return[255*r,255*s,255*o,c]}],rgb:[si,[ge,ge,ge],Da],rgba:[si,[ge,ge,ge,ge],Da],has:{type:Fe,overloads:[[[Ze],(i,[e])=>Fs(e.evaluate(i),i.properties())],[[Ze,Ei],(i,[e,r])=>Fs(e.evaluate(i),r.evaluate(i))]]},get:{type:je,overloads:[[[Ze],(i,[e])=>La(e.evaluate(i),i.properties())],[[Ze,Ei],(i,[e,r])=>La(e.evaluate(i),r.evaluate(i))]]},"feature-state":[je,[Ze],(i,[e])=>La(e.evaluate(i),i.featureState||{})],properties:[Ei,[],i=>i.properties()],"geometry-type":[Ze,[],i=>i.geometryType()],id:[je,[],i=>i.id()],zoom:[ge,[],i=>i.globals.zoom],"heatmap-density":[ge,[],i=>i.globals.heatmapDensity||0],"line-progress":[ge,[],i=>i.globals.lineProgress||0],accumulated:[je,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[ge,Hr(ge),(i,e)=>{let r=0;for(const s of e)r+=s.evaluate(i);return r}],"*":[ge,Hr(ge),(i,e)=>{let r=1;for(const s of e)r*=s.evaluate(i);return r}],"-":{type:ge,overloads:[[[ge,ge],(i,[e,r])=>e.evaluate(i)-r.evaluate(i)],[[ge],(i,[e])=>-e.evaluate(i)]]},"/":[ge,[ge,ge],(i,[e,r])=>e.evaluate(i)/r.evaluate(i)],"%":[ge,[ge,ge],(i,[e,r])=>e.evaluate(i)%r.evaluate(i)],ln2:[ge,[],()=>Math.LN2],pi:[ge,[],()=>Math.PI],e:[ge,[],()=>Math.E],"^":[ge,[ge,ge],(i,[e,r])=>Math.pow(e.evaluate(i),r.evaluate(i))],sqrt:[ge,[ge],(i,[e])=>Math.sqrt(e.evaluate(i))],log10:[ge,[ge],(i,[e])=>Math.log(e.evaluate(i))/Math.LN10],ln:[ge,[ge],(i,[e])=>Math.log(e.evaluate(i))],log2:[ge,[ge],(i,[e])=>Math.log(e.evaluate(i))/Math.LN2],sin:[ge,[ge],(i,[e])=>Math.sin(e.evaluate(i))],cos:[ge,[ge],(i,[e])=>Math.cos(e.evaluate(i))],tan:[ge,[ge],(i,[e])=>Math.tan(e.evaluate(i))],asin:[ge,[ge],(i,[e])=>Math.asin(e.evaluate(i))],acos:[ge,[ge],(i,[e])=>Math.acos(e.evaluate(i))],atan:[ge,[ge],(i,[e])=>Math.atan(e.evaluate(i))],min:[ge,Hr(ge),(i,e)=>Math.min(...e.map(r=>r.evaluate(i)))],max:[ge,Hr(ge),(i,e)=>Math.max(...e.map(r=>r.evaluate(i)))],abs:[ge,[ge],(i,[e])=>Math.abs(e.evaluate(i))],round:[ge,[ge],(i,[e])=>{const r=e.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[ge,[ge],(i,[e])=>Math.floor(e.evaluate(i))],ceil:[ge,[ge],(i,[e])=>Math.ceil(e.evaluate(i))],"filter-==":[Fe,[Ze,je],(i,[e,r])=>i.properties()[e.value]===r.value],"filter-id-==":[Fe,[je],(i,[e])=>i.id()===e.value],"filter-type-==":[Fe,[Ze],(i,[e])=>i.geometryType()===e.value],"filter-<":[Fe,[Ze,je],(i,[e,r])=>{const s=i.properties()[e.value],o=r.value;return typeof s==typeof o&&s<o}],"filter-id-<":[Fe,[je],(i,[e])=>{const r=i.id(),s=e.value;return typeof r==typeof s&&r<s}],"filter->":[Fe,[Ze,je],(i,[e,r])=>{const s=i.properties()[e.value],o=r.value;return typeof s==typeof o&&s>o}],"filter-id->":[Fe,[je],(i,[e])=>{const r=i.id(),s=e.value;return typeof r==typeof s&&r>s}],"filter-<=":[Fe,[Ze,je],(i,[e,r])=>{const s=i.properties()[e.value],o=r.value;return typeof s==typeof o&&s<=o}],"filter-id-<=":[Fe,[je],(i,[e])=>{const r=i.id(),s=e.value;return typeof r==typeof s&&r<=s}],"filter->=":[Fe,[Ze,je],(i,[e,r])=>{const s=i.properties()[e.value],o=r.value;return typeof s==typeof o&&s>=o}],"filter-id->=":[Fe,[je],(i,[e])=>{const r=i.id(),s=e.value;return typeof r==typeof s&&r>=s}],"filter-has":[Fe,[je],(i,[e])=>e.value in i.properties()],"filter-has-id":[Fe,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[Fe,[A(Ze)],(i,[e])=>e.value.indexOf(i.geometryType())>=0],"filter-id-in":[Fe,[A(je)],(i,[e])=>e.value.indexOf(i.id())>=0],"filter-in-small":[Fe,[Ze,A(je)],(i,[e,r])=>r.value.indexOf(i.properties()[e.value])>=0],"filter-in-large":[Fe,[Ze,A(je)],(i,[e,r])=>function(s,o,c,d){for(;c<=d;){const f=c+d>>1;if(o[f]===s)return!0;o[f]>s?d=f-1:c=f+1}return!1}(i.properties()[e.value],r.value,0,r.value.length-1)],all:{type:Fe,overloads:[[[Fe,Fe],(i,[e,r])=>e.evaluate(i)&&r.evaluate(i)],[Hr(Fe),(i,e)=>{for(const r of e)if(!r.evaluate(i))return!1;return!0}]]},any:{type:Fe,overloads:[[[Fe,Fe],(i,[e,r])=>e.evaluate(i)||r.evaluate(i)],[Hr(Fe),(i,e)=>{for(const r of e)if(r.evaluate(i))return!0;return!1}]]},"!":[Fe,[Fe],(i,[e])=>!e.evaluate(i)],"is-supported-script":[Fe,[Ze],(i,[e])=>{const r=i.globals&&i.globals.isSupportedScript;return!r||r(e.evaluate(i))}],upcase:[Ze,[Ze],(i,[e])=>e.evaluate(i).toUpperCase()],downcase:[Ze,[Ze],(i,[e])=>e.evaluate(i).toLowerCase()],concat:[Ze,Hr(je),(i,e)=>e.map(r=>ur(r.evaluate(i))).join("")],"resolved-locale":[Ze,[Ji],(i,[e])=>e.evaluate(i).resolvedLocale()]});class $s{constructor(e,r){var s;this.expression=e,this._warningHistory={},this._evaluator=new Zn,this._defaultValue=r?(s=r).type==="color"&&ts(s.default)?new it(0,0,0,0):s.type==="color"?it.parse(s.default)||null:s.type==="padding"?_i.parse(s.default)||null:s.type==="variableAnchorOffsetCollection"?gi.parse(s.default)||null:s.default===void 0?null:s.default:null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(e,r,s,o,c,d){return this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=s,this._evaluator.canonical=o,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=d,this.expression.evaluate(this._evaluator)}evaluate(e,r,s,o,c,d){this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=s||null,this._evaluator.canonical=o,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=d||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 It(`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 is(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in Wr}function Yr(i,e){const r=new Cr(Wr,Os,[],e?function(o){const c={color:si,string:Ze,number:ge,enum:Ze,boolean:Fe,formatted:hr,padding:Pr,resolvedImage:Yi,variableAnchorOffsetCollection:j};return o.type==="array"?A(c[o.value]||je,o.length):c[o.type]}(e):void 0),s=r.parse(i,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return s?el(new $s(s,e)):_n(r.errors)}class Oa{constructor(e,r){this.kind=e,this._styleExpression=r,this.isStateDependent=e!=="constant"&&!es(r.expression)}evaluateWithoutErrorHandling(e,r,s,o,c,d){return this._styleExpression.evaluateWithoutErrorHandling(e,r,s,o,c,d)}evaluate(e,r,s,o,c,d){return this._styleExpression.evaluate(e,r,s,o,c,d)}}class Va{constructor(e,r,s,o){this.kind=e,this.zoomStops=s,this._styleExpression=r,this.isStateDependent=e!=="camera"&&!es(r.expression),this.interpolationType=o}evaluateWithoutErrorHandling(e,r,s,o,c,d){return this._styleExpression.evaluateWithoutErrorHandling(e,r,s,o,c,d)}evaluate(e,r,s,o,c,d){return this._styleExpression.evaluate(e,r,s,o,c,d)}interpolationFactor(e,r,s){return this.interpolationType?xi.interpolationFactor(this.interpolationType,e,r,s):0}}function rl(i,e){const r=Yr(i,e);if(r.result==="error")return r;const s=r.value.expression,o=Vs(s);if(!o&&!Kr(e))return _n([new Qt("","data expressions not supported")]);const c=Ns(s,["zoom"]);if(!c&&!Ra(e))return _n([new Qt("","zoom expressions not supported")]);const d=Zs(s);return d||c?d instanceof Qt?_n([d]):d instanceof xi&&!gn(e)?_n([new Qt("",'"interpolate" expressions cannot be used with this property')]):el(d?new Va(o?"camera":"composite",r.value,d.labels,d instanceof xi?d.interpolation:void 0):new Oa(o?"constant":"source",r.value)):_n([new Qt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class qs{constructor(e,r){this._parameters=e,this._specification=r,Hi(this,il(this._parameters,this._specification))}static deserialize(e){return new qs(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Zs(i){let e=null;if(i instanceof et)e=Zs(i.result);else if(i instanceof Cs){for(const r of i.args)if(e=Zs(r),e)break}else(i instanceof pn||i instanceof xi)&&i.input instanceof vi&&i.input.name==="zoom"&&(e=i);return e instanceof Qt||i.eachChild(r=>{const s=Zs(r);s instanceof Qt?e=s:!e&&s?e=new Qt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&s&&e!==s&&(e=new Qt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}function yn(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(!yn(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}const Gs={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function ei(i){if(i==null)return{filter:()=>!0,needGeometry:!1};yn(i)||(i=Xs(i));const e=Yr(i,Gs);if(e.result==="error")throw new Error(e.value.map(r=>`${r.key}: ${r.message}`).join(", "));return{filter:(r,s,o)=>e.value.evaluate(r,s,{},o),needGeometry:Na(i)}}function rs(i,e){return i<e?-1:i>e?1:0}function Na(i){if(!Array.isArray(i))return!1;if(i[0]==="within"||i[0]==="distance")return!0;for(let e=1;e<i.length;e++)if(Na(i[e]))return!0;return!1}function Xs(i){if(!i)return!0;const e=i[0];return i.length<=1?e!=="any":e==="=="?ja(i[1],i[2],"=="):e==="!="?vn(ja(i[1],i[2],"==")):e==="<"||e===">"||e==="<="||e===">="?ja(i[1],i[2],e):e==="any"?(r=i.slice(1),["any"].concat(r.map(Xs))):e==="all"?["all"].concat(i.slice(1).map(Xs)):e==="none"?["all"].concat(i.slice(1).map(Xs).map(vn)):e==="in"?xn(i[1],i.slice(2)):e==="!in"?vn(xn(i[1],i.slice(2))):e==="has"?Ua(i[1]):e!=="!has"||vn(Ua(i[1]));var r}function ja(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 xn(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(rs)]]:["filter-in-small",i,["literal",e]]}}function Ua(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function vn(i){return["!",i]}function $a(i){const e=typeof i;if(e==="number"||e==="boolean"||e==="string"||i==null)return JSON.stringify(i);if(Array.isArray(i)){let o="[";for(const c of i)o+=`${$a(c)},`;return`${o}]`}const r=Object.keys(i).sort();let s="{";for(let o=0;o<r.length;o++)s+=`${JSON.stringify(r[o])}:${$a(i[r[o]])},`;return`${s}}`}function qa(i){let e="";for(const r of qr)e+=`/${$a(i[r])}`;return e}function nl(i){const e=i.value;return e?[new pe(i.key,e,"constants have been deprecated as of v8")]:[]}function dt(i){return i instanceof Number||i instanceof String||i instanceof Boolean?i.valueOf():i}function Qr(i){if(Array.isArray(i))return i.map(Qr);if(i instanceof Object&&!(i instanceof Number||i instanceof String||i instanceof Boolean)){const e={};for(const r in i)e[r]=Qr(i[r]);return e}return dt(i)}function ai(i){const e=i.key,r=i.value,s=i.valueSpec||{},o=i.objectElementValidators||{},c=i.style,d=i.styleSpec,f=i.validateSpec;let _=[];const x=Je(r);if(x!=="object")return[new pe(e,r,`object expected, ${x} found`)];for(const b in r){const w=b.split(".")[0],I=s[w]||s["*"];let C;if(o[w])C=o[w];else if(s[w])C=f;else if(o["*"])C=o["*"];else{if(!s["*"]){_.push(new pe(e,r[b],`unknown property "${b}"`));continue}C=f}_=_.concat(C({key:(e&&`${e}.`)+b,value:r[b],valueSpec:I,style:c,styleSpec:d,object:r,objectKey:b,validateSpec:f},r))}for(const b in s)o[b]||s[b].required&&s[b].default===void 0&&r[b]===void 0&&_.push(new pe(e,r,`missing required property "${b}"`));return _}function Ws(i){const e=i.value,r=i.valueSpec,s=i.style,o=i.styleSpec,c=i.key,d=i.arrayElementValidator||i.validateSpec;if(Je(e)!=="array")return[new pe(c,e,`array expected, ${Je(e)} found`)];if(r.length&&e.length!==r.length)return[new pe(c,e,`array length ${r.length} expected, length ${e.length} found`)];if(r["min-length"]&&e.length<r["min-length"])return[new pe(c,e,`array length at least ${r["min-length"]} expected, length ${e.length} found`)];let f={type:r.value,values:r.values};o.$version<7&&(f.function=r.function),Je(r.value)==="object"&&(f=r.value);let _=[];for(let x=0;x<e.length;x++)_=_.concat(d({array:e,arrayIndex:x,value:e[x],valueSpec:f,validateSpec:i.validateSpec,style:s,styleSpec:o,key:`${c}[${x}]`}));return _}function ns(i){const e=i.key,r=i.value,s=i.valueSpec;let o=Je(r);return o==="number"&&r!=r&&(o="NaN"),o!=="number"?[new pe(e,r,`number expected, ${o} found`)]:"minimum"in s&&r<s.minimum?[new pe(e,r,`${r} is less than the minimum value ${s.minimum}`)]:"maximum"in s&&r>s.maximum?[new pe(e,r,`${r} is greater than the maximum value ${s.maximum}`)]:[]}function Za(i){const e=i.valueSpec,r=dt(i.value.type);let s,o,c,d={};const f=r!=="categorical"&&i.value.property===void 0,_=!f,x=Je(i.value.stops)==="array"&&Je(i.value.stops[0])==="array"&&Je(i.value.stops[0][0])==="object",b=ai({key:i.key,value:i.value,valueSpec:i.styleSpec.function,validateSpec:i.validateSpec,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(C){if(r==="identity")return[new pe(C.key,C.value,'identity function may not have a "stops" property')];let k=[];const D=C.value;return k=k.concat(Ws({key:C.key,value:D,valueSpec:C.valueSpec,validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec,arrayElementValidator:w})),Je(D)==="array"&&D.length===0&&k.push(new pe(C.key,D,"array must have at least one stop")),k},default:function(C){return C.validateSpec({key:C.key,value:C.value,valueSpec:e,validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec})}}});return r==="identity"&&f&&b.push(new pe(i.key,i.value,'missing required property "property"')),r==="identity"||i.value.stops||b.push(new pe(i.key,i.value,'missing required property "stops"')),r==="exponential"&&i.valueSpec.expression&&!gn(i.valueSpec)&&b.push(new pe(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(_&&!Kr(i.valueSpec)?b.push(new pe(i.key,i.value,"property functions not supported")):f&&!Ra(i.valueSpec)&&b.push(new pe(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!x||i.value.property!==void 0||b.push(new pe(i.key,i.value,'"property" property is required')),b;function w(C){let k=[];const D=C.value,F=C.key;if(Je(D)!=="array")return[new pe(F,D,`array expected, ${Je(D)} found`)];if(D.length!==2)return[new pe(F,D,`array length 2 expected, length ${D.length} found`)];if(x){if(Je(D[0])!=="object")return[new pe(F,D,`object expected, ${Je(D[0])} found`)];if(D[0].zoom===void 0)return[new pe(F,D,"object stop key must have zoom")];if(D[0].value===void 0)return[new pe(F,D,"object stop key must have value")];if(c&&c>dt(D[0].zoom))return[new pe(F,D[0].zoom,"stop zoom values must appear in ascending order")];dt(D[0].zoom)!==c&&(c=dt(D[0].zoom),o=void 0,d={}),k=k.concat(ai({key:`${F}[0]`,value:D[0],valueSpec:{zoom:{}},validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec,objectElementValidators:{zoom:ns,value:I}}))}else k=k.concat(I({key:`${F}[0]`,value:D[0],valueSpec:{},validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec},D));return is(Qr(D[1]))?k.concat([new pe(`${F}[1]`,D[1],"expressions are not allowed in function stops.")]):k.concat(C.validateSpec({key:`${F}[1]`,value:D[1],valueSpec:e,validateSpec:C.validateSpec,style:C.style,styleSpec:C.styleSpec}))}function I(C,k){const D=Je(C.value),F=dt(C.value),$=C.value!==null?C.value:k;if(s){if(D!==s)return[new pe(C.key,$,`${D} stop domain type must match previous stop domain type ${s}`)]}else s=D;if(D!=="number"&&D!=="string"&&D!=="boolean")return[new pe(C.key,$,"stop domain value must be a number, string, or boolean")];if(D!=="number"&&r!=="categorical"){let J=`number expected, ${D} found`;return Kr(e)&&r===void 0&&(J+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new pe(C.key,$,J)]}return r!=="categorical"||D!=="number"||isFinite(F)&&Math.floor(F)===F?r!=="categorical"&&D==="number"&&o!==void 0&&F<o?[new pe(C.key,$,"stop domain values must appear in ascending order")]:(o=F,r==="categorical"&&F in d?[new pe(C.key,$,"stop domain values must be unique")]:(d[F]=!0,[])):[new pe(C.key,$,`integer expected, found ${F}`)]}}function en(i){const e=(i.expressionContext==="property"?rl:Yr)(Qr(i.value),i.valueSpec);if(e.result==="error")return e.value.map(s=>new pe(`${i.key}${s.key}`,i.value,s.message));const r=e.value.expression||e.value._styleExpression.expression;if(i.expressionContext==="property"&&i.propertyKey==="text-font"&&!r.outputDefined())return[new pe(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"&&!es(r))return[new pe(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter"&&!es(r))return[new pe(i.key,i.value,'"feature-state" data expressions are not supported with filters.')];if(i.expressionContext&&i.expressionContext.indexOf("cluster")===0){if(!Ns(r,["zoom","feature-state"]))return[new pe(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(i.expressionContext==="cluster-initial"&&!Vs(r))return[new pe(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ss(i){const e=i.key,r=i.value,s=i.valueSpec,o=[];return Array.isArray(s.values)?s.values.indexOf(dt(r))===-1&&o.push(new pe(e,r,`expected one of [${s.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(s.values).indexOf(dt(r))===-1&&o.push(new pe(e,r,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(r)} found`)),o}function as(i){return yn(Qr(i.value))?en(Hi({},i,{expressionContext:"filter",valueSpec:{value:"boolean"}})):os(i)}function os(i){const e=i.value,r=i.key;if(Je(e)!=="array")return[new pe(r,e,`array expected, ${Je(e)} found`)];const s=i.styleSpec;let o,c=[];if(e.length<1)return[new pe(r,e,"filter array must have at least 1 element")];switch(c=c.concat(ss({key:`${r}[0]`,value:e[0],valueSpec:s.filter_operator,style:i.style,styleSpec:i.styleSpec})),dt(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&dt(e[1])==="$type"&&c.push(new pe(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&c.push(new pe(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(o=Je(e[1]),o!=="string"&&c.push(new pe(`${r}[1]`,e[1],`string expected, ${o} found`)));for(let d=2;d<e.length;d++)o=Je(e[d]),dt(e[1])==="$type"?c=c.concat(ss({key:`${r}[${d}]`,value:e[d],valueSpec:s.geometry_type,style:i.style,styleSpec:i.styleSpec})):o!=="string"&&o!=="number"&&o!=="boolean"&&c.push(new pe(`${r}[${d}]`,e[d],`string, number, or boolean expected, ${o} found`));break;case"any":case"all":case"none":for(let d=1;d<e.length;d++)c=c.concat(os({key:`${r}[${d}]`,value:e[d],style:i.style,styleSpec:i.styleSpec}));break;case"has":case"!has":o=Je(e[1]),e.length!==2?c.push(new pe(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):o!=="string"&&c.push(new pe(`${r}[1]`,e[1],`string expected, ${o} found`))}return c}function Ga(i,e){const r=i.key,s=i.validateSpec,o=i.style,c=i.styleSpec,d=i.value,f=i.objectKey,_=c[`${e}_${i.layerType}`];if(!_)return[];const x=f.match(/^(.*)-transition$/);if(e==="paint"&&x&&_[x[1]]&&_[x[1]].transition)return s({key:r,value:d,valueSpec:c.transition,style:o,styleSpec:c});const b=i.valueSpec||_[f];if(!b)return[new pe(r,d,`unknown property "${f}"`)];let w;if(Je(d)==="string"&&Kr(b)&&!b.tokens&&(w=/^{([^}]+)}$/.exec(d)))return[new pe(r,d,`"${f}" does not support interpolation syntax Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(w[1])} }\`.`)];const I=[];return i.layerType==="symbol"&&(f==="text-field"&&o&&!o.glyphs&&I.push(new pe(r,d,'use of "text-field" requires a style "glyphs" property')),f==="text-font"&&ts(Qr(d))&&dt(d.type)==="identity"&&I.push(new pe(r,d,'"text-font" does not support identity functions'))),I.concat(s({key:i.key,value:d,valueSpec:b,style:o,styleSpec:c,expressionContext:"property",propertyType:e,propertyKey:f}))}function Xa(i){return Ga(i,"paint")}function Wa(i){return Ga(i,"layout")}function Ha(i){let e=[];const r=i.value,s=i.key,o=i.style,c=i.styleSpec;r.type||r.ref||e.push(new pe(s,r,'either "type" or "ref" is required'));let d=dt(r.type);const f=dt(r.ref);if(r.id){const _=dt(r.id);for(let x=0;x<i.arrayIndex;x++){const b=o.layers[x];dt(b.id)===_&&e.push(new pe(s,r.id,`duplicate layer id "${r.id}", previously used at line ${b.id.__line__}`))}}if("ref"in r){let _;["type","source","source-layer","filter","layout"].forEach(x=>{x in r&&e.push(new pe(s,r[x],`"${x}" is prohibited for ref layers`))}),o.layers.forEach(x=>{dt(x.id)===f&&(_=x)}),_?_.ref?e.push(new pe(s,r.ref,"ref cannot reference another ref layer")):d=dt(_.type):e.push(new pe(s,r.ref,`ref layer "${f}" not found`))}else if(d!=="background")if(r.source){const _=o.sources&&o.sources[r.source],x=_&&dt(_.type);_?x==="vector"&&d==="raster"?e.push(new pe(s,r.source,`layer "${r.id}" requires a raster source`)):x!=="raster-dem"&&d==="hillshade"?e.push(new pe(s,r.source,`layer "${r.id}" requires a raster-dem source`)):x==="raster"&&d!=="raster"?e.push(new pe(s,r.source,`layer "${r.id}" requires a vector source`)):x!=="vector"||r["source-layer"]?x==="raster-dem"&&d!=="hillshade"?e.push(new pe(s,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):d!=="line"||!r.paint||!r.paint["line-gradient"]||x==="geojson"&&_.lineMetrics||e.push(new pe(s,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new pe(s,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new pe(s,r.source,`source "${r.source}" not found`))}else e.push(new pe(s,r,'missing required property "source"'));return e=e.concat(ai({key:s,value:r,valueSpec:c.layer,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,objectElementValidators:{"*":()=>[],type:()=>i.validateSpec({key:`${s}.type`,value:r.type,valueSpec:c.layer.type,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,object:r,objectKey:"type"}),filter:as,layout:_=>ai({layer:r,key:_.key,value:_.value,style:_.style,styleSpec:_.styleSpec,validateSpec:_.validateSpec,objectElementValidators:{"*":x=>Wa(Hi({layerType:d},x))}}),paint:_=>ai({layer:r,key:_.key,value:_.value,style:_.style,styleSpec:_.styleSpec,validateSpec:_.validateSpec,objectElementValidators:{"*":x=>Xa(Hi({layerType:d},x))}})}})),e}function pr(i){const e=i.value,r=i.key,s=Je(e);return s!=="string"?[new pe(r,e,`string expected, ${s} found`)]:[]}const Ka={promoteId:function({key:i,value:e}){if(Je(e)==="string")return pr({key:i,value:e});{const r=[];for(const s in e)r.push(...pr({key:`${i}.${s}`,value:e[s]}));return r}}};function sl(i){const e=i.value,r=i.key,s=i.styleSpec,o=i.style,c=i.validateSpec;if(!e.type)return[new pe(r,e,'"type" is required')];const d=dt(e.type);let f;switch(d){case"vector":case"raster":return f=ai({key:r,value:e,valueSpec:s[`source_${d.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:Ka,validateSpec:c}),f;case"raster-dem":return f=function(_){var x;const b=(x=_.sourceName)!==null&&x!==void 0?x:"",w=_.value,I=_.styleSpec,C=I.source_raster_dem,k=_.style;let D=[];const F=Je(w);if(w===void 0)return D;if(F!=="object")return D.push(new pe("source_raster_dem",w,`object expected, ${F} found`)),D;const $=dt(w.encoding)==="custom",J=["redFactor","greenFactor","blueFactor","baseShift"],Z=_.value.encoding?`"${_.value.encoding}"`:"Default";for(const K in w)!$&&J.includes(K)?D.push(new pe(K,w[K],`In "${b}": "${K}" is only valid when "encoding" is set to "custom". ${Z} encoding found`)):C[K]?D=D.concat(_.validateSpec({key:K,value:w[K],valueSpec:C[K],validateSpec:_.validateSpec,style:k,styleSpec:I})):D.push(new pe(K,w[K],`unknown property "${K}"`));return D}({sourceName:r,value:e,style:i.style,styleSpec:s,validateSpec:c}),f;case"geojson":if(f=ai({key:r,value:e,valueSpec:s.source_geojson,style:o,styleSpec:s,validateSpec:c,objectElementValidators:Ka}),e.cluster)for(const _ in e.clusterProperties){const[x,b]=e.clusterProperties[_],w=typeof x=="string"?[x,["accumulated"],["get",_]]:x;f.push(...en({key:`${r}.${_}.map`,value:b,validateSpec:c,expressionContext:"cluster-map"})),f.push(...en({key:`${r}.${_}.reduce`,value:w,validateSpec:c,expressionContext:"cluster-reduce"}))}return f;case"video":return ai({key:r,value:e,valueSpec:s.source_video,style:o,validateSpec:c,styleSpec:s});case"image":return ai({key:r,value:e,valueSpec:s.source_image,style:o,validateSpec:c,styleSpec:s});case"canvas":return[new pe(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ss({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:o,validateSpec:c,styleSpec:s})}}function Ja(i){const e=i.value,r=i.styleSpec,s=r.light,o=i.style;let c=[];const d=Je(e);if(e===void 0)return c;if(d!=="object")return c=c.concat([new pe("light",e,`object expected, ${d} found`)]),c;for(const f in e){const _=f.match(/^(.*)-transition$/);c=c.concat(_&&s[_[1]]&&s[_[1]].transition?i.validateSpec({key:f,value:e[f],valueSpec:r.transition,validateSpec:i.validateSpec,style:o,styleSpec:r}):s[f]?i.validateSpec({key:f,value:e[f],valueSpec:s[f],validateSpec:i.validateSpec,style:o,styleSpec:r}):[new pe(f,e[f],`unknown property "${f}"`)])}return c}function al(i){const e=i.value,r=i.styleSpec,s=r.sky,o=i.style,c=Je(e);if(e===void 0)return[];if(c!=="object")return[new pe("sky",e,`object expected, ${c} found`)];let d=[];for(const f in e)d=d.concat(s[f]?i.validateSpec({key:f,value:e[f],valueSpec:s[f],style:o,styleSpec:r}):[new pe(f,e[f],`unknown property "${f}"`)]);return d}function Ya(i){const e=i.value,r=i.styleSpec,s=r.terrain,o=i.style;let c=[];const d=Je(e);if(e===void 0)return c;if(d!=="object")return c=c.concat([new pe("terrain",e,`object expected, ${d} found`)]),c;for(const f in e)c=c.concat(s[f]?i.validateSpec({key:f,value:e[f],valueSpec:s[f],validateSpec:i.validateSpec,style:o,styleSpec:r}):[new pe(f,e[f],`unknown property "${f}"`)]);return c}function Qa(i){let e=[];const r=i.value,s=i.key;if(Array.isArray(r)){const o=[],c=[];for(const d in r)r[d].id&&o.includes(r[d].id)&&e.push(new pe(s,r,`all the sprites' ids must be unique, but ${r[d].id} is duplicated`)),o.push(r[d].id),r[d].url&&c.includes(r[d].url)&&e.push(new pe(s,r,`all the sprites' URLs must be unique, but ${r[d].url} is duplicated`)),c.push(r[d].url),e=e.concat(ai({key:`${s}[${d}]`,value:r[d],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:i.validateSpec}));return e}return pr({key:s,value:r})}const eo={"*":()=>[],array:Ws,boolean:function(i){const e=i.value,r=i.key,s=Je(e);return s!=="boolean"?[new pe(r,e,`boolean expected, ${s} found`)]:[]},number:ns,color:function(i){const e=i.key,r=i.value,s=Je(r);return s!=="string"?[new pe(e,r,`color expected, ${s} found`)]:it.parse(String(r))?[]:[new pe(e,r,`color expected, "${r}" found`)]},constants:nl,enum:ss,filter:as,function:Za,layer:Ha,object:ai,source:sl,light:Ja,sky:al,terrain:Ya,projection:function(i){const e=i.value,r=i.styleSpec,s=r.projection,o=i.style,c=Je(e);if(e===void 0)return[];if(c!=="object")return[new pe("projection",e,`object expected, ${c} found`)];let d=[];for(const f in e)d=d.concat(s[f]?i.validateSpec({key:f,value:e[f],valueSpec:s[f],style:o,styleSpec:r}):[new pe(f,e[f],`unknown property "${f}"`)]);return d},string:pr,formatted:function(i){return pr(i).length===0?[]:en(i)},resolvedImage:function(i){return pr(i).length===0?[]:en(i)},padding:function(i){const e=i.key,r=i.value;if(Je(r)==="array"){if(r.length<1||r.length>4)return[new pe(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const s={type:"number"};let o=[];for(let c=0;c<r.length;c++)o=o.concat(i.validateSpec({key:`${e}[${c}]`,value:r[c],validateSpec:i.validateSpec,valueSpec:s}));return o}return ns({key:e,value:r,valueSpec:{}})},variableAnchorOffsetCollection:function(i){const e=i.key,r=i.value,s=Je(r),o=i.styleSpec;if(s!=="array"||r.length<1||r.length%2!=0)return[new pe(e,r,"variableAnchorOffsetCollection requires a non-empty array of even length")];let c=[];for(let d=0;d<r.length;d+=2)c=c.concat(ss({key:`${e}[${d}]`,value:r[d],valueSpec:o.layout_symbol["text-anchor"]})),c=c.concat(Ws({key:`${e}[${d+1}]`,value:r[d+1],valueSpec:{length:2,value:"number"},validateSpec:i.validateSpec,style:i.style,styleSpec:o}));return c},sprite:Qa};function ls(i){const e=i.value,r=i.valueSpec,s=i.styleSpec;return i.validateSpec=ls,r.expression&&ts(dt(e))?Za(i):r.expression&&is(Qr(e))?en(i):r.type&&eo[r.type]?eo[r.type](i):ai(Hi({},i,{valueSpec:r.type?s[r.type]:r}))}function ol(i){const e=i.value,r=i.key,s=pr(i);return s.length||(e.indexOf("{fontstack}")===-1&&s.push(new pe(r,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&s.push(new pe(r,e,'"glyphs" url must include a "{range}" token'))),s}function Ai(i,e=re){let r=[];return r=r.concat(ls({key:"",value:i,valueSpec:e.$root,styleSpec:e,style:i,validateSpec:ls,objectElementValidators:{glyphs:ol,"*":()=>[]}})),i.constants&&(r=r.concat(nl({key:"constants",value:i.constants,style:i,styleSpec:e,validateSpec:ls}))),to(r)}function Di(i){return function(e){return i({...e,validateSpec:ls})}}function to(i){return[].concat(i).sort((e,r)=>e.line-r.line)}function Li(i){return function(...e){return to(i.apply(this,e))}}Ai.source=Li(Di(sl)),Ai.sprite=Li(Di(Qa)),Ai.glyphs=Li(Di(ol)),Ai.light=Li(Di(Ja)),Ai.sky=Li(Di(al)),Ai.terrain=Li(Di(Ya)),Ai.layer=Li(Di(Ha)),Ai.filter=Li(Di(as)),Ai.paintProperty=Li(Di(Xa)),Ai.layoutProperty=Li(Di(Wa));const fr=Ai,ic=fr.light,io=fr.sky,rc=fr.paintProperty,nc=fr.layoutProperty;function ro(i,e){let r=!1;if(e&&e.length)for(const s of e)i.fire(new Tr(new Error(s.message))),r=!0;return r}class bn{constructor(e,r,s){const o=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const d=new Int32Array(this.arrayBuffer);e=d[0],this.d=(r=d[1])+2*(s=d[2]);for(let _=0;_<this.d*this.d;_++){const x=d[3+_],b=d[3+_+1];o.push(x===b?null:d.subarray(x,b))}const f=d[3+o.length+1];this.keys=d.subarray(d[3+o.length],f),this.bboxes=d.subarray(f),this.insert=this._insertReadonly}else{this.d=r+2*s;for(let d=0;d<this.d*this.d;d++)o.push([]);this.keys=[],this.bboxes=[]}this.n=r,this.extent=e,this.padding=s,this.scale=r/e,this.uid=0;const c=s/r*e;this.min=-c,this.max=e+c}insert(e,r,s,o,c){this._forEachCell(r,s,o,c,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(r),this.bboxes.push(s),this.bboxes.push(o),this.bboxes.push(c)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,r,s,o,c,d){this.cells[c].push(d)}query(e,r,s,o,c){const d=this.min,f=this.max;if(e<=d&&r<=d&&f<=s&&f<=o&&!c)return Array.prototype.slice.call(this.keys);{const _=[];return this._forEachCell(e,r,s,o,this._queryCell,_,{},c),_}}_queryCell(e,r,s,o,c,d,f,_){const x=this.cells[c];if(x!==null){const b=this.keys,w=this.bboxes;for(let I=0;I<x.length;I++){const C=x[I];if(f[C]===void 0){const k=4*C;(_?_(w[k+0],w[k+1],w[k+2],w[k+3]):e<=w[k+2]&&r<=w[k+3]&&s>=w[k+0]&&o>=w[k+1])?(f[C]=!0,d.push(b[C])):f[C]=!1}}}}_forEachCell(e,r,s,o,c,d,f,_){const x=this._convertToCellCoord(e),b=this._convertToCellCoord(r),w=this._convertToCellCoord(s),I=this._convertToCellCoord(o);for(let C=x;C<=w;C++)for(let k=b;k<=I;k++){const D=this.d*k+C;if((!_||_(this._convertFromCellCoord(C),this._convertFromCellCoord(k),this._convertFromCellCoord(C+1),this._convertFromCellCoord(k+1)))&&c.call(this,e,r,s,o,D,d,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 s=0;for(let d=0;d<this.cells.length;d++)s+=this.cells[d].length;const o=new Int32Array(r+s+this.keys.length+this.bboxes.length);o[0]=this.extent,o[1]=this.n,o[2]=this.padding;let c=r;for(let d=0;d<e.length;d++){const f=e[d];o[3+d]=c,o.set(f,c),c+=f.length}return o[3+e.length]=c,o.set(this.keys,c),c+=this.keys.length,o[3+e.length+1]=c,o.set(this.bboxes,c),c+=this.bboxes.length,o.buffer}static serialize(e,r){const s=e.toArrayBuffer();return r&&r.push(s),{buffer:s}}static deserialize(e){return new bn(e.buffer)}}const er={};function Pe(i,e,r={}){if(er[i])throw new Error(`${i} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:i,writeable:!1}),er[i]={klass:e,omit:r.omit||[],shallow:r.shallow||[]}}Pe("Object",Object),Pe("TransferableGridIndex",bn),Pe("Color",it),Pe("Error",Error),Pe("AJAXError",fi),Pe("ResolvedImage",jt),Pe("StylePropertyFunction",qs),Pe("StyleExpression",$s,{omit:["_evaluator"]}),Pe("ZoomDependentExpression",Va),Pe("ZoomConstantExpression",Oa),Pe("CompoundExpression",vi,{omit:["_evaluate"]});for(const i in Wr)Wr[i]._classRegistryKey||Pe(`Expression_${i}`,Wr[i]);function ll(i){return i&&typeof ArrayBuffer<"u"&&(i instanceof ArrayBuffer||i.constructor&&i.constructor.name==="ArrayBuffer")}function no(i){return i.$name||i.constructor._classRegistryKey}function cl(i){return!function(e){if(e===null||typeof e!="object")return!1;const r=no(e);return!(!r||r==="Object")}(i)&&(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||i instanceof Error||ll(i)||Xi(i)||ArrayBuffer.isView(i)||i instanceof ImageData)}function cs(i,e){if(cl(i))return(ll(i)||Xi(i))&&e&&e.push(i),ArrayBuffer.isView(i)&&e&&e.push(i.buffer),i instanceof ImageData&&e&&e.push(i.data.buffer),i;if(Array.isArray(i)){const c=[];for(const d of i)c.push(cs(d,e));return c}if(typeof i!="object")throw new Error("can't serialize object of type "+typeof i);const r=no(i);if(!r)throw new Error(`can't serialize object of unregistered class ${i.constructor.name}`);if(!er[r])throw new Error(`${r} is not registered.`);const{klass:s}=er[r],o=s.serialize?s.serialize(i,e):{};if(s.serialize){if(e&&o===e[e.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const c in i){if(!i.hasOwnProperty(c)||er[r].omit.indexOf(c)>=0)continue;const d=i[c];o[c]=er[r].shallow.indexOf(c)>=0?d:cs(d,e)}i instanceof Error&&(o.message=i.message)}if(o.$name)throw new Error("$name property is reserved for worker serialization logic.");return r!=="Object"&&(o.$name=r),o}function tr(i){if(cl(i))return i;if(Array.isArray(i))return i.map(tr);if(typeof i!="object")throw new Error("can't deserialize object of type "+typeof i);const e=no(i)||"Object";if(!er[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=er[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(i);const s=Object.create(r.prototype);for(const o of Object.keys(i)){if(o==="$name")continue;const c=i[o];s[o]=er[e].shallow.indexOf(o)>=0?c:tr(c)}return s}class hl{constructor(){this.first=!0}update(e,r){const s=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=s,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=s,!0):(this.lastFloorZoom>s?(this.lastIntegerZoom=s+1,this.lastIntegerZoomTime=r):this.lastFloorZoom<s&&(this.lastIntegerZoom=s,this.lastIntegerZoomTime=r),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=s,!0))}}const we={"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 so(i){for(const e of i)if(ao(e.charCodeAt(0)))return!0;return!1}function sc(i){for(const e of i)if(!ul(e.charCodeAt(0)))return!1;return!0}function ul(i){return!(we.Arabic(i)||we["Arabic Supplement"](i)||we["Arabic Extended-A"](i)||we["Arabic Presentation Forms-A"](i)||we["Arabic Presentation Forms-B"](i))}function ao(i){return!(i!==746&&i!==747&&(i<4352||!(we["Bopomofo Extended"](i)||we.Bopomofo(i)||we["CJK Compatibility Forms"](i)&&!(i>=65097&&i<=65103)||we["CJK Compatibility Ideographs"](i)||we["CJK Compatibility"](i)||we["CJK Radicals Supplement"](i)||we["CJK Strokes"](i)||!(!we["CJK Symbols and Punctuation"](i)||i>=12296&&i<=12305||i>=12308&&i<=12319||i===12336)||we["CJK Unified Ideographs Extension A"](i)||we["CJK Unified Ideographs"](i)||we["Enclosed CJK Letters and Months"](i)||we["Hangul Compatibility Jamo"](i)||we["Hangul Jamo Extended-A"](i)||we["Hangul Jamo Extended-B"](i)||we["Hangul Jamo"](i)||we["Hangul Syllables"](i)||we.Hiragana(i)||we["Ideographic Description Characters"](i)||we.Kanbun(i)||we["Kangxi Radicals"](i)||we["Katakana Phonetic Extensions"](i)||we.Katakana(i)&&i!==12540||!(!we["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)||!(!we["Small Form Variants"](i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||we["Unified Canadian Aboriginal Syllabics"](i)||we["Unified Canadian Aboriginal Syllabics Extended"](i)||we["Vertical Forms"](i)||we["Yijing Hexagram Symbols"](i)||we["Yi Syllables"](i)||we["Yi Radicals"](i))))}function dl(i){return!(ao(i)||function(e){return!!(we["Latin-1 Supplement"](e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||we["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)||we["Letterlike Symbols"](e)||we["Number Forms"](e)||we["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)||we["Control Pictures"](e)&&e!==9251||we["Optical Character Recognition"](e)||we["Enclosed Alphanumerics"](e)||we["Geometric Shapes"](e)||we["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||we["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||we["CJK Symbols and Punctuation"](e)||we.Katakana(e)||we["Private Use Area"](e)||we["CJK Compatibility Forms"](e)||we["Small Form Variants"](e)||we["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 zr(i){return i>=1424&&i<=2303||we["Arabic Presentation Forms-A"](i)||we["Arabic Presentation Forms-B"](i)}function pl(i,e){return!(!e&&zr(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||we.Khmer(i))}function oo(i){for(const e of i)if(zr(e.charCodeAt(0)))return!0;return!1}const Er=new class{constructor(){this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null}setState(i){this.pluginStatus=i.pluginStatus,this.pluginURL=i.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(i){this.applyArabicShaping=i.applyArabicShaping,this.processBidirectionalText=i.processBidirectionalText,this.processStyledBidirectionalText=i.processStyledBidirectionalText}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getPluginURL(){return this.pluginURL}getRTLTextPluginStatus(){return this.pluginStatus}};class ct{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 hl,this.transition={})}isSupportedScript(e){return function(r,s){for(const o of r)if(!pl(o.charCodeAt(0),s))return!1;return!0}(e,Er.getRTLTextPluginStatus()==="loaded")}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),s=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*s}:{fromScale:.5,toScale:1,t:1-(1-s)*r}}}class Hs{constructor(e,r){this.property=e,this.value=r,this.expression=function(s,o){if(ts(s))return new qs(s,o);if(is(s)){const c=rl(s,o);if(c.result==="error")throw new Error(c.value.map(d=>`${d.key}: ${d.message}`).join(", "));return c.value}{let c=s;return o.type==="color"&&typeof s=="string"?c=it.parse(s):o.type!=="padding"||typeof s!="number"&&!Array.isArray(s)?o.type==="variableAnchorOffsetCollection"&&Array.isArray(s)&&(c=gi.parse(s)):c=_i.parse(s),{kind:"constant",evaluate:()=>c}}}(r===void 0?e.specification.default:r,e.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,r,s){return this.property.possiblyEvaluate(this,e,r,s)}}class wn{constructor(e){this.property=e,this.value=new Hs(e,void 0)}transitioned(e,r){return new fl(this.property,this.value,r,Si({},e.transition,this.transition),e.now)}untransitioned(){return new fl(this.property,this.value,null,{},0)}}class Tn{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return rt(this._values[e].value.value)}setValue(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new wn(this._values[e].property)),this._values[e].value=new Hs(this._values[e].property,r===null?void 0:rt(r))}getTransition(e){return rt(this._values[e].transition)}setTransition(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new wn(this._values[e].property)),this._values[e].transition=rt(r)||void 0}serialize(){const e={};for(const r of Object.keys(this._values)){const s=this.getValue(r);s!==void 0&&(e[r]=s);const o=this.getTransition(r);o!==void 0&&(e[`${r}-transition`]=o)}return e}transitioned(e,r){const s=new lo(this._properties);for(const o of Object.keys(this._values))s._values[o]=this._values[o].transitioned(e,r._values[o]);return s}untransitioned(){const e=new lo(this._properties);for(const r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class fl{constructor(e,r,s,o,c){this.property=e,this.value=r,this.begin=c+o.delay||0,this.end=this.begin+o.duration||0,e.specification.transition&&(o.delay||o.duration)&&(this.prior=s)}possiblyEvaluate(e,r,s){const o=e.now||0,c=this.value.possiblyEvaluate(e,r,s),d=this.prior;if(d){if(o>this.end)return this.prior=null,c;if(this.value.isDataDriven())return this.prior=null,c;if(o<this.begin)return d.possiblyEvaluate(e,r,s);{const f=(o-this.begin)/(this.end-this.begin);return this.property.interpolate(d.possiblyEvaluate(e,r,s),c,function(_){if(_<=0)return 0;if(_>=1)return 1;const x=_*_,b=x*_;return 4*(_<.5?b:3*(_-x)+b-.75)}(f))}}return c}}class lo{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,r,s){const o=new Ks(this._properties);for(const c of Object.keys(this._values))o._values[c]=this._values[c].possiblyEvaluate(e,r,s);return o}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class hs{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}hasValue(e){return this._values[e].value!==void 0}getValue(e){return rt(this._values[e].value)}setValue(e,r){this._values[e]=new Hs(this._values[e].property,r===null?void 0:rt(r))}serialize(){const e={};for(const r of Object.keys(this._values)){const s=this.getValue(r);s!==void 0&&(e[r]=s)}return e}possiblyEvaluate(e,r,s){const o=new Ks(this._properties);for(const c of Object.keys(this._values))o._values[c]=this._values[c].possiblyEvaluate(e,r,s);return o}}class ir{constructor(e,r,s){this.property=e,this.value=r,this.parameters=s}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,r,s,o){return this.property.evaluate(this.value,this.parameters,e,r,s,o)}}class Ks{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class ze{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,s){const o=yi[this.specification.type];return o?o(e,r,s):e}}class Be{constructor(e,r){this.specification=e,this.overrides=r}possiblyEvaluate(e,r,s,o){return new ir(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(r,null,{},s,o)}:e.expression,r)}interpolate(e,r,s){if(e.value.kind!=="constant"||r.value.kind!=="constant")return e;if(e.value.value===void 0||r.value.value===void 0)return new ir(this,{kind:"constant",value:void 0},e.parameters);const o=yi[this.specification.type];if(o){const c=o(e.value.value,r.value.value,s);return new ir(this,{kind:"constant",value:c},e.parameters)}return e}evaluate(e,r,s,o,c,d){return e.kind==="constant"?e.value:e.evaluate(r,s,o,c,d)}}class h extends Be{possiblyEvaluate(e,r,s,o){if(e.value===void 0)return new ir(this,{kind:"constant",value:void 0},r);if(e.expression.kind==="constant"){const c=e.expression.evaluate(r,null,{},s,o),d=e.property.specification.type==="resolvedImage"&&typeof c!="string"?c.name:c,f=this._calculate(d,d,d,r);return new ir(this,{kind:"constant",value:f},r)}if(e.expression.kind==="camera"){const c=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 ir(this,{kind:"constant",value:c},r)}return new ir(this,e.expression,r)}evaluate(e,r,s,o,c,d){if(e.kind==="source"){const f=e.evaluate(r,s,o,c,d);return this._calculate(f,f,f,r)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(r.zoom)-1},s,o),e.evaluate({zoom:Math.floor(r.zoom)},s,o),e.evaluate({zoom:Math.floor(r.zoom)+1},s,o),r):e.value}_calculate(e,r,s,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:s,to:r}}interpolate(e){return e}}class t{constructor(e){this.specification=e}possiblyEvaluate(e,r,s,o){if(e.value!==void 0){if(e.expression.kind==="constant"){const c=e.expression.evaluate(r,null,{},s,o);return this._calculate(c,c,c,r)}return this._calculate(e.expression.evaluate(new ct(Math.floor(r.zoom-1),r)),e.expression.evaluate(new ct(Math.floor(r.zoom),r)),e.expression.evaluate(new ct(Math.floor(r.zoom+1),r)),r)}}_calculate(e,r,s,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:s,to:r}}interpolate(e){return e}}class n{constructor(e){this.specification=e}possiblyEvaluate(e,r,s,o){return!!e.expression.evaluate(r,null,{},s,o)}interpolate(){return!1}}class a{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const r in e){const s=e[r];s.specification.overridable&&this.overridableProperties.push(r);const o=this.defaultPropertyValues[r]=new Hs(s,void 0),c=this.defaultTransitionablePropertyValues[r]=new wn(s);this.defaultTransitioningPropertyValues[r]=c.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=o.possiblyEvaluate({})}}}Pe("DataDrivenProperty",Be),Pe("DataConstantProperty",ze),Pe("CrossFadedDataDrivenProperty",h),Pe("CrossFadedProperty",t),Pe("ColorRampProperty",n);const l="-transition";class u extends un{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 hs(r.layout)),r.paint)){this._transitionablePaint=new Tn(r.paint);for(const s in e.paint)this.setPaintProperty(s,e.paint[s],{validate:!1});for(const s in e.layout)this.setLayoutProperty(s,e.layout[s],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ks(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,r,s={}){r!=null&&this._validate(nc,`layers.${this.id}.layout.${e}`,e,r,s)||(e!=="visibility"?this._unevaluatedLayout.setValue(e,r):this.visibility=r)}getPaintProperty(e){return e.endsWith(l)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,r,s={}){if(r!=null&&this._validate(rc,`layers.${this.id}.paint.${e}`,e,r,s))return!1;if(e.endsWith(l))return this._transitionablePaint.setTransition(e.slice(0,-11),r||void 0),!1;{const o=this._transitionablePaint._values[e],c=o.property.specification["property-type"]==="cross-faded-data-driven",d=o.value.isDataDriven(),f=o.value;this._transitionablePaint.setValue(e,r),this._handleSpecialPaintPropertyUpdate(e);const _=this._transitionablePaint._values[e].value;return _.isDataDriven()||d||c||this._handleOverridablePaintPropertyUpdate(e,f,_)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,r,s){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),Bn(e,(r,s)=>!(r===void 0||s==="layout"&&!Object.keys(r).length||s==="paint"&&!Object.keys(r).length))}_validate(e,r,s,o,c={}){return(!c||c.validate!==!1)&&ro(this,e.call(fr,{key:r,layerType:this.type,objectKey:s,value:o,styleSpec:re,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 ir&&Kr(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}}const m={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class g{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 y{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 v(i,e=1){let r=0,s=0;return{members:i.map(o=>{const c=m[o.type].BYTES_PER_ELEMENT,d=r=S(r,Math.max(e,c)),f=o.components||1;return s=Math.max(s,c),r+=c*f,{name:o.name,type:o.type,components:f,offset:d}}),size:S(r,Math.max(s,e)),alignment:e}}function S(i,e){return Math.ceil(i/e)*e}class T extends y{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r){const s=this.length;return this.resize(s+1),this.emplace(s,e,r)}emplace(e,r,s){const o=2*e;return this.int16[o+0]=r,this.int16[o+1]=s,e}}T.prototype.bytesPerElement=4,Pe("StructArrayLayout2i4",T);class M extends y{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,r,s)}emplace(e,r,s,o){const c=3*e;return this.int16[c+0]=r,this.int16[c+1]=s,this.int16[c+2]=o,e}}M.prototype.bytesPerElement=6,Pe("StructArrayLayout3i6",M);class z extends y{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,o){const c=this.length;return this.resize(c+1),this.emplace(c,e,r,s,o)}emplace(e,r,s,o,c){const d=4*e;return this.int16[d+0]=r,this.int16[d+1]=s,this.int16[d+2]=o,this.int16[d+3]=c,e}}z.prototype.bytesPerElement=8,Pe("StructArrayLayout4i8",z);class R extends y{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,o,c,d){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,s,o,c,d)}emplace(e,r,s,o,c,d,f){const _=6*e;return this.int16[_+0]=r,this.int16[_+1]=s,this.int16[_+2]=o,this.int16[_+3]=c,this.int16[_+4]=d,this.int16[_+5]=f,e}}R.prototype.bytesPerElement=12,Pe("StructArrayLayout2i4i12",R);class N extends y{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,o,c,d){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,s,o,c,d)}emplace(e,r,s,o,c,d,f){const _=4*e,x=8*e;return this.int16[_+0]=r,this.int16[_+1]=s,this.uint8[x+4]=o,this.uint8[x+5]=c,this.uint8[x+6]=d,this.uint8[x+7]=f,e}}N.prototype.bytesPerElement=8,Pe("StructArrayLayout2i4ub8",N);class B extends y{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r){const s=this.length;return this.resize(s+1),this.emplace(s,e,r)}emplace(e,r,s){const o=2*e;return this.float32[o+0]=r,this.float32[o+1]=s,e}}B.prototype.bytesPerElement=8,Pe("StructArrayLayout2f8",B);class U extends y{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,s,o,c,d,f,_,x,b){const w=this.length;return this.resize(w+1),this.emplace(w,e,r,s,o,c,d,f,_,x,b)}emplace(e,r,s,o,c,d,f,_,x,b,w){const I=10*e;return this.uint16[I+0]=r,this.uint16[I+1]=s,this.uint16[I+2]=o,this.uint16[I+3]=c,this.uint16[I+4]=d,this.uint16[I+5]=f,this.uint16[I+6]=_,this.uint16[I+7]=x,this.uint16[I+8]=b,this.uint16[I+9]=w,e}}U.prototype.bytesPerElement=20,Pe("StructArrayLayout10ui20",U);class G extends y{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,s,o,c,d,f,_,x,b,w,I){const C=this.length;return this.resize(C+1),this.emplace(C,e,r,s,o,c,d,f,_,x,b,w,I)}emplace(e,r,s,o,c,d,f,_,x,b,w,I,C){const k=12*e;return this.int16[k+0]=r,this.int16[k+1]=s,this.int16[k+2]=o,this.int16[k+3]=c,this.uint16[k+4]=d,this.uint16[k+5]=f,this.uint16[k+6]=_,this.uint16[k+7]=x,this.int16[k+8]=b,this.int16[k+9]=w,this.int16[k+10]=I,this.int16[k+11]=C,e}}G.prototype.bytesPerElement=24,Pe("StructArrayLayout4i4ui4i24",G);class O extends y{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,r,s)}emplace(e,r,s,o){const c=3*e;return this.float32[c+0]=r,this.float32[c+1]=s,this.float32[c+2]=o,e}}O.prototype.bytesPerElement=12,Pe("StructArrayLayout3f12",O);class H extends y{_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}}H.prototype.bytesPerElement=4,Pe("StructArrayLayout1ul4",H);class Q extends y{_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,s,o,c,d,f,_,x){const b=this.length;return this.resize(b+1),this.emplace(b,e,r,s,o,c,d,f,_,x)}emplace(e,r,s,o,c,d,f,_,x,b){const w=10*e,I=5*e;return this.int16[w+0]=r,this.int16[w+1]=s,this.int16[w+2]=o,this.int16[w+3]=c,this.int16[w+4]=d,this.int16[w+5]=f,this.uint32[I+3]=_,this.uint16[w+8]=x,this.uint16[w+9]=b,e}}Q.prototype.bytesPerElement=20,Pe("StructArrayLayout6i1ul2ui20",Q);class ee extends y{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,o,c,d){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,s,o,c,d)}emplace(e,r,s,o,c,d,f){const _=6*e;return this.int16[_+0]=r,this.int16[_+1]=s,this.int16[_+2]=o,this.int16[_+3]=c,this.int16[_+4]=d,this.int16[_+5]=f,e}}ee.prototype.bytesPerElement=12,Pe("StructArrayLayout2i2i2i12",ee);class oe extends y{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,o,c){const d=this.length;return this.resize(d+1),this.emplace(d,e,r,s,o,c)}emplace(e,r,s,o,c,d){const f=4*e,_=8*e;return this.float32[f+0]=r,this.float32[f+1]=s,this.float32[f+2]=o,this.int16[_+6]=c,this.int16[_+7]=d,e}}oe.prototype.bytesPerElement=16,Pe("StructArrayLayout2f1f2i16",oe);class he extends y{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,o,c,d){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,s,o,c,d)}emplace(e,r,s,o,c,d,f){const _=16*e,x=4*e,b=8*e;return this.uint8[_+0]=r,this.uint8[_+1]=s,this.float32[x+1]=o,this.float32[x+2]=c,this.int16[b+6]=d,this.int16[b+7]=f,e}}he.prototype.bytesPerElement=16,Pe("StructArrayLayout2ub2f2i16",he);class Te extends y{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,r,s)}emplace(e,r,s,o){const c=3*e;return this.uint16[c+0]=r,this.uint16[c+1]=s,this.uint16[c+2]=o,e}}Te.prototype.bytesPerElement=6,Pe("StructArrayLayout3ui6",Te);class Se extends y{_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,s,o,c,d,f,_,x,b,w,I,C,k,D,F,$){const J=this.length;return this.resize(J+1),this.emplace(J,e,r,s,o,c,d,f,_,x,b,w,I,C,k,D,F,$)}emplace(e,r,s,o,c,d,f,_,x,b,w,I,C,k,D,F,$,J){const Z=24*e,K=12*e,ie=48*e;return this.int16[Z+0]=r,this.int16[Z+1]=s,this.uint16[Z+2]=o,this.uint16[Z+3]=c,this.uint32[K+2]=d,this.uint32[K+3]=f,this.uint32[K+4]=_,this.uint16[Z+10]=x,this.uint16[Z+11]=b,this.uint16[Z+12]=w,this.float32[K+7]=I,this.float32[K+8]=C,this.uint8[ie+36]=k,this.uint8[ie+37]=D,this.uint8[ie+38]=F,this.uint32[K+10]=$,this.int16[Z+22]=J,e}}Se.prototype.bytesPerElement=48,Pe("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Se);class ue extends y{_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,s,o,c,d,f,_,x,b,w,I,C,k,D,F,$,J,Z,K,ie,ce,xe,Le,be,ye,ke,Ae){const Ie=this.length;return this.resize(Ie+1),this.emplace(Ie,e,r,s,o,c,d,f,_,x,b,w,I,C,k,D,F,$,J,Z,K,ie,ce,xe,Le,be,ye,ke,Ae)}emplace(e,r,s,o,c,d,f,_,x,b,w,I,C,k,D,F,$,J,Z,K,ie,ce,xe,Le,be,ye,ke,Ae,Ie){const ae=32*e,Ee=16*e;return this.int16[ae+0]=r,this.int16[ae+1]=s,this.int16[ae+2]=o,this.int16[ae+3]=c,this.int16[ae+4]=d,this.int16[ae+5]=f,this.int16[ae+6]=_,this.int16[ae+7]=x,this.uint16[ae+8]=b,this.uint16[ae+9]=w,this.uint16[ae+10]=I,this.uint16[ae+11]=C,this.uint16[ae+12]=k,this.uint16[ae+13]=D,this.uint16[ae+14]=F,this.uint16[ae+15]=$,this.uint16[ae+16]=J,this.uint16[ae+17]=Z,this.uint16[ae+18]=K,this.uint16[ae+19]=ie,this.uint16[ae+20]=ce,this.uint16[ae+21]=xe,this.uint16[ae+22]=Le,this.uint32[Ee+12]=be,this.float32[Ee+13]=ye,this.float32[Ee+14]=ke,this.uint16[ae+30]=Ae,this.uint16[ae+31]=Ie,e}}ue.prototype.bytesPerElement=64,Pe("StructArrayLayout8i15ui1ul2f2ui64",ue);class de extends y{_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}}de.prototype.bytesPerElement=4,Pe("StructArrayLayout1f4",de);class Ce extends y{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,r,s)}emplace(e,r,s,o){const c=3*e;return this.uint16[6*e+0]=r,this.float32[c+1]=s,this.float32[c+2]=o,e}}Ce.prototype.bytesPerElement=12,Pe("StructArrayLayout1ui2f12",Ce);class Ne extends y{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,r,s)}emplace(e,r,s,o){const c=4*e;return this.uint32[2*e+0]=r,this.uint16[c+2]=s,this.uint16[c+3]=o,e}}Ne.prototype.bytesPerElement=8,Pe("StructArrayLayout1ul2ui8",Ne);class _e extends y{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r){const s=this.length;return this.resize(s+1),this.emplace(s,e,r)}emplace(e,r,s){const o=2*e;return this.uint16[o+0]=r,this.uint16[o+1]=s,e}}_e.prototype.bytesPerElement=4,Pe("StructArrayLayout2ui4",_e);class ve extends y{_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}}ve.prototype.bytesPerElement=2,Pe("StructArrayLayout1ui2",ve);class Oe extends y{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,s,o){const c=this.length;return this.resize(c+1),this.emplace(c,e,r,s,o)}emplace(e,r,s,o,c){const d=4*e;return this.float32[d+0]=r,this.float32[d+1]=s,this.float32[d+2]=o,this.float32[d+3]=c,e}}Oe.prototype.bytesPerElement=16,Pe("StructArrayLayout4f16",Oe);class pt extends g{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new me(this.anchorPointX,this.anchorPointY)}}pt.prototype.size=20;class qe extends Q{get(e){return new pt(this,e)}}Pe("CollisionBoxArray",qe);class We extends g{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]}}We.prototype.size=48;class ft extends Se{get(e){return new We(this,e)}}Pe("PlacedSymbolArray",ft);class Ut extends g{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Ut.prototype.size=64;class Ri extends ue{get(e){return new Ut(this,e)}}Pe("SymbolInstanceArray",Ri);class mt extends de{getoffsetX(e){return this.float32[1*e+0]}}Pe("GlyphOffsetArray",mt);class oi extends M{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}Pe("SymbolLineVertexArray",oi);class ti extends g{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}ti.prototype.size=12;class $t extends Ce{get(e){return new ti(this,e)}}Pe("TextAnchorOffsetArray",$t);class qt extends g{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]}}qt.prototype.size=8;class Bi extends Ne{get(e){return new qt(this,e)}}Pe("FeatureIndexArray",Bi);class tn extends T{}class Js extends T{}class Sn extends T{}class rn extends R{}class Ys extends N{}class co extends B{}class Bt extends U{}class Fi extends G{}class Dr extends O{}class In extends H{}class Zt extends ee{}class Gt extends he{}class Dt extends Te{}class xt extends _e{}const Pn=v([{name:"a_pos",components:2,type:"Int16"}],4),{members:ho}=Pn;class zt{constructor(e=[]){this.segments=e}prepareSegment(e,r,s,o){let c=this.segments[this.segments.length-1];return e>zt.MAX_VERTEX_ARRAY_LENGTH&&Ot(`Max vertices per segment is ${zt.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!c||c.vertexLength+e>zt.MAX_VERTEX_ARRAY_LENGTH||c.sortKey!==o)&&(c={vertexOffset:r.length,primitiveOffset:s.length,vertexLength:0,primitiveLength:0},o!==void 0&&(c.sortKey=o),this.segments.push(c)),c}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,s,o){return new zt([{vertexOffset:e,primitiveOffset:r,vertexLength:s,primitiveLength:o,vaos:{},sortKey:0}])}}function ml(i,e){return 256*(i=Mi(Math.floor(i),0,255))+Mi(Math.floor(e),0,255)}zt.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Pe("SegmentVector",zt);const Qs=v([{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 ea={exports:{}},Lr={exports:{}};Lr.exports=function(i,e){var r,s,o,c,d,f,_,x;for(s=i.length-(r=3&i.length),o=e,d=3432918353,f=461845907,x=0;x<s;)_=255&i.charCodeAt(x)|(255&i.charCodeAt(++x))<<8|(255&i.charCodeAt(++x))<<16|(255&i.charCodeAt(++x))<<24,++x,o=27492+(65535&(c=5*(65535&(o=(o^=_=(65535&(_=(_=(65535&_)*d+(((_>>>16)*d&65535)<<16)&4294967295)<<15|_>>>17))*f+(((_>>>16)*f&65535)<<16)&4294967295)<<13|o>>>19))+((5*(o>>>16)&65535)<<16)&4294967295))+((58964+(c>>>16)&65535)<<16);switch(_=0,r){case 3:_^=(255&i.charCodeAt(x+2))<<16;case 2:_^=(255&i.charCodeAt(x+1))<<8;case 1:o^=_=(65535&(_=(_=(65535&(_^=255&i.charCodeAt(x)))*d+(((_>>>16)*d&65535)<<16)&4294967295)<<15|_>>>17))*f+(((_>>>16)*f&65535)<<16)&4294967295}return o^=i.length,o=2246822507*(65535&(o^=o>>>16))+((2246822507*(o>>>16)&65535)<<16)&4294967295,o=3266489909*(65535&(o^=o>>>13))+((3266489909*(o>>>16)&65535)<<16)&4294967295,(o^=o>>>16)>>>0};var _l=Lr.exports,uo={exports:{}};uo.exports=function(i,e){for(var r,s=i.length,o=e^s,c=0;s>=4;)r=1540483477*(65535&(r=255&i.charCodeAt(c)|(255&i.charCodeAt(++c))<<8|(255&i.charCodeAt(++c))<<16|(255&i.charCodeAt(++c))<<24))+((1540483477*(r>>>16)&65535)<<16),o=1540483477*(65535&o)+((1540483477*(o>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),s-=4,++c;switch(s){case 3:o^=(255&i.charCodeAt(c+2))<<16;case 2:o^=(255&i.charCodeAt(c+1))<<8;case 1:o=1540483477*(65535&(o^=255&i.charCodeAt(c)))+((1540483477*(o>>>16)&65535)<<16)}return o=1540483477*(65535&(o^=o>>>13))+((1540483477*(o>>>16)&65535)<<16),(o^=o>>>15)>>>0};var po=_l,fo=uo.exports;ea.exports=po,ea.exports.murmur3=po,ea.exports.murmur2=fo;var ta=Ti(ea.exports);class An{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,r,s,o){this.ids.push(Yc(e)),this.positions.push(r,s,o)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const r=Yc(e);let s=0,o=this.ids.length-1;for(;s<o;){const d=s+o>>1;this.ids[d]>=r?o=d:s=d+1}const c=[];for(;this.ids[s]===r;)c.push({index:this.positions[3*s],start:this.positions[3*s+1],end:this.positions[3*s+2]}),s++;return c}static serialize(e,r){const s=new Float64Array(e.ids),o=new Uint32Array(e.positions);return ac(s,o,0,s.length-1),r&&r.push(s.buffer,o.buffer),{ids:s,positions:o}}static deserialize(e){const r=new An;return r.ids=e.ids,r.positions=e.positions,r.indexed=!0,r}}function Yc(i){const e=+i;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:ta(String(i))}function ac(i,e,r,s){for(;r<s;){const o=i[r+s>>1];let c=r-1,d=s+1;for(;;){do c++;while(i[c]<o);do d--;while(i[d]>o);if(c>=d)break;gl(i,c,d),gl(e,3*c,3*d),gl(e,3*c+1,3*d+1),gl(e,3*c+2,3*d+2)}d-r<s-d?(ac(i,e,r,d),r=d+1):(ac(i,e,d+1,s),s=d)}}function gl(i,e,r){const s=i[e];i[e]=i[r],i[r]=s}Pe("FeaturePositionMap",An);class us{constructor(e,r){this.gl=e.gl,this.location=r}}class yl extends us{constructor(e,r){super(e,r),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class Qc extends us{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 eh extends us{constructor(e,r){super(e,r),this.current=it.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 Ou=new Float32Array(16);function oc(i){return[ml(255*i.r,255*i.g),ml(255*i.b,255*i.a)]}class mo{constructor(e,r,s){this.value=e,this.uniformNames=r.map(o=>`u_${o}`),this.type=s}setUniform(e,r,s){e.set(s.constantOr(this.value))}getBinding(e,r,s){return this.type==="color"?new eh(e,r):new yl(e,r)}}class ia{constructor(e,r){this.uniformNames=r.map(s=>`u_${s}`),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,s,o){const c=o==="u_pattern_to"?this.patternTo:o==="u_pattern_from"?this.patternFrom:o==="u_pixel_ratio_to"?this.pixelRatioTo:o==="u_pixel_ratio_from"?this.pixelRatioFrom:null;c&&e.set(c)}getBinding(e,r,s){return s.substr(0,9)==="u_pattern"?new Qc(e,r):new yl(e,r)}}class nn{constructor(e,r,s,o){this.expression=e,this.type=s,this.maxValue=0,this.paintVertexAttributes=r.map(c=>({name:`a_${c}`,type:"Float32",components:s==="color"?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(e,r,s,o,c){const d=this.paintVertexArray.length,f=this.expression.evaluate(new ct(0),r,{},o,[],c);this.paintVertexArray.resize(e),this._setPaintValue(d,e,f)}updatePaintArray(e,r,s,o){const c=this.expression.evaluate({zoom:0},s,o);this._setPaintValue(e,r,c)}_setPaintValue(e,r,s){if(this.type==="color"){const o=oc(s);for(let c=e;c<r;c++)this.paintVertexArray.emplace(c,o[0],o[1])}else{for(let o=e;o<r;o++)this.paintVertexArray.emplace(o,s);this.maxValue=Math.max(this.maxValue,Math.abs(s))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class mr{constructor(e,r,s,o,c,d){this.expression=e,this.uniformNames=r.map(f=>`u_${f}_t`),this.type=s,this.useIntegerZoom=o,this.zoom=c,this.maxValue=0,this.paintVertexAttributes=r.map(f=>({name:`a_${f}`,type:"Float32",components:s==="color"?4:2,offset:0})),this.paintVertexArray=new d}populatePaintArray(e,r,s,o,c){const d=this.expression.evaluate(new ct(this.zoom),r,{},o,[],c),f=this.expression.evaluate(new ct(this.zoom+1),r,{},o,[],c),_=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(_,e,d,f)}updatePaintArray(e,r,s,o){const c=this.expression.evaluate({zoom:this.zoom},s,o),d=this.expression.evaluate({zoom:this.zoom+1},s,o);this._setPaintValue(e,r,c,d)}_setPaintValue(e,r,s,o){if(this.type==="color"){const c=oc(s),d=oc(o);for(let f=e;f<r;f++)this.paintVertexArray.emplace(f,c[0],c[1],d[0],d[1])}else{for(let c=e;c<r;c++)this.paintVertexArray.emplace(c,s,o);this.maxValue=Math.max(this.maxValue,Math.abs(s),Math.abs(o))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,r){const s=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,o=Mi(this.expression.interpolationFactor(s,this.zoom,this.zoom+1),0,1);e.set(o)}getBinding(e,r,s){return new yl(e,r)}}class Cn{constructor(e,r,s,o,c,d){this.expression=e,this.type=r,this.useIntegerZoom=s,this.zoom=o,this.layerId=d,this.zoomInPaintVertexArray=new c,this.zoomOutPaintVertexArray=new c}populatePaintArray(e,r,s){const o=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(o,e,r.patterns&&r.patterns[this.layerId],s)}updatePaintArray(e,r,s,o,c){this._setPaintValues(e,r,s.patterns&&s.patterns[this.layerId],c)}_setPaintValues(e,r,s,o){if(!o||!s)return;const{min:c,mid:d,max:f}=s,_=o[c],x=o[d],b=o[f];if(_&&x&&b)for(let w=e;w<r;w++)this.zoomInPaintVertexArray.emplace(w,x.tl[0],x.tl[1],x.br[0],x.br[1],_.tl[0],_.tl[1],_.br[0],_.br[1],x.pixelRatio,_.pixelRatio),this.zoomOutPaintVertexArray.emplace(w,x.tl[0],x.tl[1],x.br[0],x.br[1],b.tl[0],b.tl[1],b.br[0],b.br[1],x.pixelRatio,b.pixelRatio)}upload(e){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,Qs.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,Qs.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class th{constructor(e,r,s){this.binders={},this._buffers=[];const o=[];for(const c in e.paint._values){if(!s(c))continue;const d=e.paint.get(c);if(!(d instanceof ir&&Kr(d.property.specification)))continue;const f=Vu(c,e.type),_=d.value,x=d.property.specification.type,b=d.property.useIntegerZoom,w=d.property.specification["property-type"],I=w==="cross-faded"||w==="cross-faded-data-driven";if(_.kind==="constant")this.binders[c]=I?new ia(_.value,f):new mo(_.value,f,x),o.push(`/u_${c}`);else if(_.kind==="source"||I){const C=ih(c,x,"source");this.binders[c]=I?new Cn(_,x,b,r,C,e.id):new nn(_,f,x,C),o.push(`/a_${c}`)}else{const C=ih(c,x,"composite");this.binders[c]=new mr(_,f,x,b,r,C),o.push(`/z_${c}`)}}this.cacheKey=o.sort().join("")}getMaxValue(e){const r=this.binders[e];return r instanceof nn||r instanceof mr?r.maxValue:0}populatePaintArrays(e,r,s,o,c){for(const d in this.binders){const f=this.binders[d];(f instanceof nn||f instanceof mr||f instanceof Cn)&&f.populatePaintArray(e,r,s,o,c)}}setConstantPatternPositions(e,r){for(const s in this.binders){const o=this.binders[s];o instanceof ia&&o.setConstantPatternPositions(e,r)}}updatePaintArrays(e,r,s,o,c){let d=!1;for(const f in e){const _=r.getPositions(f);for(const x of _){const b=s.feature(x.index);for(const w in this.binders){const I=this.binders[w];if((I instanceof nn||I instanceof mr||I instanceof Cn)&&I.expression.isStateDependent===!0){const C=o.paint.get(w);I.expression=C.value,I.updatePaintArray(x.start,x.end,b,e[f],c),d=!0}}}}return d}defines(){const e=[];for(const r in this.binders){const s=this.binders[r];(s instanceof mo||s instanceof ia)&&e.push(...s.uniformNames.map(o=>`#define HAS_UNIFORM_${o}`))}return e}getBinderAttributes(){const e=[];for(const r in this.binders){const s=this.binders[r];if(s instanceof nn||s instanceof mr)for(let o=0;o<s.paintVertexAttributes.length;o++)e.push(s.paintVertexAttributes[o].name);else if(s instanceof Cn)for(let o=0;o<Qs.members.length;o++)e.push(Qs.members[o].name)}return e}getBinderUniforms(){const e=[];for(const r in this.binders){const s=this.binders[r];if(s instanceof mo||s instanceof ia||s instanceof mr)for(const o of s.uniformNames)e.push(o)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,r){const s=[];for(const o in this.binders){const c=this.binders[o];if(c instanceof mo||c instanceof ia||c instanceof mr){for(const d of c.uniformNames)if(r[d]){const f=c.getBinding(e,r[d],d);s.push({name:d,property:o,binding:f})}}}return s}setUniforms(e,r,s,o){for(const{name:c,property:d,binding:f}of r)this.binders[d].setUniform(f,o,s.get(d),c)}updatePaintBuffers(e){this._buffers=[];for(const r in this.binders){const s=this.binders[r];if(e&&s instanceof Cn){const o=e.fromScale===2?s.zoomInPaintVertexBuffer:s.zoomOutPaintVertexBuffer;o&&this._buffers.push(o)}else(s instanceof nn||s instanceof mr)&&s.paintVertexBuffer&&this._buffers.push(s.paintVertexBuffer)}}upload(e){for(const r in this.binders){const s=this.binders[r];(s instanceof nn||s instanceof mr||s instanceof Cn)&&s.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const r=this.binders[e];(r instanceof nn||r instanceof mr||r instanceof Cn)&&r.destroy()}}}class ds{constructor(e,r,s=()=>!0){this.programConfigurations={};for(const o of e)this.programConfigurations[o.id]=new th(o,r,s);this.needsUpload=!1,this._featureMap=new An,this._bufferOffset=0}populatePaintArrays(e,r,s,o,c,d){for(const f in this.programConfigurations)this.programConfigurations[f].populatePaintArrays(e,r,o,c,d);r.id!==void 0&&this._featureMap.add(r.id,s,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,r,s,o){for(const c of s)this.needsUpload=this.programConfigurations[c.id].updatePaintArrays(e,this._featureMap,r,c,o)||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 Vu(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 ih(i,e,r){const s={color:{source:B,composite:Oe},number:{source:de,composite:B}},o=function(c){return{"line-pattern":{source:Bt,composite:Bt},"fill-pattern":{source:Bt,composite:Bt},"fill-extrusion-pattern":{source:Bt,composite:Bt}}[c]}(i);return o&&o[r]||s[e][r]}Pe("ConstantBinder",mo),Pe("CrossFadedConstantBinder",ia),Pe("SourceExpressionBinder",nn),Pe("CrossFadedCompositeBinder",Cn),Pe("CompositeExpressionBinder",mr),Pe("ProgramConfiguration",th,{omit:["_buffers"]}),Pe("ProgramConfigurationSet",ds);const Mt=8192,lc=Math.pow(2,14)-1,rh=-lc-1;function ps(i){const e=Mt/i.extent,r=i.loadGeometry();for(let s=0;s<r.length;s++){const o=r[s];for(let c=0;c<o.length;c++){const d=o[c],f=Math.round(d.x*e),_=Math.round(d.y*e);d.x=Mi(f,rh,lc),d.y=Mi(_,rh,lc),(f<d.x||f>d.x+1||_<d.y||_>d.y+1)&&Ot("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function fs(i,e){return{type:i.type,id:i.id,properties:i.properties,geometry:e?ps(i):[]}}function xl(i,e,r,s,o){i.emplaceBack(2*e+(s+1)/2,2*r+(o+1)/2)}class cc{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 Js,this.indexArray=new Dt,this.segments=new zt,this.programConfigurations=new ds(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,s){const o=this.layers[0],c=[];let d=null,f=!1;o.type==="circle"&&(d=o.layout.get("circle-sort-key"),f=!d.isConstant());for(const{feature:_,id:x,index:b,sourceLayerIndex:w}of e){const I=this.layers[0]._featureFilter.needGeometry,C=fs(_,I);if(!this.layers[0]._featureFilter.filter(new ct(this.zoom),C,s))continue;const k=f?d.evaluate(C,{},s):void 0,D={id:x,properties:_.properties,type:_.type,sourceLayerIndex:w,index:b,geometry:I?C.geometry:ps(_),patterns:{},sortKey:k};c.push(D)}f&&c.sort((_,x)=>_.sortKey-x.sortKey);for(const _ of c){const{geometry:x,index:b,sourceLayerIndex:w}=_,I=e[b].feature;this.addFeature(_,x,b,s),r.featureIndex.insert(I,x,b,w,this.index)}}update(e,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ho),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,s,o){for(const c of r)for(const d of c){const f=d.x,_=d.y;if(f<0||f>=Mt||_<0||_>=Mt)continue;const x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),b=x.vertexLength;xl(this.layoutVertexArray,f,_,-1,-1),xl(this.layoutVertexArray,f,_,1,-1),xl(this.layoutVertexArray,f,_,1,1),xl(this.layoutVertexArray,f,_,-1,1),this.indexArray.emplaceBack(b,b+1,b+2),this.indexArray.emplaceBack(b,b+3,b+2),x.vertexLength+=4,x.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{},o)}}function nh(i,e){for(let r=0;r<i.length;r++)if(ra(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(ra(i,e[r]))return!0;return!!hc(i,e)}function Nu(i,e,r){return!!ra(i,e)||!!uc(e,i,r)}function sh(i,e){if(i.length===1)return oh(e,i[0]);for(let r=0;r<e.length;r++){const s=e[r];for(let o=0;o<s.length;o++)if(ra(i,s[o]))return!0}for(let r=0;r<i.length;r++)if(oh(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(hc(i,e[r]))return!0;return!1}function ju(i,e,r){if(i.length>1){if(hc(i,e))return!0;for(let s=0;s<e.length;s++)if(uc(e[s],i,r))return!0}for(let s=0;s<i.length;s++)if(uc(i[s],e,r))return!0;return!1}function hc(i,e){if(i.length===0||e.length===0)return!1;for(let r=0;r<i.length-1;r++){const s=i[r],o=i[r+1];for(let c=0;c<e.length-1;c++)if(Uu(s,o,e[c],e[c+1]))return!0}return!1}function Uu(i,e,r,s){return Yt(i,r,s)!==Yt(e,r,s)&&Yt(i,e,r)!==Yt(i,e,s)}function uc(i,e,r){const s=r*r;if(e.length===1)return i.distSqr(e[0])<s;for(let o=1;o<e.length;o++)if(ah(i,e[o-1],e[o])<s)return!0;return!1}function ah(i,e,r){const s=e.distSqr(r);if(s===0)return i.distSqr(e);const o=((i.x-e.x)*(r.x-e.x)+(i.y-e.y)*(r.y-e.y))/s;return i.distSqr(o<0?e:o>1?r:r.sub(e)._mult(o)._add(e))}function oh(i,e){let r,s,o,c=!1;for(let d=0;d<i.length;d++){r=i[d];for(let f=0,_=r.length-1;f<r.length;_=f++)s=r[f],o=r[_],s.y>e.y!=o.y>e.y&&e.x<(o.x-s.x)*(e.y-s.y)/(o.y-s.y)+s.x&&(c=!c)}return c}function ra(i,e){let r=!1;for(let s=0,o=i.length-1;s<i.length;o=s++){const c=i[s],d=i[o];c.y>e.y!=d.y>e.y&&e.x<(d.x-c.x)*(e.y-c.y)/(d.y-c.y)+c.x&&(r=!r)}return r}function $u(i,e,r){const s=r[0],o=r[2];if(i.x<s.x&&e.x<s.x||i.x>o.x&&e.x>o.x||i.y<s.y&&e.y<s.y||i.y>o.y&&e.y>o.y)return!1;const c=Yt(i,e,r[0]);return c!==Yt(i,e,r[1])||c!==Yt(i,e,r[2])||c!==Yt(i,e,r[3])}function _o(i,e,r){const s=e.paint.get(i).value;return s.kind==="constant"?s.value:r.programConfigurations.get(e.id).getMaxValue(i)}function vl(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function bl(i,e,r,s,o){if(!e[0]&&!e[1])return i;const c=me.convert(e)._mult(o);r==="viewport"&&c._rotate(-s);const d=[];for(let f=0;f<i.length;f++)d.push(i[f].sub(c));return d}let lh,ch;Pe("CircleBucket",cc,{omit:["layers"]});var qu={get paint(){return ch=ch||new a({"circle-radius":new Be(re.paint_circle["circle-radius"]),"circle-color":new Be(re.paint_circle["circle-color"]),"circle-blur":new Be(re.paint_circle["circle-blur"]),"circle-opacity":new Be(re.paint_circle["circle-opacity"]),"circle-translate":new ze(re.paint_circle["circle-translate"]),"circle-translate-anchor":new ze(re.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new ze(re.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new ze(re.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Be(re.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Be(re.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Be(re.paint_circle["circle-stroke-opacity"])})},get layout(){return lh=lh||new a({"circle-sort-key":new Be(re.layout_circle["circle-sort-key"])})}},li=1e-6,na=typeof Float32Array<"u"?Float32Array:Array;function dc(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 hh(i,e,r){var s=e[0],o=e[1],c=e[2],d=e[3],f=e[4],_=e[5],x=e[6],b=e[7],w=e[8],I=e[9],C=e[10],k=e[11],D=e[12],F=e[13],$=e[14],J=e[15],Z=r[0],K=r[1],ie=r[2],ce=r[3];return i[0]=Z*s+K*f+ie*w+ce*D,i[1]=Z*o+K*_+ie*I+ce*F,i[2]=Z*c+K*x+ie*C+ce*$,i[3]=Z*d+K*b+ie*k+ce*J,i[4]=(Z=r[4])*s+(K=r[5])*f+(ie=r[6])*w+(ce=r[7])*D,i[5]=Z*o+K*_+ie*I+ce*F,i[6]=Z*c+K*x+ie*C+ce*$,i[7]=Z*d+K*b+ie*k+ce*J,i[8]=(Z=r[8])*s+(K=r[9])*f+(ie=r[10])*w+(ce=r[11])*D,i[9]=Z*o+K*_+ie*I+ce*F,i[10]=Z*c+K*x+ie*C+ce*$,i[11]=Z*d+K*b+ie*k+ce*J,i[12]=(Z=r[12])*s+(K=r[13])*f+(ie=r[14])*w+(ce=r[15])*D,i[13]=Z*o+K*_+ie*I+ce*F,i[14]=Z*c+K*x+ie*C+ce*$,i[15]=Z*d+K*b+ie*k+ce*J,i}Math.hypot||(Math.hypot=function(){for(var i=0,e=arguments.length;e--;)i+=arguments[e]*arguments[e];return Math.sqrt(i)});var go,Zu=hh;function wl(i,e,r){var s=e[0],o=e[1],c=e[2],d=e[3];return i[0]=r[0]*s+r[4]*o+r[8]*c+r[12]*d,i[1]=r[1]*s+r[5]*o+r[9]*c+r[13]*d,i[2]=r[2]*s+r[6]*o+r[10]*c+r[14]*d,i[3]=r[3]*s+r[7]*o+r[11]*c+r[15]*d,i}go=new na(4),na!=Float32Array&&(go[0]=0,go[1]=0,go[2]=0,go[3]=0);class Gu extends u{constructor(e){super(e,qu)}createBucket(e){return new cc(e)}queryRadius(e){const r=e;return _o("circle-radius",this,r)+_o("circle-stroke-width",this,r)+vl(this.paint.get("circle-translate"))}queryIntersectsFeature(e,r,s,o,c,d,f,_){const x=bl(e,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),d.angle,f),b=this.paint.get("circle-radius").evaluate(r,s)+this.paint.get("circle-stroke-width").evaluate(r,s),w=this.paint.get("circle-pitch-alignment")==="map",I=w?x:function(k,D){return k.map(F=>uh(F,D))}(x,_),C=w?b*f:b;for(const k of o)for(const D of k){const F=w?D:uh(D,_);let $=C;const J=wl([],[D.x,D.y,0,1],_);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?$*=J[3]/d.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&($*=d.cameraToCenterDistance/J[3]),Nu(I,F,$))return!0}return!1}}function uh(i,e){const r=wl([],[i.x,i.y,0,1],e);return new me(r[0]/r[3],r[1]/r[3])}class dh extends cc{}let ph;Pe("HeatmapBucket",dh,{omit:["layers"]});var Xu={get paint(){return ph=ph||new a({"heatmap-radius":new Be(re.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Be(re.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new ze(re.paint_heatmap["heatmap-intensity"]),"heatmap-color":new n(re.paint_heatmap["heatmap-color"]),"heatmap-opacity":new ze(re.paint_heatmap["heatmap-opacity"])})}};function pc(i,{width:e,height:r},s,o){if(o){if(o instanceof Uint8ClampedArray)o=new Uint8Array(o.buffer);else if(o.length!==e*r*s)throw new RangeError(`mismatched image size. expected: ${o.length} but got: ${e*r*s}`)}else o=new Uint8Array(e*r*s);return i.width=e,i.height=r,i.data=o,i}function fh(i,{width:e,height:r},s){if(e===i.width&&r===i.height)return;const o=pc({},{width:e,height:r},s);fc(i,o,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,e),height:Math.min(i.height,r)},s),i.width=e,i.height=r,i.data=o.data}function fc(i,e,r,s,o,c){if(o.width===0||o.height===0)return e;if(o.width>i.width||o.height>i.height||r.x>i.width-o.width||r.y>i.height-o.height)throw new RangeError("out of range source coordinates for image copy");if(o.width>e.width||o.height>e.height||s.x>e.width-o.width||s.y>e.height-o.height)throw new RangeError("out of range destination coordinates for image copy");const d=i.data,f=e.data;if(d===f)throw new Error("srcData equals dstData, so image is already copied");for(let _=0;_<o.height;_++){const x=((r.y+_)*i.width+r.x)*c,b=((s.y+_)*e.width+s.x)*c;for(let w=0;w<o.width*c;w++)f[b+w]=d[x+w]}return e}class yo{constructor(e,r){pc(this,e,1,r)}resize(e){fh(this,e,1)}clone(){return new yo({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,s,o,c){fc(e,r,s,o,c,1)}}class Oi{constructor(e,r){pc(this,e,4,r)}resize(e){fh(this,e,4)}replace(e,r){r?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new Oi({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,s,o,c){fc(e,r,s,o,c,4)}}function mh(i){const e={},r=i.resolution||256,s=i.clips?i.clips.length:1,o=i.image||new Oi({width:r,height:s});if(Math.log(r)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${r}`);const c=(d,f,_)=>{e[i.evaluationKey]=_;const x=i.expression.evaluate(e);o.data[d+f+0]=Math.floor(255*x.r/x.a),o.data[d+f+1]=Math.floor(255*x.g/x.a),o.data[d+f+2]=Math.floor(255*x.b/x.a),o.data[d+f+3]=Math.floor(255*x.a)};if(i.clips)for(let d=0,f=0;d<s;++d,f+=4*r)for(let _=0,x=0;_<r;_++,x+=4){const b=_/(r-1),{start:w,end:I}=i.clips[d];c(f,x,w*(1-b)+I*b)}else for(let d=0,f=0;d<r;d++,f+=4)c(0,f,d/(r-1));return o}Pe("AlphaImage",yo),Pe("RGBAImage",Oi);class Wu extends u{createBucket(e){return new dh(e)}constructor(e){super(e,Xu),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){e==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=mh({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"}}let _h;var Hu={get paint(){return _h=_h||new a({"hillshade-illumination-direction":new ze(re.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new ze(re.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new ze(re.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new ze(re.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new ze(re.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new ze(re.paint_hillshade["hillshade-accent-color"])})}};class Ku extends u{constructor(e){super(e,Hu)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}}const Ju=v([{name:"a_pos",components:2,type:"Int16"}],4),{members:Yu}=Ju;var mc={exports:{}};function Tl(i,e,r){r=r||2;var s,o,c,d,f,_,x,b=e&&e.length,w=b?e[0]*r:i.length,I=gh(i,0,w,r,!0),C=[];if(!I||I.next===I.prev)return C;if(b&&(I=function(D,F,$,J){var Z,K,ie,ce=[];for(Z=0,K=F.length;Z<K;Z++)(ie=gh(D,F[Z]*J,Z<K-1?F[Z+1]*J:D.length,J,!1))===ie.next&&(ie.steiner=!0),ce.push(ad(ie));for(ce.sort(rd),Z=0;Z<ce.length;Z++)$=nd(ce[Z],$);return $}(i,e,I,r)),i.length>80*r){s=c=i[0],o=d=i[1];for(var k=r;k<w;k+=r)(f=i[k])<s&&(s=f),(_=i[k+1])<o&&(o=_),f>c&&(c=f),_>d&&(d=_);x=(x=Math.max(c-s,d-o))!==0?32767/x:0}return xo(I,C,r,s,o,x,0),C}function gh(i,e,r,s,o){var c,d;if(o===yc(i,e,r,s)>0)for(c=e;c<r;c+=s)d=vh(c,i[c],i[c+1],d);else for(c=r-s;c>=e;c-=s)d=vh(c,i[c],i[c+1],d);return d&&Sl(d,d.next)&&(bo(d),d=d.next),d}function ms(i,e){if(!i)return i;e||(e=i);var r,s=i;do if(r=!1,s.steiner||!Sl(s,s.next)&&Pt(s.prev,s,s.next)!==0)s=s.next;else{if(bo(s),(s=e=s.prev)===s.next)break;r=!0}while(r||s!==e);return e}function xo(i,e,r,s,o,c,d){if(i){!d&&c&&function(b,w,I,C){var k=b;do k.z===0&&(k.z=_c(k.x,k.y,w,I,C)),k.prevZ=k.prev,k.nextZ=k.next,k=k.next;while(k!==b);k.prevZ.nextZ=null,k.prevZ=null,function(D){var F,$,J,Z,K,ie,ce,xe,Le=1;do{for($=D,D=null,K=null,ie=0;$;){for(ie++,J=$,ce=0,F=0;F<Le&&(ce++,J=J.nextZ);F++);for(xe=Le;ce>0||xe>0&&J;)ce!==0&&(xe===0||!J||$.z<=J.z)?(Z=$,$=$.nextZ,ce--):(Z=J,J=J.nextZ,xe--),K?K.nextZ=Z:D=Z,Z.prevZ=K,K=Z;$=J}K.nextZ=null,Le*=2}while(ie>1)}(k)}(i,s,o,c);for(var f,_,x=i;i.prev!==i.next;)if(f=i.prev,_=i.next,c?ed(i,s,o,c):Qu(i))e.push(f.i/r|0),e.push(i.i/r|0),e.push(_.i/r|0),bo(i),i=_.next,x=_.next;else if((i=_)===x){d?d===1?xo(i=td(ms(i),e,r),e,r,s,o,c,2):d===2&&id(i,e,r,s,o,c):xo(ms(i),e,r,s,o,c,1);break}}}function Qu(i){var e=i.prev,r=i,s=i.next;if(Pt(e,r,s)>=0)return!1;for(var o=e.x,c=r.x,d=s.x,f=e.y,_=r.y,x=s.y,b=o<c?o<d?o:d:c<d?c:d,w=f<_?f<x?f:x:_<x?_:x,I=o>c?o>d?o:d:c>d?c:d,C=f>_?f>x?f:x:_>x?_:x,k=s.next;k!==e;){if(k.x>=b&&k.x<=I&&k.y>=w&&k.y<=C&&sa(o,f,c,_,d,x,k.x,k.y)&&Pt(k.prev,k,k.next)>=0)return!1;k=k.next}return!0}function ed(i,e,r,s){var o=i.prev,c=i,d=i.next;if(Pt(o,c,d)>=0)return!1;for(var f=o.x,_=c.x,x=d.x,b=o.y,w=c.y,I=d.y,C=f<_?f<x?f:x:_<x?_:x,k=b<w?b<I?b:I:w<I?w:I,D=f>_?f>x?f:x:_>x?_:x,F=b>w?b>I?b:I:w>I?w:I,$=_c(C,k,e,r,s),J=_c(D,F,e,r,s),Z=i.prevZ,K=i.nextZ;Z&&Z.z>=$&&K&&K.z<=J;){if(Z.x>=C&&Z.x<=D&&Z.y>=k&&Z.y<=F&&Z!==o&&Z!==d&&sa(f,b,_,w,x,I,Z.x,Z.y)&&Pt(Z.prev,Z,Z.next)>=0||(Z=Z.prevZ,K.x>=C&&K.x<=D&&K.y>=k&&K.y<=F&&K!==o&&K!==d&&sa(f,b,_,w,x,I,K.x,K.y)&&Pt(K.prev,K,K.next)>=0))return!1;K=K.nextZ}for(;Z&&Z.z>=$;){if(Z.x>=C&&Z.x<=D&&Z.y>=k&&Z.y<=F&&Z!==o&&Z!==d&&sa(f,b,_,w,x,I,Z.x,Z.y)&&Pt(Z.prev,Z,Z.next)>=0)return!1;Z=Z.prevZ}for(;K&&K.z<=J;){if(K.x>=C&&K.x<=D&&K.y>=k&&K.y<=F&&K!==o&&K!==d&&sa(f,b,_,w,x,I,K.x,K.y)&&Pt(K.prev,K,K.next)>=0)return!1;K=K.nextZ}return!0}function td(i,e,r){var s=i;do{var o=s.prev,c=s.next.next;!Sl(o,c)&&yh(o,s,s.next,c)&&vo(o,c)&&vo(c,o)&&(e.push(o.i/r|0),e.push(s.i/r|0),e.push(c.i/r|0),bo(s),bo(s.next),s=i=c),s=s.next}while(s!==i);return ms(s)}function id(i,e,r,s,o,c){var d=i;do{for(var f=d.next.next;f!==d.prev;){if(d.i!==f.i&&od(d,f)){var _=xh(d,f);return d=ms(d,d.next),_=ms(_,_.next),xo(d,e,r,s,o,c,0),void xo(_,e,r,s,o,c,0)}f=f.next}d=d.next}while(d!==i)}function rd(i,e){return i.x-e.x}function nd(i,e){var r=function(o,c){var d,f=c,_=o.x,x=o.y,b=-1/0;do{if(x<=f.y&&x>=f.next.y&&f.next.y!==f.y){var w=f.x+(x-f.y)*(f.next.x-f.x)/(f.next.y-f.y);if(w<=_&&w>b&&(b=w,d=f.x<f.next.x?f:f.next,w===_))return d}f=f.next}while(f!==c);if(!d)return null;var I,C=d,k=d.x,D=d.y,F=1/0;f=d;do _>=f.x&&f.x>=k&&_!==f.x&&sa(x<D?_:b,x,k,D,x<D?b:_,x,f.x,f.y)&&(I=Math.abs(x-f.y)/(_-f.x),vo(f,o)&&(I<F||I===F&&(f.x>d.x||f.x===d.x&&sd(d,f)))&&(d=f,F=I)),f=f.next;while(f!==C);return d}(i,e);if(!r)return e;var s=xh(r,i);return ms(s,s.next),ms(r,r.next)}function sd(i,e){return Pt(i.prev,i,e.prev)<0&&Pt(e.next,i,i.next)<0}function _c(i,e,r,s,o){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-r)*o|0)|i<<8))|i<<4))|i<<2))|i<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-s)*o|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ad(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 sa(i,e,r,s,o,c,d,f){return(o-d)*(e-f)>=(i-d)*(c-f)&&(i-d)*(s-f)>=(r-d)*(e-f)&&(r-d)*(c-f)>=(o-d)*(s-f)}function od(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!function(r,s){var o=r;do{if(o.i!==r.i&&o.next.i!==r.i&&o.i!==s.i&&o.next.i!==s.i&&yh(o,o.next,r,s))return!0;o=o.next}while(o!==r);return!1}(i,e)&&(vo(i,e)&&vo(e,i)&&function(r,s){var o=r,c=!1,d=(r.x+s.x)/2,f=(r.y+s.y)/2;do o.y>f!=o.next.y>f&&o.next.y!==o.y&&d<(o.next.x-o.x)*(f-o.y)/(o.next.y-o.y)+o.x&&(c=!c),o=o.next;while(o!==r);return c}(i,e)&&(Pt(i.prev,i,e.prev)||Pt(i,e.prev,e))||Sl(i,e)&&Pt(i.prev,i,i.next)>0&&Pt(e.prev,e,e.next)>0)}function Pt(i,e,r){return(e.y-i.y)*(r.x-e.x)-(e.x-i.x)*(r.y-e.y)}function Sl(i,e){return i.x===e.x&&i.y===e.y}function yh(i,e,r,s){var o=Pl(Pt(i,e,r)),c=Pl(Pt(i,e,s)),d=Pl(Pt(r,s,i)),f=Pl(Pt(r,s,e));return o!==c&&d!==f||!(o!==0||!Il(i,r,e))||!(c!==0||!Il(i,s,e))||!(d!==0||!Il(r,i,s))||!(f!==0||!Il(r,e,s))}function Il(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 Pl(i){return i>0?1:i<0?-1:0}function vo(i,e){return Pt(i.prev,i,i.next)<0?Pt(i,e,i.next)>=0&&Pt(i,i.prev,e)>=0:Pt(i,e,i.prev)<0||Pt(i,i.next,e)<0}function xh(i,e){var r=new gc(i.i,i.x,i.y),s=new gc(e.i,e.x,e.y),o=i.next,c=e.prev;return i.next=e,e.prev=i,r.next=o,o.prev=r,s.next=r,r.prev=s,c.next=s,s.prev=c,s}function vh(i,e,r,s){var o=new gc(i,e,r);return s?(o.next=s.next,o.prev=s,s.next.prev=o,s.next=o):(o.prev=o,o.next=o),o}function bo(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 gc(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 yc(i,e,r,s){for(var o=0,c=e,d=r-s;c<r;c+=s)o+=(i[d]-i[c])*(i[c+1]+i[d+1]),d=c;return o}mc.exports=Tl,mc.exports.default=Tl,Tl.deviation=function(i,e,r,s){var o=e&&e.length,c=Math.abs(yc(i,0,o?e[0]*r:i.length,r));if(o)for(var d=0,f=e.length;d<f;d++)c-=Math.abs(yc(i,e[d]*r,d<f-1?e[d+1]*r:i.length,r));var _=0;for(d=0;d<s.length;d+=3){var x=s[d]*r,b=s[d+1]*r,w=s[d+2]*r;_+=Math.abs((i[x]-i[w])*(i[b+1]-i[x+1])-(i[x]-i[b])*(i[w+1]-i[x+1]))}return c===0&&_===0?0:Math.abs((_-c)/c)},Tl.flatten=function(i){for(var e=i[0][0].length,r={vertices:[],holes:[],dimensions:e},s=0,o=0;o<i.length;o++){for(var c=0;c<i[o].length;c++)for(var d=0;d<e;d++)r.vertices.push(i[o][c][d]);o>0&&r.holes.push(s+=i[o-1].length)}return r};var bh=Ti(mc.exports);function xc(i,e,r){const s=r.patternDependencies;let o=!1;for(const c of e){const d=c.paint.get(`${i}-pattern`);d.isConstant()||(o=!0);const f=d.constantOr(null);f&&(o=!0,s[f.to]=!0,s[f.from]=!0)}return o}function vc(i,e,r,s,o){const c=o.patternDependencies;for(const d of e){const f=d.paint.get(`${i}-pattern`).value;if(f.kind!=="constant"){let _=f.evaluate({zoom:s-1},r,{},o.availableImages),x=f.evaluate({zoom:s},r,{},o.availableImages),b=f.evaluate({zoom:s+1},r,{},o.availableImages);_=_&&_.name?_.name:_,x=x&&x.name?x.name:x,b=b&&b.name?b.name:b,c[_]=!0,c[x]=!0,c[b]=!0,r.patterns[d.id]={min:_,mid:x,max:b}}}return r}class bc{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 Sn,this.indexArray=new Dt,this.indexArray2=new xt,this.programConfigurations=new ds(e.layers,e.zoom),this.segments=new zt,this.segments2=new zt,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,s){this.hasPattern=xc("fill",this.layers,r);const o=this.layers[0].layout.get("fill-sort-key"),c=!o.isConstant(),d=[];for(const{feature:f,id:_,index:x,sourceLayerIndex:b}of e){const w=this.layers[0]._featureFilter.needGeometry,I=fs(f,w);if(!this.layers[0]._featureFilter.filter(new ct(this.zoom),I,s))continue;const C=c?o.evaluate(I,{},s,r.availableImages):void 0,k={id:_,properties:f.properties,type:f.type,sourceLayerIndex:b,index:x,geometry:w?I.geometry:ps(f),patterns:{},sortKey:C};d.push(k)}c&&d.sort((f,_)=>f.sortKey-_.sortKey);for(const f of d){const{geometry:_,index:x,sourceLayerIndex:b}=f;if(this.hasPattern){const w=vc("fill",this.layers,f,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature(f,_,x,s,{});r.featureIndex.insert(e[x].feature,_,x,b,this.index)}}update(e,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,s)}addFeatures(e,r,s){for(const o of this.patternFeatures)this.addFeature(o,o.geometry,o.index,r,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Yu),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,s,o,c){for(const d of Es(r,500)){let f=0;for(const C of d)f+=C.length;const _=this.segments.prepareSegment(f,this.layoutVertexArray,this.indexArray),x=_.vertexLength,b=[],w=[];for(const C of d){if(C.length===0)continue;C!==d[0]&&w.push(b.length/2);const k=this.segments2.prepareSegment(C.length,this.layoutVertexArray,this.indexArray2),D=k.vertexLength;this.layoutVertexArray.emplaceBack(C[0].x,C[0].y),this.indexArray2.emplaceBack(D+C.length-1,D),b.push(C[0].x),b.push(C[0].y);for(let F=1;F<C.length;F++)this.layoutVertexArray.emplaceBack(C[F].x,C[F].y),this.indexArray2.emplaceBack(D+F-1,D+F),b.push(C[F].x),b.push(C[F].y);k.vertexLength+=C.length,k.primitiveLength+=C.length}const I=bh(b,w);for(let C=0;C<I.length;C+=3)this.indexArray.emplaceBack(x+I[C],x+I[C+1],x+I[C+2]);_.vertexLength+=f,_.primitiveLength+=I.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,c,o)}}let wh,Th;Pe("FillBucket",bc,{omit:["layers","patternFeatures"]});var ld={get paint(){return Th=Th||new a({"fill-antialias":new ze(re.paint_fill["fill-antialias"]),"fill-opacity":new Be(re.paint_fill["fill-opacity"]),"fill-color":new Be(re.paint_fill["fill-color"]),"fill-outline-color":new Be(re.paint_fill["fill-outline-color"]),"fill-translate":new ze(re.paint_fill["fill-translate"]),"fill-translate-anchor":new ze(re.paint_fill["fill-translate-anchor"]),"fill-pattern":new h(re.paint_fill["fill-pattern"])})},get layout(){return wh=wh||new a({"fill-sort-key":new Be(re.layout_fill["fill-sort-key"])})}};class cd extends u{constructor(e){super(e,ld)}recalculate(e,r){super.recalculate(e,r);const s=this.paint._values["fill-outline-color"];s.value.kind==="constant"&&s.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new bc(e)}queryRadius(){return vl(this.paint.get("fill-translate"))}queryIntersectsFeature(e,r,s,o,c,d,f){return sh(bl(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),d.angle,f),o)}isTileClipped(){return!0}}const hd=v([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),ud=v([{name:"a_centroid",components:2,type:"Int16"}],4),{members:dd}=hd;var Mn={},pd=$i,Sh=aa;function aa(i,e,r,s,o){this.properties={},this.extent=r,this.type=0,this._pbf=i,this._geometry=-1,this._keys=s,this._values=o,i.readFields(fd,this,e)}function fd(i,e,r){i==1?e.id=r.readVarint():i==2?function(s,o){for(var c=s.readVarint()+s.pos;s.pos<c;){var d=o._keys[s.readVarint()],f=o._values[s.readVarint()];o.properties[d]=f}}(r,e):i==3?e.type=r.readVarint():i==4&&(e._geometry=r.pos)}function md(i){for(var e,r,s=0,o=0,c=i.length,d=c-1;o<c;d=o++)s+=((r=i[d]).x-(e=i[o]).x)*(e.y+r.y);return s}aa.types=["Unknown","Point","LineString","Polygon"],aa.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var e,r=i.readVarint()+i.pos,s=1,o=0,c=0,d=0,f=[];i.pos<r;){if(o<=0){var _=i.readVarint();s=7&_,o=_>>3}if(o--,s===1||s===2)c+=i.readSVarint(),d+=i.readSVarint(),s===1&&(e&&f.push(e),e=[]),e.push(new pd(c,d));else{if(s!==7)throw new Error("unknown command "+s);e&&e.push(e[0].clone())}}return e&&f.push(e),f},aa.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var e=i.readVarint()+i.pos,r=1,s=0,o=0,c=0,d=1/0,f=-1/0,_=1/0,x=-1/0;i.pos<e;){if(s<=0){var b=i.readVarint();r=7&b,s=b>>3}if(s--,r===1||r===2)(o+=i.readSVarint())<d&&(d=o),o>f&&(f=o),(c+=i.readSVarint())<_&&(_=c),c>x&&(x=c);else if(r!==7)throw new Error("unknown command "+r)}return[d,_,f,x]},aa.prototype.toGeoJSON=function(i,e,r){var s,o,c=this.extent*Math.pow(2,r),d=this.extent*i,f=this.extent*e,_=this.loadGeometry(),x=aa.types[this.type];function b(C){for(var k=0;k<C.length;k++){var D=C[k];C[k]=[360*(D.x+d)/c-180,360/Math.PI*Math.atan(Math.exp((180-360*(D.y+f)/c)*Math.PI/180))-90]}}switch(this.type){case 1:var w=[];for(s=0;s<_.length;s++)w[s]=_[s][0];b(_=w);break;case 2:for(s=0;s<_.length;s++)b(_[s]);break;case 3:for(_=function(C){var k=C.length;if(k<=1)return[C];for(var D,F,$=[],J=0;J<k;J++){var Z=md(C[J]);Z!==0&&(F===void 0&&(F=Z<0),F===Z<0?(D&&$.push(D),D=[C[J]]):D.push(C[J]))}return D&&$.push(D),$}(_),s=0;s<_.length;s++)for(o=0;o<_[s].length;o++)b(_[s][o])}_.length===1?_=_[0]:x="Multi"+x;var I={type:"Feature",geometry:{type:x,coordinates:_},properties:this.properties};return"id"in this&&(I.id=this.id),I};var _d=Sh,Ih=Ph;function Ph(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(gd,this,e),this.length=this._features.length}function gd(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(s){for(var o=null,c=s.readVarint()+s.pos;s.pos<c;){var d=s.readVarint()>>3;o=d===1?s.readString():d===2?s.readFloat():d===3?s.readDouble():d===4?s.readVarint64():d===5?s.readVarint():d===6?s.readSVarint():d===7?s.readBoolean():null}return o}(r))}Ph.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 _d(this._pbf,e,this.extent,this._keys,this._values)};var yd=Ih;function xd(i,e,r){if(i===3){var s=new yd(r,r.readVarint()+r.pos);s.length&&(e[s.name]=s)}}Mn.VectorTile=function(i,e){this.layers=i.readFields(xd,{},e)},Mn.VectorTileFeature=Sh,Mn.VectorTileLayer=Ih;const vd=Mn.VectorTileFeature.types,wc=Math.pow(2,13);function wo(i,e,r,s,o,c,d,f){i.emplaceBack(e,r,2*Math.floor(s*wc)+d,o*wc*2,c*wc*2,Math.round(f))}class Tc{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 rn,this.centroidVertexArray=new tn,this.indexArray=new Dt,this.programConfigurations=new ds(e.layers,e.zoom),this.segments=new zt,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,s){this.features=[],this.hasPattern=xc("fill-extrusion",this.layers,r);for(const{feature:o,id:c,index:d,sourceLayerIndex:f}of e){const _=this.layers[0]._featureFilter.needGeometry,x=fs(o,_);if(!this.layers[0]._featureFilter.filter(new ct(this.zoom),x,s))continue;const b={id:c,sourceLayerIndex:f,index:d,geometry:_?x.geometry:ps(o),properties:o.properties,type:o.type,patterns:{}};this.hasPattern?this.features.push(vc("fill-extrusion",this.layers,b,this.zoom,r)):this.addFeature(b,b.geometry,d,s,{}),r.featureIndex.insert(o,b.geometry,d,f,this.index,!0)}}addFeatures(e,r,s){for(const o of this.features){const{geometry:c}=o;this.addFeature(o,c,o.index,r,s)}}update(e,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,s)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,dd),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,ud.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,s,o,c){for(const d of Es(r,500)){const f={x:0,y:0,vertexCount:0};let _=0;for(const k of d)_+=k.length;let x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const k of d){if(k.length===0||wd(k))continue;let D=0;for(let F=0;F<k.length;F++){const $=k[F];if(F>=1){const J=k[F-1];if(!bd($,J)){x.vertexLength+4>zt.MAX_VERTEX_ARRAY_LENGTH&&(x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const Z=$.sub(J)._perp()._unit(),K=J.dist($);D+K>32768&&(D=0),wo(this.layoutVertexArray,$.x,$.y,Z.x,Z.y,0,0,D),wo(this.layoutVertexArray,$.x,$.y,Z.x,Z.y,0,1,D),f.x+=2*$.x,f.y+=2*$.y,f.vertexCount+=2,D+=K,wo(this.layoutVertexArray,J.x,J.y,Z.x,Z.y,0,0,D),wo(this.layoutVertexArray,J.x,J.y,Z.x,Z.y,0,1,D),f.x+=2*J.x,f.y+=2*J.y,f.vertexCount+=2;const ie=x.vertexLength;this.indexArray.emplaceBack(ie,ie+2,ie+1),this.indexArray.emplaceBack(ie+1,ie+2,ie+3),x.vertexLength+=4,x.primitiveLength+=2}}}}if(x.vertexLength+_>zt.MAX_VERTEX_ARRAY_LENGTH&&(x=this.segments.prepareSegment(_,this.layoutVertexArray,this.indexArray)),vd[e.type]!=="Polygon")continue;const b=[],w=[],I=x.vertexLength;for(const k of d)if(k.length!==0){k!==d[0]&&w.push(b.length/2);for(let D=0;D<k.length;D++){const F=k[D];wo(this.layoutVertexArray,F.x,F.y,0,0,1,1,0),f.x+=F.x,f.y+=F.y,f.vertexCount+=1,b.push(F.x),b.push(F.y)}}const C=bh(b,w);for(let k=0;k<C.length;k+=3)this.indexArray.emplaceBack(I+C[k],I+C[k+2],I+C[k+1]);x.primitiveLength+=C.length/3,x.vertexLength+=_;for(let k=0;k<f.vertexCount;k++){const D=Math.floor(f.x/f.vertexCount),F=Math.floor(f.y/f.vertexCount);this.centroidVertexArray.emplaceBack(D,F)}}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,c,o)}}function bd(i,e){return i.x===e.x&&(i.x<0||i.x>Mt)||i.y===e.y&&(i.y<0||i.y>Mt)}function wd(i){return i.every(e=>e.x<0)||i.every(e=>e.x>Mt)||i.every(e=>e.y<0)||i.every(e=>e.y>Mt)}let Ah;Pe("FillExtrusionBucket",Tc,{omit:["layers","features"]});var Td={get paint(){return Ah=Ah||new a({"fill-extrusion-opacity":new ze(re["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Be(re["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new ze(re["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new ze(re["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new h(re["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Be(re["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Be(re["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new ze(re["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Sd extends u{constructor(e){super(e,Td)}createBucket(e){return new Tc(e)}queryRadius(){return vl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(e,r,s,o,c,d,f,_){const x=bl(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),d.angle,f),b=this.paint.get("fill-extrusion-height").evaluate(r,s),w=this.paint.get("fill-extrusion-base").evaluate(r,s),I=function(k,D,F,$){const J=[];for(const Z of k){const K=[Z.x,Z.y,0,1];wl(K,K,D),J.push(new me(K[0]/K[3],K[1]/K[3]))}return J}(x,_),C=function(k,D,F,$){const J=[],Z=[],K=$[8]*D,ie=$[9]*D,ce=$[10]*D,xe=$[11]*D,Le=$[8]*F,be=$[9]*F,ye=$[10]*F,ke=$[11]*F;for(const Ae of k){const Ie=[],ae=[];for(const Ee of Ae){const Me=Ee.x,Ve=Ee.y,at=$[0]*Me+$[4]*Ve+$[12],st=$[1]*Me+$[5]*Ve+$[13],Lt=$[2]*Me+$[6]*Ve+$[14],rr=$[3]*Me+$[7]*Ve+$[15],Wt=Lt+ce,Tt=rr+xe,ci=at+Le,hi=st+be,ui=Lt+ye,St=rr+ke,Rt=new me((at+K)/Tt,(st+ie)/Tt);Rt.z=Wt/Tt,Ie.push(Rt);const ii=new me(ci/St,hi/St);ii.z=ui/St,ae.push(ii)}J.push(Ie),Z.push(ae)}return[J,Z]}(o,w,b,_);return function(k,D,F){let $=1/0;sh(F,D)&&($=Ch(F,D[0]));for(let J=0;J<D.length;J++){const Z=D[J],K=k[J];for(let ie=0;ie<Z.length-1;ie++){const ce=Z[ie],xe=[ce,Z[ie+1],K[ie+1],K[ie],ce];nh(F,xe)&&($=Math.min($,Ch(F,xe)))}}return $!==1/0&&$}(C[0],C[1],I)}}function To(i,e){return i.x*e.x+i.y*e.y}function Ch(i,e){if(i.length===1){let r=0;const s=e[r++];let o;for(;!o||s.equals(o);)if(o=e[r++],!o)return 1/0;for(;r<e.length;r++){const c=e[r],d=i[0],f=o.sub(s),_=c.sub(s),x=d.sub(s),b=To(f,f),w=To(f,_),I=To(_,_),C=To(x,f),k=To(x,_),D=b*I-w*w,F=(I*C-w*k)/D,$=(b*k-w*C)/D,J=s.z*(1-F-$)+o.z*F+c.z*$;if(isFinite(J))return J}return 1/0}{let r=1/0;for(const s of e)r=Math.min(r,s.z);return r}}const Id=v([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:Pd}=Id,Ad=v([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:Cd}=Ad,Md=Mn.VectorTileFeature.types,kd=Math.cos(Math.PI/180*37.5),Mh=Math.pow(2,14)/.5;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.lineClipsArray=[],this.gradients={},this.layers.forEach(r=>{this.gradients[r.id]={}}),this.layoutVertexArray=new Ys,this.layoutVertexArray2=new co,this.indexArray=new Dt,this.programConfigurations=new ds(e.layers,e.zoom),this.segments=new zt,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,s){this.hasPattern=xc("line",this.layers,r);const o=this.layers[0].layout.get("line-sort-key"),c=!o.isConstant(),d=[];for(const{feature:f,id:_,index:x,sourceLayerIndex:b}of e){const w=this.layers[0]._featureFilter.needGeometry,I=fs(f,w);if(!this.layers[0]._featureFilter.filter(new ct(this.zoom),I,s))continue;const C=c?o.evaluate(I,{},s):void 0,k={id:_,properties:f.properties,type:f.type,sourceLayerIndex:b,index:x,geometry:w?I.geometry:ps(f),patterns:{},sortKey:C};d.push(k)}c&&d.sort((f,_)=>f.sortKey-_.sortKey);for(const f of d){const{geometry:_,index:x,sourceLayerIndex:b}=f;if(this.hasPattern){const w=vc("line",this.layers,f,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature(f,_,x,s,{});r.featureIndex.insert(e[x].feature,_,x,b,this.index)}}update(e,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,s)}addFeatures(e,r,s){for(const o of this.patternFeatures)this.addFeature(o,o.geometry,o.index,r,s)}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,Cd)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Pd),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,s,o,c){const d=this.layers[0].layout,f=d.get("line-join").evaluate(e,{}),_=d.get("line-cap"),x=d.get("line-miter-limit"),b=d.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const w of r)this.addLine(w,e,f,_,x,b);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,c,o)}addLine(e,r,s,o,c,d){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let $=0;$<e.length-1;$++)this.totalDistance+=e[$].dist(e[$+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const f=Md[r.type]==="Polygon";let _=e.length;for(;_>=2&&e[_-1].equals(e[_-2]);)_--;let x=0;for(;x<_-1&&e[x].equals(e[x+1]);)x++;if(_<(f?3:2))return;s==="bevel"&&(c=1.05);const b=this.overscaling<=16?15*Mt/(512*this.overscaling):0,w=this.segments.prepareSegment(10*_,this.layoutVertexArray,this.indexArray);let I,C,k,D,F;this.e1=this.e2=-1,f&&(I=e[_-2],F=e[x].sub(I)._unit()._perp());for(let $=x;$<_;$++){if(k=$===_-1?f?e[x+1]:void 0:e[$+1],k&&e[$].equals(k))continue;F&&(D=F),I&&(C=I),I=e[$],F=k?k.sub(I)._unit()._perp():D,D=D||F;let J=D.add(F);J.x===0&&J.y===0||J._unit();const Z=D.x*F.x+D.y*F.y,K=J.x*F.x+J.y*F.y,ie=K!==0?1/K:1/0,ce=2*Math.sqrt(2-2*K),xe=K<kd&&C&&k,Le=D.x*F.y-D.y*F.x>0;if(xe&&$>x){const ke=I.dist(C);if(ke>2*b){const Ae=I.sub(I.sub(C)._mult(b/ke)._round());this.updateDistance(C,Ae),this.addCurrentVertex(Ae,D,0,0,w),C=Ae}}const be=C&&k;let ye=be?s:f?"butt":o;if(be&&ye==="round"&&(ie<d?ye="miter":ie<=2&&(ye="fakeround")),ye==="miter"&&ie>c&&(ye="bevel"),ye==="bevel"&&(ie>2&&(ye="flipbevel"),ie<c&&(ye="miter")),C&&this.updateDistance(C,I),ye==="miter")J._mult(ie),this.addCurrentVertex(I,J,0,0,w);else if(ye==="flipbevel"){if(ie>100)J=F.mult(-1);else{const ke=ie*D.add(F).mag()/D.sub(F).mag();J._perp()._mult(ke*(Le?-1:1))}this.addCurrentVertex(I,J,0,0,w),this.addCurrentVertex(I,J.mult(-1),0,0,w)}else if(ye==="bevel"||ye==="fakeround"){const ke=-Math.sqrt(ie*ie-1),Ae=Le?ke:0,Ie=Le?0:ke;if(C&&this.addCurrentVertex(I,D,Ae,Ie,w),ye==="fakeround"){const ae=Math.round(180*ce/Math.PI/20);for(let Ee=1;Ee<ae;Ee++){let Me=Ee/ae;if(Me!==.5){const at=Me-.5;Me+=Me*at*(Me-1)*((1.0904+Z*(Z*(3.55645-1.43519*Z)-3.2452))*at*at+(.848013+Z*(.215638*Z-1.06021)))}const Ve=F.sub(D)._mult(Me)._add(D)._unit()._mult(Le?-1:1);this.addHalfVertex(I,Ve.x,Ve.y,!1,Le,0,w)}}k&&this.addCurrentVertex(I,F,-Ae,-Ie,w)}else if(ye==="butt")this.addCurrentVertex(I,J,0,0,w);else if(ye==="square"){const ke=C?1:-1;this.addCurrentVertex(I,J,ke,ke,w)}else ye==="round"&&(C&&(this.addCurrentVertex(I,D,0,0,w),this.addCurrentVertex(I,D,1,1,w,!0)),k&&(this.addCurrentVertex(I,F,-1,-1,w,!0),this.addCurrentVertex(I,F,0,0,w)));if(xe&&$<_-1){const ke=I.dist(k);if(ke>2*b){const Ae=I.add(k.sub(I)._mult(b/ke)._round());this.updateDistance(I,Ae),this.addCurrentVertex(Ae,F,0,0,w),I=Ae}}}}addCurrentVertex(e,r,s,o,c,d=!1){const f=r.y*o-r.x,_=-r.y-r.x*o;this.addHalfVertex(e,r.x+r.y*s,r.y-r.x*s,d,!1,s,c),this.addHalfVertex(e,f,_,d,!0,-o,c),this.distance>Mh/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,r,s,o,c,d))}addHalfVertex({x:e,y:r},s,o,c,d,f,_){const x=.5*(this.lineClips?this.scaledDistance*(Mh-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(c?1:0),(r<<1)+(d?1:0),Math.round(63*s)+128,Math.round(63*o)+128,1+(f===0?0:f<0?-1:1)|(63&x)<<2,x>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const b=_.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,b),_.primitiveLength++),d?this.e2=b:this.e1=b}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,r){this.distance+=e.dist(r),this.updateScaledDistance()}}let kh,zh;Pe("LineBucket",Sc,{omit:["layers","patternFeatures"]});var Eh={get paint(){return zh=zh||new a({"line-opacity":new Be(re.paint_line["line-opacity"]),"line-color":new Be(re.paint_line["line-color"]),"line-translate":new ze(re.paint_line["line-translate"]),"line-translate-anchor":new ze(re.paint_line["line-translate-anchor"]),"line-width":new Be(re.paint_line["line-width"]),"line-gap-width":new Be(re.paint_line["line-gap-width"]),"line-offset":new Be(re.paint_line["line-offset"]),"line-blur":new Be(re.paint_line["line-blur"]),"line-dasharray":new t(re.paint_line["line-dasharray"]),"line-pattern":new h(re.paint_line["line-pattern"]),"line-gradient":new n(re.paint_line["line-gradient"])})},get layout(){return kh=kh||new a({"line-cap":new ze(re.layout_line["line-cap"]),"line-join":new Be(re.layout_line["line-join"]),"line-miter-limit":new ze(re.layout_line["line-miter-limit"]),"line-round-limit":new ze(re.layout_line["line-round-limit"]),"line-sort-key":new Be(re.layout_line["line-sort-key"])})}};class zd extends Be{possiblyEvaluate(e,r){return r=new ct(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(e,r)}evaluate(e,r,s,o){return r=Si({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(e,r,s,o)}}let Al;class Ed extends u{constructor(e){super(e,Eh),this.gradientVersion=0,Al||(Al=new zd(Eh.paint.properties["line-width"].specification),Al.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e==="line-gradient"){const r=this.gradientExpression();this.stepInterpolant=!!function(s){return s._styleExpression!==void 0}(r)&&r._styleExpression.expression instanceof pn,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,r){super.recalculate(e,r),this.paint._values["line-floorwidth"]=Al.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Sc(e)}queryRadius(e){const r=e,s=Dh(_o("line-width",this,r),_o("line-gap-width",this,r)),o=_o("line-offset",this,r);return s/2+Math.abs(o)+vl(this.paint.get("line-translate"))}queryIntersectsFeature(e,r,s,o,c,d,f){const _=bl(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),d.angle,f),x=f/2*Dh(this.paint.get("line-width").evaluate(r,s),this.paint.get("line-gap-width").evaluate(r,s)),b=this.paint.get("line-offset").evaluate(r,s);return b&&(o=function(w,I){const C=[];for(let k=0;k<w.length;k++){const D=w[k],F=[];for(let $=0;$<D.length;$++){const J=D[$-1],Z=D[$],K=D[$+1],ie=$===0?new me(0,0):Z.sub(J)._unit()._perp(),ce=$===D.length-1?new me(0,0):K.sub(Z)._unit()._perp(),xe=ie._add(ce)._unit(),Le=xe.x*ce.x+xe.y*ce.y;Le!==0&&xe._mult(1/Le),F.push(xe._mult(I)._add(Z))}C.push(F)}return C}(o,b*f)),function(w,I,C){for(let k=0;k<I.length;k++){const D=I[k];if(w.length>=3){for(let F=0;F<D.length;F++)if(ra(w,D[F]))return!0}if(ju(w,D,C))return!0}return!1}(_,o,x)}isTileClipped(){return!0}}function Dh(i,e){return e>0?e+2*i:i}const Dd=v([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Ld=v([{name:"a_projected_pos",components:3,type:"Float32"}],4);v([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Rd=v([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);v([{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 Lh=v([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Bd=v([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Fd(i,e,r){return i.sections.forEach(s=>{s.text=function(o,c,d){const f=c.layout.get("text-transform").evaluate(d,{});return f==="uppercase"?o=o.toLocaleUpperCase():f==="lowercase"&&(o=o.toLocaleLowerCase()),Er.applyArabicShaping&&(o=Er.applyArabicShaping(o)),o}(s.text,e,r)}),i}v([{name:"triangle",components:3,type:"Uint16"}]),v([{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"}]),v([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),v([{type:"Float32",name:"offsetX"}]),v([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),v([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const So={"!":"︕","#":"#",$:"$","%":"ï¼…","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"ï¸","-":"︲",".":"・","/":"ï¼",":":"︓",";":"︔","<":"︿","=":"ï¼",">":"ï¹€","?":"︖","@":"ï¼ ","[":"﹇","\\":"ï¼¼","]":"﹈","^":"ï¼¾",_:"︳","`":"ï½€","{":"︷","|":"―","}":"︸","~":"~","¢":"ï¿ ","£":"ï¿¡","Â¥":"ï¿¥","¦":"¦","¬":"ï¿¢","¯":"ï¿£","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"ï¹","â€":"﹂","…":"︙","‧":"・","â‚©":"₩","ã€":"︑","。":"︒","〈":"︿","〉":"ï¹€","《":"︽","》":"︾","「":"ï¹","ã€":"﹂","『":"﹃","ã€":"﹄","ã€":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","ï¼":"︕","(":"︵",")":"︶",",":"ï¸","ï¼":"︲",".":"・",":":"︓","ï¼›":"︔","<":"︿",">":"ï¹€","?":"︖","ï¼»":"﹇","ï¼½":"﹈","_":"︳","ï½›":"︷","|":"―","ï½":"︸","⦅":"︵","ï½ ":"︶","。":"︒","ï½¢":"ï¹","ï½£":"﹂"};var Et=24,Rh=nt,Bh=function(i,e,r,s,o){var c,d,f=8*o-s-1,_=(1<<f)-1,x=_>>1,b=-7,w=o-1,I=-1,C=i[e+w];for(w+=I,c=C&(1<<-b)-1,C>>=-b,b+=f;b>0;c=256*c+i[e+w],w+=I,b-=8);for(d=c&(1<<-b)-1,c>>=-b,b+=s;b>0;d=256*d+i[e+w],w+=I,b-=8);if(c===0)c=1-x;else{if(c===_)return d?NaN:1/0*(C?-1:1);d+=Math.pow(2,s),c-=x}return(C?-1:1)*d*Math.pow(2,c-s)},Fh=function(i,e,r,s,o,c){var d,f,_,x=8*c-o-1,b=(1<<x)-1,w=b>>1,I=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,C=0,k=1,D=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(f=isNaN(e)?1:0,d=b):(d=Math.floor(Math.log(e)/Math.LN2),e*(_=Math.pow(2,-d))<1&&(d--,_*=2),(e+=d+w>=1?I/_:I*Math.pow(2,1-w))*_>=2&&(d++,_/=2),d+w>=b?(f=0,d=b):d+w>=1?(f=(e*_-1)*Math.pow(2,o),d+=w):(f=e*Math.pow(2,w-1)*Math.pow(2,o),d=0));o>=8;i[r+C]=255&f,C+=k,f/=256,o-=8);for(d=d<<o|f,x+=o;x>0;i[r+C]=255&d,C+=k,d/=256,x-=8);i[r+C-k]|=128*D};function nt(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}nt.Varint=0,nt.Fixed64=1,nt.Bytes=2,nt.Fixed32=5;var Ic=4294967296,Oh=1/Ic,Vh=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function sn(i){return i.type===nt.Bytes?i.readVarint()+i.pos:i.pos+1}function oa(i,e,r){return r?4294967296*e+(i>>>0):4294967296*(e>>>0)+(i>>>0)}function Nh(i,e,r){var s=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(s);for(var o=r.pos-1;o>=i;o--)r.buf[o+s]=r.buf[o]}function Od(i,e){for(var r=0;r<i.length;r++)e.writeVarint(i[r])}function Vd(i,e){for(var r=0;r<i.length;r++)e.writeSVarint(i[r])}function Nd(i,e){for(var r=0;r<i.length;r++)e.writeFloat(i[r])}function jd(i,e){for(var r=0;r<i.length;r++)e.writeDouble(i[r])}function Ud(i,e){for(var r=0;r<i.length;r++)e.writeBoolean(i[r])}function $d(i,e){for(var r=0;r<i.length;r++)e.writeFixed32(i[r])}function qd(i,e){for(var r=0;r<i.length;r++)e.writeSFixed32(i[r])}function Zd(i,e){for(var r=0;r<i.length;r++)e.writeFixed64(i[r])}function Gd(i,e){for(var r=0;r<i.length;r++)e.writeSFixed64(i[r])}function Cl(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16)+16777216*i[e+3]}function la(i,e,r){i[r]=e,i[r+1]=e>>>8,i[r+2]=e>>>16,i[r+3]=e>>>24}function jh(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16)+(i[e+3]<<24)}nt.prototype={destroy:function(){this.buf=null},readFields:function(i,e,r){for(r=r||this.length;this.pos<r;){var s=this.readVarint(),o=s>>3,c=this.pos;this.type=7&s,i(o,e,this),this.pos===c&&this.skip(s)}return e},readMessage:function(i,e){return this.readFields(i,e,this.readVarint()+this.pos)},readFixed32:function(){var i=Cl(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=jh(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=Cl(this.buf,this.pos)+Cl(this.buf,this.pos+4)*Ic;return this.pos+=8,i},readSFixed64:function(){var i=Cl(this.buf,this.pos)+jh(this.buf,this.pos+4)*Ic;return this.pos+=8,i},readFloat:function(){var i=Bh(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=Bh(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var e,r,s=this.buf;return e=127&(r=s[this.pos++]),r<128?e:(e|=(127&(r=s[this.pos++]))<<7,r<128?e:(e|=(127&(r=s[this.pos++]))<<14,r<128?e:(e|=(127&(r=s[this.pos++]))<<21,r<128?e:function(o,c,d){var f,_,x=d.buf;if(f=(112&(_=x[d.pos++]))>>4,_<128||(f|=(127&(_=x[d.pos++]))<<3,_<128)||(f|=(127&(_=x[d.pos++]))<<10,_<128)||(f|=(127&(_=x[d.pos++]))<<17,_<128)||(f|=(127&(_=x[d.pos++]))<<24,_<128)||(f|=(1&(_=x[d.pos++]))<<31,_<128))return oa(o,f,c);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=s[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?(i+1)/-2:i/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var i=this.readVarint()+this.pos,e=this.pos;return this.pos=i,i-e>=12&&Vh?function(r,s,o){return Vh.decode(r.subarray(s,o))}(this.buf,e,i):function(r,s,o){for(var c="",d=s;d<o;){var f,_,x,b=r[d],w=null,I=b>239?4:b>223?3:b>191?2:1;if(d+I>o)break;I===1?b<128&&(w=b):I===2?(192&(f=r[d+1]))==128&&(w=(31&b)<<6|63&f)<=127&&(w=null):I===3?(_=r[d+2],(192&(f=r[d+1]))==128&&(192&_)==128&&((w=(15&b)<<12|(63&f)<<6|63&_)<=2047||w>=55296&&w<=57343)&&(w=null)):I===4&&(_=r[d+2],x=r[d+3],(192&(f=r[d+1]))==128&&(192&_)==128&&(192&x)==128&&((w=(15&b)<<18|(63&f)<<12|(63&_)<<6|63&x)<=65535||w>=1114112)&&(w=null)),w===null?(w=65533,I=1):w>65535&&(w-=65536,c+=String.fromCharCode(w>>>10&1023|55296),w=56320|1023&w),c+=String.fromCharCode(w),d+=I}return c}(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!==nt.Bytes)return i.push(this.readVarint(e));var r=sn(this);for(i=i||[];this.pos<r;)i.push(this.readVarint(e));return i},readPackedSVarint:function(i){if(this.type!==nt.Bytes)return i.push(this.readSVarint());var e=sn(this);for(i=i||[];this.pos<e;)i.push(this.readSVarint());return i},readPackedBoolean:function(i){if(this.type!==nt.Bytes)return i.push(this.readBoolean());var e=sn(this);for(i=i||[];this.pos<e;)i.push(this.readBoolean());return i},readPackedFloat:function(i){if(this.type!==nt.Bytes)return i.push(this.readFloat());var e=sn(this);for(i=i||[];this.pos<e;)i.push(this.readFloat());return i},readPackedDouble:function(i){if(this.type!==nt.Bytes)return i.push(this.readDouble());var e=sn(this);for(i=i||[];this.pos<e;)i.push(this.readDouble());return i},readPackedFixed32:function(i){if(this.type!==nt.Bytes)return i.push(this.readFixed32());var e=sn(this);for(i=i||[];this.pos<e;)i.push(this.readFixed32());return i},readPackedSFixed32:function(i){if(this.type!==nt.Bytes)return i.push(this.readSFixed32());var e=sn(this);for(i=i||[];this.pos<e;)i.push(this.readSFixed32());return i},readPackedFixed64:function(i){if(this.type!==nt.Bytes)return i.push(this.readFixed64());var e=sn(this);for(i=i||[];this.pos<e;)i.push(this.readFixed64());return i},readPackedSFixed64:function(i){if(this.type!==nt.Bytes)return i.push(this.readSFixed64());var e=sn(this);for(i=i||[];this.pos<e;)i.push(this.readSFixed64());return i},skip:function(i){var e=7&i;if(e===nt.Varint)for(;this.buf[this.pos++]>127;);else if(e===nt.Bytes)this.pos=this.readVarint()+this.pos;else if(e===nt.Fixed32)this.pos+=4;else{if(e!==nt.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),la(this.buf,i,this.pos),this.pos+=4},writeSFixed32:function(i){this.realloc(4),la(this.buf,i,this.pos),this.pos+=4},writeFixed64:function(i){this.realloc(8),la(this.buf,-1&i,this.pos),la(this.buf,Math.floor(i*Oh),this.pos+4),this.pos+=8},writeSFixed64:function(i){this.realloc(8),la(this.buf,-1&i,this.pos),la(this.buf,Math.floor(i*Oh),this.pos+4),this.pos+=8},writeVarint:function(i){(i=+i||0)>268435455||i<0?function(e,r){var s,o;if(e>=0?(s=e%4294967296|0,o=e/4294967296|0):(o=~(-e/4294967296),4294967295^(s=~(-e%4294967296))?s=s+1|0:(s=0,o=o+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),function(c,d,f){f.buf[f.pos++]=127&c|128,c>>>=7,f.buf[f.pos++]=127&c|128,c>>>=7,f.buf[f.pos++]=127&c|128,c>>>=7,f.buf[f.pos++]=127&c|128,f.buf[f.pos]=127&(c>>>=7)}(s,0,r),function(c,d){var f=(7&c)<<4;d.buf[d.pos++]|=f|((c>>>=3)?128:0),c&&(d.buf[d.pos++]=127&c|((c>>>=7)?128:0),c&&(d.buf[d.pos++]=127&c|((c>>>=7)?128:0),c&&(d.buf[d.pos++]=127&c|((c>>>=7)?128:0),c&&(d.buf[d.pos++]=127&c|((c>>>=7)?128:0),c&&(d.buf[d.pos++]=127&c)))))}(o,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(s,o,c){for(var d,f,_=0;_<o.length;_++){if((d=o.charCodeAt(_))>55295&&d<57344){if(!f){d>56319||_+1===o.length?(s[c++]=239,s[c++]=191,s[c++]=189):f=d;continue}if(d<56320){s[c++]=239,s[c++]=191,s[c++]=189,f=d;continue}d=f-55296<<10|d-56320|65536,f=null}else f&&(s[c++]=239,s[c++]=191,s[c++]=189,f=null);d<128?s[c++]=d:(d<2048?s[c++]=d>>6|192:(d<65536?s[c++]=d>>12|224:(s[c++]=d>>18|240,s[c++]=d>>12&63|128),s[c++]=d>>6&63|128),s[c++]=63&d|128)}return c}(this.buf,i,this.pos);var r=this.pos-e;r>=128&&Nh(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(i){this.realloc(4),Fh(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),Fh(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 s=this.pos-r;s>=128&&Nh(r,s,this),this.pos=r-1,this.writeVarint(s),this.pos+=s},writeMessage:function(i,e,r){this.writeTag(i,nt.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(i,e){e.length&&this.writeMessage(i,Od,e)},writePackedSVarint:function(i,e){e.length&&this.writeMessage(i,Vd,e)},writePackedBoolean:function(i,e){e.length&&this.writeMessage(i,Ud,e)},writePackedFloat:function(i,e){e.length&&this.writeMessage(i,Nd,e)},writePackedDouble:function(i,e){e.length&&this.writeMessage(i,jd,e)},writePackedFixed32:function(i,e){e.length&&this.writeMessage(i,$d,e)},writePackedSFixed32:function(i,e){e.length&&this.writeMessage(i,qd,e)},writePackedFixed64:function(i,e){e.length&&this.writeMessage(i,Zd,e)},writePackedSFixed64:function(i,e){e.length&&this.writeMessage(i,Gd,e)},writeBytesField:function(i,e){this.writeTag(i,nt.Bytes),this.writeBytes(e)},writeFixed32Field:function(i,e){this.writeTag(i,nt.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(i,e){this.writeTag(i,nt.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(i,e){this.writeTag(i,nt.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(i,e){this.writeTag(i,nt.Fixed64),this.writeSFixed64(e)},writeVarintField:function(i,e){this.writeTag(i,nt.Varint),this.writeVarint(e)},writeSVarintField:function(i,e){this.writeTag(i,nt.Varint),this.writeSVarint(e)},writeStringField:function(i,e){this.writeTag(i,nt.Bytes),this.writeString(e)},writeFloatField:function(i,e){this.writeTag(i,nt.Fixed32),this.writeFloat(e)},writeDoubleField:function(i,e){this.writeTag(i,nt.Fixed64),this.writeDouble(e)},writeBooleanField:function(i,e){this.writeVarintField(i,!!e)}};var Pc=Ti(Rh);const Ac=3;function Xd(i,e,r){i===1&&r.readMessage(Wd,e)}function Wd(i,e,r){if(i===3){const{id:s,bitmap:o,width:c,height:d,left:f,top:_,advance:x}=r.readMessage(Hd,{});e.push({id:s,bitmap:new yo({width:c+2*Ac,height:d+2*Ac},o),metrics:{width:c,height:d,left:f,top:_,advance:x}})}}function Hd(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())}const Uh=Ac;function $h(i){let e=0,r=0;for(const d of i)e+=d.w*d.h,r=Math.max(r,d.w);i.sort((d,f)=>f.h-d.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let o=0,c=0;for(const d of i)for(let f=s.length-1;f>=0;f--){const _=s[f];if(!(d.w>_.w||d.h>_.h)){if(d.x=_.x,d.y=_.y,c=Math.max(c,d.y+d.h),o=Math.max(o,d.x+d.w),d.w===_.w&&d.h===_.h){const x=s.pop();f<s.length&&(s[f]=x)}else d.h===_.h?(_.x+=d.w,_.w-=d.w):d.w===_.w?(_.y+=d.h,_.h-=d.h):(s.push({x:_.x+d.w,y:_.y,w:_.w-d.w,h:d.h}),_.y+=d.h,_.h-=d.h);break}}return{w:o,h:c,fill:e/(o*c)||0}}const bi=1;class Cc{constructor(e,{pixelRatio:r,version:s,stretchX:o,stretchY:c,content:d,textFitWidth:f,textFitHeight:_}){this.paddedRect=e,this.pixelRatio=r,this.stretchX=o,this.stretchY=c,this.content=d,this.version=s,this.textFitWidth=f,this.textFitHeight=_}get tl(){return[this.paddedRect.x+bi,this.paddedRect.y+bi]}get br(){return[this.paddedRect.x+this.paddedRect.w-bi,this.paddedRect.y+this.paddedRect.h-bi]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2*bi)/this.pixelRatio,(this.paddedRect.h-2*bi)/this.pixelRatio]}}class qh{constructor(e,r){const s={},o={};this.haveRenderCallbacks=[];const c=[];this.addImages(e,s,c),this.addImages(r,o,c);const{w:d,h:f}=$h(c),_=new Oi({width:d||1,height:f||1});for(const x in e){const b=e[x],w=s[x].paddedRect;Oi.copy(b.data,_,{x:0,y:0},{x:w.x+bi,y:w.y+bi},b.data)}for(const x in r){const b=r[x],w=o[x].paddedRect,I=w.x+bi,C=w.y+bi,k=b.data.width,D=b.data.height;Oi.copy(b.data,_,{x:0,y:0},{x:I,y:C},b.data),Oi.copy(b.data,_,{x:0,y:D-1},{x:I,y:C-1},{width:k,height:1}),Oi.copy(b.data,_,{x:0,y:0},{x:I,y:C+D},{width:k,height:1}),Oi.copy(b.data,_,{x:k-1,y:0},{x:I-1,y:C},{width:1,height:D}),Oi.copy(b.data,_,{x:0,y:0},{x:I+k,y:C},{width:1,height:D})}this.image=_,this.iconPositions=s,this.patternPositions=o}addImages(e,r,s){for(const o in e){const c=e[o],d={x:0,y:0,w:c.data.width+2*bi,h:c.data.height+2*bi};s.push(d),r[o]=new Cc(d,c),c.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(e,r){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const s in e.updatedImages)this.patchUpdatedImage(this.iconPositions[s],e.getImage(s),r),this.patchUpdatedImage(this.patternPositions[s],e.getImage(s),r)}patchUpdatedImage(e,r,s){if(!e||!r||e.version===r.version)return;e.version=r.version;const[o,c]=e.tl;s.update(r.data,void 0,{x:o,y:c})}}var kn;Pe("ImagePosition",Cc),Pe("ImageAtlas",qh),L.ai=void 0,(kn=L.ai||(L.ai={}))[kn.none=0]="none",kn[kn.horizontal=1]="horizontal",kn[kn.vertical=2]="vertical",kn[kn.horizontalOnly=3]="horizontalOnly";const Io=-17;class Po{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,r){const s=new Po;return s.scale=e||1,s.fontStack=r,s}static forImage(e){const r=new Po;return r.imageName=e,r}}class ca{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,r){const s=new ca;for(let o=0;o<e.sections.length;o++){const c=e.sections[o];c.image?s.addImageSection(c):s.addTextSection(c,r)}return s}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 s=0;s<e.length;s++){const o=e.charCodeAt(s+1)||null,c=e.charCodeAt(s-1)||null;r+=o&&dl(o)&&!So[e[s+1]]||c&&dl(c)&&!So[e[s-1]]||!So[e[s]]?e[s]:So[e[s]]}return r}(this.text)}trim(){let e=0;for(let s=0;s<this.text.length&&kl[this.text.charCodeAt(s)];s++)e++;let r=this.text.length;for(let s=this.text.length-1;s>=0&&s>=e&&kl[this.text.charCodeAt(s)];s--)r--;this.text=this.text.substring(e,r),this.sectionIndex=this.sectionIndex.slice(e,r)}substring(e,r){const s=new ca;return s.text=this.text.substring(e,r),s.sectionIndex=this.sectionIndex.slice(e,r),s.sections=this.sections,s}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(Po.forText(e.scale,e.fontStack||r));const s=this.sections.length-1;for(let o=0;o<e.text.length;++o)this.sectionIndex.push(s)}addImageSection(e){const r=e.image?e.image.name:"";if(r.length===0)return void Ot("Can't add FormattedSection with an empty image.");const s=this.getNextImageSectionCharCode();s?(this.text+=String.fromCharCode(s),this.sections.push(Po.forImage(r)),this.sectionIndex.push(this.sections.length-1)):Ot("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Ml(i,e,r,s,o,c,d,f,_,x,b,w,I,C,k){const D=ca.fromFeature(i,o);let F;w===L.ai.vertical&&D.verticalizePunctuation();const{processBidirectionalText:$,processStyledBidirectionalText:J}=Er;if($&&D.sections.length===1){F=[];const ie=$(D.toString(),Mc(D,x,c,e,s,C));for(const ce of ie){const xe=new ca;xe.text=ce,xe.sections=D.sections;for(let Le=0;Le<ce.length;Le++)xe.sectionIndex.push(0);F.push(xe)}}else if(J){F=[];const ie=J(D.text,D.sectionIndex,Mc(D,x,c,e,s,C));for(const ce of ie){const xe=new ca;xe.text=ce[0],xe.sectionIndex=ce[1],xe.sections=D.sections,F.push(xe)}}else F=function(ie,ce){const xe=[],Le=ie.text;let be=0;for(const ye of ce)xe.push(ie.substring(be,ye)),be=ye;return be<Le.length&&xe.push(ie.substring(be,Le.length)),xe}(D,Mc(D,x,c,e,s,C));const Z=[],K={positionedLines:Z,text:D.toString(),top:b[1],bottom:b[1],left:b[0],right:b[0],writingMode:w,iconsInText:!1,verticalizable:!1};return function(ie,ce,xe,Le,be,ye,ke,Ae,Ie,ae,Ee,Me){let Ve=0,at=Io,st=0,Lt=0;const rr=Ae==="right"?1:Ae==="left"?0:.5;let Wt=0;for(const St of be){St.trim();const Rt=St.getMaxScale(),ii=(Rt-1)*Et,Ht={positionedGlyphs:[],lineOffset:0};ie.positionedLines[Wt]=Ht;const di=Ht.positionedGlyphs;let Kt=0;if(!St.length()){at+=ye,++Wt;continue}for(let wi=0;wi<St.length();wi++){const Ye=St.getSection(wi),ht=St.getSectionIndex(wi),_t=St.getCharCode(wi);let Ci=0,wt=null,pa=null,Br=null,Fr=Et;const nr=!(Ie===L.ai.horizontal||!Ee&&!ao(_t)||Ee&&(kl[_t]||(Tt=_t,we.Arabic(Tt)||we["Arabic Supplement"](Tt)||we["Arabic Extended-A"](Tt)||we["Arabic Presentation Forms-A"](Tt)||we["Arabic Presentation Forms-B"](Tt))));if(Ye.imageName){const ji=Le[Ye.imageName];if(!ji)continue;Br=Ye.imageName,ie.iconsInText=ie.iconsInText||!0,pa=ji.paddedRect;const Ft=ji.displaySize;Ye.scale=Ye.scale*Et/Me,wt={width:Ft[0],height:Ft[1],left:bi,top:-Uh,advance:nr?Ft[1]:Ft[0]},Ci=ii+(Et-Ft[1]*Ye.scale),Fr=wt.advance;const an=nr?Ft[0]*Ye.scale-Et*Rt:Ft[1]*Ye.scale-Et*Rt;an>0&&an>Kt&&(Kt=an)}else{const ji=xe[Ye.fontStack],Ft=ji&&ji[_t];if(Ft&&Ft.rect)pa=Ft.rect,wt=Ft.metrics;else{const an=ce[Ye.fontStack],zo=an&&an[_t];if(!zo)continue;wt=zo.metrics}Ci=(Rt-Ye.scale)*Et}nr?(ie.verticalizable=!0,di.push({glyph:_t,imageName:Br,x:Ve,y:at+Ci,vertical:nr,scale:Ye.scale,fontStack:Ye.fontStack,sectionIndex:ht,metrics:wt,rect:pa}),Ve+=Fr*Ye.scale+ae):(di.push({glyph:_t,imageName:Br,x:Ve,y:at+Ci,vertical:nr,scale:Ye.scale,fontStack:Ye.fontStack,sectionIndex:ht,metrics:wt,rect:pa}),Ve+=wt.advance*Ye.scale+ae)}di.length!==0&&(st=Math.max(Ve-ae,st),Qd(di,0,di.length-1,rr,Kt)),Ve=0;const Ni=ye*Rt+Kt;Ht.lineOffset=Math.max(Kt,ii),at+=Ni,Lt=Math.max(Ni,Lt),++Wt}var Tt;const ci=at-Io,{horizontalAlign:hi,verticalAlign:ui}=kc(ke);(function(St,Rt,ii,Ht,di,Kt,Ni,wi,Ye){const ht=(Rt-ii)*di;let _t=0;_t=Kt!==Ni?-wi*Ht-Io:(-Ht*Ye+.5)*Ni;for(const Ci of St)for(const wt of Ci.positionedGlyphs)wt.x+=ht,wt.y+=_t})(ie.positionedLines,rr,hi,ui,st,Lt,ye,ci,be.length),ie.top+=-ui*ci,ie.bottom=ie.top+ci,ie.left+=-hi*st,ie.right=ie.left+st}(K,e,r,s,F,d,f,_,w,x,I,k),!function(ie){for(const ce of ie)if(ce.positionedGlyphs.length!==0)return!1;return!0}(Z)&&K}const kl={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Kd={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},Jd={40:!0};function Zh(i,e,r,s,o,c){if(e.imageName){const d=s[e.imageName];return d?d.displaySize[0]*e.scale*Et/c+o:0}{const d=r[e.fontStack],f=d&&d[i];return f?f.metrics.advance*e.scale+o:0}}function Gh(i,e,r,s){const o=Math.pow(i-e,2);return s?i<e?o/2:2*o:o+Math.abs(r)*r}function Yd(i,e,r){let s=0;return i===10&&(s-=1e4),r&&(s+=150),i!==40&&i!==65288||(s+=50),e!==41&&e!==65289||(s+=50),s}function Xh(i,e,r,s,o,c){let d=null,f=Gh(e,r,o,c);for(const _ of s){const x=Gh(e-_.x,r,o,c)+_.badness;x<=f&&(d=_,f=x)}return{index:i,x:e,priorBreak:d,badness:f}}function Wh(i){return i?Wh(i.priorBreak).concat(i.index):[]}function Mc(i,e,r,s,o,c){if(!i)return[];const d=[],f=function(w,I,C,k,D,F){let $=0;for(let J=0;J<w.length();J++){const Z=w.getSection(J);$+=Zh(w.getCharCode(J),Z,k,D,I,F)}return $/Math.max(1,Math.ceil($/C))}(i,e,r,s,o,c),_=i.text.indexOf("​")>=0;let x=0;for(let w=0;w<i.length();w++){const I=i.getSection(w),C=i.getCharCode(w);if(kl[C]||(x+=Zh(C,I,s,o,e,c)),w<i.length()-1){const k=!((b=C)<11904||!(we["Bopomofo Extended"](b)||we.Bopomofo(b)||we["CJK Compatibility Forms"](b)||we["CJK Compatibility Ideographs"](b)||we["CJK Compatibility"](b)||we["CJK Radicals Supplement"](b)||we["CJK Strokes"](b)||we["CJK Symbols and Punctuation"](b)||we["CJK Unified Ideographs Extension A"](b)||we["CJK Unified Ideographs"](b)||we["Enclosed CJK Letters and Months"](b)||we["Halfwidth and Fullwidth Forms"](b)||we.Hiragana(b)||we["Ideographic Description Characters"](b)||we["Kangxi Radicals"](b)||we["Katakana Phonetic Extensions"](b)||we.Katakana(b)||we["Vertical Forms"](b)||we["Yi Radicals"](b)||we["Yi Syllables"](b)));(Kd[C]||k||I.imageName||w!==i.length()-2&&Jd[i.getCharCode(w+1)])&&d.push(Xh(w+1,x,f,d,Yd(C,i.getCharCode(w+1),k&&_),!1))}}var b;return Wh(Xh(i.length(),x,f,d,0,!0))}function kc(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 Qd(i,e,r,s,o){if(!s&&!o)return;const c=i[r],d=(i[r].x+c.metrics.advance*c.scale)*s;for(let f=e;f<=r;f++)i[f].x-=d,i[f].y+=o}function ep(i,e,r){const{horizontalAlign:s,verticalAlign:o}=kc(r),c=e[0]-i.displaySize[0]*s,d=e[1]-i.displaySize[1]*o;return{image:i,top:d,bottom:d+i.displaySize[1],left:c,right:c+i.displaySize[0]}}function Hh(i){var e,r;let s=i.left,o=i.top,c=i.right-s,d=i.bottom-o;const f=(e=i.image.textFitWidth)!==null&&e!==void 0?e:"stretchOrShrink",_=(r=i.image.textFitHeight)!==null&&r!==void 0?r:"stretchOrShrink",x=(i.image.content[2]-i.image.content[0])/(i.image.content[3]-i.image.content[1]);if(_==="proportional"){if(f==="stretchOnly"&&c/d<x||f==="proportional"){const b=Math.ceil(d*x);s*=b/c,c=b}}else if(f==="proportional"&&_==="stretchOnly"&&x!==0&&c/d>x){const b=Math.ceil(c/x);o*=b/d,d=b}return{x1:s,y1:o,x2:s+c,y2:o+d}}function Kh(i,e,r,s,o,c){const d=i.image;let f;if(d.content){const F=d.content,$=d.pixelRatio||1;f=[F[0]/$,F[1]/$,d.displaySize[0]-F[2]/$,d.displaySize[1]-F[3]/$]}const _=e.left*c,x=e.right*c;let b,w,I,C;r==="width"||r==="both"?(C=o[0]+_-s[3],w=o[0]+x+s[1]):(C=o[0]+(_+x-d.displaySize[0])/2,w=C+d.displaySize[0]);const k=e.top*c,D=e.bottom*c;return r==="height"||r==="both"?(b=o[1]+k-s[0],I=o[1]+D+s[2]):(b=o[1]+(k+D-d.displaySize[1])/2,I=b+d.displaySize[1]),{image:d,top:b,right:w,bottom:I,left:C,collisionPadding:f}}const Ao=255,Rr=128,zn=Ao*Rr;function Jh(i,e){const{expression:r}=e;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new ct(i+1))};if(r.kind==="source")return{kind:"source"};{const{zoomStops:s,interpolationType:o}=r;let c=0;for(;c<s.length&&s[c]<=i;)c++;c=Math.max(0,c-1);let d=c;for(;d<s.length&&s[d]<i+1;)d++;d=Math.min(s.length-1,d);const f=s[c],_=s[d];return r.kind==="composite"?{kind:"composite",minZoom:f,maxZoom:_,interpolationType:o}:{kind:"camera",minZoom:f,maxZoom:_,minSize:r.evaluate(new ct(f)),maxSize:r.evaluate(new ct(_)),interpolationType:o}}}function zc(i,e,r){let s="never";const o=i.get(e);return o?s=o:i.get(r)&&(s="always"),s}const tp=Mn.VectorTileFeature.types,ip=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function zl(i,e,r,s,o,c,d,f,_,x,b,w,I){const C=f?Math.min(zn,Math.round(f[0])):0,k=f?Math.min(zn,Math.round(f[1])):0;i.emplaceBack(e,r,Math.round(32*s),Math.round(32*o),c,d,(C<<1)+(_?1:0),k,16*x,16*b,256*w,256*I)}function Ec(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 rp(i){for(const e of i.sections)if(oo(e.text))return!0;return!1}class Dc{constructor(e){this.layoutVertexArray=new Fi,this.indexArray=new Dt,this.programConfigurations=e,this.segments=new zt,this.dynamicLayoutVertexArray=new Dr,this.opacityVertexArray=new In,this.hasVisibleVertices=!1,this.placedSymbolArray=new ft}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,r,s,o){this.isEmpty()||(s&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Dd.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Ld.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,ip,!0),this.opacityVertexBuffer.itemSize=1),(s||o)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}Pe("SymbolBuffers",Dc);class Lc{constructor(e,r,s){this.layoutVertexArray=new e,this.layoutAttributes=r,this.indexArray=new s,this.segments=new zt,this.collisionVertexArray=new Gt}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Rd.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}Pe("CollisionBuffers",Lc);class ha{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(d=>d.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=dc([]),this.placementViewportMatrix=dc([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Jh(this.zoom,r["text-size"]),this.iconSizeData=Jh(this.zoom,r["icon-size"]);const s=this.layers[0].layout,o=s.get("symbol-sort-key"),c=s.get("symbol-z-order");this.canOverlap=zc(s,"text-overlap","text-allow-overlap")!=="never"||zc(s,"icon-overlap","icon-allow-overlap")!=="never"||s.get("text-ignore-placement")||s.get("icon-ignore-placement"),this.sortFeaturesByKey=c!=="viewport-y"&&!o.isConstant(),this.sortFeaturesByY=(c==="viewport-y"||c==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,s.get("symbol-placement")==="point"&&(this.writingModes=s.get("text-writing-mode").map(d=>L.ai[d])),this.stateDependentLayerIds=this.layers.filter(d=>d.isStateDependent()).map(d=>d.id),this.sourceID=e.sourceID}createArrays(){this.text=new Dc(new ds(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Dc(new ds(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new mt,this.lineVertexArray=new oi,this.symbolInstances=new Ri,this.textAnchorOffsets=new $t}calculateGlyphDependencies(e,r,s,o,c){for(let d=0;d<e.length;d++)if(r[e.charCodeAt(d)]=!0,(s||o)&&c){const f=So[e.charAt(d)];f&&(r[f.charCodeAt(0)]=!0)}}populate(e,r,s){const o=this.layers[0],c=o.layout,d=c.get("text-font"),f=c.get("text-field"),_=c.get("icon-image"),x=(f.value.kind!=="constant"||f.value.value instanceof mi&&!f.value.value.isEmpty()||f.value.value.toString().length>0)&&(d.value.kind!=="constant"||d.value.value.length>0),b=_.value.kind!=="constant"||!!_.value.value||Object.keys(_.parameters).length>0,w=c.get("symbol-sort-key");if(this.features=[],!x&&!b)return;const I=r.iconDependencies,C=r.glyphDependencies,k=r.availableImages,D=new ct(this.zoom);for(const{feature:F,id:$,index:J,sourceLayerIndex:Z}of e){const K=o._featureFilter.needGeometry,ie=fs(F,K);if(!o._featureFilter.filter(D,ie,s))continue;let ce,xe;if(K||(ie.geometry=ps(F)),x){const be=o.getValueAndResolveTokens("text-field",ie,s,k),ye=mi.factory(be),ke=this.hasRTLText=this.hasRTLText||rp(ye);(!ke||Er.getRTLTextPluginStatus()==="unavailable"||ke&&Er.isParsed())&&(ce=Fd(ye,o,ie))}if(b){const be=o.getValueAndResolveTokens("icon-image",ie,s,k);xe=be instanceof jt?be:jt.fromString(be)}if(!ce&&!xe)continue;const Le=this.sortFeaturesByKey?w.evaluate(ie,{},s):void 0;if(this.features.push({id:$,text:ce,icon:xe,index:J,sourceLayerIndex:Z,geometry:ie.geometry,properties:F.properties,type:tp[F.type],sortKey:Le}),xe&&(I[xe.name]=!0),ce){const be=d.evaluate(ie,{},s).join(","),ye=c.get("text-rotation-alignment")!=="viewport"&&c.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(L.ai.vertical)>=0;for(const ke of ce.sections)if(ke.image)I[ke.image.name]=!0;else{const Ae=so(ce.toString()),Ie=ke.fontStack||be,ae=C[Ie]=C[Ie]||{};this.calculateGlyphDependencies(ke.text,ae,ye,this.allowVerticalPlacement,Ae)}}}c.get("symbol-placement")==="line"&&(this.features=function(F){const $={},J={},Z=[];let K=0;function ie(be){Z.push(F[be]),K++}function ce(be,ye,ke){const Ae=J[be];return delete J[be],J[ye]=Ae,Z[Ae].geometry[0].pop(),Z[Ae].geometry[0]=Z[Ae].geometry[0].concat(ke[0]),Ae}function xe(be,ye,ke){const Ae=$[ye];return delete $[ye],$[be]=Ae,Z[Ae].geometry[0].shift(),Z[Ae].geometry[0]=ke[0].concat(Z[Ae].geometry[0]),Ae}function Le(be,ye,ke){const Ae=ke?ye[0][ye[0].length-1]:ye[0][0];return`${be}:${Ae.x}:${Ae.y}`}for(let be=0;be<F.length;be++){const ye=F[be],ke=ye.geometry,Ae=ye.text?ye.text.toString():null;if(!Ae){ie(be);continue}const Ie=Le(Ae,ke),ae=Le(Ae,ke,!0);if(Ie in J&&ae in $&&J[Ie]!==$[ae]){const Ee=xe(Ie,ae,ke),Me=ce(Ie,ae,Z[Ee].geometry);delete $[Ie],delete J[ae],J[Le(Ae,Z[Me].geometry,!0)]=Me,Z[Ee].geometry=null}else Ie in J?ce(Ie,ae,ke):ae in $?xe(Ie,ae,ke):(ie(be),$[Ie]=K-1,J[ae]=K-1)}return Z.filter(be=>be.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((F,$)=>F.sortKey-$.sortKey)}update(e,r,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,r,this.layers,s),this.icon.programConfigurations.updatePaintArrays(e,r,this.layers,s))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(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 s=this.lineVertexArray.length;if(e.segment!==void 0){let o=e.dist(r[e.segment+1]),c=e.dist(r[e.segment]);const d={};for(let f=e.segment+1;f<r.length;f++)d[f]={x:r[f].x,y:r[f].y,tileUnitDistanceFromAnchor:o},f<r.length-1&&(o+=r[f+1].dist(r[f]));for(let f=e.segment||0;f>=0;f--)d[f]={x:r[f].x,y:r[f].y,tileUnitDistanceFromAnchor:c},f>0&&(c+=r[f-1].dist(r[f]));for(let f=0;f<r.length;f++){const _=d[f];this.lineVertexArray.emplaceBack(_.x,_.y,_.tileUnitDistanceFromAnchor)}}return{lineStartIndex:s,lineLength:this.lineVertexArray.length-s}}addSymbols(e,r,s,o,c,d,f,_,x,b,w,I){const C=e.indexArray,k=e.layoutVertexArray,D=e.segments.prepareSegment(4*r.length,k,C,this.canOverlap?d.sortKey:void 0),F=this.glyphOffsetArray.length,$=D.vertexLength,J=this.allowVerticalPlacement&&f===L.ai.vertical?Math.PI/2:0,Z=d.text&&d.text.sections;for(let K=0;K<r.length;K++){const{tl:ie,tr:ce,bl:xe,br:Le,tex:be,pixelOffsetTL:ye,pixelOffsetBR:ke,minFontScaleX:Ae,minFontScaleY:Ie,glyphOffset:ae,isSDF:Ee,sectionIndex:Me}=r[K],Ve=D.vertexLength,at=ae[1];zl(k,_.x,_.y,ie.x,at+ie.y,be.x,be.y,s,Ee,ye.x,ye.y,Ae,Ie),zl(k,_.x,_.y,ce.x,at+ce.y,be.x+be.w,be.y,s,Ee,ke.x,ye.y,Ae,Ie),zl(k,_.x,_.y,xe.x,at+xe.y,be.x,be.y+be.h,s,Ee,ye.x,ke.y,Ae,Ie),zl(k,_.x,_.y,Le.x,at+Le.y,be.x+be.w,be.y+be.h,s,Ee,ke.x,ke.y,Ae,Ie),Ec(e.dynamicLayoutVertexArray,_,J),C.emplaceBack(Ve,Ve+1,Ve+2),C.emplaceBack(Ve+1,Ve+2,Ve+3),D.vertexLength+=4,D.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(ae[0]),K!==r.length-1&&Me===r[K+1].sectionIndex||e.programConfigurations.populatePaintArrays(k.length,d,d.index,{},I,Z&&Z[Me])}e.placedSymbolArray.emplaceBack(_.x,_.y,F,this.glyphOffsetArray.length-F,$,x,b,_.segment,s?s[0]:0,s?s[1]:0,o[0],o[1],f,0,!1,0,w)}_addCollisionDebugVertex(e,r,s,o,c,d){return r.emplaceBack(0,0),e.emplaceBack(s.x,s.y,o,c,Math.round(d.x),Math.round(d.y))}addCollisionDebugVertices(e,r,s,o,c,d,f){const _=c.segments.prepareSegment(4,c.layoutVertexArray,c.indexArray),x=_.vertexLength,b=c.layoutVertexArray,w=c.collisionVertexArray,I=f.anchorX,C=f.anchorY;this._addCollisionDebugVertex(b,w,d,I,C,new me(e,r)),this._addCollisionDebugVertex(b,w,d,I,C,new me(s,r)),this._addCollisionDebugVertex(b,w,d,I,C,new me(s,o)),this._addCollisionDebugVertex(b,w,d,I,C,new me(e,o)),_.vertexLength+=4;const k=c.indexArray;k.emplaceBack(x,x+1),k.emplaceBack(x+1,x+2),k.emplaceBack(x+2,x+3),k.emplaceBack(x+3,x),_.primitiveLength+=4}addDebugCollisionBoxes(e,r,s,o){for(let c=e;c<r;c++){const d=this.collisionBoxArray.get(c);this.addCollisionDebugVertices(d.x1,d.y1,d.x2,d.y2,o?this.textCollisionBox:this.iconCollisionBox,d.anchorPoint,s)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Lc(Zt,Lh.members,xt),this.iconCollisionBox=new Lc(Zt,Lh.members,xt);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,s,o,c,d,f,_,x){const b={};for(let w=r;w<s;w++){const I=e.get(w);b.textBox={x1:I.x1,y1:I.y1,x2:I.x2,y2:I.y2,anchorPointX:I.anchorPointX,anchorPointY:I.anchorPointY},b.textFeatureIndex=I.featureIndex;break}for(let w=o;w<c;w++){const I=e.get(w);b.verticalTextBox={x1:I.x1,y1:I.y1,x2:I.x2,y2:I.y2,anchorPointX:I.anchorPointX,anchorPointY:I.anchorPointY},b.verticalTextFeatureIndex=I.featureIndex;break}for(let w=d;w<f;w++){const I=e.get(w);b.iconBox={x1:I.x1,y1:I.y1,x2:I.x2,y2:I.y2,anchorPointX:I.anchorPointX,anchorPointY:I.anchorPointY},b.iconFeatureIndex=I.featureIndex;break}for(let w=_;w<x;w++){const I=e.get(w);b.verticalIconBox={x1:I.x1,y1:I.y1,x2:I.x2,y2:I.y2,anchorPointX:I.anchorPointX,anchorPointY:I.anchorPointY},b.verticalIconFeatureIndex=I.featureIndex;break}return b}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let r=0;r<this.symbolInstances.length;r++){const s=this.symbolInstances.get(r);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,s.textBoxStartIndex,s.textBoxEndIndex,s.verticalTextBoxStartIndex,s.verticalTextBoxEndIndex,s.iconBoxStartIndex,s.iconBoxEndIndex,s.verticalIconBoxStartIndex,s.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,r){const s=e.placedSymbolArray.get(r),o=s.vertexStartIndex+4*s.numGlyphs;for(let c=s.vertexStartIndex;c<o;c+=4)e.indexArray.emplaceBack(c,c+1,c+2),e.indexArray.emplaceBack(c+1,c+2,c+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const r=Math.sin(e),s=Math.cos(e),o=[],c=[],d=[];for(let f=0;f<this.symbolInstances.length;++f){d.push(f);const _=this.symbolInstances.get(f);o.push(0|Math.round(r*_.anchorX+s*_.anchorY)),c.push(_.featureIndex)}return d.sort((f,_)=>o[f]-o[_]||c[_]-c[f]),d}addToSortKeyRanges(e,r){const s=this.sortKeyRanges[this.sortKeyRanges.length-1];s&&s.sortKey===r?s.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 s=this.symbolInstances.get(r);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach((o,c,d)=>{o>=0&&d.indexOf(o)===c&&this.addIndicesForPlacedSymbol(this.text,o)}),s.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,s.verticalPlacedTextSymbolIndex),s.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.placedIconSymbolIndex),s.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Yh,Qh;Pe("SymbolBucket",ha,{omit:["layers","collisionBoxArray","features","compareText"]}),ha.MAX_GLYPHS=65535,ha.addDynamicAttributes=Ec;var Rc={get paint(){return Qh=Qh||new a({"icon-opacity":new Be(re.paint_symbol["icon-opacity"]),"icon-color":new Be(re.paint_symbol["icon-color"]),"icon-halo-color":new Be(re.paint_symbol["icon-halo-color"]),"icon-halo-width":new Be(re.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Be(re.paint_symbol["icon-halo-blur"]),"icon-translate":new ze(re.paint_symbol["icon-translate"]),"icon-translate-anchor":new ze(re.paint_symbol["icon-translate-anchor"]),"text-opacity":new Be(re.paint_symbol["text-opacity"]),"text-color":new Be(re.paint_symbol["text-color"],{runtimeType:si,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new Be(re.paint_symbol["text-halo-color"]),"text-halo-width":new Be(re.paint_symbol["text-halo-width"]),"text-halo-blur":new Be(re.paint_symbol["text-halo-blur"]),"text-translate":new ze(re.paint_symbol["text-translate"]),"text-translate-anchor":new ze(re.paint_symbol["text-translate-anchor"])})},get layout(){return Yh=Yh||new a({"symbol-placement":new ze(re.layout_symbol["symbol-placement"]),"symbol-spacing":new ze(re.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new ze(re.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Be(re.layout_symbol["symbol-sort-key"]),"symbol-z-order":new ze(re.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new ze(re.layout_symbol["icon-allow-overlap"]),"icon-overlap":new ze(re.layout_symbol["icon-overlap"]),"icon-ignore-placement":new ze(re.layout_symbol["icon-ignore-placement"]),"icon-optional":new ze(re.layout_symbol["icon-optional"]),"icon-rotation-alignment":new ze(re.layout_symbol["icon-rotation-alignment"]),"icon-size":new Be(re.layout_symbol["icon-size"]),"icon-text-fit":new ze(re.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ze(re.layout_symbol["icon-text-fit-padding"]),"icon-image":new Be(re.layout_symbol["icon-image"]),"icon-rotate":new Be(re.layout_symbol["icon-rotate"]),"icon-padding":new Be(re.layout_symbol["icon-padding"]),"icon-keep-upright":new ze(re.layout_symbol["icon-keep-upright"]),"icon-offset":new Be(re.layout_symbol["icon-offset"]),"icon-anchor":new Be(re.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new ze(re.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new ze(re.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new ze(re.layout_symbol["text-rotation-alignment"]),"text-field":new Be(re.layout_symbol["text-field"]),"text-font":new Be(re.layout_symbol["text-font"]),"text-size":new Be(re.layout_symbol["text-size"]),"text-max-width":new Be(re.layout_symbol["text-max-width"]),"text-line-height":new ze(re.layout_symbol["text-line-height"]),"text-letter-spacing":new Be(re.layout_symbol["text-letter-spacing"]),"text-justify":new Be(re.layout_symbol["text-justify"]),"text-radial-offset":new Be(re.layout_symbol["text-radial-offset"]),"text-variable-anchor":new ze(re.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Be(re.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Be(re.layout_symbol["text-anchor"]),"text-max-angle":new ze(re.layout_symbol["text-max-angle"]),"text-writing-mode":new ze(re.layout_symbol["text-writing-mode"]),"text-rotate":new Be(re.layout_symbol["text-rotate"]),"text-padding":new ze(re.layout_symbol["text-padding"]),"text-keep-upright":new ze(re.layout_symbol["text-keep-upright"]),"text-transform":new Be(re.layout_symbol["text-transform"]),"text-offset":new Be(re.layout_symbol["text-offset"]),"text-allow-overlap":new ze(re.layout_symbol["text-allow-overlap"]),"text-overlap":new ze(re.layout_symbol["text-overlap"]),"text-ignore-placement":new ze(re.layout_symbol["text-ignore-placement"]),"text-optional":new ze(re.layout_symbol["text-optional"])})}};class eu{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:Ir,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}}Pe("FormatSectionOverride",eu,{omit:["defaultValue"]});class El extends u{constructor(e){super(e,Rc)}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 s=this.layout.get("text-writing-mode");if(s){const o=[];for(const c of s)o.indexOf(c)<0&&o.push(c);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,r,s,o){const c=this.layout.get(e).evaluate(r,{},s,o),d=this._unevaluatedLayout._values[e];return d.isDataDriven()||is(d.value)||!c?c:function(f,_){return _.replace(/{([^{}]+)}/g,(x,b)=>f&&b in f?String(f[b]):"")}(r.properties,c)}createBucket(e){return new ha(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Rc.paint.overridableProperties){if(!El.hasPaintOverride(this.layout,e))continue;const r=this.paint.get(e),s=new eu(r),o=new $s(s,r.property.specification);let c=null;c=r.value.kind==="constant"||r.value.kind==="source"?new Oa("source",o):new Va("composite",o,r.value.zoomStops),this.paint._values[e]=new ir(r.property,c,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,s){return!(!this.layout||r.isDataDriven()||s.isDataDriven())&&El.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){const s=e.get("text-field"),o=Rc.paint.properties[r];let c=!1;const d=f=>{for(const _ of f)if(o.overrides&&o.overrides.hasOverride(_))return void(c=!0)};if(s.value.kind==="constant"&&s.value.value instanceof mi)d(s.value.value.sections);else if(s.value.kind==="source"){const f=x=>{c||(x instanceof Zr&&Ct(x.value)===hr?d(x.value.sections):x instanceof ks?d(x.sections):x.eachChild(f))},_=s.value;_._styleExpression&&f(_._styleExpression.expression)}return c}}let tu;var np={get paint(){return tu=tu||new a({"background-color":new ze(re.paint_background["background-color"]),"background-pattern":new t(re.paint_background["background-pattern"]),"background-opacity":new ze(re.paint_background["background-opacity"])})}};class sp extends u{constructor(e){super(e,np)}}let iu;var ap={get paint(){return iu=iu||new a({"raster-opacity":new ze(re.paint_raster["raster-opacity"]),"raster-hue-rotate":new ze(re.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new ze(re.paint_raster["raster-brightness-min"]),"raster-brightness-max":new ze(re.paint_raster["raster-brightness-max"]),"raster-saturation":new ze(re.paint_raster["raster-saturation"]),"raster-contrast":new ze(re.paint_raster["raster-contrast"]),"raster-resampling":new ze(re.paint_raster["raster-resampling"]),"raster-fade-duration":new ze(re.paint_raster["raster-fade-duration"])})}};class op extends u{constructor(e){super(e,ap)}}class lp extends u{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")}}class cp{constructor(e){this._methodToThrottle=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._methodToThrottle()},0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Bc=63710088e-1;class En{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 En(Zi(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,s=this.lat*r,o=e.lat*r,c=Math.sin(s)*Math.sin(o)+Math.cos(s)*Math.cos(o)*Math.cos((e.lng-this.lng)*r);return Bc*Math.acos(Math.min(c,1))}static convert(e){if(e instanceof En)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new En(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new En(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const ru=2*Math.PI*Bc;function nu(i){return ru*Math.cos(i*Math.PI/180)}function su(i){return(180+i)/360}function au(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function ou(i,e){return i/nu(e)}function Fc(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class Dl{constructor(e,r,s=0){this.x=+e,this.y=+r,this.z=+s}static fromLngLat(e,r=0){const s=En.convert(e);return new Dl(su(s.lng),au(s.lat),ou(r,s.lat))}toLngLat(){return new En(360*this.x-180,Fc(this.y))}toAltitude(){return this.z*nu(Fc(this.y))}meterInMercatorCoordinateUnits(){return 1/ru*(e=Fc(this.y),1/Math.cos(e*Math.PI/180));var e}}function lu(i,e,r){var s=2*Math.PI*6378137/256/Math.pow(2,r);return[i*s-2*Math.PI*6378137/2,e*s-2*Math.PI*6378137/2]}class Oc{constructor(e,r,s){if(e<0||e>25||s<0||s>=Math.pow(2,e)||r<0||r>=Math.pow(2,e))throw new Error(`x=${r}, y=${s}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=r,this.y=s,this.key=Co(0,e,e,r,s)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,r,s){const o=(d=this.y,f=this.z,_=lu(256*(c=this.x),256*(d=Math.pow(2,f)-d-1),f),x=lu(256*(c+1),256*(d+1),f),_[0]+","+_[1]+","+x[0]+","+x[1]);var c,d,f,_,x;const b=function(w,I,C){let k,D="";for(let F=w;F>0;F--)k=1<<F-1,D+=(I&k?1:0)+(C&k?2:0);return D}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(s==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,r>1?"@2x":"").replace(/{quadkey}/g,b).replace(/{bbox-epsg-3857}/g,o)}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 me((e.x*r-this.x)*Mt,(e.y*r-this.y)*Mt)}toString(){return`${this.z}/${this.x}/${this.y}`}}class cu{constructor(e,r){this.wrap=e,this.canonical=r,this.key=Co(e,r.z,r.z,r.x,r.y)}}class Vi{constructor(e,r,s,o,c){if(e<s)throw new Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${s}`);this.overscaledZ=e,this.wrap=r,this.canonical=new Oc(s,+o,+c),this.key=Co(r,e,s,o,c)}clone(){return new Vi(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 Vi(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Vi(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 s=this.canonical.z-e;return e>this.canonical.z?Co(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y):Co(this.wrap*+r,e,e,this.canonical.x>>s,this.canonical.y>>s)}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 Vi(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,s=2*this.canonical.x,o=2*this.canonical.y;return[new Vi(r,this.wrap,r,s,o),new Vi(r,this.wrap,r,s+1,o),new Vi(r,this.wrap,r,s,o+1),new Vi(r,this.wrap,r,s+1,o+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new Vi(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Vi(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 cu(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new Dl(e.x-this.wrap,e.y))}}function Co(i,e,r,s,o){(i*=2)<0&&(i=-1*i-1);const c=1<<r;return(c*c*i+c*o+s).toString(36)+r.toString(36)+e.toString(36)}Pe("CanonicalTileID",Oc),Pe("OverscaledTileID",Vi,{omit:["posMatrix"]});class hu{constructor(e,r,s,o=1,c=1,d=1,f=0){if(this.uid=e,r.height!==r.width)throw new RangeError("DEM tiles must be square");if(s&&!["mapbox","terrarium","custom"].includes(s))return void Ot(`"${s}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=r.height;const _=this.dim=r.height-2;switch(this.data=new Uint32Array(r.data.buffer),s){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=o,this.greenFactor=c,this.blueFactor=d,this.baseShift=f;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let x=0;x<_;x++)this.data[this._idx(-1,x)]=this.data[this._idx(0,x)],this.data[this._idx(_,x)]=this.data[this._idx(_-1,x)],this.data[this._idx(x,-1)]=this.data[this._idx(x,0)],this.data[this._idx(x,_)]=this.data[this._idx(x,_-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(_,-1)]=this.data[this._idx(_-1,0)],this.data[this._idx(-1,_)]=this.data[this._idx(0,_-1)],this.data[this._idx(_,_)]=this.data[this._idx(_-1,_-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let x=0;x<_;x++)for(let b=0;b<_;b++){const w=this.get(x,b);w>this.max&&(this.max=w),w<this.min&&(this.min=w)}}get(e,r){const s=new Uint8Array(this.data.buffer),o=4*this._idx(e,r);return this.unpack(s[o],s[o+1],s[o+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_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)}unpack(e,r,s){return e*this.redFactor+r*this.greenFactor+s*this.blueFactor-this.baseShift}getPixels(){return new Oi({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,r,s){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let o=r*this.dim,c=r*this.dim+this.dim,d=s*this.dim,f=s*this.dim+this.dim;switch(r){case-1:o=c-1;break;case 1:c=o+1}switch(s){case-1:d=f-1;break;case 1:f=d+1}const _=-r*this.dim,x=-s*this.dim;for(let b=d;b<f;b++)for(let w=o;w<c;w++)this.data[this._idx(w,b)]=e.data[this._idx(w+_,b+x)]}}Pe("DEMData",hu);class uu{constructor(e){this._stringToNumber={},this._numberToString=[];for(let r=0;r<e.length;r++){const s=e[r];this._stringToNumber[s]=r,this._numberToString[r]=s}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class du{constructor(e,r,s,o,c){this.type="Feature",this._vectorTileFeature=e,e._z=r,e._x=s,e._y=o,this.properties=e.properties,this.id=c}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 pu{constructor(e,r){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new bn(Mt,16,0),this.grid3D=new bn(Mt,16,0),this.featureIndexArray=new Bi,this.promoteId=r}insert(e,r,s,o,c,d){const f=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(s,o,c);const _=d?this.grid3D:this.grid;for(let x=0;x<r.length;x++){const b=r[x],w=[1/0,1/0,-1/0,-1/0];for(let I=0;I<b.length;I++){const C=b[I];w[0]=Math.min(w[0],C.x),w[1]=Math.min(w[1],C.y),w[2]=Math.max(w[2],C.x),w[3]=Math.max(w[3],C.y)}w[0]<Mt&&w[1]<Mt&&w[2]>=0&&w[3]>=0&&_.insert(f,w[0],w[1],w[2],w[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Mn.VectorTile(new Pc(this.rawTileData)).layers,this.sourceLayerCoder=new uu(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(e,r,s,o){this.loadVTLayers();const c=e.params||{},d=Mt/e.tileSize/e.scale,f=ei(c.filter),_=e.queryGeometry,x=e.queryPadding*d,b=mu(_),w=this.grid.query(b.minX-x,b.minY-x,b.maxX+x,b.maxY+x),I=mu(e.cameraQueryGeometry),C=this.grid3D.query(I.minX-x,I.minY-x,I.maxX+x,I.maxY+x,(F,$,J,Z)=>function(K,ie,ce,xe,Le){for(const ye of K)if(ie<=ye.x&&ce<=ye.y&&xe>=ye.x&&Le>=ye.y)return!0;const be=[new me(ie,ce),new me(ie,Le),new me(xe,Le),new me(xe,ce)];if(K.length>2){for(const ye of be)if(ra(K,ye))return!0}for(let ye=0;ye<K.length-1;ye++)if($u(K[ye],K[ye+1],be))return!0;return!1}(e.cameraQueryGeometry,F-x,$-x,J+x,Z+x));for(const F of C)w.push(F);w.sort(hp);const k={};let D;for(let F=0;F<w.length;F++){const $=w[F];if($===D)continue;D=$;const J=this.featureIndexArray.get($);let Z=null;this.loadMatchingFeature(k,J.bucketIndex,J.sourceLayerIndex,J.featureIndex,f,c.layers,c.availableImages,r,s,o,(K,ie,ce)=>(Z||(Z=ps(K)),ie.queryIntersectsFeature(_,K,ce,Z,this.z,e.transform,d,e.pixelPosMatrix)))}return k}loadMatchingFeature(e,r,s,o,c,d,f,_,x,b,w){const I=this.bucketLayerIDs[r];if(d&&!function(F,$){for(let J=0;J<F.length;J++)if($.indexOf(F[J])>=0)return!0;return!1}(d,I))return;const C=this.sourceLayerCoder.decode(s),k=this.vtLayers[C].feature(o);if(c.needGeometry){const F=fs(k,!0);if(!c.filter(new ct(this.tileID.overscaledZ),F,this.tileID.canonical))return}else if(!c.filter(new ct(this.tileID.overscaledZ),k))return;const D=this.getId(k,C);for(let F=0;F<I.length;F++){const $=I[F];if(d&&d.indexOf($)<0)continue;const J=_[$];if(!J)continue;let Z={};D&&b&&(Z=b.getState(J.sourceLayer||"_geojsonTileLayer",D));const K=Si({},x[$]);K.paint=fu(K.paint,J.paint,k,Z,f),K.layout=fu(K.layout,J.layout,k,Z,f);const ie=!w||w(k,J,Z);if(!ie)continue;const ce=new du(k,this.z,this.x,this.y,D);ce.layer=K;let xe=e[$];xe===void 0&&(xe=e[$]=[]),xe.push({featureIndex:o,feature:ce,intersectionZ:ie})}}lookupSymbolFeatures(e,r,s,o,c,d,f,_){const x={};this.loadVTLayers();const b=ei(c);for(const w of e)this.loadMatchingFeature(x,s,o,w,b,d,f,_,r);return x}hasLayer(e){for(const r of this.bucketLayerIDs)for(const s of r)if(e===s)return!0;return!1}getId(e,r){let s=e.id;return this.promoteId&&(s=e.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[r]],typeof s=="boolean"&&(s=Number(s))),s}}function fu(i,e,r,s,o){return Gi(i,(c,d)=>{const f=e instanceof Ks?e.get(d):null;return f&&f.evaluate?f.evaluate(r,s,o):f})}function mu(i){let e=1/0,r=1/0,s=-1/0,o=-1/0;for(const c of i)e=Math.min(e,c.x),r=Math.min(r,c.y),s=Math.max(s,c.x),o=Math.max(o,c.y);return{minX:e,minY:r,maxX:s,maxY:o}}function hp(i,e){return e-i}function _u(i,e,r,s,o){const c=[];for(let d=0;d<i.length;d++){const f=i[d];let _;for(let x=0;x<f.length-1;x++){let b=f[x],w=f[x+1];b.x<e&&w.x<e||(b.x<e?b=new me(e,b.y+(e-b.x)/(w.x-b.x)*(w.y-b.y))._round():w.x<e&&(w=new me(e,b.y+(e-b.x)/(w.x-b.x)*(w.y-b.y))._round()),b.y<r&&w.y<r||(b.y<r?b=new me(b.x+(r-b.y)/(w.y-b.y)*(w.x-b.x),r)._round():w.y<r&&(w=new me(b.x+(r-b.y)/(w.y-b.y)*(w.x-b.x),r)._round()),b.x>=s&&w.x>=s||(b.x>=s?b=new me(s,b.y+(s-b.x)/(w.x-b.x)*(w.y-b.y))._round():w.x>=s&&(w=new me(s,b.y+(s-b.x)/(w.x-b.x)*(w.y-b.y))._round()),b.y>=o&&w.y>=o||(b.y>=o?b=new me(b.x+(o-b.y)/(w.y-b.y)*(w.x-b.x),o)._round():w.y>=o&&(w=new me(b.x+(o-b.y)/(w.y-b.y)*(w.x-b.x),o)._round()),_&&b.equals(_[_.length-1])||(_=[b],c.push(_)),_.push(w)))))}}return c}Pe("FeatureIndex",pu,{omit:["rawTileData","sourceLayerCoder"]});class Dn extends me{constructor(e,r,s,o){super(e,r),this.angle=s,o!==void 0&&(this.segment=o)}clone(){return new Dn(this.x,this.y,this.angle,this.segment)}}function gu(i,e,r,s,o){if(e.segment===void 0||r===0)return!0;let c=e,d=e.segment+1,f=0;for(;f>-r/2;){if(d--,d<0)return!1;f-=i[d].dist(c),c=i[d]}f+=i[d].dist(i[d+1]),d++;const _=[];let x=0;for(;f<r/2;){const b=i[d],w=i[d+1];if(!w)return!1;let I=i[d-1].angleTo(b)-b.angleTo(w);for(I=Math.abs((I+3*Math.PI)%(2*Math.PI)-Math.PI),_.push({distance:f,angleDelta:I}),x+=I;f-_[0].distance>s;)x-=_.shift().angleDelta;if(x>o)return!1;d++,f+=b.dist(w)}return!0}function yu(i){let e=0;for(let r=0;r<i.length-1;r++)e+=i[r].dist(i[r+1]);return e}function xu(i,e,r){return i?.6*e*r:0}function vu(i,e){return Math.max(i?i.right-i.left:0,e?e.right-e.left:0)}function up(i,e,r,s,o,c){const d=xu(r,o,c),f=vu(r,s)*c;let _=0;const x=yu(i)/2;for(let b=0;b<i.length-1;b++){const w=i[b],I=i[b+1],C=w.dist(I);if(_+C>x){const k=(x-_)/C,D=yi.number(w.x,I.x,k),F=yi.number(w.y,I.y,k),$=new Dn(D,F,I.angleTo(w),b);return $._round(),!d||gu(i,$,f,d,e)?$:void 0}_+=C}}function dp(i,e,r,s,o,c,d,f,_){const x=xu(s,c,d),b=vu(s,o),w=b*d,I=i[0].x===0||i[0].x===_||i[0].y===0||i[0].y===_;return e-w<e/4&&(e=w+e/4),bu(i,I?e/2*f%e:(b/2+2*c)*d*f%e,e,x,r,w,I,!1,_)}function bu(i,e,r,s,o,c,d,f,_){const x=c/2,b=yu(i);let w=0,I=e-r,C=[];for(let k=0;k<i.length-1;k++){const D=i[k],F=i[k+1],$=D.dist(F),J=F.angleTo(D);for(;I+r<w+$;){I+=r;const Z=(I-w)/$,K=yi.number(D.x,F.x,Z),ie=yi.number(D.y,F.y,Z);if(K>=0&&K<_&&ie>=0&&ie<_&&I-x>=0&&I+x<=b){const ce=new Dn(K,ie,J,k);ce._round(),s&&!gu(i,ce,c,s,o)||C.push(ce)}}w+=$}return f||C.length||d||(C=bu(i,w/2,r,s,o,c,d,!0,_)),C}Pe("Anchor",Dn);const ua=bi;function wu(i,e,r,s){const o=[],c=i.image,d=c.pixelRatio,f=c.paddedRect.w-2*ua,_=c.paddedRect.h-2*ua;let x={x1:i.left,y1:i.top,x2:i.right,y2:i.bottom};const b=c.stretchX||[[0,f]],w=c.stretchY||[[0,_]],I=(ae,Ee)=>ae+Ee[1]-Ee[0],C=b.reduce(I,0),k=w.reduce(I,0),D=f-C,F=_-k;let $=0,J=C,Z=0,K=k,ie=0,ce=D,xe=0,Le=F;if(c.content&&s){const ae=c.content,Ee=ae[2]-ae[0],Me=ae[3]-ae[1];(c.textFitWidth||c.textFitHeight)&&(x=Hh(i)),$=Ll(b,0,ae[0]),Z=Ll(w,0,ae[1]),J=Ll(b,ae[0],ae[2]),K=Ll(w,ae[1],ae[3]),ie=ae[0]-$,xe=ae[1]-Z,ce=Ee-J,Le=Me-K}const be=x.x1,ye=x.y1,ke=x.x2-be,Ae=x.y2-ye,Ie=(ae,Ee,Me,Ve)=>{const at=Rl(ae.stretch-$,J,ke,be),st=Bl(ae.fixed-ie,ce,ae.stretch,C),Lt=Rl(Ee.stretch-Z,K,Ae,ye),rr=Bl(Ee.fixed-xe,Le,Ee.stretch,k),Wt=Rl(Me.stretch-$,J,ke,be),Tt=Bl(Me.fixed-ie,ce,Me.stretch,C),ci=Rl(Ve.stretch-Z,K,Ae,ye),hi=Bl(Ve.fixed-xe,Le,Ve.stretch,k),ui=new me(at,Lt),St=new me(Wt,Lt),Rt=new me(Wt,ci),ii=new me(at,ci),Ht=new me(st/d,rr/d),di=new me(Tt/d,hi/d),Kt=e*Math.PI/180;if(Kt){const Ye=Math.sin(Kt),ht=Math.cos(Kt),_t=[ht,-Ye,Ye,ht];ui._matMult(_t),St._matMult(_t),ii._matMult(_t),Rt._matMult(_t)}const Ni=ae.stretch+ae.fixed,wi=Ee.stretch+Ee.fixed;return{tl:ui,tr:St,bl:ii,br:Rt,tex:{x:c.paddedRect.x+ua+Ni,y:c.paddedRect.y+ua+wi,w:Me.stretch+Me.fixed-Ni,h:Ve.stretch+Ve.fixed-wi},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Ht,pixelOffsetBR:di,minFontScaleX:ce/d/ke,minFontScaleY:Le/d/Ae,isSDF:r}};if(s&&(c.stretchX||c.stretchY)){const ae=Tu(b,D,C),Ee=Tu(w,F,k);for(let Me=0;Me<ae.length-1;Me++){const Ve=ae[Me],at=ae[Me+1];for(let st=0;st<Ee.length-1;st++)o.push(Ie(Ve,Ee[st],at,Ee[st+1]))}}else o.push(Ie({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:f+1},{fixed:0,stretch:_+1}));return o}function Ll(i,e,r){let s=0;for(const o of i)s+=Math.max(e,Math.min(r,o[1]))-Math.max(e,Math.min(r,o[0]));return s}function Tu(i,e,r){const s=[{fixed:-ua,stretch:0}];for(const[o,c]of i){const d=s[s.length-1];s.push({fixed:o-d.stretch,stretch:d.stretch}),s.push({fixed:o-d.stretch,stretch:d.stretch+(c-o)})}return s.push({fixed:e+ua,stretch:r}),s}function Rl(i,e,r,s){return i/e*r+s}function Bl(i,e,r,s){return i-e*r/s}class Fl{constructor(e,r,s,o,c,d,f,_,x,b){var w;if(this.boxStartIndex=e.length,x){let I=d.top,C=d.bottom;const k=d.collisionPadding;k&&(I-=k[1],C+=k[3]);let D=C-I;D>0&&(D=Math.max(10,D),this.circleDiameter=D)}else{const I=!((w=d.image)===null||w===void 0)&&w.content&&(d.image.textFitWidth||d.image.textFitHeight)?Hh(d):{x1:d.left,y1:d.top,x2:d.right,y2:d.bottom};I.y1=I.y1*f-_[0],I.y2=I.y2*f+_[2],I.x1=I.x1*f-_[3],I.x2=I.x2*f+_[1];const C=d.collisionPadding;if(C&&(I.x1-=C[0]*f,I.y1-=C[1]*f,I.x2+=C[2]*f,I.y2+=C[3]*f),b){const k=new me(I.x1,I.y1),D=new me(I.x2,I.y1),F=new me(I.x1,I.y2),$=new me(I.x2,I.y2),J=b*Math.PI/180;k._rotate(J),D._rotate(J),F._rotate(J),$._rotate(J),I.x1=Math.min(k.x,D.x,F.x,$.x),I.x2=Math.max(k.x,D.x,F.x,$.x),I.y1=Math.min(k.y,D.y,F.y,$.y),I.y2=Math.max(k.y,D.y,F.y,$.y)}e.emplaceBack(r.x,r.y,I.x1,I.y1,I.x2,I.y2,s,o,c)}this.boxEndIndex=e.length}}class pp{constructor(e=[],r=fp){if(this.data=e,this.length=this.data.length,this.compare=r,this.length>0)for(let s=(this.length>>1)-1;s>=0;s--)this._down(s)}push(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:s}=this,o=r[e];for(;e>0;){const c=e-1>>1,d=r[c];if(s(o,d)>=0)break;r[e]=d,e=c}r[e]=o}_down(e){const{data:r,compare:s}=this,o=this.length>>1,c=r[e];for(;e<o;){let d=1+(e<<1),f=r[d];const _=d+1;if(_<this.length&&s(r[_],f)<0&&(d=_,f=r[_]),s(f,c)>=0)break;r[e]=f,e=d}r[e]=c}}function fp(i,e){return i<e?-1:i>e?1:0}function mp(i,e=1,r=!1){let s=1/0,o=1/0,c=-1/0,d=-1/0;const f=i[0];for(let C=0;C<f.length;C++){const k=f[C];(!C||k.x<s)&&(s=k.x),(!C||k.y<o)&&(o=k.y),(!C||k.x>c)&&(c=k.x),(!C||k.y>d)&&(d=k.y)}const _=Math.min(c-s,d-o);let x=_/2;const b=new pp([],_p);if(_===0)return new me(s,o);for(let C=s;C<c;C+=_)for(let k=o;k<d;k+=_)b.push(new da(C+x,k+x,x,i));let w=function(C){let k=0,D=0,F=0;const $=C[0];for(let J=0,Z=$.length,K=Z-1;J<Z;K=J++){const ie=$[J],ce=$[K],xe=ie.x*ce.y-ce.x*ie.y;D+=(ie.x+ce.x)*xe,F+=(ie.y+ce.y)*xe,k+=3*xe}return new da(D/k,F/k,0,C)}(i),I=b.length;for(;b.length;){const C=b.pop();(C.d>w.d||!w.d)&&(w=C,r&&console.log("found best %d after %d probes",Math.round(1e4*C.d)/1e4,I)),C.max-w.d<=e||(x=C.h/2,b.push(new da(C.p.x-x,C.p.y-x,x,i)),b.push(new da(C.p.x+x,C.p.y-x,x,i)),b.push(new da(C.p.x-x,C.p.y+x,x,i)),b.push(new da(C.p.x+x,C.p.y+x,x,i)),I+=4)}return r&&(console.log(`num probes: ${I}`),console.log(`best distance: ${w.d}`)),w.p}function _p(i,e){return e.max-i.max}function da(i,e,r,s){this.p=new me(i,e),this.h=r,this.d=function(o,c){let d=!1,f=1/0;for(let _=0;_<c.length;_++){const x=c[_];for(let b=0,w=x.length,I=w-1;b<w;I=b++){const C=x[b],k=x[I];C.y>o.y!=k.y>o.y&&o.x<(k.x-C.x)*(o.y-C.y)/(k.y-C.y)+C.x&&(d=!d),f=Math.min(f,ah(o,C,k))}}return(d?1:-1)*Math.sqrt(f)}(this.p,s),this.max=this.d+this.h*Math.SQRT2}var Xt;L.ar=void 0,(Xt=L.ar||(L.ar={}))[Xt.center=1]="center",Xt[Xt.left=2]="left",Xt[Xt.right=3]="right",Xt[Xt.top=4]="top",Xt[Xt.bottom=5]="bottom",Xt[Xt["top-left"]=6]="top-left",Xt[Xt["top-right"]=7]="top-right",Xt[Xt["bottom-left"]=8]="bottom-left",Xt[Xt["bottom-right"]=9]="bottom-right";const Ln=7,Vc=Number.POSITIVE_INFINITY;function Su(i,e){return e[1]!==Vc?function(r,s,o){let c=0,d=0;switch(s=Math.abs(s),o=Math.abs(o),r){case"top-right":case"top-left":case"top":d=o-Ln;break;case"bottom-right":case"bottom-left":case"bottom":d=-o+Ln}switch(r){case"top-right":case"bottom-right":case"right":c=-s;break;case"top-left":case"bottom-left":case"left":c=s}return[c,d]}(i,e[0],e[1]):function(r,s){let o=0,c=0;s<0&&(s=0);const d=s/Math.SQRT2;switch(r){case"top-right":case"top-left":c=d-Ln;break;case"bottom-right":case"bottom-left":c=-d+Ln;break;case"bottom":c=-s+Ln;break;case"top":c=s-Ln}switch(r){case"top-right":case"bottom-right":o=-d;break;case"top-left":case"bottom-left":o=d;break;case"left":o=s;break;case"right":o=-s}return[o,c]}(i,e[0])}function Iu(i,e,r){var s;const o=i.layout,c=(s=o.get("text-variable-anchor-offset"))===null||s===void 0?void 0:s.evaluate(e,{},r);if(c){const f=c.values,_=[];for(let x=0;x<f.length;x+=2){const b=_[x]=f[x],w=f[x+1].map(I=>I*Et);b.startsWith("top")?w[1]-=Ln:b.startsWith("bottom")&&(w[1]+=Ln),_[x+1]=w}return new gi(_)}const d=o.get("text-variable-anchor");if(d){let f;f=i._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[o.get("text-radial-offset").evaluate(e,{},r)*Et,Vc]:o.get("text-offset").evaluate(e,{},r).map(x=>x*Et);const _=[];for(const x of d)_.push(x,Su(x,f));return new gi(_)}return null}function Nc(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function gp(i,e,r,s,o,c,d,f,_,x,b){let w=c.textMaxSize.evaluate(e,{});w===void 0&&(w=d);const I=i.layers[0].layout,C=I.get("icon-offset").evaluate(e,{},b),k=Au(r.horizontal),D=d/24,F=i.tilePixelRatio*D,$=i.tilePixelRatio*w/24,J=i.tilePixelRatio*f,Z=i.tilePixelRatio*I.get("symbol-spacing"),K=I.get("text-padding")*i.tilePixelRatio,ie=function(ae,Ee,Me,Ve=1){const at=ae.get("icon-padding").evaluate(Ee,{},Me),st=at&&at.values;return[st[0]*Ve,st[1]*Ve,st[2]*Ve,st[3]*Ve]}(I,e,b,i.tilePixelRatio),ce=I.get("text-max-angle")/180*Math.PI,xe=I.get("text-rotation-alignment")!=="viewport"&&I.get("symbol-placement")!=="point",Le=I.get("icon-rotation-alignment")==="map"&&I.get("symbol-placement")!=="point",be=I.get("symbol-placement"),ye=Z/2,ke=I.get("icon-text-fit");let Ae;s&&ke!=="none"&&(i.allowVerticalPlacement&&r.vertical&&(Ae=Kh(s,r.vertical,ke,I.get("icon-text-fit-padding"),C,D)),k&&(s=Kh(s,k,ke,I.get("icon-text-fit-padding"),C,D)));const Ie=(ae,Ee)=>{Ee.x<0||Ee.x>=Mt||Ee.y<0||Ee.y>=Mt||function(Me,Ve,at,st,Lt,rr,Wt,Tt,ci,hi,ui,St,Rt,ii,Ht,di,Kt,Ni,wi,Ye,ht,_t,Ci,wt,pa){const Br=Me.addToLineVertexArray(Ve,at);let Fr,nr,ji,Ft,an=0,zo=0,zu=0,Eu=0,Wc=-1,Hc=-1;const on={};let Du=ta("");if(Me.allowVerticalPlacement&&st.vertical){const ri=Tt.layout.get("text-rotate").evaluate(ht,{},wt)+90;ji=new Fl(ci,Ve,hi,ui,St,st.vertical,Rt,ii,Ht,ri),Wt&&(Ft=new Fl(ci,Ve,hi,ui,St,Wt,Kt,Ni,Ht,ri))}if(Lt){const ri=Tt.layout.get("icon-rotate").evaluate(ht,{}),Ui=Tt.layout.get("icon-text-fit")!=="none",_s=wu(Lt,ri,Ci,Ui),gr=Wt?wu(Wt,ri,Ci,Ui):void 0;nr=new Fl(ci,Ve,hi,ui,St,Lt,Kt,Ni,!1,ri),an=4*_s.length;const gs=Me.iconSizeData;let Or=null;gs.kind==="source"?(Or=[Rr*Tt.layout.get("icon-size").evaluate(ht,{})],Or[0]>zn&&Ot(`${Me.layerIds[0]}: Value for "icon-size" is >= ${Ao}. Reduce your "icon-size".`)):gs.kind==="composite"&&(Or=[Rr*_t.compositeIconSizes[0].evaluate(ht,{},wt),Rr*_t.compositeIconSizes[1].evaluate(ht,{},wt)],(Or[0]>zn||Or[1]>zn)&&Ot(`${Me.layerIds[0]}: Value for "icon-size" is >= ${Ao}. Reduce your "icon-size".`)),Me.addSymbols(Me.icon,_s,Or,Ye,wi,ht,L.ai.none,Ve,Br.lineStartIndex,Br.lineLength,-1,wt),Wc=Me.icon.placedSymbolArray.length-1,gr&&(zo=4*gr.length,Me.addSymbols(Me.icon,gr,Or,Ye,wi,ht,L.ai.vertical,Ve,Br.lineStartIndex,Br.lineLength,-1,wt),Hc=Me.icon.placedSymbolArray.length-1)}const Lu=Object.keys(st.horizontal);for(const ri of Lu){const Ui=st.horizontal[ri];if(!Fr){Du=ta(Ui.text);const gr=Tt.layout.get("text-rotate").evaluate(ht,{},wt);Fr=new Fl(ci,Ve,hi,ui,St,Ui,Rt,ii,Ht,gr)}const _s=Ui.positionedLines.length===1;if(zu+=Pu(Me,Ve,Ui,rr,Tt,Ht,ht,di,Br,st.vertical?L.ai.horizontal:L.ai.horizontalOnly,_s?Lu:[ri],on,Wc,_t,wt),_s)break}st.vertical&&(Eu+=Pu(Me,Ve,st.vertical,rr,Tt,Ht,ht,di,Br,L.ai.vertical,["vertical"],on,Hc,_t,wt));const vp=Fr?Fr.boxStartIndex:Me.collisionBoxArray.length,bp=Fr?Fr.boxEndIndex:Me.collisionBoxArray.length,wp=ji?ji.boxStartIndex:Me.collisionBoxArray.length,Tp=ji?ji.boxEndIndex:Me.collisionBoxArray.length,Sp=nr?nr.boxStartIndex:Me.collisionBoxArray.length,Ip=nr?nr.boxEndIndex:Me.collisionBoxArray.length,Pp=Ft?Ft.boxStartIndex:Me.collisionBoxArray.length,Ap=Ft?Ft.boxEndIndex:Me.collisionBoxArray.length;let _r=-1;const Vl=(ri,Ui)=>ri&&ri.circleDiameter?Math.max(ri.circleDiameter,Ui):Ui;_r=Vl(Fr,_r),_r=Vl(ji,_r),_r=Vl(nr,_r),_r=Vl(Ft,_r);const Ru=_r>-1?1:0;Ru&&(_r*=pa/Et),Me.glyphOffsetArray.length>=ha.MAX_GLYPHS&&Ot("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),ht.sortKey!==void 0&&Me.addToSortKeyRanges(Me.symbolInstances.length,ht.sortKey);const Cp=Iu(Tt,ht,wt),[Mp,kp]=function(ri,Ui){const _s=ri.length,gr=Ui==null?void 0:Ui.values;if((gr==null?void 0:gr.length)>0)for(let gs=0;gs<gr.length;gs+=2){const Or=gr[gs+1];ri.emplaceBack(L.ar[gr[gs]],Or[0],Or[1])}return[_s,ri.length]}(Me.textAnchorOffsets,Cp);Me.symbolInstances.emplaceBack(Ve.x,Ve.y,on.right>=0?on.right:-1,on.center>=0?on.center:-1,on.left>=0?on.left:-1,on.vertical||-1,Wc,Hc,Du,vp,bp,wp,Tp,Sp,Ip,Pp,Ap,hi,zu,Eu,an,zo,Ru,0,Rt,_r,Mp,kp)}(i,Ee,ae,r,s,o,Ae,i.layers[0],i.collisionBoxArray,e.index,e.sourceLayerIndex,i.index,F,[K,K,K,K],xe,_,J,ie,Le,C,e,c,x,b,d)};if(be==="line")for(const ae of _u(e.geometry,0,0,Mt,Mt)){const Ee=dp(ae,Z,ce,r.vertical||k,s,24,$,i.overscaling,Mt);for(const Me of Ee)k&&yp(i,k.text,ye,Me)||Ie(ae,Me)}else if(be==="line-center"){for(const ae of e.geometry)if(ae.length>1){const Ee=up(ae,ce,r.vertical||k,s,24,$);Ee&&Ie(ae,Ee)}}else if(e.type==="Polygon")for(const ae of Es(e.geometry,0)){const Ee=mp(ae,16);Ie(ae[0],new Dn(Ee.x,Ee.y,0))}else if(e.type==="LineString")for(const ae of e.geometry)Ie(ae,new Dn(ae[0].x,ae[0].y,0));else if(e.type==="Point")for(const ae of e.geometry)for(const Ee of ae)Ie([Ee],new Dn(Ee.x,Ee.y,0))}function Pu(i,e,r,s,o,c,d,f,_,x,b,w,I,C,k){const D=function(J,Z,K,ie,ce,xe,Le,be){const ye=ie.layout.get("text-rotate").evaluate(xe,{})*Math.PI/180,ke=[];for(const Ae of Z.positionedLines)for(const Ie of Ae.positionedGlyphs){if(!Ie.rect)continue;const ae=Ie.rect||{};let Ee=Uh+1,Me=!0,Ve=1,at=0;const st=(ce||be)&&Ie.vertical,Lt=Ie.metrics.advance*Ie.scale/2;if(be&&Z.verticalizable&&(at=Ae.lineOffset/2-(Ie.imageName?-(Et-Ie.metrics.width*Ie.scale)/2:(Ie.scale-1)*Et)),Ie.imageName){const Ye=Le[Ie.imageName];Me=Ye.sdf,Ve=Ye.pixelRatio,Ee=bi/Ve}const rr=ce?[Ie.x+Lt,Ie.y]:[0,0];let Wt=ce?[0,0]:[Ie.x+Lt+K[0],Ie.y+K[1]-at],Tt=[0,0];st&&(Tt=Wt,Wt=[0,0]);const ci=Ie.metrics.isDoubleResolution?2:1,hi=(Ie.metrics.left-Ee)*Ie.scale-Lt+Wt[0],ui=(-Ie.metrics.top-Ee)*Ie.scale+Wt[1],St=hi+ae.w/ci*Ie.scale/Ve,Rt=ui+ae.h/ci*Ie.scale/Ve,ii=new me(hi,ui),Ht=new me(St,ui),di=new me(hi,Rt),Kt=new me(St,Rt);if(st){const Ye=new me(-Lt,Lt-Io),ht=-Math.PI/2,_t=Et/2-Lt,Ci=new me(5-Io-_t,-(Ie.imageName?_t:0)),wt=new me(...Tt);ii._rotateAround(ht,Ye)._add(Ci)._add(wt),Ht._rotateAround(ht,Ye)._add(Ci)._add(wt),di._rotateAround(ht,Ye)._add(Ci)._add(wt),Kt._rotateAround(ht,Ye)._add(Ci)._add(wt)}if(ye){const Ye=Math.sin(ye),ht=Math.cos(ye),_t=[ht,-Ye,Ye,ht];ii._matMult(_t),Ht._matMult(_t),di._matMult(_t),Kt._matMult(_t)}const Ni=new me(0,0),wi=new me(0,0);ke.push({tl:ii,tr:Ht,bl:di,br:Kt,tex:ae,writingMode:Z.writingMode,glyphOffset:rr,sectionIndex:Ie.sectionIndex,isSDF:Me,pixelOffsetTL:Ni,pixelOffsetBR:wi,minFontScaleX:0,minFontScaleY:0})}return ke}(0,r,f,o,c,d,s,i.allowVerticalPlacement),F=i.textSizeData;let $=null;F.kind==="source"?($=[Rr*o.layout.get("text-size").evaluate(d,{})],$[0]>zn&&Ot(`${i.layerIds[0]}: Value for "text-size" is >= ${Ao}. Reduce your "text-size".`)):F.kind==="composite"&&($=[Rr*C.compositeTextSizes[0].evaluate(d,{},k),Rr*C.compositeTextSizes[1].evaluate(d,{},k)],($[0]>zn||$[1]>zn)&&Ot(`${i.layerIds[0]}: Value for "text-size" is >= ${Ao}. Reduce your "text-size".`)),i.addSymbols(i.text,D,$,f,c,d,x,e,_.lineStartIndex,_.lineLength,I,k);for(const J of b)w[J]=i.text.placedSymbolArray.length-1;return 4*D.length}function Au(i){for(const e in i)return i[e];return null}function yp(i,e,r,s){const o=i.compareText;if(e in o){const c=o[e];for(let d=c.length-1;d>=0;d--)if(s.dist(c[d])<r)return!0}else o[e]=[];return o[e].push(s),!1}const Cu=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class jc{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[r,s]=new Uint8Array(e,0,2);if(r!==219)throw new Error("Data does not appear to be in a KDBush format.");const o=s>>4;if(o!==1)throw new Error(`Got v${o} data when expected v1.`);const c=Cu[15&s];if(!c)throw new Error("Unrecognized array type.");const[d]=new Uint16Array(e,2,1),[f]=new Uint32Array(e,4,1);return new jc(f,d,c,e)}constructor(e,r=64,s=Float64Array,o){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=s,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const c=Cu.indexOf(this.ArrayType),d=2*e*this.ArrayType.BYTES_PER_ELEMENT,f=e*this.IndexArrayType.BYTES_PER_ELEMENT,_=(8-f%8)%8;if(c<0)throw new Error(`Unexpected typed array class: ${s}.`);o&&o instanceof ArrayBuffer?(this.data=o,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+f+_,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+d+f+_),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+f+_,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+c]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=e)}add(e,r){const s=this._pos>>1;return this.ids[s]=s,this.coords[this._pos++]=e,this.coords[this._pos++]=r,s}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Uc(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,r,s,o){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:c,coords:d,nodeSize:f}=this,_=[0,c.length-1,0],x=[];for(;_.length;){const b=_.pop()||0,w=_.pop()||0,I=_.pop()||0;if(w-I<=f){for(let F=I;F<=w;F++){const $=d[2*F],J=d[2*F+1];$>=e&&$<=s&&J>=r&&J<=o&&x.push(c[F])}continue}const C=I+w>>1,k=d[2*C],D=d[2*C+1];k>=e&&k<=s&&D>=r&&D<=o&&x.push(c[C]),(b===0?e<=k:r<=D)&&(_.push(I),_.push(C-1),_.push(1-b)),(b===0?s>=k:o>=D)&&(_.push(C+1),_.push(w),_.push(1-b))}return x}within(e,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:o,coords:c,nodeSize:d}=this,f=[0,o.length-1,0],_=[],x=s*s;for(;f.length;){const b=f.pop()||0,w=f.pop()||0,I=f.pop()||0;if(w-I<=d){for(let F=I;F<=w;F++)ku(c[2*F],c[2*F+1],e,r)<=x&&_.push(o[F]);continue}const C=I+w>>1,k=c[2*C],D=c[2*C+1];ku(k,D,e,r)<=x&&_.push(o[C]),(b===0?e-s<=k:r-s<=D)&&(f.push(I),f.push(C-1),f.push(1-b)),(b===0?e+s>=k:r+s>=D)&&(f.push(C+1),f.push(w),f.push(1-b))}return _}}function Uc(i,e,r,s,o,c){if(o-s<=r)return;const d=s+o>>1;Mu(i,e,d,s,o,c),Uc(i,e,r,s,d-1,1-c),Uc(i,e,r,d+1,o,1-c)}function Mu(i,e,r,s,o,c){for(;o>s;){if(o-s>600){const x=o-s+1,b=r-s+1,w=Math.log(x),I=.5*Math.exp(2*w/3),C=.5*Math.sqrt(w*I*(x-I)/x)*(b-x/2<0?-1:1);Mu(i,e,r,Math.max(s,Math.floor(r-b*I/x+C)),Math.min(o,Math.floor(r+(x-b)*I/x+C)),c)}const d=e[2*r+c];let f=s,_=o;for(Mo(i,e,s,r),e[2*o+c]>d&&Mo(i,e,s,o);f<_;){for(Mo(i,e,f,_),f++,_--;e[2*f+c]<d;)f++;for(;e[2*_+c]>d;)_--}e[2*s+c]===d?Mo(i,e,s,_):(_++,Mo(i,e,_,o)),_<=r&&(s=_+1),r<=_&&(o=_-1)}}function Mo(i,e,r,s){$c(i,r,s),$c(e,2*r,2*s),$c(e,2*r+1,2*s+1)}function $c(i,e,r){const s=i[e];i[e]=i[r],i[r]=s}function ku(i,e,r,s){const o=i-r,c=e-s;return o*o+c*c}var qc;L.bf=void 0,(qc=L.bf||(L.bf={})).create="create",qc.load="load",qc.fullLoad="fullLoad";let Ol=null,ko=[];const Zc=1e3/60,Gc="loadTime",Xc="fullLoadTime",xp={mark(i){performance.mark(i)},frame(i){const e=i;Ol!=null&&ko.push(e-Ol),Ol=e},clearMetrics(){Ol=null,ko=[],performance.clearMeasures(Gc),performance.clearMeasures(Xc);for(const i in L.bf)performance.clearMarks(L.bf[i])},getPerformanceMetrics(){performance.measure(Gc,L.bf.create,L.bf.load),performance.measure(Xc,L.bf.create,L.bf.fullLoad);const i=performance.getEntriesByName(Gc)[0].duration,e=performance.getEntriesByName(Xc)[0].duration,r=ko.length,s=1/(ko.reduce((c,d)=>c+d,0)/r/1e3),o=ko.filter(c=>c>Zc).reduce((c,d)=>c+(d-Zc)/Zc,0);return{loadTime:i,fullLoadTime:e,fps:s,percentDroppedFrames:o/(r+o)*100,totalFrames:r}}};L.$=class extends z{},L.A=na,L.B=io,L.C=function(i){if(ln==null){const e=i.navigator?i.navigator.userAgent:null;ln=!!i.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return ln},L.D=ze,L.E=un,L.F=class{constructor(i,e){this.target=i,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new cp(()=>this.process()),this.subscription=function(r,s,o,c){return r.addEventListener(s,o,!1),{unsubscribe:()=>{r.removeEventListener(s,o,!1)}}}(this.target,"message",r=>this.receive(r)),this.globalScope=ar(self)?i:window}registerMessageHandler(i,e){this.messageHandlers[i]=e}sendAsync(i,e){return new Promise((r,s)=>{const o=Math.round(1e18*Math.random()).toString(36).substring(0,10);this.resolveRejects[o]={resolve:r,reject:s},e&&e.signal.addEventListener("abort",()=>{delete this.resolveRejects[o];const f={id:o,type:"<cancel>",origin:location.origin,targetMapId:i.targetMapId,sourceMapId:this.mapId};this.target.postMessage(f)},{once:!0});const c=[],d=Object.assign(Object.assign({},i),{id:o,sourceMapId:this.mapId,origin:location.origin,data:cs(i.data,c)});this.target.postMessage(d,{transfer:c})})}receive(i){const e=i.data,r=e.id;if(!(e.origin!=="file://"&&location.origin!=="file://"&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(e.type==="<cancel>"){delete this.tasks[r];const s=this.abortControllers[r];return delete this.abortControllers[r],void(s&&s.abort())}if(ar(self)||e.mustQueue)return this.tasks[r]=e,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,e)}}process(){if(this.taskQueue.length===0)return;const i=this.taskQueue.shift(),e=this.tasks[i];delete this.tasks[i],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(i,e)}processTask(i,e){return p(this,void 0,void 0,function*(){if(e.type==="<response>"){const o=this.resolveRejects[i];return delete this.resolveRejects[i],o?void(e.error?o.reject(tr(e.error)):o.resolve(tr(e.data))):void 0}if(!this.messageHandlers[e.type])return void this.completeTask(i,new Error(`Could not find a registered handler for ${e.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const r=tr(e.data),s=new AbortController;this.abortControllers[i]=s;try{const o=yield this.messageHandlers[e.type](e.sourceMapId,r,s);this.completeTask(i,null,o)}catch(o){this.completeTask(i,o)}})}completeTask(i,e,r){const s=[];delete this.abortControllers[i];const o={id:i,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:e?cs(e):null,data:cs(r,s)};this.target.postMessage(o,{transfer:s})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},L.G=hn,L.H=function(){var i=new na(16);return na!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},L.I=Cc,L.J=function(i,e,r){var s,o,c,d,f,_,x,b,w,I,C,k,D=r[0],F=r[1],$=r[2];return e===i?(i[12]=e[0]*D+e[4]*F+e[8]*$+e[12],i[13]=e[1]*D+e[5]*F+e[9]*$+e[13],i[14]=e[2]*D+e[6]*F+e[10]*$+e[14],i[15]=e[3]*D+e[7]*F+e[11]*$+e[15]):(o=e[1],c=e[2],d=e[3],f=e[4],_=e[5],x=e[6],b=e[7],w=e[8],I=e[9],C=e[10],k=e[11],i[0]=s=e[0],i[1]=o,i[2]=c,i[3]=d,i[4]=f,i[5]=_,i[6]=x,i[7]=b,i[8]=w,i[9]=I,i[10]=C,i[11]=k,i[12]=s*D+f*F+w*$+e[12],i[13]=o*D+_*F+I*$+e[13],i[14]=c*D+x*F+C*$+e[14],i[15]=d*D+b*F+k*$+e[15]),i},L.K=function(i,e,r){var s=r[0],o=r[1],c=r[2];return i[0]=e[0]*s,i[1]=e[1]*s,i[2]=e[2]*s,i[3]=e[3]*s,i[4]=e[4]*o,i[5]=e[5]*o,i[6]=e[6]*o,i[7]=e[7]*o,i[8]=e[8]*c,i[9]=e[9]*c,i[10]=e[10]*c,i[11]=e[11]*c,i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},L.L=hh,L.M=function(i,e){const r={};for(let s=0;s<e.length;s++){const o=e[s];o in i&&(r[o]=i[o])}return r},L.N=En,L.O=su,L.P=me,L.Q=au,L.R=Oi,L.S=Vi,L.T=Tn,L.U=sr,L.V=Rn,L.W=jr,L.X=Mt,L.Y=v,L.Z=Dl,L._=p,L.a=br,L.a$=function(i,e){var r=i[0],s=i[1],o=i[2],c=i[3],d=i[4],f=i[5],_=i[6],x=i[7],b=i[8],w=i[9],I=i[10],C=i[11],k=i[12],D=i[13],F=i[14],$=i[15],J=e[0],Z=e[1],K=e[2],ie=e[3],ce=e[4],xe=e[5],Le=e[6],be=e[7],ye=e[8],ke=e[9],Ae=e[10],Ie=e[11],ae=e[12],Ee=e[13],Me=e[14],Ve=e[15];return Math.abs(r-J)<=li*Math.max(1,Math.abs(r),Math.abs(J))&&Math.abs(s-Z)<=li*Math.max(1,Math.abs(s),Math.abs(Z))&&Math.abs(o-K)<=li*Math.max(1,Math.abs(o),Math.abs(K))&&Math.abs(c-ie)<=li*Math.max(1,Math.abs(c),Math.abs(ie))&&Math.abs(d-ce)<=li*Math.max(1,Math.abs(d),Math.abs(ce))&&Math.abs(f-xe)<=li*Math.max(1,Math.abs(f),Math.abs(xe))&&Math.abs(_-Le)<=li*Math.max(1,Math.abs(_),Math.abs(Le))&&Math.abs(x-be)<=li*Math.max(1,Math.abs(x),Math.abs(be))&&Math.abs(b-ye)<=li*Math.max(1,Math.abs(b),Math.abs(ye))&&Math.abs(w-ke)<=li*Math.max(1,Math.abs(w),Math.abs(ke))&&Math.abs(I-Ae)<=li*Math.max(1,Math.abs(I),Math.abs(Ae))&&Math.abs(C-Ie)<=li*Math.max(1,Math.abs(C),Math.abs(Ie))&&Math.abs(k-ae)<=li*Math.max(1,Math.abs(k),Math.abs(ae))&&Math.abs(D-Ee)<=li*Math.max(1,Math.abs(D),Math.abs(Ee))&&Math.abs(F-Me)<=li*Math.max(1,Math.abs(F),Math.abs(Me))&&Math.abs($-Ve)<=li*Math.max(1,Math.abs($),Math.abs(Ve))},L.a0=zt,L.a1=Oc,L.a2=pe,L.a3=i=>{const e=window.document.createElement("video");return e.muted=!0,new Promise(r=>{e.onloadstart=()=>{r(e)};for(const s of i){const o=window.document.createElement("source");$r(s)||(e.crossOrigin="Anonymous"),o.src=s,e.appendChild(o)}})},L.a4=function(){return ys++},L.a5=qe,L.a6=ha,L.a7=ei,L.a8=fs,L.a9=ct,L.aA=function(i){i=i.slice();const e=Object.create(null);for(let r=0;r<i.length;r++)e[i[r].id]=i[r];for(let r=0;r<i.length;r++)"ref"in i[r]&&(i[r]=On(i[r],e[i[r].ref]));return i},L.aB=function(i){if(i.type==="custom")return new lp(i);switch(i.type){case"background":return new sp(i);case"circle":return new Gu(i);case"fill":return new cd(i);case"fill-extrusion":return new Sd(i);case"heatmap":return new Wu(i);case"hillshade":return new Ku(i);case"line":return new Ed(i);case"raster":return new op(i);case"symbol":return new El(i)}},L.aC=rt,L.aD=function(i,e){if(!i)return[{command:"setStyle",args:[e]}];let r=[];try{if(!Qe(i.version,e.version))return[{command:"setStyle",args:[e]}];Qe(i.center,e.center)||r.push({command:"setCenter",args:[e.center]}),Qe(i.zoom,e.zoom)||r.push({command:"setZoom",args:[e.zoom]}),Qe(i.bearing,e.bearing)||r.push({command:"setBearing",args:[e.bearing]}),Qe(i.pitch,e.pitch)||r.push({command:"setPitch",args:[e.pitch]}),Qe(i.sprite,e.sprite)||r.push({command:"setSprite",args:[e.sprite]}),Qe(i.glyphs,e.glyphs)||r.push({command:"setGlyphs",args:[e.glyphs]}),Qe(i.transition,e.transition)||r.push({command:"setTransition",args:[e.transition]}),Qe(i.light,e.light)||r.push({command:"setLight",args:[e.light]}),Qe(i.terrain,e.terrain)||r.push({command:"setTerrain",args:[e.terrain]}),Qe(i.sky,e.sky)||r.push({command:"setSky",args:[e.sky]}),Qe(i.projection,e.projection)||r.push({command:"setProjection",args:[e.projection]});const s={},o=[];(function(d,f,_,x){let b;for(b in f=f||{},d=d||{})Object.prototype.hasOwnProperty.call(d,b)&&(Object.prototype.hasOwnProperty.call(f,b)||Sr(b,_,x));for(b in f)Object.prototype.hasOwnProperty.call(f,b)&&(Object.prototype.hasOwnProperty.call(d,b)?Qe(d[b],f[b])||(d[b].type==="geojson"&&f[b].type==="geojson"&&dn(d,f,b)?vt(_,{command:"setGeoJSONSourceData",args:[b,f[b].data]}):cr(b,f,_,x)):Vn(b,f,_))})(i.sources,e.sources,o,s);const c=[];i.layers&&i.layers.forEach(d=>{"source"in d&&s[d.source]?r.push({command:"removeLayer",args:[d.id]}):c.push(d)}),r=r.concat(o),function(d,f,_){f=f||[];const x=(d=d||[]).map(Nn),b=f.map(Nn),w=d.reduce(jn,{}),I=f.reduce(jn,{}),C=x.slice(),k=Object.create(null);let D,F,$,J,Z;for(let K=0,ie=0;K<x.length;K++)D=x[K],Object.prototype.hasOwnProperty.call(I,D)?ie++:(vt(_,{command:"removeLayer",args:[D]}),C.splice(C.indexOf(D,ie),1));for(let K=0,ie=0;K<b.length;K++)D=b[b.length-1-K],C[C.length-1-K]!==D&&(Object.prototype.hasOwnProperty.call(w,D)?(vt(_,{command:"removeLayer",args:[D]}),C.splice(C.lastIndexOf(D,C.length-ie),1)):ie++,J=C[C.length-K],vt(_,{command:"addLayer",args:[I[D],J]}),C.splice(C.length-K,0,D),k[D]=!0);for(let K=0;K<b.length;K++)if(D=b[K],F=w[D],$=I[D],!k[D]&&!Qe(F,$))if(Qe(F.source,$.source)&&Qe(F["source-layer"],$["source-layer"])&&Qe(F.type,$.type)){for(Z in Ii(F.layout,$.layout,_,D,null,"setLayoutProperty"),Ii(F.paint,$.paint,_,D,null,"setPaintProperty"),Qe(F.filter,$.filter)||vt(_,{command:"setFilter",args:[D,$.filter]}),Qe(F.minzoom,$.minzoom)&&Qe(F.maxzoom,$.maxzoom)||vt(_,{command:"setLayerZoomRange",args:[D,$.minzoom,$.maxzoom]}),F)Object.prototype.hasOwnProperty.call(F,Z)&&Z!=="layout"&&Z!=="paint"&&Z!=="filter"&&Z!=="metadata"&&Z!=="minzoom"&&Z!=="maxzoom"&&(Z.indexOf("paint.")===0?Ii(F[Z],$[Z],_,D,Z.slice(6),"setPaintProperty"):Qe(F[Z],$[Z])||vt(_,{command:"setLayerProperty",args:[D,Z,$[Z]]}));for(Z in $)Object.prototype.hasOwnProperty.call($,Z)&&!Object.prototype.hasOwnProperty.call(F,Z)&&Z!=="layout"&&Z!=="paint"&&Z!=="filter"&&Z!=="metadata"&&Z!=="minzoom"&&Z!=="maxzoom"&&(Z.indexOf("paint.")===0?Ii(F[Z],$[Z],_,D,Z.slice(6),"setPaintProperty"):Qe(F[Z],$[Z])||vt(_,{command:"setLayerProperty",args:[D,Z,$[Z]]}))}else vt(_,{command:"removeLayer",args:[D]}),J=C[C.lastIndexOf(D)+1],vt(_,{command:"addLayer",args:[$,J]})}(c,e.layers,r)}catch(s){console.warn("Unable to compute style diff:",s),r=[{command:"setStyle",args:[e]}]}return r},L.aE=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},L.aF=function i(e,r){if(Array.isArray(e)){if(!Array.isArray(r)||e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(!i(e[s],r[s]))return!1;return!0}if(typeof e=="object"&&e!==null&&r!==null){if(typeof r!="object"||Object.keys(e).length!==Object.keys(r).length)return!1;for(const s in e)if(!i(e[s],r[s]))return!1;return!0}return e===r},L.aG=Gi,L.aH=Bn,L.aI=class extends us{constructor(i,e){super(i,e),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},L.aJ=yl,L.aK=class extends us{constructor(i,e){super(i,e),this.current=Ou}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}}},L.aL=Qc,L.aM=eh,L.aN=it,L.aO=class extends us{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]))}},L.aP=class extends us{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]))}},L.aQ=function(i,e,r,s,o,c,d){var f=1/(e-r),_=1/(s-o),x=1/(c-d);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*x,i[11]=0,i[12]=(e+r)*f,i[13]=(o+s)*_,i[14]=(d+c)*x,i[15]=1,i},L.aR=Zu,L.aS=class extends oe{},L.aT=Bd,L.aU=class extends Te{},L.aV=function(i){return i<=1?1:Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))},L.aW=mh,L.aX=tn,L.aY=Dt,L.aZ=class extends ve{},L.a_=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]},L.aa=du,L.ab=function(i){const e={};if(i.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(r,s,o,c)=>{const d=o||c;return e[s]=!d||d.toLowerCase(),""}),e["max-age"]){const r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e},L.ac=function(i,e){const r=[];for(const s in i)s in e||r.push(s);return r},L.ad=Mi,L.ae=function(i,e,r){var s=Math.sin(r),o=Math.cos(r),c=e[0],d=e[1],f=e[2],_=e[3],x=e[4],b=e[5],w=e[6],I=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]=c*o+x*s,i[1]=d*o+b*s,i[2]=f*o+w*s,i[3]=_*o+I*s,i[4]=x*o-c*s,i[5]=b*o-d*s,i[6]=w*o-f*s,i[7]=I*o-_*s,i},L.af=function(i){var e=new na(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},L.ag=wl,L.ah=function(i,e){let r=0,s=0;if(i.kind==="constant")s=i.layoutSize;else if(i.kind!=="source"){const{interpolationType:o,minZoom:c,maxZoom:d}=i,f=o?Mi(xi.interpolationFactor(o,e,c,d),0,1):0;i.kind==="camera"?s=yi.number(i.minSize,i.maxSize,f):r=f}return{uSizeT:r,uSize:s}},L.aj=function(i,{uSize:e,uSizeT:r},{lowerSize:s,upperSize:o}){return i.kind==="source"?s/Rr:i.kind==="composite"?yi.number(s/Rr,o/Rr,r):e},L.ak=Ec,L.al=function(i,e,r,s){const o=e.y-i.y,c=e.x-i.x,d=s.y-r.y,f=s.x-r.x,_=d*c-f*o;if(_===0)return null;const x=(f*(i.y-r.y)-d*(i.x-r.x))/_;return new me(i.x+x*c,i.y+x*o)},L.am=_u,L.an=nh,L.ao=dc,L.ap=function(i){let e=1/0,r=1/0,s=-1/0,o=-1/0;for(const c of i)e=Math.min(e,c.x),r=Math.min(r,c.y),s=Math.max(s,c.x),o=Math.max(o,c.y);return[e,r,s,o]},L.aq=Et,L.as=zc,L.at=function(i,e){var r=e[0],s=e[1],o=e[2],c=e[3],d=e[4],f=e[5],_=e[6],x=e[7],b=e[8],w=e[9],I=e[10],C=e[11],k=e[12],D=e[13],F=e[14],$=e[15],J=r*f-s*d,Z=r*_-o*d,K=r*x-c*d,ie=s*_-o*f,ce=s*x-c*f,xe=o*x-c*_,Le=b*D-w*k,be=b*F-I*k,ye=b*$-C*k,ke=w*F-I*D,Ae=w*$-C*D,Ie=I*$-C*F,ae=J*Ie-Z*Ae+K*ke+ie*ye-ce*be+xe*Le;return ae?(i[0]=(f*Ie-_*Ae+x*ke)*(ae=1/ae),i[1]=(o*Ae-s*Ie-c*ke)*ae,i[2]=(D*xe-F*ce+$*ie)*ae,i[3]=(I*ce-w*xe-C*ie)*ae,i[4]=(_*ye-d*Ie-x*be)*ae,i[5]=(r*Ie-o*ye+c*be)*ae,i[6]=(F*K-k*xe-$*Z)*ae,i[7]=(b*xe-I*K+C*Z)*ae,i[8]=(d*Ae-f*ye+x*Le)*ae,i[9]=(s*ye-r*Ae-c*Le)*ae,i[10]=(k*ce-D*K+$*J)*ae,i[11]=(w*K-b*ce-C*J)*ae,i[12]=(f*be-d*ke-_*Le)*ae,i[13]=(r*ke-s*be+o*Le)*ae,i[14]=(D*Z-k*ie-F*J)*ae,i[15]=(b*ie-w*Z+I*J)*ae,i):null},L.au=Nc,L.av=kc,L.aw=jc,L.ax=function(){const i={},e=re.$version;for(const r in re.$root){const s=re.$root[r];if(s.required){let o=null;o=r==="version"?e:s.type==="array"?[]:{},o!=null&&(i[r]=o)}}return i},L.ay=hl,L.az=zi,L.b=Xi,L.b0=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},L.b1=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},L.b2=function(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]+i[3]*e[3]},L.b3=Zi,L.b4=cu,L.b5=ou,L.b6=function(i,e,r,s,o){var c,d=1/Math.tan(e/2);return i[0]=d/r,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=d,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,o!=null&&o!==1/0?(i[10]=(o+s)*(c=1/(s-o)),i[14]=2*o*s*c):(i[10]=-1,i[14]=-2*s),i},L.b7=function(i,e,r){var s=Math.sin(r),o=Math.cos(r),c=e[4],d=e[5],f=e[6],_=e[7],x=e[8],b=e[9],w=e[10],I=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]=c*o+x*s,i[5]=d*o+b*s,i[6]=f*o+w*s,i[7]=_*o+I*s,i[8]=x*o-c*s,i[9]=b*o-d*s,i[10]=w*o-f*s,i[11]=I*o-_*s,i},L.b8=pi,L.b9=ma,L.bA=function(i){return i.message===ki},L.bB=Yr,L.bC=Er,L.ba=function(i){return i*Math.PI/180},L.bb=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},L.bc=class extends M{},L.bd=Bc,L.be=xp,L.bg=fi,L.bh=function(i,e){br.REGISTERED_PROTOCOLS[i]=e},L.bi=function(i){delete br.REGISTERED_PROTOCOLS[i]},L.bj=function(i,e){const r={};for(let o=0;o<i.length;o++){const c=e&&e[i[o].id]||qa(i[o]);e&&(e[i[o].id]=c);let d=r[c];d||(d=r[c]=[]),d.push(i[o])}const s=[];for(const o in r)s.push(r[o]);return s},L.bk=Pe,L.bl=uu,L.bm=pu,L.bn=qh,L.bo=function(i){i.bucket.createArrays(),i.bucket.tilePixelRatio=Mt/(512*i.bucket.overscaling),i.bucket.compareText={},i.bucket.iconsNeedLinear=!1;const e=i.bucket.layers[0],r=e.layout,s=e._unevaluatedLayout._values,o={layoutIconSize:s["icon-size"].possiblyEvaluate(new ct(i.bucket.zoom+1),i.canonical),layoutTextSize:s["text-size"].possiblyEvaluate(new ct(i.bucket.zoom+1),i.canonical),textMaxSize:s["text-size"].possiblyEvaluate(new ct(18))};if(i.bucket.textSizeData.kind==="composite"){const{minZoom:x,maxZoom:b}=i.bucket.textSizeData;o.compositeTextSizes=[s["text-size"].possiblyEvaluate(new ct(x),i.canonical),s["text-size"].possiblyEvaluate(new ct(b),i.canonical)]}if(i.bucket.iconSizeData.kind==="composite"){const{minZoom:x,maxZoom:b}=i.bucket.iconSizeData;o.compositeIconSizes=[s["icon-size"].possiblyEvaluate(new ct(x),i.canonical),s["icon-size"].possiblyEvaluate(new ct(b),i.canonical)]}const c=r.get("text-line-height")*Et,d=r.get("text-rotation-alignment")!=="viewport"&&r.get("symbol-placement")!=="point",f=r.get("text-keep-upright"),_=r.get("text-size");for(const x of i.bucket.features){const b=r.get("text-font").evaluate(x,{},i.canonical).join(","),w=_.evaluate(x,{},i.canonical),I=o.layoutTextSize.evaluate(x,{},i.canonical),C=o.layoutIconSize.evaluate(x,{},i.canonical),k={horizontal:{},vertical:void 0},D=x.text;let F,$=[0,0];if(D){const K=D.toString(),ie=r.get("text-letter-spacing").evaluate(x,{},i.canonical)*Et,ce=sc(K)?ie:0,xe=r.get("text-anchor").evaluate(x,{},i.canonical),Le=Iu(e,x,i.canonical);if(!Le){const Ae=r.get("text-radial-offset").evaluate(x,{},i.canonical);$=Ae?Su(xe,[Ae*Et,Vc]):r.get("text-offset").evaluate(x,{},i.canonical).map(Ie=>Ie*Et)}let be=d?"center":r.get("text-justify").evaluate(x,{},i.canonical);const ye=r.get("symbol-placement")==="point"?r.get("text-max-width").evaluate(x,{},i.canonical)*Et:1/0,ke=()=>{i.bucket.allowVerticalPlacement&&so(K)&&(k.vertical=Ml(D,i.glyphMap,i.glyphPositions,i.imagePositions,b,ye,c,xe,"left",ce,$,L.ai.vertical,!0,I,w))};if(!d&&Le){const Ae=new Set;if(be==="auto")for(let ae=0;ae<Le.values.length;ae+=2)Ae.add(Nc(Le.values[ae]));else Ae.add(be);let Ie=!1;for(const ae of Ae)if(!k.horizontal[ae])if(Ie)k.horizontal[ae]=k.horizontal[0];else{const Ee=Ml(D,i.glyphMap,i.glyphPositions,i.imagePositions,b,ye,c,"center",ae,ce,$,L.ai.horizontal,!1,I,w);Ee&&(k.horizontal[ae]=Ee,Ie=Ee.positionedLines.length===1)}ke()}else{be==="auto"&&(be=Nc(xe));const Ae=Ml(D,i.glyphMap,i.glyphPositions,i.imagePositions,b,ye,c,xe,be,ce,$,L.ai.horizontal,!1,I,w);Ae&&(k.horizontal[be]=Ae),ke(),so(K)&&d&&f&&(k.vertical=Ml(D,i.glyphMap,i.glyphPositions,i.imagePositions,b,ye,c,xe,be,ce,$,L.ai.vertical,!1,I,w))}}let J=!1;if(x.icon&&x.icon.name){const K=i.imageMap[x.icon.name];K&&(F=ep(i.imagePositions[x.icon.name],r.get("icon-offset").evaluate(x,{},i.canonical),r.get("icon-anchor").evaluate(x,{},i.canonical)),J=!!K.sdf,i.bucket.sdfIcons===void 0?i.bucket.sdfIcons=J:i.bucket.sdfIcons!==J&&Ot("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(K.pixelRatio!==i.bucket.pixelRatio||r.get("icon-rotate").constantOr(1)!==0)&&(i.bucket.iconsNeedLinear=!0))}const Z=Au(k.horizontal)||k.vertical;i.bucket.iconsInText=!!Z&&Z.iconsInText,(Z||F)&&gp(i.bucket,x,k,F,i.imageMap,o,I,C,$,J,i.canonical)}i.showCollisionBoxes&&i.bucket.generateCollisionDebugBuffers()},L.bp=Sc,L.bq=bc,L.br=Tc,L.bs=Mn,L.bt=Pc,L.bu=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}},L.bv=function(i,e,r,s,o){return p(this,void 0,void 0,function*(){if(Rn())try{return yield jr(i,e,r,s,o)}catch{}return function(c,d,f,_,x){const b=c.width,w=c.height;or&&ni||(or=new OffscreenCanvas(b,w),ni=or.getContext("2d",{willReadFrequently:!0})),or.width=b,or.height=w,ni.drawImage(c,0,0,b,w);const I=ni.getImageData(d,f,_,x);return ni.clearRect(0,0,b,w),I.data}(i,e,r,s,o)})},L.bw=hu,L.bx=Ti,L.by=$i,L.bz=Rh,L.c=cn,L.d=i=>p(void 0,void 0,void 0,function*(){if(i.byteLength===0)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(i)],{type:"image/png"});try{return createImageBitmap(e)}catch(r){throw new Error(`Could not load image because of ${r.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),L.e=Si,L.f=i=>new Promise((e,r)=>{const s=new Image;s.onload=()=>{e(s),URL.revokeObjectURL(s.src),s.onload=null,window.requestAnimationFrame(()=>{s.src=vs})},s.onerror=()=>r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const o=new Blob([new Uint8Array(i)],{type:"image/png"});s.src=i.byteLength?URL.createObjectURL(o):vs}),L.g=Wi,L.h=(i,e)=>Ur(Si(i,{type:"json"}),e),L.i=ar,L.j=Tr,L.k=wr,L.l=(i,e)=>Ur(Si(i,{type:"arrayBuffer"}),e),L.m=Ur,L.n=function(i){return new Pc(i).readFields(Xd,[])},L.o=yo,L.p=$h,L.q=a,L.r=ic,L.s=$r,L.t=ro,L.u=we,L.v=re,L.w=Ot,L.x=fr,L.y=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)}},L.z=yi}),Do("worker",["./shared"],function(L){class p{constructor(A){this.keyCache={},A&&this.replace(A)}replace(A){this._layerConfigs={},this._layers={},this.update(A,[])}update(A,P){for(const V of A){this._layerConfigs[V.id]=V;const X=this._layers[V.id]=L.aB(V);X._featureFilter=L.a7(X.filter),this.keyCache[V.id]&&delete this.keyCache[V.id]}for(const V of P)delete this.keyCache[V],delete this._layerConfigs[V],delete this._layers[V];this.familiesBySource={};const E=L.bj(Object.values(this._layerConfigs),this.keyCache);for(const V of E){const X=V.map(te=>this._layers[te.id]),W=X[0];if(W.visibility==="none")continue;const Y=W.source||"";let q=this.familiesBySource[Y];q||(q=this.familiesBySource[Y]={});const ne=W.sourceLayer||"_geojsonTileLayer";let le=q[ne];le||(le=q[ne]=[]),le.push(X)}}}class Ti{constructor(A){const P={},E=[];for(const Y in A){const q=A[Y],ne=P[Y]={};for(const le in q){const te=q[+le];if(!te||te.bitmap.width===0||te.bitmap.height===0)continue;const fe={x:0,y:0,w:te.bitmap.width+2,h:te.bitmap.height+2};E.push(fe),ne[le]={rect:fe,metrics:te.metrics}}}const{w:V,h:X}=L.p(E),W=new L.o({width:V||1,height:X||1});for(const Y in A){const q=A[Y];for(const ne in q){const le=q[+ne];if(!le||le.bitmap.width===0||le.bitmap.height===0)continue;const te=P[Y][ne].rect;L.o.copy(le.bitmap,W,{x:0,y:0},{x:te.x+1,y:te.y+1},le.bitmap)}}this.image=W,this.positions=P}}L.bk("GlyphAtlas",Ti);class $i{constructor(A){this.tileID=new L.S(A.tileID.overscaledZ,A.tileID.wrap,A.tileID.canonical.z,A.tileID.canonical.x,A.tileID.canonical.y),this.uid=A.uid,this.zoom=A.zoom,this.pixelRatio=A.pixelRatio,this.tileSize=A.tileSize,this.source=A.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=A.showCollisionBoxes,this.collectResourceTiming=!!A.collectResourceTiming,this.returnDependencies=!!A.returnDependencies,this.promoteId=A.promoteId,this.inFlightDependencies=[]}parse(A,P,E,V){return L._(this,void 0,void 0,function*(){this.status="parsing",this.data=A,this.collisionBoxArray=new L.a5;const X=new L.bl(Object.keys(A.layers).sort()),W=new L.bm(this.tileID,this.promoteId);W.bucketLayerIDs=[];const Y={},q={featureIndex:W,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:E},ne=P.familiesBySource[this.source];for(const Ge in ne){const tt=A.layers[Ge];if(!tt)continue;tt.version===1&&L.w(`Vector tile source "${this.source}" layer "${Ge}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const gt=X.encode(Ge),kt=[];for(let Vt=0;Vt<tt.length;Vt++){const Nt=tt.feature(Vt),Un=W.getId(Nt,Ge);kt.push({feature:Nt,id:Un,index:Vt,sourceLayerIndex:gt})}for(const Vt of ne[Ge]){const Nt=Vt[0];Nt.source!==this.source&&L.w(`layer.source = ${Nt.source} does not equal this.source = ${this.source}`),Nt.minzoom&&this.zoom<Math.floor(Nt.minzoom)||Nt.maxzoom&&this.zoom>=Nt.maxzoom||Nt.visibility!=="none"&&(Jt(Vt,this.zoom,E),(Y[Nt.id]=Nt.createBucket({index:W.bucketLayerIDs.length,layers:Vt,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:gt,sourceID:this.source})).populate(kt,q,this.tileID.canonical),W.bucketLayerIDs.push(Vt.map(Un=>Un.id)))}}const le=L.aG(q.glyphDependencies,Ge=>Object.keys(Ge).map(Number));this.inFlightDependencies.forEach(Ge=>Ge==null?void 0:Ge.abort()),this.inFlightDependencies=[];let te=Promise.resolve({});if(Object.keys(le).length){const Ge=new AbortController;this.inFlightDependencies.push(Ge),te=V.sendAsync({type:"GG",data:{stacks:le,source:this.source,tileID:this.tileID,type:"glyphs"}},Ge)}const fe=Object.keys(q.iconDependencies);let De=Promise.resolve({});if(fe.length){const Ge=new AbortController;this.inFlightDependencies.push(Ge),De=V.sendAsync({type:"GI",data:{icons:fe,source:this.source,tileID:this.tileID,type:"icons"}},Ge)}const Re=Object.keys(q.patternDependencies);let $e=Promise.resolve({});if(Re.length){const Ge=new AbortController;this.inFlightDependencies.push(Ge),$e=V.sendAsync({type:"GI",data:{icons:Re,source:this.source,tileID:this.tileID,type:"patterns"}},Ge)}const[Ke,Ue,ot]=yield Promise.all([te,De,$e]),bt=new Ti(Ke),At=new L.bn(Ue,ot);for(const Ge in Y){const tt=Y[Ge];tt instanceof L.a6?(Jt(tt.layers,this.zoom,E),L.bo({bucket:tt,glyphMap:Ke,glyphPositions:bt.positions,imageMap:Ue,imagePositions:At.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):tt.hasPattern&&(tt instanceof L.bp||tt instanceof L.bq||tt instanceof L.br)&&(Jt(tt.layers,this.zoom,E),tt.addFeatures(q,this.tileID.canonical,At.patternPositions))}return this.status="done",{buckets:Object.values(Y).filter(Ge=>!Ge.isEmpty()),featureIndex:W,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:bt.image,imageAtlas:At,glyphMap:this.returnDependencies?Ke:null,iconMap:this.returnDependencies?Ue:null,glyphPositions:this.returnDependencies?bt.positions:null}})}}function Jt(j,A,P){const E=new L.a9(A);for(const V of j)V.recalculate(E,P)}class me{constructor(A,P,E){this.actor=A,this.layerIndex=P,this.availableImages=E,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(A,P){return L._(this,void 0,void 0,function*(){const E=yield L.l(A.request,P);try{return{vectorTile:new L.bs.VectorTile(new L.bt(E.data)),rawData:E.data,cacheControl:E.cacheControl,expires:E.expires}}catch(V){const X=new Uint8Array(E.data);let W=`Unable to parse the tile at ${A.request.url}, `;throw W+=X[0]===31&&X[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${V.message}`,new Error(W)}})}loadTile(A){return L._(this,void 0,void 0,function*(){const P=A.uid,E=!!(A&&A.request&&A.request.collectResourceTiming)&&new L.bu(A.request),V=new $i(A);this.loading[P]=V;const X=new AbortController;V.abort=X;try{const W=yield this.loadVectorTile(A,X);if(delete this.loading[P],!W)return null;const Y=W.rawData,q={};W.expires&&(q.expires=W.expires),W.cacheControl&&(q.cacheControl=W.cacheControl);const ne={};if(E){const te=E.finish();te&&(ne.resourceTiming=JSON.parse(JSON.stringify(te)))}V.vectorTile=W.vectorTile;const le=V.parse(W.vectorTile,this.layerIndex,this.availableImages,this.actor);this.loaded[P]=V,this.fetching[P]={rawTileData:Y,cacheControl:q,resourceTiming:ne};try{const te=yield le;return L.e({rawTileData:Y.slice(0)},te,q,ne)}finally{delete this.fetching[P]}}catch(W){throw delete this.loading[P],V.status="done",this.loaded[P]=V,W}})}reloadTile(A){return L._(this,void 0,void 0,function*(){const P=A.uid;if(!this.loaded||!this.loaded[P])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const E=this.loaded[P];if(E.showCollisionBoxes=A.showCollisionBoxes,E.status==="parsing"){const V=yield E.parse(E.vectorTile,this.layerIndex,this.availableImages,this.actor);let X;if(this.fetching[P]){const{rawTileData:W,cacheControl:Y,resourceTiming:q}=this.fetching[P];delete this.fetching[P],X=L.e({rawTileData:W.slice(0)},V,Y,q)}else X=V;return X}if(E.status==="done"&&E.vectorTile)return E.parse(E.vectorTile,this.layerIndex,this.availableImages,this.actor)})}abortTile(A){return L._(this,void 0,void 0,function*(){const P=this.loading,E=A.uid;P&&P[E]&&P[E].abort&&(P[E].abort.abort(),delete P[E])})}removeTile(A){return L._(this,void 0,void 0,function*(){this.loaded&&this.loaded[A.uid]&&delete this.loaded[A.uid]})}}class se{constructor(){this.loaded={}}loadTile(A){return L._(this,void 0,void 0,function*(){const{uid:P,encoding:E,rawImageData:V,redFactor:X,greenFactor:W,blueFactor:Y,baseShift:q}=A,ne=V.width+2,le=V.height+2,te=L.b(V)?new L.R({width:ne,height:le},yield L.bv(V,-1,-1,ne,le)):V,fe=new L.bw(P,te,E,X,W,Y,q);return this.loaded=this.loaded||{},this.loaded[P]=fe,fe})}removeTile(A){const P=this.loaded,E=A.uid;P&&P[E]&&delete P[E]}}function Nr(j,A){if(j.length!==0){xr(j[0],A);for(var P=1;P<j.length;P++)xr(j[P],!A)}}function xr(j,A){for(var P=0,E=0,V=0,X=j.length,W=X-1;V<X;W=V++){var Y=(j[V][0]-j[W][0])*(j[W][1]+j[V][1]),q=P+Y;E+=Math.abs(P)>=Math.abs(Y)?P-q+Y:Y-q+P,P=q}P+E>=0!=!!A&&j.reverse()}var qi=L.bx(function j(A,P){var E,V=A&&A.type;if(V==="FeatureCollection")for(E=0;E<A.features.length;E++)j(A.features[E],P);else if(V==="GeometryCollection")for(E=0;E<A.geometries.length;E++)j(A.geometries[E],P);else if(V==="Feature")j(A.geometry,P);else if(V==="Polygon")Nr(A.coordinates,P);else if(V==="MultiPolygon")for(E=0;E<A.coordinates.length;E++)Nr(A.coordinates[E],P);return A});const vr=L.bs.VectorTileFeature.prototype.toGeoJSON;var sr={exports:{}},Rn=L.by,pi=L.bs.VectorTileFeature,ma=Mi;function Mi(j,A){this.options=A||{},this.features=j,this.length=j.length}function Zi(j,A){this.id=typeof j.id=="number"?j.id:void 0,this.type=j.type,this.rawGeometry=j.type===1?[j.geometry]:j.geometry,this.properties=j.tags,this.extent=A||4096}Mi.prototype.feature=function(j){return new Zi(this.features[j],this.options.extent)},Zi.prototype.loadGeometry=function(){var j=this.rawGeometry;this.geometry=[];for(var A=0;A<j.length;A++){for(var P=j[A],E=[],V=0;V<P.length;V++)E.push(new Rn(P[V][0],P[V][1]));this.geometry.push(E)}return this.geometry},Zi.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var j=this.geometry,A=1/0,P=-1/0,E=1/0,V=-1/0,X=0;X<j.length;X++)for(var W=j[X],Y=0;Y<W.length;Y++){var q=W[Y];A=Math.min(A,q.x),P=Math.max(P,q.x),E=Math.min(E,q.y),V=Math.max(V,q.y)}return[A,E,P,V]},Zi.prototype.toGeoJSON=pi.prototype.toGeoJSON;var Si=L.bz,ys=ma;function Gi(j){var A=new Si;return function(P,E){for(var V in P.layers)E.writeMessage(3,Bn,P.layers[V])}(j,A),A.finish()}function Bn(j,A){var P;A.writeVarintField(15,j.version||1),A.writeStringField(1,j.name||""),A.writeVarintField(5,j.extent||4096);var E={keys:[],values:[],keycache:{},valuecache:{}};for(P=0;P<j.length;P++)E.feature=j.feature(P),A.writeMessage(2,rt,E);var V=E.keys;for(P=0;P<V.length;P++)A.writeStringField(3,V[P]);var X=E.values;for(P=0;P<X.length;P++)A.writeMessage(4,ln,X[P])}function rt(j,A){var P=j.feature;P.id!==void 0&&A.writeVarintField(1,P.id),A.writeMessage(2,xs,j),A.writeVarintField(3,P.type),A.writeMessage(4,ar,P)}function xs(j,A){var P=j.feature,E=j.keys,V=j.values,X=j.keycache,W=j.valuecache;for(var Y in P.properties){var q=P.properties[Y],ne=X[Y];if(q!==null){ne===void 0&&(E.push(Y),X[Y]=ne=E.length-1),A.writeVarint(ne);var le=typeof q;le!=="string"&&le!=="boolean"&&le!=="number"&&(q=JSON.stringify(q));var te=le+":"+q,fe=W[te];fe===void 0&&(V.push(q),W[te]=fe=V.length-1),A.writeVarint(fe)}}}function Ot(j,A){return(A<<3)+(7&j)}function Yt(j){return j<<1^j>>31}function ar(j,A){for(var P=j.loadGeometry(),E=j.type,V=0,X=0,W=P.length,Y=0;Y<W;Y++){var q=P[Y],ne=1;E===1&&(ne=q.length),A.writeVarint(Ot(1,ne));for(var le=E===3?q.length-1:q.length,te=0;te<le;te++){te===1&&E!==1&&A.writeVarint(Ot(2,le-1));var fe=q[te].x-V,De=q[te].y-X;A.writeVarint(Yt(fe)),A.writeVarint(Yt(De)),V+=fe,X+=De}E===3&&A.writeVarint(Ot(7,1))}}function ln(j,A){var P=typeof j;P==="string"?A.writeStringField(1,j):P==="boolean"?A.writeBooleanField(7,j):P==="number"&&(j%1!=0?A.writeDoubleField(3,j):j<0?A.writeSVarintField(6,j):A.writeVarintField(5,j))}sr.exports=Gi,sr.exports.fromVectorTileJs=Gi,sr.exports.fromGeojsonVt=function(j,A){A=A||{};var P={};for(var E in j)P[E]=new ys(j[E].features,A),P[E].name=E,P[E].version=A.version,P[E].extent=A.extent;return Gi({layers:P})},sr.exports.GeoJSONWrapper=ys;var Xi=L.bx(sr.exports);const vs={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:j=>j},jr=Math.fround||(or=new Float32Array(1),j=>(or[0]=+j,or[0]));var or;const ni=3,ki=5,cn=6;class br{constructor(A){this.options=Object.assign(Object.create(vs),A),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(A){const{log:P,minZoom:E,maxZoom:V}=this.options;P&&console.time("total time");const X=`prepare ${A.length} points`;P&&console.time(X),this.points=A;const W=[];for(let q=0;q<A.length;q++){const ne=A[q];if(!ne.geometry)continue;const[le,te]=ne.geometry.coordinates,fe=jr(fi(le)),De=jr(zi(te));W.push(fe,De,1/0,q,-1,1),this.options.reduce&&W.push(0)}let Y=this.trees[V+1]=this._createTree(W);P&&console.timeEnd(X);for(let q=V;q>=E;q--){const ne=+Date.now();Y=this.trees[q]=this._createTree(this._cluster(Y,q)),P&&console.log("z%d: %d clusters in %dms",q,Y.numItems,+Date.now()-ne)}return P&&console.timeEnd("total time"),this}getClusters(A,P){let E=((A[0]+180)%360+360)%360-180;const V=Math.max(-90,Math.min(90,A[1]));let X=A[2]===180?180:((A[2]+180)%360+360)%360-180;const W=Math.max(-90,Math.min(90,A[3]));if(A[2]-A[0]>=360)E=-180,X=180;else if(E>X){const te=this.getClusters([E,V,180,W],P),fe=this.getClusters([-180,V,X,W],P);return te.concat(fe)}const Y=this.trees[this._limitZoom(P)],q=Y.range(fi(E),zi(W),fi(X),zi(V)),ne=Y.data,le=[];for(const te of q){const fe=this.stride*te;le.push(ne[fe+ki]>1?Wi(ne,fe,this.clusterProps):this.points[ne[fe+ni]])}return le}getChildren(A){const P=this._getOriginId(A),E=this._getOriginZoom(A),V="No cluster with the specified id.",X=this.trees[E];if(!X)throw new Error(V);const W=X.data;if(P*this.stride>=W.length)throw new Error(V);const Y=this.options.radius/(this.options.extent*Math.pow(2,E-1)),q=X.within(W[P*this.stride],W[P*this.stride+1],Y),ne=[];for(const le of q){const te=le*this.stride;W[te+4]===A&&ne.push(W[te+ki]>1?Wi(W,te,this.clusterProps):this.points[W[te+ni]])}if(ne.length===0)throw new Error(V);return ne}getLeaves(A,P,E){const V=[];return this._appendLeaves(V,A,P=P||10,E=E||0,0),V}getTile(A,P,E){const V=this.trees[this._limitZoom(A)],X=Math.pow(2,A),{extent:W,radius:Y}=this.options,q=Y/W,ne=(E-q)/X,le=(E+1+q)/X,te={features:[]};return this._addTileFeatures(V.range((P-q)/X,ne,(P+1+q)/X,le),V.data,P,E,X,te),P===0&&this._addTileFeatures(V.range(1-q/X,ne,1,le),V.data,X,E,X,te),P===X-1&&this._addTileFeatures(V.range(0,ne,q/X,le),V.data,-1,E,X,te),te.features.length?te:null}getClusterExpansionZoom(A){let P=this._getOriginZoom(A)-1;for(;P<=this.options.maxZoom;){const E=this.getChildren(A);if(P++,E.length!==1)break;A=E[0].properties.cluster_id}return P}_appendLeaves(A,P,E,V,X){const W=this.getChildren(P);for(const Y of W){const q=Y.properties;if(q&&q.cluster?X+q.point_count<=V?X+=q.point_count:X=this._appendLeaves(A,q.cluster_id,E,V,X):X<V?X++:A.push(Y),A.length===E)break}return X}_createTree(A){const P=new L.aw(A.length/this.stride|0,this.options.nodeSize,Float32Array);for(let E=0;E<A.length;E+=this.stride)P.add(A[E],A[E+1]);return P.finish(),P.data=A,P}_addTileFeatures(A,P,E,V,X,W){for(const Y of A){const q=Y*this.stride,ne=P[q+ki]>1;let le,te,fe;if(ne)le=hn(P,q,this.clusterProps),te=P[q],fe=P[q+1];else{const $e=this.points[P[q+ni]];le=$e.properties;const[Ke,Ue]=$e.geometry.coordinates;te=fi(Ke),fe=zi(Ue)}const De={type:1,geometry:[[Math.round(this.options.extent*(te*X-E)),Math.round(this.options.extent*(fe*X-V))]],tags:le};let Re;Re=ne||this.options.generateId?P[q+ni]:this.points[P[q+ni]].id,Re!==void 0&&(De.id=Re),W.features.push(De)}}_limitZoom(A){return Math.max(this.options.minZoom,Math.min(Math.floor(+A),this.options.maxZoom+1))}_cluster(A,P){const{radius:E,extent:V,reduce:X,minPoints:W}=this.options,Y=E/(V*Math.pow(2,P)),q=A.data,ne=[],le=this.stride;for(let te=0;te<q.length;te+=le){if(q[te+2]<=P)continue;q[te+2]=P;const fe=q[te],De=q[te+1],Re=A.within(q[te],q[te+1],Y),$e=q[te+ki];let Ke=$e;for(const Ue of Re){const ot=Ue*le;q[ot+2]>P&&(Ke+=q[ot+ki])}if(Ke>$e&&Ke>=W){let Ue,ot=fe*$e,bt=De*$e,At=-1;const Ge=((te/le|0)<<5)+(P+1)+this.points.length;for(const tt of Re){const gt=tt*le;if(q[gt+2]<=P)continue;q[gt+2]=P;const kt=q[gt+ki];ot+=q[gt]*kt,bt+=q[gt+1]*kt,q[gt+4]=Ge,X&&(Ue||(Ue=this._map(q,te,!0),At=this.clusterProps.length,this.clusterProps.push(Ue)),X(Ue,this._map(q,gt)))}q[te+4]=Ge,ne.push(ot/Ke,bt/Ke,1/0,Ge,-1,Ke),X&&ne.push(At)}else{for(let Ue=0;Ue<le;Ue++)ne.push(q[te+Ue]);if(Ke>1)for(const Ue of Re){const ot=Ue*le;if(!(q[ot+2]<=P)){q[ot+2]=P;for(let bt=0;bt<le;bt++)ne.push(q[ot+bt])}}}}return ne}_getOriginId(A){return A-this.points.length>>5}_getOriginZoom(A){return(A-this.points.length)%32}_map(A,P,E){if(A[P+ki]>1){const W=this.clusterProps[A[P+cn]];return E?Object.assign({},W):W}const V=this.points[A[P+ni]].properties,X=this.options.map(V);return E&&X===V?Object.assign({},X):X}}function Wi(j,A,P){return{type:"Feature",id:j[A+ni],properties:hn(j,A,P),geometry:{type:"Point",coordinates:[(E=j[A],360*(E-.5)),Ur(j[A+1])]}};var E}function hn(j,A,P){const E=j[A+ki],V=E>=1e4?`${Math.round(E/1e3)}k`:E>=1e3?Math.round(E/100)/10+"k":E,X=j[A+cn],W=X===-1?{}:Object.assign({},P[X]);return Object.assign(W,{cluster:!0,cluster_id:j[A+ni],point_count:E,point_count_abbreviated:V})}function fi(j){return j/360+.5}function zi(j){const A=Math.sin(j*Math.PI/180),P=.5-.25*Math.log((1+A)/(1-A))/Math.PI;return P<0?0:P>1?1:P}function Ur(j){const A=(180-360*j)*Math.PI/180;return 360*Math.atan(Math.exp(A))/Math.PI-90}function $r(j,A,P,E){let V=E;const X=A+(P-A>>1);let W,Y=P-A;const q=j[A],ne=j[A+1],le=j[P],te=j[P+1];for(let fe=A+3;fe<P;fe+=3){const De=Fn(j[fe],j[fe+1],q,ne,le,te);if(De>V)W=fe,V=De;else if(De===V){const Re=Math.abs(fe-X);Re<Y&&(W=fe,Y=Re)}}V>E&&(W-A>3&&$r(j,A,W,E),j[W+2]=V,P-W>3&&$r(j,W,P,E))}function Fn(j,A,P,E,V,X){let W=V-P,Y=X-E;if(W!==0||Y!==0){const q=((j-P)*W+(A-E)*Y)/(W*W+Y*Y);q>1?(P=V,E=X):q>0&&(P+=W*q,E+=Y*q)}return W=j-P,Y=A-E,W*W+Y*Y}function lr(j,A,P,E){const V={id:j??null,type:A,geometry:P,tags:E,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(A==="Point"||A==="MultiPoint"||A==="LineString")wr(V,P);else if(A==="Polygon")wr(V,P[0]);else if(A==="MultiLineString")for(const X of P)wr(V,X);else if(A==="MultiPolygon")for(const X of P)wr(V,X[0]);return V}function wr(j,A){for(let P=0;P<A.length;P+=3)j.minX=Math.min(j.minX,A[P]),j.minY=Math.min(j.minY,A[P+1]),j.maxX=Math.max(j.maxX,A[P]),j.maxY=Math.max(j.maxY,A[P+1])}function Tr(j,A,P,E){if(!A.geometry)return;const V=A.geometry.coordinates;if(V&&V.length===0)return;const X=A.geometry.type,W=Math.pow(P.tolerance/((1<<P.maxZoom)*P.extent),2);let Y=[],q=A.id;if(P.promoteId?q=A.properties[P.promoteId]:P.generateId&&(q=E||0),X==="Point")un(V,Y);else if(X==="MultiPoint")for(const ne of V)un(ne,Y);else if(X==="LineString")re(V,Y,W,!1);else if(X==="MultiLineString"){if(P.lineMetrics){for(const ne of V)Y=[],re(ne,Y,W,!1),j.push(lr(q,"LineString",Y,A.properties));return}qr(V,Y,W,!1)}else if(X==="Polygon")qr(V,Y,W,!0);else{if(X!=="MultiPolygon"){if(X==="GeometryCollection"){for(const ne of A.geometry.geometries)Tr(j,{id:q,geometry:ne,properties:A.properties},P,E);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const ne of V){const le=[];qr(ne,le,W,!0),Y.push(le)}}j.push(lr(q,X,Y,A.properties))}function un(j,A){A.push(On(j[0]),Qe(j[1]),0)}function re(j,A,P,E){let V,X,W=0;for(let q=0;q<j.length;q++){const ne=On(j[q][0]),le=Qe(j[q][1]);A.push(ne,le,0),q>0&&(W+=E?(V*le-ne*X)/2:Math.sqrt(Math.pow(ne-V,2)+Math.pow(le-X,2))),V=ne,X=le}const Y=A.length-3;A[2]=1,$r(A,0,Y,P),A[Y+2]=1,A.size=Math.abs(W),A.start=0,A.end=A.size}function qr(j,A,P,E){for(let V=0;V<j.length;V++){const X=[];re(j[V],X,P,E),A.push(X)}}function On(j){return j/360+.5}function Qe(j){const A=Math.sin(j*Math.PI/180),P=.5-.25*Math.log((1+A)/(1-A))/Math.PI;return P<0?0:P>1?1:P}function vt(j,A,P,E,V,X,W,Y){if(E/=A,X>=(P/=A)&&W<E)return j;if(W<P||X>=E)return null;const q=[];for(const ne of j){const le=ne.geometry;let te=ne.type;const fe=V===0?ne.minX:ne.minY,De=V===0?ne.maxX:ne.maxY;if(fe>=P&&De<E){q.push(ne);continue}if(De<P||fe>=E)continue;let Re=[];if(te==="Point"||te==="MultiPoint")Vn(le,Re,P,E,V);else if(te==="LineString")Sr(le,Re,P,E,V,!1,Y.lineMetrics);else if(te==="MultiLineString")dn(le,Re,P,E,V,!1);else if(te==="Polygon")dn(le,Re,P,E,V,!0);else if(te==="MultiPolygon")for(const $e of le){const Ke=[];dn($e,Ke,P,E,V,!0),Ke.length&&Re.push(Ke)}if(Re.length){if(Y.lineMetrics&&te==="LineString"){for(const $e of Re)q.push(lr(ne.id,te,$e,ne.tags));continue}te!=="LineString"&&te!=="MultiLineString"||(Re.length===1?(te="LineString",Re=Re[0]):te="MultiLineString"),te!=="Point"&&te!=="MultiPoint"||(te=Re.length===3?"Point":"MultiPoint"),q.push(lr(ne.id,te,Re,ne.tags))}}return q.length?q:null}function Vn(j,A,P,E,V){for(let X=0;X<j.length;X+=3){const W=j[X+V];W>=P&&W<=E&&Ii(A,j[X],j[X+1],j[X+2])}}function Sr(j,A,P,E,V,X,W){let Y=cr(j);const q=V===0?Nn:jn;let ne,le,te=j.start;for(let Ke=0;Ke<j.length-3;Ke+=3){const Ue=j[Ke],ot=j[Ke+1],bt=j[Ke+2],At=j[Ke+3],Ge=j[Ke+4],tt=V===0?Ue:ot,gt=V===0?At:Ge;let kt=!1;W&&(ne=Math.sqrt(Math.pow(Ue-At,2)+Math.pow(ot-Ge,2))),tt<P?gt>P&&(le=q(Y,Ue,ot,At,Ge,P),W&&(Y.start=te+ne*le)):tt>E?gt<E&&(le=q(Y,Ue,ot,At,Ge,E),W&&(Y.start=te+ne*le)):Ii(Y,Ue,ot,bt),gt<P&&tt>=P&&(le=q(Y,Ue,ot,At,Ge,P),kt=!0),gt>E&&tt<=E&&(le=q(Y,Ue,ot,At,Ge,E),kt=!0),!X&&kt&&(W&&(Y.end=te+ne*le),A.push(Y),Y=cr(j)),W&&(te+=ne)}let fe=j.length-3;const De=j[fe],Re=j[fe+1],$e=V===0?De:Re;$e>=P&&$e<=E&&Ii(Y,De,Re,j[fe+2]),fe=Y.length-3,X&&fe>=3&&(Y[fe]!==Y[0]||Y[fe+1]!==Y[1])&&Ii(Y,Y[0],Y[1],Y[2]),Y.length&&A.push(Y)}function cr(j){const A=[];return A.size=j.size,A.start=j.start,A.end=j.end,A}function dn(j,A,P,E,V,X){for(const W of j)Sr(W,A,P,E,V,X,!1)}function Ii(j,A,P,E){j.push(A,P,E)}function Nn(j,A,P,E,V,X){const W=(X-A)/(E-A);return Ii(j,X,P+(V-P)*W,1),W}function jn(j,A,P,E,V,X){const W=(X-P)/(V-P);return Ii(j,A+(E-A)*W,X,1),W}function pe(j,A){const P=[];for(let E=0;E<j.length;E++){const V=j[E],X=V.type;let W;if(X==="Point"||X==="MultiPoint"||X==="LineString")W=Hi(V.geometry,A);else if(X==="MultiLineString"||X==="Polygon"){W=[];for(const Y of V.geometry)W.push(Hi(Y,A))}else if(X==="MultiPolygon"){W=[];for(const Y of V.geometry){const q=[];for(const ne of Y)q.push(Hi(ne,A));W.push(q)}}P.push(lr(V.id,X,W,V.tags))}return P}function Hi(j,A){const P=[];P.size=j.size,j.start!==void 0&&(P.start=j.start,P.end=j.end);for(let E=0;E<j.length;E+=3)P.push(j[E]+A,j[E+1],j[E+2]);return P}function Qt(j,A){if(j.transformed)return j;const P=1<<j.z,E=j.x,V=j.y;for(const X of j.features){const W=X.geometry,Y=X.type;if(X.geometry=[],Y===1)for(let q=0;q<W.length;q+=2)X.geometry.push(Ki(W[q],W[q+1],A,P,E,V));else for(let q=0;q<W.length;q++){const ne=[];for(let le=0;le<W[q].length;le+=2)ne.push(Ki(W[q][le],W[q][le+1],A,P,E,V));X.geometry.push(ne)}}return j.transformed=!0,j}function Ki(j,A,P,E,V,X){return[Math.round(P*(j*E-V)),Math.round(P*(A*E-X))]}function Ir(j,A,P,E,V){const X=A===V.maxZoom?0:V.tolerance/((1<<A)*V.extent),W={features:[],numPoints:0,numSimplified:0,numFeatures:j.length,source:null,x:P,y:E,z:A,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const Y of j)ge(W,Y,X,V);return W}function ge(j,A,P,E){const V=A.geometry,X=A.type,W=[];if(j.minX=Math.min(j.minX,A.minX),j.minY=Math.min(j.minY,A.minY),j.maxX=Math.max(j.maxX,A.maxX),j.maxY=Math.max(j.maxY,A.maxY),X==="Point"||X==="MultiPoint")for(let Y=0;Y<V.length;Y+=3)W.push(V[Y],V[Y+1]),j.numPoints++,j.numSimplified++;else if(X==="LineString")Ze(W,V,j,P,!1,!1);else if(X==="MultiLineString"||X==="Polygon")for(let Y=0;Y<V.length;Y++)Ze(W,V[Y],j,P,X==="Polygon",Y===0);else if(X==="MultiPolygon")for(let Y=0;Y<V.length;Y++){const q=V[Y];for(let ne=0;ne<q.length;ne++)Ze(W,q[ne],j,P,!0,ne===0)}if(W.length){let Y=A.tags||null;if(X==="LineString"&&E.lineMetrics){Y={};for(const ne in A.tags)Y[ne]=A.tags[ne];Y.mapbox_clip_start=V.start/V.size,Y.mapbox_clip_end=V.end/V.size}const q={geometry:W,type:X==="Polygon"||X==="MultiPolygon"?3:X==="LineString"||X==="MultiLineString"?2:1,tags:Y};A.id!==null&&(q.id=A.id),j.features.push(q)}}function Ze(j,A,P,E,V,X){const W=E*E;if(E>0&&A.size<(V?W:E))return void(P.numPoints+=A.length/3);const Y=[];for(let q=0;q<A.length;q+=3)(E===0||A[q+2]>W)&&(P.numSimplified++,Y.push(A[q],A[q+1])),P.numPoints++;V&&function(q,ne){let le=0;for(let te=0,fe=q.length,De=fe-2;te<fe;De=te,te+=2)le+=(q[te]-q[De])*(q[te+1]+q[De+1]);if(le>0===ne)for(let te=0,fe=q.length;te<fe/2;te+=2){const De=q[te],Re=q[te+1];q[te]=q[fe-2-te],q[te+1]=q[fe-1-te],q[fe-2-te]=De,q[fe-1-te]=Re}}(Y,X),j.push(Y)}const Fe={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class si{constructor(A,P){const E=(P=this.options=function(X,W){for(const Y in W)X[Y]=W[Y];return X}(Object.create(Fe),P)).debug;if(E&&console.time("preprocess data"),P.maxZoom<0||P.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(P.promoteId&&P.generateId)throw new Error("promoteId and generateId cannot be used together.");let V=function(X,W){const Y=[];if(X.type==="FeatureCollection")for(let q=0;q<X.features.length;q++)Tr(Y,X.features[q],W,q);else Tr(Y,X.type==="Feature"?X:{geometry:X},W);return Y}(A,P);this.tiles={},this.tileCoords=[],E&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",P.indexMaxZoom,P.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),V=function(X,W){const Y=W.buffer/W.extent;let q=X;const ne=vt(X,1,-1-Y,Y,0,-1,2,W),le=vt(X,1,1-Y,2+Y,0,-1,2,W);return(ne||le)&&(q=vt(X,1,-Y,1+Y,0,-1,2,W)||[],ne&&(q=pe(ne,1).concat(q)),le&&(q=q.concat(pe(le,-1)))),q}(V,P),V.length&&this.splitTile(V,0,0,0),E&&(V.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(A,P,E,V,X,W,Y){const q=[A,P,E,V],ne=this.options,le=ne.debug;for(;q.length;){V=q.pop(),E=q.pop(),P=q.pop(),A=q.pop();const te=1<<P,fe=Ei(P,E,V);let De=this.tiles[fe];if(!De&&(le>1&&console.time("creation"),De=this.tiles[fe]=Ir(A,P,E,V,ne),this.tileCoords.push({z:P,x:E,y:V}),le)){le>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",P,E,V,De.numFeatures,De.numPoints,De.numSimplified),console.timeEnd("creation"));const kt=`z${P}`;this.stats[kt]=(this.stats[kt]||0)+1,this.total++}if(De.source=A,X==null){if(P===ne.indexMaxZoom||De.numPoints<=ne.indexMaxPoints)continue}else{if(P===ne.maxZoom||P===X)continue;if(X!=null){const kt=X-P;if(E!==W>>kt||V!==Y>>kt)continue}}if(De.source=null,A.length===0)continue;le>1&&console.time("clipping");const Re=.5*ne.buffer/ne.extent,$e=.5-Re,Ke=.5+Re,Ue=1+Re;let ot=null,bt=null,At=null,Ge=null,tt=vt(A,te,E-Re,E+Ke,0,De.minX,De.maxX,ne),gt=vt(A,te,E+$e,E+Ue,0,De.minX,De.maxX,ne);A=null,tt&&(ot=vt(tt,te,V-Re,V+Ke,1,De.minY,De.maxY,ne),bt=vt(tt,te,V+$e,V+Ue,1,De.minY,De.maxY,ne),tt=null),gt&&(At=vt(gt,te,V-Re,V+Ke,1,De.minY,De.maxY,ne),Ge=vt(gt,te,V+$e,V+Ue,1,De.minY,De.maxY,ne),gt=null),le>1&&console.timeEnd("clipping"),q.push(ot||[],P+1,2*E,2*V),q.push(bt||[],P+1,2*E,2*V+1),q.push(At||[],P+1,2*E+1,2*V),q.push(Ge||[],P+1,2*E+1,2*V+1)}}getTile(A,P,E){A=+A,P=+P,E=+E;const V=this.options,{extent:X,debug:W}=V;if(A<0||A>24)return null;const Y=1<<A,q=Ei(A,P=P+Y&Y-1,E);if(this.tiles[q])return Qt(this.tiles[q],X);W>1&&console.log("drilling down to z%d-%d-%d",A,P,E);let ne,le=A,te=P,fe=E;for(;!ne&&le>0;)le--,te>>=1,fe>>=1,ne=this.tiles[Ei(le,te,fe)];return ne&&ne.source?(W>1&&(console.log("found parent tile z%d-%d-%d",le,te,fe),console.time("drilling down")),this.splitTile(ne.source,le,te,fe,A,P,E),W>1&&console.timeEnd("drilling down"),this.tiles[q]?Qt(this.tiles[q],X):null):null}}function Ei(j,A,P){return 32*((1<<j)*P+A)+j}function je(j,A){return A?j.properties[A]:j.id}function Ji(j,A){if(j==null)return!0;if(j.type==="Feature")return je(j,A)!=null;if(j.type==="FeatureCollection"){const P=new Set;for(const E of j.features){const V=je(E,A);if(V==null||P.has(V))return!1;P.add(V)}return!0}return!1}function hr(j,A){const P=new Map;if(j!=null)if(j.type==="Feature")P.set(je(j,A),j);else for(const E of j.features)P.set(je(E,A),E);return P}class Pr extends me{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(A,P){return L._(this,void 0,void 0,function*(){const E=A.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const V=this._geoJSONIndex.getTile(E.z,E.x,E.y);if(!V)return null;const X=new class{constructor(Y){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=L.X,this.length=Y.length,this._features=Y}feature(Y){return new class{constructor(q){this._feature=q,this.extent=L.X,this.type=q.type,this.properties=q.tags,"id"in q&&!isNaN(q.id)&&(this.id=parseInt(q.id,10))}loadGeometry(){if(this._feature.type===1){const q=[];for(const ne of this._feature.geometry)q.push([new L.P(ne[0],ne[1])]);return q}{const q=[];for(const ne of this._feature.geometry){const le=[];for(const te of ne)le.push(new L.P(te[0],te[1]));q.push(le)}return q}}toGeoJSON(q,ne,le){return vr.call(this,q,ne,le)}}(this._features[Y])}}(V.features);let W=Xi(X);return W.byteOffset===0&&W.byteLength===W.buffer.byteLength||(W=new Uint8Array(W)),{vectorTile:X,rawData:W.buffer}})}loadData(A){return L._(this,void 0,void 0,function*(){var P;(P=this._pendingRequest)===null||P===void 0||P.abort();const E=!!(A&&A.request&&A.request.collectResourceTiming)&&new L.bu(A.request);this._pendingRequest=new AbortController;try{this._pendingData=this.loadAndProcessGeoJSON(A,this._pendingRequest),this._geoJSONIndex=A.cluster?new br(function({superclusterOptions:W,clusterProperties:Y}){if(!Y||!W)return W;const q={},ne={},le={accumulated:null,zoom:0},te={properties:null},fe=Object.keys(Y);for(const De of fe){const[Re,$e]=Y[De],Ke=L.bB($e),Ue=L.bB(typeof Re=="string"?[Re,["accumulated"],["get",De]]:Re);q[De]=Ke.value,ne[De]=Ue.value}return W.map=De=>{te.properties=De;const Re={};for(const $e of fe)Re[$e]=q[$e].evaluate(le,te);return Re},W.reduce=(De,Re)=>{te.properties=Re;for(const $e of fe)le.accumulated=De[$e],De[$e]=ne[$e].evaluate(le,te)},W}(A)).load((yield this._pendingData).features):(V=yield this._pendingData,new si(V,A.geojsonVtOptions)),this.loaded={};const X={};if(E){const W=E.finish();W&&(X.resourceTiming={},X.resourceTiming[A.source]=JSON.parse(JSON.stringify(W)))}return X}catch(X){if(delete this._pendingRequest,L.bA(X))return{abandoned:!0};throw X}var V})}getData(){return L._(this,void 0,void 0,function*(){return this._pendingData})}reloadTile(A){const P=this.loaded;return P&&P[A.uid]?super.reloadTile(A):this.loadTile(A)}loadAndProcessGeoJSON(A,P){return L._(this,void 0,void 0,function*(){let E=yield this.loadGeoJSON(A,P);if(delete this._pendingRequest,typeof E!="object")throw new Error(`Input data given to '${A.source}' is not a valid GeoJSON object.`);if(qi(E,!0),A.filter){const V=L.bB(A.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(V.result==="error")throw new Error(V.value.map(W=>`${W.key}: ${W.message}`).join(", "));E={type:"FeatureCollection",features:E.features.filter(W=>V.value.evaluate({zoom:0},W))}}return E})}loadGeoJSON(A,P){return L._(this,void 0,void 0,function*(){const{promoteId:E}=A;if(A.request){const V=yield L.h(A.request,P);return this._dataUpdateable=Ji(V.data,E)?hr(V.data,E):void 0,V.data}if(typeof A.data=="string")try{const V=JSON.parse(A.data);return this._dataUpdateable=Ji(V,E)?hr(V,E):void 0,V}catch{throw new Error(`Input data given to '${A.source}' is not a valid GeoJSON object.`)}if(!A.dataDiff)throw new Error(`Input data given to '${A.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${A.source}`);return function(V,X,W){var Y,q,ne,le;if(X.removeAll&&V.clear(),X.remove)for(const te of X.remove)V.delete(te);if(X.add)for(const te of X.add){const fe=je(te,W);fe!=null&&V.set(fe,te)}if(X.update)for(const te of X.update){let fe=V.get(te.id);if(fe==null)continue;const De=!te.removeAllProperties&&(((Y=te.removeProperties)===null||Y===void 0?void 0:Y.length)>0||((q=te.addOrUpdateProperties)===null||q===void 0?void 0:q.length)>0);if((te.newGeometry||te.removeAllProperties||De)&&(fe=Object.assign({},fe),V.set(te.id,fe),De&&(fe.properties=Object.assign({},fe.properties))),te.newGeometry&&(fe.geometry=te.newGeometry),te.removeAllProperties)fe.properties={};else if(((ne=te.removeProperties)===null||ne===void 0?void 0:ne.length)>0)for(const Re of te.removeProperties)Object.prototype.hasOwnProperty.call(fe.properties,Re)&&delete fe.properties[Re];if(((le=te.addOrUpdateProperties)===null||le===void 0?void 0:le.length)>0)for(const{key:Re,value:$e}of te.addOrUpdateProperties)fe.properties[Re]=$e}}(this._dataUpdateable,A.dataDiff,E),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}})}removeSource(A){return L._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(A){return this._geoJSONIndex.getClusterExpansionZoom(A.clusterId)}getClusterChildren(A){return this._geoJSONIndex.getChildren(A.clusterId)}getClusterLeaves(A){return this._geoJSONIndex.getLeaves(A.clusterId,A.limit,A.offset)}}class Yi{constructor(A){this.self=A,this.actor=new L.F(A),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(P,E)=>{if(this.externalWorkerSourceTypes[P])throw new Error(`Worker source with name "${P}" already registered.`);this.externalWorkerSourceTypes[P]=E},this.self.addProtocol=L.bh,this.self.removeProtocol=L.bi,this.self.registerRTLTextPlugin=P=>{if(L.bC.isParsed())throw new Error("RTL text plugin already registered.");L.bC.setMethods(P)},this.actor.registerMessageHandler("LDT",(P,E)=>this._getDEMWorkerSource(P,E.source).loadTile(E)),this.actor.registerMessageHandler("RDT",(P,E)=>L._(this,void 0,void 0,function*(){this._getDEMWorkerSource(P,E.source).removeTile(E)})),this.actor.registerMessageHandler("GCEZ",(P,E)=>L._(this,void 0,void 0,function*(){return this._getWorkerSource(P,E.type,E.source).getClusterExpansionZoom(E)})),this.actor.registerMessageHandler("GCC",(P,E)=>L._(this,void 0,void 0,function*(){return this._getWorkerSource(P,E.type,E.source).getClusterChildren(E)})),this.actor.registerMessageHandler("GCL",(P,E)=>L._(this,void 0,void 0,function*(){return this._getWorkerSource(P,E.type,E.source).getClusterLeaves(E)})),this.actor.registerMessageHandler("LD",(P,E)=>this._getWorkerSource(P,E.type,E.source).loadData(E)),this.actor.registerMessageHandler("GD",(P,E)=>this._getWorkerSource(P,E.type,E.source).getData()),this.actor.registerMessageHandler("LT",(P,E)=>this._getWorkerSource(P,E.type,E.source).loadTile(E)),this.actor.registerMessageHandler("RT",(P,E)=>this._getWorkerSource(P,E.type,E.source).reloadTile(E)),this.actor.registerMessageHandler("AT",(P,E)=>this._getWorkerSource(P,E.type,E.source).abortTile(E)),this.actor.registerMessageHandler("RMT",(P,E)=>this._getWorkerSource(P,E.type,E.source).removeTile(E)),this.actor.registerMessageHandler("RS",(P,E)=>L._(this,void 0,void 0,function*(){if(!this.workerSources[P]||!this.workerSources[P][E.type]||!this.workerSources[P][E.type][E.source])return;const V=this.workerSources[P][E.type][E.source];delete this.workerSources[P][E.type][E.source],V.removeSource!==void 0&&V.removeSource(E)})),this.actor.registerMessageHandler("RM",P=>L._(this,void 0,void 0,function*(){delete this.layerIndexes[P],delete this.availableImages[P],delete this.workerSources[P],delete this.demWorkerSources[P]})),this.actor.registerMessageHandler("SR",(P,E)=>L._(this,void 0,void 0,function*(){this.referrer=E})),this.actor.registerMessageHandler("SRPS",(P,E)=>this._syncRTLPluginState(P,E)),this.actor.registerMessageHandler("IS",(P,E)=>L._(this,void 0,void 0,function*(){this.self.importScripts(E)})),this.actor.registerMessageHandler("SI",(P,E)=>this._setImages(P,E)),this.actor.registerMessageHandler("UL",(P,E)=>L._(this,void 0,void 0,function*(){this._getLayerIndex(P).update(E.layers,E.removedIds)})),this.actor.registerMessageHandler("SL",(P,E)=>L._(this,void 0,void 0,function*(){this._getLayerIndex(P).replace(E)}))}_setImages(A,P){return L._(this,void 0,void 0,function*(){this.availableImages[A]=P;for(const E in this.workerSources[A]){const V=this.workerSources[A][E];for(const X in V)V[X].availableImages=P}})}_syncRTLPluginState(A,P){return L._(this,void 0,void 0,function*(){if(L.bC.isParsed())return L.bC.getState();if(P.pluginStatus!=="loading")return L.bC.setState(P),P;const E=P.pluginURL;if(this.self.importScripts(E),L.bC.isParsed()){const V={pluginStatus:"loaded",pluginURL:E};return L.bC.setState(V),V}throw L.bC.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${E}`)})}_getAvailableImages(A){let P=this.availableImages[A];return P||(P=[]),P}_getLayerIndex(A){let P=this.layerIndexes[A];return P||(P=this.layerIndexes[A]=new p),P}_getWorkerSource(A,P,E){if(this.workerSources[A]||(this.workerSources[A]={}),this.workerSources[A][P]||(this.workerSources[A][P]={}),!this.workerSources[A][P][E]){const V={sendAsync:(X,W)=>(X.targetMapId=A,this.actor.sendAsync(X,W))};switch(P){case"vector":this.workerSources[A][P][E]=new me(V,this._getLayerIndex(A),this._getAvailableImages(A));break;case"geojson":this.workerSources[A][P][E]=new Pr(V,this._getLayerIndex(A),this._getAvailableImages(A));break;default:this.workerSources[A][P][E]=new this.externalWorkerSourceTypes[P](V,this._getLayerIndex(A),this._getAvailableImages(A))}}return this.workerSources[A][P][E]}_getDEMWorkerSource(A,P){return this.demWorkerSources[A]||(this.demWorkerSources[A]={}),this.demWorkerSources[A][P]||(this.demWorkerSources[A][P]=new se),this.demWorkerSources[A][P]}}return L.i(self)&&(self.worker=new Yi(self)),Yi}),Do("index",["exports","./shared"],function(L,p){var Ti="4.5.0";let $i,Jt;const me={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frameAsync:h=>new Promise((t,n)=>{const a=requestAnimationFrame(t);h.signal.addEventListener("abort",()=>{cancelAnimationFrame(a),n(p.c())})}),getImageData(h,t=0){return this.getImageCanvasContext(h).getImageData(-t,-t,h.width+2*t,h.height+2*t)},getImageCanvasContext(h){const t=window.document.createElement("canvas"),n=t.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return t.width=h.width,t.height=h.height,n.drawImage(h,0,0,h.width,h.height),n},resolveURL:h=>($i||($i=document.createElement("a")),$i.href=h,$i.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(Jt==null&&(Jt=matchMedia("(prefers-reduced-motion: reduce)")),Jt.matches)}};class se{static testProp(t){if(!se.docStyle)return t[0];for(let n=0;n<t.length;n++)if(t[n]in se.docStyle)return t[n];return t[0]}static create(t,n,a){const l=window.document.createElement(t);return n!==void 0&&(l.className=n),a&&a.appendChild(l),l}static createNS(t,n){return window.document.createElementNS(t,n)}static disableDrag(){se.docStyle&&se.selectProp&&(se.userSelect=se.docStyle[se.selectProp],se.docStyle[se.selectProp]="none")}static enableDrag(){se.docStyle&&se.selectProp&&(se.docStyle[se.selectProp]=se.userSelect)}static setTransform(t,n){t.style[se.transformProp]=n}static addEventListener(t,n,a,l={}){t.addEventListener(n,a,"passive"in l?l:l.capture)}static removeEventListener(t,n,a,l={}){t.removeEventListener(n,a,"passive"in l?l:l.capture)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",se.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",se.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",se.suppressClickInternal,!0)},0)}static getScale(t){const n=t.getBoundingClientRect();return{x:n.width/t.offsetWidth||1,y:n.height/t.offsetHeight||1,boundingClientRect:n}}static getPoint(t,n,a){const l=n.boundingClientRect;return new p.P((a.clientX-l.left)/n.x-t.clientLeft,(a.clientY-l.top)/n.y-t.clientTop)}static mousePos(t,n){const a=se.getScale(t);return se.getPoint(t,a,n)}static touchPos(t,n){const a=[],l=se.getScale(t);for(let u=0;u<n.length;u++)a.push(se.getPoint(t,l,n[u]));return a}static mouseButton(t){return t.button}static remove(t){t.parentNode&&t.parentNode.removeChild(t)}}se.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,se.selectProp=se.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),se.transformProp=se.testProp(["transform","WebkitTransform"]);const Nr={supported:!1,testSupport:function(h){!vr&&qi&&(sr?Rn(h):xr=h)}};let xr,qi,vr=!1,sr=!1;function Rn(h){const t=h.createTexture();h.bindTexture(h.TEXTURE_2D,t);try{if(h.texImage2D(h.TEXTURE_2D,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,qi),h.isContextLost())return;Nr.supported=!0}catch{}h.deleteTexture(t),vr=!0}var pi;typeof document<"u"&&(qi=document.createElement("img"),qi.onload=()=>{xr&&Rn(xr),xr=null,sr=!0},qi.onerror=()=>{vr=!0,xr=null},qi.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(h){let t,n,a,l;h.resetRequestQueue=()=>{t=[],n=0,a=0,l={}},h.addThrottleControl=y=>{const v=a++;return l[v]=y,v},h.removeThrottleControl=y=>{delete l[y],m()},h.getImage=(y,v,S=!0)=>new Promise((T,M)=>{Nr.supported&&(y.headers||(y.headers={}),y.headers.accept="image/webp,*/*"),p.e(y,{type:"image"}),t.push({abortController:v,requestParameters:y,supportImageRefresh:S,state:"queued",onError:z=>{M(z)},onSuccess:z=>{T(z)}}),m()});const u=y=>p._(this,void 0,void 0,function*(){y.state="running";const{requestParameters:v,supportImageRefresh:S,onError:T,onSuccess:M,abortController:z}=y,R=S===!1&&!p.i(self)&&!p.g(v.url)&&(!v.headers||Object.keys(v.headers).reduce((U,G)=>U&&G==="accept",!0));n++;const N=R?g(v,z):p.m(v,z);try{const U=yield N;delete y.abortController,y.state="completed",U.data instanceof HTMLImageElement||p.b(U.data)?M(U):U.data&&M({data:yield(B=U.data,typeof createImageBitmap=="function"?p.d(B):p.f(B)),cacheControl:U.cacheControl,expires:U.expires})}catch(U){delete y.abortController,T(U)}finally{n--,m()}var B}),m=()=>{const y=(()=>{for(const v of Object.keys(l))if(l[v]())return!0;return!1})()?p.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:p.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let v=n;v<y&&t.length>0;v++){const S=t.shift();S.abortController.signal.aborted?v--:u(S)}},g=(y,v)=>new Promise((S,T)=>{const M=new Image,z=y.url,R=y.credentials;R&&R==="include"?M.crossOrigin="use-credentials":(R&&R==="same-origin"||!p.s(z))&&(M.crossOrigin="anonymous"),v.signal.addEventListener("abort",()=>{M.src="",T(p.c())}),M.fetchPriority="high",M.onload=()=>{M.onerror=M.onload=null,S({data:M})},M.onerror=()=>{M.onerror=M.onload=null,v.signal.aborted||T(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},M.src=z})}(pi||(pi={})),pi.resetRequestQueue();class ma{constructor(t){this._transformRequestFn=t}transformRequest(t,n){return this._transformRequestFn&&this._transformRequestFn(t,n)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}}function Mi(h){var t=new p.A(3);return t[0]=h[0],t[1]=h[1],t[2]=h[2],t}var Zi,Si=function(h,t,n){return h[0]=t[0]-n[0],h[1]=t[1]-n[1],h[2]=t[2]-n[2],h};Zi=new p.A(3),p.A!=Float32Array&&(Zi[0]=0,Zi[1]=0,Zi[2]=0);var ys=function(h){var t=h[0],n=h[1];return t*t+n*n};function Gi(h){const t=[];if(typeof h=="string")t.push({id:"default",url:h});else if(h&&h.length>0){const n=[];for(const{id:a,url:l}of h){const u=`${a}${l}`;n.indexOf(u)===-1&&(n.push(u),t.push({id:a,url:l}))}}return t}function Bn(h,t,n){const a=h.split("?");return a[0]+=`${t}${n}`,a.join("?")}(function(){var h=new p.A(2);p.A!=Float32Array&&(h[0]=0,h[1]=0)})();class rt{constructor(t,n,a,l){this.context=t,this.format=a,this.texture=t.gl.createTexture(),this.update(n,l)}update(t,n,a){const{width:l,height:u}=t,m=!(this.size&&this.size[0]===l&&this.size[1]===u||a),{context:g}=this,{gl:y}=g;if(this.useMipmap=!!(n&&n.useMipmap),y.bindTexture(y.TEXTURE_2D,this.texture),g.pixelStoreUnpackFlipY.set(!1),g.pixelStoreUnpack.set(1),g.pixelStoreUnpackPremultiplyAlpha.set(this.format===y.RGBA&&(!n||n.premultiply!==!1)),m)this.size=[l,u],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||p.b(t)?y.texImage2D(y.TEXTURE_2D,0,this.format,this.format,y.UNSIGNED_BYTE,t):y.texImage2D(y.TEXTURE_2D,0,this.format,l,u,0,this.format,y.UNSIGNED_BYTE,t.data);else{const{x:v,y:S}=a||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||p.b(t)?y.texSubImage2D(y.TEXTURE_2D,0,v,S,y.RGBA,y.UNSIGNED_BYTE,t):y.texSubImage2D(y.TEXTURE_2D,0,v,S,l,u,y.RGBA,y.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&y.generateMipmap(y.TEXTURE_2D)}bind(t,n,a){const{context:l}=this,{gl:u}=l;u.bindTexture(u.TEXTURE_2D,this.texture),a!==u.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(a=u.LINEAR),t!==this.filter&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,t),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,a||t),this.filter=t),n!==this.wrap&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,n),u.texParameteri(u.TEXTURE_2D,u.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 xs(h){const{userImage:t}=h;return!!(t&&t.render&&t.render())&&(h.data.replace(new Uint8Array(t.data.buffer)),!0)}class Ot extends p.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new p.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:n,promiseResolve:a}of this.requestors)a(this._getImagesForIds(n));this.requestors=[]}}getImage(t){const n=this.images[t];if(n&&!n.data&&n.spriteData){const a=n.spriteData;n.data=new p.R({width:a.width,height:a.height},a.context.getImageData(a.x,a.y,a.width,a.height).data),n.spriteData=null}return n}addImage(t,n){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,n)&&(this.images[t]=n)}_validate(t,n){let a=!0;const l=n.data||n.spriteData;return this._validateStretch(n.stretchX,l&&l.width)||(this.fire(new p.j(new Error(`Image "${t}" has invalid "stretchX" value`))),a=!1),this._validateStretch(n.stretchY,l&&l.height)||(this.fire(new p.j(new Error(`Image "${t}" has invalid "stretchY" value`))),a=!1),this._validateContent(n.content,n)||(this.fire(new p.j(new Error(`Image "${t}" has invalid "content" value`))),a=!1),a}_validateStretch(t,n){if(!t)return!0;let a=0;for(const l of t){if(l[0]<a||l[1]<l[0]||n<l[1])return!1;a=l[1]}return!0}_validateContent(t,n){if(!t)return!0;if(t.length!==4)return!1;const a=n.spriteData,l=a&&a.width||n.data.width,u=a&&a.height||n.data.height;return!(t[0]<0||l<t[0]||t[1]<0||u<t[1]||t[2]<0||l<t[2]||t[3]<0||u<t[3]||t[2]<t[0]||t[3]<t[1])}updateImage(t,n,a=!0){const l=this.getImage(t);if(a&&(l.data.width!==n.data.width||l.data.height!==n.data.height))throw new Error(`size mismatch between old image (${l.data.width}x${l.data.height}) and new image (${n.data.width}x${n.data.height}).`);n.version=l.version+1,this.images[t]=n,this.updatedImages[t]=!0}removeImage(t){const n=this.images[t];delete this.images[t],delete this.patterns[t],n.userImage&&n.userImage.onRemove&&n.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t){return new Promise((n,a)=>{let l=!0;if(!this.isLoaded())for(const u of t)this.images[u]||(l=!1);this.isLoaded()||l?n(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:n})})}_getImagesForIds(t){const n={};for(const a of t){let l=this.getImage(a);l||(this.fire(new p.k("styleimagemissing",{id:a})),l=this.getImage(a)),l?n[a]={data:l.data.clone(),pixelRatio:l.pixelRatio,sdf:l.sdf,version:l.version,stretchX:l.stretchX,stretchY:l.stretchY,content:l.content,textFitWidth:l.textFitWidth,textFitHeight:l.textFitHeight,hasRenderCallback:!!(l.userImage&&l.userImage.render)}:p.w(`Image "${a}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return n}getPixelSize(){const{width:t,height:n}=this.atlasImage;return{width:t,height:n}}getPattern(t){const n=this.patterns[t],a=this.getImage(t);if(!a)return null;if(n&&n.position.version===a.version)return n.position;if(n)n.position.version=a.version;else{const l={w:a.data.width+2,h:a.data.height+2,x:0,y:0},u=new p.I(l,a);this.patterns[t]={bin:l,position:u}}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 rt(t,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const u in this.patterns)t.push(this.patterns[u].bin);const{w:n,h:a}=p.p(t),l=this.atlasImage;l.resize({width:n||1,height:a||1});for(const u in this.patterns){const{bin:m}=this.patterns[u],g=m.x+1,y=m.y+1,v=this.getImage(u).data,S=v.width,T=v.height;p.R.copy(v,l,{x:0,y:0},{x:g,y},{width:S,height:T}),p.R.copy(v,l,{x:0,y:T-1},{x:g,y:y-1},{width:S,height:1}),p.R.copy(v,l,{x:0,y:0},{x:g,y:y+T},{width:S,height:1}),p.R.copy(v,l,{x:S-1,y:0},{x:g-1,y},{width:1,height:T}),p.R.copy(v,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 a=this.getImage(n);a||p.w(`Image with ID: "${n}" was not found`),xs(a)&&this.updateImage(n,a)}}}const Yt=1e20;function ar(h,t,n,a,l,u,m,g,y){for(let v=t;v<t+a;v++)ln(h,n*u+v,u,l,m,g,y);for(let v=n;v<n+l;v++)ln(h,v*u+t,1,a,m,g,y)}function ln(h,t,n,a,l,u,m){u[0]=0,m[0]=-Yt,m[1]=Yt,l[0]=h[t];for(let g=1,y=0,v=0;g<a;g++){l[g]=h[t+g*n];const S=g*g;do{const T=u[y];v=(l[g]-l[T]+S-T*T)/(g-T)/2}while(v<=m[y]&&--y>-1);y++,u[y]=g,m[y]=v,m[y+1]=Yt}for(let g=0,y=0;g<a;g++){for(;m[y+1]<g;)y++;const v=u[y],S=g-v;h[t+g*n]=l[v]+S*S}}class Xi{constructor(t,n){this.requestManager=t,this.localIdeographFontFamily=n,this.entries={}}setURL(t){this.url=t}getGlyphs(t){return p._(this,void 0,void 0,function*(){const n=[];for(const u in t)for(const m of t[u])n.push(this._getAndCacheGlyphsPromise(u,m));const a=yield Promise.all(n),l={};for(const{stack:u,id:m,glyph:g}of a)l[u]||(l[u]={}),l[u][m]=g&&{id:g.id,bitmap:g.bitmap.clone(),metrics:g.metrics};return l})}_getAndCacheGlyphsPromise(t,n){return p._(this,void 0,void 0,function*(){let a=this.entries[t];a||(a=this.entries[t]={glyphs:{},requests:{},ranges:{}});let l=a.glyphs[n];if(l!==void 0)return{stack:t,id:n,glyph:l};if(l=this._tinySDF(a,t,n),l)return a.glyphs[n]=l,{stack:t,id:n,glyph:l};const u=Math.floor(n/256);if(256*u>65535)throw new Error("glyphs > 65535 not supported");if(a.ranges[u])return{stack:t,id:n,glyph:l};if(!this.url)throw new Error("glyphsUrl is not set");if(!a.requests[u]){const g=Xi.loadGlyphRange(t,u,this.url,this.requestManager);a.requests[u]=g}const m=yield a.requests[u];for(const g in m)this._doesCharSupportLocalGlyph(+g)||(a.glyphs[+g]=m[+g]);return a.ranges[u]=!0,{stack:t,id:n,glyph:m[n]||null}})}_doesCharSupportLocalGlyph(t){return!!this.localIdeographFontFamily&&(p.u["CJK Unified Ideographs"](t)||p.u["Hangul Syllables"](t)||p.u.Hiragana(t)||p.u.Katakana(t))}_tinySDF(t,n,a){const l=this.localIdeographFontFamily;if(!l||!this._doesCharSupportLocalGlyph(a))return;let u=t.tinySDF;if(!u){let g="400";/bold/i.test(n)?g="900":/medium/i.test(n)?g="500":/light/i.test(n)&&(g="200"),u=t.tinySDF=new Xi.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:l,fontWeight:g})}const m=u.draw(String.fromCharCode(a));return{id:a,bitmap:new p.o({width:m.width||60,height:m.height||60},m.data),metrics:{width:m.glyphWidth/2||24,height:m.glyphHeight/2||24,left:m.glyphLeft/2+.5||0,top:m.glyphTop/2-27.5||-8,advance:m.glyphAdvance/2||24,isDoubleResolution:!0}}}}Xi.loadGlyphRange=function(h,t,n,a){return p._(this,void 0,void 0,function*(){const l=256*t,u=l+255,m=a.transformRequest(n.replace("{fontstack}",h).replace("{range}",`${l}-${u}`),"Glyphs"),g=yield p.l(m,new AbortController);if(!g||!g.data)throw new Error(`Could not load glyph range. range: ${t}, ${l}-${u}`);const y={};for(const v of p.n(g.data))y[v.id]=v;return y})},Xi.TinySDF=class{constructor({fontSize:h=24,buffer:t=3,radius:n=8,cutoff:a=.25,fontFamily:l="sans-serif",fontWeight:u="normal",fontStyle:m="normal"}={}){this.buffer=t,this.cutoff=a,this.radius=n;const g=this.size=h+4*t,y=this._createCanvas(g),v=this.ctx=y.getContext("2d",{willReadFrequently:!0});v.font=`${m} ${u} ${h}px ${l}`,v.textBaseline="alphabetic",v.textAlign="left",v.fillStyle="black",this.gridOuter=new Float64Array(g*g),this.gridInner=new Float64Array(g*g),this.f=new Float64Array(g),this.z=new Float64Array(g+1),this.v=new Uint16Array(g)}_createCanvas(h){const t=document.createElement("canvas");return t.width=t.height=h,t}draw(h){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:a,actualBoundingBoxLeft:l,actualBoundingBoxRight:u}=this.ctx.measureText(h),m=Math.ceil(n),g=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(u-l))),y=Math.min(this.size-this.buffer,m+Math.ceil(a)),v=g+2*this.buffer,S=y+2*this.buffer,T=Math.max(v*S,0),M=new Uint8ClampedArray(T),z={data:M,width:v,height:S,glyphWidth:g,glyphHeight:y,glyphTop:m,glyphLeft:0,glyphAdvance:t};if(g===0||y===0)return z;const{ctx:R,buffer:N,gridInner:B,gridOuter:U}=this;R.clearRect(N,N,g,y),R.fillText(h,N,N+m);const G=R.getImageData(N,N,g,y);U.fill(Yt,0,T),B.fill(0,0,T);for(let O=0;O<y;O++)for(let H=0;H<g;H++){const Q=G.data[4*(O*g+H)+3]/255;if(Q===0)continue;const ee=(O+N)*v+H+N;if(Q===1)U[ee]=0,B[ee]=Yt;else{const oe=.5-Q;U[ee]=oe>0?oe*oe:0,B[ee]=oe<0?oe*oe:0}}ar(U,0,0,v,S,v,this.f,this.v,this.z),ar(B,N,N,g,y,v,this.f,this.v,this.z);for(let O=0;O<T;O++){const H=Math.sqrt(U[O])-Math.sqrt(B[O]);M[O]=Math.round(255-255*(H/this.radius+this.cutoff))}return z}};class vs{constructor(){this.specification=p.v.light.position}possiblyEvaluate(t,n){return p.y(t.expression.evaluate(n))}interpolate(t,n,a){return{x:p.z.number(t.x,n.x,a),y:p.z.number(t.y,n.y,a),z:p.z.number(t.z,n.z,a)}}}let jr;class or extends p.E{constructor(t){super(),jr=jr||new p.q({anchor:new p.D(p.v.light.anchor),position:new vs,color:new p.D(p.v.light.color),intensity:new p.D(p.v.light.intensity)}),this._transitionable=new p.T(jr),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,n={}){if(!this._validate(p.r,t,n))for(const a in t){const l=t[a];a.endsWith("-transition")?this._transitionable.setTransition(a.slice(0,-11),l):this._transitionable.setValue(a,l)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,n,a){return(!a||a.validate!==!1)&&p.t(this,t.call(p.x,{value:n,style:{glyphs:!0,sprite:!0},styleSpec:p.v}))}}const ni=new p.q({"sky-color":new p.D(p.v.sky["sky-color"]),"horizon-color":new p.D(p.v.sky["horizon-color"]),"fog-color":new p.D(p.v.sky["fog-color"]),"fog-ground-blend":new p.D(p.v.sky["fog-ground-blend"]),"horizon-fog-blend":new p.D(p.v.sky["horizon-fog-blend"]),"sky-horizon-blend":new p.D(p.v.sky["sky-horizon-blend"]),"atmosphere-blend":new p.D(p.v.sky["atmosphere-blend"])});class ki extends p.E{constructor(t){super(),this._transitionable=new p.T(ni),this.setSky(t),this._transitioning=this._transitionable.untransitioned()}setSky(t,n={}){if(!this._validate(p.B,t,n))for(const a in t){const l=t[a];a.endsWith("-transition")?this._transitionable.setTransition(a.slice(0,-11),l):this._transitionable.setValue(a,l)}}getSky(){return this._transitionable.serialize()}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,n,a={}){return(a==null?void 0:a.validate)!==!1&&p.t(this,t.call(p.x,p.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:p.v})))}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}}class cn{constructor(t,n){this.width=t,this.height=n,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,n){const a=t.join(",")+String(n);return this.dashEntry[a]||(this.dashEntry[a]=this.addDash(t,n)),this.dashEntry[a]}getDashRanges(t,n,a){const l=[];let u=t.length%2==1?-t[t.length-1]*a:0,m=t[0]*a,g=!0;l.push({left:u,right:m,isDash:g,zeroLength:t[0]===0});let y=t[0];for(let v=1;v<t.length;v++){g=!g;const S=t[v];u=y*a,y+=S,m=y*a,l.push({left:u,right:m,isDash:g,zeroLength:S===0})}return l}addRoundDash(t,n,a){const l=n/2;for(let u=-a;u<=a;u++){const m=this.width*(this.nextRow+a+u);let g=0,y=t[g];for(let v=0;v<this.width;v++){v/y.right>1&&(y=t[++g]);const S=Math.abs(v-y.left),T=Math.abs(v-y.right),M=Math.min(S,T);let z;const R=u/a*(l+1);if(y.isDash){const N=l-Math.abs(R);z=Math.sqrt(M*M+N*N)}else z=l-Math.sqrt(M*M+R*R);this.data[m+v]=Math.max(0,Math.min(255,z+128))}}}addRegularDash(t){for(let g=t.length-1;g>=0;--g){const y=t[g],v=t[g+1];y.zeroLength?t.splice(g,1):v&&v.isDash===y.isDash&&(v.left=y.left,t.splice(g,1))}const n=t[0],a=t[t.length-1];n.isDash===a.isDash&&(n.left=a.left-this.width,a.right=n.right+this.width);const l=this.width*this.nextRow;let u=0,m=t[u];for(let g=0;g<this.width;g++){g/m.right>1&&(m=t[++u]);const y=Math.abs(g-m.left),v=Math.abs(g-m.right),S=Math.min(y,v);this.data[l+g]=Math.max(0,Math.min(255,(m.isDash?S:-S)+128))}}addDash(t,n){const a=n?7:0,l=2*a+1;if(this.nextRow+l>this.height)return p.w("LineAtlas out of space"),null;let u=0;for(let g=0;g<t.length;g++)u+=t[g];if(u!==0){const g=this.width/u,y=this.getDashRanges(t,this.width,g);n?this.addRoundDash(y,g,a):this.addRegularDash(y)}const m={y:(this.nextRow+a+.5)/this.height,height:2*a/this.height,width:u};return this.nextRow+=l,this.dirty=!0,m}bind(t){const n=t.gl;this.texture?(n.bindTexture(n.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,n.texSubImage2D(n.TEXTURE_2D,0,0,0,this.width,this.height,n.ALPHA,n.UNSIGNED_BYTE,this.data))):(this.texture=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this.texture),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texImage2D(n.TEXTURE_2D,0,n.ALPHA,this.width,this.height,0,n.ALPHA,n.UNSIGNED_BYTE,this.data))}}const br="maplibre_preloaded_worker_pool";class Wi{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<Wi.workerCount;)this.workers.push(new Worker(p.a.WORKER_URL));return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],this.numActive()===0&&(this.workers.forEach(n=>{n.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[br]}numActive(){return Object.keys(this.active).length}}const hn=Math.floor(me.hardwareConcurrency/2);let fi,zi;function Ur(){return fi||(fi=new Wi),fi}Wi.workerCount=p.C(globalThis)?Math.max(Math.min(hn,3),1):1;class $r{constructor(t,n){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=n;const a=this.workerPool.acquire(n);for(let l=0;l<a.length;l++){const u=new p.F(a[l],n);u.name=`Worker ${l}`,this.actors.push(u)}if(!this.actors.length)throw new Error("No actors found")}broadcast(t,n){const a=[];for(const l of this.actors)a.push(l.sendAsync({type:t,data:n}));return Promise.all(a)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.actors.forEach(n=>{n.remove()}),this.actors=[],t&&this.workerPool.release(this.id)}registerMessageHandler(t,n){for(const a of this.actors)a.registerMessageHandler(t,n)}}function Fn(){return zi||(zi=new $r(Ur(),p.G),zi.registerMessageHandler("GR",(h,t,n)=>p.m(t,n))),zi}function lr(h,t){const n=p.H();return p.J(n,n,[1,1,0]),p.K(n,n,[.5*h.width,.5*h.height,1]),p.L(n,n,h.calculatePosMatrix(t.toUnwrapped()))}function wr(h,t,n,a,l,u){const m=function(T,M,z){if(T)for(const R of T){const N=M[R];if(N&&N.source===z&&N.type==="fill-extrusion")return!0}else for(const R in M){const N=M[R];if(N.source===z&&N.type==="fill-extrusion")return!0}return!1}(l&&l.layers,t,h.id),g=u.maxPitchScaleFactor(),y=h.tilesIn(a,g,m);y.sort(Tr);const v=[];for(const T of y)v.push({wrappedTileID:T.tileID.wrapped().key,queryResults:T.tile.queryRenderedFeatures(t,n,h._state,T.queryGeometry,T.cameraQueryGeometry,T.scale,l,u,g,lr(h.transform,T.tileID))});const S=function(T){const M={},z={};for(const R of T){const N=R.queryResults,B=R.wrappedTileID,U=z[B]=z[B]||{};for(const G in N){const O=N[G],H=U[G]=U[G]||{},Q=M[G]=M[G]||[];for(const ee of O)H[ee.featureIndex]||(H[ee.featureIndex]=!0,Q.push(ee))}}return M}(v);for(const T in S)S[T].forEach(M=>{const z=M.feature,R=h.getFeatureState(z.layer["source-layer"],z.id);z.source=z.layer.source,z.layer["source-layer"]&&(z.sourceLayer=z.layer["source-layer"]),z.state=R});return S}function Tr(h,t){const n=h.tileID,a=t.tileID;return n.overscaledZ-a.overscaledZ||n.canonical.y-a.canonical.y||n.wrap-a.wrap||n.canonical.x-a.canonical.x}function un(h,t,n){return p._(this,void 0,void 0,function*(){let a=h;if(h.url?a=(yield p.h(t.transformRequest(h.url,"Source"),n)).data:yield me.frameAsync(n),!a)return null;const l=p.M(p.e(a,h),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in a&&a.vector_layers&&(l.vectorLayerIds=a.vector_layers.map(u=>u.id)),l})}class re{constructor(t,n){t&&(n?this.setSouthWest(t).setNorthEast(n):Array.isArray(t)&&(t.length===4?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof p.N?new p.N(t.lng,t.lat):p.N.convert(t),this}setSouthWest(t){return this._sw=t instanceof p.N?new p.N(t.lng,t.lat):p.N.convert(t),this}extend(t){const n=this._sw,a=this._ne;let l,u;if(t instanceof p.N)l=t,u=t;else{if(!(t instanceof re))return Array.isArray(t)?t.length===4||t.every(Array.isArray)?this.extend(re.convert(t)):this.extend(p.N.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(p.N.convert(t)):this;if(l=t._sw,u=t._ne,!l||!u)return this}return n||a?(n.lng=Math.min(l.lng,n.lng),n.lat=Math.min(l.lat,n.lat),a.lng=Math.max(u.lng,a.lng),a.lat=Math.max(u.lat,a.lat)):(this._sw=new p.N(l.lng,l.lat),this._ne=new p.N(u.lng,u.lat)),this}getCenter(){return new p.N((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new p.N(this.getWest(),this.getNorth())}getSouthEast(){return new p.N(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:n,lat:a}=p.N.convert(t);let l=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(l=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=a&&a<=this._ne.lat&&l}static convert(t){return t instanceof re?t:t&&new re(t)}static fromLngLat(t,n=0){const a=360*n/40075017,l=a/Math.cos(Math.PI/180*t.lat);return new re(new p.N(t.lng-l,t.lat-a),new p.N(t.lng+l,t.lat+a))}}class qr{constructor(t,n,a){this.bounds=re.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=a||24}validateBounds(t){return Array.isArray(t)&&t.length===4?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const n=Math.pow(2,t.z),a=Math.floor(p.O(this.bounds.getWest())*n),l=Math.floor(p.Q(this.bounds.getNorth())*n),u=Math.ceil(p.O(this.bounds.getEast())*n),m=Math.ceil(p.Q(this.bounds.getSouth())*n);return t.x>=a&&t.x<u&&t.y>=l&&t.y<m}}class On extends p.E{constructor(t,n,a,l){if(super(),this.id=t,this.dispatcher=a,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,p.e(this,p.M(n,["url","scheme","tileSize","promoteId"])),this._options=p.e({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(l)}load(){return p._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new p.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const t=yield un(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),t&&(p.e(this,t),t.bounds&&(this.tileBounds=new qr(t.bounds,this.minzoom,this.maxzoom)),this.fire(new p.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new p.k("data",{dataType:"source",sourceDataType:"content"})))}catch(t){this._tileJSONRequest=null,this.fire(new p.j(t))}})}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.abort(),t(),this.load()}setTiles(t){return this.setSourceProperty(()=>{this._options.tiles=t}),this}setUrl(t){return this.setSourceProperty(()=>{this.url=t,this._options.url=t}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return p.e({},this._options)}loadTile(t){return p._(this,void 0,void 0,function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a={request:this.map._requestManager.transformRequest(n,"Tile"),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};a.request.collectResourceTiming=this._collectResourceTiming;let l="RT";if(t.actor&&t.state!=="expired"){if(t.state==="loading")return new Promise((u,m)=>{t.reloadPromise={resolve:u,reject:m}})}else t.actor=this.dispatcher.getActor(),l="LT";t.abortController=new AbortController;try{const u=yield t.actor.sendAsync({type:l,data:a},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,u)}catch(u){if(delete t.abortController,t.aborted)return;if(u&&u.status!==404)throw u;this._afterTileLoadWorkerResponse(t,null)}})}_afterTileLoadWorkerResponse(t,n){if(n&&n.resourceTiming&&(t.resourceTiming=n.resourceTiming),n&&this.map._refreshExpiredTiles&&t.setExpiryData(n),t.loadVectorData(n,this.map.painter),t.reloadPromise){const a=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(a.resolve).catch(a.reject)}}abortTile(t){return p._(this,void 0,void 0,function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&(yield t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.type,source:this.id}}))})}unloadTile(t){return p._(this,void 0,void 0,function*(){t.unloadVectorData(),t.actor&&(yield t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}}))})}hasTransition(){return!1}}class Qe extends p.E{constructor(t,n,a,l){super(),this.id=t,this.dispatcher=a,this.setEventedParent(l),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=p.e({type:"raster"},n),p.e(this,p.M(n,["url","scheme","tileSize"]))}load(){return p._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new p.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const t=yield un(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,t&&(p.e(this,t),t.bounds&&(this.tileBounds=new qr(t.bounds,this.minzoom,this.maxzoom)),this.fire(new p.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new p.k("data",{dataType:"source",sourceDataType:"content"})))}catch(t){this._tileJSONRequest=null,this.fire(new p.j(t))}})}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),t(),this.load()}setTiles(t){return this.setSourceProperty(()=>{this._options.tiles=t}),this}setUrl(t){return this.setSourceProperty(()=>{this.url=t,this._options.url=t}),this}serialize(){return p.e({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t){return p._(this,void 0,void 0,function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.abortController=new AbortController;try{const a=yield pi.getImage(this.map._requestManager.transformRequest(n,"Tile"),t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(a&&a.data){this.map._refreshExpiredTiles&&a.cacheControl&&a.expires&&t.setExpiryData({cacheControl:a.cacheControl,expires:a.expires});const l=this.map.painter.context,u=l.gl,m=a.data;t.texture=this.map.painter.getTileTexture(m.width),t.texture?t.texture.update(m,{useMipmap:!0}):(t.texture=new rt(l,m,u.RGBA,{useMipmap:!0}),t.texture.bind(u.LINEAR,u.CLAMP_TO_EDGE,u.LINEAR_MIPMAP_NEAREST),l.extTextureFilterAnisotropic&&u.texParameterf(u.TEXTURE_2D,l.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,l.extTextureFilterAnisotropicMax)),t.state="loaded"}}catch(a){if(delete t.abortController,t.aborted)t.state="unloaded";else if(a)throw t.state="errored",a}})}abortTile(t){return p._(this,void 0,void 0,function*(){t.abortController&&(t.abortController.abort(),delete t.abortController)})}unloadTile(t){return p._(this,void 0,void 0,function*(){t.texture&&this.map.painter.saveTileTexture(t.texture)})}hasTransition(){return!1}}class vt extends Qe{constructor(t,n,a,l){super(t,n,a,l),this.type="raster-dem",this.maxzoom=22,this._options=p.e({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox",this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(t){return p._(this,void 0,void 0,function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a=this.map._requestManager.transformRequest(n,"Tile");t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{const l=yield pi.getImage(a,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(l&&l.data){const u=l.data;this.map._refreshExpiredTiles&&l.cacheControl&&l.expires&&t.setExpiryData({cacheControl:l.cacheControl,expires:l.expires});const m=p.b(u)&&p.U()?u:yield this.readImageNow(u),g={type:this.type,uid:t.uid,source:this.id,rawImageData:m,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!t.actor||t.state==="expired"){t.actor=this.dispatcher.getActor();const y=yield t.actor.sendAsync({type:"LDT",data:g});t.dem=y,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded"}}}catch(l){if(delete t.abortController,t.aborted)t.state="unloaded";else if(l)throw t.state="errored",l}})}readImageNow(t){return p._(this,void 0,void 0,function*(){if(typeof VideoFrame<"u"&&p.V()){const n=t.width+2,a=t.height+2;try{return new p.R({width:n,height:a},yield p.W(t,-1,-1,n,a))}catch{}}return me.getImageData(t,1)})}_getNeighboringTiles(t){const n=t.canonical,a=Math.pow(2,n.z),l=(n.x-1+a)%a,u=n.x===0?t.wrap-1:t.wrap,m=(n.x+1+a)%a,g=n.x+1===a?t.wrap+1:t.wrap,y={};return y[new p.S(t.overscaledZ,u,n.z,l,n.y).key]={backfilled:!1},y[new p.S(t.overscaledZ,g,n.z,m,n.y).key]={backfilled:!1},n.y>0&&(y[new p.S(t.overscaledZ,u,n.z,l,n.y-1).key]={backfilled:!1},y[new p.S(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},y[new p.S(t.overscaledZ,g,n.z,m,n.y-1).key]={backfilled:!1}),n.y+1<a&&(y[new p.S(t.overscaledZ,u,n.z,l,n.y+1).key]={backfilled:!1},y[new p.S(t.overscaledZ,t.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},y[new p.S(t.overscaledZ,g,n.z,m,n.y+1).key]={backfilled:!1}),y}unloadTile(t){return p._(this,void 0,void 0,function*(){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded",t.actor&&(yield t.actor.sendAsync({type:"RDT",data:{type:this.type,uid:t.uid,source:this.id}}))})}}class Vn extends p.E{constructor(t,n,a,l){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._pendingLoads=0,this.actor=a.getActor(),this.setEventedParent(l),this._data=n.data,this._options=p.e({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId;const u=p.X/this.tileSize;this.workerOptions=p.e({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:(n.buffer!==void 0?n.buffer:128)*u,tolerance:(n.tolerance!==void 0?n.tolerance:.375)*u,extent:p.X,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:p.X,radius:(n.clusterRadius||50)*u,log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}load(){return p._(this,void 0,void 0,function*(){yield 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}getData(){return p._(this,void 0,void 0,function*(){const t=p.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:t})})}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){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:t,source:this.id}})}getClusterChildren(t){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:t,source:this.id}})}getClusterLeaves(t,n,a){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:t,limit:n,offset:a}})}_updateWorkerData(t){return p._(this,void 0,void 0,function*(){const n=p.e({type:this.type},this.workerOptions);t?n.dataDiff=t:typeof this._data=="string"?(n.request=this.map._requestManager.transformRequest(me.resolveURL(this._data),"Source"),n.request.collectResourceTiming=this._collectResourceTiming):n.data=JSON.stringify(this._data),this._pendingLoads++,this.fire(new p.k("dataloading",{dataType:"source"}));try{const a=yield this.actor.sendAsync({type:"LD",data:n});if(this._pendingLoads--,this._removed||a.abandoned)return void this.fire(new p.k("dataabort",{dataType:"source"}));let l=null;a.resourceTiming&&a.resourceTiming[this.id]&&(l=a.resourceTiming[this.id].slice(0));const u={dataType:"source"};this._collectResourceTiming&&l&&l.length>0&&p.e(u,{resourceTiming:l}),this.fire(new p.k("data",Object.assign(Object.assign({},u),{sourceDataType:"metadata"}))),this.fire(new p.k("data",Object.assign(Object.assign({},u),{sourceDataType:"content"})))}catch(a){if(this._pendingLoads--,this._removed)return void this.fire(new p.k("dataabort",{dataType:"source"}));this.fire(new p.j(a))}})}loaded(){return this._pendingLoads===0}loadTile(t){return p._(this,void 0,void 0,function*(){const n=t.actor?"RT":"LT";t.actor=this.actor;const a={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};t.abortController=new AbortController;const l=yield this.actor.sendAsync({type:n,data:a},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(l,this.map.painter,n==="RT")})}abortTile(t){return p._(this,void 0,void 0,function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0})}unloadTile(t){return p._(this,void 0,void 0,function*(){t.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}})})}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return p.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var Sr=p.Y([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class cr extends p.E{constructor(t,n,a,l){super(),this.id=t,this.dispatcher=a,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(l),this.options=n}load(t){return p._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new p.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const n=yield pi.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,n&&n.data&&(this.image=n.data,t&&(this.coordinates=t),this._finishLoading())}catch(n){this._request=null,this._loaded=!0,this.fire(new p.j(n))}})}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=t.url,this.load(t.coordinates).finally(()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new p.k("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(t){this.coordinates=t;const n=t.map(p.Z.fromLngLat);this.tileID=function(l){let u=1/0,m=1/0,g=-1/0,y=-1/0;for(const M of l)u=Math.min(u,M.x),m=Math.min(m,M.y),g=Math.max(g,M.x),y=Math.max(y,M.y);const v=Math.max(g-u,y-m),S=Math.max(0,Math.floor(-Math.log(v)/Math.LN2)),T=Math.pow(2,S);return new p.a1(S,Math.floor((u+g)/2*T),Math.floor((m+y)/2*T))}(n),this.minzoom=this.maxzoom=this.tileID.z;const a=n.map(l=>this.tileID.getTilePoint(l)._round());return this._boundsArray=new p.$,this._boundsArray.emplaceBack(a[0].x,a[0].y,0,0),this._boundsArray.emplaceBack(a[1].x,a[1].y,p.X,0),this._boundsArray.emplaceBack(a[3].x,a[3].y,0,p.X),this._boundsArray.emplaceBack(a[2].x,a[2].y,p.X,p.X),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new p.k("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const t=this.map.painter.context,n=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,Sr.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),this.texture||(this.texture=new rt(t,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let a=!1;for(const l in this.tiles){const u=this.tiles[l];u.state!=="loaded"&&(u.state="loaded",u.texture=this.texture,a=!0)}a&&this.fire(new p.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(t){return p._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class dn extends cr{constructor(t,n,a,l){super(t,n,a,l),this.roundZoom=!0,this.type="video",this.options=n}load(){return p._(this,void 0,void 0,function*(){this._loaded=!1;const t=this.options;this.urls=[];for(const n of t.urls)this.urls.push(this.map._requestManager.transformRequest(n,"Source").url);try{const n=yield p.a3(this.urls);if(this._loaded=!0,!n)return;this.video=n,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(n){this.fire(new p.j(n))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const n=this.video.seekable;t<n.start(0)||t>n.end(0)?this.fire(new p.j(new p.a2(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=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,Sr.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new rt(t,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let a=!1;for(const l in this.tiles){const u=this.tiles[l];u.state!=="loaded"&&(u.state="loaded",u.texture=this.texture,a=!0)}a&&this.fire(new p.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class Ii extends cr{constructor(t,n,a,l){super(t,n,a,l),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some(u=>!Array.isArray(u)||u.length!==2||u.some(m=>typeof m!="number"))||this.fire(new p.j(new p.a2(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new p.j(new p.a2(`sources.${t}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new p.j(new p.a2(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new p.j(new p.a2(`sources.${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 p.j(new p.a2(`sources.${t}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return p._(this,void 0,void 0,function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new p.j(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())})}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const n=this.map.painter.context,a=n.gl;this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,Sr.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new rt(n,this.canvas,a.RGBA,{premultiply:!0});let l=!1;for(const u in this.tiles){const m=this.tiles[u];m.state!=="loaded"&&(m.state="loaded",m.texture=this.texture,l=!0)}l&&this.fire(new p.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const Nn={},jn=h=>{switch(h){case"geojson":return Vn;case"image":return cr;case"raster":return Qe;case"raster-dem":return vt;case"vector":return On;case"video":return dn;case"canvas":return Ii}return Nn[h]},pe="RTLPluginLoaded";class Hi extends p.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=Fn()}_syncState(t){return this.status=t,this.dispatcher.broadcast("SRPS",{pluginStatus:t,pluginURL:this.url}).catch(n=>{throw this.status="error",n})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(t){return p._(this,arguments,void 0,function*(n,a=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=me.resolveURL(n),!this.url)throw new Error(`requested url ${n} is invalid`);if(this.status==="unavailable"){if(!a)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if(this.status==="requested")return this._requestImport()})}_requestImport(){return p._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new p.k(pe))})}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let Qt=null;function Ki(){return Qt||(Qt=new Hi),Qt}class Ir{constructor(t,n){this.timeAdded=0,this.fadeEndTime=0,this.tileID=t,this.uid=p.a4(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(t){const n=t+this.timeAdded;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,a){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(l,u){const m={};if(!u)return m;for(const g of l){const y=g.layerIds.map(v=>u.getLayer(v)).filter(Boolean);if(y.length!==0){g.layers=y,g.stateDependentLayerIds&&(g.stateDependentLayers=g.stateDependentLayerIds.map(v=>y.filter(S=>S.id===v)[0]));for(const v of y)m[v.id]=g}}return m}(t.buckets,n.style),this.hasSymbolBuckets=!1;for(const l in this.buckets){const u=this.buckets[l];if(u instanceof p.a6){if(this.hasSymbolBuckets=!0,!a)break;u.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const l in this.buckets){const u=this.buckets[l];if(u instanceof p.a6&&u.hasRTLText){this.hasRTLText=!0,Ki().lazyLoad();break}}this.queryPadding=0;for(const l in this.buckets){const u=this.buckets[l];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(l).queryRadius(u))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage)}else this.collisionBoxArray=new p.a5}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 a in this.buckets){const l=this.buckets[a];l.uploadPending()&&l.upload(t)}const n=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new rt(t,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new rt(t,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,n,a,l,u,m,g,y,v,S){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:l,cameraQueryGeometry:u,scale:m,tileSize:this.tileSize,pixelPosMatrix:S,transform:y,params:g,queryPadding:this.queryPadding*v},t,n,a):{}}querySourceFeatures(t,n){const a=this.latestFeatureIndex;if(!a||!a.rawTileData)return;const l=a.loadVTLayers(),u=n&&n.sourceLayer?n.sourceLayer:"",m=l._geojsonTileLayer||l[u];if(!m)return;const g=p.a7(n&&n.filter),{z:y,x:v,y:S}=this.tileID.canonical,T={z:y,x:v,y:S};for(let M=0;M<m.length;M++){const z=m.feature(M);if(g.needGeometry){const B=p.a8(z,!0);if(!g.filter(new p.a9(this.tileID.overscaledZ),B,this.tileID.canonical))continue}else if(!g.filter(new p.a9(this.tileID.overscaledZ),z))continue;const R=a.getId(z,u),N=new p.aa(z,y,v,S,R);N.tile=T,t.push(N)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const n=this.expirationTime;if(t.cacheControl){const a=p.ab(t.cacheControl);a["max-age"]&&(this.expirationTime=Date.now()+1e3*a["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const a=Date.now();let l=!1;if(this.expirationTime>a)l=!1;else if(n)if(this.expirationTime<n)l=!0;else{const u=this.expirationTime-n;u?this.expirationTime=a+Math.max(u,3e4):l=!0}else l=!0;l?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(t,n){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(t).length===0)return;const a=this.latestFeatureIndex.loadVTLayers();for(const l in this.buckets){if(!n.style.hasLayer(l))continue;const u=this.buckets[l],m=u.layers[0].sourceLayer||"_geojsonTileLayer",g=a[m],y=t[m];if(!g||!y||Object.keys(y).length===0)continue;u.update(y,g,this.imageAtlas&&this.imageAtlas.patternPositions||{});const v=n&&n.style&&n.style.getLayer(l);v&&(this.queryPadding=Math.max(this.queryPadding,v.queryRadius(u)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<me.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=me.now()+t}setDependencies(t,n){const a={};for(const l of n)a[l]=!0;this.dependencies[t]=a}hasDependency(t,n){for(const a of t){const l=this.dependencies[a];if(l){for(const u of n)if(l[u])return!0}}return!1}}class ge{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,a){const l=t.wrapped().key;this.data[l]===void 0&&(this.data[l]=[]);const u={value:n,timeout:void 0};if(a!==void 0&&(u.timeout=setTimeout(()=>{this.remove(t,u)},a)),this.data[l].push(u),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 a=t.wrapped().key,l=n===void 0?0:this.data[a].indexOf(n),u=this.data[a][l];return this.data[a].splice(l,1),u.timeout&&clearTimeout(u.timeout),this.data[a].length===0&&delete this.data[a],this.onRemove(u.value),this.order.splice(this.order.indexOf(a),1),this}setMaxSize(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 a in this.data)for(const l of this.data[a])t(l.value)||n.push(l);for(const a of n)this.remove(a.value.tileID,a)}}class Ze{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,n,a){const l=String(n);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][l]=this.stateChanges[t][l]||{},p.e(this.stateChanges[t][l],a),this.deletedStates[t]===null){this.deletedStates[t]={};for(const u in this.state[t])u!==l&&(this.deletedStates[t][u]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][l]===null){this.deletedStates[t][l]={};for(const u in this.state[t][l])a[u]||(this.deletedStates[t][l][u]=null)}else for(const u in a)this.deletedStates[t]&&this.deletedStates[t][l]&&this.deletedStates[t][l][u]===null&&delete this.deletedStates[t][l][u]}removeFeatureState(t,n,a){if(this.deletedStates[t]===null)return;const l=String(n);if(this.deletedStates[t]=this.deletedStates[t]||{},a&&n!==void 0)this.deletedStates[t][l]!==null&&(this.deletedStates[t][l]=this.deletedStates[t][l]||{},this.deletedStates[t][l][a]=null);else if(n!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][l])for(a in this.deletedStates[t][l]={},this.stateChanges[t][l])this.deletedStates[t][l][a]=null;else this.deletedStates[t][l]=null;else this.deletedStates[t]=null}getState(t,n){const a=String(n),l=p.e({},(this.state[t]||{})[a],(this.stateChanges[t]||{})[a]);if(this.deletedStates[t]===null)return{};if(this.deletedStates[t]){const u=this.deletedStates[t][n];if(u===null)return{};for(const m in u)delete l[m]}return l}initializeTileState(t,n){t.setFeatureState(this.state,n)}coalesceChanges(t,n){const a={};for(const l in this.stateChanges){this.state[l]=this.state[l]||{};const u={};for(const m in this.stateChanges[l])this.state[l][m]||(this.state[l][m]={}),p.e(this.state[l][m],this.stateChanges[l][m]),u[m]=this.state[l][m];a[l]=u}for(const l in this.deletedStates){this.state[l]=this.state[l]||{};const u={};if(this.deletedStates[l]===null)for(const m in this.state[l])u[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];u[m]=this.state[l][m]}a[l]=a[l]||{},p.e(a[l],u)}if(this.stateChanges={},this.deletedStates={},Object.keys(a).length!==0)for(const l in t)t[l].setFeatureState(a,n)}}class Fe extends p.E{constructor(t,n,a){super(),this.id=t,this.dispatcher=a,this.on("data",l=>this._dataHandler(l)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((l,u,m,g)=>{const y=new(jn(u.type))(l,u,m,g);if(y.id!==l)throw new Error(`Expected Source id to be ${l} instead of ${y.id}`);return y})(t,n,a,this),this._tiles={},this._cache=new ge(0,l=>this._unloadTile(l)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new Ze,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){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;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)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,a){return p._(this,void 0,void 0,function*(){try{yield this._source.loadTile(t),this._tileLoaded(t,n,a)}catch(l){t.state="errored",l.status!==404?this._source.fire(new p.j(l,{tile:t})):this.update(this.transform,this.terrain)}})}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new p.k("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 a=this._tiles[n];a.upload(t),a.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(t=>t.tileID).sort(si).map(t=>t.key)}getRenderableIds(t){const n=[];for(const a in this._tiles)this._isIdRenderable(a,t)&&n.push(this._tiles[a]);return t?n.sort((a,l)=>{const u=a.tileID,m=l.tileID,g=new p.P(u.canonical.x,u.canonical.y)._rotate(this.transform.angle),y=new p.P(m.canonical.x,m.canonical.y)._rotate(this.transform.angle);return u.overscaledZ-m.overscaledZ||y.y-g.y||y.x-g.x}).map(a=>a.tileID.key):n.map(a=>a.tileID).sort(si).map(a=>a.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){return p._(this,void 0,void 0,function*(){const a=this._tiles[t];a&&(a.state!=="loading"&&(a.state=n),yield this._loadTile(a,t,n))})}_tileLoaded(t,n,a){t.timeAdded=me.now(),a==="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 p.k("data",{dataType:"source",tile:t,coord:t.tileID}))}_backfillDEM(t){const n=this.getRenderableIds();for(let l=0;l<n.length;l++){const u=n[l];if(t.neighboringTiles&&t.neighboringTiles[u]){const m=this.getTileByID(u);a(t,m),a(m,t)}}function a(l,u){l.needsHillshadePrepare=!0,l.needsTerrainPrepare=!0;let m=u.tileID.canonical.x-l.tileID.canonical.x;const g=u.tileID.canonical.y-l.tileID.canonical.y,y=Math.pow(2,l.tileID.canonical.z),v=u.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)),u.dem&&l.dem&&(l.dem.backfillBorder(u.dem,m,g),l.neighboringTiles&&l.neighboringTiles[v]&&(l.neighboringTiles[v].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,n,a,l){for(const u in this._tiles){let m=this._tiles[u];if(l[u]||!m.hasData()||m.tileID.overscaledZ<=n||m.tileID.overscaledZ>a)continue;let g=m.tileID;for(;m&&m.tileID.overscaledZ>n+1;){const v=m.tileID.scaledTo(m.tileID.overscaledZ-1);m=this._tiles[v.key],m&&m.hasData()&&(g=v)}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 a=this._loadedParentTiles[t.key];return a&&a.tileID.overscaledZ>=n?a:null}for(let a=t.overscaledZ-1;a>=n;a--){const l=t.scaledTo(a),u=this._getLoadedTile(l);if(u)return u}}findLoadedSibling(t){return this._getLoadedTile(t)}_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,a=Math.ceil(t.height/this._source.tileSize)+1,l=Math.floor(n*a*(this._maxTileCacheZoomLevels===null?p.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),u=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,l):l;this._cache.setMaxSize(u)}handleWrapJump(t){const n=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);if(this._prevLng=t,n){const a={};for(const l in this._tiles){const u=this._tiles[l];u.tileID=u.tileID.unwrapTo(u.tileID.wrap+n),a[u.tileID.key]=u}this._tiles=a;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])}}_updateCoveredAndRetainedTiles(t,n,a,l,u,m){const g={},y={},v=Object.keys(t),S=me.now();for(const T of v){const M=t[T],z=this._tiles[T];if(!z||z.fadeEndTime!==0&&z.fadeEndTime<=S)continue;const R=this.findLoadedParent(M,n),N=this.findLoadedSibling(M),B=R||N||null;B&&(this._addTile(B.tileID),g[B.tileID.key]=B.tileID),y[T]=M}this._retainLoadedChildren(y,l,a,t);for(const T in g)t[T]||(this._coveredTiles[T]=!0,t[T]=g[T]);if(m){const T={},M={};for(const z of u)this._tiles[z.key].hasData()?T[z.key]=z:M[z.key]=z;for(const z in M){const R=M[z].children(this._source.maxzoom);this._tiles[R[0].key]&&this._tiles[R[1].key]&&this._tiles[R[2].key]&&this._tiles[R[3].key]&&(T[R[0].key]=t[R[0].key]=R[0],T[R[1].key]=t[R[1].key]=R[1],T[R[2].key]=t[R[2].key]=R[2],T[R[3].key]=t[R[3].key]=R[3],delete M[z])}for(const z in M){const R=M[z],N=this.findLoadedParent(R,this._source.minzoom),B=this.findLoadedSibling(R),U=N||B||null;if(U){T[U.tileID.key]=t[U.tileID.key]=U.tileID;for(const G in T)T[G].isChildOf(U.tileID)&&delete T[G]}}for(const z in this._tiles)T[z]||(this._coveredTiles[z]=!0)}}update(t,n){if(!this._sourceLoaded||this._paused)return;let a;this.transform=t,this.terrain=n,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?a=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(S=>new p.S(S.canonical.z,S.wrap,S.canonical.z,S.canonical.x,S.canonical.y)):(a=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&&(a=a.filter(S=>this._source.hasTile(S)))):a=[];const l=t.coveringZoomLevel(this._source),u=Math.max(l-Fe.maxOverzooming,this._source.minzoom),m=Math.max(l+Fe.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const S={};for(const T of a)if(T.canonical.z>this._source.minzoom){const M=T.scaledTo(T.canonical.z-1);S[M.key]=M;const z=T.scaledTo(Math.max(this._source.minzoom,Math.min(T.canonical.z,5)));S[z.key]=z}a=a.concat(Object.values(S))}const g=a.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,g&&this.fire(new p.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const y=this._updateRetainedTiles(a,l);Ei(this._source.type)&&this._updateCoveredAndRetainedTiles(y,u,m,l,a,n);for(const S in y)this._tiles[S].clearFadeHold();const v=p.ac(this._tiles,y);for(const S of v){const T=this._tiles[S];T.hasSymbolBuckets&&!T.holdingForFade()?T.setHoldDuration(this.map._fadeDuration):T.hasSymbolBuckets&&!T.symbolFadeFinished()||this._removeTile(S)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,n){var a;const l={},u={},m=Math.max(n-Fe.maxOverzooming,this._source.minzoom),g=Math.max(n+Fe.maxUnderzooming,this._source.minzoom),y={};for(const v of t){const S=this._addTile(v);l[v.key]=v,S.hasData()||n<this._source.maxzoom&&(y[v.key]=v)}this._retainLoadedChildren(y,n,g,l);for(const v of t){let S=this._tiles[v.key];if(S.hasData())continue;if(n+1>this._source.maxzoom){const M=v.children(this._source.maxzoom)[0],z=this.getTile(M);if(z&&z.hasData()){l[M.key]=M;continue}}else{const M=v.children(this._source.maxzoom);if(l[M[0].key]&&l[M[1].key]&&l[M[2].key]&&l[M[3].key])continue}let T=S.wasRequested();for(let M=v.overscaledZ-1;M>=m;--M){const z=v.scaledTo(M);if(u[z.key])break;if(u[z.key]=!0,S=this.getTile(z),!S&&T&&(S=this._addTile(z)),S){const R=S.hasData();if((R||!(!((a=this.map)===null||a===void 0)&&a.cancelPendingTileRequestsWhileZooming)||T)&&(l[z.key]=z),T=S.wasRequested(),R)break}}}return l}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const n=[];let a,l=this._tiles[t].tileID;for(;l.overscaledZ>0;){if(l.key in this._loadedParentTiles){a=this._loadedParentTiles[l.key];break}n.push(l.key);const u=l.scaledTo(l.overscaledZ-1);if(a=this._getLoadedTile(u),a)break;l=u}for(const u of n)this._loadedParentTiles[u]=a}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const t in this._tiles){const n=this._tiles[t].tileID,a=this._getLoadedTile(n);this._loadedSiblingTiles[n.key]=a}}_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 a=n;return n||(n=new Ir(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(n,t.key,n.state)),n.uses++,this._tiles[t.key]=n,a||this._source.fire(new p.k("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 a=n.getExpiryTimeout();a&&(this._timers[t]=setTimeout(()=>{this._reloadTile(t,"expired"),delete this._timers[t]},a))}_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))))}_dataHandler(t){const n=t.sourceDataType;t.dataType==="source"&&n==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&t.dataType==="source"&&n==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(t,n,a){const l=[],u=this.transform;if(!u)return l;const m=a?u.getCameraQueryGeometry(t):t,g=t.map(R=>u.pointCoordinate(R,this.terrain)),y=m.map(R=>u.pointCoordinate(R,this.terrain)),v=this.getIds();let S=1/0,T=1/0,M=-1/0,z=-1/0;for(const R of y)S=Math.min(S,R.x),T=Math.min(T,R.y),M=Math.max(M,R.x),z=Math.max(z,R.y);for(let R=0;R<v.length;R++){const N=this._tiles[v[R]];if(N.holdingForFade())continue;const B=N.tileID,U=Math.pow(2,u.zoom-N.tileID.overscaledZ),G=n*N.queryPadding*p.X/N.tileSize/U,O=[B.getTilePoint(new p.Z(S,T)),B.getTilePoint(new p.Z(M,z))];if(O[0].x-G<p.X&&O[0].y-G<p.X&&O[1].x+G>=0&&O[1].y+G>=0){const H=g.map(ee=>B.getTilePoint(ee)),Q=y.map(ee=>B.getTilePoint(ee));l.push({tile:N,tileID:B,queryGeometry:H,cameraQueryGeometry:Q,scale:U})}}return l}getVisibleCoordinates(t){const n=this.getRenderableIds(t).map(a=>this._tiles[a].tileID);for(const a of n)a.posMatrix=this.transform.calculatePosMatrix(a.toUnwrapped());return n}hasTransition(){if(this._source.hasTransition())return!0;if(Ei(this._source.type)){const t=me.now();for(const n in this._tiles)if(this._tiles[n].fadeEndTime>=t)return!0}return!1}setFeatureState(t,n,a){this._state.updateState(t=t||"_geojsonTileLayer",n,a)}removeFeatureState(t,n,a){this._state.removeFeatureState(t=t||"_geojsonTileLayer",n,a)}getFeatureState(t,n){return this._state.getState(t=t||"_geojsonTileLayer",n)}setDependencies(t,n,a){const l=this._tiles[t];l&&l.setDependencies(n,a)}reloadTilesForDependencies(t,n){for(const a in this._tiles)this._tiles[a].hasDependency(t,n)&&this._reloadTile(a,"reloading");this._cache.filter(a=>!a.hasDependency(t,n))}}function si(h,t){const n=Math.abs(2*h.wrap)-+(h.wrap<0),a=Math.abs(2*t.wrap)-+(t.wrap<0);return h.overscaledZ-t.overscaledZ||a-n||t.canonical.y-h.canonical.y||t.canonical.x-h.canonical.x}function Ei(h){return h==="raster"||h==="image"||h==="video"}Fe.maxOverzooming=10,Fe.maxUnderzooming=3;class je{constructor(t,n){this.reset(t,n)}reset(t,n){this.points=t||[],this._distances=[0];for(let a=1;a<this.points.length;a++)this._distances[a]=this._distances[a-1]+this.points[a].dist(this.points[a-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(n||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(this.points.length===1)return this.points[0];t=p.ad(t,0,1);let n=1,a=this._distances[n];const l=t*this.paddedLength+this.padding;for(;a<l&&n<this._distances.length;)a=this._distances[++n];const u=n-1,m=this._distances[u],g=a-m,y=g>0?(l-m)/g:0;return this.points[u].mult(1-y).add(this.points[n].mult(y))}}function Ji(h,t){let n=!0;return h==="always"||h!=="never"&&t!=="never"||(n=!1),n}class hr{constructor(t,n,a){const l=this.boxCells=[],u=this.circleCells=[];this.xCellCount=Math.ceil(t/a),this.yCellCount=Math.ceil(n/a);for(let m=0;m<this.xCellCount*this.yCellCount;m++)l.push([]),u.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=n,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/n,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,n,a,l,u){this._forEachCell(n,a,l,u,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(n),this.bboxes.push(a),this.bboxes.push(l),this.bboxes.push(u)}insertCircle(t,n,a,l){this._forEachCell(n-l,a-l,n+l,a+l,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(n),this.circles.push(a),this.circles.push(l)}_insertBoxCell(t,n,a,l,u,m){this.boxCells[u].push(m)}_insertCircleCell(t,n,a,l,u,m){this.circleCells[u].push(m)}_query(t,n,a,l,u,m,g){if(a<0||t>this.width||l<0||n>this.height)return[];const y=[];if(t<=0&&n<=0&&this.width<=a&&this.height<=l){if(u)return[{key:null,x1:t,y1:n,x2:a,y2:l}];for(let v=0;v<this.boxKeys.length;v++)y.push({key:this.boxKeys[v],x1:this.bboxes[4*v],y1:this.bboxes[4*v+1],x2:this.bboxes[4*v+2],y2:this.bboxes[4*v+3]});for(let v=0;v<this.circleKeys.length;v++){const S=this.circles[3*v],T=this.circles[3*v+1],M=this.circles[3*v+2];y.push({key:this.circleKeys[v],x1:S-M,y1:T-M,x2:S+M,y2:T+M})}}else this._forEachCell(t,n,a,l,this._queryCell,y,{hitTest:u,overlapMode:m,seenUids:{box:{},circle:{}}},g);return y}query(t,n,a,l){return this._query(t,n,a,l,!1,null)}hitTest(t,n,a,l,u,m){return this._query(t,n,a,l,!0,u,m).length>0}hitTestCircle(t,n,a,l,u){const m=t-a,g=t+a,y=n-a,v=n+a;if(g<0||m>this.width||v<0||y>this.height)return!1;const S=[];return this._forEachCell(m,y,g,v,this._queryCellCircle,S,{hitTest:!0,overlapMode:l,circle:{x:t,y:n,radius:a},seenUids:{box:{},circle:{}}},u),S.length>0}_queryCell(t,n,a,l,u,m,g,y){const{seenUids:v,hitTest:S,overlapMode:T}=g,M=this.boxCells[u];if(M!==null){const R=this.bboxes;for(const N of M)if(!v.box[N]){v.box[N]=!0;const B=4*N,U=this.boxKeys[N];if(t<=R[B+2]&&n<=R[B+3]&&a>=R[B+0]&&l>=R[B+1]&&(!y||y(U))&&(!S||!Ji(T,U.overlapMode))&&(m.push({key:U,x1:R[B],y1:R[B+1],x2:R[B+2],y2:R[B+3]}),S))return!0}}const z=this.circleCells[u];if(z!==null){const R=this.circles;for(const N of z)if(!v.circle[N]){v.circle[N]=!0;const B=3*N,U=this.circleKeys[N];if(this._circleAndRectCollide(R[B],R[B+1],R[B+2],t,n,a,l)&&(!y||y(U))&&(!S||!Ji(T,U.overlapMode))){const G=R[B],O=R[B+1],H=R[B+2];if(m.push({key:U,x1:G-H,y1:O-H,x2:G+H,y2:O+H}),S)return!0}}}return!1}_queryCellCircle(t,n,a,l,u,m,g,y){const{circle:v,seenUids:S,overlapMode:T}=g,M=this.boxCells[u];if(M!==null){const R=this.bboxes;for(const N of M)if(!S.box[N]){S.box[N]=!0;const B=4*N,U=this.boxKeys[N];if(this._circleAndRectCollide(v.x,v.y,v.radius,R[B+0],R[B+1],R[B+2],R[B+3])&&(!y||y(U))&&!Ji(T,U.overlapMode))return m.push(!0),!0}}const z=this.circleCells[u];if(z!==null){const R=this.circles;for(const N of z)if(!S.circle[N]){S.circle[N]=!0;const B=3*N,U=this.circleKeys[N];if(this._circlesCollide(R[B],R[B+1],R[B+2],v.x,v.y,v.radius)&&(!y||y(U))&&!Ji(T,U.overlapMode))return m.push(!0),!0}}}_forEachCell(t,n,a,l,u,m,g,y){const v=this._convertToXCellCoord(t),S=this._convertToYCellCoord(n),T=this._convertToXCellCoord(a),M=this._convertToYCellCoord(l);for(let z=v;z<=T;z++)for(let R=S;R<=M;R++)if(u.call(this,t,n,a,l,this.xCellCount*R+z,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,a,l,u,m){const g=l-t,y=u-n,v=a+m;return v*v>g*g+y*y}_circleAndRectCollide(t,n,a,l,u,m,g){const y=(m-l)/2,v=Math.abs(t-(l+y));if(v>y+a)return!1;const S=(g-u)/2,T=Math.abs(n-(u+S));if(T>S+a)return!1;if(v<=y||T<=S)return!0;const M=v-y,z=T-S;return M*M+z*z<=a*a}}function Pr(h,t,n,a,l){const u=p.H();return t?(p.K(u,u,[1/l,1/l,1]),n||p.ae(u,u,a.angle)):p.L(u,a.labelPlaneMatrix,h),u}function Yi(h,t,n,a,l){if(t){const u=p.af(h);return p.K(u,u,[l,l,1]),n||p.ae(u,u,-a.angle),u}return a.glCoordMatrix}function j(h,t,n){let a;n?(a=[h.x,h.y,n(h.x,h.y),1],p.ag(a,a,t)):(a=[h.x,h.y,0,1],function(u,m,g){const y=m[0],v=m[1];u[0]=g[0]*y+g[4]*v+g[12],u[1]=g[1]*y+g[5]*v+g[13],u[3]=g[3]*y+g[7]*v+g[15]}(a,a,t));const l=a[3];return{point:new p.P(a[0]/l,a[1]/l),signedDistanceFromCamera:l,isOccluded:!1}}function A(h,t){return .5+h/t*.5}function P(h,t){return h.x>=-t[0]&&h.x<=t[0]&&h.y>=-t[1]&&h.y<=t[1]}function E(h,t,n,a,l,u,m,g,y,v,S,T,M,z,R){const N=a?h.textSizeData:h.iconSizeData,B=p.ah(N,n.transform.zoom),U=[256/n.width*2+1,256/n.height*2+1],G=a?h.text.dynamicLayoutVertexArray:h.icon.dynamicLayoutVertexArray;G.clear();const O=h.lineVertexArray,H=a?h.text.placedSymbolArray:h.icon.placedSymbolArray,Q=n.transform.width/n.transform.height;let ee=!1;for(let oe=0;oe<H.length;oe++){const he=H.get(oe);if(he.hidden||he.writingMode===p.ai.vertical&&!ee){Re(he.numGlyphs,G);continue}ee=!1;const Te=j(new p.P(he.anchorX,he.anchorY),t,R);if(!P(Te.point,U)){Re(he.numGlyphs,G);continue}const Se=A(n.transform.cameraToCenterDistance,Te.signedDistanceFromCamera),ue=p.aj(N,B,he),de=m?ue/Se:ue*Se,Ce={getElevation:R,labelPlaneMatrix:l,lineVertexArray:O,pitchWithMap:m,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},projection:v,tileAnchorPoint:new p.P(he.anchorX,he.anchorY),unwrappedTileID:S,width:T,height:M,translation:z},Ne=W(Ce,he,de,!1,g,t,u,h.glyphOffsetArray,G,Q,y);ee=Ne.useVertical,(Ne.notEnoughRoom||ee||Ne.needsFlipping&&W(Ce,he,de,!0,g,t,u,h.glyphOffsetArray,G,Q,y).notEnoughRoom)&&Re(he.numGlyphs,G)}a?h.text.dynamicLayoutVertexBuffer.updateData(G):h.icon.dynamicLayoutVertexBuffer.updateData(G)}function V(h,t,n,a,l,u,m,g){const y=u.glyphStartIndex+u.numGlyphs,v=u.lineStartIndex,S=u.lineStartIndex+u.lineLength,T=t.getoffsetX(u.glyphStartIndex),M=t.getoffsetX(y-1),z=fe(h*T,n,a,l,u.segment,v,S,g,m);if(!z)return null;const R=fe(h*M,n,a,l,u.segment,v,S,g,m);return R?g.projectionCache.anyProjectionOccluded?null:{first:z,last:R}:null}function X(h,t,n,a){return h===p.ai.horizontal&&Math.abs(n.y-t.y)>Math.abs(n.x-t.x)*a?{useVertical:!0}:(h===p.ai.vertical?t.y<n.y:t.x>n.x)?{needsFlipping:!0}:null}function W(h,t,n,a,l,u,m,g,y,v,S){const T=n/24,M=t.lineOffsetX*T,z=t.lineOffsetY*T;let R;if(t.numGlyphs>1){const N=t.glyphStartIndex+t.numGlyphs,B=t.lineStartIndex,U=t.lineStartIndex+t.lineLength,G=V(T,g,M,z,a,t,S,h);if(!G)return{notEnoughRoom:!0};const O=j(G.first.point,m,h.getElevation).point,H=j(G.last.point,m,h.getElevation).point;if(l&&!a){const Q=X(t.writingMode,O,H,v);if(Q)return Q}R=[G.first];for(let Q=t.glyphStartIndex+1;Q<N-1;Q++)R.push(fe(T*g.getoffsetX(Q),M,z,a,t.segment,B,U,h,S));R.push(G.last)}else{if(l&&!a){const B=j(h.tileAnchorPoint,u,h.getElevation).point,U=t.lineStartIndex+t.segment+1,G=new p.P(h.lineVertexArray.getx(U),h.lineVertexArray.gety(U)),O=j(G,u,h.getElevation),H=O.signedDistanceFromCamera>0?O.point:function(ee,oe,he,Te,Se,ue){return Y(ee,oe,he,1,Se,ue)}(h.tileAnchorPoint,G,B,0,u,h),Q=X(t.writingMode,B,H,v);if(Q)return Q}const N=fe(T*g.getoffsetX(t.glyphStartIndex),M,z,a,t.segment,t.lineStartIndex,t.lineStartIndex+t.lineLength,h,S);if(!N||h.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};R=[N]}for(const N of R)p.ak(y,N.point,N.angle);return{}}function Y(h,t,n,a,l,u){const m=h.add(h.sub(t)._unit()),g=l!==void 0?j(m,l,u.getElevation).point:ne(m.x,m.y,u).point,y=n.sub(g);return n.add(y._mult(a/y.mag()))}function q(h,t,n){const a=t.projectionCache;if(a.projections[h])return a.projections[h];const l=new p.P(t.lineVertexArray.getx(h),t.lineVertexArray.gety(h)),u=ne(l.x,l.y,t);if(u.signedDistanceFromCamera>0)return a.projections[h]=u.point,a.anyProjectionOccluded=a.anyProjectionOccluded||u.isOccluded,u.point;const m=h-n.direction;return function(g,y,v,S,T){return Y(g,y,v,S,void 0,T)}(n.distanceFromAnchor===0?t.tileAnchorPoint:new p.P(t.lineVertexArray.getx(m),t.lineVertexArray.gety(m)),l,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,t)}function ne(h,t,n){const a=h+n.translation[0],l=t+n.translation[1];let u;return!n.pitchWithMap&&n.projection.useSpecialProjectionForSymbols?(u=n.projection.projectTileCoordinates(a,l,n.unwrappedTileID,n.getElevation),u.point.x=(.5*u.point.x+.5)*n.width,u.point.y=(.5*-u.point.y+.5)*n.height):(u=j(new p.P(a,l),n.labelPlaneMatrix,n.getElevation),u.isOccluded=!1),u}function le(h,t,n){return h._unit()._perp()._mult(t*n)}function te(h,t,n,a,l,u,m,g,y){if(g.projectionCache.offsets[h])return g.projectionCache.offsets[h];const v=n.add(t);if(h+y.direction<a||h+y.direction>=l)return g.projectionCache.offsets[h]=v,v;const S=q(h+y.direction,g,y),T=le(S.sub(n),m,y.direction),M=n.add(T),z=S.add(T);return g.projectionCache.offsets[h]=p.al(u,v,M,z)||v,g.projectionCache.offsets[h]}function fe(h,t,n,a,l,u,m,g,y){const v=a?h-t:h+t;let S=v>0?1:-1,T=0;a&&(S*=-1,T=Math.PI),S<0&&(T+=Math.PI);let M,z=S>0?u+l:u+l+1;g.projectionCache.cachedAnchorPoint?M=g.projectionCache.cachedAnchorPoint:(M=ne(g.tileAnchorPoint.x,g.tileAnchorPoint.y,g).point,g.projectionCache.cachedAnchorPoint=M);let R,N,B=M,U=M,G=0,O=0;const H=Math.abs(v),Q=[];let ee;for(;G+O<=H;){if(z+=S,z<u||z>=m)return null;G+=O,U=B,N=R;const Te={absOffsetX:H,direction:S,distanceFromAnchor:G,previousVertex:U};if(B=q(z,g,Te),n===0)Q.push(U),ee=B.sub(U);else{let Se;const ue=B.sub(U);Se=ue.mag()===0?le(q(z+S,g,Te).sub(B),n,S):le(ue,n,S),N||(N=U.add(Se)),R=te(z,Se,B,u,m,N,n,g,Te),Q.push(N),ee=R.sub(N)}O=ee.mag()}const oe=ee._mult((H-G)/O)._add(N||U),he=T+Math.atan2(B.y-U.y,B.x-U.x);return Q.push(oe),{point:oe,angle:y?he:0,path:Q}}const De=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Re(h,t){for(let n=0;n<h;n++){const a=t.length;t.resize(a+4),t.float32.set(De,3*a)}}const $e=100;class Ke{constructor(t,n,a=new hr(t.width+200,t.height+200,25),l=new hr(t.width+200,t.height+200,25)){this.transform=t,this.mapProjection=n,this.grid=a,this.ignoredGrid=l,this.pitchFactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+$e,this.screenBottomBoundary=t.height+$e,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,n,a,l,u,m,g,y,v,S,T){const M=t.anchorPointX+y[0],z=t.anchorPointY+y[1],R=this.projectAndGetPerspectiveRatio(l,M,z,u,S),N=this._projectCollisionBox(t,a,l,u,m,g,y,R,S,T),[B,U,G,O]=N.box;return this.mapProjection.useSpecialProjectionForSymbols&&(m?N.allPointsOccluded:this.mapProjection.isOccluded(M,z,u))||R.perspectiveRatio<this.perspectiveRatioCutoff||!this.isInsideGrid(B,U,G,O)||n!=="always"&&this.grid.hitTest(B,U,G,O,n,v)?{box:[B,U,G,O],placeable:!1,offscreen:!1}:{box:[B,U,G,O],placeable:!0,offscreen:this.isOffscreen(B,U,G,O)}}placeCollisionCircles(t,n,a,l,u,m,g,y,v,S,T,M,z,R,N,B){const U=[],G=new p.P(n.anchorX,n.anchorY),O=this.getPerspectiveRatio(m,G.x,G.y,g,B),H=(T?u/O:u*O)/p.aq,Q={getElevation:B,labelPlaneMatrix:y,lineVertexArray:a,pitchWithMap:T,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},projection:this.mapProjection,tileAnchorPoint:G,unwrappedTileID:g,width:this.transform.width,height:this.transform.height,translation:N},ee=V(H,l,n.lineOffsetX*H,n.lineOffsetY*H,!1,n,!1,Q);let oe=!1,he=!1,Te=!0;if(ee){const Se=.5*z*O+R,ue=new p.P(-100,-100),de=new p.P(this.screenRightBoundary,this.screenBottomBoundary),Ce=new je,Ne=ee.first,_e=ee.last;let ve=[];for(let qe=Ne.path.length-1;qe>=1;qe--)ve.push(Ne.path[qe]);for(let qe=1;qe<_e.path.length;qe++)ve.push(_e.path[qe]);const Oe=2.5*Se;if(v){const qe=this.projectPathToScreenSpace(ve,Q,v);ve=qe.some(We=>We.signedDistanceFromCamera<=0)?[]:qe.map(We=>We.point)}let pt=[];if(ve.length>0){const qe=ve[0].clone(),We=ve[0].clone();for(let ft=1;ft<ve.length;ft++)qe.x=Math.min(qe.x,ve[ft].x),qe.y=Math.min(qe.y,ve[ft].y),We.x=Math.max(We.x,ve[ft].x),We.y=Math.max(We.y,ve[ft].y);pt=qe.x>=ue.x&&We.x<=de.x&&qe.y>=ue.y&&We.y<=de.y?[ve]:We.x<ue.x||qe.x>de.x||We.y<ue.y||qe.y>de.y?[]:p.am([ve],ue.x,ue.y,de.x,de.y)}for(const qe of pt){Ce.reset(qe,.25*Se);let We=0;We=Ce.length<=.5*Se?1:Math.ceil(Ce.paddedLength/Oe)+1;for(let ft=0;ft<We;ft++){const Ut=ft/Math.max(We-1,1),Ri=Ce.lerp(Ut),mt=Ri.x+$e,oi=Ri.y+$e;U.push(mt,oi,Se,0);const ti=mt-Se,$t=oi-Se,qt=mt+Se,Bi=oi+Se;if(Te=Te&&this.isOffscreen(ti,$t,qt,Bi),he=he||this.isInsideGrid(ti,$t,qt,Bi),t!=="always"&&this.grid.hitTestCircle(mt,oi,Se,t,M)&&(oe=!0,!S))return{circles:[],offscreen:!1,collisionDetected:oe}}}}return{circles:!S&&oe||!he||O<this.perspectiveRatioCutoff?[]:U,offscreen:Te,collisionDetected:oe}}projectPathToScreenSpace(t,n,a){return t.map(l=>j(l,a,n.getElevation))}queryRenderedSymbols(t){if(t.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const n=[];let a=1/0,l=1/0,u=-1/0,m=-1/0;for(const S of t){const T=new p.P(S.x+$e,S.y+$e);a=Math.min(a,T.x),l=Math.min(l,T.y),u=Math.max(u,T.x),m=Math.max(m,T.y),n.push(T)}const g=this.grid.query(a,l,u,m).concat(this.ignoredGrid.query(a,l,u,m)),y={},v={};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 p.P(S.x1,S.y1),new p.P(S.x2,S.y1),new p.P(S.x2,S.y2),new p.P(S.x1,S.y2)];p.an(n,M)&&(y[T.bucketInstanceId][T.featureIndex]=!0,v[T.bucketInstanceId]===void 0&&(v[T.bucketInstanceId]=[]),v[T.bucketInstanceId].push(T.featureIndex))}return v}insertCollisionBox(t,n,a,l,u,m){(a?this.ignoredGrid:this.grid).insert({bucketInstanceId:l,featureIndex:u,collisionGroupID:m,overlapMode:n},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,n,a,l,u,m){const g=a?this.ignoredGrid:this.grid,y={bucketInstanceId:l,featureIndex:u,collisionGroupID:m,overlapMode:n};for(let v=0;v<t.length;v+=4)g.insertCircle(y,t[v],t[v+1],t[v+2])}projectAndGetPerspectiveRatio(t,n,a,l,u){const m=this.mapProjection.useSpecialProjectionForSymbols?this.mapProjection.projectTileCoordinates(n,a,l,u):j(new p.P(n,a),t,u);return{point:new p.P((m.point.x+1)/2*this.transform.width+$e,(1-m.point.y)/2*this.transform.height+$e),perspectiveRatio:.5+this.transform.cameraToCenterDistance/m.signedDistanceFromCamera*.5,isOccluded:m.isOccluded,signedDistanceFromCamera:m.signedDistanceFromCamera}}getPerspectiveRatio(t,n,a,l,u){const m=this.mapProjection.useSpecialProjectionForSymbols?this.mapProjection.projectTileCoordinates(n,a,l,u):j(new p.P(n,a),t,u);return .5+this.transform.cameraToCenterDistance/m.signedDistanceFromCamera*.5}isOffscreen(t,n,a,l){return a<$e||t>=this.screenRightBoundary||l<$e||n>this.screenBottomBoundary}isInsideGrid(t,n,a,l){return a>=0&&t<this.gridRightBoundary&&l>=0&&n<this.gridBottomBoundary}getViewportMatrix(){const t=p.ao([]);return p.J(t,t,[-100,-100,0]),t}_projectCollisionBox(t,n,a,l,u,m,g,y,v,S){const T=n*y.perspectiveRatio;let M=new p.P(1,0),z=new p.P(0,1);const R=new p.P(t.anchorPointX+g[0],t.anchorPointY+g[1]);if(m&&!u){const Se=this.projectAndGetPerspectiveRatio(a,R.x+1,R.y,l,v).point.sub(y.point).unit(),ue=Math.atan(Se.y/Se.x)+(Se.x<0?Math.PI:0),de=Math.sin(ue),Ce=Math.cos(ue);M=new p.P(Ce,de),z=new p.P(-de,Ce)}else if(!m&&u){const Se=-this.transform.angle,ue=Math.sin(Se),de=Math.cos(Se);M=new p.P(de,ue),z=new p.P(-ue,de)}let N=y.point,B=T;if(u){N=R;const Se=this.transform.zoom-Math.floor(this.transform.zoom);B=Math.pow(2,-Se),B*=this.mapProjection.getPitchedTextCorrection(this.transform,R,l),S||(B*=p.ad(.5+y.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))}S&&(N=N.add(M.mult(S.x*B)).add(z.mult(S.y*B)));const U=t.x1*B,G=t.x2*B,O=(U+G)/2,H=t.y1*B,Q=t.y2*B,ee=(H+Q)/2,oe=[{offsetX:U,offsetY:H},{offsetX:O,offsetY:H},{offsetX:G,offsetY:H},{offsetX:G,offsetY:ee},{offsetX:G,offsetY:Q},{offsetX:O,offsetY:Q},{offsetX:U,offsetY:Q},{offsetX:U,offsetY:ee}];let he=[];for(const{offsetX:Se,offsetY:ue}of oe)he.push(new p.P(N.x+M.x*Se+z.x*ue,N.y+M.y*Se+z.y*ue));let Te=!1;if(u){const Se=he.map(ue=>this.projectAndGetPerspectiveRatio(a,ue.x,ue.y,l,v));Te=Se.some(ue=>!ue.isOccluded),he=Se.map(ue=>ue.point)}else Te=!0;return{box:p.ap(he),allPointsOccluded:!Te}}}function Ue(h,t,n){return t*(p.X/(h.tileSize*Math.pow(2,n-h.tileID.overscaledZ)))}class ot{constructor(t,n,a,l){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?n:-n))):l&&a?1:0,this.placed=a}isHidden(){return this.opacity===0&&!this.placed}}class bt{constructor(t,n,a,l,u){this.text=new ot(t?t.text:null,n,a,u),this.icon=new ot(t?t.icon:null,n,l,u)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class At{constructor(t,n,a){this.text=t,this.icon=n,this.skipFade=a}}class Ge{constructor(){this.invProjMatrix=p.H(),this.viewportMatrix=p.H(),this.circles=[]}}class tt{constructor(t,n,a,l,u){this.bucketInstanceId=t,this.featureIndex=n,this.sourceLayerIndex=a,this.bucketIndex=l,this.tileID=u}}class gt{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const n=++this.maxGroupID;this.collisionGroups[t]={ID:n,predicate:a=>a.collisionGroupID===n}}return this.collisionGroups[t]}}function kt(h,t,n,a,l){const{horizontalAlign:u,verticalAlign:m}=p.av(h);return new p.P(-(u-.5)*t+a[0]*l,-(m-.5)*n+a[1]*l)}class Vt{constructor(t,n,a,l,u,m){this.transform=t.clone(),this.terrain=a,this.collisionIndex=new Ke(this.transform,n),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=l,this.retainedQueryData={},this.collisionGroups=new gt(u),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=m,m&&(m.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){const n=this.terrain;return n?(a,l)=>n.getElevation(t,a,l):null}getBucketParts(t,n,a,l){const u=a.getBucket(n),m=a.latestFeatureIndex;if(!u||!m||n.id!==u.layerIds[0])return;const g=a.collisionBoxArray,y=u.layers[0].layout,v=u.layers[0].paint,S=Math.pow(2,this.transform.zoom-a.tileID.overscaledZ),T=a.tileSize/p.X,M=a.tileID.toUnwrapped(),z=this.transform.calculatePosMatrix(M),R=y.get("text-pitch-alignment")==="map",N=y.get("text-rotation-alignment")==="map",B=Ue(a,1,this.transform.zoom),U=this.collisionIndex.mapProjection.translatePosition(this.transform,a,v.get("text-translate"),v.get("text-translate-anchor")),G=this.collisionIndex.mapProjection.translatePosition(this.transform,a,v.get("icon-translate"),v.get("icon-translate-anchor")),O=Pr(z,R,N,this.transform,B);let H=null;if(R){const ee=Yi(z,R,N,this.transform,B);H=p.L([],this.transform.labelPlaneMatrix,ee)}this.retainedQueryData[u.bucketInstanceId]=new tt(u.bucketInstanceId,m,u.sourceLayerIndex,u.index,a.tileID);const Q={bucket:u,layout:y,translationText:U,translationIcon:G,posMatrix:z,unwrappedTileID:M,textLabelPlaneMatrix:O,labelToScreenMatrix:H,scale:S,textPixelRatio:T,holdingForFade:a.holdingForFade(),collisionBoxArray:g,partiallyEvaluatedTextSize:p.ah(u.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(u.sourceID)};if(l)for(const ee of u.sortKeyRanges){const{sortKey:oe,symbolInstanceStart:he,symbolInstanceEnd:Te}=ee;t.push({sortKey:oe,symbolInstanceStart:he,symbolInstanceEnd:Te,parameters:Q})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:u.symbolInstances.length,parameters:Q})}attemptAnchorPlacement(t,n,a,l,u,m,g,y,v,S,T,M,z,R,N,B,U,G,O){const H=p.ar[t.textAnchor],Q=[t.textOffset0,t.textOffset1],ee=kt(H,a,l,Q,u),oe=this.collisionIndex.placeCollisionBox(n,M,y,v,S,g,m,B,T.predicate,O,ee);if((!G||this.collisionIndex.placeCollisionBox(G,M,y,v,S,g,m,U,T.predicate,O,ee).placeable)&&oe.placeable){let he;if(this.prevPlacement&&this.prevPlacement.variableOffsets[z.crossTileID]&&this.prevPlacement.placements[z.crossTileID]&&this.prevPlacement.placements[z.crossTileID].text&&(he=this.prevPlacement.variableOffsets[z.crossTileID].anchor),z.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[z.crossTileID]={textOffset:Q,width:a,height:l,anchor:H,textBoxScale:u,prevAnchor:he},this.markUsedJustification(R,H,z,N),R.allowVerticalPlacement&&(this.markUsedOrientation(R,N,z),this.placedOrientations[z.crossTileID]=N),{shift:ee,placedGlyphBoxes:oe}}}placeLayerBucketPart(t,n,a){const{bucket:l,layout:u,translationText:m,translationIcon:g,posMatrix:y,unwrappedTileID:v,textLabelPlaneMatrix:S,labelToScreenMatrix:T,textPixelRatio:M,holdingForFade:z,collisionBoxArray:R,partiallyEvaluatedTextSize:N,collisionGroup:B}=t.parameters,U=u.get("text-optional"),G=u.get("icon-optional"),O=p.as(u,"text-overlap","text-allow-overlap"),H=O==="always",Q=p.as(u,"icon-overlap","icon-allow-overlap"),ee=Q==="always",oe=u.get("text-rotation-alignment")==="map",he=u.get("text-pitch-alignment")==="map",Te=u.get("icon-text-fit")!=="none",Se=u.get("symbol-z-order")==="viewport-y",ue=H&&(ee||!l.hasIconData()||G),de=ee&&(H||!l.hasTextData()||U);!l.collisionArrays&&R&&l.deserializeCollisionBoxes(R);const Ce=this._getTerrainElevationFunc(this.retainedQueryData[l.bucketInstanceId].tileID),Ne=(_e,ve,Oe)=>{var pt,qe;if(n[_e.crossTileID])return;if(z)return void(this.placements[_e.crossTileID]=new At(!1,!1,!1));let We=!1,ft=!1,Ut=!0,Ri=null,mt={box:null,placeable:!1,offscreen:null},oi={box:null,placeable:!1,offscreen:null},ti=null,$t=null,qt=null,Bi=0,tn=0,Js=0;ve.textFeatureIndex?Bi=ve.textFeatureIndex:_e.useRuntimeCollisionCircles&&(Bi=_e.featureIndex),ve.verticalTextFeatureIndex&&(tn=ve.verticalTextFeatureIndex);const Sn=ve.textBox;if(Sn){const Bt=Zt=>{let Gt=p.ai.horizontal;if(l.allowVerticalPlacement&&!Zt&&this.prevPlacement){const Dt=this.prevPlacement.placedOrientations[_e.crossTileID];Dt&&(this.placedOrientations[_e.crossTileID]=Dt,Gt=Dt,this.markUsedOrientation(l,Gt,_e))}return Gt},Fi=(Zt,Gt)=>{if(l.allowVerticalPlacement&&_e.numVerticalGlyphVertices>0&&ve.verticalTextBox){for(const Dt of l.writingModes)if(Dt===p.ai.vertical?(mt=Gt(),oi=mt):mt=Zt(),mt&&mt.placeable)break}else mt=Zt()},Dr=_e.textAnchorOffsetStartIndex,In=_e.textAnchorOffsetEndIndex;if(In===Dr){const Zt=(Gt,Dt)=>{const xt=this.collisionIndex.placeCollisionBox(Gt,O,M,y,v,he,oe,m,B.predicate,Ce);return xt&&xt.placeable&&(this.markUsedOrientation(l,Dt,_e),this.placedOrientations[_e.crossTileID]=Dt),xt};Fi(()=>Zt(Sn,p.ai.horizontal),()=>{const Gt=ve.verticalTextBox;return l.allowVerticalPlacement&&_e.numVerticalGlyphVertices>0&&Gt?Zt(Gt,p.ai.vertical):{box:null,offscreen:null}}),Bt(mt&&mt.placeable)}else{let Zt=p.ar[(qe=(pt=this.prevPlacement)===null||pt===void 0?void 0:pt.variableOffsets[_e.crossTileID])===null||qe===void 0?void 0:qe.anchor];const Gt=(xt,Pn,ho)=>{const zt=xt.x2-xt.x1,ml=xt.y2-xt.y1,Qs=_e.textBoxScale,ea=Te&&Q==="never"?Pn:null;let Lr=null,_l=O==="never"?1:2,uo="never";Zt&&_l++;for(let po=0;po<_l;po++){for(let fo=Dr;fo<In;fo++){const ta=l.textAnchorOffsets.get(fo);if(Zt&&ta.textAnchor!==Zt)continue;const An=this.attemptAnchorPlacement(ta,xt,zt,ml,Qs,oe,he,M,y,v,B,uo,_e,l,ho,m,g,ea,Ce);if(An&&(Lr=An.placedGlyphBoxes,Lr&&Lr.placeable))return We=!0,Ri=An.shift,Lr}Zt?Zt=null:uo=O}return a&&!Lr&&(Lr={box:this.collisionIndex.placeCollisionBox(Sn,"always",M,y,v,he,oe,m,B.predicate,Ce,new p.P(0,0)).box,offscreen:!1,placeable:!1}),Lr};Fi(()=>Gt(Sn,ve.iconBox,p.ai.horizontal),()=>{const xt=ve.verticalTextBox;return l.allowVerticalPlacement&&(!mt||!mt.placeable)&&_e.numVerticalGlyphVertices>0&&xt?Gt(xt,ve.verticalIconBox,p.ai.vertical):{box:null,occluded:!0,offscreen:null}}),mt&&(We=mt.placeable,Ut=mt.offscreen);const Dt=Bt(mt&&mt.placeable);if(!We&&this.prevPlacement){const xt=this.prevPlacement.variableOffsets[_e.crossTileID];xt&&(this.variableOffsets[_e.crossTileID]=xt,this.markUsedJustification(l,xt.anchor,_e,Dt))}}}if(ti=mt,We=ti&&ti.placeable,Ut=ti&&ti.offscreen,_e.useRuntimeCollisionCircles){const Bt=l.text.placedSymbolArray.get(_e.centerJustifiedTextSymbolIndex),Fi=p.aj(l.textSizeData,N,Bt),Dr=u.get("text-padding");$t=this.collisionIndex.placeCollisionCircles(O,Bt,l.lineVertexArray,l.glyphOffsetArray,Fi,y,v,S,T,a,he,B.predicate,_e.collisionCircleDiameter,Dr,m,Ce),$t.circles.length&&$t.collisionDetected&&!a&&p.w("Collisions detected, but collision boxes are not shown"),We=H||$t.circles.length>0&&!$t.collisionDetected,Ut=Ut&&$t.offscreen}if(ve.iconFeatureIndex&&(Js=ve.iconFeatureIndex),ve.iconBox){const Bt=Fi=>this.collisionIndex.placeCollisionBox(Fi,Q,M,y,v,he,oe,g,B.predicate,Ce,Te&&Ri?Ri:void 0);oi&&oi.placeable&&ve.verticalIconBox?(qt=Bt(ve.verticalIconBox),ft=qt.placeable):(qt=Bt(ve.iconBox),ft=qt.placeable),Ut=Ut&&qt.offscreen}const rn=U||_e.numHorizontalGlyphVertices===0&&_e.numVerticalGlyphVertices===0,Ys=G||_e.numIconVertices===0;rn||Ys?Ys?rn||(ft=ft&&We):We=ft&&We:ft=We=ft&&We;const co=ft&&qt.placeable;if(We&&ti.placeable&&this.collisionIndex.insertCollisionBox(ti.box,O,u.get("text-ignore-placement"),l.bucketInstanceId,oi&&oi.placeable&&tn?tn:Bi,B.ID),co&&this.collisionIndex.insertCollisionBox(qt.box,Q,u.get("icon-ignore-placement"),l.bucketInstanceId,Js,B.ID),$t&&We&&this.collisionIndex.insertCollisionCircles($t.circles,O,u.get("text-ignore-placement"),l.bucketInstanceId,Bi,B.ID),a&&this.storeCollisionData(l.bucketInstanceId,Oe,ve,ti,qt,$t),_e.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[_e.crossTileID]=new At(We||ue,ft||de,Ut||l.justReloaded),n[_e.crossTileID]=!0};if(Se){if(t.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const _e=l.getSortedSymbolIndexes(this.transform.angle);for(let ve=_e.length-1;ve>=0;--ve){const Oe=_e[ve];Ne(l.symbolInstances.get(Oe),l.collisionArrays[Oe],Oe)}}else for(let _e=t.symbolInstanceStart;_e<t.symbolInstanceEnd;_e++)Ne(l.symbolInstances.get(_e),l.collisionArrays[_e],_e);if(a&&l.bucketInstanceId in this.collisionCircleArrays){const _e=this.collisionCircleArrays[l.bucketInstanceId];p.at(_e.invProjMatrix,y),_e.viewportMatrix=this.collisionIndex.getViewportMatrix()}l.justReloaded=!1}storeCollisionData(t,n,a,l,u,m){if(a.textBox||a.iconBox){let g,y;this.collisionBoxArrays.has(t)?g=this.collisionBoxArrays.get(t):(g=new Map,this.collisionBoxArrays.set(t,g)),g.has(n)?y=g.get(n):(y={text:null,icon:null},g.set(n,y)),a.textBox&&(y.text=l.box),a.iconBox&&(y.icon=u.box)}if(m){let g=this.collisionCircleArrays[t];g===void 0&&(g=this.collisionCircleArrays[t]=new Ge);for(let y=0;y<m.circles.length;y+=4)g.circles.push(m.circles[y+0]),g.circles.push(m.circles[y+1]),g.circles.push(m.circles[y+2]),g.circles.push(m.collisionDetected?1:0)}}markUsedJustification(t,n,a,l){let u;u=l===p.ai.vertical?a.verticalPlacedTextSymbolIndex:{left:a.leftJustifiedTextSymbolIndex,center:a.centerJustifiedTextSymbolIndex,right:a.rightJustifiedTextSymbolIndex}[p.au(n)];const m=[a.leftJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.rightJustifiedTextSymbolIndex,a.verticalPlacedTextSymbolIndex];for(const g of m)g>=0&&(t.text.placedSymbolArray.get(g).crossTileID=u>=0&&g!==u?0:a.crossTileID)}markUsedOrientation(t,n,a){const l=n===p.ai.horizontal||n===p.ai.horizontalOnly?n:0,u=n===p.ai.vertical?n:0,m=[a.leftJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.rightJustifiedTextSymbolIndex];for(const g of m)t.text.placedSymbolArray.get(g).placedOrientation=l;a.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(a.verticalPlacedTextSymbolIndex).placedOrientation=u)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let a=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const l=n?n.symbolFadeChange(t):1,u=n?n.opacities:{},m=n?n.variableOffsets:{},g=n?n.placedOrientations:{};for(const y in this.placements){const v=this.placements[y],S=u[y];S?(this.opacities[y]=new bt(S,l,v.text,v.icon),a=a||v.text!==S.text.placed||v.icon!==S.icon.placed):(this.opacities[y]=new bt(null,l,v.text,v.icon,v.skipFade),a=a||v.text||v.icon)}for(const y in u){const v=u[y];if(!this.opacities[y]){const S=new bt(v,l,!1,!1);S.isHidden()||(this.opacities[y]=S,a=a||v.text.placed||v.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");a?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:t)}updateLayerOpacities(t,n){const a={};for(const l of n){const u=l.getBucket(t);u&&l.latestFeatureIndex&&t.id===u.layerIds[0]&&this.updateBucketOpacities(u,l.tileID,a,l.collisionBoxArray)}}updateBucketOpacities(t,n,a,l){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const u=t.layers[0],m=u.layout,g=new bt(null,0,!1,!1,!0),y=m.get("text-allow-overlap"),v=m.get("icon-allow-overlap"),S=u._unevaluatedLayout.hasValue("text-variable-anchor")||u._unevaluatedLayout.hasValue("text-variable-anchor-offset"),T=m.get("text-rotation-alignment")==="map",M=m.get("text-pitch-alignment")==="map",z=m.get("icon-text-fit")!=="none",R=new bt(null,0,y&&(v||!t.hasIconData()||m.get("icon-optional")),v&&(y||!t.hasTextData()||m.get("text-optional")),!0);!t.collisionArrays&&l&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(l);const N=(U,G,O)=>{for(let H=0;H<G/4;H++)U.opacityVertexArray.emplaceBack(O);U.hasVisibleVertices=U.hasVisibleVertices||O!==jt},B=this.collisionBoxArrays.get(t.bucketInstanceId);for(let U=0;U<t.symbolInstances.length;U++){const G=t.symbolInstances.get(U),{numHorizontalGlyphVertices:O,numVerticalGlyphVertices:H,crossTileID:Q}=G;let ee=this.opacities[Q];a[Q]?ee=g:ee||(ee=R,this.opacities[Q]=ee),a[Q]=!0;const oe=G.numIconVertices>0,he=this.placedOrientations[G.crossTileID],Te=he===p.ai.vertical,Se=he===p.ai.horizontal||he===p.ai.horizontalOnly;if(O>0||H>0){const de=gi(ee.text);N(t.text,O,Te?jt:de),N(t.text,H,Se?jt:de);const Ce=ee.text.isHidden();[G.rightJustifiedTextSymbolIndex,G.centerJustifiedTextSymbolIndex,G.leftJustifiedTextSymbolIndex].forEach(ve=>{ve>=0&&(t.text.placedSymbolArray.get(ve).hidden=Ce||Te?1:0)}),G.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(G.verticalPlacedTextSymbolIndex).hidden=Ce||Se?1:0);const Ne=this.variableOffsets[G.crossTileID];Ne&&this.markUsedJustification(t,Ne.anchor,G,he);const _e=this.placedOrientations[G.crossTileID];_e&&(this.markUsedJustification(t,"left",G,_e),this.markUsedOrientation(t,_e,G))}if(oe){const de=gi(ee.icon),Ce=!(z&&G.verticalPlacedIconSymbolIndex&&Te);G.placedIconSymbolIndex>=0&&(N(t.icon,G.numIconVertices,Ce?de:jt),t.icon.placedSymbolArray.get(G.placedIconSymbolIndex).hidden=ee.icon.isHidden()),G.verticalPlacedIconSymbolIndex>=0&&(N(t.icon,G.numVerticalIconVertices,Ce?jt:de),t.icon.placedSymbolArray.get(G.verticalPlacedIconSymbolIndex).hidden=ee.icon.isHidden())}const ue=B&&B.has(U)?B.get(U):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const de=t.collisionArrays[U];if(de){let Ce=new p.P(0,0);if(de.textBox||de.verticalTextBox){let Ne=!0;if(S){const _e=this.variableOffsets[Q];_e?(Ce=kt(_e.anchor,_e.width,_e.height,_e.textOffset,_e.textBoxScale),T&&Ce._rotate(M?this.transform.angle:-this.transform.angle)):Ne=!1}if(de.textBox||de.verticalTextBox){let _e;de.textBox&&(_e=Te),de.verticalTextBox&&(_e=Se),Nt(t.textCollisionBox.collisionVertexArray,ee.text.placed,!Ne||_e,ue.text,Ce.x,Ce.y)}}if(de.iconBox||de.verticalIconBox){const Ne=!!(!Se&&de.verticalIconBox);let _e;de.iconBox&&(_e=Ne),de.verticalIconBox&&(_e=!Ne),Nt(t.iconCollisionBox.collisionVertexArray,ee.icon.placed,_e,ue.icon,z?Ce.x:0,z?Ce.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 U=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=U.invProjMatrix,t.placementViewportMatrix=U.viewportMatrix,t.collisionCircleArray=U.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 a=this.zoomAtLastRecencyCheck===n?1-this.zoomAdjustment(n):1;return this.zoomAtLastRecencyCheck=n,this.commitTime+this.fadeDuration*a>t}setStale(){this.stale=!0}}function Nt(h,t,n,a,l,u){a&&a.length!==0||(a=[0,0,0,0]);const m=a[0]-$e,g=a[1]-$e,y=a[2]-$e,v=a[3]-$e;h.emplaceBack(t?1:0,n?1:0,l||0,u||0,m,g),h.emplaceBack(t?1:0,n?1:0,l||0,u||0,y,g),h.emplaceBack(t?1:0,n?1:0,l||0,u||0,y,v),h.emplaceBack(t?1:0,n?1:0,l||0,u||0,m,v)}const Un=Math.pow(2,25),it=Math.pow(2,24),_a=Math.pow(2,17),ga=Math.pow(2,16),mi=Math.pow(2,9),_i=Math.pow(2,8),Nl=Math.pow(2,1);function gi(h){if(h.opacity===0&&!h.placed)return 0;if(h.opacity===1&&h.placed)return 4294967295;const t=h.placed?1:0,n=Math.floor(127*h.opacity);return n*Un+t*it+n*_a+t*ga+n*mi+t*_i+n*Nl+t}const jt=0;function bs(){return{isOccluded:(h,t,n)=>!1,getPitchedTextCorrection:(h,t,n)=>1,get useSpecialProjectionForSymbols(){return!1},projectTileCoordinates(h,t,n,a){throw new Error("Not implemented.")},translatePosition:(h,t,n,a)=>function(l,u,m,g,y=!1){if(!m[0]&&!m[1])return[0,0];const v=y?g==="map"?l.angle:0:g==="viewport"?-l.angle:0;if(v){const S=Math.sin(v),T=Math.cos(v);m=[m[0]*T-m[1]*S,m[0]*S+m[1]*T]}return[y?m[0]:Ue(u,m[0],l.zoom),y?m[1]:Ue(u,m[1],l.zoom)]}(h,t,n,a),getCircleRadiusCorrection:h=>1}}class $n{constructor(t){this._sortAcrossTiles=t.layout.get("symbol-z-order")!=="viewport-y"&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,n,a,l,u){const m=this._bucketParts;for(;this._currentTileIndex<t.length;)if(n.getBucketParts(m,l,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,u())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,a),this._currentPartIndex++,u())return!0;return!1}}class Ct{constructor(t,n,a,l,u,m,g,y){this.placement=new Vt(t,bs(),n,m,g,y),this._currentPlacementIndex=a.length-1,this._forceFullPlacement=l,this._showCollisionBoxes=u,this._done=!1}isDone(){return this._done}continuePlacement(t,n,a){const l=me.now(),u=()=>!this._forceFullPlacement&&me.now()-l>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 $n(m)),this._inProgressLayer.continuePlacement(a[m.source],this.placement,this._showCollisionBoxes,m,u))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const ur=512/p.X/2;class Zr{constructor(t,n,a){this.tileID=t,this.bucketInstanceId=a,this._symbolsByKey={};const l=new Map;for(let u=0;u<n.length;u++){const m=n.get(u),g=m.key,y=l.get(g);y?y.push(m):l.set(g,[m])}for(const[u,m]of l){const g={positions:m.map(y=>({x:Math.floor(y.anchorX*ur),y:Math.floor(y.anchorY*ur)})),crossTileIDs:m.map(y=>y.crossTileID)};if(g.positions.length>128){const y=new p.aw(g.positions.length,16,Uint16Array);for(const{x:v,y:S}of g.positions)y.add(v,S);y.finish(),delete g.positions,g.index=y}this._symbolsByKey[u]=g}}getScaledCoordinates(t,n){const{x:a,y:l,z:u}=this.tileID.canonical,{x:m,y:g,z:y}=n.canonical,v=ur/Math.pow(2,y-u),S=(g*p.X+t.anchorY)*v,T=l*p.X*ur;return{x:Math.floor((m*p.X+t.anchorX)*v-a*p.X*ur),y:Math.floor(S-T)}}findMatches(t,n,a){const l=this.tileID.canonical.z<n.canonical.z?1:Math.pow(2,this.tileID.canonical.z-n.canonical.z);for(let u=0;u<t.length;u++){const m=t.get(u);if(m.crossTileID)continue;const g=this._symbolsByKey[m.key];if(!g)continue;const y=this.getScaledCoordinates(m,n);if(g.index){const v=g.index.range(y.x-l,y.y-l,y.x+l,y.y+l).sort();for(const S of v){const T=g.crossTileIDs[S];if(!a[T]){a[T]=!0,m.crossTileID=T;break}}}else if(g.positions)for(let v=0;v<g.positions.length;v++){const S=g.positions[v],T=g.crossTileIDs[v];if(Math.abs(S.x-y.x)<=l&&Math.abs(S.y-y.y)<=l&&!a[T]){a[T]=!0,m.crossTileID=T;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:t})=>t)}}class It{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ws{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const n=Math.round((t-this.lng)/360);if(n!==0)for(const a in this.indexes){const l=this.indexes[a],u={};for(const m in l){const g=l[m];g.tileID=g.tileID.unwrapTo(g.tileID.wrap+n),u[g.tileID.key]=g}this.indexes[a]=u}this.lng=t}addBucket(t,n,a){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let u=0;u<n.symbolInstances.length;u++)n.symbolInstances.get(u).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const l=this.usedCrossTileIDs[t.overscaledZ];for(const u in this.indexes){const m=this.indexes[u];if(Number(u)>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(u)).key];g&&g.findMatches(n.symbolInstances,t,l)}}for(let u=0;u<n.symbolInstances.length;u++){const m=n.symbolInstances.get(u);m.crossTileID||(m.crossTileID=a.generate(),l[m.crossTileID]=!0)}return this.indexes[t.overscaledZ]===void 0&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Zr(t,n.symbolInstances,n.bucketInstanceId),!0}removeBucketCrossTileIDs(t,n){for(const a of n.getCrossTileIDsLists())for(const l of a)delete this.usedCrossTileIDs[t][l]}removeStaleBuckets(t){let n=!1;for(const a in this.indexes){const l=this.indexes[a];for(const u in l)t[l[u].bucketInstanceId]||(this.removeBucketCrossTileIDs(a,l[u]),delete l[u],n=!0)}return n}}class Pi{constructor(){this.layerIndexes={},this.crossTileIDs=new It,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,n,a){let l=this.layerIndexes[t.id];l===void 0&&(l=this.layerIndexes[t.id]=new ws);let u=!1;const m={};l.handleWrapJump(a);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)&&(u=!0),m[y.bucketInstanceId]=!0)}return l.removeStaleBuckets(m)&&(u=!0),u}pruneUnusedLayers(t){const n={};t.forEach(a=>{n[a]=!0});for(const a in this.layerIndexes)n[a]||delete this.layerIndexes[a]}}const qn=(h,t)=>p.t(h,t&&t.filter(n=>n.identifier!=="source.canvas")),Ar=p.ax();class ya extends p.E{constructor(t,n={}){super(),this._rtlPluginLoaded=()=>{for(const a in this.sourceCaches){const l=this.sourceCaches[a].getSource().type;l!=="vector"&&l!=="geojson"||this.sourceCaches[a].reload()}},this.map=t,this.dispatcher=new $r(Ur(),t._getMapId()),this.dispatcher.registerMessageHandler("GG",(a,l)=>this.getGlyphs(a,l)),this.dispatcher.registerMessageHandler("GI",(a,l)=>this.getImages(a,l)),this.imageManager=new Ot,this.imageManager.setEventedParent(this),this.glyphManager=new Xi(t._requestManager,n.localIdeographFontFamily),this.lineAtlas=new cn(256,512),this.crossTileSymbolIndex=new Pi,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new p.ay,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",p.az()),Ki().on(pe,this._rtlPluginLoaded),this.on("data",a=>{if(a.dataType!=="source"||a.sourceDataType!=="metadata")return;const l=this.sourceCaches[a.sourceId];if(!l)return;const u=l.getSource();if(u&&u.vectorLayerIds)for(const m in this._layers){const g=this._layers[m];g.source===u.id&&this._validateLayer(g)}})}loadURL(t,n={},a){this.fire(new p.k("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const l=this.map._requestManager.transformRequest(t,"Style");this._loadStyleRequest=new AbortController,p.h(l,this._loadStyleRequest).then(u=>{this._loadStyleRequest=null,this._load(u.data,n,a)}).catch(u=>{this._loadStyleRequest=null,u&&this.fire(new p.j(u))})}loadJSON(t,n={},a){this.fire(new p.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,me.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(t,n,a)}).catch(()=>{})}loadEmpty(){this.fire(new p.k("dataloading",{dataType:"style"})),this._load(Ar,{validate:!1})}_load(t,n,a){var l;const u=n.transformStyle?n.transformStyle(a,t):t;if(!n.validate||!qn(this,p.x(u))){this._loaded=!0,this.stylesheet=u;for(const m in u.sources)this.addSource(m,u.sources[m],{validate:!1});u.sprite?this._loadSprite(u.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(u.glyphs),this._createLayers(),this.light=new or(this.stylesheet.light),this.sky=new ki(this.stylesheet.sky),this.map.setTerrain((l=this.stylesheet.terrain)!==null&&l!==void 0?l:null),this.fire(new p.k("data",{dataType:"style"})),this.fire(new p.k("style.load"))}}_createLayers(){const t=p.aA(this.stylesheet.layers);this.dispatcher.broadcast("SL",t),this._order=t.map(n=>n.id),this._layers={},this._serializedLayers=null;for(const n of t){const a=p.aB(n);a.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=a}}_loadSprite(t,n=!1,a=void 0){let l;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(u,m,g,y){return p._(this,void 0,void 0,function*(){const v=Gi(u),S=g>1?"@2x":"",T={},M={};for(const{id:z,url:R}of v){const N=m.transformRequest(Bn(R,S,".json"),"SpriteJSON");T[z]=p.h(N,y);const B=m.transformRequest(Bn(R,S,".png"),"SpriteImage");M[z]=pi.getImage(B,y)}return yield Promise.all([...Object.values(T),...Object.values(M)]),function(z,R){return p._(this,void 0,void 0,function*(){const N={};for(const B in z){N[B]={};const U=me.getImageCanvasContext((yield R[B]).data),G=(yield z[B]).data;for(const O in G){const{width:H,height:Q,x:ee,y:oe,sdf:he,pixelRatio:Te,stretchX:Se,stretchY:ue,content:de,textFitWidth:Ce,textFitHeight:Ne}=G[O];N[B][O]={data:null,pixelRatio:Te,sdf:he,stretchX:Se,stretchY:ue,content:de,textFitWidth:Ce,textFitHeight:Ne,spriteData:{width:H,height:Q,x:ee,y:oe,context:U}}}}return N})}(T,M)})}(t,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(u=>{if(this._spriteRequest=null,u)for(const m in u){this._spritesImagesIds[m]=[];const g=this._spritesImagesIds[m]?this._spritesImagesIds[m].filter(y=>!(y in u)):[];for(const y of g)this.imageManager.removeImage(y),this._changedImages[y]=!0;for(const y in u[m]){const v=m==="default"?y:`${m}:${y}`;this._spritesImagesIds[m].push(v),v in this.imageManager.images?this.imageManager.updateImage(v,u[m][y],!1):this.imageManager.addImage(v,u[m][y]),n&&(this._changedImages[v]=!0)}}}).catch(u=>{this._spriteRequest=null,l=u,this.fire(new p.j(l))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.k("data",{dataType:"style"})),a&&a(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("SI",this._availableImages),this.fire(new p.k("data",{dataType:"style"}))}_validateLayer(t){const n=this.sourceCaches[t.source];if(!n)return;const a=t.sourceLayer;if(!a)return;const l=n.getSource();(l.type==="geojson"||l.vectorLayerIds&&l.vectorLayerIds.indexOf(a)===-1)&&this.fire(new p.j(new Error(`Source layer "${a}" does not exist on source "${l.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(t){const n=this._serializedAllLayers();if(!t||t.length===0)return Object.values(n);const a=[];for(const l of t)n[l]&&a.push(n[l]);return a}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const n=Object.keys(this._layers);for(const a of n){const l=this._layers[a];l.type!=="custom"&&(t[a]=l.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition()||this.sky&&this.sky.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(n){const l=Object.keys(this._updatedLayers),u=Object.keys(this._removedLayers);(l.length||u.length)&&this._updateWorkerLayers(l,u);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.sky.updateTransitions(t),this._resetUpdates()}const a={};for(const l in this.sourceCaches){const u=this.sourceCaches[l];a[l]=u.used,u.used=!1}for(const l of this._order){const u=this._layers[l];u.recalculate(t,this._availableImages),!u.isHidden(t.zoom)&&u.source&&(this.sourceCaches[u.source].used=!0)}for(const l in a){const u=this.sourceCaches[l];!!a[l]!=!!u.used&&u.fire(new p.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:l}))}this.light.recalculate(t),this.sky.recalculate(t),this.z=t.zoom,n&&this.fire(new p.k("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("UL",{layers:this._serializeByIds(t),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,n={}){var a;this._checkLoaded();const l=this.serialize();if(t=n.transformStyle?n.transformStyle(l,t):t,((a=n.validate)===null||a===void 0||a)&&qn(this,p.x(t)))return!1;(t=p.aC(t)).layers=p.aA(t.layers);const u=p.aD(l,t),m=this._getOperationsToPerform(u);if(m.unimplemented.length>0)throw new Error(`Unimplemented: ${m.unimplemented.join(", ")}.`);if(m.operations.length===0)return!1;for(const g of m.operations)g();return this.stylesheet=t,this._serializedLayers=null,!0}_getOperationsToPerform(t){const n=[],a=[];for(const l of t)switch(l.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":continue;case"addLayer":n.push(()=>this.addLayer.apply(this,l.args));break;case"removeLayer":n.push(()=>this.removeLayer.apply(this,l.args));break;case"setPaintProperty":n.push(()=>this.setPaintProperty.apply(this,l.args));break;case"setLayoutProperty":n.push(()=>this.setLayoutProperty.apply(this,l.args));break;case"setFilter":n.push(()=>this.setFilter.apply(this,l.args));break;case"addSource":n.push(()=>this.addSource.apply(this,l.args));break;case"removeSource":n.push(()=>this.removeSource.apply(this,l.args));break;case"setLayerZoomRange":n.push(()=>this.setLayerZoomRange.apply(this,l.args));break;case"setLight":n.push(()=>this.setLight.apply(this,l.args));break;case"setGeoJSONSourceData":n.push(()=>this.setGeoJSONSourceData.apply(this,l.args));break;case"setGlyphs":n.push(()=>this.setGlyphs.apply(this,l.args));break;case"setSprite":n.push(()=>this.setSprite.apply(this,l.args));break;case"setSky":n.push(()=>this.setSky.apply(this,l.args));break;case"setTerrain":n.push(()=>this.map.setTerrain.apply(this,l.args));break;case"setTransition":n.push(()=>{});break;default:a.push(l.command)}return{operations:n,unimplemented:a}}addImage(t,n){if(this.getImage(t))return this.fire(new p.j(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 p.j(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.k("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,n,a={}){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(p.x.source,`sources.${t}`,n,null,a))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const l=this.sourceCaches[t]=new Fe(t,n,this.dispatcher);l.style=this,l.setEventedParent(this,()=>({isSourceLoaded:l.loaded(),source:l.serialize(),sourceId:t})),l.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),this.sourceCaches[t]===void 0)throw new Error("There is no source with this ID");for(const a in this._layers)if(this._layers[a].source===t)return this.fire(new p.j(new Error(`Source "${t}" cannot be removed while layer "${a}" is using it.`)));const n=this.sourceCaches[t];delete this.sourceCaches[t],delete this._updatedSources[t],n.fire(new p.k("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 a=this.sourceCaches[t].getSource();if(a.type!=="geojson")throw new Error(`geojsonSource.type is ${a.type}, which is !== 'geojson`);a.setData(n),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(t,n,a={}){this._checkLoaded();const l=t.id;if(this.getLayer(l))return void this.fire(new p.j(new Error(`Layer "${l}" already exists on this map.`)));let u;if(t.type==="custom"){if(qn(this,p.aE(t)))return;u=p.aB(t)}else{if("source"in t&&typeof t.source=="object"&&(this.addSource(l,t.source),t=p.aC(t),t=p.e(t,{source:l})),this._validate(p.x.layer,`layers.${l}`,t,{arrayIndex:-1},a))return;u=p.aB(t),this._validateLayer(u),u.setEventedParent(this,{layer:{id:l}})}const m=n?this._order.indexOf(n):this._order.length;if(n&&m===-1)this.fire(new p.j(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]=u,this._removedLayers[l]&&u.source&&u.type!=="custom"){const g=this._removedLayers[l];delete this._removedLayers[l],g.type!==u.type?this._updatedSources[u.source]="clear":(this._updatedSources[u.source]="reload",this.sourceCaches[u.source].pause())}this._updateLayer(u),u.onAdd&&u.onAdd(this.map)}}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new p.j(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===n)return;const a=this._order.indexOf(t);this._order.splice(a,1);const l=n?this._order.indexOf(n):this._order.length;n&&l===-1?this.fire(new p.j(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 p.j(new Error(`Cannot remove non-existing layer "${t}".`)));n.setEventedParent(null);const a=this._order.indexOf(t);this._order.splice(a,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,n,a){this._checkLoaded();const l=this.getLayer(t);l?l.minzoom===n&&l.maxzoom===a||(n!=null&&(l.minzoom=n),a!=null&&(l.maxzoom=a),this._updateLayer(l)):this.fire(new p.j(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,n,a={}){this._checkLoaded();const l=this.getLayer(t);if(l){if(!p.aF(l.filter,n))return n==null?(l.filter=void 0,void this._updateLayer(l)):void(this._validate(p.x.filter,`layers.${l.id}.filter`,n,null,a)||(l.filter=p.aC(n),this._updateLayer(l)))}else this.fire(new p.j(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return p.aC(this.getLayer(t).filter)}setLayoutProperty(t,n,a,l={}){this._checkLoaded();const u=this.getLayer(t);u?p.aF(u.getLayoutProperty(n),a)||(u.setLayoutProperty(n,a,l),this._updateLayer(u)):this.fire(new p.j(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,n){const a=this.getLayer(t);if(a)return a.getLayoutProperty(n);this.fire(new p.j(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,n,a,l={}){this._checkLoaded();const u=this.getLayer(t);u?p.aF(u.getPaintProperty(n),a)||(u.setPaintProperty(n,a,l)&&this._updateLayer(u),this._changed=!0,this._updatedPaintProps[t]=!0,this._serializedLayers=null):this.fire(new p.j(new Error(`Cannot style non-existing layer "${t}".`)))}getPaintProperty(t,n){return this.getLayer(t).getPaintProperty(n)}setFeatureState(t,n){this._checkLoaded();const a=t.source,l=t.sourceLayer,u=this.sourceCaches[a];if(u===void 0)return void this.fire(new p.j(new Error(`The source '${a}' does not exist in the map's style.`)));const m=u.getSource().type;m==="geojson"&&l?this.fire(new p.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):m!=="vector"||l?(t.id===void 0&&this.fire(new p.j(new Error("The feature id parameter must be provided."))),u.setFeatureState(l,t.id,n)):this.fire(new p.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,n){this._checkLoaded();const a=t.source,l=this.sourceCaches[a];if(l===void 0)return void this.fire(new p.j(new Error(`The source '${a}' does not exist in the map's style.`)));const u=l.getSource().type,m=u==="vector"?t.sourceLayer:void 0;u!=="vector"||m?n&&typeof t.id!="string"&&typeof t.id!="number"?this.fire(new p.j(new Error("A feature id is required to remove its specific state property."))):l.removeFeatureState(m,t.id,n):this.fire(new p.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const n=t.source,a=t.sourceLayer,l=this.sourceCaches[n];if(l!==void 0)return l.getSource().type!=="vector"||a?(t.id===void 0&&this.fire(new p.j(new Error("The feature id parameter must be provided."))),l.getFeatureState(a,t.id)):void this.fire(new p.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new p.j(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return p.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=p.aG(this.sourceCaches,u=>u.serialize()),n=this._serializeByIds(this._order),a=this.map.getTerrain()||void 0,l=this.stylesheet;return p.aH({version:l.version,name:l.name,metadata:l.metadata,light:l.light,sky:l.sky,center:l.center,zoom:l.zoom,bearing:l.bearing,pitch:l.pitch,sprite:l.sprite,glyphs:l.glyphs,transition:l.transition,sources:t,layers:n,terrain:a},u=>u!==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._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){const n=m=>this._layers[m].type==="fill-extrusion",a={},l=[];for(let m=this._order.length-1;m>=0;m--){const g=this._order[m];if(n(g)){a[g]=m;for(const y of t){const v=y[g];if(v)for(const S of v)l.push(S)}}}l.sort((m,g)=>g.intersectionZ-m.intersectionZ);const u=[];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 v=l[y].feature;if(a[v.layer.id]<m)break;u.push(v),l.pop()}else for(const y of t){const v=y[g];if(v)for(const S of v)u.push(S.feature)}}return u}queryRenderedFeatures(t,n,a){n&&n.filter&&this._validate(p.x.filter,"queryRenderedFeatures.filter",n.filter,null,n);const l={};if(n&&n.layers){if(!Array.isArray(n.layers))return this.fire(new p.j(new Error("parameters.layers must be an Array."))),[];for(const g of n.layers){const y=this._layers[g];if(!y)return this.fire(new p.j(new Error(`The layer '${g}' does not exist in the map's style and cannot be queried for features.`))),[];l[y.source]=!0}}const u=[];n.availableImages=this._availableImages;const m=this._serializedAllLayers();for(const g in this.sourceCaches)n.layers&&!l[g]||u.push(wr(this.sourceCaches[g],this._layers,m,t,n,a));return this.placement&&u.push(function(g,y,v,S,T,M,z){const R={},N=M.queryRenderedSymbols(S),B=[];for(const U of Object.keys(N).map(Number))B.push(z[U]);B.sort(Tr);for(const U of B){const G=U.featureIndex.lookupSymbolFeatures(N[U.bucketInstanceId],y,U.bucketIndex,U.sourceLayerIndex,T.filter,T.layers,T.availableImages,g);for(const O in G){const H=R[O]=R[O]||[],Q=G[O];Q.sort((ee,oe)=>{const he=U.featureSortOrder;if(he){const Te=he.indexOf(ee.featureIndex);return he.indexOf(oe.featureIndex)-Te}return oe.featureIndex-ee.featureIndex});for(const ee of Q)H.push(ee)}}for(const U in R)R[U].forEach(G=>{const O=G.feature,H=v[g[U].source].getFeatureState(O.layer["source-layer"],O.id);O.source=O.layer.source,O.layer["source-layer"]&&(O.sourceLayer=O.layer["source-layer"]),O.state=H});return R}(this._layers,m,this.sourceCaches,t,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(u)}querySourceFeatures(t,n){n&&n.filter&&this._validate(p.x.filter,"querySourceFeatures.filter",n.filter,null,n);const a=this.sourceCaches[t];return a?function(l,u){const m=l.getRenderableIds().map(v=>l.getTileByID(v)),g=[],y={};for(let v=0;v<m.length;v++){const S=m[v],T=S.tileID.canonical.key;y[T]||(y[T]=!0,S.querySourceFeatures(g,u))}return g}(a,n):[]}getLight(){return this.light.getLight()}setLight(t,n={}){this._checkLoaded();const a=this.light.getLight();let l=!1;for(const m in t)if(!p.aF(t[m],a[m])){l=!0;break}if(!l)return;const u={now:me.now(),transition:p.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,n),this.light.updateTransitions(u)}getSky(){var t;return(t=this.stylesheet)===null||t===void 0?void 0:t.sky}setSky(t,n={}){const a=this.sky.getSky();let l=!1;t||a&&(l=!0);for(const m in t)if(!p.aF(t[m],a[m])){l=!0;break}if(!l)return;const u={now:me.now(),transition:p.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=t,this.sky.setSky(t,n),this.sky.updateTransitions(u)}_validate(t,n,a,l,u={}){return(!u||u.validate!==!1)&&qn(this,t.call(p.x,p.e({key:n,style:this.serialize(),value:a,styleSpec:p.v},l)))}_remove(t=!0){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),Ki().off(pe,this._rtlPluginLoaded);for(const n in this._layers)this._layers[n].setEventedParent(null);for(const n in this.sourceCaches){const a=this.sourceCaches[n];a.setEventedParent(null),a.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),t&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(t)}_clearSource(t){this.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,a,l,u=!1){let m=!1,g=!1;const y={};for(const v of this._order){const S=this._layers[v];if(S.type!=="symbol")continue;if(!y[S.source]){const M=this.sourceCaches[S.source];y[S.source]=M.getRenderableIds(!0).map(z=>M.getTileByID(z)).sort((z,R)=>R.tileID.overscaledZ-z.tileID.overscaledZ||(z.tileID.isLessThan(R.tileID)?-1:1))}const T=this.crossTileSymbolIndex.addLayer(S,y[S.source],t.center.lng);m=m||T}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((u=u||this._layerOrderChanged||a===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(me.now(),t.zoom))&&(this.pauseablePlacement=new Ct(t,this.map.terrain,this._order,u,n,a,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(me.now()),g=!0),m&&this.pauseablePlacement.placement.setStale()),g||m)for(const v of this._order){const S=this._layers[v];S.type==="symbol"&&this.placement.updateLayerOpacities(S,y[S.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(me.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,n){return p._(this,void 0,void 0,function*(){const a=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();const l=this.sourceCaches[n.source];return l&&l.setDependencies(n.tileID.key,n.type,n.icons),a})}getGlyphs(t,n){return p._(this,void 0,void 0,function*(){const a=yield this.glyphManager.getGlyphs(n.stacks),l=this.sourceCaches[n.source];return l&&l.setDependencies(n.tileID.key,n.type,[""]),a})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,n={}){this._checkLoaded(),t&&this._validate(p.x.glyphs,"glyphs",t,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}addSprite(t,n,a={},l){this._checkLoaded();const u=[{id:t,url:n}],m=[...Gi(this.stylesheet.sprite),...u];this._validate(p.x.sprite,"sprite",m,null,a)||(this.stylesheet.sprite=m,this._loadSprite(u,!0,l))}removeSprite(t){this._checkLoaded();const n=Gi(this.stylesheet.sprite);if(n.find(a=>a.id===t)){if(this._spritesImagesIds[t])for(const a of this._spritesImagesIds[t])this.imageManager.removeImage(a),this._changedImages[a]=!0;n.splice(n.findIndex(a=>a.id===t),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.k("data",{dataType:"style"}))}else this.fire(new p.j(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return Gi(this.stylesheet.sprite)}setSprite(t,n={},a){this._checkLoaded(),t&&this._validate(p.x.sprite,"sprite",t,null,n)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,a):(this._unloadSprite(),a&&a(null)))}}var Zn=p.Y([{name:"a_pos",type:"Int16",components:2}]);const Cr={prelude:et(`#ifdef GL_ES precision mediump float; #else #if !defined(lowp) #define lowp #endif #if !defined(mediump) #define mediump #endif #if !defined(highp) #define highp #endif #endif `,`#ifdef GL_ES precision highp float; #else #if !defined(lowp) #define lowp #endif #if !defined(mediump) #define mediump #endif #if !defined(highp) #define highp #endif #endif vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0 );}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;} #ifdef TERRAIN3D uniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth; #endif const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) { #ifdef TERRAIN3D highp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0)); #else return 1.0; #endif }float calculate_visibility(vec4 pos) { #ifdef TERRAIN3D vec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0; #else return 1.0; #endif }float ele(vec2 pos) { #ifdef TERRAIN3D vec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a; #else return 0.0; #endif }float get_elevation(vec2 pos) { #ifdef TERRAIN3D vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration; #else return 0.0; #endif }`),background:et(`uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:et(`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:et(`varying vec3 v_data;varying float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity void main(void) { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}`),clippingMask:et("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:et(`uniform highp float u_intensity;varying vec2 v_extrude; #pragma mapbox: define highp float weight #define GAUSS_COEF 0.3989422804014327 void main() { #pragma mapbox: initialize highp float weight float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude; #pragma mapbox: define highp float weight #pragma mapbox: define mediump float radius const highp float ZERO=1.0/255.0/16.0; #define GAUSS_COEF 0.3989422804014327 void main(void) { #pragma mapbox: initialize highp float weight #pragma mapbox: initialize mediump float radius vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,0,1);gl_Position=u_matrix*pos;}`),heatmapTexture:et(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(0.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:et("varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}","attribute vec2 a_anchor_pos;attribute vec2 a_placed;attribute vec2 a_box_real;uniform mat4 u_matrix;uniform vec2 u_pixel_extrude_scale;varying float v_placed;varying float v_notUsed;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:et("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:et("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}"),fill:et(`#pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity gl_FragColor=color*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity gl_Position=u_matrix*vec4(a_pos,0,1);}`),fillOutline:et(`varying vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}`),fillOutlinePattern:et(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}`),fillPattern:et(`#ifdef GL_ES precision highp float; #endif uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}`),fillExtrusion:et(`varying vec4 v_color;void main() {gl_FragColor=v_color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed; #ifdef TERRAIN3D attribute vec2 a_centroid; #endif varying vec4 v_color; #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp vec4 color void main() { #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize highp vec4 color vec3 normal=a_normal_ed.xyz; #ifdef TERRAIN3D float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0); #else float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0; #endif base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}`),fillExtrusionPattern:et(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting; #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed; #ifdef TERRAIN3D attribute vec2 a_centroid; #endif varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting; #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to; #ifdef TERRAIN3D float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0); #else float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0; #endif base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0 ? a_pos : vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}`),hillshadePrepare:et(`#ifdef GL_ES precision highp float; #endif uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:et(`uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent; #define PI 3.141592653589793 void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}"),line:et(`uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_width2=vec2(outset,inset);}`),lineGradient:et(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 attribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width void main() { #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_width2=vec2(outset,inset);}`),linePattern:et(`#ifdef GL_ES precision highp float; #endif uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width; #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 #define LINE_DISTANCE_SCALE 2.0 attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float gapwidth #pragma mapbox: define mediump float width #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize mediump float width #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:et(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float width #pragma mapbox: define lowp float floorwidth void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float width #pragma mapbox: initialize lowp float floorwidth float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 #define LINE_DISTANCE_SCALE 2.0 attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width #pragma mapbox: define lowp float floorwidth void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width #pragma mapbox: initialize lowp float floorwidth float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}`),raster:et(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:et(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity; #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float opacity lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec2 v_tex;varying float v_fade_opacity;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);} #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float opacity vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}`),symbolSDF:et(`#define SDF_PX 8.0 uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec2 v_data0;varying vec3 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);} #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}`),symbolTextAndIcon:et(`#define SDF_PX 8.0 #define SDF 1.0 #define ICON 0.0 uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec4 v_data0;varying vec4 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);} #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}`),terrain:et("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;varying vec2 v_texture_pos;varying float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture2D(u_texture,v_texture_pos);if (v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);gl_FragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {gl_FragColor=surface_color;}}","attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform mat4 u_fog_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:et("varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}","attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:et("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);}"),sky:et("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform float u_horizon;uniform float u_sky_horizon_blend;void main() {float y=gl_FragCoord.y;if (y > u_horizon) {float blend=y-u_horizon;if (blend < u_sky_horizon_blend) {gl_FragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {gl_FragColor=u_sky_color;}}}","attribute vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function et(h,t){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,a=t.match(/attribute ([\w]+) ([\w]+)/g),l=h.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),u=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),m=u?u.concat(l):l,g={};return{fragmentSource:h=h.replace(n,(y,v,S,T,M)=>(g[M]=!0,v==="define"?` #ifndef HAS_UNIFORM_u_${M} varying ${S} ${T} ${M}; #else uniform ${S} ${T} u_${M}; #endif `:` #ifdef HAS_UNIFORM_u_${M} ${S} ${T} ${M} = u_${M}; #endif `)),vertexSource:t=t.replace(n,(y,v,S,T,M)=>{const z=T==="float"?"vec2":"vec4",R=M.match(/color/)?"color":z;return g[M]?v==="define"?` #ifndef HAS_UNIFORM_u_${M} uniform lowp float u_${M}_t; attribute ${S} ${z} a_${M}; varying ${S} ${T} ${M}; #else uniform ${S} ${T} u_${M}; #endif `:R==="vec4"?` #ifndef HAS_UNIFORM_u_${M} ${M} = a_${M}; #else ${S} ${T} ${M} = u_${M}; #endif `:` #ifndef HAS_UNIFORM_u_${M} ${M} = unpack_mix_${R}(a_${M}, u_${M}_t); #else ${S} ${T} ${M} = u_${M}; #endif `:v==="define"?` #ifndef HAS_UNIFORM_u_${M} uniform lowp float u_${M}_t; attribute ${S} ${z} a_${M}; #else uniform ${S} ${T} u_${M}; #endif `:R==="vec4"?` #ifndef HAS_UNIFORM_u_${M} ${S} ${T} ${M} = a_${M}; #else ${S} ${T} ${M} = u_${M}; #endif `:` #ifndef HAS_UNIFORM_u_${M} ${S} ${T} ${M} = unpack_mix_${R}(a_${M}, u_${M}_t); #else ${S} ${T} ${M} = u_${M}; #endif `}),staticAttributes:a,staticUniforms:m}}class Ts{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,n,a,l,u,m,g,y,v){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);!this.vao||this.boundProgram!==n||this.boundLayoutVertexBuffer!==a||S||this.boundIndexBuffer!==u||this.boundVertexOffset!==m||this.boundDynamicVertexBuffer!==g||this.boundDynamicVertexBuffer2!==y||this.boundDynamicVertexBuffer3!==v?this.freshBind(n,a,l,u,m,g,y,v):(t.bindVertexArray.set(this.vao),g&&g.bind(),u&&u.dynamicDraw&&u.bind(),y&&y.bind(),v&&v.bind())}freshBind(t,n,a,l,u,m,g,y){const v=t.numAttributes,S=this.context,T=S.gl;this.vao&&this.destroy(),this.vao=S.createVertexArray(),S.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=n,this.boundPaintVertexBuffers=a,this.boundIndexBuffer=l,this.boundVertexOffset=u,this.boundDynamicVertexBuffer=m,this.boundDynamicVertexBuffer2=g,this.boundDynamicVertexBuffer3=y,n.enableAttributes(T,t);for(const M of a)M.enableAttributes(T,t);m&&m.enableAttributes(T,t),g&&g.enableAttributes(T,t),y&&y.enableAttributes(T,t),n.bind(),n.setVertexAttribPointers(T,t,u);for(const M of a)M.bind(),M.setVertexAttribPointers(T,t,u);m&&(m.bind(),m.setVertexAttribPointers(T,t,u)),l&&l.bind(),g&&(g.bind(),g.setVertexAttribPointers(T,t,u)),y&&(y.bind(),y.setVertexAttribPointers(T,t,u)),S.currentNumAttributes=v}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const xa=(h,t,n,a,l)=>({u_matrix:h,u_texture:0,u_ele_delta:t,u_fog_matrix:n,u_fog_color:a?a.properties.get("fog-color"):p.aN.white,u_fog_ground_blend:a?a.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:a?a.calculateFogBlendOpacity(l):0,u_horizon_color:a?a.properties.get("horizon-color"):p.aN.white,u_horizon_fog_blend:a?a.properties.get("horizon-fog-blend"):1});function Gn(h){const t=[];for(let n=0;n<h.length;n++){if(h[n]===null)continue;const a=h[n].split(" ");t.push(a.pop())}return t}class Ss{constructor(t,n,a,l,u,m){const g=t.gl;this.program=g.createProgram();const y=Gn(n.staticAttributes),v=a?a.getBinderAttributes():[],S=y.concat(v),T=Cr.prelude.staticUniforms?Gn(Cr.prelude.staticUniforms):[],M=n.staticUniforms?Gn(n.staticUniforms):[],z=a?a.getBinderUniforms():[],R=T.concat(M).concat(z),N=[];for(const ee of R)N.indexOf(ee)<0&&N.push(ee);const B=a?a.defines():[];u&&B.push("#define OVERDRAW_INSPECTOR;"),m&&B.push("#define TERRAIN3D;");const U=B.concat(Cr.prelude.fragmentSource,n.fragmentSource).join(` `),G=B.concat(Cr.prelude.vertexSource,n.vertexSource).join(` `),O=g.createShader(g.FRAGMENT_SHADER);if(g.isContextLost())return void(this.failedToCreate=!0);if(g.shaderSource(O,U),g.compileShader(O),!g.getShaderParameter(O,g.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${g.getShaderInfoLog(O)}`);g.attachShader(this.program,O);const H=g.createShader(g.VERTEX_SHADER);if(g.isContextLost())return void(this.failedToCreate=!0);if(g.shaderSource(H,G),g.compileShader(H),!g.getShaderParameter(H,g.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${g.getShaderInfoLog(H)}`);g.attachShader(this.program,H),this.attributes={};const Q={};this.numAttributes=S.length;for(let ee=0;ee<this.numAttributes;ee++)S[ee]&&(g.bindAttribLocation(this.program,ee,S[ee]),this.attributes[S[ee]]=ee);if(g.linkProgram(this.program),!g.getProgramParameter(this.program,g.LINK_STATUS))throw new Error(`Program failed to link: ${g.getProgramInfoLog(this.program)}`);g.deleteShader(H),g.deleteShader(O);for(let ee=0;ee<N.length;ee++){const oe=N[ee];if(oe&&!Q[oe]){const he=g.getUniformLocation(this.program,oe);he&&(Q[oe]=he)}}this.fixedUniforms=l(t,Q),this.terrainUniforms=((ee,oe)=>({u_depth:new p.aI(ee,oe.u_depth),u_terrain:new p.aI(ee,oe.u_terrain),u_terrain_dim:new p.aJ(ee,oe.u_terrain_dim),u_terrain_matrix:new p.aK(ee,oe.u_terrain_matrix),u_terrain_unpack:new p.aL(ee,oe.u_terrain_unpack),u_terrain_exaggeration:new p.aJ(ee,oe.u_terrain_exaggeration)}))(t,Q),this.binderUniforms=a?a.getUniforms(t,Q):[]}draw(t,n,a,l,u,m,g,y,v,S,T,M,z,R,N,B,U,G){const O=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(a),t.setStencilMode(l),t.setColorMode(u),t.setCullFace(m),y){t.activeTexture.set(O.TEXTURE2),O.bindTexture(O.TEXTURE_2D,y.depthTexture),t.activeTexture.set(O.TEXTURE3),O.bindTexture(O.TEXTURE_2D,y.texture);for(const Q in this.terrainUniforms)this.terrainUniforms[Q].set(y[Q])}for(const Q in this.fixedUniforms)this.fixedUniforms[Q].set(g[Q]);N&&N.setUniforms(t,this.binderUniforms,z,{zoom:R});let H=0;switch(n){case O.LINES:H=2;break;case O.TRIANGLES:H=3;break;case O.LINE_STRIP:H=1}for(const Q of M.get()){const ee=Q.vaos||(Q.vaos={});(ee[v]||(ee[v]=new Ts)).bind(t,this,S,N?N.getPaintVertexBuffers():[],T,Q.vertexOffset,B,U,G),O.drawElements(n,Q.primitiveLength*H,O.UNSIGNED_SHORT,Q.primitiveOffset*H*2)}}}function Is(h,t,n){const a=1/Ue(n,1,t.transform.tileZoom),l=Math.pow(2,n.tileID.overscaledZ),u=n.tileSize*Math.pow(2,t.transform.tileZoom)/l,m=u*(n.tileID.canonical.x+n.tileID.wrap*l),g=u*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[a,h.fromScale,h.toScale],u_fade:h.t,u_pixel_coord_upper:[m>>16,g>>16],u_pixel_coord_lower:[65535&m,65535&g]}}const Ps=(h,t,n,a)=>{const l=t.style.light,u=l.properties.get("position"),m=[u.x,u.y,u.z],g=function(){var v=new p.A(9);return p.A!=Float32Array&&(v[1]=0,v[2]=0,v[3]=0,v[5]=0,v[6]=0,v[7]=0),v[0]=1,v[4]=1,v[8]=1,v}();l.properties.get("anchor")==="viewport"&&function(v,S){var T=Math.sin(S),M=Math.cos(S);v[0]=M,v[1]=T,v[2]=0,v[3]=-T,v[4]=M,v[5]=0,v[6]=0,v[7]=0,v[8]=1}(g,-t.transform.angle),function(v,S,T){var M=S[0],z=S[1],R=S[2];v[0]=M*T[0]+z*T[3]+R*T[6],v[1]=M*T[1]+z*T[4]+R*T[7],v[2]=M*T[2]+z*T[5]+R*T[8]}(m,m,g);const y=l.properties.get("color");return{u_matrix:h,u_lightpos:m,u_lightintensity:l.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_vertical_gradient:+n,u_opacity:a}},As=(h,t,n,a,l,u,m)=>p.e(Ps(h,t,n,a),Is(u,t,m),{u_height_factor:-Math.pow(2,l.overscaledZ)/m.tileSize/8}),Xn=h=>({u_matrix:h}),pn=(h,t,n,a)=>p.e(Xn(h),Is(n,t,a)),jl=(h,t)=>({u_matrix:h,u_world:t}),Ul=(h,t,n,a,l)=>p.e(pn(h,t,n,a),{u_world:l}),Lo=(h,t,n,a)=>{const l=h.transform;let u,m;if(a.paint.get("circle-pitch-alignment")==="map"){const g=Ue(n,1,l.zoom);u=!0,m=[g,g]}else u=!1,m=l.pixelsToGLUnits;return{u_camera_to_center_distance:l.cameraToCenterDistance,u_scale_with_map:+(a.paint.get("circle-pitch-scale")==="map"),u_matrix:h.translatePosMatrix(t.posMatrix,n,a.paint.get("circle-translate"),a.paint.get("circle-translate-anchor")),u_pitch_with_map:+u,u_device_pixel_ratio:h.pixelRatio,u_extrude_scale:m}},$l=(h,t,n)=>({u_matrix:h,u_inv_matrix:t,u_camera_to_center_distance:n.cameraToCenterDistance,u_viewport_size:[n.width,n.height]}),Mr=(h,t,n=1)=>({u_matrix:h,u_color:t,u_overlay:0,u_overlay_scale:n}),Wn=h=>({u_matrix:h}),yi=(h,t,n,a)=>({u_matrix:h,u_extrude_scale:Ue(t,1,n),u_intensity:a});function xi(h,t){const n=Math.pow(2,t.canonical.z),a=t.canonical.y;return[new p.Z(0,a/n).toLngLat().lat,new p.Z(0,(a+1)/n).toLngLat().lat]}const Hn=(h,t,n,a)=>{const l=h.transform;return{u_matrix:Fo(h,t,n,a),u_ratio:1/Ue(t,1,l.zoom),u_device_pixel_ratio:h.pixelRatio,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]]}},Cs=(h,t,n,a,l)=>p.e(Hn(h,t,n,l),{u_image:0,u_image_height:a}),Ro=(h,t,n,a,l)=>{const u=h.transform,m=Gr(t,u);return{u_matrix:Fo(h,t,n,l),u_texsize:t.imageAtlasTexture.size,u_ratio:1/Ue(t,1,u.zoom),u_device_pixel_ratio:h.pixelRatio,u_image:0,u_scale:[m,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]]}},Bo=(h,t,n,a,l,u)=>{const m=h.lineAtlas,g=Gr(t,h.transform),y=n.layout.get("line-cap")==="round",v=m.getDash(a.from,y),S=m.getDash(a.to,y),T=v.width*l.fromScale,M=S.width*l.toScale;return p.e(Hn(h,t,n,u),{u_patternscale_a:[g/T,-v.height/2],u_patternscale_b:[g/M,-S.height/2],u_sdfgamma:m.width/(256*Math.min(T,M)*h.pixelRatio)/2,u_image:0,u_tex_y_a:v.y,u_tex_y_b:S.y,u_mix:l.t})};function Gr(h,t){return 1/Ue(h,1,t.tileZoom)}function Fo(h,t,n,a){return h.translatePosMatrix(a?a.posMatrix:t.tileID.posMatrix,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const ql=(h,t,n,a,l)=>{return{u_matrix:h,u_tl_parent:t,u_scale_parent:n,u_buffer_scale:1,u_fade_t:a.mix,u_opacity:a.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:(u=l.paint.get("raster-contrast"),u>0?1/(1-u):1+u),u_spin_weights:Zl(l.paint.get("raster-hue-rotate"))};var u,m};function Zl(h){h*=Math.PI/180;const t=Math.sin(h),n=Math.cos(h);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const Oo=(h,t,n,a,l,u,m,g,y,v,S,T,M,z)=>{const R=m.transform;return{u_is_size_zoom_constant:+(h==="constant"||h==="source"),u_is_size_feature_constant:+(h==="constant"||h==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:R.cameraToCenterDistance,u_pitch:R.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:R.width/R.height,u_fade_change:m.options.fadeDuration?m.symbolFadeChange:1,u_matrix:g,u_label_plane_matrix:y,u_coord_matrix:v,u_is_text:+T,u_pitch_with_map:+a,u_is_along_line:l,u_is_variable_anchor:u,u_texsize:M,u_texture:0,u_translation:S,u_pitched_scale:z}},Vo=(h,t,n,a,l,u,m,g,y,v,S,T,M,z,R)=>{const N=m.transform;return p.e(Oo(h,t,n,a,l,u,m,g,y,v,S,T,M,R),{u_gamma_scale:a?Math.cos(N._pitch)*N.cameraToCenterDistance:1,u_device_pixel_ratio:m.pixelRatio,u_is_halo:+z})},Gl=(h,t,n,a,l,u,m,g,y,v,S,T,M,z)=>p.e(Vo(h,t,n,a,l,u,m,g,y,v,S,!0,T,!0,z),{u_texsize_icon:M,u_texture_icon:1}),Ms=(h,t,n)=>({u_matrix:h,u_opacity:t,u_color:n}),va=(h,t,n,a,l,u)=>p.e(function(m,g,y,v){const S=y.imageManager.getPattern(m.from.toString()),T=y.imageManager.getPattern(m.to.toString()),{width:M,height:z}=y.imageManager.getPixelSize(),R=Math.pow(2,v.tileID.overscaledZ),N=v.tileSize*Math.pow(2,y.transform.tileZoom)/R,B=N*(v.tileID.canonical.x+v.tileID.wrap*R),U=N*v.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,z],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/Ue(v,1,y.transform.tileZoom),u_pixel_coord_upper:[B>>16,U>>16],u_pixel_coord_lower:[65535&B,65535&U]}}(a,u,n,l),{u_matrix:h,u_opacity:t}),ks={fillExtrusion:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_lightpos:new p.aO(h,t.u_lightpos),u_lightintensity:new p.aJ(h,t.u_lightintensity),u_lightcolor:new p.aO(h,t.u_lightcolor),u_vertical_gradient:new p.aJ(h,t.u_vertical_gradient),u_opacity:new p.aJ(h,t.u_opacity)}),fillExtrusionPattern:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_lightpos:new p.aO(h,t.u_lightpos),u_lightintensity:new p.aJ(h,t.u_lightintensity),u_lightcolor:new p.aO(h,t.u_lightcolor),u_vertical_gradient:new p.aJ(h,t.u_vertical_gradient),u_height_factor:new p.aJ(h,t.u_height_factor),u_image:new p.aI(h,t.u_image),u_texsize:new p.aP(h,t.u_texsize),u_pixel_coord_upper:new p.aP(h,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.aP(h,t.u_pixel_coord_lower),u_scale:new p.aO(h,t.u_scale),u_fade:new p.aJ(h,t.u_fade),u_opacity:new p.aJ(h,t.u_opacity)}),fill:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix)}),fillPattern:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_image:new p.aI(h,t.u_image),u_texsize:new p.aP(h,t.u_texsize),u_pixel_coord_upper:new p.aP(h,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.aP(h,t.u_pixel_coord_lower),u_scale:new p.aO(h,t.u_scale),u_fade:new p.aJ(h,t.u_fade)}),fillOutline:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_world:new p.aP(h,t.u_world)}),fillOutlinePattern:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_world:new p.aP(h,t.u_world),u_image:new p.aI(h,t.u_image),u_texsize:new p.aP(h,t.u_texsize),u_pixel_coord_upper:new p.aP(h,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.aP(h,t.u_pixel_coord_lower),u_scale:new p.aO(h,t.u_scale),u_fade:new p.aJ(h,t.u_fade)}),circle:(h,t)=>({u_camera_to_center_distance:new p.aJ(h,t.u_camera_to_center_distance),u_scale_with_map:new p.aI(h,t.u_scale_with_map),u_pitch_with_map:new p.aI(h,t.u_pitch_with_map),u_extrude_scale:new p.aP(h,t.u_extrude_scale),u_device_pixel_ratio:new p.aJ(h,t.u_device_pixel_ratio),u_matrix:new p.aK(h,t.u_matrix)}),collisionBox:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_pixel_extrude_scale:new p.aP(h,t.u_pixel_extrude_scale)}),collisionCircle:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_inv_matrix:new p.aK(h,t.u_inv_matrix),u_camera_to_center_distance:new p.aJ(h,t.u_camera_to_center_distance),u_viewport_size:new p.aP(h,t.u_viewport_size)}),debug:(h,t)=>({u_color:new p.aM(h,t.u_color),u_matrix:new p.aK(h,t.u_matrix),u_overlay:new p.aI(h,t.u_overlay),u_overlay_scale:new p.aJ(h,t.u_overlay_scale)}),clippingMask:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix)}),heatmap:(h,t)=>({u_extrude_scale:new p.aJ(h,t.u_extrude_scale),u_intensity:new p.aJ(h,t.u_intensity),u_matrix:new p.aK(h,t.u_matrix)}),heatmapTexture:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_world:new p.aP(h,t.u_world),u_image:new p.aI(h,t.u_image),u_color_ramp:new p.aI(h,t.u_color_ramp),u_opacity:new p.aJ(h,t.u_opacity)}),hillshade:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_image:new p.aI(h,t.u_image),u_latrange:new p.aP(h,t.u_latrange),u_light:new p.aP(h,t.u_light),u_shadow:new p.aM(h,t.u_shadow),u_highlight:new p.aM(h,t.u_highlight),u_accent:new p.aM(h,t.u_accent)}),hillshadePrepare:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_image:new p.aI(h,t.u_image),u_dimension:new p.aP(h,t.u_dimension),u_zoom:new p.aJ(h,t.u_zoom),u_unpack:new p.aL(h,t.u_unpack)}),line:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_ratio:new p.aJ(h,t.u_ratio),u_device_pixel_ratio:new p.aJ(h,t.u_device_pixel_ratio),u_units_to_pixels:new p.aP(h,t.u_units_to_pixels)}),lineGradient:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_ratio:new p.aJ(h,t.u_ratio),u_device_pixel_ratio:new p.aJ(h,t.u_device_pixel_ratio),u_units_to_pixels:new p.aP(h,t.u_units_to_pixels),u_image:new p.aI(h,t.u_image),u_image_height:new p.aJ(h,t.u_image_height)}),linePattern:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_texsize:new p.aP(h,t.u_texsize),u_ratio:new p.aJ(h,t.u_ratio),u_device_pixel_ratio:new p.aJ(h,t.u_device_pixel_ratio),u_image:new p.aI(h,t.u_image),u_units_to_pixels:new p.aP(h,t.u_units_to_pixels),u_scale:new p.aO(h,t.u_scale),u_fade:new p.aJ(h,t.u_fade)}),lineSDF:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_ratio:new p.aJ(h,t.u_ratio),u_device_pixel_ratio:new p.aJ(h,t.u_device_pixel_ratio),u_units_to_pixels:new p.aP(h,t.u_units_to_pixels),u_patternscale_a:new p.aP(h,t.u_patternscale_a),u_patternscale_b:new p.aP(h,t.u_patternscale_b),u_sdfgamma:new p.aJ(h,t.u_sdfgamma),u_image:new p.aI(h,t.u_image),u_tex_y_a:new p.aJ(h,t.u_tex_y_a),u_tex_y_b:new p.aJ(h,t.u_tex_y_b),u_mix:new p.aJ(h,t.u_mix)}),raster:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_tl_parent:new p.aP(h,t.u_tl_parent),u_scale_parent:new p.aJ(h,t.u_scale_parent),u_buffer_scale:new p.aJ(h,t.u_buffer_scale),u_fade_t:new p.aJ(h,t.u_fade_t),u_opacity:new p.aJ(h,t.u_opacity),u_image0:new p.aI(h,t.u_image0),u_image1:new p.aI(h,t.u_image1),u_brightness_low:new p.aJ(h,t.u_brightness_low),u_brightness_high:new p.aJ(h,t.u_brightness_high),u_saturation_factor:new p.aJ(h,t.u_saturation_factor),u_contrast_factor:new p.aJ(h,t.u_contrast_factor),u_spin_weights:new p.aO(h,t.u_spin_weights)}),symbolIcon:(h,t)=>({u_is_size_zoom_constant:new p.aI(h,t.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aI(h,t.u_is_size_feature_constant),u_size_t:new p.aJ(h,t.u_size_t),u_size:new p.aJ(h,t.u_size),u_camera_to_center_distance:new p.aJ(h,t.u_camera_to_center_distance),u_pitch:new p.aJ(h,t.u_pitch),u_rotate_symbol:new p.aI(h,t.u_rotate_symbol),u_aspect_ratio:new p.aJ(h,t.u_aspect_ratio),u_fade_change:new p.aJ(h,t.u_fade_change),u_matrix:new p.aK(h,t.u_matrix),u_label_plane_matrix:new p.aK(h,t.u_label_plane_matrix),u_coord_matrix:new p.aK(h,t.u_coord_matrix),u_is_text:new p.aI(h,t.u_is_text),u_pitch_with_map:new p.aI(h,t.u_pitch_with_map),u_is_along_line:new p.aI(h,t.u_is_along_line),u_is_variable_anchor:new p.aI(h,t.u_is_variable_anchor),u_texsize:new p.aP(h,t.u_texsize),u_texture:new p.aI(h,t.u_texture),u_translation:new p.aP(h,t.u_translation),u_pitched_scale:new p.aJ(h,t.u_pitched_scale)}),symbolSDF:(h,t)=>({u_is_size_zoom_constant:new p.aI(h,t.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aI(h,t.u_is_size_feature_constant),u_size_t:new p.aJ(h,t.u_size_t),u_size:new p.aJ(h,t.u_size),u_camera_to_center_distance:new p.aJ(h,t.u_camera_to_center_distance),u_pitch:new p.aJ(h,t.u_pitch),u_rotate_symbol:new p.aI(h,t.u_rotate_symbol),u_aspect_ratio:new p.aJ(h,t.u_aspect_ratio),u_fade_change:new p.aJ(h,t.u_fade_change),u_matrix:new p.aK(h,t.u_matrix),u_label_plane_matrix:new p.aK(h,t.u_label_plane_matrix),u_coord_matrix:new p.aK(h,t.u_coord_matrix),u_is_text:new p.aI(h,t.u_is_text),u_pitch_with_map:new p.aI(h,t.u_pitch_with_map),u_is_along_line:new p.aI(h,t.u_is_along_line),u_is_variable_anchor:new p.aI(h,t.u_is_variable_anchor),u_texsize:new p.aP(h,t.u_texsize),u_texture:new p.aI(h,t.u_texture),u_gamma_scale:new p.aJ(h,t.u_gamma_scale),u_device_pixel_ratio:new p.aJ(h,t.u_device_pixel_ratio),u_is_halo:new p.aI(h,t.u_is_halo),u_translation:new p.aP(h,t.u_translation),u_pitched_scale:new p.aJ(h,t.u_pitched_scale)}),symbolTextAndIcon:(h,t)=>({u_is_size_zoom_constant:new p.aI(h,t.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aI(h,t.u_is_size_feature_constant),u_size_t:new p.aJ(h,t.u_size_t),u_size:new p.aJ(h,t.u_size),u_camera_to_center_distance:new p.aJ(h,t.u_camera_to_center_distance),u_pitch:new p.aJ(h,t.u_pitch),u_rotate_symbol:new p.aI(h,t.u_rotate_symbol),u_aspect_ratio:new p.aJ(h,t.u_aspect_ratio),u_fade_change:new p.aJ(h,t.u_fade_change),u_matrix:new p.aK(h,t.u_matrix),u_label_plane_matrix:new p.aK(h,t.u_label_plane_matrix),u_coord_matrix:new p.aK(h,t.u_coord_matrix),u_is_text:new p.aI(h,t.u_is_text),u_pitch_with_map:new p.aI(h,t.u_pitch_with_map),u_is_along_line:new p.aI(h,t.u_is_along_line),u_is_variable_anchor:new p.aI(h,t.u_is_variable_anchor),u_texsize:new p.aP(h,t.u_texsize),u_texsize_icon:new p.aP(h,t.u_texsize_icon),u_texture:new p.aI(h,t.u_texture),u_texture_icon:new p.aI(h,t.u_texture_icon),u_gamma_scale:new p.aJ(h,t.u_gamma_scale),u_device_pixel_ratio:new p.aJ(h,t.u_device_pixel_ratio),u_is_halo:new p.aI(h,t.u_is_halo),u_translation:new p.aP(h,t.u_translation),u_pitched_scale:new p.aJ(h,t.u_pitched_scale)}),background:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_opacity:new p.aJ(h,t.u_opacity),u_color:new p.aM(h,t.u_color)}),backgroundPattern:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_opacity:new p.aJ(h,t.u_opacity),u_image:new p.aI(h,t.u_image),u_pattern_tl_a:new p.aP(h,t.u_pattern_tl_a),u_pattern_br_a:new p.aP(h,t.u_pattern_br_a),u_pattern_tl_b:new p.aP(h,t.u_pattern_tl_b),u_pattern_br_b:new p.aP(h,t.u_pattern_br_b),u_texsize:new p.aP(h,t.u_texsize),u_mix:new p.aJ(h,t.u_mix),u_pattern_size_a:new p.aP(h,t.u_pattern_size_a),u_pattern_size_b:new p.aP(h,t.u_pattern_size_b),u_scale_a:new p.aJ(h,t.u_scale_a),u_scale_b:new p.aJ(h,t.u_scale_b),u_pixel_coord_upper:new p.aP(h,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.aP(h,t.u_pixel_coord_lower),u_tile_units_to_pixels:new p.aJ(h,t.u_tile_units_to_pixels)}),terrain:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_texture:new p.aI(h,t.u_texture),u_ele_delta:new p.aJ(h,t.u_ele_delta),u_fog_matrix:new p.aK(h,t.u_fog_matrix),u_fog_color:new p.aM(h,t.u_fog_color),u_fog_ground_blend:new p.aJ(h,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new p.aJ(h,t.u_fog_ground_blend_opacity),u_horizon_color:new p.aM(h,t.u_horizon_color),u_horizon_fog_blend:new p.aJ(h,t.u_horizon_fog_blend)}),terrainDepth:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_ele_delta:new p.aJ(h,t.u_ele_delta)}),terrainCoords:(h,t)=>({u_matrix:new p.aK(h,t.u_matrix),u_texture:new p.aI(h,t.u_texture),u_terrain_coords_id:new p.aJ(h,t.u_terrain_coords_id),u_ele_delta:new p.aJ(h,t.u_ele_delta)}),sky:(h,t)=>({u_sky_color:new p.aM(h,t.u_sky_color),u_horizon_color:new p.aM(h,t.u_horizon_color),u_horizon:new p.aJ(h,t.u_horizon),u_sky_horizon_blend:new p.aJ(h,t.u_sky_horizon_blend)})};class ba{constructor(t,n,a){this.context=t;const l=t.gl;this.buffer=l.createBuffer(),this.dynamicDraw=!!a,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),l.bufferData(l.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?l.DYNAMIC_DRAW:l.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const wa={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Qi{constructor(t,n,a,l){this.length=n.length,this.attributes=a,this.itemSize=n.bytesPerElement,this.dynamicDraw=l,this.context=t;const u=t.gl;this.buffer=u.createBuffer(),t.bindVertexBuffer.set(this.buffer),u.bufferData(u.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?u.DYNAMIC_DRAW:u.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,n){for(let a=0;a<this.attributes.length;a++){const l=n.attributes[this.attributes[a].name];l!==void 0&&t.enableVertexAttribArray(l)}}setVertexAttribPointers(t,n,a){for(let l=0;l<this.attributes.length;l++){const u=this.attributes[l],m=n.attributes[u.name];m!==void 0&&t.vertexAttribPointer(m,u.components,t[wa[u.type]],!1,this.itemSize,u.offset+this.itemSize*(a||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Ta=new WeakMap;function fn(h){var t;if(Ta.has(h))return Ta.get(h);{const n=(t=h.getParameter(h.VERSION))===null||t===void 0?void 0:t.startsWith("WebGL 2.0");return Ta.set(h,n),n}}class He{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 Kn extends He{getDefault(){return p.aN.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 Xl extends He{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class zs extends He{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class Wl extends He{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 mn extends He{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class Hl extends He{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class No extends He{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 Kl extends He{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 jo extends He{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 He{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 Uo extends He{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 $o extends He{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class qo extends He{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 Zo extends He{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 Xr extends He{getDefault(){return p.aN.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 Go extends He{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class Jl extends He{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 Yl extends He{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Xo extends He{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class Jn extends He{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Ql extends He{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class Es extends He{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 ec extends He{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 tc extends He{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 Wo extends He{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 Ho extends He{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 He{getDefault(){return null}set(t){const n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Ia extends He{getDefault(){return null}set(t){var n;if(t===this.current&&!this.dirty)return;const a=this.gl;fn(a)?a.bindVertexArray(t):(n=a.getExtension("OES_vertex_array_object"))===null||n===void 0||n.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class Jo extends He{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 Ds extends He{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 dr extends He{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 Yn extends He{constructor(t,n){super(t),this.context=t,this.parent=n}getDefault(){return null}}class Pa extends Yn{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 Aa extends Yn{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 Yo extends Yn{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Ca{constructor(t,n,a,l,u){this.context=t,this.width=n,this.height=a;const m=t.gl,g=this.framebuffer=m.createFramebuffer();if(this.colorAttachment=new Pa(t,g),l)this.depthAttachment=u?new Yo(t,g):new Aa(t,g);else if(u)throw new Error("Stencil cannot be set without depth");if(m.checkFramebufferStatus(m.FRAMEBUFFER)!==m.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 a=this.depthAttachment.get();a&&t.deleteRenderbuffer(a)}t.deleteFramebuffer(this.framebuffer)}}class lt{constructor(t,n,a){this.blendFunction=t,this.blendColor=n,this.mask=a}}lt.Replace=[1,0],lt.disabled=new lt(lt.Replace,p.aN.transparent,[!1,!1,!1,!1]),lt.unblended=new lt(lt.Replace,p.aN.transparent,[!0,!0,!0,!0]),lt.alphaBlended=new lt([1,771],p.aN.transparent,[!0,!0,!0,!0]);class Ma{constructor(t){var n,a;if(this.gl=t,this.clearColor=new Kn(this),this.clearDepth=new Xl(this),this.clearStencil=new zs(this),this.colorMask=new Wl(this),this.depthMask=new mn(this),this.stencilMask=new Hl(this),this.stencilFunc=new No(this),this.stencilOp=new Kl(this),this.stencilTest=new jo(this),this.depthRange=new Sa(this),this.depthTest=new Uo(this),this.depthFunc=new $o(this),this.blend=new qo(this),this.blendFunc=new Zo(this),this.blendColor=new Xr(this),this.blendEquation=new Go(this),this.cullFace=new Jl(this),this.cullFaceSide=new Yl(this),this.frontFace=new Xo(this),this.program=new Jn(this),this.activeTexture=new Ql(this),this.viewport=new Es(this),this.bindFramebuffer=new ec(this),this.bindRenderbuffer=new tc(this),this.bindTexture=new Wo(this),this.bindVertexBuffer=new Ho(this),this.bindElementBuffer=new Ko(this),this.bindVertexArray=new Ia(this),this.pixelStoreUnpack=new Jo(this),this.pixelStoreUnpackPremultiplyAlpha=new Ds(this),this.pixelStoreUnpackFlipY=new dr(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),fn(t)){this.HALF_FLOAT=t.HALF_FLOAT;const l=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(n=t.RGBA16F)!==null&&n!==void 0?n:l==null?void 0:l.RGBA16F_EXT,this.RGB16F=(a=t.RGB16F)!==null&&a!==void 0?a:l==null?void 0:l.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");const l=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=l==null?void 0:l.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,n){return new ba(this,t,n)}createVertexBuffer(t,n,a){return new Qi(this,t,n,a)}createRenderbuffer(t,n,a){const l=this.gl,u=l.createRenderbuffer();return this.bindRenderbuffer.set(u),l.renderbufferStorage(l.RENDERBUFFER,t,n,a),this.bindRenderbuffer.set(null),u}createFramebuffer(t,n,a,l){return new Ca(this,t,n,a,l)}clear({color:t,depth:n,stencil:a}){const l=this.gl;let u=0;t&&(u|=l.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),n!==void 0&&(u|=l.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),a!==void 0&&(u|=l.STENCIL_BUFFER_BIT,this.clearStencil.set(a),this.stencilMask.set(255)),l.clear(u)}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){p.aF(t.blendFunction,lt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}createVertexArray(){var t;return fn(this.gl)?this.gl.createVertexArray():(t=this.gl.getExtension("OES_vertex_array_object"))===null||t===void 0?void 0:t.createVertexArrayOES()}deleteVertexArray(t){var n;return fn(this.gl)?this.gl.deleteVertexArray(t):(n=this.gl.getExtension("OES_vertex_array_object"))===null||n===void 0?void 0:n.deleteVertexArrayOES(t)}unbindVAO(){this.bindVertexArray.set(null)}}class Xe{constructor(t,n,a){this.func=t,this.mask=n,this.range=a}}Xe.ReadOnly=!1,Xe.ReadWrite=!0,Xe.disabled=new Xe(519,Xe.ReadOnly,[0,1]);const ka=7680;class yt{constructor(t,n,a,l,u,m){this.test=t,this.ref=n,this.mask=a,this.fail=l,this.depthFail=u,this.pass=m}}yt.disabled=new yt({func:519,mask:0},0,0,ka,ka,ka);class ut{constructor(t,n,a){this.enable=t,this.mode=n,this.frontFace=a}}let Qn;function Qo(h,t,n,a,l){const u=h.context,m=u.gl,g=h.useProgram("collisionBox"),y=[];let v=0,S=0;for(let U=0;U<a.length;U++){const G=a[U],O=t.getTile(G).getBucket(n);if(!O)continue;const H=l?O.textCollisionBox:O.iconCollisionBox,Q=O.collisionCircleArray;if(Q.length>0){const ee=p.H();p.aR(ee,O.placementInvProjMatrix,h.transform.glCoordMatrix),p.aR(ee,ee,O.placementViewportMatrix),y.push({circleArray:Q,circleOffset:S,transform:G.posMatrix,invTransform:ee,coord:G}),v+=Q.length/4,S=v}H&&g.draw(u,m.LINES,Xe.disabled,yt.disabled,h.colorModeForRenderPass(),ut.disabled,{u_matrix:G.posMatrix,u_pixel_extrude_scale:[1/(T=h.transform).width,1/T.height]},h.style.map.terrain&&h.style.map.terrain.getTerrainData(G),n.id,H.layoutVertexBuffer,H.indexBuffer,H.segments,null,h.transform.zoom,null,null,H.collisionVertexBuffer)}var T;if(!l||!y.length)return;const M=h.useProgram("collisionCircle"),z=new p.aS;z.resize(4*v),z._trim();let R=0;for(const U of y)for(let G=0;G<U.circleArray.length/4;G++){const O=4*G,H=U.circleArray[O+0],Q=U.circleArray[O+1],ee=U.circleArray[O+2],oe=U.circleArray[O+3];z.emplace(R++,H,Q,ee,oe,0),z.emplace(R++,H,Q,ee,oe,1),z.emplace(R++,H,Q,ee,oe,2),z.emplace(R++,H,Q,ee,oe,3)}(!Qn||Qn.length<2*v)&&(Qn=function(U){const G=2*U,O=new p.aU;O.resize(G),O._trim();for(let H=0;H<G;H++){const Q=6*H;O.uint16[Q+0]=4*H+0,O.uint16[Q+1]=4*H+1,O.uint16[Q+2]=4*H+2,O.uint16[Q+3]=4*H+2,O.uint16[Q+4]=4*H+3,O.uint16[Q+5]=4*H+0}return O}(v));const N=u.createIndexBuffer(Qn,!0),B=u.createVertexBuffer(z,p.aT.members,!0);for(const U of y){const G=$l(U.transform,U.invTransform,h.transform);M.draw(u,m.TRIANGLES,Xe.disabled,yt.disabled,h.colorModeForRenderPass(),ut.disabled,G,h.style.map.terrain&&h.style.map.terrain.getTerrainData(U.coord),n.id,B,N,p.a0.simpleSegment(0,2*U.circleOffset,U.circleArray.length,U.circleArray.length/2),null,h.transform.zoom,null,null,null)}B.destroy(),N.destroy()}ut.disabled=new ut(!1,1029,2305),ut.backCCW=new ut(!0,1029,2305);const za=p.ao(new Float32Array(16));function Ls(h,t,n,a,l,u){const{horizontalAlign:m,verticalAlign:g}=p.av(h);return new p.P((-(m-.5)*t/l+a[0])*u,(-(g-.5)*n/l+a[1])*u)}function Rs(h,t,n,a,l,u){const m=t.tileAnchorPoint.add(new p.P(t.translation[0],t.translation[1]));if(t.pitchWithMap){let g=a.mult(u);return n||(g=g.rotate(-l)),j(m.add(g),t.labelPlaneMatrix,t.getElevation).point}if(n){const g=ne(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(h),y=Math.atan(g.y/g.x)+(g.x<0?Math.PI:0);return h.add(a.rotate(y))}return h.add(a)}function Bs(h,t,n,a,l,u,m,g,y,v,S,T,M,z){const R=h.text.placedSymbolArray,N=h.text.dynamicLayoutVertexArray,B=h.icon.dynamicLayoutVertexArray,U={};N.clear();for(let G=0;G<R.length;G++){const O=R.get(G),H=O.hidden||!O.crossTileID||h.allowVerticalPlacement&&!O.placedOrientation?null:a[O.crossTileID];if(H){const Q=new p.P(O.anchorX,O.anchorY),ee={getElevation:z,width:l.width,height:l.height,labelPlaneMatrix:u,lineVertexArray:null,pitchWithMap:n,projection:S,projectionCache:null,tileAnchorPoint:Q,translation:T,unwrappedTileID:M},oe=n?j(Q,m,z):ne(Q.x,Q.y,ee),he=A(l.cameraToCenterDistance,oe.signedDistanceFromCamera);let Te=p.aj(h.textSizeData,y,O)*he/p.aq;n&&(Te*=h.tilePixelRatio/g);const{width:Se,height:ue,anchor:de,textOffset:Ce,textBoxScale:Ne}=H,_e=Ls(de,Se,ue,Ce,Ne,Te),ve=S.getPitchedTextCorrection(l,Q.add(new p.P(T[0],T[1])),M),Oe=Rs(oe.point,ee,t,_e,l.angle,ve),pt=h.allowVerticalPlacement&&O.placedOrientation===p.ai.vertical?Math.PI/2:0;for(let qe=0;qe<O.numGlyphs;qe++)p.ak(N,Oe,pt);v&&O.associatedIconIndex>=0&&(U[O.associatedIconIndex]={shiftedAnchor:Oe,angle:pt})}else Re(O.numGlyphs,N)}if(v){B.clear();const G=h.icon.placedSymbolArray;for(let O=0;O<G.length;O++){const H=G.get(O);if(H.hidden)Re(H.numGlyphs,B);else{const Q=U[O];if(Q)for(let ee=0;ee<H.numGlyphs;ee++)p.ak(B,Q.shiftedAnchor,Q.angle);else Re(H.numGlyphs,B)}}h.icon.dynamicLayoutVertexBuffer.updateData(B)}h.text.dynamicLayoutVertexBuffer.updateData(N)}function Ea(h,t,n){return n.iconsInText&&t?"symbolTextAndIcon":h?"symbolSDF":"symbolIcon"}function kr(h,t,n,a,l,u,m,g,y,v,S,T){const M=h.context,z=M.gl,R=h.transform,N=bs(),B=g==="map",U=y==="map",G=g!=="viewport"&&n.layout.get("symbol-placement")!=="point",O=B&&!U&&!G,H=!U&&G,Q=!n.layout.get("symbol-sort-key").isConstant();let ee=!1;const oe=h.depthModeForSublayer(0,Xe.ReadOnly),he=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),Te=[],Se=N.getCircleRadiusCorrection(R);for(const ue of a){const de=t.getTile(ue),Ce=de.getBucket(n);if(!Ce)continue;const Ne=l?Ce.text:Ce.icon;if(!Ne||!Ne.segments.get().length||!Ne.hasVisibleVertices)continue;const _e=Ne.programConfigurations.get(n.id),ve=l||Ce.sdfIcons,Oe=l?Ce.textSizeData:Ce.iconSizeData,pt=U||R.pitch!==0,qe=h.useProgram(Ea(ve,l,Ce),_e),We=p.ah(Oe,R.zoom),ft=h.style.map.terrain&&h.style.map.terrain.getTerrainData(ue);let Ut,Ri,mt,oi,ti=[0,0],$t=null;if(l)Ri=de.glyphAtlasTexture,mt=z.LINEAR,Ut=de.glyphAtlasTexture.size,Ce.iconsInText&&(ti=de.imageAtlasTexture.size,$t=de.imageAtlasTexture,oi=pt||h.options.rotating||h.options.zooming||Oe.kind==="composite"||Oe.kind==="camera"?z.LINEAR:z.NEAREST);else{const xt=n.layout.get("icon-size").constantOr(0)!==1||Ce.iconsNeedLinear;Ri=de.imageAtlasTexture,mt=ve||h.options.rotating||h.options.zooming||xt||pt?z.LINEAR:z.NEAREST,Ut=de.imageAtlasTexture.size}const qt=Ue(de,1,h.transform.zoom),Bi=H?ue.posMatrix:za,tn=Pr(Bi,U,B,h.transform,qt),Js=Yi(Bi,U,B,h.transform,qt),Sn=Yi(ue.posMatrix,U,B,h.transform,qt),rn=N.translatePosition(h.transform,de,u,m),Ys=he&&Ce.hasTextData(),co=n.layout.get("icon-text-fit")!=="none"&&Ys&&Ce.hasIconData();if(G){const xt=h.style.map.terrain?(ho,zt)=>h.style.map.terrain.getElevation(ue,ho,zt):null,Pn=n.layout.get("text-rotation-alignment")==="map";E(Ce,ue.posMatrix,h,l,tn,Sn,U,v,Pn,N,ue.toUnwrapped(),R.width,R.height,rn,xt)}const Bt=ue.posMatrix,Fi=l&&he||co,Dr=G||Fi?za:tn,In=Js,Zt=ve&&n.paint.get(l?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Gt;Gt=ve?Ce.iconsInText?Gl(Oe.kind,We,O,U,G,Fi,h,Bt,Dr,In,rn,Ut,ti,Se):Vo(Oe.kind,We,O,U,G,Fi,h,Bt,Dr,In,rn,l,Ut,!0,Se):Oo(Oe.kind,We,O,U,G,Fi,h,Bt,Dr,In,rn,l,Ut,Se);const Dt={program:qe,buffers:Ne,uniformValues:Gt,atlasTexture:Ri,atlasTextureIcon:$t,atlasInterpolation:mt,atlasInterpolationIcon:oi,isSDF:ve,hasHalo:Zt};if(Q&&Ce.canOverlap){ee=!0;const xt=Ne.segments.get();for(const Pn of xt)Te.push({segments:new p.a0([Pn]),sortKey:Pn.sortKey,state:Dt,terrainData:ft})}else Te.push({segments:Ne.segments,sortKey:0,state:Dt,terrainData:ft})}ee&&Te.sort((ue,de)=>ue.sortKey-de.sortKey);for(const ue of Te){const de=ue.state;if(M.activeTexture.set(z.TEXTURE0),de.atlasTexture.bind(de.atlasInterpolation,z.CLAMP_TO_EDGE),de.atlasTextureIcon&&(M.activeTexture.set(z.TEXTURE1),de.atlasTextureIcon&&de.atlasTextureIcon.bind(de.atlasInterpolationIcon,z.CLAMP_TO_EDGE)),de.isSDF){const Ce=de.uniformValues;de.hasHalo&&(Ce.u_is_halo=1,Wr(de.buffers,ue.segments,n,h,de.program,oe,S,T,Ce,ue.terrainData)),Ce.u_is_halo=0}Wr(de.buffers,ue.segments,n,h,de.program,oe,S,T,de.uniformValues,ue.terrainData)}}function Wr(h,t,n,a,l,u,m,g,y,v){const S=a.context;l.draw(S,S.gl.TRIANGLES,u,m,g,ut.disabled,y,v,n.id,h.layoutVertexBuffer,h.indexBuffer,t,n.paint,a.transform.zoom,h.programConfigurations.get(n.id),h.dynamicLayoutVertexBuffer,h.opacityVertexBuffer)}function vi(h,t,n,a,l){if(!n||!a||!a.imageAtlas)return;const u=a.imageAtlas.patternPositions;let m=u[n.to.toString()],g=u[n.from.toString()];if(!m&&g&&(m=g),!g&&m&&(g=m),!m||!g){const y=l.getPaintProperty(t);m=u[y],g=u[y]}m&&g&&h.setConstantPatternPositions(m,g)}function Da(h,t,n,a,l,u,m){const g=h.context.gl,y="fill-pattern",v=n.paint.get(y),S=v&&v.constantOr(1),T=n.getCrossfadeParameters();let M,z,R,N,B;m?(z=S&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",M=g.LINES):(z=S?"fillPattern":"fill",M=g.TRIANGLES);const U=v.constantOr(null);for(const G of a){const O=t.getTile(G);if(S&&!O.patternsLoaded())continue;const H=O.getBucket(n);if(!H)continue;const Q=H.programConfigurations.get(n.id),ee=h.useProgram(z,Q),oe=h.style.map.terrain&&h.style.map.terrain.getTerrainData(G);S&&(h.context.activeTexture.set(g.TEXTURE0),O.imageAtlasTexture.bind(g.LINEAR,g.CLAMP_TO_EDGE),Q.updatePaintBuffers(T)),vi(Q,y,U,O,n);const he=oe?G:null,Te=h.translatePosMatrix(he?he.posMatrix:G.posMatrix,O,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(m){N=H.indexBuffer2,B=H.segments2;const Se=[g.drawingBufferWidth,g.drawingBufferHeight];R=z==="fillOutlinePattern"&&S?Ul(Te,h,T,O,Se):jl(Te,Se)}else N=H.indexBuffer,B=H.segments,R=S?pn(Te,h,T,O):Xn(Te);ee.draw(h.context,M,l,h.stencilModeForClipping(G),u,ut.disabled,R,oe,n.id,H.layoutVertexBuffer,N,B,n.paint,h.transform.zoom,Q)}}function Fs(h,t,n,a,l,u,m){const g=h.context,y=g.gl,v="fill-extrusion-pattern",S=n.paint.get(v),T=S.constantOr(1),M=n.getCrossfadeParameters(),z=n.paint.get("fill-extrusion-opacity"),R=S.constantOr(null);for(const N of a){const B=t.getTile(N),U=B.getBucket(n);if(!U)continue;const G=h.style.map.terrain&&h.style.map.terrain.getTerrainData(N),O=U.programConfigurations.get(n.id),H=h.useProgram(T?"fillExtrusionPattern":"fillExtrusion",O);T&&(h.context.activeTexture.set(y.TEXTURE0),B.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),O.updatePaintBuffers(M)),vi(O,v,R,B,n);const Q=h.translatePosMatrix(N.posMatrix,B,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),ee=n.paint.get("fill-extrusion-vertical-gradient"),oe=T?As(Q,h,ee,z,N,M,B):Ps(Q,h,ee,z);H.draw(g,g.gl.TRIANGLES,l,u,m,ut.backCCW,oe,G,n.id,U.layoutVertexBuffer,U.indexBuffer,U.segments,n.paint,h.transform.zoom,O,h.style.map.terrain&&U.centroidVertexBuffer)}}function La(h,t,n,a,l,u,m){const g=h.context,y=g.gl,v=n.fbo;if(!v)return;const S=h.useProgram("hillshade"),T=h.style.map.terrain&&h.style.map.terrain.getTerrainData(t);g.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,v.colorAttachment.get()),S.draw(g,y.TRIANGLES,l,u,m,ut.disabled,((M,z,R,N)=>{const B=R.paint.get("hillshade-shadow-color"),U=R.paint.get("hillshade-highlight-color"),G=R.paint.get("hillshade-accent-color");let O=R.paint.get("hillshade-illumination-direction")*(Math.PI/180);R.paint.get("hillshade-illumination-anchor")==="viewport"&&(O-=M.transform.angle);const H=!M.options.moving;return{u_matrix:N?N.posMatrix:M.transform.calculatePosMatrix(z.tileID.toUnwrapped(),H),u_image:0,u_latrange:xi(0,z.tileID),u_light:[R.paint.get("hillshade-exaggeration"),O],u_shadow:B,u_highlight:U,u_accent:G}})(h,n,a,T?t:null),T,a.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments)}function Hr(h,t,n,a,l,u){const m=h.context,g=m.gl,y=t.dem;if(y&&y.data){const v=y.dim,S=y.stride,T=y.getPixels();if(m.activeTexture.set(g.TEXTURE1),m.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||h.getTileTexture(S),t.demTexture){const z=t.demTexture;z.update(T,{premultiply:!1}),z.bind(g.NEAREST,g.CLAMP_TO_EDGE)}else t.demTexture=new rt(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 z=new rt(m,{width:v,height:v,data:null},g.RGBA);z.bind(g.LINEAR,g.CLAMP_TO_EDGE),M=t.fbo=m.createFramebuffer(v,v,!0,!1),M.colorAttachment.set(z.texture)}m.bindFramebuffer.set(M.framebuffer),m.viewport.set([0,0,v,v]),h.useProgram("hillshadePrepare").draw(m,g.TRIANGLES,a,l,u,ut.disabled,((z,R)=>{const N=R.stride,B=p.H();return p.aQ(B,0,p.X,-p.X,0,0,1),p.J(B,B,[0,-p.X,0]),{u_matrix:B,u_image:1,u_dimension:[N,N],u_zoom:z.overscaledZ,u_unpack:R.getUnpackVector()}})(t.tileID,y),null,n.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments),t.needsHillshadePrepare=!1}}function Os(h,t,n,a,l,u){const m=a.paint.get("raster-fade-duration");if(!u&&m>0){const g=me.now(),y=(g-h.timeAdded)/m,v=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(h.tileID.overscaledZ-T),z=M&&h.refreshedUponExpiration?1:p.ad(M?y:1-v,0,1);return h.refreshedUponExpiration&&y>=1&&(h.refreshedUponExpiration=!1),t?{opacity:1,mix:1-z}:{opacity:z,mix:0}}return{opacity:1,mix:0}}const Vs=new p.aN(1,0,0,1),es=new p.aN(0,1,0,1),Ns=new p.aN(0,0,1,1),el=new p.aN(1,0,1,1),_n=new p.aN(0,1,1,1);function Kr(h,t,n,a){gn(h,0,t+n/2,h.transform.width,n,a)}function Ra(h,t,n,a){gn(h,t-n/2,0,n,h.transform.height,a)}function gn(h,t,n,a,l,u){const m=h.context,g=m.gl;g.enable(g.SCISSOR_TEST),g.scissor(t*h.pixelRatio,n*h.pixelRatio,a*h.pixelRatio,l*h.pixelRatio),m.clear({color:u}),g.disable(g.SCISSOR_TEST)}function Je(h,t,n){const a=h.context,l=a.gl,u=n.posMatrix,m=h.useProgram("debug"),g=Xe.disabled,y=yt.disabled,v=h.colorModeForRenderPass(),S="$debug",T=h.style.map.terrain&&h.style.map.terrain.getTerrainData(n);a.activeTexture.set(l.TEXTURE0);const M=t.getTileByID(n.key).latestRawTileData,z=Math.floor((M&&M.byteLength||0)/1024),R=t.getTile(n).tileSize,N=512/Math.min(R,512)*(n.overscaledZ/h.transform.zoom)*.5;let B=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(B+=` => ${n.overscaledZ}`),function(U,G){U.initDebugOverlayCanvas();const O=U.debugOverlayCanvas,H=U.context.gl,Q=U.debugOverlayCanvas.getContext("2d");Q.clearRect(0,0,O.width,O.height),Q.shadowColor="white",Q.shadowBlur=2,Q.lineWidth=1.5,Q.strokeStyle="white",Q.textBaseline="top",Q.font="bold 36px Open Sans, sans-serif",Q.fillText(G,5,5),Q.strokeText(G,5,5),U.debugOverlayTexture.update(O),U.debugOverlayTexture.bind(H.LINEAR,H.CLAMP_TO_EDGE)}(h,`${B} ${z}kB`),m.draw(a,l.TRIANGLES,g,y,lt.alphaBlended,ut.disabled,Mr(u,p.aN.transparent,N),null,S,h.debugBuffer,h.quadTriangleIndexBuffer,h.debugSegments),m.draw(a,l.LINE_STRIP,g,y,v,ut.disabled,Mr(u,p.aN.red),T,S,h.debugBuffer,h.tileBorderIndexBuffer,h.debugSegments)}function ts(h,t,n){const a=h.context,l=a.gl,u=h.colorModeForRenderPass(),m=new Xe(l.LEQUAL,Xe.ReadWrite,h.depthRangeFor3D),g=h.useProgram("terrain"),y=t.getTerrainMesh();a.bindFramebuffer.set(null),a.viewport.set([0,0,h.width,h.height]);for(const v of n){const S=h.renderToTexture.getTexture(v),T=t.getTerrainData(v.tileID);a.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,S.texture);const M=h.transform.calculatePosMatrix(v.tileID.toUnwrapped()),z=t.getMeshFrameDelta(h.transform.zoom),R=h.transform.calculateFogMatrix(v.tileID.toUnwrapped()),N=xa(M,z,R,h.style.sky,h.transform.pitch);g.draw(a,l.TRIANGLES,m,yt.disabled,u,ut.backCCW,N,T,"terrain",y.vertexBuffer,y.indexBuffer,y.segments)}}class tl{constructor(t,n,a){this.vertexBuffer=t,this.indexBuffer=n,this.segments=a}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class il{constructor(t,n){this.context=new Ma(t),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:p.ao(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Fe.maxUnderzooming+Fe.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Pi}resize(t,n,a){if(this.width=Math.floor(t*a),this.height=Math.floor(n*a),this.pixelRatio=a,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const l of this.style._order)this.style._layers[l].resize()}setup(){const t=this.context,n=new p.aX;n.emplaceBack(0,0),n.emplaceBack(p.X,0),n.emplaceBack(0,p.X),n.emplaceBack(p.X,p.X),this.tileExtentBuffer=t.createVertexBuffer(n,Zn.members),this.tileExtentSegments=p.a0.simpleSegment(0,0,4,2);const a=new p.aX;a.emplaceBack(0,0),a.emplaceBack(p.X,0),a.emplaceBack(0,p.X),a.emplaceBack(p.X,p.X),this.debugBuffer=t.createVertexBuffer(a,Zn.members),this.debugSegments=p.a0.simpleSegment(0,0,4,5);const l=new p.$;l.emplaceBack(0,0,0,0),l.emplaceBack(p.X,0,p.X,0),l.emplaceBack(0,p.X,0,p.X),l.emplaceBack(p.X,p.X,p.X,p.X),this.rasterBoundsBuffer=t.createVertexBuffer(l,Sr.members),this.rasterBoundsSegments=p.a0.simpleSegment(0,0,4,2);const u=new p.aX;u.emplaceBack(0,0),u.emplaceBack(1,0),u.emplaceBack(0,1),u.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(u,Zn.members),this.viewportSegments=p.a0.simpleSegment(0,0,4,2);const m=new p.aZ;m.emplaceBack(0),m.emplaceBack(1),m.emplaceBack(3),m.emplaceBack(2),m.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(m);const g=new p.aY;g.emplaceBack(0,1,2),g.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(g);const y=this.context.gl;this.stencilClearMode=new yt({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 a=p.H();p.aQ(a,0,this.width,this.height,0,0,1),p.K(a,a,[n.drawingBufferWidth,n.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,n.TRIANGLES,Xe.disabled,this.stencilClearMode,lt.disabled,ut.disabled,Wn(a),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 a=this.context,l=a.gl;this.nextStencilID+n.length>256&&this.clearStencil(),a.setColorMode(lt.disabled),a.setDepthMode(Xe.disabled);const u=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);u.draw(a,l.TRIANGLES,Xe.disabled,new yt({func:l.ALWAYS,mask:0},g,255,l.KEEP,l.KEEP,l.REPLACE),lt.disabled,ut.disabled,Wn(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 yt({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){const n=this.context.gl;return new yt({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(t){const n=this.context.gl,a=t.sort((m,g)=>g.overscaledZ-m.overscaledZ),l=a[a.length-1].overscaledZ,u=a[0].overscaledZ-l+1;if(u>1){this.currentStencilSource=void 0,this.nextStencilID+u>256&&this.clearStencil();const m={};for(let g=0;g<u;g++)m[g+l]=new yt({func:n.GEQUAL,mask:255},g+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=u,[m,a]}return[{[l]:yt.disabled},a]}colorModeForRenderPass(){const t=this.context.gl;return this._showOverdrawInspector?new lt([t.CONSTANT_COLOR,t.ONE],new p.aN(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?lt.unblended:lt.alphaBlended}depthModeForSublayer(t,n,a){if(!this.opaquePassEnabledForLayer())return Xe.disabled;const l=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new Xe(a||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(me.now()),this.imageManager.beginFrame();const a=this.style._order,l=this.style.sourceCaches,u={},m={},g={};for(const y in l){const v=l[y];v.used&&v.prepare(this.context),u[y]=v.getVisibleCoordinates(),m[y]=u[y].slice().reverse(),g[y]=v.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let y=0;y<a.length;y++)if(this.style._layers[a[y]].is3D()){this.opaquePassCutoff=y;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const y of a){const v=this.style._layers[y];if(!v.hasOffscreenPass()||v.isHidden(this.transform.zoom))continue;const S=m[v.source];(v.type==="custom"||S.length)&&this.renderLayer(this,l[v.source],v,S)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?p.aN.black:p.aN.transparent,depth:1}),this.clearStencil(),this.style.stylesheet.sky&&function(y,v){const S=y.context,T=S.gl,M=((U,G,O)=>({u_sky_color:U.properties.get("sky-color"),u_horizon_color:U.properties.get("horizon-color"),u_horizon:(G.height/2+G.getHorizon())*O,u_sky_horizon_blend:U.properties.get("sky-horizon-blend")*G.height/2*O}))(v,y.style.map.transform,y.pixelRatio),z=new Xe(T.LEQUAL,Xe.ReadWrite,[0,1]),R=yt.disabled,N=y.colorModeForRenderPass(),B=y.useProgram("sky");if(!v.mesh){const U=new p.aX;U.emplaceBack(-1,-1),U.emplaceBack(1,-1),U.emplaceBack(1,1),U.emplaceBack(-1,1);const G=new p.aY;G.emplaceBack(0,1,2),G.emplaceBack(0,2,3),v.mesh=new tl(S.createVertexBuffer(U,Zn.members),S.createIndexBuffer(G),p.a0.simpleSegment(0,0,U.length,G.length))}B.draw(S,T.TRIANGLES,z,R,N,ut.disabled,M,void 0,"sky",v.mesh.vertexBuffer,v.mesh.indexBuffer,v.mesh.segments)}(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=a.length-1;this.currentLayer>=0;this.currentLayer--){const y=this.style._layers[a[this.currentLayer]],v=l[y.source],S=u[y.source];this._renderTileClippingMasks(y,S),this.renderLayer(this,v,y,S)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<a.length;this.currentLayer++){const y=this.style._layers[a[this.currentLayer]],v=l[y.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(y))continue;const S=(y.type==="symbol"?g:m)[y.source];this._renderTileClippingMasks(y,u[y.source]),this.renderLayer(this,v,y,S)}if(this.options.showTileBoundaries){const y=function(v,S){let T=null;const M=Object.values(v._layers).flatMap(B=>B.source&&!B.isHidden(S)?[v.sourceCaches[B.source]]:[]),z=M.filter(B=>B.getSource().type==="vector"),R=M.filter(B=>B.getSource().type!=="vector"),N=B=>{(!T||T.getSource().maxzoom<B.getSource().maxzoom)&&(T=B)};return z.forEach(B=>N(B)),T||R.forEach(B=>N(B)),T}(this.style,this.transform.zoom);y&&function(v,S,T){for(let M=0;M<T.length;M++)Je(v,S,T[M])}(this,y,y.getVisibleCoordinates())}this.options.showPadding&&function(y){const v=y.transform.padding;Kr(y,y.transform.height-(v.top||0),3,Vs),Kr(y,v.bottom||0,3,es),Ra(y,v.left||0,3,Ns),Ra(y,y.transform.width-(v.right||0),3,el);const S=y.transform.centerPoint;(function(T,M,z,R){gn(T,M-1,z-10,2,20,R),gn(T,M-10,z-1,20,2,R)})(y,S.x,y.transform.height-S.y,_n)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(t){if(!this.style||!this.style.map||!this.style.map.terrain)return;const n=this.terrainFacilitator.matrix,a=this.transform.modelViewProjectionMatrix;let l=this.terrainFacilitator.dirty;l||(l=t?!p.a_(n,a):!p.a$(n,a)),l||(l=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),l&&(p.b0(n,a),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(u,m){const g=u.context,y=g.gl,v=lt.unblended,S=new Xe(y.LEQUAL,Xe.ReadWrite,[0,1]),T=m.getTerrainMesh(),M=m.sourceCache.getRenderableTiles(),z=u.useProgram("terrainDepth");g.bindFramebuffer.set(m.getFramebuffer("depth").framebuffer),g.viewport.set([0,0,u.width/devicePixelRatio,u.height/devicePixelRatio]),g.clear({color:p.aN.transparent,depth:1});for(const R of M){const N=m.getTerrainData(R.tileID),B={u_matrix:u.transform.calculatePosMatrix(R.tileID.toUnwrapped()),u_ele_delta:m.getMeshFrameDelta(u.transform.zoom)};z.draw(g,y.TRIANGLES,S,yt.disabled,v,ut.backCCW,B,N,"terrain",T.vertexBuffer,T.indexBuffer,T.segments)}g.bindFramebuffer.set(null),g.viewport.set([0,0,u.width,u.height])}(this,this.style.map.terrain),function(u,m){const g=u.context,y=g.gl,v=lt.unblended,S=new Xe(y.LEQUAL,Xe.ReadWrite,[0,1]),T=m.getTerrainMesh(),M=m.getCoordsTexture(),z=m.sourceCache.getRenderableTiles(),R=u.useProgram("terrainCoords");g.bindFramebuffer.set(m.getFramebuffer("coords").framebuffer),g.viewport.set([0,0,u.width/devicePixelRatio,u.height/devicePixelRatio]),g.clear({color:p.aN.transparent,depth:1}),m.coordsIndex=[];for(const N of z){const B=m.getTerrainData(N.tileID);g.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,M.texture);const U={u_matrix:u.transform.calculatePosMatrix(N.tileID.toUnwrapped()),u_terrain_coords_id:(255-m.coordsIndex.length)/255,u_texture:0,u_ele_delta:m.getMeshFrameDelta(u.transform.zoom)};R.draw(g,y.TRIANGLES,S,yt.disabled,v,ut.backCCW,U,B,"terrain",T.vertexBuffer,T.indexBuffer,T.segments),m.coordsIndex.push(N.tileID.key)}g.bindFramebuffer.set(null),g.viewport.set([0,0,u.width,u.height])}(this,this.style.map.terrain))}renderLayer(t,n,a,l){if(!a.isHidden(this.transform.zoom)&&(a.type==="background"||a.type==="custom"||(l||[]).length))switch(this.id=a.id,a.type){case"symbol":(function(u,m,g,y,v){if(u.renderPass!=="translucent")return;const S=yt.disabled,T=u.colorModeForRenderPass();(g._unevaluatedLayout.hasValue("text-variable-anchor")||g._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(M,z,R,N,B,U,G,O,H){const Q=z.transform,ee=bs(),oe=B==="map",he=U==="map";for(const Te of M){const Se=N.getTile(Te),ue=Se.getBucket(R);if(!ue||!ue.text||!ue.text.segments.get().length)continue;const de=p.ah(ue.textSizeData,Q.zoom),Ce=Ue(Se,1,z.transform.zoom),Ne=Pr(Te.posMatrix,he,oe,z.transform,Ce),_e=R.layout.get("icon-text-fit")!=="none"&&ue.hasIconData();if(de){const ve=Math.pow(2,Q.zoom-Se.tileID.overscaledZ),Oe=z.style.map.terrain?(qe,We)=>z.style.map.terrain.getElevation(Te,qe,We):null,pt=ee.translatePosition(Q,Se,G,O);Bs(ue,oe,he,H,Q,Ne,Te.posMatrix,ve,de,_e,ee,pt,Te.toUnwrapped(),Oe)}}}(y,u,g,m,g.layout.get("text-rotation-alignment"),g.layout.get("text-pitch-alignment"),g.paint.get("text-translate"),g.paint.get("text-translate-anchor"),v),g.paint.get("icon-opacity").constantOr(1)!==0&&kr(u,m,g,y,!1,g.paint.get("icon-translate"),g.paint.get("icon-translate-anchor"),g.layout.get("icon-rotation-alignment"),g.layout.get("icon-pitch-alignment"),g.layout.get("icon-keep-upright"),S,T),g.paint.get("text-opacity").constantOr(1)!==0&&kr(u,m,g,y,!0,g.paint.get("text-translate"),g.paint.get("text-translate-anchor"),g.layout.get("text-rotation-alignment"),g.layout.get("text-pitch-alignment"),g.layout.get("text-keep-upright"),S,T),m.map.showCollisionBoxes&&(Qo(u,m,g,y,!0),Qo(u,m,g,y,!1))})(t,n,a,l,this.style.placement.variableOffsets);break;case"circle":(function(u,m,g,y){if(u.renderPass!=="translucent")return;const v=g.paint.get("circle-opacity"),S=g.paint.get("circle-stroke-width"),T=g.paint.get("circle-stroke-opacity"),M=!g.layout.get("circle-sort-key").isConstant();if(v.constantOr(1)===0&&(S.constantOr(1)===0||T.constantOr(1)===0))return;const z=u.context,R=z.gl,N=u.depthModeForSublayer(0,Xe.ReadOnly),B=yt.disabled,U=u.colorModeForRenderPass(),G=[];for(let O=0;O<y.length;O++){const H=y[O],Q=m.getTile(H),ee=Q.getBucket(g);if(!ee)continue;const oe=ee.programConfigurations.get(g.id),he=u.useProgram("circle",oe),Te=ee.layoutVertexBuffer,Se=ee.indexBuffer,ue=u.style.map.terrain&&u.style.map.terrain.getTerrainData(H),de={programConfiguration:oe,program:he,layoutVertexBuffer:Te,indexBuffer:Se,uniformValues:Lo(u,H,Q,g),terrainData:ue};if(M){const Ce=ee.segments.get();for(const Ne of Ce)G.push({segments:new p.a0([Ne]),sortKey:Ne.sortKey,state:de})}else G.push({segments:ee.segments,sortKey:0,state:de})}M&&G.sort((O,H)=>O.sortKey-H.sortKey);for(const O of G){const{programConfiguration:H,program:Q,layoutVertexBuffer:ee,indexBuffer:oe,uniformValues:he,terrainData:Te}=O.state;Q.draw(z,R.TRIANGLES,N,B,U,ut.disabled,he,Te,g.id,ee,oe,O.segments,g.paint,u.transform.zoom,H)}})(t,n,a,l);break;case"heatmap":(function(u,m,g,y){if(g.paint.get("heatmap-opacity")!==0)if(u.renderPass==="offscreen"){const v=u.context,S=v.gl,T=yt.disabled,M=new lt([S.ONE,S.ONE],p.aN.transparent,[!0,!0,!0,!0]);(function(z,R,N){const B=z.gl;z.activeTexture.set(B.TEXTURE1),z.viewport.set([0,0,R.width/4,R.height/4]);let U=N.heatmapFbo;if(U)B.bindTexture(B.TEXTURE_2D,U.colorAttachment.get()),z.bindFramebuffer.set(U.framebuffer);else{const G=B.createTexture();B.bindTexture(B.TEXTURE_2D,G),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_WRAP_S,B.CLAMP_TO_EDGE),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_WRAP_T,B.CLAMP_TO_EDGE),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_MIN_FILTER,B.LINEAR),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_MAG_FILTER,B.LINEAR),U=N.heatmapFbo=z.createFramebuffer(R.width/4,R.height/4,!1,!1),function(O,H,Q,ee){var oe,he;const Te=O.gl,Se=(oe=O.HALF_FLOAT)!==null&&oe!==void 0?oe:Te.UNSIGNED_BYTE,ue=(he=O.RGBA16F)!==null&&he!==void 0?he:Te.RGBA;Te.texImage2D(Te.TEXTURE_2D,0,ue,H.width/4,H.height/4,0,Te.RGBA,Se,null),ee.colorAttachment.set(Q)}(z,R,G,U)}})(v,u,g),v.clear({color:p.aN.transparent});for(let z=0;z<y.length;z++){const R=y[z];if(m.hasRenderableParent(R))continue;const N=m.getTile(R),B=N.getBucket(g);if(!B)continue;const U=B.programConfigurations.get(g.id),G=u.useProgram("heatmap",U),{zoom:O}=u.transform;G.draw(v,S.TRIANGLES,Xe.disabled,T,M,ut.disabled,yi(R.posMatrix,N,O,g.paint.get("heatmap-intensity")),null,g.id,B.layoutVertexBuffer,B.indexBuffer,B.segments,g.paint,u.transform.zoom,U)}v.viewport.set([0,0,u.width,u.height])}else u.renderPass==="translucent"&&(u.context.setColorMode(u.colorModeForRenderPass()),function(v,S){const T=v.context,M=T.gl,z=S.heatmapFbo;if(!z)return;T.activeTexture.set(M.TEXTURE0),M.bindTexture(M.TEXTURE_2D,z.colorAttachment.get()),T.activeTexture.set(M.TEXTURE1);let R=S.colorRampTexture;R||(R=S.colorRampTexture=new rt(T,S.colorRamp,M.RGBA)),R.bind(M.LINEAR,M.CLAMP_TO_EDGE),v.useProgram("heatmapTexture").draw(T,M.TRIANGLES,Xe.disabled,yt.disabled,v.colorModeForRenderPass(),ut.disabled,((N,B,U,G)=>{const O=p.H();p.aQ(O,0,N.width,N.height,0,0,1);const H=N.context.gl;return{u_matrix:O,u_world:[H.drawingBufferWidth,H.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:B.paint.get("heatmap-opacity")}})(v,S),null,S.id,v.viewportBuffer,v.quadTriangleIndexBuffer,v.viewportSegments,S.paint,v.transform.zoom)}(u,g))})(t,n,a,l);break;case"line":(function(u,m,g,y){if(u.renderPass!=="translucent")return;const v=g.paint.get("line-opacity"),S=g.paint.get("line-width");if(v.constantOr(1)===0||S.constantOr(1)===0)return;const T=u.depthModeForSublayer(0,Xe.ReadOnly),M=u.colorModeForRenderPass(),z=g.paint.get("line-dasharray"),R=g.paint.get("line-pattern"),N=R.constantOr(1),B=g.paint.get("line-gradient"),U=g.getCrossfadeParameters(),G=N?"linePattern":z?"lineSDF":B?"lineGradient":"line",O=u.context,H=O.gl;let Q=!0;for(const ee of y){const oe=m.getTile(ee);if(N&&!oe.patternsLoaded())continue;const he=oe.getBucket(g);if(!he)continue;const Te=he.programConfigurations.get(g.id),Se=u.context.program.get(),ue=u.useProgram(G,Te),de=Q||ue.program!==Se,Ce=u.style.map.terrain&&u.style.map.terrain.getTerrainData(ee),Ne=R.constantOr(null);if(Ne&&oe.imageAtlas){const Oe=oe.imageAtlas,pt=Oe.patternPositions[Ne.to.toString()],qe=Oe.patternPositions[Ne.from.toString()];pt&&qe&&Te.setConstantPatternPositions(pt,qe)}const _e=Ce?ee:null,ve=N?Ro(u,oe,g,U,_e):z?Bo(u,oe,g,z,U,_e):B?Cs(u,oe,g,he.lineClipsArray.length,_e):Hn(u,oe,g,_e);if(N)O.activeTexture.set(H.TEXTURE0),oe.imageAtlasTexture.bind(H.LINEAR,H.CLAMP_TO_EDGE),Te.updatePaintBuffers(U);else if(z&&(de||u.lineAtlas.dirty))O.activeTexture.set(H.TEXTURE0),u.lineAtlas.bind(O);else if(B){const Oe=he.gradients[g.id];let pt=Oe.texture;if(g.gradientVersion!==Oe.version){let qe=256;if(g.stepInterpolant){const We=m.getSource().maxzoom,ft=ee.canonical.z===We?Math.ceil(1<<u.transform.maxZoom-ee.canonical.z):1;qe=p.ad(p.aV(he.maxLineLength/p.X*1024*ft),256,O.maxTextureSize)}Oe.gradient=p.aW({expression:g.gradientExpression(),evaluationKey:"lineProgress",resolution:qe,image:Oe.gradient||void 0,clips:he.lineClipsArray}),Oe.texture?Oe.texture.update(Oe.gradient):Oe.texture=new rt(O,Oe.gradient,H.RGBA),Oe.version=g.gradientVersion,pt=Oe.texture}O.activeTexture.set(H.TEXTURE0),pt.bind(g.stepInterpolant?H.NEAREST:H.LINEAR,H.CLAMP_TO_EDGE)}ue.draw(O,H.TRIANGLES,T,u.stencilModeForClipping(ee),M,ut.disabled,ve,Ce,g.id,he.layoutVertexBuffer,he.indexBuffer,he.segments,g.paint,u.transform.zoom,Te,he.layoutVertexBuffer2),Q=!1}})(t,n,a,l);break;case"fill":(function(u,m,g,y){const v=g.paint.get("fill-color"),S=g.paint.get("fill-opacity");if(S.constantOr(1)===0)return;const T=u.colorModeForRenderPass(),M=g.paint.get("fill-pattern"),z=u.opaquePassEnabledForLayer()&&!M.constantOr(1)&&v.constantOr(p.aN.transparent).a===1&&S.constantOr(0)===1?"opaque":"translucent";if(u.renderPass===z){const R=u.depthModeForSublayer(1,u.renderPass==="opaque"?Xe.ReadWrite:Xe.ReadOnly);Da(u,m,g,y,R,T,!1)}if(u.renderPass==="translucent"&&g.paint.get("fill-antialias")){const R=u.depthModeForSublayer(g.getPaintProperty("fill-outline-color")?2:0,Xe.ReadOnly);Da(u,m,g,y,R,T,!0)}})(t,n,a,l);break;case"fill-extrusion":(function(u,m,g,y){const v=g.paint.get("fill-extrusion-opacity");if(v!==0&&u.renderPass==="translucent"){const S=new Xe(u.context.gl.LEQUAL,Xe.ReadWrite,u.depthRangeFor3D);if(v!==1||g.paint.get("fill-extrusion-pattern").constantOr(1))Fs(u,m,g,y,S,yt.disabled,lt.disabled),Fs(u,m,g,y,S,u.stencilModeFor3D(),u.colorModeForRenderPass());else{const T=u.colorModeForRenderPass();Fs(u,m,g,y,S,yt.disabled,T)}}})(t,n,a,l);break;case"hillshade":(function(u,m,g,y){if(u.renderPass!=="offscreen"&&u.renderPass!=="translucent")return;const v=u.context,S=u.depthModeForSublayer(0,Xe.ReadOnly),T=u.colorModeForRenderPass(),[M,z]=u.renderPass==="translucent"?u.stencilConfigForOverlap(y):[{},y];for(const R of z){const N=m.getTile(R);N.needsHillshadePrepare!==void 0&&N.needsHillshadePrepare&&u.renderPass==="offscreen"?Hr(u,N,g,S,yt.disabled,T):u.renderPass==="translucent"&&La(u,R,N,g,S,M[R.overscaledZ],T)}v.viewport.set([0,0,u.width,u.height])})(t,n,a,l);break;case"raster":(function(u,m,g,y){if(u.renderPass!=="translucent"||g.paint.get("raster-opacity")===0||!y.length)return;const v=u.context,S=v.gl,T=m.getSource(),M=u.useProgram("raster"),z=u.colorModeForRenderPass(),[R,N]=T instanceof cr?[{},y]:u.stencilConfigForOverlap(y),B=N[N.length-1].overscaledZ,U=!u.options.moving;for(const G of N){const O=u.depthModeForSublayer(G.overscaledZ-B,g.paint.get("raster-opacity")===1?Xe.ReadWrite:Xe.ReadOnly,S.LESS),H=m.getTile(G);H.registerFadeDuration(g.paint.get("raster-fade-duration"));const Q=m.findLoadedParent(G,0),ee=m.findLoadedSibling(G),oe=Os(H,Q||ee||null,m,g,u.transform,u.style.map.terrain);let he,Te;const Se=g.paint.get("raster-resampling")==="nearest"?S.NEAREST:S.LINEAR;v.activeTexture.set(S.TEXTURE0),H.texture.bind(Se,S.CLAMP_TO_EDGE,S.LINEAR_MIPMAP_NEAREST),v.activeTexture.set(S.TEXTURE1),Q?(Q.texture.bind(Se,S.CLAMP_TO_EDGE,S.LINEAR_MIPMAP_NEAREST),he=Math.pow(2,Q.tileID.overscaledZ-H.tileID.overscaledZ),Te=[H.tileID.canonical.x*he%1,H.tileID.canonical.y*he%1]):H.texture.bind(Se,S.CLAMP_TO_EDGE,S.LINEAR_MIPMAP_NEAREST);const ue=u.style.map.terrain&&u.style.map.terrain.getTerrainData(G),de=ue?G:null,Ce=de?de.posMatrix:u.transform.calculatePosMatrix(G.toUnwrapped(),U),Ne=ql(Ce,Te||[0,0],he||1,oe,g);T instanceof cr?M.draw(v,S.TRIANGLES,O,yt.disabled,z,ut.disabled,Ne,ue,g.id,T.boundsBuffer,u.quadTriangleIndexBuffer,T.boundsSegments):M.draw(v,S.TRIANGLES,O,R[G.overscaledZ],z,ut.disabled,Ne,ue,g.id,u.rasterBoundsBuffer,u.quadTriangleIndexBuffer,u.rasterBoundsSegments)}})(t,n,a,l);break;case"background":(function(u,m,g,y){const v=g.paint.get("background-color"),S=g.paint.get("background-opacity");if(S===0)return;const T=u.context,M=T.gl,z=u.transform,R=z.tileSize,N=g.paint.get("background-pattern");if(u.isPatternMissing(N))return;const B=!N&&v.a===1&&S===1&&u.opaquePassEnabledForLayer()?"opaque":"translucent";if(u.renderPass!==B)return;const U=yt.disabled,G=u.depthModeForSublayer(0,B==="opaque"?Xe.ReadWrite:Xe.ReadOnly),O=u.colorModeForRenderPass(),H=u.useProgram(N?"backgroundPattern":"background"),Q=y||z.coveringTiles({tileSize:R,terrain:u.style.map.terrain});N&&(T.activeTexture.set(M.TEXTURE0),u.imageManager.bind(u.context));const ee=g.getCrossfadeParameters();for(const oe of Q){const he=y?oe.posMatrix:u.transform.calculatePosMatrix(oe.toUnwrapped()),Te=N?va(he,S,u,N,{tileID:oe,tileSize:R},ee):Ms(he,S,v),Se=u.style.map.terrain&&u.style.map.terrain.getTerrainData(oe);H.draw(T,M.TRIANGLES,G,U,O,ut.disabled,Te,Se,g.id,u.tileExtentBuffer,u.quadTriangleIndexBuffer,u.tileExtentSegments)}})(t,0,a,l);break;case"custom":(function(u,m,g){const y=u.context,v=g.implementation;if(u.renderPass==="offscreen"){const S=v.prerender;S&&(u.setCustomLayerDefaults(),y.setColorMode(u.colorModeForRenderPass()),S.call(v,y.gl,u.transform.customLayerMatrix()),y.setDirty(),u.setBaseState())}else if(u.renderPass==="translucent"){u.setCustomLayerDefaults(),y.setColorMode(u.colorModeForRenderPass()),y.setStencilMode(yt.disabled);const S=v.renderingMode==="3d"?new Xe(u.context.gl.LEQUAL,Xe.ReadWrite,u.depthRangeFor3D):u.depthModeForSublayer(0,Xe.ReadOnly);y.setDepthMode(S),v.render(y.gl,u.transform.customLayerMatrix()),y.setDirty(),u.setBaseState(),y.bindFramebuffer.set(null)}})(t,0,a)}}translatePosMatrix(t,n,a,l,u){if(!a[0]&&!a[1])return t;const m=u?l==="map"?this.transform.angle:0:l==="viewport"?-this.transform.angle:0;if(m){const v=Math.sin(m),S=Math.cos(m);a=[a[0]*S-a[1]*v,a[0]*v+a[1]*S]}const g=[u?a[0]:Ue(n,a[0],this.transform.zoom),u?a[1]:Ue(n,a[1],this.transform.zoom),0],y=new Float32Array(16);return p.J(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()),a=this.imageManager.getPattern(t.to.toString());return!n||!a}useProgram(t,n){this.cache=this.cache||{};const a=t+(n?n.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[a]||(this.cache[a]=new Ss(this.context,Cr[t],n,ks[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[a]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){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 rt(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:n}=this.context.gl;return this.width!==t||this.height!==n}}class Jr{constructor(t,n){this.points=t,this.planes=n}static fromInvProjectionMatrix(t,n,a){const l=Math.pow(2,a),u=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(g=>{const y=1/(g=p.ag([],g,t))[3]/n*l;return p.b1(g,g,[y,y,1/g[3],y])}),m=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(g=>{const y=function(M,z){var R=z[0],N=z[1],B=z[2],U=R*R+N*N+B*B;return U>0&&(U=1/Math.sqrt(U)),M[0]=z[0]*U,M[1]=z[1]*U,M[2]=z[2]*U,M}([],function(M,z,R){var N=z[0],B=z[1],U=z[2],G=R[0],O=R[1],H=R[2];return M[0]=B*H-U*O,M[1]=U*G-N*H,M[2]=N*O-B*G,M}([],Si([],u[g[0]],u[g[1]]),Si([],u[g[2]],u[g[1]]))),v=-((S=y)[0]*(T=u[g[1]])[0]+S[1]*T[1]+S[2]*T[2]);var S,T;return y.concat(v)});return new Jr(u,m)}}class js{constructor(t,n){this.min=t,this.max=n,this.center=function(a,l,u){return a[0]=.5*l[0],a[1]=.5*l[1],a[2]=.5*l[2],a}([],function(a,l,u){return a[0]=l[0]+u[0],a[1]=l[1]+u[1],a[2]=l[2]+u[2],a}([],this.min,this.max))}quadrant(t){const n=[t%2==0,t<2],a=Mi(this.min),l=Mi(this.max);for(let u=0;u<n.length;u++)a[u]=n[u]?this.min[u]:this.center[u],l[u]=n[u]?this.center[u]:this.max[u];return l[2]=this.max[2],new js(a,l)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}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 a=!0;for(let l=0;l<t.planes.length;l++){const u=t.planes[l];let m=0;for(let g=0;g<n.length;g++)p.b2(u,n[g])>=0&&m++;if(m===0)return 0;m!==n.length&&(a=!1)}if(a)return 2;for(let l=0;l<3;l++){let u=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];u=Math.min(u,y),m=Math.max(m,y)}if(m<0||u>this.max[l]-this.min[l])return 0}return 1}}class Us{constructor(t=0,n=0,a=0,l=0){if(isNaN(t)||t<0||isNaN(n)||n<0||isNaN(a)||a<0||isNaN(l)||l<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=n,this.left=a,this.right=l}interpolate(t,n,a){return n.top!=null&&t.top!=null&&(this.top=p.z.number(t.top,n.top,a)),n.bottom!=null&&t.bottom!=null&&(this.bottom=p.z.number(t.bottom,n.bottom,a)),n.left!=null&&t.left!=null&&(this.left=p.z.number(t.left,n.left,a)),n.right!=null&&t.right!=null&&(this.right=p.z.number(t.right,n.right,a)),this}getCenter(t,n){const a=p.ad((this.left+t-this.right)/2,0,t),l=p.ad((this.top+n-this.bottom)/2,0,n);return new p.P(a,l)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Us(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const Ba=85.051129;class Fa{constructor(t,n,a,l,u){this.tileSize=512,this._renderWorldCopies=u===void 0||!!u,this._minZoom=t||0,this._maxZoom=n||22,this._minPitch=a??0,this._maxPitch=l??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new p.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Us,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const t=new Fa(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.apply(this),t}apply(t){this.tileSize=t.tileSize,this.latRange=t.latRange,this.width=t.width,this.height=t.height,this._center=t._center,this._elevation=t._elevation,this.minElevationForCurrentTile=t.minElevationForCurrentTile,this.zoom=t.zoom,this.angle=t.angle,this._fov=t._fov,this._pitch=t._pitch,this._unmodified=t._unmodified,this._edgeInsets=t._edgeInsets.clone(),this._calcMatrices()}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 p.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){const n=-p.b3(t,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=function(){var a=new p.A(4);return p.A!=Float32Array&&(a[1]=0,a[2]=0),a[0]=1,a[3]=1,a}(),function(a,l,u){var m=l[0],g=l[1],y=l[2],v=l[3],S=Math.sin(u),T=Math.cos(u);a[0]=m*T+y*S,a[1]=g*T+v*S,a[2]=m*-S+y*T,a[3]=g*-S+v*T}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const n=p.ad(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,a){this._unmodified=!1,this._edgeInsets.interpolate(t,n,a),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 p.b4(0,t)];if(this._renderWorldCopies){const a=this.pointCoordinate(new p.P(0,0)),l=this.pointCoordinate(new p.P(this.width,0)),u=this.pointCoordinate(new p.P(this.width,this.height)),m=this.pointCoordinate(new p.P(0,this.height)),g=Math.floor(Math.min(a.x,l.x,u.x,m.x)),y=Math.floor(Math.max(a.x,l.x,u.x,m.x)),v=1;for(let S=g-v;S<=y+v;S++)S!==0&&n.push(new p.b4(S,t))}return n}coveringTiles(t){var n,a;let l=this.coveringZoomLevel(t);const u=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=p.Z.fromLngLat(this.center),y=Math.pow(2,l),v=[y*m.x,y*m.y,0],S=[y*g.x,y*g.y,0],T=Jr.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,l);let M=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(M=l);const z=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,R=O=>({aabb:new js([O*y,0,0],[(O+1)*y,y,0]),zoom:0,x:0,y:0,wrap:O,fullyVisible:!1}),N=[],B=[],U=l,G=t.reparseOverscaled?u:l;if(this._renderWorldCopies)for(let O=1;O<=3;O++)N.push(R(-O)),N.push(R(O));for(N.push(R(0));N.length>0;){const O=N.pop(),H=O.x,Q=O.y;let ee=O.fullyVisible;if(!ee){const ue=O.aabb.intersects(T);if(ue===0)continue;ee=ue===2}const oe=t.terrain?v:S,he=O.aabb.distanceX(oe),Te=O.aabb.distanceY(oe),Se=Math.max(Math.abs(he),Math.abs(Te));if(O.zoom===U||Se>z+(1<<U-O.zoom)-2&&O.zoom>=M){const ue=U-O.zoom,de=v[0]-.5-(H<<ue),Ce=v[1]-.5-(Q<<ue);B.push({tileID:new p.S(O.zoom===U?G:O.zoom,O.wrap,O.zoom,H,Q),distanceSq:ys([S[0]-.5-H,S[1]-.5-Q]),tileDistanceToCamera:Math.sqrt(de*de+Ce*Ce)})}else for(let ue=0;ue<4;ue++){const de=(H<<1)+ue%2,Ce=(Q<<1)+(ue>>1),Ne=O.zoom+1;let _e=O.aabb.quadrant(ue);if(t.terrain){const ve=new p.S(Ne,O.wrap,Ne,de,Ce),Oe=t.terrain.getMinMaxElevation(ve),pt=(n=Oe.minElevation)!==null&&n!==void 0?n:this.elevation,qe=(a=Oe.maxElevation)!==null&&a!==void 0?a:this.elevation;_e=new js([_e.min[0],_e.min[1],pt],[_e.max[0],_e.max[1],qe])}N.push({aabb:_e,zoom:Ne,x:de,y:Ce,wrap:O.wrap,fullyVisible:ee})}}return B.sort((O,H)=>O.distanceSq-H.distanceSq).map(O=>O.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=p.ad(t.lat,-85.051129,Ba);return new p.P(p.O(t.lng)*this.worldSize,p.Q(n)*this.worldSize)}unproject(t){return new p.Z(t.x/this.worldSize,t.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(t){const n=this.elevation,a=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,l=this.pointLocation(this.centerPoint,t),u=t.getElevationForLngLatZoom(l,this.tileZoom);if(!(this.elevation-u))return;const m=a+n-u,g=Math.cos(this._pitch)*this.cameraToCenterDistance/m/p.b5(1,l.lat),y=this.scaleZoom(g/this.tileSize);this._elevation=u,this._center=l,this.zoom=y}setLocationAtPoint(t,n){const a=this.pointCoordinate(n),l=this.pointCoordinate(this.centerPoint),u=this.locationCoordinate(t),m=new p.Z(u.x-(a.x-l.x),u.y-(a.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),n.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,n){return this.coordinateLocation(this.pointCoordinate(t,n))}locationCoordinate(t){return p.Z.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,n){if(n){const M=n.pointCoordinate(t);if(M!=null)return M}const a=[t.x,t.y,0,1],l=[t.x,t.y,1,1];p.ag(a,a,this.pixelMatrixInverse),p.ag(l,l,this.pixelMatrixInverse);const u=a[3],m=l[3],g=a[1]/u,y=l[1]/m,v=a[2]/u,S=l[2]/m,T=v===S?0:(0-v)/(S-v);return new p.Z(p.z.number(a[0]/u,l[0]/m,T)/this.worldSize,p.z.number(g,y,T)/this.worldSize)}coordinatePoint(t,n=0,a=this.pixelMatrix){const l=[t.x*this.worldSize,t.y*this.worldSize,n,1];return p.ag(l,l,a),new p.P(l[0]/l[3],l[1]/l[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return new re().extend(this.pointLocation(new p.P(0,t))).extend(this.pointLocation(new p.P(this.width,t))).extend(this.pointLocation(new p.P(this.width,this.height))).extend(this.pointLocation(new p.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new re([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=[-85.051129,Ba])}calculateTileMatrix(t){const n=t.canonical,a=this.worldSize/this.zoomScale(n.z),l=n.x+Math.pow(2,n.z)*t.wrap,u=p.ao(new Float64Array(16));return p.J(u,u,[l*a,n.y*a,0]),p.K(u,u,[a/p.X,a/p.X,1]),u}calculatePosMatrix(t,n=!1){const a=t.key,l=n?this._alignedPosMatrixCache:this._posMatrixCache;if(l[a])return l[a];const u=this.calculateTileMatrix(t);return p.L(u,n?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,u),l[a]=new Float32Array(u),l[a]}calculateFogMatrix(t){const n=t.key,a=this._fogMatrixCache;if(a[n])return a[n];const l=this.calculateTileMatrix(t);return p.L(l,this.fogMatrix,l),a[n]=new Float32Array(l),a[n]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(t,n){n=p.ad(+n,this.minZoom,this.maxZoom);const a={center:new p.N(t.lng,t.lat),zoom:n};let l=this.lngRange;if(!this._renderWorldCopies&&l===null){const O=179.9999999999;l=[-O,O]}const u=this.tileSize*this.zoomScale(a.zoom);let m=0,g=u,y=0,v=u,S=0,T=0;const{x:M,y:z}=this.size;if(this.latRange){const O=this.latRange;m=p.Q(O[1])*u,g=p.Q(O[0])*u,g-m<z&&(S=z/(g-m))}l&&(y=p.b3(p.O(l[0])*u,0,u),v=p.b3(p.O(l[1])*u,0,u),v<y&&(v+=u),v-y<M&&(T=M/(v-y)));const{x:R,y:N}=this.project.call({worldSize:u},t);let B,U;const G=Math.max(T||0,S||0);if(G){const O=new p.P(T?(v+y)/2:R,S?(g+m)/2:N);return a.center=this.unproject.call({worldSize:u},O).wrap(),a.zoom+=this.scaleZoom(G),a}if(this.latRange){const O=z/2;N-O<m&&(U=m+O),N+O>g&&(U=g-O)}if(l){const O=(y+v)/2;let H=R;this._renderWorldCopies&&(H=p.b3(R,O-u/2,O+u/2));const Q=M/2;H-Q<y&&(B=y+Q),H+Q>v&&(B=v-Q)}if(B!==void 0||U!==void 0){const O=new p.P(B??R,U??N);a.center=this.unproject.call({worldSize:u},O).wrap()}return a}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:n,zoom:a}=this.getConstrained(this.center,this.zoom);this.center=n,this.zoom=a,this._unmodified=t,this._constraining=!1}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,n=this.point.x,a=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=p.b5(1,this.center.lat)*this.worldSize;let l=p.ao(new Float64Array(16));p.K(l,l,[this.width/2,-this.height/2,1]),p.J(l,l,[1,-1,0]),this.labelPlaneMatrix=l,l=p.ao(new Float64Array(16)),p.K(l,l,[1,-1,1]),p.J(l,l,[-1,-1,0]),p.K(l,l,[2/this.width,2/this.height,1]),this.glCoordMatrix=l;const u=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),m=Math.min(this.elevation,this.minElevationForCurrentTile),g=u-m*this._pixelPerMeter/Math.cos(this._pitch),y=m<0?g:u,v=Math.PI/2+this._pitch,S=this._fov*(.5+t.y/this.height),T=Math.sin(S)*y/Math.sin(p.ad(Math.PI-v-S,.01,Math.PI-.01)),M=this.getHorizon(),z=2*Math.atan(M/this.cameraToCenterDistance)*(.5+t.y/(2*M)),R=Math.sin(z)*y/Math.sin(p.ad(Math.PI-v-z,.01,Math.PI-.01)),N=Math.min(T,R),B=1.01*(Math.cos(Math.PI/2-this._pitch)*N+y),U=this.height/50;l=new Float64Array(16),p.b6(l,this._fov,this.width/this.height,U,B),l[8]=2*-t.x/this.width,l[9]=2*t.y/this.height,p.K(l,l,[1,-1,1]),p.J(l,l,[0,0,-this.cameraToCenterDistance]),p.b7(l,l,this._pitch),p.ae(l,l,this.angle),p.J(l,l,[-n,-a,0]),this.mercatorMatrix=p.K([],l,[this.worldSize,this.worldSize,this.worldSize]),p.K(l,l,[1,1,this._pixelPerMeter]),this.pixelMatrix=p.L(new Float64Array(16),this.labelPlaneMatrix,l),p.J(l,l,[0,0,-this.elevation]),this.modelViewProjectionMatrix=l,this.invModelViewProjectionMatrix=p.at([],l),this.fogMatrix=new Float64Array(16),p.b6(this.fogMatrix,this._fov,this.width/this.height,u,B),this.fogMatrix[8]=2*-t.x/this.width,this.fogMatrix[9]=2*t.y/this.height,p.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),p.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),p.b7(this.fogMatrix,this.fogMatrix,this._pitch),p.ae(this.fogMatrix,this.fogMatrix,this.angle),p.J(this.fogMatrix,this.fogMatrix,[-n,-a,0]),p.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),p.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=p.L(new Float64Array(16),this.labelPlaneMatrix,l);const G=this.width%2/2,O=this.height%2/2,H=Math.cos(this.angle),Q=Math.sin(this.angle),ee=n-Math.round(n)+H*G+Q*O,oe=a-Math.round(a)+H*O+Q*G,he=new Float64Array(l);if(p.J(he,he,[ee>.5?ee-1:ee,oe>.5?oe-1:oe,0]),this.alignedModelViewProjectionMatrix=he,l=p.at(new Float64Array(16),this.pixelMatrix),!l)throw new Error("failed to invert matrix");this.pixelMatrixInverse=l,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const t=this.pointCoordinate(new p.P(0,0)),n=[t.x*this.worldSize,t.y*this.worldSize,0,1];return p.ag(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new p.P(0,t))}getCameraQueryGeometry(t){const n=this.getCameraPoint();if(t.length===1)return[t[0],n];{let a=n.x,l=n.y,u=n.x,m=n.y;for(const g of t)a=Math.min(a,g.x),l=Math.min(l,g.y),u=Math.max(u,g.x),m=Math.max(m,g.y);return[new p.P(a,l),new p.P(u,l),new p.P(u,m),new p.P(a,m),new p.P(a,l)]}}lngLatToCameraDepth(t,n){const a=this.locationCoordinate(t),l=[a.x*this.worldSize,a.y*this.worldSize,n,1];return p.ag(l,l,this.modelViewProjectionMatrix),l[2]/l[3]}}function $s(h,t){let n,a=!1,l=null,u=null;const m=()=>{l=null,a&&(h.apply(u,n),l=setTimeout(m,t),a=!1)};return(...g)=>(a=!0,u=this,n=g,l||m(),l)}class is{constructor(t){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let a;return n.split("&").map(l=>l.split("=")).forEach(l=>{l[0]===this._hashName&&(a=l)}),(a&&a[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(n.length>=3&&!n.some(a=>isNaN(a))){const a=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:a,pitch:+(n[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const n=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,n)}catch{}},this._updateHash=$s(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(t){const n=this._map.getCenter(),a=Math.round(100*this._map.getZoom())/100,l=Math.ceil((a*Math.LN2+Math.log(512/360/.5))/Math.LN10),u=Math.pow(10,l),m=Math.round(n.lng*u)/u,g=Math.round(n.lat*u)/u,y=this._map.getBearing(),v=this._map.getPitch();let S="";if(S+=t?`/${m}/${g}/${a}`:`${a}/${g}/${m}`,(y||v)&&(S+="/"+Math.round(10*y)/10),v&&(S+=`/${Math.round(v)}`),this._hashName){const T=this._hashName;let M=!1;const z=window.location.hash.slice(1).split("&").map(R=>{const N=R.split("=")[0];return N===T?(M=!0,`${N}=${S}`):R}).filter(R=>R);return M||z.push(`${T}=${S}`),`#${z.join("&")}`}return`#${S}`}}const Yr={linearity:.3,easing:p.b8(0,0,.3,1)},Oa=p.e({deceleration:2500,maxSpeed:1400},Yr),Va=p.e({deceleration:20,maxSpeed:1400},Yr),rl=p.e({deceleration:1e3,maxSpeed:360},Yr),qs=p.e({deceleration:1e3,maxSpeed:90},Yr);class Zs{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:me.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=me.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 p.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:u}of this._inertiaBuffer)n.zoom+=u.zoomDelta||0,n.bearing+=u.bearingDelta||0,n.pitch+=u.pitchDelta||0,u.panDelta&&n.pan._add(u.panDelta),u.around&&(n.around=u.around),u.pinchAround&&(n.pinchAround=u.pinchAround);const a=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,l={};if(n.pan.mag()){const u=Gs(n.pan.mag(),a,p.e({},Oa,t||{}));l.offset=n.pan.mult(u.amount/n.pan.mag()),l.center=this._map.transform.center,yn(l,u)}if(n.zoom){const u=Gs(n.zoom,a,Va);l.zoom=this._map.transform.zoom+u.amount,yn(l,u)}if(n.bearing){const u=Gs(n.bearing,a,rl);l.bearing=this._map.transform.bearing+p.ad(u.amount,-179,179),yn(l,u)}if(n.pitch){const u=Gs(n.pitch,a,qs);l.pitch=this._map.transform.pitch+u.amount,yn(l,u)}if(l.zoom||l.bearing){const u=n.pinchAround===void 0?n.around:n.pinchAround;l.around=u?this._map.unproject(u):this._map.getCenter()}return this.clear(),p.e(l,{noMoveStart:!0})}}function yn(h,t){(!h.duration||h.duration<t.duration)&&(h.duration=t.duration,h.easing=t.easing)}function Gs(h,t,n){const{maxSpeed:a,linearity:l,deceleration:u}=n,m=p.ad(h*l/(t/1e3),-a,a),g=Math.abs(m)/(u*l);return{easing:n.easing,duration:1e3*g,amount:m*(g/2)}}class ei extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,a,l={}){const u=se.mousePos(n.getCanvas(),a),m=n.unproject(u);super(t,p.e({point:u,lngLat:m,originalEvent:a},l)),this._defaultPrevented=!1,this.target=n}}class rs extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,a){const l=t==="touchend"?a.changedTouches:a.touches,u=se.touchPos(n.getCanvasContainer(),l),m=u.map(y=>n.unproject(y)),g=u.reduce((y,v,S,T)=>y.add(v.div(T.length)),new p.P(0,0));super(t,{points:u,point:g,lngLats:m,lngLat:n.unproject(g),originalEvent:a}),this._defaultPrevented=!1}}class Na extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,a){super(t,{originalEvent:a}),this._defaultPrevented=!1}}class Xs{constructor(t,n){this._map=t,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new Na(t.type,this._map,t))}mousedown(t,n){return this._mousedownPos=n,this._firePreventable(new ei(t.type,this._map,t))}mouseup(t){this._map.fire(new ei(t.type,this._map,t))}click(t,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new ei(t.type,this._map,t))}dblclick(t){return this._firePreventable(new ei(t.type,this._map,t))}mouseover(t){this._map.fire(new ei(t.type,this._map,t))}mouseout(t){this._map.fire(new ei(t.type,this._map,t))}touchstart(t){return this._firePreventable(new rs(t.type,this._map,t))}touchmove(t){this._map.fire(new rs(t.type,this._map,t))}touchend(t){this._map.fire(new rs(t.type,this._map,t))}touchcancel(t){this._map.fire(new rs(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ja{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new ei(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ei("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new ei(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class xn{constructor(t){this._map=t}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(t){return this.transform.pointLocation(p.P.convert(t),this._map.terrain)}}class Ua{constructor(t,n){this._map=t,this._tr=new xn(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&&(se.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(t,n){if(!this._active)return;const a=n;if(this._lastPos.equals(a)||!this._box&&a.dist(this._startPos)<this._clickTolerance)return;const l=this._startPos;this._lastPos=a,this._box||(this._box=se.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));const u=Math.min(l.x,a.x),m=Math.max(l.x,a.x),g=Math.min(l.y,a.y),y=Math.max(l.y,a.y);se.setTransform(this._box,`translate(${u}px,${g}px)`),this._box.style.width=m-u+"px",this._box.style.height=y-g+"px"}mouseupWindow(t,n){if(!this._active||t.button!==0)return;const a=this._startPos,l=n;if(this.reset(),se.suppressClick(),a.x!==l.x||a.y!==l.y)return this._map.fire(new p.k("boxzoomend",{originalEvent:t})),{cameraAnimation:u=>u.fitScreenCoordinates(a,l,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&t.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(se.remove(this._box),this._box=null),se.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new p.k(t,{originalEvent:n}))}}function vn(h,t){if(h.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${h.length}, points ${t.length}`);const n={};for(let a=0;a<h.length;a++)n[h[a].identifier]=t[a];return n}class $a{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,n,a){(this.centroid||a.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=t.timeStamp),a.length===this.numTouches&&(this.centroid=function(l){const u=new p.P(0,0);for(const m of l)u._add(m);return u.div(l.length)}(n),this.touches=vn(a,n)))}touchmove(t,n,a){if(this.aborted||!this.centroid)return;const l=vn(a,n);for(const u in this.touches){const m=l[u];(!m||m.dist(this.touches[u])>30)&&(this.aborted=!0)}}touchend(t,n,a){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),a.length===0){const l=!this.aborted&&this.centroid;if(this.reset(),l)return l}}}class qa{constructor(t){this.singleTap=new $a(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,n,a){this.singleTap.touchstart(t,n,a)}touchmove(t,n,a){this.singleTap.touchmove(t,n,a)}touchend(t,n,a){const l=this.singleTap.touchend(t,n,a);if(l){const u=t.timeStamp-this.lastTime<500,m=!this.lastTap||this.lastTap.dist(l)<30;if(u&&m||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=l,this.count===this.numTaps)return this.reset(),l}}}class nl{constructor(t){this._tr=new xn(t),this._zoomIn=new qa({numTouches:1,numTaps:2}),this._zoomOut=new qa({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,n,a){this._zoomIn.touchstart(t,n,a),this._zoomOut.touchstart(t,n,a)}touchmove(t,n,a){this._zoomIn.touchmove(t,n,a),this._zoomOut.touchmove(t,n,a)}touchend(t,n,a){const l=this._zoomIn.touchend(t,n,a),u=this._zoomOut.touchend(t,n,a),m=this._tr;return l?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:m.zoom+1,around:m.unproject(l)},{originalEvent:t})}):u?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:m.zoom-1,around:m.unproject(u)},{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 dt{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 a=this._lastPoint;if(!a)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(a)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=l,this._move(a,l))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&se.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 Qr={0:1,2:2};class ai{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){const n=se.mouseButton(t);this._eventButton=n}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!function(n,a){const l=Qr[a];return n.buttons===void 0||(n.buttons&l)!==l}(t,this._eventButton)}isValidEndEvent(t){return se.mouseButton(t)===this._eventButton}}class Ws{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 ns=h=>{h.mousedown=h.dragStart,h.mousemoveWindow=h.dragMove,h.mouseup=h.dragEnd,h.contextmenu=t=>{t.preventDefault()}},Za=({enable:h,clickTolerance:t,bearingDegreesPerPixelMoved:n=.8})=>{const a=new ai({checkCorrectEvent:l=>se.mouseButton(l)===0&&l.ctrlKey||se.mouseButton(l)===2});return new dt({clickTolerance:t,move:(l,u)=>({bearingDelta:(u.x-l.x)*n}),moveStateManager:a,enable:h,assignEvents:ns})},en=({enable:h,clickTolerance:t,pitchDegreesPerPixelMoved:n=-.5})=>{const a=new ai({checkCorrectEvent:l=>se.mouseButton(l)===0&&l.ctrlKey||se.mouseButton(l)===2});return new dt({clickTolerance:t,move:(l,u)=>({pitchDelta:(u.y-l.y)*n}),moveStateManager:a,enable:h,assignEvents:ns})};class ss{constructor(t,n){this._clickTolerance=t.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new p.P(0,0)}minTouchs(){return this._map.cooperativeGestures.isEnabled()?2:1}touchstart(t,n,a){return this._calculateTransform(t,n,a)}touchmove(t,n,a){if(this._active&&!(a.length<this.minTouchs()))return t.preventDefault(),this._calculateTransform(t,n,a)}touchend(t,n,a){this._calculateTransform(t,n,a),this._active&&a.length<this.minTouchs()&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,n,a){a.length>0&&(this._active=!0);const l=vn(a,n),u=new p.P(0,0),m=new p.P(0,0);let g=0;for(const v in l){const S=l[v],T=this._touches[v];T&&(u._add(S),m._add(S.sub(T)),g++,l[v]=S)}if(this._touches=l,g<this.minTouchs()||!m.mag())return;const y=m.div(g);return this._sum._add(y),this._sum.mag()<this._clickTolerance?void 0:{around:u.div(g),panDelta:y}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class as{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,n,a){this._firstTwoTouches||a.length<2||(this._firstTwoTouches=[a[0].identifier,a[1].identifier],this._start([n[0],n[1]]))}touchmove(t,n,a){if(!this._firstTwoTouches)return;t.preventDefault();const[l,u]=this._firstTwoTouches,m=os(a,n,l),g=os(a,n,u);if(!m||!g)return;const y=this._aroundCenter?null:m.add(g).div(2);return this._move([m,g],y,t)}touchend(t,n,a){if(!this._firstTwoTouches)return;const[l,u]=this._firstTwoTouches,m=os(a,n,l),g=os(a,n,u);m&&g||(this._active&&se.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 os(h,t,n){for(let a=0;a<h.length;a++)if(h[a].identifier===n)return t[a]}function Ga(h,t){return Math.log(h/t)/Math.LN2}class Xa extends as{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,n){const a=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(Ga(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Ga(this._distance,a),pinchAround:n}}}function Wa(h,t){return 180*h.angleWith(t)/Math.PI}class Ha extends as{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,n,a){const l=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Wa(this._vector,l),pinchAround:n}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const n=25/(Math.PI*this._minDiameter)*360,a=Wa(t,this._startVector);return Math.abs(a)<n}}function pr(h){return Math.abs(h.y)>Math.abs(h.x)}class Ka extends as{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,n,a){super.touchstart(t,n,a),this._currentTouchCount=a.length}_start(t){this._lastPoints=t,pr(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,n,a){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const l=t[0].sub(this._lastPoints[0]),u=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(l,u,a.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(l.y+u.y)/2*-.5}):void 0}gestureBeginsVertically(t,n,a){if(this._valid!==void 0)return this._valid;const l=t.mag()>=2,u=n.mag()>=2;if(!l&&!u)return;if(!l||!u)return this._firstMove===void 0&&(this._firstMove=a),a-this._firstMove<100&&void 0;const m=t.y>0==n.y>0;return pr(t)&&pr(n)&&m}}const sl={panStep:100,bearingStep:15,pitchStep:10};class Ja{constructor(t){this._tr=new xn(t);const n=sl;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=0,a=0,l=0,u=0,m=0;switch(t.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:t.shiftKey?a=-1:(t.preventDefault(),u=-1);break;case 39:t.shiftKey?a=1:(t.preventDefault(),u=1);break;case 38:t.shiftKey?l=1:(t.preventDefault(),m=-1);break;case 40:t.shiftKey?l=-1:(t.preventDefault(),m=1);break;default:return}return this._rotationDisabled&&(a=0,l=0),{cameraAnimation:g=>{const y=this._tr;g.easeTo({duration:300,easeId:"keyboardHandler",easing:al,zoom:n?Math.round(y.zoom)+n*(t.shiftKey?2:1):y.zoom,bearing:y.bearing+a*this._bearingStep,pitch:y.pitch+l*this._pitchStep,offset:[-u*this._panStep,-m*this._panStep],center:y.center},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function al(h){return h*(2-h)}const Ya=4.000244140625;class Qa{constructor(t,n){this._onTimeout=a=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)},this._map=t,this._tr=new xn(t),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}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()||this._map.cooperativeGestures.isEnabled()&&!t[this._map.cooperativeGestures._bypassKey])return;let n=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const a=me.now(),l=a-(this._lastWheelEventTime||0);this._lastWheelEventTime=a,n!==0&&n%Ya==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":l>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(l*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const n=se.mousePos(this._map.getCanvas(),t),a=this._tr;this._around=n.y>a.transform.height/2-a.transform.getHorizon()?p.N.convert(this._aroundCenter?a.center:a.unproject(n)):p.N.convert(a.center),this._aroundPoint=a.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const t=this._tr.transform;if(this._delta!==0){const g=this._type==="wheel"&&Math.abs(this._delta)>Ya?this._wheelZoomRate:this._defaultZoomRate;let y=2/(1+Math.exp(-Math.abs(this._delta*g)));this._delta<0&&y!==0&&(y=1/y);const v=typeof this._targetZoom=="number"?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(v*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,a=this._startZoom,l=this._easing;let u,m=!1;if(this._type==="wheel"&&a&&l){const g=Math.min((me.now()-this._lastWheelEventTime)/200,1),y=l(g);u=p.z.number(a,n,y),g<1?this._frameId||(this._frameId=!0):m=!0}else u=n,m=!0;return this._active=!0,m&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!m,zoomDelta:u-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=p.b9;if(this._prevEase){const a=this._prevEase,l=(me.now()-a.start)/a.duration,u=a.easing(l+.01)-a.easing(l),m=.27/Math.sqrt(u*u+1e-4)*.01,g=Math.sqrt(.0729-m*m);n=p.b8(m,g,.25,1)}return this._prevEase={start:me.now(),duration:t,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class eo{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 ls{constructor(t){this._tr=new xn(t),this.reset()}reset(){this._active=!1}dblclick(t,n){return t.preventDefault(),{cameraAnimation:a=>{a.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ol{constructor(){this._tap=new qa({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,n,a){if(!this._swipePoint)if(this._tapTime){const l=n[0],u=t.timeStamp-this._tapTime<500,m=this._tapPoint.dist(l)<30;u&&m?a.length>0&&(this._swipePoint=l,this._swipeTouch=a[0].identifier):this.reset()}else this._tap.touchstart(t,n,a)}touchmove(t,n,a){if(this._tapTime){if(this._swipePoint){if(a[0].identifier!==this._swipeTouch)return;const l=n[0],u=l.y-this._swipePoint.y;return this._swipePoint=l,t.preventDefault(),this._active=!0,{zoomDelta:u/128}}}else this._tap.touchmove(t,n,a)}touchend(t,n,a){if(this._tapTime)this._swipePoint&&a.length===0&&this.reset();else{const l=this._tap.touchend(t,n,a);l&&(this._tapTime=t.timeStamp,this._tapPoint=l)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ai{constructor(t,n,a){this._el=t,this._mousePan=n,this._touchPan=a}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Di{constructor(t,n,a){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=n,this._mousePitch=a}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class to{constructor(t,n,a,l){this._el=t,this._touchZoom=n,this._touchRotate=a,this._tapDragZoom=l,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Li{constructor(t,n){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=t,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=se.create("div","maplibregl-cooperative-gesture-screen",t);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const a=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),l=document.createElement("div");l.className="maplibregl-desktop-message",l.textContent=n,this._container.appendChild(l);const u=document.createElement("div");u.className="maplibregl-mobile-message",u.textContent=a,this._container.appendChild(u),this._container.setAttribute("aria-hidden","true")}_destoryUI(){this._container&&(se.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destoryUI()}isEnabled(){return this._enabled}touchmove(t){this._onCooperativeGesture(t.touches.length===1)}wheel(t){this._map.scrollZoom.isEnabled()&&this._onCooperativeGesture(!t[this._bypassKey])}_onCooperativeGesture(t){this._enabled&&t&&(this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const fr=h=>h.zoom||h.drag||h.pitch||h.rotate;class ic extends p.k{}function io(h){return h.panDelta&&h.panDelta.mag()||h.zoomDelta||h.bearingDelta||h.pitchDelta}class rc{constructor(t,n){this.handleWindowEvent=l=>{this.handleEvent(l,`${l.type}Window`)},this.handleEvent=(l,u)=>{if(l.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const m=l.type==="renderFrame"?void 0:l,g={needsRenderFrame:!1},y={},v={},S=l.touches,T=S?this._getMapTouches(S):void 0,M=T?se.touchPos(this._map.getCanvas(),T):se.mousePos(this._map.getCanvas(),l);for(const{handlerName:N,handler:B,allowed:U}of this._handlers){if(!B.isEnabled())continue;let G;this._blockedByActive(v,U,N)?B.reset():B[u||l.type]&&(G=B[u||l.type](l,M,T),this.mergeHandlerResult(g,y,G,N,m),G&&G.needsRenderFrame&&this._triggerRenderFrame()),(G||B.isActive())&&(v[N]=B)}const z={};for(const N in this._previousActiveHandlers)v[N]||(z[N]=m);this._previousActiveHandlers=v,(Object.keys(z).length||io(g))&&(this._changes.push([g,y,z]),this._triggerRenderFrame()),(Object.keys(v).length||io(g))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:R}=g;R&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],R(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Zs(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const a=this._el;this._listeners=[[a,"touchstart",{passive:!0}],[a,"touchmove",{passive:!1}],[a,"touchend",void 0],[a,"touchcancel",void 0],[a,"mousedown",void 0],[a,"mousemove",void 0],[a,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[a,"mouseover",void 0],[a,"mouseout",void 0],[a,"dblclick",void 0],[a,"click",void 0],[a,"keydown",{capture:!1}],[a,"keyup",void 0],[a,"wheel",{passive:!1}],[a,"contextmenu",void 0],[window,"blur",void 0]];for(const[l,u,m]of this._listeners)se.addEventListener(l,u,l===document?this.handleWindowEvent:this.handleEvent,m)}destroy(){for(const[t,n,a]of this._listeners)se.removeEventListener(t,n,t===document?this.handleWindowEvent:this.handleEvent,a)}_addDefaultHandlers(t){const n=this._map,a=n.getCanvasContainer();this._add("mapEvent",new Xs(n,t));const l=n.boxZoom=new Ua(n,t);this._add("boxZoom",l),t.interactive&&t.boxZoom&&l.enable();const u=n.cooperativeGestures=new Li(n,t.cooperativeGestures);this._add("cooperativeGestures",u),t.cooperativeGestures&&u.enable();const m=new nl(n),g=new ls(n);n.doubleClickZoom=new eo(g,m),this._add("tapZoom",m),this._add("clickZoom",g),t.interactive&&t.doubleClickZoom&&n.doubleClickZoom.enable();const y=new ol;this._add("tapDragZoom",y);const v=n.touchPitch=new Ka(n);this._add("touchPitch",v),t.interactive&&t.touchPitch&&n.touchPitch.enable(t.touchPitch);const S=Za(t),T=en(t);n.dragRotate=new Di(t,S,T),this._add("mouseRotate",S,["mousePitch"]),this._add("mousePitch",T,["mouseRotate"]),t.interactive&&t.dragRotate&&n.dragRotate.enable();const M=(({enable:G,clickTolerance:O})=>{const H=new ai({checkCorrectEvent:Q=>se.mouseButton(Q)===0&&!Q.ctrlKey});return new dt({clickTolerance:O,move:(Q,ee)=>({around:ee,panDelta:ee.sub(Q)}),activateOnStart:!0,moveStateManager:H,enable:G,assignEvents:ns})})(t),z=new ss(t,n);n.dragPan=new Ai(a,M,z),this._add("mousePan",M),this._add("touchPan",z,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&n.dragPan.enable(t.dragPan);const R=new Ha,N=new Xa;n.touchZoomRotate=new to(a,N,R,y),this._add("touchRotate",R,["touchPan","touchZoom"]),this._add("touchZoom",N,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&n.touchZoomRotate.enable(t.touchZoomRotate);const B=n.scrollZoom=new Qa(n,()=>this._triggerRenderFrame());this._add("scrollZoom",B,["mousePan"]),t.interactive&&t.scrollZoom&&n.scrollZoom.enable(t.scrollZoom);const U=n.keyboard=new Ja(n);this._add("keyboard",U),t.interactive&&t.keyboard&&n.keyboard.enable(),this._add("blockableMapEvent",new ja(n))}_add(t,n,a){this._handlers.push({handlerName:t,handler:n,allowed:a}),this._handlersById[t]=n}stop(t){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!fr(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,n,a){for(const l in t)if(l!==a&&(!n||n.indexOf(l)<0))return!0;return!1}_getMapTouches(t){const n=[];for(const a of t)this._el.contains(a.target)&&n.push(a);return n}mergeHandlerResult(t,n,a,l,u){if(!a)return;p.e(t,a);const m={handlerName:l,originalEvent:a.originalEvent||u};a.zoomDelta!==void 0&&(n.zoom=m),a.panDelta!==void 0&&(n.drag=m),a.pitchDelta!==void 0&&(n.pitch=m),a.bearingDelta!==void 0&&(n.rotate=m)}_applyChanges(){const t={},n={},a={};for(const[l,u,m]of this._changes)l.panDelta&&(t.panDelta=(t.panDelta||new p.P(0,0))._add(l.panDelta)),l.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+l.zoomDelta),l.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+l.bearingDelta),l.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+l.pitchDelta),l.around!==void 0&&(t.around=l.around),l.pinchAround!==void 0&&(t.pinchAround=l.pinchAround),l.noInertia&&(t.noInertia=l.noInertia),p.e(n,u),p.e(a,m);this._updateMapTransform(t,n,a),this._changes=[]}_updateMapTransform(t,n,a){const l=this._map,u=l._getTransformForUpdate(),m=l.terrain;if(!(io(t)||m&&this._terrainMovement))return this._fireEvents(n,a,!0);let{panDelta:g,zoomDelta:y,bearingDelta:v,pitchDelta:S,around:T,pinchAround:M}=t;M!==void 0&&(T=M),l._stop(!0),T=T||l.transform.centerPoint;const z=u.pointLocation(g?T.sub(g):T);v&&(u.bearing+=v),S&&(u.pitch+=S),y&&(u.zoom+=y),m?this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?u.center=u.pointLocation(u.centerPoint.sub(g)):u.setLocationAtPoint(z,T):(this._terrainMovement=!0,this._map._elevationFreeze=!0,u.setLocationAtPoint(z,T)):u.setLocationAtPoint(z,T),l._applyUpdatedTransform(u),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,a,!0)}_fireEvents(t,n,a){const l=fr(this._eventsInProgress),u=fr(t),m={};for(const T in t){const{originalEvent:M}=t[T];this._eventsInProgress[T]||(m[`${T}start`]=M),this._eventsInProgress[T]=t[T]}!l&&u&&this._fireEvent("movestart",u.originalEvent);for(const T in m)this._fireEvent(T,m[T]);u&&this._fireEvent("move",u.originalEvent);for(const T in t){const{originalEvent:M}=t[T];this._fireEvent(T,M)}const g={};let y;for(const T in this._eventsInProgress){const{handlerName:M,originalEvent:z}=this._eventsInProgress[T];this._handlersById[M].isActive()||(delete this._eventsInProgress[T],y=n[M]||z,g[`${T}end`]=y)}for(const T in g)this._fireEvent(T,g[T]);const v=fr(this._eventsInProgress),S=(l||u)&&!v;if(S&&this._terrainMovement&&(this._map._elevationFreeze=!1,this._terrainMovement=!1,this._map.transform.recalculateZoom(this._map.terrain)),a&&S){this._updatingCamera=!0;const T=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),M=z=>z!==0&&-this._bearingSnap<z&&z<this._bearingSnap;!T||!T.essential&&me.prefersReducedMotion?(this._map.fire(new p.k("moveend",{originalEvent:y})),M(this._map.getBearing())&&this._map.resetNorth()):(M(T.bearing||this._map.getBearing())&&(T.bearing=0),T.freezeElevation=!0,this._map.easeTo(T,{originalEvent:y})),this._updatingCamera=!1}}_fireEvent(t,n){this._map.fire(new p.k(t,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(t=>{delete this._frameId,this.handleEvent(new ic("renderFrame",{timeStamp:t})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class nc extends p.E{constructor(t,n){super(),this._renderFrameCallback=()=>{const a=Math.min((me.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(a)),a<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=n.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new p.N(this.transform.center.lng,this.transform.center.lat)}setCenter(t,n){return this.jumpTo({center:t},n)}panBy(t,n,a){return t=p.P.convert(t).mult(-1),this.panTo(this.transform.center,p.e({offset:t},n),a)}panTo(t,n,a){return this.easeTo(p.e({center:t},n),a)}getZoom(){return this.transform.zoom}setZoom(t,n){return this.jumpTo({zoom:t},n),this}zoomTo(t,n,a){return this.easeTo(p.e({zoom:t},n),a)}zoomIn(t,n){return this.zoomTo(this.getZoom()+1,t,n),this}zoomOut(t,n){return this.zoomTo(this.getZoom()-1,t,n),this}getBearing(){return this.transform.bearing}setBearing(t,n){return this.jumpTo({bearing:t},n),this}getPadding(){return this.transform.padding}setPadding(t,n){return this.jumpTo({padding:t},n),this}rotateTo(t,n,a){return this.easeTo(p.e({bearing:t},n),a)}resetNorth(t,n){return this.rotateTo(0,p.e({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(p.e({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=re.convert(t);const a=n&&n.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),a,n)}_cameraForBoxAndBearing(t,n,a,l){const u={top:0,bottom:0,right:0,left:0};if(typeof(l=p.e({padding:u,offset:[0,0],maxZoom:this.transform.maxZoom},l)).padding=="number"){const ue=l.padding;l.padding={top:ue,bottom:ue,right:ue,left:ue}}l.padding=p.e(u,l.padding);const m=this.transform,g=m.padding,y=new re(t,n),v=m.project(y.getNorthWest()),S=m.project(y.getNorthEast()),T=m.project(y.getSouthEast()),M=m.project(y.getSouthWest()),z=p.ba(-a),R=v.rotate(z),N=S.rotate(z),B=T.rotate(z),U=M.rotate(z),G=new p.P(Math.max(R.x,N.x,U.x,B.x),Math.max(R.y,N.y,U.y,B.y)),O=new p.P(Math.min(R.x,N.x,U.x,B.x),Math.min(R.y,N.y,U.y,B.y)),H=G.sub(O),Q=(m.width-(g.left+g.right+l.padding.left+l.padding.right))/H.x,ee=(m.height-(g.top+g.bottom+l.padding.top+l.padding.bottom))/H.y;if(ee<0||Q<0)return void p.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const oe=Math.min(m.scaleZoom(m.scale*Math.min(Q,ee)),l.maxZoom),he=p.P.convert(l.offset),Te=new p.P((l.padding.left-l.padding.right)/2,(l.padding.top-l.padding.bottom)/2).rotate(p.ba(a)),Se=he.add(Te).mult(m.scale/m.zoomScale(oe));return{center:m.unproject(v.add(T).div(2).sub(Se)),zoom:oe,bearing:a}}fitBounds(t,n,a){return this._fitInternal(this.cameraForBounds(t,n),n,a)}fitScreenCoordinates(t,n,a,l,u){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(p.P.convert(t)),this.transform.pointLocation(p.P.convert(n)),a,l),l,u)}_fitInternal(t,n,a){return t?(delete(n=p.e(t,n)).padding,n.linear?this.easeTo(n,a):this.flyTo(n,a)):this}jumpTo(t,n){this.stop();const a=this._getTransformForUpdate();let l=!1,u=!1,m=!1;return"zoom"in t&&a.zoom!==+t.zoom&&(l=!0,a.zoom=+t.zoom),t.center!==void 0&&(a.center=p.N.convert(t.center)),"bearing"in t&&a.bearing!==+t.bearing&&(u=!0,a.bearing=+t.bearing),"pitch"in t&&a.pitch!==+t.pitch&&(m=!0,a.pitch=+t.pitch),t.padding==null||a.isPaddingEqual(t.padding)||(a.padding=t.padding),this._applyUpdatedTransform(a),this.fire(new p.k("movestart",n)).fire(new p.k("move",n)),l&&this.fire(new p.k("zoomstart",n)).fire(new p.k("zoom",n)).fire(new p.k("zoomend",n)),u&&this.fire(new p.k("rotatestart",n)).fire(new p.k("rotate",n)).fire(new p.k("rotateend",n)),m&&this.fire(new p.k("pitchstart",n)).fire(new p.k("pitch",n)).fire(new p.k("pitchend",n)),this.fire(new p.k("moveend",n))}calculateCameraOptionsFromTo(t,n,a,l=0){const u=p.Z.fromLngLat(t,n),m=p.Z.fromLngLat(a,l),g=m.x-u.x,y=m.y-u.y,v=m.z-u.z,S=Math.hypot(g,y,v);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),z=180*Math.atan2(g,-y)/Math.PI;let R=180*Math.acos(T/S)/Math.PI;return R=v<0?90-R:90+R,{center:m.toLngLat(),zoom:M,pitch:R,bearing:z}}easeTo(t,n){var a;this._stop(!1,t.easeId),((t=p.e({offset:[0,0],duration:500,easing:p.b9},t)).animate===!1||!t.essential&&me.prefersReducedMotion)&&(t.duration=0);const l=this._getTransformForUpdate(),u=this.getZoom(),m=this.getBearing(),g=this.getPitch(),y=this.getPadding(),v="bearing"in t?this._normalizeBearing(t.bearing,m):m,S="pitch"in t?+t.pitch:g,T="padding"in t?t.padding:l.padding,M=p.P.convert(t.offset);let z=l.centerPoint.add(M);const R=l.pointLocation(z),{center:N,zoom:B}=l.getConstrained(p.N.convert(t.center||R),(a=t.zoom)!==null&&a!==void 0?a:u);this._normalizeCenter(N);const U=l.project(R),G=l.project(N).sub(U),O=l.zoomScale(B-u);let H,Q;t.around&&(H=p.N.convert(t.around),Q=l.locationPoint(H));const ee={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||B!==u,this._rotating=this._rotating||m!==v,this._pitching=this._pitching||S!==g,this._padding=!l.isPaddingEqual(T),this._easeId=t.easeId,this._prepareEase(n,t.noMoveStart,ee),this.terrain&&this._prepareElevation(N),this._ease(oe=>{if(this._zooming&&(l.zoom=p.z.number(u,B,oe)),this._rotating&&(l.bearing=p.z.number(m,v,oe)),this._pitching&&(l.pitch=p.z.number(g,S,oe)),this._padding&&(l.interpolatePadding(y,T,oe),z=l.centerPoint.add(M)),this.terrain&&!t.freezeElevation&&this._updateElevation(oe),H)l.setLocationAtPoint(H,Q);else{const he=l.zoomScale(l.zoom-u),Te=B>u?Math.min(2,O):Math.max(.5,O),Se=Math.pow(Te,1-oe),ue=l.unproject(U.add(G.mult(oe*Se)).mult(he));l.setLocationAtPoint(l.renderWorldCopies?ue.wrap():ue,z)}this._applyUpdatedTransform(l),this._fireMoveEvents(n)},oe=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(n,oe)},t),this}_prepareEase(t,n,a={}){this._moving=!0,n||a.moving||this.fire(new p.k("movestart",t)),this._zooming&&!a.zooming&&this.fire(new p.k("zoomstart",t)),this._rotating&&!a.rotating&&this.fire(new p.k("rotatestart",t)),this._pitching&&!a.pitching&&this.fire(new p.k("pitchstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&n!==this._elevationTarget){const a=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(a-(n-(a*t+this._elevationStart))/(1-t)),this._elevationTarget=n}this.transform.elevation=p.z.number(this._elevationStart,this._elevationTarget,t)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_applyUpdatedTransform(t){if(!this.transformCameraUpdate)return;const n=t.clone(),{center:a,zoom:l,pitch:u,bearing:m,elevation:g}=this.transformCameraUpdate(n);a&&(n.center=a),l!==void 0&&(n.zoom=l),u!==void 0&&(n.pitch=u),m!==void 0&&(n.bearing=m),g!==void 0&&(n.elevation=g),this.transform.apply(n)}_fireMoveEvents(t){this.fire(new p.k("move",t)),this._zooming&&this.fire(new p.k("zoom",t)),this._rotating&&this.fire(new p.k("rotate",t)),this._pitching&&this.fire(new p.k("pitch",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const a=this._zooming,l=this._rotating,u=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,a&&this.fire(new p.k("zoomend",t)),l&&this.fire(new p.k("rotateend",t)),u&&this.fire(new p.k("pitchend",t)),this.fire(new p.k("moveend",t))}flyTo(t,n){var a;if(!t.essential&&me.prefersReducedMotion){const ve=p.M(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(ve,n)}this.stop(),t=p.e({offset:[0,0],speed:1.2,curve:1.42,easing:p.b9},t);const l=this._getTransformForUpdate(),u=this.getZoom(),m=this.getBearing(),g=this.getPitch(),y=this.getPadding(),v="bearing"in t?this._normalizeBearing(t.bearing,m):m,S="pitch"in t?+t.pitch:g,T="padding"in t?t.padding:l.padding,M=p.P.convert(t.offset);let z=l.centerPoint.add(M);const R=l.pointLocation(z),{center:N,zoom:B}=l.getConstrained(p.N.convert(t.center||R),(a=t.zoom)!==null&&a!==void 0?a:u);this._normalizeCenter(N);const U=l.zoomScale(B-u),G=l.project(R),O=l.project(N).sub(G);let H=t.curve;const Q=Math.max(l.width,l.height),ee=Q/U,oe=O.mag();if("minZoom"in t){const ve=p.ad(Math.min(t.minZoom,u,B),l.minZoom,l.maxZoom),Oe=Q/l.zoomScale(ve-u);H=Math.sqrt(Oe/oe*2)}const he=H*H;function Te(ve){const Oe=(ee*ee-Q*Q+(ve?-1:1)*he*he*oe*oe)/(2*(ve?ee:Q)*he*oe);return Math.log(Math.sqrt(Oe*Oe+1)-Oe)}function Se(ve){return(Math.exp(ve)-Math.exp(-ve))/2}function ue(ve){return(Math.exp(ve)+Math.exp(-ve))/2}const de=Te(!1);let Ce=function(ve){return ue(de)/ue(de+H*ve)},Ne=function(ve){return Q*((ue(de)*(Se(Oe=de+H*ve)/ue(Oe))-Se(de))/he)/oe;var Oe},_e=(Te(!0)-de)/H;if(Math.abs(oe)<1e-6||!isFinite(_e)){if(Math.abs(Q-ee)<1e-6)return this.easeTo(t,n);const ve=ee<Q?-1:1;_e=Math.abs(Math.log(ee/Q))/H,Ne=()=>0,Ce=Oe=>Math.exp(ve*H*Oe)}return t.duration="duration"in t?+t.duration:1e3*_e/("screenSpeed"in t?+t.screenSpeed/H:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=m!==v,this._pitching=S!==g,this._padding=!l.isPaddingEqual(T),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(N),this._ease(ve=>{const Oe=ve*_e,pt=1/Ce(Oe);l.zoom=ve===1?B:u+l.scaleZoom(pt),this._rotating&&(l.bearing=p.z.number(m,v,ve)),this._pitching&&(l.pitch=p.z.number(g,S,ve)),this._padding&&(l.interpolatePadding(y,T,ve),z=l.centerPoint.add(M)),this.terrain&&!t.freezeElevation&&this._updateElevation(ve);const qe=ve===1?N:l.unproject(G.add(O.mult(Ne(Oe))).mult(pt));l.setLocationAtPoint(l.renderWorldCopies?qe.wrap():qe,z),this._applyUpdatedTransform(l),this._fireMoveEvents(n)},()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(n)},t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,n){var a;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const l=this._onEaseEnd;delete this._onEaseEnd,l.call(this,n)}return t||(a=this.handlers)===null||a===void 0||a.stop(!1),this}_ease(t,n,a){a.animate===!1||a.duration===0?(t(1),n()):(this._easeStart=me.now(),this._easeOptions=a,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,n){t=p.b3(t,-180,180);const a=Math.abs(t-n);return Math.abs(t-360-n)<a&&(t-=360),Math.abs(t+360-n)<a&&(t+=360),t}_normalizeCenter(t){const n=this.transform;if(!n.renderWorldCopies||n.lngRange)return;const a=t.lng-n.center.lng;t.lng+=a>180?-360:a<-180?360:0}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(p.N.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}const ro={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class bn{constructor(t=ro){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=se.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=se.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=se.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){se.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,n){const a=this._map._getUIString(`AttributionControl.${n}`);t.title=a,t.setAttribute("aria-label",a)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map(l=>typeof l!="string"?"":l)):typeof this.options.customAttribution=="string"&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const l=this._map.style.stylesheet;this.styleOwner=l.owner,this.styleId=l.id}const n=this._map.style.sourceCaches;for(const l in n){const u=n[l];if(u.used||u.usedForTerrain){const m=u.getSource();m.attribution&&t.indexOf(m.attribution)<0&&t.push(m.attribution)}}t=t.filter(l=>String(l).trim()),t.sort((l,u)=>l.length-u.length),t=t.filter((l,u)=>{for(let m=u+1;m<t.length;m++)if(t[m].indexOf(l)>=0)return!1;return!0});const a=t.join(" | ");a!==this._attribHTML&&(this._attribHTML=a,t.length?(this._innerContainer.innerHTML=a,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class er{constructor(t={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const a=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&a.classList.add("maplibregl-compact"):a.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=se.create("div","maplibregl-ctrl");const n=se.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){se.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Pe{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const n=++this._id;return this._queue.push({callback:t,id:n,cancelled:!1}),n}remove(t){const n=this._currentlyRunning,a=n?this._queue.concat(n):this._queue;for(const l of a)if(l.id===t)return void(l.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const a of n)if(!a.cancelled&&(a.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var ll=p.Y([{name:"a_pos3d",type:"Int16",components:3}]);class no extends p.E{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 a={};for(const l of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n}))a[l.key]=!0,this._renderableTilesKeys.push(l.key),this._tiles[l.key]||(l.posMatrix=new Float64Array(16),p.aQ(l.posMatrix,0,p.X,0,p.X,0,1),this._tiles[l.key]=new Ir(l,this.tileSize));for(const l in this._tiles)a[l]||delete this._tiles[l]}freeRtt(t){for(const n in this._tiles){const a=this._tiles[n];(!t||a.tileID.equals(t)||a.tileID.isChildOf(t)||t.isChildOf(a.tileID))&&(a.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(t=>this.getTileByID(t))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){const n={};for(const a of this._renderableTilesKeys){const l=this._tiles[a].tileID;if(l.canonical.equals(t.canonical)){const u=t.clone();u.posMatrix=new Float64Array(16),p.aQ(u.posMatrix,0,p.X,0,p.X,0,1),n[a]=u}else if(l.canonical.isChildOf(t.canonical)){const u=t.clone();u.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),v=p.X>>m;p.aQ(u.posMatrix,0,v,0,v,0,1),p.J(u.posMatrix,u.posMatrix,[-g*v,-y*v,0]),n[a]=u}else if(t.canonical.isChildOf(l.canonical)){const u=t.clone();u.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),v=p.X>>m;p.aQ(u.posMatrix,0,p.X,0,p.X,0,1),p.J(u.posMatrix,u.posMatrix,[g*v,y*v,0]),p.K(u.posMatrix,u.posMatrix,[1/2**m,1/2**m,0]),n[a]=u}}return n}getSourceTile(t,n){const a=this.sourceCache._source;let l=t.overscaledZ-this.deltaZoom;if(l>a.maxzoom&&(l=a.maxzoom),l<a.minzoom)return null;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(l).key);let u=this.sourceCache.getTileByID(this._sourceTileCache[t.key]);if((!u||!u.dem)&&n)for(;l>=a.minzoom&&(!u||!u.dem);)u=this.sourceCache.getTileByID(t.scaledTo(l--).key);return u}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter(n=>n.timeAdded>=t)}}class cl{constructor(t,n,a){this.painter=t,this.sourceCache=new no(n),this.options=a,this.exaggeration=typeof a.exaggeration=="number"?a.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,n,a,l=p.X){var u;if(!(n>=0&&n<l&&a>=0&&a<l))return 0;const m=this.getTerrainData(t),g=(u=m.tile)===null||u===void 0?void 0:u.dem;if(!g)return 0;const y=function(R,N,B){var U=N[0],G=N[1];return R[0]=B[0]*U+B[4]*G+B[12],R[1]=B[1]*U+B[5]*G+B[13],R}([],[n/l*p.X,a/l*p.X],m.u_terrain_matrix),v=[y[0]*g.dim,y[1]*g.dim],S=Math.floor(v[0]),T=Math.floor(v[1]),M=v[0]-S,z=v[1]-T;return g.get(S,T)*(1-M)*(1-z)+g.get(S+1,T)*M*(1-z)+g.get(S,T+1)*(1-M)*z+g.get(S+1,T+1)*M*z}getElevationForLngLatZoom(t,n){const{tileID:a,mercatorX:l,mercatorY:u}=this._getOverscaledTileIDFromLngLatZoom(t,n);return this.getElevation(a,l%p.X,u%p.X,p.X)}getElevation(t,n,a,l=p.X){return this.getDEMElevation(t,n,a,l)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){const l=this.painter.context,u=new p.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new rt(l,u,l.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new rt(l,new p.R({width:1,height:1}),l.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(l.gl.NEAREST,l.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=p.ao([])}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 rt(l,n.dem.getPixels(),l.gl.RGBA,{premultiply:!1}),n.demTexture.bind(l.gl.NEAREST,l.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}const a=n&&n+n.tileID.key+t.key;if(a&&!this._demMatrixCache[a]){const l=this.sourceCache.sourceCache._source.maxzoom;let u=t.canonical.z-n.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=l?u=t.canonical.z-l:p.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const m=t.canonical.x-(t.canonical.x>>u<<u),g=t.canonical.y-(t.canonical.y>>u<<u),y=p.bb(new Float64Array(16),[1/(p.X<<u),1/(p.X<<u),0]);p.J(y,y,[m*p.X,g*p.X,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:a?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:n&&n.dem&&n.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(n&&n.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:n}}getFramebuffer(t){const n=this.painter,a=n.width/devicePixelRatio,l=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===a&&this._fbo.height===l||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new rt(n.context,{width:a,height:l,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new rt(n.context,{width:a,height:l,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=n.context.createFramebuffer(a,l,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,a,l))),this._fbo.colorAttachment.set(t==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let u=0,m=0;u<this._coordsTextureSize;u++)for(let g=0;g<this._coordsTextureSize;g++,m+=4)n[m+0]=255&g,n[m+1]=255&u,n[m+2]=g>>8<<4|u>>8,n[m+3]=0;const a=new p.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),l=new rt(t,a,t.gl.RGBA,{premultiply:!1});return l.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=l,l}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);const n=new Uint8Array(4),a=this.painter.context,l=a.gl,u=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),m=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),g=Math.round(this.painter.height/devicePixelRatio);a.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),l.readPixels(u,g-m-1,1,1,l.RGBA,l.UNSIGNED_BYTE,n),a.bindFramebuffer.set(null);const y=n[0]+(n[2]>>4<<8),v=n[1]+((15&n[2])<<8),S=this.coordsIndex[255-n[3]],T=S&&this.sourceCache.getTileByID(S);if(!T)return null;const M=this._coordsTextureSize,z=(1<<T.tileID.canonical.z)*M;return new p.Z((T.tileID.canonical.x*M+y)/z+T.tileID.wrap,(T.tileID.canonical.y*M+v)/z,this.getElevation(T.tileID,y,v,M))}depthAtPoint(t){const n=new Uint8Array(4),a=this.painter.context,l=a.gl;return a.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),l.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,l.RGBA,l.UNSIGNED_BYTE,n),a.bindFramebuffer.set(null),(n[0]/16777216+n[1]/65536+n[2]/256+n[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;const t=this.painter.context,n=new p.bc,a=new p.aY,l=this.meshSize,u=p.X/l,m=l*l;for(let T=0;T<=l;T++)for(let M=0;M<=l;M++)n.emplaceBack(M*u,T*u,0);for(let T=0;T<m;T+=l+1)for(let M=0;M<l;M++)a.emplaceBack(M+T,l+M+T+1,l+M+T+2),a.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 z of[0,1])n.emplaceBack(M*u,T*p.X,z);for(let T=0;T<2*l;T+=2)a.emplaceBack(y+T,y+T+1,y+T+3),a.emplaceBack(y+T,y+T+3,y+T+2),a.emplaceBack(g+T,g+T+3,g+T+1),a.emplaceBack(g+T,g+T+2,g+T+3);const v=n.length,S=v+2*(l+1);for(const T of[0,1])for(let M=0;M<=l;M++)for(const z of[0,1])n.emplaceBack(T*p.X,M*u,z);for(let T=0;T<2*l;T+=2)a.emplaceBack(v+T,v+T+1,v+T+3),a.emplaceBack(v+T,v+T+3,v+T+2),a.emplaceBack(S+T,S+T+3,S+T+1),a.emplaceBack(S+T,S+T+2,S+T+3);return this._mesh=new tl(t.createVertexBuffer(n,ll.members),t.createIndexBuffer(a),p.a0.simpleSegment(0,0,n.length,a.length)),this._mesh}getMeshFrameDelta(t){return 2*Math.PI*p.bd/Math.pow(2,t)/5}getMinTileElevationForLngLatZoom(t,n){var a;const{tileID:l}=this._getOverscaledTileIDFromLngLatZoom(t,n);return(a=this.getMinMaxElevation(l).minElevation)!==null&&a!==void 0?a:0}getMinMaxElevation(t){const n=this.getTerrainData(t).tile,a={minElevation:null,maxElevation:null};return n&&n.dem&&(a.minElevation=n.dem.min*this.exaggeration,a.maxElevation=n.dem.max*this.exaggeration),a}_getOverscaledTileIDFromLngLatZoom(t,n){const a=p.Z.fromLngLat(t.wrap()),l=(1<<n)*p.X,u=a.x*l,m=a.y*l,g=Math.floor(u/p.X),y=Math.floor(m/p.X);return{tileID:new p.S(n,0,n,g,y),mercatorX:u,mercatorY:m}}}class cs{constructor(t,n,a){this._context=t,this._size=n,this._tileSize=a,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),a=new rt(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return a.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(a.texture),{id:t,fbo:n,texture:a,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(n=>t.id!==n),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length<this._size)&&this._objects.some(t=>!t.inUse)===!1}}const tr={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class hl{constructor(t,n){this.painter=t,this.terrain=n,this.pool=new cs(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(a=>!t._layers[a].isHidden(n)),this._coordsDescendingInv={};for(const a in t.sourceCaches){this._coordsDescendingInv[a]={};const l=t.sourceCaches[a].getVisibleCoordinates();for(const u of l){const m=this.terrain.sourceCache.getTerrainCoords(u);for(const g in m)this._coordsDescendingInv[a][g]||(this._coordsDescendingInv[a][g]=[]),this._coordsDescendingInv[a][g].push(m[g])}}this._coordsDescendingInvStr={};for(const a of t._order){const l=t._layers[a],u=l.source;if(tr[l.type]&&!this._coordsDescendingInvStr[u]){this._coordsDescendingInvStr[u]={};for(const m in this._coordsDescendingInv[u])this._coordsDescendingInvStr[u][m]=this._coordsDescendingInv[u][m].map(g=>g.key).sort().join()}}for(const a of this._renderableTiles)for(const l in this._coordsDescendingInvStr){const u=this._coordsDescendingInvStr[l][a.tileID.key];u&&u!==a.rttCoords[l]&&(a.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;const n=t.type,a=this.painter,l=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(tr[n]&&(this._prevType&&tr[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(t.id),!l))return!0;if(tr[this._prevType]||tr[n]&&l){this._prevType=n;const u=this._stacks.length-1,m=this._stacks[u]||[];for(const g of this._renderableTiles){if(this.pool.isFull()&&(ts(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(g),g.rtt[u]){const v=this.pool.getObjectForId(g.rtt[u].id);if(v.stamp===g.rtt[u].stamp){this.pool.useObject(v);continue}}const y=this.pool.getOrCreateFreeObject();this.pool.useObject(y),this.pool.stampObject(y),g.rtt[u]={id:y.id,stamp:y.stamp},a.context.bindFramebuffer.set(y.fbo.framebuffer),a.context.clear({color:p.aN.transparent,stencil:0}),a.currentStencilSource=void 0;for(let v=0;v<m.length;v++){const S=a.style._layers[m[v]],T=S.source?this._coordsDescendingInv[S.source][g.tileID.key]:[g.tileID];a.context.viewport.set([0,0,y.fbo.width,y.fbo.height]),a._renderTileClippingMasks(S,T),a.renderLayer(a,a.style.sourceCaches[S.source],S,T),S.source&&(g.rttCoords[S.source]=this._coordsDescendingInvStr[S.source][g.tileID.key])}}return ts(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),tr[n]}return!1}}const we={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},so=Ti,sc={hash:!1,interactive:!0,bearingSnap:7,attributionControl:ro,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,refreshExpiredTiles:!0,scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],zoom:0,bearing:0,pitch:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:p.a.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0},ul=h=>{h.touchstart=h.dragStart,h.touchmoveWindow=h.dragMove,h.touchend=h.dragEnd},ao={showCompass:!0,showZoom:!0,visualizePitch:!1};class dl{constructor(t,n,a=!1){this.mousedown=m=>{this.startMouse(p.e({},m,{ctrlKey:!0,preventDefault:()=>m.preventDefault()}),se.mousePos(this.element,m)),se.addEventListener(window,"mousemove",this.mousemove),se.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=m=>{this.moveMouse(m,se.mousePos(this.element,m))},this.mouseup=m=>{this.mouseRotate.dragEnd(m),this.mousePitch&&this.mousePitch.dragEnd(m),this.offTemp()},this.touchstart=m=>{m.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=se.touchPos(this.element,m.targetTouches)[0],this.startTouch(m,this._startPos),se.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.addEventListener(window,"touchend",this.touchend))},this.touchmove=m=>{m.targetTouches.length!==1?this.reset():(this._lastPos=se.touchPos(this.element,m.targetTouches)[0],this.moveTouch(m,this._lastPos))},this.touchend=m=>{m.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.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()},this._clickTolerance=10;const l=t.dragRotate._mouseRotate.getClickTolerance(),u=t.dragRotate._mousePitch.getClickTolerance();this.element=n,this.mouseRotate=Za({clickTolerance:l,enable:!0}),this.touchRotate=(({enable:m,clickTolerance:g,bearingDegreesPerPixelMoved:y=.8})=>{const v=new Ws;return new dt({clickTolerance:g,move:(S,T)=>({bearingDelta:(T.x-S.x)*y}),moveStateManager:v,enable:m,assignEvents:ul})})({clickTolerance:l,enable:!0}),this.map=t,a&&(this.mousePitch=en({clickTolerance:u,enable:!0}),this.touchPitch=(({enable:m,clickTolerance:g,pitchDegreesPerPixelMoved:y=-.5})=>{const v=new Ws;return new dt({clickTolerance:g,move:(S,T)=>({pitchDelta:(T.y-S.y)*y}),moveStateManager:v,enable:m,assignEvents:ul})})({clickTolerance:u,enable:!0})),se.addEventListener(n,"mousedown",this.mousedown),se.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),se.addEventListener(n,"touchcancel",this.reset)}startMouse(t,n){this.mouseRotate.dragStart(t,n),this.mousePitch&&this.mousePitch.dragStart(t,n),se.disableDrag()}startTouch(t,n){this.touchRotate.dragStart(t,n),this.touchPitch&&this.touchPitch.dragStart(t,n),se.disableDrag()}moveMouse(t,n){const a=this.map,{bearingDelta:l}=this.mouseRotate.dragMove(t,n)||{};if(l&&a.setBearing(a.getBearing()+l),this.mousePitch){const{pitchDelta:u}=this.mousePitch.dragMove(t,n)||{};u&&a.setPitch(a.getPitch()+u)}}moveTouch(t,n){const a=this.map,{bearingDelta:l}=this.touchRotate.dragMove(t,n)||{};if(l&&a.setBearing(a.getBearing()+l),this.touchPitch){const{pitchDelta:u}=this.touchPitch.dragMove(t,n)||{};u&&a.setPitch(a.getPitch()+u)}}off(){const t=this.element;se.removeEventListener(t,"mousedown",this.mousedown),se.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),se.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.removeEventListener(window,"touchend",this.touchend),se.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){se.enableDrag(),se.removeEventListener(window,"mousemove",this.mousemove),se.removeEventListener(window,"mouseup",this.mouseup),se.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.removeEventListener(window,"touchend",this.touchend)}}let zr;function pl(h,t,n){const a=new p.N(h.lng,h.lat);if(h=new p.N(h.lng,h.lat),t){const l=new p.N(h.lng-360,h.lat),u=new p.N(h.lng+360,h.lat),m=n.locationPoint(h).distSqr(t);n.locationPoint(l).distSqr(t)<m?h=l:n.locationPoint(u).distSqr(t)<m&&(h=u)}for(;Math.abs(h.lng-n.center.lng)>180;){const l=n.locationPoint(h);if(l.x>=0&&l.y>=0&&l.x<=n.width&&l.y<=n.height)break;h.lng>n.center.lng?h.lng-=360:h.lng+=360}return h.lng!==a.lng&&n.locationPoint(h).y>n.height/2-n.getHorizon()?h:a}const oo={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 Er(h,t,n){const a=h.classList;for(const l in oo)a.remove(`maplibregl-${n}-anchor-${l}`);a.add(`maplibregl-${n}-anchor-${t}`)}class ct extends p.E{constructor(t){if(super(),this._onKeyPress=n=>{const a=n.code,l=n.charCode||n.keyCode;a!=="Space"&&a!=="Enter"&&l!==32&&l!==13||this.togglePopup()},this._onMapClick=n=>{const a=n.originalEvent.target,l=this._element;this._popup&&(a===l||l.contains(a))&&this.togglePopup()},this._update=n=>{var a;if(!this._map)return;const l=this._map.loaded()&&!this._map.isMoving();((n==null?void 0:n.type)==="terrain"||(n==null?void 0:n.type)==="render"&&!l)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?pl(this._lngLat,this._flatPos,this._map.transform):(a=this._lngLat)===null||a===void 0?void 0:a.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let u="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?u=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(u=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let m="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?m="rotateX(0deg)":this._pitchAlignment==="map"&&(m=`rotateX(${this._map.getPitch()}deg)`),n&&n.type!=="moveend"||(this._pos=this._pos.round()),se.setTransform(this._element,`${oo[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${m} ${u}`),me.frameAsync(new AbortController).then(()=>{this._updateOpacity(n&&n.type==="moveend")}).catch(()=>{})},this._onMove=n=>{if(!this._isDragging){const a=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=a}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new p.k("dragstart"))),this.fire(new p.k("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new p.k("dragend")),this._state="inactive"},this._addDragHandler=n=>{this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(this._pos).add(this._offset),this._pointerdownPos=n.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=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,this.setOpacity(),this.setOpacity(t==null?void 0:t.opacity,t==null?void 0:t.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=p.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=se.create("div");const n=se.createNS("http://www.w3.org/2000/svg","svg"),a=41,l=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${a}px`),n.setAttributeNS(null,"width",`${l}px`),n.setAttributeNS(null,"viewBox",`0 0 ${l} ${a}`);const u=se.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"stroke","none"),u.setAttributeNS(null,"stroke-width","1"),u.setAttributeNS(null,"fill","none"),u.setAttributeNS(null,"fill-rule","evenodd");const m=se.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"fill-rule","nonzero");const g=se.createNS("http://www.w3.org/2000/svg","g");g.setAttributeNS(null,"transform","translate(3.0, 29.0)"),g.setAttributeNS(null,"fill","#000000");const y=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const U of y){const G=se.createNS("http://www.w3.org/2000/svg","ellipse");G.setAttributeNS(null,"opacity","0.04"),G.setAttributeNS(null,"cx","10.5"),G.setAttributeNS(null,"cy","5.80029008"),G.setAttributeNS(null,"rx",U.rx),G.setAttributeNS(null,"ry",U.ry),g.appendChild(G)}const v=se.createNS("http://www.w3.org/2000/svg","g");v.setAttributeNS(null,"fill",this._color);const S=se.createNS("http://www.w3.org/2000/svg","path");S.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),v.appendChild(S);const T=se.createNS("http://www.w3.org/2000/svg","g");T.setAttributeNS(null,"opacity","0.25"),T.setAttributeNS(null,"fill","#000000");const M=se.createNS("http://www.w3.org/2000/svg","path");M.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"),T.appendChild(M);const z=se.createNS("http://www.w3.org/2000/svg","g");z.setAttributeNS(null,"transform","translate(6.0, 7.0)"),z.setAttributeNS(null,"fill","#FFFFFF");const R=se.createNS("http://www.w3.org/2000/svg","g");R.setAttributeNS(null,"transform","translate(8.0, 8.0)");const N=se.createNS("http://www.w3.org/2000/svg","circle");N.setAttributeNS(null,"fill","#000000"),N.setAttributeNS(null,"opacity","0.25"),N.setAttributeNS(null,"cx","5.5"),N.setAttributeNS(null,"cy","5.5"),N.setAttributeNS(null,"r","5.4999962");const B=se.createNS("http://www.w3.org/2000/svg","circle");B.setAttributeNS(null,"fill","#FFFFFF"),B.setAttributeNS(null,"cx","5.5"),B.setAttributeNS(null,"cy","5.5"),B.setAttributeNS(null,"r","5.4999962"),R.appendChild(N),R.appendChild(B),m.appendChild(g),m.appendChild(v),m.appendChild(T),m.appendChild(z),m.appendChild(R),n.appendChild(m),n.setAttributeNS(null,"height",a*this._scale+"px"),n.setAttributeNS(null,"width",l*this._scale+"px"),this._element.appendChild(n),this._offset=p.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",n=>{n.preventDefault()}),this._element.addEventListener("mousedown",n=>{n.preventDefault()}),Er(this._element,this._anchor,"marker"),t&&t.className)for(const n of t.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(t){return this.remove(),this._map=t,this._element.setAttribute("aria-label",t._getUIString("Marker.Title")),t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),se.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=p.N.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const l=Math.abs(13.5)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[l,-1*(38.1-13.5+l)],"bottom-right":[-l,-1*(38.1-13.5+l)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=t,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:t?(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map)),this):this}_updateOpacity(t=!1){var n,a;if(!(!((n=this._map)===null||n===void 0)&&n.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const l=this._map,u=l.terrain.depthAtPoint(this._pos),m=l.terrain.getElevationForLngLatZoom(this._lngLat,l.transform.tileZoom);if(l.transform.lngLatToCameraDepth(this._lngLat,m)-u<.006)return void(this._element.style.opacity=this._opacity);const g=-this._offset.y/l.transform._pixelPerMeter,y=Math.sin(l.getPitch()*Math.PI/180)*g,v=l.terrain.depthAtPoint(new p.P(this._pos.x,this._pos.y-this._offset.y)),S=l.transform.lngLatToCameraDepth(this._lngLat,m+y)-v>.006;!((a=this._popup)===null||a===void 0)&&a.isOpen()&&S&&this._popup.remove(),this._element.style.opacity=S?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(t){return this._offset=p.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&t!=="auto"?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,n){return t===void 0&&n===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),t!==void 0&&(this._opacity=t),n!==void 0&&(this._opacityWhenCovered=n),this._map&&this._updateOpacity(!0),this}}const Hs={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let wn=0,Tn=!1;const fl={maxWidth:100,unit:"metric"};function lo(h,t,n){const a=n&&n.maxWidth||100,l=h._container.clientHeight/2,u=h.unproject([0,l]),m=h.unproject([a,l]),g=u.distanceTo(m);if(n&&n.unit==="imperial"){const y=3.2808*g;y>5280?hs(t,a,y/5280,h._getUIString("ScaleControl.Miles")):hs(t,a,y,h._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?hs(t,a,g/1852,h._getUIString("ScaleControl.NauticalMiles")):g>=1e3?hs(t,a,g/1e3,h._getUIString("ScaleControl.Kilometers")):hs(t,a,g,h._getUIString("ScaleControl.Meters"))}function hs(h,t,n,a){const l=function(u){const m=Math.pow(10,`${Math.floor(u)}`.length-1);let g=u/m;return g=g>=10?10:g>=5?5:g>=3?3:g>=2?2:g>=1?1:function(y){const v=Math.pow(10,Math.ceil(-Math.log(y)/Math.LN10));return Math.round(y*v)/v}(g),m*g}(n);h.style.width=t*(l/n)+"px",h.innerHTML=`${l} ${a}`}const ir={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},Ks=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function ze(h){if(h){if(typeof h=="number"){const t=Math.round(Math.abs(h)/Math.SQRT2);return{center:new p.P(0,0),top:new p.P(0,h),"top-left":new p.P(t,t),"top-right":new p.P(-t,t),bottom:new p.P(0,-h),"bottom-left":new p.P(t,-t),"bottom-right":new p.P(-t,-t),left:new p.P(h,0),right:new p.P(-h,0)}}if(h instanceof p.P||Array.isArray(h)){const t=p.P.convert(h);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:p.P.convert(h.center||[0,0]),top:p.P.convert(h.top||[0,0]),"top-left":p.P.convert(h["top-left"]||[0,0]),"top-right":p.P.convert(h["top-right"]||[0,0]),bottom:p.P.convert(h.bottom||[0,0]),"bottom-left":p.P.convert(h["bottom-left"]||[0,0]),"bottom-right":p.P.convert(h["bottom-right"]||[0,0]),left:p.P.convert(h.left||[0,0]),right:p.P.convert(h.right||[0,0])}}return ze(new p.P(0,0))}const Be=Ti;L.AJAXError=p.bg,L.Evented=p.E,L.LngLat=p.N,L.MercatorCoordinate=p.Z,L.Point=p.P,L.addProtocol=p.bh,L.config=p.a,L.removeProtocol=p.bi,L.AttributionControl=bn,L.BoxZoomHandler=Ua,L.CanvasSource=Ii,L.CooperativeGesturesHandler=Li,L.DoubleClickZoomHandler=eo,L.DragPanHandler=Ai,L.DragRotateHandler=Di,L.EdgeInsets=Us,L.FullscreenControl=class extends p.E{constructor(h={}){super(),this._onFullscreenChange=()=>{var t;let n=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((t=n==null?void 0:n.shadowRoot)===null||t===void 0)&&t.fullscreenElement;)n=n.shadowRoot.fullscreenElement;n===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,h&&h.container&&(h.container instanceof HTMLElement?this._container=h.container:p.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(h){return this._map=h,this._container||(this._container=this._map.getContainer()),this._controlContainer=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){se.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const h=this._fullscreenButton=se.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);se.create("span","maplibregl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const h=this._getTitle();this._fullscreenButton.setAttribute("aria-label",h),this._fullscreenButton.title=h}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new p.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new p.k("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},L.GeoJSONSource=Vn,L.GeolocateControl=class extends p.E{constructor(h){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new p.k("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(t),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new p.k("geolocate",t)),this._finish()}},this._updateCamera=t=>{const n=new p.N(t.coords.longitude,t.coords.latitude),a=t.coords.accuracy,l=this._map.getBearing(),u=p.e({bearing:l},this.options.fitBoundsOptions),m=re.fromLngLat(n,a);this._map.fitBounds(m,u,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const n=new p.N(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=t=>{if(this._map){if(this.options.trackUserLocation)if(t.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(t.code===3&&Tn)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new p.k("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=t=>{if(this._map){if(this._container.addEventListener("contextmenu",n=>n.preventDefault()),this._geolocateButton=se.create("button","maplibregl-ctrl-geolocate",this._container),se.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",t===!1){p.w("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=se.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new ct({element:this._dotElement}),this._circleElement=se.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new ct({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",n=>{n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||n.originalEvent&&n.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new p.k("trackuserlocationend")),this.fire(new p.k("userlocationlostfocus")))})}},this.options=p.e({},Hs,h)}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),function(){return p._(this,arguments,void 0,function*(t=!1){if(zr!==void 0&&!t)return zr;if(window.navigator.permissions===void 0)return zr=!!window.navigator.geolocation,zr;try{zr=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{zr=!!window.navigator.geolocation}return zr})}().then(t=>this._setupUI(t)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),se.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,wn=0,Tn=!1}_isOutOfMapMaxBounds(h){const t=this._map.getMaxBounds(),n=h.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}`)}}_updateCircleRadius(){const h=this._map.getBounds(),t=h.getSouthEast(),n=h.getNorthEast(),a=t.distanceTo(n),l=Math.ceil(this._accuracy/(a/this._map._container.clientHeight)*2);this._circleElement.style.width=`${l}px`,this._circleElement.style.height=`${l}px`}trigger(){if(!this._setup)return p.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new p.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":wn--,Tn=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new p.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new p.k("trackuserlocationstart")),this.fire(new p.k("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let h;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),wn++,wn>1?(h={maximumAge:6e5,timeout:0},Tn=!0):(h=this.options.positionOptions,Tn=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,h)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},L.Hash=is,L.ImageSource=cr,L.KeyboardHandler=Ja,L.LngLatBounds=re,L.LogoControl=er,L.Map=class extends nc{constructor(h){p.be.mark(p.bf.create);const t=Object.assign(Object.assign({},sc),h);if(t.minZoom!=null&&t.maxZoom!=null&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(t.minPitch!=null&&t.maxPitch!=null&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(t.minPitch!=null&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(t.maxPitch!=null&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Fa(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),{bearingSnap:t.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Pe,this._controls=[],this._mapId=p.a4(),this._contextLost=n=>{n.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new p.k("webglcontextlost",{originalEvent:n}))},this._contextRestored=n=>{this._setupPainter(),this.resize(),this._update(),this.fire(new p.k("webglcontextrestored",{originalEvent:n}))},this._onMapScroll=n=>{if(n.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=t.interactive,this._maxTileCacheSize=t.maxTileCacheSize,this._maxTileCacheZoomLevels=t.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=t.preserveDrawingBuffer===!0,this._antialias=t.antialias===!0,this._trackResize=t.trackResize===!0,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles===!0,this._fadeDuration=t.fadeDuration,this._crossSourceCollisions=t.crossSourceCollisions===!0,this._collectResourceTiming=t.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},we),t.locale),this._clickTolerance=t.clickTolerance,this._overridePixelRatio=t.pixelRatio,this._maxCanvasSize=t.maxCanvasSize,this.transformCameraUpdate=t.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=t.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=pi.addThrottleControl(()=>this.isMoving()),this._requestManager=new ma(t.transformRequest),typeof t.container=="string"){if(this._container=document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(t.maxBounds&&this.setMaxBounds(t.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)).on("moveend",()=>this._update(!1)).on("zoom",()=>this._update(!0)).on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}).once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let n=!1;const a=$s(l=>{this._trackResize&&!this._removed&&this.resize(l)._update()},50);this._resizeObserver=new ResizeObserver(l=>{n?a(l):n=!0}),this._resizeObserver.observe(this._container)}this.handlers=new rc(this,t),this._hash=t.hash&&new is(typeof t.hash=="string"&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,p.e({},t.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new bn(typeof t.attributionControl=="boolean"?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new er,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",n=>{this._update(n.dataType==="style"),this.fire(new p.k(`${n.dataType}data`,n))}),this.on("dataloading",n=>{this.fire(new p.k(`${n.dataType}dataloading`,n))}),this.on("dataabort",n=>{this.fire(new p.k("sourcedataabort",n))})}_getMapId(){return this._mapId}addControl(h,t){if(t===void 0&&(t=h.getDefaultPosition?h.getDefaultPosition():"top-right"),!h||!h.onAdd)return this.fire(new p.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=h.onAdd(this);this._controls.push(h);const a=this._controlPositions[t];return t.indexOf("bottom")!==-1?a.insertBefore(n,a.firstChild):a.appendChild(n),this}removeControl(h){if(!h||!h.onRemove)return this.fire(new p.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(h);return t>-1&&this._controls.splice(t,1),h.onRemove(this),this}hasControl(h){return this._controls.indexOf(h)>-1}calculateCameraOptionsFromTo(h,t,n,a){return a==null&&this.terrain&&(a=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(h,t,n,a)}resize(h){var t;const n=this._containerDimensions(),a=n[0],l=n[1],u=this._getClampedPixelRatio(a,l);if(this._resizeCanvas(a,l,u),this.painter.resize(a,l,u),this.painter.overLimit()){const g=this.painter.context.gl;this._maxCanvasSize=[g.drawingBufferWidth,g.drawingBufferHeight];const y=this._getClampedPixelRatio(a,l);this._resizeCanvas(a,l,y),this.painter.resize(a,l,y)}this.transform.resize(a,l),(t=this._requestedCameraState)===null||t===void 0||t.resize(a,l);const m=!this._moving;return m&&(this.stop(),this.fire(new p.k("movestart",h)).fire(new p.k("move",h))),this.fire(new p.k("resize",h)),m&&this.fire(new p.k("moveend",h)),this}_getClampedPixelRatio(h,t){const{0:n,1:a}=this._maxCanvasSize,l=this.getPixelRatio(),u=h*l,m=t*l;return Math.min(u>n?n/u:1,m>a?a/m:1)*l}getPixelRatio(){var h;return(h=this._overridePixelRatio)!==null&&h!==void 0?h:devicePixelRatio}setPixelRatio(h){this._overridePixelRatio=h,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(h){return this.transform.setMaxBounds(re.convert(h)),this._update()}setMinZoom(h){if((h=h??-2)>=-2&&h<=this.transform.maxZoom)return this.transform.minZoom=h,this._update(),this.getZoom()<h&&this.setZoom(h),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(h){if((h=h??22)>=this.transform.minZoom)return this.transform.maxZoom=h,this._update(),this.getZoom()>h&&this.setZoom(h),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(h){if((h=h??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(h>=0&&h<=this.transform.maxPitch)return this.transform.minPitch=h,this._update(),this.getPitch()<h&&this.setPitch(h),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(h){if((h=h??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(h>=this.transform.minPitch)return this.transform.maxPitch=h,this._update(),this.getPitch()>h&&this.setPitch(h),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(h){return this.transform.renderWorldCopies=h,this._update()}project(h){return this.transform.locationPoint(p.N.convert(h),this.style&&this.terrain)}unproject(h){return this.transform.pointLocation(p.P.convert(h),this.terrain)}isMoving(){var h;return this._moving||((h=this.handlers)===null||h===void 0?void 0:h.isMoving())}isZooming(){var h;return this._zooming||((h=this.handlers)===null||h===void 0?void 0:h.isZooming())}isRotating(){var h;return this._rotating||((h=this.handlers)===null||h===void 0?void 0:h.isRotating())}_createDelegatedListener(h,t,n){if(h==="mouseenter"||h==="mouseover"){let a=!1;return{layer:t,listener:n,delegates:{mousemove:u=>{const m=this.getLayer(t)?this.queryRenderedFeatures(u.point,{layers:[t]}):[];m.length?a||(a=!0,n.call(this,new ei(h,this,u.originalEvent,{features:m}))):a=!1},mouseout:()=>{a=!1}}}}if(h==="mouseleave"||h==="mouseout"){let a=!1;return{layer:t,listener:n,delegates:{mousemove:m=>{(this.getLayer(t)?this.queryRenderedFeatures(m.point,{layers:[t]}):[]).length?a=!0:a&&(a=!1,n.call(this,new ei(h,this,m.originalEvent)))},mouseout:m=>{a&&(a=!1,n.call(this,new ei(h,this,m.originalEvent)))}}}}{const a=l=>{const u=this.getLayer(t)?this.queryRenderedFeatures(l.point,{layers:[t]}):[];u.length&&(l.features=u,n.call(this,l),delete l.features)};return{layer:t,listener:n,delegates:{[h]:a}}}}on(h,t,n){if(n===void 0)return super.on(h,t);const a=this._createDelegatedListener(h,t,n);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[h]=this._delegatedListeners[h]||[],this._delegatedListeners[h].push(a);for(const l in a.delegates)this.on(l,a.delegates[l]);return this}once(h,t,n){if(n===void 0)return super.once(h,t);const a=this._createDelegatedListener(h,t,n);for(const l in a.delegates)this.once(l,a.delegates[l]);return this}off(h,t,n){return n===void 0?super.off(h,t):(this._delegatedListeners&&this._delegatedListeners[h]&&(a=>{const l=this._delegatedListeners[h];for(let u=0;u<l.length;u++){const m=l[u];if(m.layer===t&&m.listener===n){for(const g in m.delegates)this.off(g,m.delegates[g]);return l.splice(u,1),this}}})(),this)}queryRenderedFeatures(h,t){if(!this.style)return[];let n;const a=h instanceof p.P||Array.isArray(h),l=a?h:[[0,0],[this.transform.width,this.transform.height]];if(t=t||(a?{}:h)||{},l instanceof p.P||typeof l[0]=="number")n=[p.P.convert(l)];else{const u=p.P.convert(l[0]),m=p.P.convert(l[1]);n=[u,new p.P(m.x,u.y),m,new p.P(u.x,m.y),u]}return this.style.queryRenderedFeatures(n,t,this.transform)}querySourceFeatures(h,t){return this.style.querySourceFeatures(h,t)}setStyle(h,t){return(t=p.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},t)).diff!==!1&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&h?(this._diffStyle(h,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(h,t))}setTransformRequest(h){return this._requestManager.setTransformRequest(h),this}_getUIString(h){const t=this._locale[h];if(t==null)throw new Error(`Missing UI string '${h}'`);return t}_updateStyle(h,t){if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(h,t));const n=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!h)),h?(this.style=new ya(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof h=="string"?this.style.loadURL(h,t,n):this.style.loadJSON(h,t,n),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new ya(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(h,t){if(typeof h=="string"){const n=this._requestManager.transformRequest(h,"Style");p.h(n,new AbortController).then(a=>{this._updateDiff(a.data,t)}).catch(a=>{a&&this.fire(new p.j(a))})}else typeof h=="object"&&this._updateDiff(h,t)}_updateDiff(h,t){try{this.style.setState(h,t)&&this._update(!0)}catch(n){p.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(h,t)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():p.w("There is no style added to the map.")}addSource(h,t){return this._lazyInitEmptyStyle(),this.style.addSource(h,t),this._update(!0)}isSourceLoaded(h){const t=this.style&&this.style.sourceCaches[h];if(t!==void 0)return t.loaded();this.fire(new p.j(new Error(`There is no source with ID '${h}'`)))}setTerrain(h){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),h){const t=this.style.sourceCaches[h.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${h.source}`);this.terrain===null&&t.reload();for(const n in this.style._layers){const a=this.style._layers[n];a.type==="hillshade"&&a.source===h.source&&p.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new cl(this.painter,t,h),this.painter.renderToTexture=new hl(this.painter,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=n=>{n.dataType==="style"?this.terrain.sourceCache.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==h.source||this._elevationFreeze||(this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(n.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new p.k("terrain",{terrain:h})),this}getTerrain(){var h,t;return(t=(h=this.terrain)===null||h===void 0?void 0:h.options)!==null&&t!==void 0?t:null}areTilesLoaded(){const h=this.style&&this.style.sourceCaches;for(const t in h){const n=h[t]._tiles;for(const a in n){const l=n[a];if(l.state!=="loaded"&&l.state!=="errored")return!1}}return!0}removeSource(h){return this.style.removeSource(h),this._update(!0)}getSource(h){return this.style.getSource(h)}addImage(h,t,n={}){const{pixelRatio:a=1,sdf:l=!1,stretchX:u,stretchY:m,content:g,textFitWidth:y,textFitHeight:v}=n;if(this._lazyInitEmptyStyle(),!(t instanceof HTMLImageElement||p.b(t))){if(t.width===void 0||t.height===void 0)return this.fire(new p.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:S,height:T,data:M}=t,z=t;return this.style.addImage(h,{data:new p.R({width:S,height:T},new Uint8Array(M)),pixelRatio:a,stretchX:u,stretchY:m,content:g,textFitWidth:y,textFitHeight:v,sdf:l,version:0,userImage:z}),z.onAdd&&z.onAdd(this,h),this}}{const{width:S,height:T,data:M}=me.getImageData(t);this.style.addImage(h,{data:new p.R({width:S,height:T},M),pixelRatio:a,stretchX:u,stretchY:m,content:g,textFitWidth:y,textFitHeight:v,sdf:l,version:0})}}updateImage(h,t){const n=this.style.getImage(h);if(!n)return this.fire(new p.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const a=t instanceof HTMLImageElement||p.b(t)?me.getImageData(t):t,{width:l,height:u,data:m}=a;if(l===void 0||u===void 0)return this.fire(new p.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(l!==n.data.width||u!==n.data.height)return this.fire(new p.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const g=!(t instanceof HTMLImageElement||p.b(t));return n.data.replace(m,g),this.style.updateImage(h,n),this}getImage(h){return this.style.getImage(h)}hasImage(h){return h?!!this.style.getImage(h):(this.fire(new p.j(new Error("Missing required image id"))),!1)}removeImage(h){this.style.removeImage(h)}loadImage(h){return pi.getImage(this._requestManager.transformRequest(h,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(h,t){return this._lazyInitEmptyStyle(),this.style.addLayer(h,t),this._update(!0)}moveLayer(h,t){return this.style.moveLayer(h,t),this._update(!0)}removeLayer(h){return this.style.removeLayer(h),this._update(!0)}getLayer(h){return this.style.getLayer(h)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(h,t,n){return this.style.setLayerZoomRange(h,t,n),this._update(!0)}setFilter(h,t,n={}){return this.style.setFilter(h,t,n),this._update(!0)}getFilter(h){return this.style.getFilter(h)}setPaintProperty(h,t,n,a={}){return this.style.setPaintProperty(h,t,n,a),this._update(!0)}getPaintProperty(h,t){return this.style.getPaintProperty(h,t)}setLayoutProperty(h,t,n,a={}){return this.style.setLayoutProperty(h,t,n,a),this._update(!0)}getLayoutProperty(h,t){return this.style.getLayoutProperty(h,t)}setGlyphs(h,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(h,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(h,t,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(h,t,n,a=>{a||this._update(!0)}),this}removeSprite(h){return this._lazyInitEmptyStyle(),this.style.removeSprite(h),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(h,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(h,t,n=>{n||this._update(!0)}),this}setLight(h,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(h,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(h){return this._lazyInitEmptyStyle(),this.style.setSky(h),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(h,t){return this.style.setFeatureState(h,t),this._update()}removeFeatureState(h,t){return this.style.removeFeatureState(h,t),this._update()}getFeatureState(h){return this.style.getFeatureState(h)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let h=0,t=0;return this._container&&(h=this._container.clientWidth||400,t=this._container.clientHeight||300),[h,t]}_setupContainer(){const h=this._container;h.classList.add("maplibregl-map");const t=this._canvasContainer=se.create("div","maplibregl-canvas-container",h);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=se.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const n=this._containerDimensions(),a=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],a);const l=this._controlContainer=se.create("div","maplibregl-control-container",h),u=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(m=>{u[m]=se.create("div",`maplibregl-ctrl-${m} `,l)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(h,t,n){this._canvas.width=Math.floor(n*h),this._canvas.height=Math.floor(n*t),this._canvas.style.width=`${h}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const h={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let t=null;this._canvas.addEventListener("webglcontextcreationerror",a=>{t={requestedAttributes:h},a&&(t.statusMessage=a.statusMessage,t.type=a.type)},{once:!0});const n=this._canvas.getContext("webgl2",h)||this._canvas.getContext("webgl",h);if(!n){const a="Failed to initialize WebGL";throw t?(t.message=a,new Error(JSON.stringify(t))):new Error(a)}this.painter=new il(n,this.transform),Nr.testSupport(n)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(h){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||h,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(h){return this._update(),this._renderTaskQueue.add(h)}_cancelRenderFrame(h){this._renderTaskQueue.remove(h)}_render(h){const t=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(h),this._removed)return;let n=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const l=this.transform.zoom,u=me.now();this.style.zoomHistory.update(l,u);const m=new p.a9(l,{now:u,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),g=m.crossFadingFactor();g===1&&g===this._crossFadingFactor||(n=!0,this._crossFadingFactor=g),this.style.update(m)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,t,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:t,showPadding:this.showPadding}),this.fire(new p.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,p.be.mark(p.bf.load),this.fire(new p.k("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const a=this._sourcesDirty||this._styleDirty||this._placementDirty;return a||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new p.k("idle")),!this._loaded||this._fullyLoaded||a||(this._fullyLoaded=!0,p.be.mark(p.bf.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var h;this._hash&&this._hash.remove();for(const n of this._controls)n.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),pi.removeThrottleControl(this._imageQueueHandle),(h=this._resizeObserver)===null||h===void 0||h.disconnect();const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t!=null&&t.loseContext&&t.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),se.remove(this._canvasContainer),se.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),p.be.clearMetrics(),this._removed=!0,this.fire(new p.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,me.frameAsync(this._frameRequest).then(h=>{p.be.frame(h),this._frameRequest=null,this._render(h)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(h){this._showTileBoundaries!==h&&(this._showTileBoundaries=h,this._update())}get showPadding(){return!!this._showPadding}set showPadding(h){this._showPadding!==h&&(this._showPadding=h,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(h){this._showCollisionBoxes!==h&&(this._showCollisionBoxes=h,h?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(h){this._showOverdrawInspector!==h&&(this._showOverdrawInspector=h,this._update())}get repaint(){return!!this._repaint}set repaint(h){this._repaint!==h&&(this._repaint=h,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(h){this._vertices=h,this._update()}get version(){return so}getCameraTargetElevation(){return this.transform.elevation}},L.MapMouseEvent=ei,L.MapTouchEvent=rs,L.MapWheelEvent=Na,L.Marker=ct,L.NavigationControl=class{constructor(h){this._updateZoomButtons=()=>{const t=this._map.getZoom(),n=t===this._map.getMaxZoom(),a=t===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=a,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",a.toString())},this._rotateCompassArrow=()=>{const t=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=t},this._setButtonTitle=(t,n)=>{const a=this._map._getUIString(`NavigationControl.${n}`);t.title=a,t.setAttribute("aria-label",a)},this.options=p.e({},ao,h),this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",t=>this._map.zoomIn({},{originalEvent:t})),se.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})),se.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})}),this._compassIcon=se.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(h){return this._map=h,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new dl(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){se.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(h,t){const n=se.create("button",h,this._container);return n.type="button",n.addEventListener("click",t),n}},L.Popup=class extends p.E{constructor(h){super(),this.remove=()=>(this._content&&se.remove(this._content),this._container&&(se.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new p.k("close"))),this),this._onMouseUp=t=>{this._update(t.point)},this._onMouseMove=t=>{this._update(t.point)},this._onDrag=t=>{this._update(t.point)},this._update=t=>{var n;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=se.create("div","maplibregl-popup",this._map.getContainer()),this._tip=se.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const g of this.options.className.split(" "))this._container.classList.add(g);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?pl(this._lngLat,this._flatPos,this._map.transform):(n=this._lngLat)===null||n===void 0?void 0:n.wrap(),this._trackPointer&&!t)return;const a=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationPoint(this._lngLat));let l=this.options.anchor;const u=ze(this.options.offset);if(!l){const g=this._container.offsetWidth,y=this._container.offsetHeight;let v;v=a.y+u.bottom.y<y?["top"]:a.y>this._map.transform.height-y?["bottom"]:[],a.x<g/2?v.push("left"):a.x>this._map.transform.width-g/2&&v.push("right"),l=v.length===0?"bottom":v.join("-")}let m=a.add(u[l]);this.options.subpixelPositioning||(m=m.round()),se.setTransform(this._container,`${oo[l]} translate(${m.x}px,${m.y}px)`),Er(this._container,l,"popup")},this._onClose=()=>{this.remove()},this.options=p.e(Object.create(ir),h)}addTo(h){return this._map&&this.remove(),this._map=h,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new p.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=p.N.convert(h),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(h){return this.setDOMContent(document.createTextNode(h))}setHTML(h){const t=document.createDocumentFragment(),n=document.createElement("body");let a;for(n.innerHTML=h;a=n.firstChild,a;)t.appendChild(a);return this.setDOMContent(t)}getMaxWidth(){var h;return(h=this._container)===null||h===void 0?void 0:h.style.maxWidth}setMaxWidth(h){return this.options.maxWidth=h,this._update(),this}setDOMContent(h){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=se.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(h),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(h){return this._container&&this._container.classList.add(h),this}removeClassName(h){return this._container&&this._container.classList.remove(h),this}setOffset(h){return this.options.offset=h,this._update(),this}toggleClassName(h){if(this._container)return this._container.classList.toggle(h)}setSubpixelPositioning(h){this.options.subpixelPositioning=h}_createCloseButton(){this.options.closeButton&&(this._closeButton=se.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const h=this._container.querySelector(Ks);h&&h.focus()}},L.RasterDEMTileSource=vt,L.RasterTileSource=Qe,L.ScaleControl=class{constructor(h){this._onMove=()=>{lo(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,lo(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},fl),h)}getDefaultPosition(){return"bottom-left"}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-scale",h.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){se.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},L.ScrollZoomHandler=Qa,L.Style=ya,L.TerrainControl=class{constructor(h){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=h}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=se.create("button","maplibregl-ctrl-terrain",this._container),se.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){se.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},L.TwoFingersTouchPitchHandler=Ka,L.TwoFingersTouchRotateHandler=Ha,L.TwoFingersTouchZoomHandler=Xa,L.TwoFingersTouchZoomRotateHandler=to,L.VectorTileSource=On,L.VideoSource=dn,L.addSourceType=(h,t)=>p._(void 0,void 0,void 0,function*(){if(jn(h))throw new Error(`A source type called "${h}" already exists.`);((n,a)=>{Nn[n]=a})(h,t)}),L.clearPrewarmedResources=function(){const h=fi;h&&(h.isPreloaded()&&h.numActive()===1?(h.release(br),fi=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},L.getMaxParallelImageRequests=function(){return p.a.MAX_PARALLEL_IMAGE_REQUESTS},L.getRTLTextPluginStatus=function(){return Ki().getRTLTextPluginStatus()},L.getVersion=function(){return Be},L.getWorkerCount=function(){return Wi.workerCount},L.getWorkerUrl=function(){return p.a.WORKER_URL},L.importScriptInWorkers=function(h){return Fn().broadcast("IS",h)},L.prewarm=function(){Ur().acquire(br)},L.setMaxParallelImageRequests=function(h){p.a.MAX_PARALLEL_IMAGE_REQUESTS=h},L.setRTLTextPlugin=function(h,t){return Ki().setRTLTextPlugin(h,t)},L.setWorkerCount=function(h){Wi.workerCount=h},L.setWorkerUrl=function(h){p.a.WORKER_URL=h}});var Jc=Vr;return Jc})})(Bu);var Fp=Bu.exports;const Kc=Ep(Fp),Op={name:"MapViewer",props:{coordinates:{type:Array,required:!0},height:{type:Number,required:!1,default:400}},data(){return{markers:[]}},async mounted(){const Eo="WdiFMRFf0t6kzDBO7zMX";let fa=new Kc.Map({container:"map",attributionControl:!1,style:`https://api.maptiler.com/maps/ca9f6ac1-7816-4fb7-926f-b171b5afd27a/style.json?key=${Eo}`,center:[16.38629,46.014566],zoom:2}).addControl(new Kc.AttributionControl({compact:!1}));for(let Vr of this.coordinates){let yr=new Kc.Marker({color:"#C60C30",draggable:!1}).setLngLat(Vr).addTo(fa);this.markers.push(yr)}setTimeout(()=>{this.coordinates.length>1?fa.fitBounds(this.coordinates,{padding:{top:40,bottom:40,left:40,right:40}}):fa.flyTo({center:this.coordinates[0],zoom:8,curve:1})},1e3)}};function Vp(Eo,fa,Vr,yr,Do,Jc){return Lp(),Rp("div",{id:"map",style:Bp(`min-height: ${Vr.height}px`)},null,4)}const Up=Dp(Op,[["render",Vp]]);export{Up as M};