wafields 0.33.2 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ap=require("./index-aVViDT9z.js");function Dp(wn,Ll){for(var Lr=0;Lr<Ll.length;Lr++){const Ci=Ll[Lr];if(typeof Ci!="string"&&!Array.isArray(Ci)){for(const Or in Ci)if(Or!=="default"&&!(Or in wn)){const Tn=Object.getOwnPropertyDescriptor(Ci,Or);Tn&&Object.defineProperty(wn,Or,Tn.get?Tn:{enumerable:!0,get:()=>Ci[Or]})}}}return Object.freeze(Object.defineProperty(wn,Symbol.toStringTag,{value:"Module"}))}var Fl={exports:{}};/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ap=require("./index-f3JehyrW.js");function Dp(wn,Ll){for(var Lr=0;Lr<Ll.length;Lr++){const Ci=Ll[Lr];if(typeof Ci!="string"&&!Array.isArray(Ci)){for(const Or in Ci)if(Or!=="default"&&!(Or in wn)){const Tn=Object.getOwnPropertyDescriptor(Ci,Or);Tn&&Object.defineProperty(wn,Or,Tn.get?Tn:{enumerable:!0,get:()=>Ci[Or]})}}}return Object.freeze(Object.defineProperty(wn,Symbol.toStringTag,{value:"Module"}))}var Fl={exports:{}};/**
2
2
  * MapLibre GL JS
3
3
  * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v4.7.1/LICENSE.txt
4
4
  */var Rp=Fl.exports,Fh;function Bp(){return Fh||(Fh=1,(function(wn,Ll){(function(Lr,Ci){wn.exports=Ci()})(Rp,(function(){"use strict";var Lr={},Ci={};function Or(R,p,Pi){if(Ci[R]=Pi,R==="index"){var Hi="var sharedModule = {}; ("+Ci.shared+")(sharedModule); ("+Ci.worker+")(sharedModule);",Ge={};return Ci.shared(Ge),Ci.index(Lr,Ge),typeof window<"u"&&Lr.setWorkerUrl(window.URL.createObjectURL(new Blob([Hi],{type:"text/javascript"}))),Lr}}Or("shared",["exports"],(function(R){"use strict";function p(i,e,r,a){return new(r||(r=Promise))((function(l,h){function d(x){try{_(a.next(x))}catch(v){h(v)}}function f(x){try{_(a.throw(x))}catch(v){h(v)}}function _(x){var v;x.done?l(x.value):(v=x.value,v instanceof r?v:new r((function(w){w(v)}))).then(d,f)}_((a=a.apply(i,e||[])).next())}))}function Pi(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}typeof SuppressedError=="function"&&SuppressedError;var Hi=Ge;function Ge(i,e){this.x=i,this.y=e}Ge.prototype={clone:function(){return new Ge(this.x,this.y)},add:function(i){return this.clone()._add(i)},sub:function(i){return this.clone()._sub(i)},multByPoint:function(i){return this.clone()._multByPoint(i)},divByPoint:function(i){return this.clone()._divByPoint(i)},mult:function(i){return this.clone()._mult(i)},div:function(i){return this.clone()._div(i)},rotate:function(i){return this.clone()._rotate(i)},rotateAround:function(i,e){return this.clone()._rotateAround(i,e)},matMult:function(i){return this.clone()._matMult(i)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(i){return this.x===i.x&&this.y===i.y},dist:function(i){return Math.sqrt(this.distSqr(i))},distSqr:function(i){var e=i.x-this.x,r=i.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith:function(i){return this.angleWithSep(i.x,i.y)},angleWithSep:function(i,e){return Math.atan2(this.x*e-this.y*i,this.x*i+this.y*e)},_matMult:function(i){var e=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=e,this},_add:function(i){return this.x+=i.x,this.y+=i.y,this},_sub:function(i){return this.x-=i.x,this.y-=i.y,this},_mult:function(i){return this.x*=i,this.y*=i,this},_div:function(i){return this.x/=i,this.y/=i,this},_multByPoint:function(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint:function(i){return this.x/=i.x,this.y/=i.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var i=this.y;return this.y=this.x,this.x=-i,this},_rotate:function(i){var e=Math.cos(i),r=Math.sin(i),a=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=a,this},_rotateAround:function(i,e){var r=Math.cos(i),a=Math.sin(i),l=e.y+a*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-a*(this.y-e.y),this.y=l,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Ge.convert=function(i){return i instanceof Ge?i:Array.isArray(i)?new Ge(i[0],i[1]):i};var mt=Pi(Hi),at=Vr;function Vr(i,e,r,a){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(a-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=e,this.p2x=r,this.p2y=a}Vr.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,e){if(e===void 0&&(e=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,a=0;a<8;a++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)<e)return r;var h=this.sampleCurveDerivativeX(r);if(Math.abs(h)<1e-6)break;r-=l/h}var d=0,f=1;for(r=i,a=0;a<20&&(l=this.sampleCurveX(r),!(Math.abs(l-i)<e));a++)i>l?d=r:f=r,r=.5*(f-d)+d;return r},solve:function(i,e){return this.sampleCurveY(this.solveCurveX(i,e))}};var br=Pi(at);let Wi,wr;function ur(){return Wi==null&&(Wi=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Wi}function Gs(){if(wr==null&&(wr=!1,ur())){const i=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(i){for(let r=0;r<25;r++){const a=4*r;i.fillStyle=`rgb(${a},${a+1},${a+2})`,i.fillRect(r%5,Math.floor(r/5),1,1)}const e=i.getImageData(0,0,5,5).data;for(let r=0;r<100;r++)if(r%4!=3&&e[r]!==r){wr=!0;break}}}return wr||!1}function ui(i,e,r,a){const l=new br(i,e,r,a);return h=>l.solve(h)}const Sn=ui(.25,.1,.25,1);function Ai(i,e,r){return Math.min(r,Math.max(e,i))}function Ki(i,e,r){const a=r-e,l=((i-e)%a+a)%a+e;return l===e?r:l}function vi(i,...e){for(const r of e)for(const a in r)i[a]=r[a];return i}let Ia=1;function Ji(i,e,r){const a={};for(const l in i)a[l]=e.call(this,i[l],l,i);return a}function Xs(i,e,r){const a={};for(const l in i)e.call(this,i[l],l,i)&&(a[l]=i[l]);return a}function ae(i){return Array.isArray(i)?i.map(ae):typeof i=="object"&&i?Ji(i,ae):i}const ka={};function Le(i){ka[i]||(typeof console<"u"&&console.warn(i),ka[i]=!0)}function Xe(i,e,r){return(r.y-i.y)*(e.x-i.x)>(e.y-i.y)*(r.x-i.x)}function hr(i){return typeof WorkerGlobalScope<"u"&&i!==void 0&&i instanceof WorkerGlobalScope}let os=null;function Yi(i){return typeof ImageBitmap<"u"&&i instanceof ImageBitmap}const Ma="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function jr(i,e,r,a,l){return p(this,void 0,void 0,(function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");const h=new VideoFrame(i,{timestamp:0});try{const d=h==null?void 0:h.format;if(!d||!d.startsWith("BGR")&&!d.startsWith("RGB"))throw new Error(`Unrecognized format ${d}`);const f=d.startsWith("BGR"),_=new Uint8ClampedArray(a*l*4);if(yield h.copyTo(_,(function(x,v,w,I,E){const C=4*Math.max(-v,0),P=(Math.max(0,w)-w)*I*4+C,L=4*I,U=Math.max(0,v),Q=Math.max(0,w);return{rect:{x:U,y:Q,width:Math.min(x.width,v+I)-U,height:Math.min(x.height,w+E)-Q},layout:[{offset:P,stride:L}]}})(i,e,r,a,l)),f)for(let x=0;x<_.length;x+=4){const v=_[x];_[x]=_[x+2],_[x+2]=v}return _}finally{h.close()}}))}let dr,ti;const Di="AbortError";function ls(){return new Error(Di)}const Tr={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function Qi(i){return Tr.REGISTERED_PROTOCOLS[i.substring(0,i.indexOf("://"))]}const cs="global-dispatcher";class hi extends Error{constructor(e,r,a,l){super(`AJAXError: ${r} (${e}): ${a}`),this.status=e,this.statusText=r,this.url=a,this.body=l}}const Ri=()=>hr(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 a=Qi(i.url);if(a)return a(i,e);if(hr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,targetMapId:cs},e)}if(!(/^file:/.test(r=i.url)||/^file:/.test(Ri())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return(function(a,l){return p(this,void 0,void 0,(function*(){const h=new Request(a.url,{method:a.method||"GET",body:a.body,credentials:a.credentials,headers:a.headers,cache:a.cache,referrer:Ri(),signal:l.signal});a.type!=="json"||h.headers.has("Accept")||h.headers.set("Accept","application/json");const d=yield fetch(h);if(!d.ok){const x=yield d.blob();throw new hi(d.status,d.statusText,a.url,x)}let f;f=a.type==="arrayBuffer"||a.type==="image"?d.arrayBuffer():a.type==="json"?d.json():d.text();const _=yield f;if(l.signal.aborted)throw ls();return{data:_,cacheControl:d.headers.get("Cache-Control"),expires:d.headers.get("Expires")}}))})(i,e);if(hr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,mustQueue:!0,targetMapId:cs},e)}var r;return(function(a,l){return new Promise(((h,d)=>{var f;const _=new XMLHttpRequest;_.open(a.method||"GET",a.url,!0),a.type!=="arrayBuffer"&&a.type!=="image"||(_.responseType="arraybuffer");for(const x in a.headers)_.setRequestHeader(x,a.headers[x]);a.type==="json"&&(_.responseType="text",!((f=a.headers)===null||f===void 0)&&f.Accept||_.setRequestHeader("Accept","application/json")),_.withCredentials=a.credentials==="include",_.onerror=()=>{d(new Error(_.statusText))},_.onload=()=>{if(!l.signal.aborted)if((_.status>=200&&_.status<300||_.status===0)&&_.response!==null){let x=_.response;if(a.type==="json")try{x=JSON.parse(_.response)}catch(v){return void d(v)}h({data:x,cacheControl:_.getResponseHeader("Cache-Control"),expires:_.getResponseHeader("Expires")})}else{const x=new Blob([_.response],{type:_.getResponseHeader("Content-Type")});d(new hi(_.status,_.statusText,a.url,x))}},l.signal.addEventListener("abort",(()=>{_.abort(),d(ls())})),_.send(a.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 Hs(i,e,r){r[i]&&r[i].indexOf(e)!==-1||(r[i]=r[i]||[],r[i].push(e))}function pr(i,e,r){if(r&&r[i]){const a=r[i].indexOf(e);a!==-1&&r[i].splice(a,1)}}class Sr{constructor(e,r={}){vi(this,r),this.type=e}}class Ir extends Sr{constructor(e,r={}){super("error",vi({error:e},r))}}class us{on(e,r){return this._listeners=this._listeners||{},Hs(e,r,this._listeners),this}off(e,r){return pr(e,r,this._listeners),pr(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},Hs(e,r,this._oneTimeListeners),this):new Promise((a=>this.once(e,a)))}fire(e,r){typeof e=="string"&&(e=new Sr(e,r||{}));const a=e.type;if(this.listens(a)){e.target=this;const l=this._listeners&&this._listeners[a]?this._listeners[a].slice():[];for(const f of l)f.call(this,e);const h=this._oneTimeListeners&&this._oneTimeListeners[a]?this._oneTimeListeners[a].slice():[];for(const f of h)pr(a,f,this._oneTimeListeners),f.call(this,e);const d=this._eventedParent;d&&(vi(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),d.fire(e))}else e instanceof Ir&&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 it={$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 Nr=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Ws(i,e){const r={};for(const a in i)a!=="ref"&&(r[a]=i[a]);return Nr.forEach((a=>{a in e&&(r[a]=e[a])})),r}function te(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(!te(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(!te(i[r],e[r]))return!1;return!0}return i===e}function ye(i,e){i.push(e)}function Ks(i,e,r){ye(r,{command:"addSource",args:[i,e[i]]})}function kr(i,e,r){ye(e,{command:"removeSource",args:[i]}),r[i]=!0}function fr(i,e,r,a){kr(i,r,a),Ks(i,e,r)}function hs(i,e,r){let a;for(a in i[r])if(Object.prototype.hasOwnProperty.call(i[r],a)&&a!=="data"&&!te(i[r][a],e[r][a]))return!1;for(a in e[r])if(Object.prototype.hasOwnProperty.call(e[r],a)&&a!=="data"&&!te(i[r][a],e[r][a]))return!1;return!0}function bi(i,e,r,a,l,h){i=i||{},e=e||{};for(const d in i)Object.prototype.hasOwnProperty.call(i,d)&&(te(i[d],e[d])||r.push({command:h,args:[a,d,e[d],l]}));for(const d in e)Object.prototype.hasOwnProperty.call(e,d)&&!Object.prototype.hasOwnProperty.call(i,d)&&(te(i[d],e[d])||r.push({command:h,args:[a,d,e[d],l]}))}function Js(i){return i.id}function Ys(i,e){return i[e.id]=e,i}class ht{constructor(e,r,a,l){this.message=(e?`${e}: `:"")+a,l&&(this.identifier=l),r!=null&&r.__line__&&(this.line=r.__line__)}}function tr(i,...e){for(const r of e)for(const a in r)i[a]=r[a];return i}class He extends Error{constructor(e,r){super(r),this.message=r,this.key=e}}class er{constructor(e,r=[]){this.parent=e,this.bindings={};for(const[a,l]of r)this.bindings[a]=l}concat(e){return new er(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 Mr={kind:"null"},_t={kind:"number"},Nt={kind:"string"},Ft={kind:"boolean"},ei={kind:"color"},Bi={kind:"object"},jt={kind:"value"},ir={kind:"collator"},mr={kind:"formatted"},Er={kind:"padding"},rr={kind:"resolvedImage"},j={kind:"variableAnchorOffsetCollection"};function M(i,e){return{kind:"array",itemType:i,N:e}}function k(i){if(i.kind==="array"){const e=k(i.itemType);return typeof i.N=="number"?`array<${e}, ${i.N}>`:i.itemType.kind==="value"?"array":`array<${e}>`}return i.kind}const D=[Mr,_t,Nt,Ft,ei,mr,Bi,M(jt),Er,rr,j];function O(i,e){if(e.kind==="error")return null;if(i.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!O(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 D)if(!O(r,e))return null}}return`Expected ${k(i)} but found ${k(e)} instead.`}function G(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 Z=.96422,st=.82521,lt=4/29,et=6/29,dt=3*et*et,At=et*et*et,Dt=Math.PI/180,Kt=180/Math.PI;function Ut(i){return(i%=360)<0&&(i+=360),i}function Jt([i,e,r,a]){let l,h;const d=ke((.2225045*(i=Gt(i))+.7168786*(e=Gt(e))+.0606169*(r=Gt(r)))/1);i===e&&e===r?l=h=d:(l=ke((.4360747*i+.3850649*e+.1430804*r)/Z),h=ke((.0139322*i+.0971045*e+.7141733*r)/st));const f=116*d-16;return[f<0?0:f,500*(l-d),200*(d-h),a]}function Gt(i){return i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function ke(i){return i>At?Math.pow(i,1/3):i/dt+lt}function xe([i,e,r,a]){let l=(i+16)/116,h=isNaN(e)?l:l+e/500,d=isNaN(r)?l:l-r/200;return l=1*re(l),h=Z*re(h),d=st*re(d),[Zt(3.1338561*h-1.6168667*l-.4906146*d),Zt(-.9787684*h+1.9161415*l+.033454*d),Zt(.0719453*h-.2289914*l+1.4052427*d),a]}function Zt(i){return(i=i<=.00304?12.92*i:1.055*Math.pow(i,1/2.4)-.055)<0?0:i>1?1:i}function re(i){return i>et?i*i*i:dt*(i-lt)}function ge(i){return parseInt(i.padEnd(2,i),16)/255}function Ce(i,e){return Re(e?i/100:i,0,1)}function Re(i,e,r){return Math.min(Math.max(e,i),r)}function We(i){return!i.some(Number.isNaN)}const ds={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 se{constructor(e,r,a,l=1,h=!0){this.r=e,this.g=r,this.b=a,this.a=l,h||(this.r*=l,this.g*=l,this.b*=l,l||this.overwriteGetter("rgb",[e,r,a,l]))}static parse(e){if(e instanceof se)return e;if(typeof e!="string")return;const r=(function(a){if((a=a.toLowerCase().trim())==="transparent")return[0,0,0,0];const l=ds[a];if(l){const[d,f,_]=l;return[d/255,f/255,_/255,1]}if(a.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(a)){const d=a.length<6?1:2;let f=1;return[ge(a.slice(f,f+=d)),ge(a.slice(f,f+=d)),ge(a.slice(f,f+=d)),ge(a.slice(f,f+d)||"ff")]}if(a.startsWith("rgb")){const d=a.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(d){const[f,_,x,v,w,I,E,C,P,L,U,Q]=d,X=[v||" ",E||" ",L].join("");if(X===" "||X===" /"||X===",,"||X===",,,"){const J=[x,I,P].join(""),rt=J==="%%%"?100:J===""?255:0;if(rt){const ct=[Re(+_/rt,0,1),Re(+w/rt,0,1),Re(+C/rt,0,1),U?Ce(+U,Q):1];if(We(ct))return ct}}return}}const h=a.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(h){const[d,f,_,x,v,w,I,E,C]=h,P=[_||" ",v||" ",I].join("");if(P===" "||P===" /"||P===",,"||P===",,,"){const L=[+f,Re(+x,0,100),Re(+w,0,100),E?Ce(+E,C):1];if(We(L))return(function([U,Q,X,J]){function rt(ct){const wt=(ct+U/30)%12,Rt=Q*Math.min(X,1-X);return X-Rt*Math.max(-1,Math.min(wt-3,9-wt,1))}return U=Ut(U),Q/=100,X/=100,[rt(0),rt(8),rt(4),J]})(L)}}})(e);return r?new se(...r,!1):void 0}get rgb(){const{r:e,g:r,b:a,a:l}=this,h=l||1/0;return this.overwriteGetter("rgb",[e/h,r/h,a/h,l])}get hcl(){return this.overwriteGetter("hcl",(function(e){const[r,a,l,h]=Jt(e),d=Math.sqrt(a*a+l*l);return[Math.round(1e4*d)?Ut(Math.atan2(l,a)*Kt):NaN,d,r,h]})(this.rgb))}get lab(){return this.overwriteGetter("lab",Jt(this.rgb))}overwriteGetter(e,r){return Object.defineProperty(this,e,{value:r}),r}toString(){const[e,r,a,l]=this.rgb;return`rgba(${[e,r,a].map((h=>Math.round(255*h))).join(",")},${l})`}}se.black=new se(0,0,0,1),se.white=new se(1,1,1,1),se.transparent=new se(0,0,0,0),se.red=new se(1,0,0,1);class In{constructor(e,r,a){this.sensitivity=e?r?"variant":"case":r?"accent":"base",this.locale=a,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,r){return this.collator.compare(e,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class kn{constructor(e,r,a,l,h){this.text=e,this.image=r,this.scale=a,this.fontStack=l,this.textColor=h}}class di{constructor(e){this.sections=e}static fromString(e){return new di([new kn(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 di?e:di.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map((e=>e.text)).join("")}}class pi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof pi)return e;if(typeof e=="number")return new pi([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 pi(e)}}toString(){return JSON.stringify(this.values)}}const Ol=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class wi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof wi)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let r=0;r<e.length;r+=2){const a=e[r],l=e[r+1];if(typeof a!="string"||!Ol.has(a)||!Array.isArray(l)||l.length!==2||typeof l[0]!="number"||typeof l[1]!="number")return}return new wi(e)}}toString(){return JSON.stringify(this.values)}}class fi{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new fi({name:e,available:!1}):null}}function ps(i,e,r,a){return typeof i=="number"&&i>=0&&i<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof r=="number"&&r>=0&&r<=255?a===void 0||typeof a=="number"&&a>=0&&a<=1?null:`Invalid rgba value [${[i,e,r,a].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof a=="number"?[i,e,r,a]:[i,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Zr(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof se||i instanceof In||i instanceof di||i instanceof pi||i instanceof wi||i instanceof fi)return!0;if(Array.isArray(i)){for(const e of i)if(!Zr(e))return!1;return!0}if(typeof i=="object"){for(const e in i)if(!Zr(i[e]))return!1;return!0}return!1}function Me(i){if(i===null)return Mr;if(typeof i=="string")return Nt;if(typeof i=="boolean")return Ft;if(typeof i=="number")return _t;if(i instanceof se)return ei;if(i instanceof In)return ir;if(i instanceof di)return mr;if(i instanceof pi)return Er;if(i instanceof wi)return j;if(i instanceof fi)return rr;if(Array.isArray(i)){const e=i.length;let r;for(const a of i){const l=Me(a);if(r){if(r===l)continue;r=jt;break}r=l}return M(r||jt,e)}return Bi}function Qs(i){const e=typeof i;return i===null?"":e==="string"||e==="number"||e==="boolean"?String(i):i instanceof se||i instanceof di||i instanceof pi||i instanceof wi||i instanceof fi?i.toString():JSON.stringify(i)}class Fi{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(!Zr(e[1]))return r.error("invalid value");const a=e[1];let l=Me(a);const h=r.expectedType;return l.kind!=="array"||l.N!==0||!h||h.kind!=="array"||typeof h.N=="number"&&h.N!==0||(l=h),new Fi(l,a)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class Se{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const Ea={string:Nt,number:_t,boolean:Ft,object:Bi};class Li{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let a,l=1;const h=e[0];if(h==="array"){let f,_;if(e.length>2){const x=e[1];if(typeof x!="string"||!(x in Ea)||x==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);f=Ea[x],l++}else f=jt;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],l++}a=M(f,_)}else{if(!Ea[h])throw new Error(`Types doesn't contain name = ${h}`);a=Ea[h]}const d=[];for(;l<e.length;l++){const f=r.parse(e[l],l,jt);if(!f)return null;d.push(f)}return new Li(a,d)}evaluate(e){for(let r=0;r<this.args.length;r++){const a=this.args[r].evaluate(e);if(!O(this.type,Me(a)))return a;if(r===this.args.length-1)throw new Se(`Expected value to be of type ${k(this.type)}, but found ${k(Me(a))} instead.`)}throw new Error}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Mn={"to-boolean":Ft,"to-color":ei,"to-number":_t,"to-string":Nt};class Oi{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const a=e[0];if(!Mn[a])throw new Error(`Can't parse ${a} as it is not part of the known types`);if((a==="to-boolean"||a==="to-string")&&e.length!==2)return r.error("Expected one argument.");const l=Mn[a],h=[];for(let d=1;d<e.length;d++){const f=r.parse(e[d],d,jt);if(!f)return null;h.push(f)}return new Oi(l,h)}evaluate(e){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(e);case"color":{let r,a;for(const l of this.args){if(r=l.evaluate(e),a=null,r instanceof se)return r;if(typeof r=="string"){const h=e.parseColor(r);if(h)return h}else if(Array.isArray(r)&&(a=r.length<3||r.length>4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:ps(r[0],r[1],r[2],r[3]),!a))return new se(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new Se(a||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"padding":{let r;for(const a of this.args){r=a.evaluate(e);const l=pi.parse(r);if(l)return l}throw new Se(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"variableAnchorOffsetCollection":{let r;for(const a of this.args){r=a.evaluate(e);const l=wi.parse(r);if(l)return l}throw new Se(`Could not parse variableAnchorOffsetCollection from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"number":{let r=null;for(const a of this.args){if(r=a.evaluate(e),r===null)return 0;const l=Number(r);if(!isNaN(l))return l}throw new Se(`Could not convert ${JSON.stringify(r)} to number.`)}case"formatted":return di.fromString(Qs(this.args[0].evaluate(e)));case"resolvedImage":return fi.fromString(Qs(this.args[0].evaluate(e)));default:return Qs(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Vl=["Unknown","Point","LineString","Polygon"];class za{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"?Vl[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]=se.parse(e)),r}}class qr{constructor(e,r,a=[],l,h=new er,d=[]){this.registry=e,this.path=a,this.key=a.map((f=>`[${f}]`)).join(""),this.scope=h,this.errors=d,this.expectedType=l,this._isConstant=r}parse(e,r,a,l,h={}){return r?this.concat(r,a,l)._parse(e,h):this._parse(e,h)}_parse(e,r){function a(l,h,d){return d==="assert"?new Li(h,[l]):d==="coerce"?new Oi(h,[l]):l}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 l=e[0];if(typeof l!="string")return this.error(`Expression name must be a string, but found ${typeof l} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const h=this.registry[l];if(h){let d=h.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=a(d,f,r.typeAnnotation||"coerce");else d=a(d,f,r.typeAnnotation||"coerce");else d=a(d,f,r.typeAnnotation||"coerce");else d=a(d,f,r.typeAnnotation||"assert")}if(!(d instanceof Fi)&&d.type.kind!=="resolvedImage"&&this._isConstant(d)){const f=new za;try{d=new Fi(d.type,d.evaluate(f))}catch(_){return this.error(_.message),null}}return d}return this.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,r,a){const l=typeof e=="number"?this.path.concat(e):this.path,h=a?this.scope.concat(a):this.scope;return new qr(this.registry,this._isConstant,l,r||null,h,this.errors)}error(e,...r){const a=`${this.key}${r.map((l=>`[${l}]`)).join("")}`;this.errors.push(new He(a,e))}checkSubtype(e,r){const a=O(e,r);return a&&this.error(a),a}}class zr{constructor(e,r){this.type=r.type,this.bindings=[].concat(e),this.result=r}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const r of this.bindings)e(r[1]);e(this.result)}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const a=[];for(let h=1;h<e.length-1;h+=2){const d=e[h];if(typeof d!="string")return r.error(`Expected string, but found ${typeof d} instead.`,h);if(/[^a-zA-Z0-9_]/.test(d))return r.error("Variable names must contain only alphanumeric characters or '_'.",h);const f=r.parse(e[h+1],h+1);if(!f)return null;a.push([d,f])}const l=r.parse(e[e.length-1],e.length-1,r.expectedType,a);return l?new zr(a,l):null}outputDefined(){return this.result.outputDefined()}}class ee{constructor(e,r){this.type=r.type,this.name=e,this.boundExpression=r}static parse(e,r){if(e.length!==2||typeof e[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");const a=e[1];return r.scope.has(a)?new ee(a,r.scope.get(a)):r.error(`Unknown variable "${a}". Make sure "${a}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class En{constructor(e,r,a){this.type=e,this.index=r,this.input=a}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,_t),l=r.parse(e[2],2,M(r.expectedType||jt));return a&&l?new En(l.type.itemType,a,l):null}evaluate(e){const r=this.index.evaluate(e),a=this.input.evaluate(e);if(r<0)throw new Se(`Array index out of bounds: ${r} < 0.`);if(r>=a.length)throw new Se(`Array index out of bounds: ${r} > ${a.length-1}.`);if(r!==Math.floor(r))throw new Se(`Array index must be an integer, but found ${r} instead.`);return a[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class zn{constructor(e,r){this.type=Ft,this.needle=e,this.haystack=r}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,jt),l=r.parse(e[2],2,jt);return a&&l?G(a.type,[Ft,Nt,_t,Mr,jt])?new zn(a,l):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${k(a.type)} instead`):null}evaluate(e){const r=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!a)return!1;if(!W(r,["boolean","string","number","null"]))throw new Se(`Expected first argument to be of type boolean, string, number or null, but found ${k(Me(r))} instead.`);if(!W(a,["string","array"]))throw new Se(`Expected second argument to be of type array or string, but found ${k(Me(a))} instead.`);return a.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class fs{constructor(e,r,a){this.type=_t,this.needle=e,this.haystack=r,this.fromIndex=a}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,jt),l=r.parse(e[2],2,jt);if(!a||!l)return null;if(!G(a.type,[Ft,Nt,_t,Mr,jt]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${k(a.type)} instead`);if(e.length===4){const h=r.parse(e[3],3,_t);return h?new fs(a,l,h):null}return new fs(a,l)}evaluate(e){const r=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!W(r,["boolean","string","number","null"]))throw new Se(`Expected first argument to be of type boolean, string, number or null, but found ${k(Me(r))} instead.`);let l;if(this.fromIndex&&(l=this.fromIndex.evaluate(e)),W(a,["string"])){const h=a.indexOf(r,l);return h===-1?-1:[...a.slice(0,h)].length}if(W(a,["array"]))return a.indexOf(r,l);throw new Se(`Expected second argument to be of type array or string, but found ${k(Me(a))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class Cn{constructor(e,r,a,l,h,d){this.inputType=e,this.type=r,this.input=a,this.cases=l,this.outputs=h,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 a,l;r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);const h={},d=[];for(let x=2;x<e.length-1;x+=2){let v=e[x];const w=e[x+1];Array.isArray(v)||(v=[v]);const I=r.concat(x);if(v.length===0)return I.error("Expected at least one branch label.");for(const C of v){if(typeof C!="number"&&typeof C!="string")return I.error("Branch labels must be numbers or strings.");if(typeof C=="number"&&Math.abs(C)>Number.MAX_SAFE_INTEGER)return I.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof C=="number"&&Math.floor(C)!==C)return I.error("Numeric branch labels must be integer values.");if(a){if(I.checkSubtype(a,Me(C)))return null}else a=Me(C);if(h[String(C)]!==void 0)return I.error("Branch labels must be unique.");h[String(C)]=d.length}const E=r.parse(w,x,l);if(!E)return null;l=l||E.type,d.push(E)}const f=r.parse(e[1],1,jt);if(!f)return null;const _=r.parse(e[e.length-1],e.length-1,l);return _?f.type.kind!=="value"&&r.concat(1).checkSubtype(a,f.type)?null:new Cn(a,l,f,h,d,_):null}evaluate(e){const r=this.input.evaluate(e);return(Me(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 Ca{constructor(e,r,a){this.type=e,this.branches=r,this.otherwise=a}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error("Expected an odd number of arguments.");let a;r.expectedType&&r.expectedType.kind!=="value"&&(a=r.expectedType);const l=[];for(let d=1;d<e.length-1;d+=2){const f=r.parse(e[d],d,Ft);if(!f)return null;const _=r.parse(e[d+1],d+1,a);if(!_)return null;l.push([f,_]),a=a||_.type}const h=r.parse(e[e.length-1],e.length-1,a);if(!h)return null;if(!a)throw new Error("Can't infer output type");return new Ca(a,l,h)}evaluate(e){for(const[r,a]of this.branches)if(r.evaluate(e))return a.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[r,a]of this.branches)e(r),e(a);e(this.otherwise)}outputDefined(){return this.branches.every((([e,r])=>r.outputDefined()))&&this.otherwise.outputDefined()}}class ta{constructor(e,r,a,l){this.type=e,this.input=r,this.beginIndex=a,this.endIndex=l}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,jt),l=r.parse(e[2],2,_t);if(!a||!l)return null;if(!G(a.type,[M(jt),Nt,jt]))return r.error(`Expected first argument to be of type array or string, but found ${k(a.type)} instead`);if(e.length===4){const h=r.parse(e[3],3,_t);return h?new ta(a.type,a,l,h):null}return new ta(a.type,a,l)}evaluate(e){const r=this.input.evaluate(e),a=this.beginIndex.evaluate(e);let l;if(this.endIndex&&(l=this.endIndex.evaluate(e)),W(r,["string"]))return[...r].slice(a,l).join("");if(W(r,["array"]))return r.slice(a,l);throw new Se(`Expected first argument to be of type array or string, but found ${k(Me(r))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function Pa(i,e){const r=i.length-1;let a,l,h=0,d=r,f=0;for(;h<=d;)if(f=Math.floor((h+d)/2),a=i[f],l=i[f+1],a<=e){if(f===r||e<l)return f;h=f+1}else{if(!(a>e))throw new Se("Input is not a number.");d=f-1}return 0}class ms{constructor(e,r,a){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(const[l,h]of a)this.labels.push(l),this.outputs.push(h)}static parse(e,r){if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");const a=r.parse(e[1],1,_t);if(!a)return null;const l=[];let h=null;r.expectedType&&r.expectedType.kind!=="value"&&(h=r.expectedType);for(let d=1;d<e.length;d+=2){const f=d===1?-1/0:e[d],_=e[d+1],x=d,v=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(l.length&&l[l.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(_,v,h);if(!w)return null;h=h||w.type,l.push([f,w])}return new ms(h,a,l)}evaluate(e){const r=this.labels,a=this.outputs;if(r.length===1)return a[0].evaluate(e);const l=this.input.evaluate(e);if(l<=r[0])return a[0].evaluate(e);const h=r.length;return l>=r[h-1]?a[h-1].evaluate(e):a[Pa(r,l)].evaluate(e)}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Ro(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var jl=Bo;function Bo(i,e,r,a){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(a-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=e,this.p2x=r,this.p2y=a}Bo.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,e){if(e===void 0&&(e=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,a=0;a<8;a++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)<e)return r;var h=this.sampleCurveDerivativeX(r);if(Math.abs(h)<1e-6)break;r-=l/h}var d=0,f=1;for(r=i,a=0;a<20&&(l=this.sampleCurveX(r),!(Math.abs(l-i)<e));a++)i>l?d=r:f=r,r=.5*(f-d)+d;return r},solve:function(i,e){return this.sampleCurveY(this.solveCurveX(i,e))}};var Ul=Ro(jl);function Gr(i,e,r){return i+r*(e-i)}function ea(i,e,r){return i.map(((a,l)=>Gr(a,e[l],r)))}const ii={number:Gr,color:function(i,e,r,a="rgb"){switch(a){case"rgb":{const[l,h,d,f]=ea(i.rgb,e.rgb,r);return new se(l,h,d,f,!1)}case"hcl":{const[l,h,d,f]=i.hcl,[_,x,v,w]=e.hcl;let I,E;if(isNaN(l)||isNaN(_))isNaN(l)?isNaN(_)?I=NaN:(I=_,d!==1&&d!==0||(E=x)):(I=l,v!==1&&v!==0||(E=h));else{let Q=_-l;_>l&&Q>180?Q-=360:_<l&&l-_>180&&(Q+=360),I=l+r*Q}const[C,P,L,U]=(function([Q,X,J,rt]){return Q=isNaN(Q)?0:Q*Dt,xe([J,Math.cos(Q)*X,Math.sin(Q)*X,rt])})([I,E??Gr(h,x,r),Gr(d,v,r),Gr(f,w,r)]);return new se(C,P,L,U,!1)}case"lab":{const[l,h,d,f]=xe(ea(i.lab,e.lab,r));return new se(l,h,d,f,!1)}}},array:ea,padding:function(i,e,r){return new pi(ea(i.values,e.values,r))},variableAnchorOffsetCollection:function(i,e,r){const a=i.values,l=e.values;if(a.length!==l.length)throw new Se(`Cannot interpolate values of different length. from: ${i.toString()}, to: ${e.toString()}`);const h=[];for(let d=0;d<a.length;d+=2){if(a[d]!==l[d])throw new Se(`Cannot interpolate values containing mismatched anchors. from[${d}]: ${a[d]}, to[${d}]: ${l[d]}`);h.push(a[d]);const[f,_]=a[d+1],[x,v]=l[d+1];h.push([Gr(f,x,r),Gr(_,v,r)])}return new wi(h)}};class ri{constructor(e,r,a,l,h){this.type=e,this.operator=r,this.interpolation=a,this.input=l,this.labels=[],this.outputs=[];for(const[d,f]of h)this.labels.push(d),this.outputs.push(f)}static interpolationFactor(e,r,a,l){let h=0;if(e.name==="exponential")h=Aa(r,e.base,a,l);else if(e.name==="linear")h=Aa(r,1,a,l);else if(e.name==="cubic-bezier"){const d=e.controlPoints;h=new Ul(d[0],d[1],d[2],d[3]).solve(Aa(r,1,a,l))}return h}static parse(e,r){let[a,l,h,...d]=e;if(!Array.isArray(l)||l.length===0)return r.error("Expected an interpolation type expression.",1);if(l[0]==="linear")l={name:"linear"};else if(l[0]==="exponential"){const x=l[1];if(typeof x!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);l={name:"exponential",base:x}}else{if(l[0]!=="cubic-bezier")return r.error(`Unknown interpolation type ${String(l[0])}`,1,0);{const x=l.slice(1);if(x.length!==4||x.some((v=>typeof v!="number"||v<0||v>1)))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);l={name:"cubic-bezier",controlPoints:x}}}if(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(h=r.parse(h,2,_t),!h)return null;const f=[];let _=null;a==="interpolate-hcl"||a==="interpolate-lab"?_=ei:r.expectedType&&r.expectedType.kind!=="value"&&(_=r.expectedType);for(let x=0;x<d.length;x+=2){const v=d[x],w=d[x+1],I=x+3,E=x+4;if(typeof v!="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]>=v)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',I);const C=r.parse(w,E,_);if(!C)return null;_=_||C.type,f.push([v,C])}return Y(_,_t)||Y(_,ei)||Y(_,Er)||Y(_,j)||Y(_,M(_t))?new ri(_,a,l,h,f):r.error(`Type ${k(_)} is not interpolatable.`)}evaluate(e){const r=this.labels,a=this.outputs;if(r.length===1)return a[0].evaluate(e);const l=this.input.evaluate(e);if(l<=r[0])return a[0].evaluate(e);const h=r.length;if(l>=r[h-1])return a[h-1].evaluate(e);const d=Pa(r,l),f=ri.interpolationFactor(this.interpolation,l,r[d],r[d+1]),_=a[d].evaluate(e),x=a[d+1].evaluate(e);switch(this.operator){case"interpolate":return ii[this.type.kind](_,x,f);case"interpolate-hcl":return ii.color(_,x,f,"hcl");case"interpolate-lab":return ii.color(_,x,f,"lab")}}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Aa(i,e,r,a){const l=a-r,h=i-r;return l===0?0:e===1?h/l:(Math.pow(e,h)-1)/(Math.pow(e,l)-1)}class Da{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expectected at least one argument.");let a=null;const l=r.expectedType;l&&l.kind!=="value"&&(a=l);const h=[];for(const f of e.slice(1)){const _=r.parse(f,1+h.length,a,void 0,{typeAnnotation:"omit"});if(!_)return null;a=a||_.type,h.push(_)}if(!a)throw new Error("No output type");const d=l&&h.some((f=>O(l,f.type)));return new Da(d?jt:a,h)}evaluate(e){let r,a=null,l=0;for(const h of this.args)if(l++,a=h.evaluate(e),a&&a instanceof fi&&!a.available&&(r||(r=a.name),a=null,l===this.args.length&&(a=r)),a!==null)break;return a}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function Ra(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 Fo(i,e,r,a){return a.compare(e,r)===0}function _s(i,e,r){const a=i!=="=="&&i!=="!=";return class Lh{constructor(h,d,f){this.type=Ft,this.lhs=h,this.rhs=d,this.collator=f,this.hasUntypedArgument=h.type.kind==="value"||d.type.kind==="value"}static parse(h,d){if(h.length!==3&&h.length!==4)return d.error("Expected two or three arguments.");const f=h[0];let _=d.parse(h[1],1,jt);if(!_)return null;if(!Ra(f,_.type))return d.concat(1).error(`"${f}" comparisons are not supported for type '${k(_.type)}'.`);let x=d.parse(h[2],2,jt);if(!x)return null;if(!Ra(f,x.type))return d.concat(2).error(`"${f}" comparisons are not supported for type '${k(x.type)}'.`);if(_.type.kind!==x.type.kind&&_.type.kind!=="value"&&x.type.kind!=="value")return d.error(`Cannot compare types '${k(_.type)}' and '${k(x.type)}'.`);a&&(_.type.kind==="value"&&x.type.kind!=="value"?_=new Li(x.type,[_]):_.type.kind!=="value"&&x.type.kind==="value"&&(x=new Li(_.type,[x])));let v=null;if(h.length===4){if(_.type.kind!=="string"&&x.type.kind!=="string"&&_.type.kind!=="value"&&x.type.kind!=="value")return d.error("Cannot use collator to compare non-string types.");if(v=d.parse(h[3],3,ir),!v)return null}return new Lh(_,x,v)}evaluate(h){const d=this.lhs.evaluate(h),f=this.rhs.evaluate(h);if(a&&this.hasUntypedArgument){const _=Me(d),x=Me(f);if(_.kind!==x.kind||_.kind!=="string"&&_.kind!=="number")throw new Se(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${_.kind}, ${x.kind}) instead.`)}if(this.collator&&!a&&this.hasUntypedArgument){const _=Me(d),x=Me(f);if(_.kind!=="string"||x.kind!=="string")return e(h,d,f)}return this.collator?r(h,d,f,this.collator.evaluate(h)):e(h,d,f)}eachChild(h){h(this.lhs),h(this.rhs),this.collator&&h(this.collator)}outputDefined(){return!0}}}const $l=_s("==",(function(i,e,r){return e===r}),Fo),Lo=_s("!=",(function(i,e,r){return e!==r}),(function(i,e,r,a){return!Fo(0,e,r,a)})),Oo=_s("<",(function(i,e,r){return e<r}),(function(i,e,r,a){return a.compare(e,r)<0})),Nl=_s(">",(function(i,e,r){return e>r}),(function(i,e,r,a){return a.compare(e,r)>0})),Zl=_s("<=",(function(i,e,r){return e<=r}),(function(i,e,r,a){return a.compare(e,r)<=0})),Vo=_s(">=",(function(i,e,r){return e>=r}),(function(i,e,r,a){return a.compare(e,r)>=0}));class ia{constructor(e,r,a){this.type=ir,this.locale=a,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error("Expected one argument.");const a=e[1];if(typeof a!="object"||Array.isArray(a))return r.error("Collator options argument must be an object.");const l=r.parse(a["case-sensitive"]!==void 0&&a["case-sensitive"],1,Ft);if(!l)return null;const h=r.parse(a["diacritic-sensitive"]!==void 0&&a["diacritic-sensitive"],1,Ft);if(!h)return null;let d=null;return a.locale&&(d=r.parse(a.locale,1,Nt),!d)?null:new ia(l,h,d)}evaluate(e){return new In(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 Pn{constructor(e,r,a,l,h){this.type=Nt,this.number=e,this.locale=r,this.currency=a,this.minFractionDigits=l,this.maxFractionDigits=h}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");const a=r.parse(e[1],1,_t);if(!a)return null;const l=e[2];if(typeof l!="object"||Array.isArray(l))return r.error("NumberFormat options argument must be an object.");let h=null;if(l.locale&&(h=r.parse(l.locale,1,Nt),!h))return null;let d=null;if(l.currency&&(d=r.parse(l.currency,1,Nt),!d))return null;let f=null;if(l["min-fraction-digits"]&&(f=r.parse(l["min-fraction-digits"],1,_t),!f))return null;let _=null;return l["max-fraction-digits"]&&(_=r.parse(l["max-fraction-digits"],1,_t),!_)?null:new Pn(a,h,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 Ba{constructor(e){this.type=mr,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const a=e[1];if(!Array.isArray(a)&&typeof a=="object")return r.error("First argument must be an image or text section.");const l=[];let h=!1;for(let d=1;d<=e.length-1;++d){const f=e[d];if(h&&typeof f=="object"&&!Array.isArray(f)){h=!1;let _=null;if(f["font-scale"]&&(_=r.parse(f["font-scale"],1,_t),!_))return null;let x=null;if(f["text-font"]&&(x=r.parse(f["text-font"],1,M(Nt)),!x))return null;let v=null;if(f["text-color"]&&(v=r.parse(f["text-color"],1,ei),!v))return null;const w=l[l.length-1];w.scale=_,w.font=x,w.textColor=v}else{const _=r.parse(e[d],1,jt);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'.");h=!0,l.push({content:_,scale:null,font:null,textColor:null})}}return new Ba(l)}evaluate(e){return new di(this.sections.map((r=>{const a=r.content.evaluate(e);return Me(a)===rr?new kn("",a,null,null,null):new kn(Qs(a),null,r.scale?r.scale.evaluate(e):null,r.font?r.font.evaluate(e).join(","):null,r.textColor?r.textColor.evaluate(e):null)})))}eachChild(e){for(const r of this.sections)e(r.content),r.scale&&e(r.scale),r.font&&e(r.font),r.textColor&&e(r.textColor)}outputDefined(){return!1}}class An{constructor(e){this.type=rr,this.input=e}static parse(e,r){if(e.length!==2)return r.error("Expected two arguments.");const a=r.parse(e[1],1,Nt);return a?new An(a):r.error("No image name provided.")}evaluate(e){const r=this.input.evaluate(e),a=fi.fromString(r);return a&&e.availableImages&&(a.available=e.availableImages.indexOf(r)>-1),a}eachChild(e){e(this.input)}outputDefined(){return!1}}class Dn{constructor(e){this.type=_t,this.input=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);const a=r.parse(e[1],1);return a?a.type.kind!=="array"&&a.type.kind!=="string"&&a.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${k(a.type)} instead.`):new Dn(a):null}evaluate(e){const r=this.input.evaluate(e);if(typeof r=="string")return[...r].length;if(Array.isArray(r))return r.length;throw new Se(`Expected value to be of type string or array, but found ${k(Me(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const sr=8192;function ql(i,e){const r=(180+i[0])/360,a=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,l=Math.pow(2,e.z);return[Math.round(r*l*sr),Math.round(a*l*sr)]}function Rn(i,e){const r=Math.pow(2,e.z);return[(l=(i[0]/sr+e.x)/r,360*l-180),(a=(i[1]/sr+e.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*a)*Math.PI/180))-90)];var a,l}function Xr(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 Cr(i,e){return!(i[0]<=e[0]||i[2]>=e[2]||i[1]<=e[1]||i[3]>=e[3])}function ie(i,e,r){const a=i[0]-e[0],l=i[1]-e[1],h=i[0]-r[0],d=i[1]-r[1];return a*d-h*l==0&&a*h<=0&&l*d<=0}function Fa(i,e,r,a){return(l=[a[0]-r[0],a[1]-r[1]])[0]*(h=[e[0]-i[0],e[1]-i[1]])[1]-l[1]*h[0]!=0&&!(!Uo(i,e,r,a)||!Uo(r,a,i,e));var l,h}function Gl(i,e,r){for(const a of r)for(let l=0;l<a.length-1;++l)if(Fa(i,e,a[l],a[l+1]))return!0;return!1}function gs(i,e,r=!1){let a=!1;for(const f of e)for(let _=0;_<f.length-1;_++){if(ie(i,f[_],f[_+1]))return r;(h=f[_])[1]>(l=i)[1]!=(d=f[_+1])[1]>l[1]&&l[0]<(d[0]-h[0])*(l[1]-h[1])/(d[1]-h[1])+h[0]&&(a=!a)}var l,h,d;return a}function Xl(i,e){for(const r of e)if(gs(i,r))return!0;return!1}function jo(i,e){for(const r of i)if(!gs(r,e))return!1;for(let r=0;r<i.length-1;++r)if(Gl(i[r],i[r+1],e))return!1;return!0}function Hl(i,e){for(const r of e)if(jo(i,r))return!0;return!1}function Uo(i,e,r,a){const l=a[0]-r[0],h=a[1]-r[1],d=(i[0]-r[0])*h-l*(i[1]-r[1]),f=(e[0]-r[0])*h-l*(e[1]-r[1]);return d>0&&f<0||d<0&&f>0}function Bn(i,e,r){const a=[];for(let l=0;l<i.length;l++){const h=[];for(let d=0;d<i[l].length;d++){const f=ql(i[l][d],r);Xr(e,f),h.push(f)}a.push(h)}return a}function $o(i,e,r){const a=[];for(let l=0;l<i.length;l++){const h=Bn(i[l],e,r);a.push(h)}return a}function No(i,e,r,a){if(i[0]<r[0]||i[0]>r[2]){const l=.5*a;let h=i[0]-r[0]>l?-a:r[0]-i[0]>l?a:0;h===0&&(h=i[0]-r[2]>l?-a:r[2]-i[0]>l?a:0),i[0]+=h}Xr(e,i)}function Zo(i,e,r,a){const l=Math.pow(2,a.z)*sr,h=[a.x*sr,a.y*sr],d=[];for(const f of i)for(const _ of f){const x=[_.x+h[0],_.y+h[1]];No(x,e,r,l),d.push(x)}return d}function qo(i,e,r,a){const l=Math.pow(2,a.z)*sr,h=[a.x*sr,a.y*sr],d=[];for(const _ of i){const x=[];for(const v of _){const w=[v.x+h[0],v.y+h[1]];Xr(e,w),x.push(w)}d.push(x)}if(e[2]-e[0]<=l/2){(f=e)[0]=f[1]=1/0,f[2]=f[3]=-1/0;for(const _ of d)for(const x of _)No(x,e,r,l)}var f;return d}class Hr{constructor(e,r){this.type=Ft,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(Zr(e[1])){const a=e[1];if(a.type==="FeatureCollection"){const l=[];for(const h of a.features){const{type:d,coordinates:f}=h.geometry;d==="Polygon"&&l.push(f),d==="MultiPolygon"&&l.push(...f)}if(l.length)return new Hr(a,{type:"MultiPolygon",coordinates:l})}else if(a.type==="Feature"){const l=a.geometry.type;if(l==="Polygon"||l==="MultiPolygon")return new Hr(a,a.geometry)}else if(a.type==="Polygon"||a.type==="MultiPolygon")return new Hr(a,a)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return(function(r,a){const l=[1/0,1/0,-1/0,-1/0],h=[1/0,1/0,-1/0,-1/0],d=r.canonicalID();if(a.type==="Polygon"){const f=Bn(a.coordinates,h,d),_=Zo(r.geometry(),l,h,d);if(!Cr(l,h))return!1;for(const x of _)if(!gs(x,f))return!1}if(a.type==="MultiPolygon"){const f=$o(a.coordinates,h,d),_=Zo(r.geometry(),l,h,d);if(!Cr(l,h))return!1;for(const x of _)if(!Xl(x,f))return!1}return!0})(e,this.geometries);if(e.geometryType()==="LineString")return(function(r,a){const l=[1/0,1/0,-1/0,-1/0],h=[1/0,1/0,-1/0,-1/0],d=r.canonicalID();if(a.type==="Polygon"){const f=Bn(a.coordinates,h,d),_=qo(r.geometry(),l,h,d);if(!Cr(l,h))return!1;for(const x of _)if(!jo(x,f))return!1}if(a.type==="MultiPolygon"){const f=$o(a.coordinates,h,d),_=qo(r.geometry(),l,h,d);if(!Cr(l,h))return!1;for(const x of _)if(!Hl(x,f))return!1}return!0})(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Go=class{constructor(i=[],e=((r,a)=>r<a?-1:r>a?1:0)){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._up(this.length++)}pop(){if(this.length===0)return;const i=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:e,compare:r}=this,a=e[i];for(;i>0;){const l=i-1>>1,h=e[l];if(r(a,h)>=0)break;e[i]=h,i=l}e[i]=a}_down(i){const{data:e,compare:r}=this,a=this.length>>1,l=e[i];for(;i<a;){let h=1+(i<<1);const d=h+1;if(d<this.length&&r(e[d],e[h])<0&&(h=d),r(e[h],l)>=0)break;e[i]=e[h],i=h}e[i]=l}};function Wl(i,e,r,a,l){Xo(i,e,r,a||i.length-1,l||Kl)}function Xo(i,e,r,a,l){for(;a>r;){if(a-r>600){var h=a-r+1,d=e-r+1,f=Math.log(h),_=.5*Math.exp(2*f/3),x=.5*Math.sqrt(f*_*(h-_)/h)*(d-h/2<0?-1:1);Xo(i,e,Math.max(r,Math.floor(e-d*_/h+x)),Math.min(a,Math.floor(e+(h-d)*_/h+x)),l)}var v=i[e],w=r,I=a;for(ra(i,r,e),l(i[a],v)>0&&ra(i,r,a);w<I;){for(ra(i,w,I),w++,I--;l(i[w],v)<0;)w++;for(;l(i[I],v)>0;)I--}l(i[r],v)===0?ra(i,r,I):ra(i,++I,a),I<=e&&(r=I+1),e<=I&&(a=I-1)}}function ra(i,e,r){var a=i[e];i[e]=i[r],i[r]=a}function Kl(i,e){return i<e?-1:i>e?1:0}function La(i,e){if(i.length<=1)return[i];const r=[];let a,l;for(const h of i){const d=Yl(h);d!==0&&(h.area=Math.abs(d),l===void 0&&(l=d<0),l===d<0?(a&&r.push(a),a=[h]):a.push(h))}if(a&&r.push(a),e>1)for(let h=0;h<r.length;h++)r[h].length<=e||(Wl(r[h],e,1,r[h].length-1,Jl),r[h]=r[h].slice(0,e));return r}function Jl(i,e){return e.area-i.area}function Yl(i){let e=0;for(let r,a,l=0,h=i.length,d=h-1;l<h;d=l++)r=i[l],a=i[d],e+=(a.x-r.x)*(r.y+a.y);return e}const Ho=1/298.257223563,Wo=Ho*(2-Ho),Ko=Math.PI/180;class Fn{constructor(e){const r=6378.137*Ko*1e3,a=Math.cos(e*Ko),l=1/(1-Wo*(1-a*a)),h=Math.sqrt(l);this.kx=r*h*a,this.ky=r*h*l*(1-Wo)}distance(e,r){const a=this.wrap(e[0]-r[0])*this.kx,l=(e[1]-r[1])*this.ky;return Math.sqrt(a*a+l*l)}pointOnLine(e,r){let a,l,h,d,f=1/0;for(let _=0;_<e.length-1;_++){let x=e[_][0],v=e[_][1],w=this.wrap(e[_+1][0]-x)*this.kx,I=(e[_+1][1]-v)*this.ky,E=0;w===0&&I===0||(E=(this.wrap(r[0]-x)*this.kx*w+(r[1]-v)*this.ky*I)/(w*w+I*I),E>1?(x=e[_+1][0],v=e[_+1][1]):E>0&&(x+=w/this.kx*E,v+=I/this.ky*E)),w=this.wrap(r[0]-x)*this.kx,I=(r[1]-v)*this.ky;const C=w*w+I*I;C<f&&(f=C,a=x,l=v,h=_,d=E)}return{point:[a,l],index:h,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 Oa(i){return i[1]-i[0]+1}function _r(i,e){return i[1]>=i[0]&&i[1]<e}function Ln(i,e){if(i[0]>i[1])return[null,null];const r=Oa(i);if(e){if(r===2)return[i,null];const l=Math.floor(r/2);return[[i[0],i[0]+l],[i[0]+l,i[1]]]}if(r===1)return[i,null];const a=Math.floor(r/2)-1;return[[i[0],i[0]+a],[i[0]+a+1,i[1]]]}function On(i,e){if(!_r(e,i.length))return[1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let a=e[0];a<=e[1];++a)Xr(r,i[a]);return r}function Vn(i){const e=[1/0,1/0,-1/0,-1/0];for(const r of i)for(const a of r)Xr(e,a);return e}function Va(i){return i[0]!==-1/0&&i[1]!==-1/0&&i[2]!==1/0&&i[3]!==1/0}function jn(i,e,r){if(!Va(i)||!Va(e))return NaN;let a=0,l=0;return i[2]<e[0]&&(a=e[0]-i[2]),i[0]>e[2]&&(a=i[0]-e[2]),i[1]>e[3]&&(l=i[1]-e[3]),i[3]<e[1]&&(l=e[1]-i[3]),r.distance([0,0],[a,l])}function Wr(i,e,r){const a=r.pointOnLine(e,i);return r.distance(i,a.point)}function Un(i,e,r,a,l){const h=Math.min(Wr(i,[r,a],l),Wr(e,[r,a],l)),d=Math.min(Wr(r,[i,e],l),Wr(a,[i,e],l));return Math.min(h,d)}function Ql(i,e,r,a,l){if(!_r(e,i.length)||!_r(a,r.length))return 1/0;let h=1/0;for(let d=e[0];d<e[1];++d){const f=i[d],_=i[d+1];for(let x=a[0];x<a[1];++x){const v=r[x],w=r[x+1];if(Fa(f,_,v,w))return 0;h=Math.min(h,Un(f,_,v,w,l))}}return h}function be(i,e,r,a,l){if(!_r(e,i.length)||!_r(a,r.length))return NaN;let h=1/0;for(let d=e[0];d<=e[1];++d)for(let f=a[0];f<=a[1];++f)if(h=Math.min(h,l.distance(i[d],r[f])),h===0)return h;return h}function tc(i,e,r){if(gs(i,e,!0))return 0;let a=1/0;for(const l of e){const h=l[0],d=l[l.length-1];if(h!==d&&(a=Math.min(a,Wr(i,[d,h],r)),a===0))return a;const f=r.pointOnLine(l,i);if(a=Math.min(a,r.distance(i,f.point)),a===0)return a}return a}function qt(i,e,r,a){if(!_r(e,i.length))return NaN;for(let h=e[0];h<=e[1];++h)if(gs(i[h],r,!0))return 0;let l=1/0;for(let h=e[0];h<e[1];++h){const d=i[h],f=i[h+1];for(const _ of r)for(let x=0,v=_.length,w=v-1;x<v;w=x++){const I=_[w],E=_[x];if(Fa(d,f,I,E))return 0;l=Math.min(l,Un(d,f,I,E,a))}}return l}function ja(i,e){for(const r of i)for(const a of r)if(gs(a,e,!0))return!0;return!1}function ue(i,e,r,a=1/0){const l=Vn(i),h=Vn(e);if(a!==1/0&&jn(l,h,r)>=a)return a;if(Cr(l,h)){if(ja(i,e))return 0}else if(ja(e,i))return 0;let d=1/0;for(const f of i)for(let _=0,x=f.length,v=x-1;_<x;v=_++){const w=f[v],I=f[_];for(const E of e)for(let C=0,P=E.length,L=P-1;C<P;L=C++){const U=E[L],Q=E[C];if(Fa(w,I,U,Q))return 0;d=Math.min(d,Un(w,I,U,Q,r))}}return d}function ne(i,e,r,a,l,h){if(!h)return;const d=jn(On(a,h),l,r);d<e&&i.push([d,h,[0,0]])}function Kr(i,e,r,a,l,h,d){if(!h||!d)return;const f=jn(On(a,h),On(l,d),r);f<e&&i.push([f,h,d])}function sa(i,e,r,a,l=1/0){let h=Math.min(a.distance(i[0],r[0][0]),l);if(h===0)return h;const d=new Go([[0,[0,i.length-1],[0,0]]],Jo),f=Vn(r);for(;d.length>0;){const _=d.pop();if(_[0]>=h)continue;const x=_[1],v=e?50:100;if(Oa(x)<=v){if(!_r(x,i.length))return NaN;if(e){const w=qt(i,x,r,a);if(isNaN(w)||w===0)return w;h=Math.min(h,w)}else for(let w=x[0];w<=x[1];++w){const I=tc(i[w],r,a);if(h=Math.min(h,I),h===0)return 0}}else{const w=Ln(x,e);ne(d,h,a,i,f,w[0]),ne(d,h,a,i,f,w[1])}}return h}function aa(i,e,r,a,l,h=1/0){let d=Math.min(h,l.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],v=_[2],w=e?50:100,I=a?50:100;if(Oa(x)<=w&&Oa(v)<=I){if(!_r(x,i.length)&&_r(v,r.length))return NaN;let E;if(e&&a)E=Ql(i,x,r,v,l),d=Math.min(d,E);else if(e&&!a){const C=i.slice(x[0],x[1]+1);for(let P=v[0];P<=v[1];++P)if(E=Wr(r[P],C,l),d=Math.min(d,E),d===0)return d}else if(!e&&a){const C=r.slice(v[0],v[1]+1);for(let P=x[0];P<=x[1];++P)if(E=Wr(i[P],C,l),d=Math.min(d,E),d===0)return d}else E=be(i,x,r,v,l),d=Math.min(d,E)}else{const E=Ln(x,e),C=Ln(v,a);Kr(f,d,l,i,r,E[0],C[0]),Kr(f,d,l,i,r,E[0],C[1]),Kr(f,d,l,i,r,E[1],C[0]),Kr(f,d,l,i,r,E[1],C[1])}}return d}function $n(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 Jr{constructor(e,r){this.type=_t,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(Zr(e[1])){const a=e[1];if(a.type==="FeatureCollection")return new Jr(a,a.features.map((l=>$n(l.geometry))).flat());if(a.type==="Feature")return new Jr(a,$n(a.geometry));if("type"in a&&"coordinates"in a)return new Jr(a,$n(a))}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,a){const l=r.geometry(),h=l.flat().map((_=>Rn([_.x,_.y],r.canonical)));if(l.length===0)return NaN;const d=new Fn(h[0][1]);let f=1/0;for(const _ of a){switch(_.type){case"Point":f=Math.min(f,aa(h,!1,[_.coordinates],!1,d,f));break;case"LineString":f=Math.min(f,aa(h,!1,_.coordinates,!0,d,f));break;case"Polygon":f=Math.min(f,sa(h,!1,_.coordinates,d,f))}if(f===0)return f}return f})(e,this.geometries);if(e.geometryType()==="LineString")return(function(r,a){const l=r.geometry(),h=l.flat().map((_=>Rn([_.x,_.y],r.canonical)));if(l.length===0)return NaN;const d=new Fn(h[0][1]);let f=1/0;for(const _ of a){switch(_.type){case"Point":f=Math.min(f,aa(h,!0,[_.coordinates],!1,d,f));break;case"LineString":f=Math.min(f,aa(h,!0,_.coordinates,!0,d,f));break;case"Polygon":f=Math.min(f,sa(h,!0,_.coordinates,d,f))}if(f===0)return f}return f})(e,this.geometries);if(e.geometryType()==="Polygon")return(function(r,a){const l=r.geometry();if(l.length===0||l[0].length===0)return NaN;const h=La(l,0).map((_=>_.map((x=>x.map((v=>Rn([v.x,v.y],r.canonical))))))),d=new Fn(h[0][0][0][1]);let f=1/0;for(const _ of a)for(const x of h){switch(_.type){case"Point":f=Math.min(f,sa([_.coordinates],!1,x,d,f));break;case"LineString":f=Math.min(f,sa(_.coordinates,!0,x,d,f));break;case"Polygon":f=Math.min(f,ue(x,_.coordinates,d,f))}if(f===0)return f}return f})(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}const ys={"==":$l,"!=":Lo,">":Nl,"<":Oo,">=":Vo,"<=":Zl,array:Li,at:En,boolean:Li,case:Ca,coalesce:Da,collator:ia,format:Ba,image:An,in:zn,"index-of":fs,interpolate:ri,"interpolate-hcl":ri,"interpolate-lab":ri,length:Dn,let:zr,literal:Fi,match:Cn,number:Li,"number-format":Pn,object:Li,slice:ta,step:ms,string:Li,"to-boolean":Oi,"to-color":Oi,"to-number":Oi,"to-string":Oi,var:ee,within:Hr,distance:Jr};class Ti{constructor(e,r,a,l){this.name=e,this.type=r,this._evaluate=a,this.args=l}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,r){const a=e[0],l=Ti.definitions[a];if(!l)return r.error(`Unknown expression "${a}". If you wanted a literal array, use ["literal", [...]].`,0);const h=Array.isArray(l)?l[0]:l.type,d=Array.isArray(l)?[[l[1],l[2]]]:l.overloads,f=d.filter((([x])=>!Array.isArray(x)||x.length===e.length-1));let _=null;for(const[x,v]of f){_=new qr(r.registry,na,r.path,null,r.scope);const w=[];let I=!1;for(let E=1;E<e.length;E++){const C=e[E],P=Array.isArray(x)?x[E-1]:x.type,L=_.parse(C,1+w.length,P);if(!L){I=!0;break}w.push(L)}if(!I)if(Array.isArray(x)&&x.length!==w.length)_.error(`Expected ${x.length} arguments, but found ${w.length} instead.`);else{for(let E=0;E<w.length;E++){const C=Array.isArray(x)?x[E]:x.type,P=w[E];_.concat(E+1).checkSubtype(C,P.type)}if(_.errors.length===0)return new Ti(a,h,v,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(k).join(", ")})`:`(${k(I.type)}...)`;var I})).join(" | "),v=[];for(let w=1;w<e.length;w++){const I=r.parse(e[w],1+v.length);if(!I)return null;v.push(k(I.type))}r.error(`Expected arguments of type ${x}, but found (${v.join(", ")}) instead.`)}return null}static register(e,r){Ti.definitions=r;for(const a in r)e[a]=Ti}}function Nn(i,[e,r,a,l]){e=e.evaluate(i),r=r.evaluate(i),a=a.evaluate(i);const h=l?l.evaluate(i):1,d=ps(e,r,a,h);if(d)throw new Se(d);return new se(e/255,r/255,a/255,h,!1)}function Zn(i,e){return i in e}function qn(i,e){const r=e[i];return r===void 0?null:r}function Yr(i){return{type:i}}function na(i){if(i instanceof ee)return na(i.boundExpression);if(i instanceof Ti&&i.name==="error"||i instanceof ia||i instanceof Hr||i instanceof Jr)return!1;const e=i instanceof Oi||i instanceof Li;let r=!0;return i.eachChild((a=>{r=e?r&&na(a):r&&a instanceof Fi})),!!r&&oa(i)&&la(i,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function oa(i){if(i instanceof Ti&&(i.name==="get"&&i.args.length===1||i.name==="feature-state"||i.name==="has"&&i.args.length===1||i.name==="properties"||i.name==="geometry-type"||i.name==="id"||/^filter-/.test(i.name))||i instanceof Hr||i instanceof Jr)return!1;let e=!0;return i.eachChild((r=>{e&&!oa(r)&&(e=!1)})),e}function xs(i){if(i instanceof Ti&&i.name==="feature-state")return!1;let e=!0;return i.eachChild((r=>{e&&!xs(r)&&(e=!1)})),e}function la(i,e){if(i instanceof Ti&&e.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild((a=>{r&&!la(a,e)&&(r=!1)})),r}function Ua(i){return{result:"success",value:i}}function vs(i){return{result:"error",value:i}}function bs(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function Yo(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function Gn(i){return!!i.expression&&i.expression.interpolated}function Yt(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":i===null?"null":typeof i}function $a(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function ec(i){return i}function Qo(i,e){const r=e.type==="color",a=i.stops&&typeof i.stops[0][0]=="object",l=a||!(a||i.property!==void 0),h=i.type||(Gn(e)?"exponential":"interval");if(r||e.type==="padding"){const v=r?se.parse:pi.parse;(i=tr({},i)).stops&&(i.stops=i.stops.map((w=>[w[0],v(w[1])]))),i.default=v(i.default?i.default:e.default)}if(i.colorSpace&&(d=i.colorSpace)!=="rgb"&&d!=="hcl"&&d!=="lab")throw new Error(`Unknown color space: "${i.colorSpace}"`);var d;let f,_,x;if(h==="exponential")f=el;else if(h==="interval")f=Na;else if(h==="categorical"){f=tl,_=Object.create(null);for(const v of i.stops)_[v[0]]=v[1];x=typeof i.stops[0][0]}else{if(h!=="identity")throw new Error(`Unknown function type "${h}"`);f=il}if(a){const v={},w=[];for(let C=0;C<i.stops.length;C++){const P=i.stops[C],L=P[0].zoom;v[L]===void 0&&(v[L]={zoom:L,type:i.type,property:i.property,default:i.default,stops:[]},w.push(L)),v[L].stops.push([P[0].value,P[1]])}const I=[];for(const C of w)I.push([v[C].zoom,Qo(v[C],e)]);const E={name:"linear"};return{kind:"composite",interpolationType:E,interpolationFactor:ri.interpolationFactor.bind(void 0,E),zoomStops:I.map((C=>C[0])),evaluate:({zoom:C},P)=>el({stops:I,base:i.base},e,C).evaluate(C,P)}}if(l){const v=h==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:v,interpolationFactor:ri.interpolationFactor.bind(void 0,v),zoomStops:i.stops.map((w=>w[0])),evaluate:({zoom:w})=>f(i,e,w,_,x)}}return{kind:"source",evaluate(v,w){const I=w&&w.properties?w.properties[i.property]:void 0;return I===void 0?ws(i.default,e.default):f(i,e,I,_,x)}}}function ws(i,e,r){return i!==void 0?i:e!==void 0?e:r!==void 0?r:void 0}function tl(i,e,r,a,l){return ws(typeof r===l?a[r]:void 0,i.default,e.default)}function Na(i,e,r){if(Yt(r)!=="number")return ws(i.default,e.default);const a=i.stops.length;if(a===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[a-1][0])return i.stops[a-1][1];const l=Pa(i.stops.map((h=>h[0])),r);return i.stops[l][1]}function el(i,e,r){const a=i.base!==void 0?i.base:1;if(Yt(r)!=="number")return ws(i.default,e.default);const l=i.stops.length;if(l===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[l-1][0])return i.stops[l-1][1];const h=Pa(i.stops.map((v=>v[0])),r),d=(function(v,w,I,E){const C=E-I,P=v-I;return C===0?0:w===1?P/C:(Math.pow(w,P)-1)/(Math.pow(w,C)-1)})(r,a,i.stops[h][0],i.stops[h+1][0]),f=i.stops[h][1],_=i.stops[h+1][1],x=ii[e.type]||ec;return typeof f.evaluate=="function"?{evaluate(...v){const w=f.evaluate.apply(void 0,v),I=_.evaluate.apply(void 0,v);if(w!==void 0&&I!==void 0)return x(w,I,d,i.colorSpace)}}:x(f,_,d,i.colorSpace)}function il(i,e,r){switch(e.type){case"color":r=se.parse(r);break;case"formatted":r=di.fromString(r.toString());break;case"resolvedImage":r=fi.fromString(r.toString());break;case"padding":r=pi.parse(r);break;default:Yt(r)===e.type||e.type==="enum"&&e.values[r]||(r=void 0)}return ws(r,i.default,e.default)}Ti.register(ys,{error:[{kind:"error"},[Nt],(i,[e])=>{throw new Se(e.evaluate(i))}],typeof:[Nt,[jt],(i,[e])=>k(Me(e.evaluate(i)))],"to-rgba":[M(_t,4),[ei],(i,[e])=>{const[r,a,l,h]=e.evaluate(i).rgb;return[255*r,255*a,255*l,h]}],rgb:[ei,[_t,_t,_t],Nn],rgba:[ei,[_t,_t,_t,_t],Nn],has:{type:Ft,overloads:[[[Nt],(i,[e])=>Zn(e.evaluate(i),i.properties())],[[Nt,Bi],(i,[e,r])=>Zn(e.evaluate(i),r.evaluate(i))]]},get:{type:jt,overloads:[[[Nt],(i,[e])=>qn(e.evaluate(i),i.properties())],[[Nt,Bi],(i,[e,r])=>qn(e.evaluate(i),r.evaluate(i))]]},"feature-state":[jt,[Nt],(i,[e])=>qn(e.evaluate(i),i.featureState||{})],properties:[Bi,[],i=>i.properties()],"geometry-type":[Nt,[],i=>i.geometryType()],id:[jt,[],i=>i.id()],zoom:[_t,[],i=>i.globals.zoom],"heatmap-density":[_t,[],i=>i.globals.heatmapDensity||0],"line-progress":[_t,[],i=>i.globals.lineProgress||0],accumulated:[jt,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[_t,Yr(_t),(i,e)=>{let r=0;for(const a of e)r+=a.evaluate(i);return r}],"*":[_t,Yr(_t),(i,e)=>{let r=1;for(const a of e)r*=a.evaluate(i);return r}],"-":{type:_t,overloads:[[[_t,_t],(i,[e,r])=>e.evaluate(i)-r.evaluate(i)],[[_t],(i,[e])=>-e.evaluate(i)]]},"/":[_t,[_t,_t],(i,[e,r])=>e.evaluate(i)/r.evaluate(i)],"%":[_t,[_t,_t],(i,[e,r])=>e.evaluate(i)%r.evaluate(i)],ln2:[_t,[],()=>Math.LN2],pi:[_t,[],()=>Math.PI],e:[_t,[],()=>Math.E],"^":[_t,[_t,_t],(i,[e,r])=>Math.pow(e.evaluate(i),r.evaluate(i))],sqrt:[_t,[_t],(i,[e])=>Math.sqrt(e.evaluate(i))],log10:[_t,[_t],(i,[e])=>Math.log(e.evaluate(i))/Math.LN10],ln:[_t,[_t],(i,[e])=>Math.log(e.evaluate(i))],log2:[_t,[_t],(i,[e])=>Math.log(e.evaluate(i))/Math.LN2],sin:[_t,[_t],(i,[e])=>Math.sin(e.evaluate(i))],cos:[_t,[_t],(i,[e])=>Math.cos(e.evaluate(i))],tan:[_t,[_t],(i,[e])=>Math.tan(e.evaluate(i))],asin:[_t,[_t],(i,[e])=>Math.asin(e.evaluate(i))],acos:[_t,[_t],(i,[e])=>Math.acos(e.evaluate(i))],atan:[_t,[_t],(i,[e])=>Math.atan(e.evaluate(i))],min:[_t,Yr(_t),(i,e)=>Math.min(...e.map((r=>r.evaluate(i))))],max:[_t,Yr(_t),(i,e)=>Math.max(...e.map((r=>r.evaluate(i))))],abs:[_t,[_t],(i,[e])=>Math.abs(e.evaluate(i))],round:[_t,[_t],(i,[e])=>{const r=e.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[_t,[_t],(i,[e])=>Math.floor(e.evaluate(i))],ceil:[_t,[_t],(i,[e])=>Math.ceil(e.evaluate(i))],"filter-==":[Ft,[Nt,jt],(i,[e,r])=>i.properties()[e.value]===r.value],"filter-id-==":[Ft,[jt],(i,[e])=>i.id()===e.value],"filter-type-==":[Ft,[Nt],(i,[e])=>i.geometryType()===e.value],"filter-<":[Ft,[Nt,jt],(i,[e,r])=>{const a=i.properties()[e.value],l=r.value;return typeof a==typeof l&&a<l}],"filter-id-<":[Ft,[jt],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r<a}],"filter->":[Ft,[Nt,jt],(i,[e,r])=>{const a=i.properties()[e.value],l=r.value;return typeof a==typeof l&&a>l}],"filter-id->":[Ft,[jt],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r>a}],"filter-<=":[Ft,[Nt,jt],(i,[e,r])=>{const a=i.properties()[e.value],l=r.value;return typeof a==typeof l&&a<=l}],"filter-id-<=":[Ft,[jt],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r<=a}],"filter->=":[Ft,[Nt,jt],(i,[e,r])=>{const a=i.properties()[e.value],l=r.value;return typeof a==typeof l&&a>=l}],"filter-id->=":[Ft,[jt],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r>=a}],"filter-has":[Ft,[jt],(i,[e])=>e.value in i.properties()],"filter-has-id":[Ft,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[Ft,[M(Nt)],(i,[e])=>e.value.indexOf(i.geometryType())>=0],"filter-id-in":[Ft,[M(jt)],(i,[e])=>e.value.indexOf(i.id())>=0],"filter-in-small":[Ft,[Nt,M(jt)],(i,[e,r])=>r.value.indexOf(i.properties()[e.value])>=0],"filter-in-large":[Ft,[Nt,M(jt)],(i,[e,r])=>(function(a,l,h,d){for(;h<=d;){const f=h+d>>1;if(l[f]===a)return!0;l[f]>a?d=f-1:h=f+1}return!1})(i.properties()[e.value],r.value,0,r.value.length-1)],all:{type:Ft,overloads:[[[Ft,Ft],(i,[e,r])=>e.evaluate(i)&&r.evaluate(i)],[Yr(Ft),(i,e)=>{for(const r of e)if(!r.evaluate(i))return!1;return!0}]]},any:{type:Ft,overloads:[[[Ft,Ft],(i,[e,r])=>e.evaluate(i)||r.evaluate(i)],[Yr(Ft),(i,e)=>{for(const r of e)if(r.evaluate(i))return!0;return!1}]]},"!":[Ft,[Ft],(i,[e])=>!e.evaluate(i)],"is-supported-script":[Ft,[Nt],(i,[e])=>{const r=i.globals&&i.globals.isSupportedScript;return!r||r(e.evaluate(i))}],upcase:[Nt,[Nt],(i,[e])=>e.evaluate(i).toUpperCase()],downcase:[Nt,[Nt],(i,[e])=>e.evaluate(i).toLowerCase()],concat:[Nt,Yr(jt),(i,e)=>e.map((r=>Qs(r.evaluate(i)))).join("")],"resolved-locale":[Nt,[ir],(i,[e])=>e.evaluate(i).resolvedLocale()]});class Za{constructor(e,r){var a;this.expression=e,this._warningHistory={},this._evaluator=new za,this._defaultValue=r?(a=r).type==="color"&&$a(a.default)?new se(0,0,0,0):a.type==="color"?se.parse(a.default)||null:a.type==="padding"?pi.parse(a.default)||null:a.type==="variableAnchorOffsetCollection"?wi.parse(a.default)||null:a.default===void 0?null:a.default:null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(e,r,a,l,h,d){return this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=a,this._evaluator.canonical=l,this._evaluator.availableImages=h||null,this._evaluator.formattedSection=d,this.expression.evaluate(this._evaluator)}evaluate(e,r,a,l,h,d){this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=a||null,this._evaluator.canonical=l,this._evaluator.availableImages=h||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 Se(`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 qa(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in ys}function Ts(i,e){const r=new qr(ys,na,[],e?(function(l){const h={color:ei,string:Nt,number:_t,enum:Nt,boolean:Ft,formatted:mr,padding:Er,resolvedImage:rr,variableAnchorOffsetCollection:j};return l.type==="array"?M(h[l.value]||jt,l.length):h[l.type]})(e):void 0),a=r.parse(i,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return a?Ua(new Za(a,e)):vs(r.errors)}class Ss{constructor(e,r){this.kind=e,this._styleExpression=r,this.isStateDependent=e!=="constant"&&!xs(r.expression)}evaluateWithoutErrorHandling(e,r,a,l,h,d){return this._styleExpression.evaluateWithoutErrorHandling(e,r,a,l,h,d)}evaluate(e,r,a,l,h,d){return this._styleExpression.evaluate(e,r,a,l,h,d)}}class Is{constructor(e,r,a,l){this.kind=e,this.zoomStops=a,this._styleExpression=r,this.isStateDependent=e!=="camera"&&!xs(r.expression),this.interpolationType=l}evaluateWithoutErrorHandling(e,r,a,l,h,d){return this._styleExpression.evaluateWithoutErrorHandling(e,r,a,l,h,d)}evaluate(e,r,a,l,h,d){return this._styleExpression.evaluate(e,r,a,l,h,d)}interpolationFactor(e,r,a){return this.interpolationType?ri.interpolationFactor(this.interpolationType,e,r,a):0}}function Xn(i,e){const r=Ts(i,e);if(r.result==="error")return r;const a=r.value.expression,l=oa(a);if(!l&&!bs(e))return vs([new He("","data expressions not supported")]);const h=la(a,["zoom"]);if(!h&&!Yo(e))return vs([new He("","zoom expressions not supported")]);const d=ca(a);return d||h?d instanceof He?vs([d]):d instanceof ri&&!Gn(e)?vs([new He("",'"interpolate" expressions cannot be used with this property')]):Ua(d?new Is(l?"camera":"composite",r.value,d.labels,d instanceof ri?d.interpolation:void 0):new Ss(l?"constant":"source",r.value)):vs([new He("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class ks{constructor(e,r){this._parameters=e,this._specification=r,tr(this,Qo(this._parameters,this._specification))}static deserialize(e){return new ks(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function ca(i){let e=null;if(i instanceof zr)e=ca(i.result);else if(i instanceof Da){for(const r of i.args)if(e=ca(r),e)break}else(i instanceof ms||i instanceof ri)&&i.input instanceof Ti&&i.input.name==="zoom"&&(e=i);return e instanceof He||i.eachChild((r=>{const a=ca(r);a instanceof He?e=a:!e&&a?e=new He("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&a&&e!==a&&(e=new He("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function Ga(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(!Ga(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}const Xa={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Hn(i){if(i==null)return{filter:()=>!0,needGeometry:!1};Ga(i)||(i=Ha(i));const e=Ts(i,Xa);if(e.result==="error")throw new Error(e.value.map((r=>`${r.key}: ${r.message}`)).join(", "));return{filter:(r,a,l)=>e.value.evaluate(r,a,{},l),needGeometry:rl(i)}}function ic(i,e){return i<e?-1:i>e?1:0}function rl(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(rl(i[e]))return!0;return!1}function Ha(i){if(!i)return!0;const e=i[0];return i.length<=1?e!=="any":e==="=="?Wn(i[1],i[2],"=="):e==="!="?Oe(Wn(i[1],i[2],"==")):e==="<"||e===">"||e==="<="||e===">="?Wn(i[1],i[2],e):e==="any"?(r=i.slice(1),["any"].concat(r.map(Ha))):e==="all"?["all"].concat(i.slice(1).map(Ha)):e==="none"?["all"].concat(i.slice(1).map(Ha).map(Oe)):e==="in"?ua(i[1],i.slice(2)):e==="!in"?Oe(ua(i[1],i.slice(2))):e==="has"?ha(i[1]):e!=="!has"||Oe(ha(i[1]));var r}function Wn(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 ua(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(ic)]]:["filter-in-small",i,["literal",e]]}}function ha(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function Oe(i){return["!",i]}function Qr(i){const e=typeof i;if(e==="number"||e==="boolean"||e==="string"||i==null)return JSON.stringify(i);if(Array.isArray(i)){let l="[";for(const h of i)l+=`${Qr(h)},`;return`${l}]`}const r=Object.keys(i).sort();let a="{";for(let l=0;l<r.length;l++)a+=`${JSON.stringify(r[l])}:${Qr(i[r[l]])},`;return`${a}}`}function sl(i){let e="";for(const r of Nr)e+=`/${Qr(i[r])}`;return e}function al(i){const e=i.value;return e?[new ht(i.key,e,"constants have been deprecated as of v8")]:[]}function we(i){return i instanceof Number||i instanceof String||i instanceof Boolean?i.valueOf():i}function Vi(i){if(Array.isArray(i))return i.map(Vi);if(i instanceof Object&&!(i instanceof Number||i instanceof String||i instanceof Boolean)){const e={};for(const r in i)e[r]=Vi(i[r]);return e}return we(i)}function mi(i){const e=i.key,r=i.value,a=i.valueSpec||{},l=i.objectElementValidators||{},h=i.style,d=i.styleSpec,f=i.validateSpec;let _=[];const x=Yt(r);if(x!=="object")return[new ht(e,r,`object expected, ${x} found`)];for(const v in r){const w=v.split(".")[0],I=a[w]||a["*"];let E;if(l[w])E=l[w];else if(a[w])E=f;else if(l["*"])E=l["*"];else{if(!a["*"]){_.push(new ht(e,r[v],`unknown property "${v}"`));continue}E=f}_=_.concat(E({key:(e&&`${e}.`)+v,value:r[v],valueSpec:I,style:h,styleSpec:d,object:r,objectKey:v,validateSpec:f},r))}for(const v in a)l[v]||a[v].required&&a[v].default===void 0&&r[v]===void 0&&_.push(new ht(e,r,`missing required property "${v}"`));return _}function da(i){const e=i.value,r=i.valueSpec,a=i.style,l=i.styleSpec,h=i.key,d=i.arrayElementValidator||i.validateSpec;if(Yt(e)!=="array")return[new ht(h,e,`array expected, ${Yt(e)} found`)];if(r.length&&e.length!==r.length)return[new ht(h,e,`array length ${r.length} expected, length ${e.length} found`)];if(r["min-length"]&&e.length<r["min-length"])return[new ht(h,e,`array length at least ${r["min-length"]} expected, length ${e.length} found`)];let f={type:r.value,values:r.values};l.$version<7&&(f.function=r.function),Yt(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:a,styleSpec:l,key:`${h}[${x}]`}));return _}function Kn(i){const e=i.key,r=i.value,a=i.valueSpec;let l=Yt(r);return l==="number"&&r!=r&&(l="NaN"),l!=="number"?[new ht(e,r,`number expected, ${l} found`)]:"minimum"in a&&r<a.minimum?[new ht(e,r,`${r} is less than the minimum value ${a.minimum}`)]:"maximum"in a&&r>a.maximum?[new ht(e,r,`${r} is greater than the maximum value ${a.maximum}`)]:[]}function Wa(i){const e=i.valueSpec,r=we(i.value.type);let a,l,h,d={};const f=r!=="categorical"&&i.value.property===void 0,_=!f,x=Yt(i.value.stops)==="array"&&Yt(i.value.stops[0])==="array"&&Yt(i.value.stops[0][0])==="object",v=mi({key:i.key,value:i.value,valueSpec:i.styleSpec.function,validateSpec:i.validateSpec,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(E){if(r==="identity")return[new ht(E.key,E.value,'identity function may not have a "stops" property')];let C=[];const P=E.value;return C=C.concat(da({key:E.key,value:P,valueSpec:E.valueSpec,validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec,arrayElementValidator:w})),Yt(P)==="array"&&P.length===0&&C.push(new ht(E.key,P,"array must have at least one stop")),C},default:function(E){return E.validateSpec({key:E.key,value:E.value,valueSpec:e,validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec})}}});return r==="identity"&&f&&v.push(new ht(i.key,i.value,'missing required property "property"')),r==="identity"||i.value.stops||v.push(new ht(i.key,i.value,'missing required property "stops"')),r==="exponential"&&i.valueSpec.expression&&!Gn(i.valueSpec)&&v.push(new ht(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(_&&!bs(i.valueSpec)?v.push(new ht(i.key,i.value,"property functions not supported")):f&&!Yo(i.valueSpec)&&v.push(new ht(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!x||i.value.property!==void 0||v.push(new ht(i.key,i.value,'"property" property is required')),v;function w(E){let C=[];const P=E.value,L=E.key;if(Yt(P)!=="array")return[new ht(L,P,`array expected, ${Yt(P)} found`)];if(P.length!==2)return[new ht(L,P,`array length 2 expected, length ${P.length} found`)];if(x){if(Yt(P[0])!=="object")return[new ht(L,P,`object expected, ${Yt(P[0])} found`)];if(P[0].zoom===void 0)return[new ht(L,P,"object stop key must have zoom")];if(P[0].value===void 0)return[new ht(L,P,"object stop key must have value")];if(h&&h>we(P[0].zoom))return[new ht(L,P[0].zoom,"stop zoom values must appear in ascending order")];we(P[0].zoom)!==h&&(h=we(P[0].zoom),l=void 0,d={}),C=C.concat(mi({key:`${L}[0]`,value:P[0],valueSpec:{zoom:{}},validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec,objectElementValidators:{zoom:Kn,value:I}}))}else C=C.concat(I({key:`${L}[0]`,value:P[0],valueSpec:{},validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec},P));return qa(Vi(P[1]))?C.concat([new ht(`${L}[1]`,P[1],"expressions are not allowed in function stops.")]):C.concat(E.validateSpec({key:`${L}[1]`,value:P[1],valueSpec:e,validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec}))}function I(E,C){const P=Yt(E.value),L=we(E.value),U=E.value!==null?E.value:C;if(a){if(P!==a)return[new ht(E.key,U,`${P} stop domain type must match previous stop domain type ${a}`)]}else a=P;if(P!=="number"&&P!=="string"&&P!=="boolean")return[new ht(E.key,U,"stop domain value must be a number, string, or boolean")];if(P!=="number"&&r!=="categorical"){let Q=`number expected, ${P} found`;return bs(e)&&r===void 0&&(Q+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ht(E.key,U,Q)]}return r!=="categorical"||P!=="number"||isFinite(L)&&Math.floor(L)===L?r!=="categorical"&&P==="number"&&l!==void 0&&L<l?[new ht(E.key,U,"stop domain values must appear in ascending order")]:(l=L,r==="categorical"&&L in d?[new ht(E.key,U,"stop domain values must be unique")]:(d[L]=!0,[])):[new ht(E.key,U,`integer expected, found ${L}`)]}}function Ms(i){const e=(i.expressionContext==="property"?Xn:Ts)(Vi(i.value),i.valueSpec);if(e.result==="error")return e.value.map((a=>new ht(`${i.key}${a.key}`,i.value,a.message)));const r=e.value.expression||e.value._styleExpression.expression;if(i.expressionContext==="property"&&i.propertyKey==="text-font"&&!r.outputDefined())return[new ht(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"&&!xs(r))return[new ht(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter"&&!xs(r))return[new ht(i.key,i.value,'"feature-state" data expressions are not supported with filters.')];if(i.expressionContext&&i.expressionContext.indexOf("cluster")===0){if(!la(r,["zoom","feature-state"]))return[new ht(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(i.expressionContext==="cluster-initial"&&!oa(r))return[new ht(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function gr(i){const e=i.key,r=i.value,a=i.valueSpec,l=[];return Array.isArray(a.values)?a.values.indexOf(we(r))===-1&&l.push(new ht(e,r,`expected one of [${a.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(a.values).indexOf(we(r))===-1&&l.push(new ht(e,r,`expected one of [${Object.keys(a.values).join(", ")}], ${JSON.stringify(r)} found`)),l}function Jn(i){return Ga(Vi(i.value))?Ms(tr({},i,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Ka(i)}function Ka(i){const e=i.value,r=i.key;if(Yt(e)!=="array")return[new ht(r,e,`array expected, ${Yt(e)} found`)];const a=i.styleSpec;let l,h=[];if(e.length<1)return[new ht(r,e,"filter array must have at least 1 element")];switch(h=h.concat(gr({key:`${r}[0]`,value:e[0],valueSpec:a.filter_operator,style:i.style,styleSpec:i.styleSpec})),we(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&we(e[1])==="$type"&&h.push(new ht(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&h.push(new ht(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(l=Yt(e[1]),l!=="string"&&h.push(new ht(`${r}[1]`,e[1],`string expected, ${l} found`)));for(let d=2;d<e.length;d++)l=Yt(e[d]),we(e[1])==="$type"?h=h.concat(gr({key:`${r}[${d}]`,value:e[d],valueSpec:a.geometry_type,style:i.style,styleSpec:i.styleSpec})):l!=="string"&&l!=="number"&&l!=="boolean"&&h.push(new ht(`${r}[${d}]`,e[d],`string, number, or boolean expected, ${l} found`));break;case"any":case"all":case"none":for(let d=1;d<e.length;d++)h=h.concat(Ka({key:`${r}[${d}]`,value:e[d],style:i.style,styleSpec:i.styleSpec}));break;case"has":case"!has":l=Yt(e[1]),e.length!==2?h.push(new ht(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):l!=="string"&&h.push(new ht(`${r}[1]`,e[1],`string expected, ${l} found`))}return h}function Yn(i,e){const r=i.key,a=i.validateSpec,l=i.style,h=i.styleSpec,d=i.value,f=i.objectKey,_=h[`${e}_${i.layerType}`];if(!_)return[];const x=f.match(/^(.*)-transition$/);if(e==="paint"&&x&&_[x[1]]&&_[x[1]].transition)return a({key:r,value:d,valueSpec:h.transition,style:l,styleSpec:h});const v=i.valueSpec||_[f];if(!v)return[new ht(r,d,`unknown property "${f}"`)];let w;if(Yt(d)==="string"&&bs(v)&&!v.tokens&&(w=/^{([^}]+)}$/.exec(d)))return[new ht(r,d,`"${f}" does not support interpolation syntax
@@ -577,4 +577,4 @@ uniform ${T} ${S} u_${z};
577
577
  #endif
578
578
  `})),staticAttributes:n,staticUniforms:m}}class En{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,s,n,o,c,m,g,y,b){this.context=t;let T=this.boundPaintVertexBuffers.length!==o.length;for(let S=0;!T&&S<o.length;S++)this.boundPaintVertexBuffers[S]!==o[S]&&(T=!0);!this.vao||this.boundProgram!==s||this.boundLayoutVertexBuffer!==n||T||this.boundIndexBuffer!==c||this.boundVertexOffset!==m||this.boundDynamicVertexBuffer!==g||this.boundDynamicVertexBuffer2!==y||this.boundDynamicVertexBuffer3!==b?this.freshBind(s,n,o,c,m,g,y,b):(t.bindVertexArray.set(this.vao),g&&g.bind(),c&&c.dynamicDraw&&c.bind(),y&&y.bind(),b&&b.bind())}freshBind(t,s,n,o,c,m,g,y){const b=t.numAttributes,T=this.context,S=T.gl;this.vao&&this.destroy(),this.vao=T.createVertexArray(),T.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=s,this.boundPaintVertexBuffers=n,this.boundIndexBuffer=o,this.boundVertexOffset=c,this.boundDynamicVertexBuffer=m,this.boundDynamicVertexBuffer2=g,this.boundDynamicVertexBuffer3=y,s.enableAttributes(S,t);for(const z of n)z.enableAttributes(S,t);m&&m.enableAttributes(S,t),g&&g.enableAttributes(S,t),y&&y.enableAttributes(S,t),s.bind(),s.setVertexAttribPointers(S,t,c);for(const z of n)z.bind(),z.setVertexAttribPointers(S,t,c);m&&(m.bind(),m.setVertexAttribPointers(S,t,c)),o&&o.bind(),g&&(g.bind(),g.setVertexAttribPointers(S,t,c)),y&&(y.bind(),y.setVertexAttribPointers(S,t,c)),T.currentNumAttributes=b}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const zn=(u,t,s,n,o)=>({u_matrix:u,u_texture:0,u_ele_delta:t,u_fog_matrix:s,u_fog_color:n?n.properties.get("fog-color"):p.aM.white,u_fog_ground_blend:n?n.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:n?n.calculateFogBlendOpacity(o):0,u_horizon_color:n?n.properties.get("horizon-color"):p.aM.white,u_horizon_fog_blend:n?n.properties.get("horizon-fog-blend"):1});function fs(u){const t=[];for(let s=0;s<u.length;s++){if(u[s]===null)continue;const n=u[s].split(" ");t.push(n.pop())}return t}class Cn{constructor(t,s,n,o,c,m){const g=t.gl;this.program=g.createProgram();const y=fs(s.staticAttributes),b=n?n.getBinderAttributes():[],T=y.concat(b),S=zr.prelude.staticUniforms?fs(zr.prelude.staticUniforms):[],z=s.staticUniforms?fs(s.staticUniforms):[],A=n?n.getBinderUniforms():[],B=S.concat(z).concat(A),V=[];for(const tt of B)V.indexOf(tt)<0&&V.push(tt);const $=n?n.defines():[];c&&$.push("#define OVERDRAW_INSPECTOR;"),m&&$.push("#define TERRAIN3D;");const N=$.concat(zr.prelude.fragmentSource,s.fragmentSource).join(`
579
579
  `),q=$.concat(zr.prelude.vertexSource,s.vertexSource).join(`
580
- `),F=g.createShader(g.FRAGMENT_SHADER);if(g.isContextLost())return void(this.failedToCreate=!0);if(g.shaderSource(F,N),g.compileShader(F),!g.getShaderParameter(F,g.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${g.getShaderInfoLog(F)}`);g.attachShader(this.program,F);const H=g.createShader(g.VERTEX_SHADER);if(g.isContextLost())return void(this.failedToCreate=!0);if(g.shaderSource(H,q),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 K={};this.numAttributes=T.length;for(let tt=0;tt<this.numAttributes;tt++)T[tt]&&(g.bindAttribLocation(this.program,tt,T[tt]),this.attributes[T[tt]]=tt);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(F);for(let tt=0;tt<V.length;tt++){const ot=V[tt];if(ot&&!K[ot]){const ut=g.getUniformLocation(this.program,ot);ut&&(K[ot]=ut)}}this.fixedUniforms=o(t,K),this.terrainUniforms=((tt,ot)=>({u_depth:new p.aH(tt,ot.u_depth),u_terrain:new p.aH(tt,ot.u_terrain),u_terrain_dim:new p.aI(tt,ot.u_terrain_dim),u_terrain_matrix:new p.aJ(tt,ot.u_terrain_matrix),u_terrain_unpack:new p.aK(tt,ot.u_terrain_unpack),u_terrain_exaggeration:new p.aI(tt,ot.u_terrain_exaggeration)}))(t,K),this.binderUniforms=n?n.getUniforms(t,K):[]}draw(t,s,n,o,c,m,g,y,b,T,S,z,A,B,V,$,N,q){const F=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(n),t.setStencilMode(o),t.setColorMode(c),t.setCullFace(m),y){t.activeTexture.set(F.TEXTURE2),F.bindTexture(F.TEXTURE_2D,y.depthTexture),t.activeTexture.set(F.TEXTURE3),F.bindTexture(F.TEXTURE_2D,y.texture);for(const K in this.terrainUniforms)this.terrainUniforms[K].set(y[K])}for(const K in this.fixedUniforms)this.fixedUniforms[K].set(g[K]);V&&V.setUniforms(t,this.binderUniforms,A,{zoom:B});let H=0;switch(s){case F.LINES:H=2;break;case F.TRIANGLES:H=3;break;case F.LINE_STRIP:H=1}for(const K of z.get()){const tt=K.vaos||(K.vaos={});(tt[b]||(tt[b]=new En)).bind(t,this,T,V?V.getPaintVertexBuffers():[],S,K.vertexOffset,$,N,q),F.drawElements(s,K.primitiveLength*H,F.UNSIGNED_SHORT,K.primitiveOffset*H*2)}}}function Ca(u,t,s){const n=1/Gt(s,1,t.transform.tileZoom),o=Math.pow(2,s.tileID.overscaledZ),c=s.tileSize*Math.pow(2,t.transform.tileZoom)/o,m=c*(s.tileID.canonical.x+s.tileID.wrap*o),g=c*s.tileID.canonical.y;return{u_image:0,u_texsize:s.imageAtlasTexture.size,u_scale:[n,u.fromScale,u.toScale],u_fade:u.t,u_pixel_coord_upper:[m>>16,g>>16],u_pixel_coord_lower:[65535&m,65535&g]}}const ta=(u,t,s,n)=>{const o=t.style.light,c=o.properties.get("position"),m=[c.x,c.y,c.z],g=(function(){var b=new p.A(9);return p.A!=Float32Array&&(b[1]=0,b[2]=0,b[3]=0,b[5]=0,b[6]=0,b[7]=0),b[0]=1,b[4]=1,b[8]=1,b})();o.properties.get("anchor")==="viewport"&&(function(b,T){var S=Math.sin(T),z=Math.cos(T);b[0]=z,b[1]=S,b[2]=0,b[3]=-S,b[4]=z,b[5]=0,b[6]=0,b[7]=0,b[8]=1})(g,-t.transform.angle),(function(b,T,S){var z=T[0],A=T[1],B=T[2];b[0]=z*S[0]+A*S[3]+B*S[6],b[1]=z*S[1]+A*S[4]+B*S[7],b[2]=z*S[2]+A*S[5]+B*S[8]})(m,m,g);const y=o.properties.get("color");return{u_matrix:u,u_lightpos:m,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_vertical_gradient:+s,u_opacity:n}},Pa=(u,t,s,n,o,c,m)=>p.e(ta(u,t,s,n),Ca(c,t,m),{u_height_factor:-Math.pow(2,o.overscaledZ)/m.tileSize/8}),ms=u=>({u_matrix:u}),Ro=(u,t,s,n)=>p.e(ms(u),Ca(s,t,n)),jl=(u,t)=>({u_matrix:u,u_world:t}),Bo=(u,t,s,n,o)=>p.e(Ro(u,t,s,n),{u_world:o}),Ul=(u,t,s,n)=>{const o=u.transform;let c,m;if(n.paint.get("circle-pitch-alignment")==="map"){const g=Gt(s,1,o.zoom);c=!0,m=[g,g]}else c=!1,m=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+(n.paint.get("circle-pitch-scale")==="map"),u_matrix:u.translatePosMatrix(t.posMatrix,s,n.paint.get("circle-translate"),n.paint.get("circle-translate-anchor")),u_pitch_with_map:+c,u_device_pixel_ratio:u.pixelRatio,u_extrude_scale:m}},Gr=(u,t,s)=>({u_matrix:u,u_inv_matrix:t,u_camera_to_center_distance:s.cameraToCenterDistance,u_viewport_size:[s.width,s.height]}),ea=(u,t,s=1)=>({u_matrix:u,u_color:t,u_overlay:0,u_overlay_scale:s}),ii=u=>({u_matrix:u}),ri=(u,t,s,n)=>({u_matrix:u,u_extrude_scale:Gt(t,1,s),u_intensity:n}),Aa=(u,t,s,n)=>{const o=p.H();p.aP(o,0,u.width,u.height,0,0,1);const c=u.context.gl;return{u_matrix:o,u_world:[c.drawingBufferWidth,c.drawingBufferHeight],u_image:s,u_color_ramp:n,u_opacity:t.paint.get("heatmap-opacity")}};function Da(u,t){const s=Math.pow(2,t.canonical.z),n=t.canonical.y;return[new p.Z(0,n/s).toLngLat().lat,new p.Z(0,(n+1)/s).toLngLat().lat]}const Ra=(u,t,s,n)=>{const o=u.transform;return{u_matrix:Oo(u,t,s,n),u_ratio:1/Gt(t,1,o.zoom),u_device_pixel_ratio:u.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},Fo=(u,t,s,n,o)=>p.e(Ra(u,t,s,o),{u_image:0,u_image_height:n}),_s=(u,t,s,n,o)=>{const c=u.transform,m=Lo(t,c);return{u_matrix:Oo(u,t,s,o),u_texsize:t.imageAtlasTexture.size,u_ratio:1/Gt(t,1,c.zoom),u_device_pixel_ratio:u.pixelRatio,u_image:0,u_scale:[m,n.fromScale,n.toScale],u_fade:n.t,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]]}},$l=(u,t,s,n,o,c)=>{const m=u.lineAtlas,g=Lo(t,u.transform),y=s.layout.get("line-cap")==="round",b=m.getDash(n.from,y),T=m.getDash(n.to,y),S=b.width*o.fromScale,z=T.width*o.toScale;return p.e(Ra(u,t,s,c),{u_patternscale_a:[g/S,-b.height/2],u_patternscale_b:[g/z,-T.height/2],u_sdfgamma:m.width/(256*Math.min(S,z)*u.pixelRatio)/2,u_image:0,u_tex_y_a:b.y,u_tex_y_b:T.y,u_mix:o.t})};function Lo(u,t){return 1/Gt(u,1,t.tileZoom)}function Oo(u,t,s,n){return u.translatePosMatrix(n?n.posMatrix:t.tileID.posMatrix,t,s.paint.get("line-translate"),s.paint.get("line-translate-anchor"))}const Nl=(u,t,s,n,o)=>{return{u_matrix:u,u_tl_parent:t,u_scale_parent:s,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.opacity*o.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:o.paint.get("raster-brightness-min"),u_brightness_high:o.paint.get("raster-brightness-max"),u_saturation_factor:(m=o.paint.get("raster-saturation"),m>0?1-1/(1.001-m):-m),u_contrast_factor:(c=o.paint.get("raster-contrast"),c>0?1/(1-c):1+c),u_spin_weights:Zl(o.paint.get("raster-hue-rotate"))};var c,m};function Zl(u){u*=Math.PI/180;const t=Math.sin(u),s=Math.cos(u);return[(2*s+1)/3,(-Math.sqrt(3)*t-s+1)/3,(Math.sqrt(3)*t-s+1)/3]}const Vo=(u,t,s,n,o,c,m,g,y,b,T,S,z,A)=>{const B=m.transform;return{u_is_size_zoom_constant:+(u==="constant"||u==="source"),u_is_size_feature_constant:+(u==="constant"||u==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:B.cameraToCenterDistance,u_pitch:B.pitch/360*2*Math.PI,u_rotate_symbol:+s,u_aspect_ratio:B.width/B.height,u_fade_change:m.options.fadeDuration?m.symbolFadeChange:1,u_matrix:g,u_label_plane_matrix:y,u_coord_matrix:b,u_is_text:+S,u_pitch_with_map:+n,u_is_along_line:o,u_is_variable_anchor:c,u_texsize:z,u_texture:0,u_translation:T,u_pitched_scale:A}},ia=(u,t,s,n,o,c,m,g,y,b,T,S,z,A,B)=>{const V=m.transform;return p.e(Vo(u,t,s,n,o,c,m,g,y,b,T,S,z,B),{u_gamma_scale:n?Math.cos(V._pitch)*V.cameraToCenterDistance:1,u_device_pixel_ratio:m.pixelRatio,u_is_halo:+A})},Pn=(u,t,s,n,o,c,m,g,y,b,T,S,z,A)=>p.e(ia(u,t,s,n,o,c,m,g,y,b,T,!0,S,!0,A),{u_texsize_icon:z,u_texture_icon:1}),Ba=(u,t,s)=>({u_matrix:u,u_opacity:t,u_color:s}),An=(u,t,s,n,o,c)=>p.e((function(m,g,y,b){const T=y.imageManager.getPattern(m.from.toString()),S=y.imageManager.getPattern(m.to.toString()),{width:z,height:A}=y.imageManager.getPixelSize(),B=Math.pow(2,b.tileID.overscaledZ),V=b.tileSize*Math.pow(2,y.transform.tileZoom)/B,$=V*(b.tileID.canonical.x+b.tileID.wrap*B),N=V*b.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:T.tl,u_pattern_br_a:T.br,u_pattern_tl_b:S.tl,u_pattern_br_b:S.br,u_texsize:[z,A],u_mix:g.t,u_pattern_size_a:T.displaySize,u_pattern_size_b:S.displaySize,u_scale_a:g.fromScale,u_scale_b:g.toScale,u_tile_units_to_pixels:1/Gt(b,1,y.transform.tileZoom),u_pixel_coord_upper:[$>>16,N>>16],u_pixel_coord_lower:[65535&$,65535&N]}})(n,c,s,o),{u_matrix:u,u_opacity:t}),Dn={fillExtrusion:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_lightpos:new p.aN(u,t.u_lightpos),u_lightintensity:new p.aI(u,t.u_lightintensity),u_lightcolor:new p.aN(u,t.u_lightcolor),u_vertical_gradient:new p.aI(u,t.u_vertical_gradient),u_opacity:new p.aI(u,t.u_opacity)}),fillExtrusionPattern:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_lightpos:new p.aN(u,t.u_lightpos),u_lightintensity:new p.aI(u,t.u_lightintensity),u_lightcolor:new p.aN(u,t.u_lightcolor),u_vertical_gradient:new p.aI(u,t.u_vertical_gradient),u_height_factor:new p.aI(u,t.u_height_factor),u_image:new p.aH(u,t.u_image),u_texsize:new p.aO(u,t.u_texsize),u_pixel_coord_upper:new p.aO(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(u,t.u_pixel_coord_lower),u_scale:new p.aN(u,t.u_scale),u_fade:new p.aI(u,t.u_fade),u_opacity:new p.aI(u,t.u_opacity)}),fill:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix)}),fillPattern:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_image:new p.aH(u,t.u_image),u_texsize:new p.aO(u,t.u_texsize),u_pixel_coord_upper:new p.aO(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(u,t.u_pixel_coord_lower),u_scale:new p.aN(u,t.u_scale),u_fade:new p.aI(u,t.u_fade)}),fillOutline:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_world:new p.aO(u,t.u_world)}),fillOutlinePattern:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_world:new p.aO(u,t.u_world),u_image:new p.aH(u,t.u_image),u_texsize:new p.aO(u,t.u_texsize),u_pixel_coord_upper:new p.aO(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(u,t.u_pixel_coord_lower),u_scale:new p.aN(u,t.u_scale),u_fade:new p.aI(u,t.u_fade)}),circle:(u,t)=>({u_camera_to_center_distance:new p.aI(u,t.u_camera_to_center_distance),u_scale_with_map:new p.aH(u,t.u_scale_with_map),u_pitch_with_map:new p.aH(u,t.u_pitch_with_map),u_extrude_scale:new p.aO(u,t.u_extrude_scale),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_matrix:new p.aJ(u,t.u_matrix)}),collisionBox:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_pixel_extrude_scale:new p.aO(u,t.u_pixel_extrude_scale)}),collisionCircle:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_inv_matrix:new p.aJ(u,t.u_inv_matrix),u_camera_to_center_distance:new p.aI(u,t.u_camera_to_center_distance),u_viewport_size:new p.aO(u,t.u_viewport_size)}),debug:(u,t)=>({u_color:new p.aL(u,t.u_color),u_matrix:new p.aJ(u,t.u_matrix),u_overlay:new p.aH(u,t.u_overlay),u_overlay_scale:new p.aI(u,t.u_overlay_scale)}),clippingMask:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix)}),heatmap:(u,t)=>({u_extrude_scale:new p.aI(u,t.u_extrude_scale),u_intensity:new p.aI(u,t.u_intensity),u_matrix:new p.aJ(u,t.u_matrix)}),heatmapTexture:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_world:new p.aO(u,t.u_world),u_image:new p.aH(u,t.u_image),u_color_ramp:new p.aH(u,t.u_color_ramp),u_opacity:new p.aI(u,t.u_opacity)}),hillshade:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_image:new p.aH(u,t.u_image),u_latrange:new p.aO(u,t.u_latrange),u_light:new p.aO(u,t.u_light),u_shadow:new p.aL(u,t.u_shadow),u_highlight:new p.aL(u,t.u_highlight),u_accent:new p.aL(u,t.u_accent)}),hillshadePrepare:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_image:new p.aH(u,t.u_image),u_dimension:new p.aO(u,t.u_dimension),u_zoom:new p.aI(u,t.u_zoom),u_unpack:new p.aK(u,t.u_unpack)}),line:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_ratio:new p.aI(u,t.u_ratio),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_units_to_pixels:new p.aO(u,t.u_units_to_pixels)}),lineGradient:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_ratio:new p.aI(u,t.u_ratio),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_units_to_pixels:new p.aO(u,t.u_units_to_pixels),u_image:new p.aH(u,t.u_image),u_image_height:new p.aI(u,t.u_image_height)}),linePattern:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_texsize:new p.aO(u,t.u_texsize),u_ratio:new p.aI(u,t.u_ratio),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_image:new p.aH(u,t.u_image),u_units_to_pixels:new p.aO(u,t.u_units_to_pixels),u_scale:new p.aN(u,t.u_scale),u_fade:new p.aI(u,t.u_fade)}),lineSDF:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_ratio:new p.aI(u,t.u_ratio),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_units_to_pixels:new p.aO(u,t.u_units_to_pixels),u_patternscale_a:new p.aO(u,t.u_patternscale_a),u_patternscale_b:new p.aO(u,t.u_patternscale_b),u_sdfgamma:new p.aI(u,t.u_sdfgamma),u_image:new p.aH(u,t.u_image),u_tex_y_a:new p.aI(u,t.u_tex_y_a),u_tex_y_b:new p.aI(u,t.u_tex_y_b),u_mix:new p.aI(u,t.u_mix)}),raster:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_tl_parent:new p.aO(u,t.u_tl_parent),u_scale_parent:new p.aI(u,t.u_scale_parent),u_buffer_scale:new p.aI(u,t.u_buffer_scale),u_fade_t:new p.aI(u,t.u_fade_t),u_opacity:new p.aI(u,t.u_opacity),u_image0:new p.aH(u,t.u_image0),u_image1:new p.aH(u,t.u_image1),u_brightness_low:new p.aI(u,t.u_brightness_low),u_brightness_high:new p.aI(u,t.u_brightness_high),u_saturation_factor:new p.aI(u,t.u_saturation_factor),u_contrast_factor:new p.aI(u,t.u_contrast_factor),u_spin_weights:new p.aN(u,t.u_spin_weights)}),symbolIcon:(u,t)=>({u_is_size_zoom_constant:new p.aH(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(u,t.u_is_size_feature_constant),u_size_t:new p.aI(u,t.u_size_t),u_size:new p.aI(u,t.u_size),u_camera_to_center_distance:new p.aI(u,t.u_camera_to_center_distance),u_pitch:new p.aI(u,t.u_pitch),u_rotate_symbol:new p.aH(u,t.u_rotate_symbol),u_aspect_ratio:new p.aI(u,t.u_aspect_ratio),u_fade_change:new p.aI(u,t.u_fade_change),u_matrix:new p.aJ(u,t.u_matrix),u_label_plane_matrix:new p.aJ(u,t.u_label_plane_matrix),u_coord_matrix:new p.aJ(u,t.u_coord_matrix),u_is_text:new p.aH(u,t.u_is_text),u_pitch_with_map:new p.aH(u,t.u_pitch_with_map),u_is_along_line:new p.aH(u,t.u_is_along_line),u_is_variable_anchor:new p.aH(u,t.u_is_variable_anchor),u_texsize:new p.aO(u,t.u_texsize),u_texture:new p.aH(u,t.u_texture),u_translation:new p.aO(u,t.u_translation),u_pitched_scale:new p.aI(u,t.u_pitched_scale)}),symbolSDF:(u,t)=>({u_is_size_zoom_constant:new p.aH(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(u,t.u_is_size_feature_constant),u_size_t:new p.aI(u,t.u_size_t),u_size:new p.aI(u,t.u_size),u_camera_to_center_distance:new p.aI(u,t.u_camera_to_center_distance),u_pitch:new p.aI(u,t.u_pitch),u_rotate_symbol:new p.aH(u,t.u_rotate_symbol),u_aspect_ratio:new p.aI(u,t.u_aspect_ratio),u_fade_change:new p.aI(u,t.u_fade_change),u_matrix:new p.aJ(u,t.u_matrix),u_label_plane_matrix:new p.aJ(u,t.u_label_plane_matrix),u_coord_matrix:new p.aJ(u,t.u_coord_matrix),u_is_text:new p.aH(u,t.u_is_text),u_pitch_with_map:new p.aH(u,t.u_pitch_with_map),u_is_along_line:new p.aH(u,t.u_is_along_line),u_is_variable_anchor:new p.aH(u,t.u_is_variable_anchor),u_texsize:new p.aO(u,t.u_texsize),u_texture:new p.aH(u,t.u_texture),u_gamma_scale:new p.aI(u,t.u_gamma_scale),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_is_halo:new p.aH(u,t.u_is_halo),u_translation:new p.aO(u,t.u_translation),u_pitched_scale:new p.aI(u,t.u_pitched_scale)}),symbolTextAndIcon:(u,t)=>({u_is_size_zoom_constant:new p.aH(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(u,t.u_is_size_feature_constant),u_size_t:new p.aI(u,t.u_size_t),u_size:new p.aI(u,t.u_size),u_camera_to_center_distance:new p.aI(u,t.u_camera_to_center_distance),u_pitch:new p.aI(u,t.u_pitch),u_rotate_symbol:new p.aH(u,t.u_rotate_symbol),u_aspect_ratio:new p.aI(u,t.u_aspect_ratio),u_fade_change:new p.aI(u,t.u_fade_change),u_matrix:new p.aJ(u,t.u_matrix),u_label_plane_matrix:new p.aJ(u,t.u_label_plane_matrix),u_coord_matrix:new p.aJ(u,t.u_coord_matrix),u_is_text:new p.aH(u,t.u_is_text),u_pitch_with_map:new p.aH(u,t.u_pitch_with_map),u_is_along_line:new p.aH(u,t.u_is_along_line),u_is_variable_anchor:new p.aH(u,t.u_is_variable_anchor),u_texsize:new p.aO(u,t.u_texsize),u_texsize_icon:new p.aO(u,t.u_texsize_icon),u_texture:new p.aH(u,t.u_texture),u_texture_icon:new p.aH(u,t.u_texture_icon),u_gamma_scale:new p.aI(u,t.u_gamma_scale),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_is_halo:new p.aH(u,t.u_is_halo),u_translation:new p.aO(u,t.u_translation),u_pitched_scale:new p.aI(u,t.u_pitched_scale)}),background:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_opacity:new p.aI(u,t.u_opacity),u_color:new p.aL(u,t.u_color)}),backgroundPattern:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_opacity:new p.aI(u,t.u_opacity),u_image:new p.aH(u,t.u_image),u_pattern_tl_a:new p.aO(u,t.u_pattern_tl_a),u_pattern_br_a:new p.aO(u,t.u_pattern_br_a),u_pattern_tl_b:new p.aO(u,t.u_pattern_tl_b),u_pattern_br_b:new p.aO(u,t.u_pattern_br_b),u_texsize:new p.aO(u,t.u_texsize),u_mix:new p.aI(u,t.u_mix),u_pattern_size_a:new p.aO(u,t.u_pattern_size_a),u_pattern_size_b:new p.aO(u,t.u_pattern_size_b),u_scale_a:new p.aI(u,t.u_scale_a),u_scale_b:new p.aI(u,t.u_scale_b),u_pixel_coord_upper:new p.aO(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(u,t.u_pixel_coord_lower),u_tile_units_to_pixels:new p.aI(u,t.u_tile_units_to_pixels)}),terrain:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_texture:new p.aH(u,t.u_texture),u_ele_delta:new p.aI(u,t.u_ele_delta),u_fog_matrix:new p.aJ(u,t.u_fog_matrix),u_fog_color:new p.aL(u,t.u_fog_color),u_fog_ground_blend:new p.aI(u,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new p.aI(u,t.u_fog_ground_blend_opacity),u_horizon_color:new p.aL(u,t.u_horizon_color),u_horizon_fog_blend:new p.aI(u,t.u_horizon_fog_blend)}),terrainDepth:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_ele_delta:new p.aI(u,t.u_ele_delta)}),terrainCoords:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_texture:new p.aH(u,t.u_texture),u_terrain_coords_id:new p.aI(u,t.u_terrain_coords_id),u_ele_delta:new p.aI(u,t.u_ele_delta)}),sky:(u,t)=>({u_sky_color:new p.aL(u,t.u_sky_color),u_horizon_color:new p.aL(u,t.u_horizon_color),u_horizon:new p.aI(u,t.u_horizon),u_sky_horizon_blend:new p.aI(u,t.u_sky_horizon_blend)})};class sr{constructor(t,s,n){this.context=t;const o=t.gl;this.buffer=o.createBuffer(),this.dynamicDraw=!!n,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,s.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete s.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const s=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),s.bufferSubData(s.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const ql={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Rn{constructor(t,s,n,o){this.length=s.length,this.attributes=n,this.itemSize=s.bytesPerElement,this.dynamicDraw=o,this.context=t;const c=t.gl;this.buffer=c.createBuffer(),t.bindVertexBuffer.set(this.buffer),c.bufferData(c.ARRAY_BUFFER,s.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete s.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 s=this.context.gl;this.bind(),s.bufferSubData(s.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,s){for(let n=0;n<this.attributes.length;n++){const o=s.attributes[this.attributes[n].name];o!==void 0&&t.enableVertexAttribArray(o)}}setVertexAttribPointers(t,s,n){for(let o=0;o<this.attributes.length;o++){const c=this.attributes[o],m=s.attributes[c.name];m!==void 0&&t.vertexAttribPointer(m,c.components,t[ql[c.type]],!1,this.itemSize,c.offset+this.itemSize*(n||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Xr=new WeakMap;function Cr(u){var t;if(Xr.has(u))return Xr.get(u);{const s=(t=u.getParameter(u.VERSION))===null||t===void 0?void 0:t.startsWith("WebGL 2.0");return Xr.set(u,s),s}}class ie{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 Fa extends ie{getDefault(){return p.aM.transparent}set(t){const s=this.current;(t.r!==s.r||t.g!==s.g||t.b!==s.b||t.a!==s.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Gl extends ie{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class gs extends ie{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class Xl extends ie{getDefault(){return[!0,!0,!0,!0]}set(t){const s=this.current;(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||t[3]!==s[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class jo extends ie{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class Hl extends ie{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class Uo extends ie{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const s=this.current;(t.func!==s.func||t.ref!==s.ref||t.mask!==s.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class Bn extends ie{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const s=this.current;(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class $o extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;t?s.enable(s.STENCIL_TEST):s.disable(s.STENCIL_TEST),this.current=t,this.dirty=!1}}class No extends ie{getDefault(){return[0,1]}set(t){const s=this.current;(t[0]!==s[0]||t[1]!==s[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class Zo extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;t?s.enable(s.DEPTH_TEST):s.disable(s.DEPTH_TEST),this.current=t,this.dirty=!1}}class qo extends ie{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class Hr extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;t?s.enable(s.BLEND):s.disable(s.BLEND),this.current=t,this.dirty=!1}}class Go extends ie{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const s=this.current;(t[0]!==s[0]||t[1]!==s[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class Wl extends ie{getDefault(){return p.aM.transparent}set(t){const s=this.current;(t.r!==s.r||t.g!==s.g||t.b!==s.b||t.a!==s.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Xo extends ie{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class ra extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;t?s.enable(s.CULL_FACE):s.disable(s.CULL_FACE),this.current=t,this.dirty=!1}}class Kl extends ie{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class La extends ie{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class Jl extends ie{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Yl extends ie{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class Ho extends ie{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const s=this.current;(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||t[3]!==s[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Wo extends ie{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.bindFramebuffer(s.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Ko extends ie{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.bindRenderbuffer(s.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Fn extends ie{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.bindTexture(s.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class Jo extends ie{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.bindBuffer(s.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Oa extends ie{getDefault(){return null}set(t){const s=this.gl;s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class _r extends ie{getDefault(){return null}set(t){var s;if(t===this.current&&!this.dirty)return;const n=this.gl;Cr(n)?n.bindVertexArray(t):(s=n.getExtension("OES_vertex_array_object"))===null||s===void 0||s.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class Ln extends ie{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class On extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class Vn extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class Va extends ie{constructor(t,s){super(t),this.context=t,this.parent=s}getDefault(){return null}}class jn extends Va{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const s=this.gl;s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class Wr extends Va{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const s=this.gl;s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Un extends Va{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const s=this.gl;s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Ql{constructor(t,s,n,o,c){this.context=t,this.width=s,this.height=n;const m=t.gl,g=this.framebuffer=m.createFramebuffer();if(this.colorAttachment=new jn(t,g),o)this.depthAttachment=c?new Un(t,g):new Wr(t,g);else if(c)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,s=this.colorAttachment.get();if(s&&t.deleteTexture(s),this.depthAttachment){const n=this.depthAttachment.get();n&&t.deleteRenderbuffer(n)}t.deleteFramebuffer(this.framebuffer)}}class be{constructor(t,s,n){this.blendFunction=t,this.blendColor=s,this.mask=n}}be.Replace=[1,0],be.disabled=new be(be.Replace,p.aM.transparent,[!1,!1,!1,!1]),be.unblended=new be(be.Replace,p.aM.transparent,[!0,!0,!0,!0]),be.alphaBlended=new be([1,771],p.aM.transparent,[!0,!0,!0,!0]);class tc{constructor(t){var s,n;if(this.gl=t,this.clearColor=new Fa(this),this.clearDepth=new Gl(this),this.clearStencil=new gs(this),this.colorMask=new Xl(this),this.depthMask=new jo(this),this.stencilMask=new Hl(this),this.stencilFunc=new Uo(this),this.stencilOp=new Bn(this),this.stencilTest=new $o(this),this.depthRange=new No(this),this.depthTest=new Zo(this),this.depthFunc=new qo(this),this.blend=new Hr(this),this.blendFunc=new Go(this),this.blendColor=new Wl(this),this.blendEquation=new Xo(this),this.cullFace=new ra(this),this.cullFaceSide=new Kl(this),this.frontFace=new La(this),this.program=new Jl(this),this.activeTexture=new Yl(this),this.viewport=new Ho(this),this.bindFramebuffer=new Wo(this),this.bindRenderbuffer=new Ko(this),this.bindTexture=new Fn(this),this.bindVertexBuffer=new Jo(this),this.bindElementBuffer=new Oa(this),this.bindVertexArray=new _r(this),this.pixelStoreUnpack=new Ln(this),this.pixelStoreUnpackPremultiplyAlpha=new On(this),this.pixelStoreUnpackFlipY=new Vn(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),Cr(t)){this.HALF_FLOAT=t.HALF_FLOAT;const o=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(s=t.RGBA16F)!==null&&s!==void 0?s:o==null?void 0:o.RGBA16F_EXT,this.RGB16F=(n=t.RGB16F)!==null&&n!==void 0?n:o==null?void 0:o.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");const o=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=o==null?void 0:o.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,s){return new sr(this,t,s)}createVertexBuffer(t,s,n){return new Rn(this,t,s,n)}createRenderbuffer(t,s,n){const o=this.gl,c=o.createRenderbuffer();return this.bindRenderbuffer.set(c),o.renderbufferStorage(o.RENDERBUFFER,t,s,n),this.bindRenderbuffer.set(null),c}createFramebuffer(t,s,n,o){return new Ql(this,t,s,n,o)}clear({color:t,depth:s,stencil:n}){const o=this.gl;let c=0;t&&(c|=o.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),s!==void 0&&(c|=o.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(s),this.depthMask.set(!0)),n!==void 0&&(c|=o.STENCIL_BUFFER_BIT,this.clearStencil.set(n),this.stencilMask.set(255)),o.clear(c)}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.aE(t.blendFunction,be.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 Cr(this.gl)?this.gl.createVertexArray():(t=this.gl.getExtension("OES_vertex_array_object"))===null||t===void 0?void 0:t.createVertexArrayOES()}deleteVertexArray(t){var s;return Cr(this.gl)?this.gl.deleteVertexArray(t):(s=this.gl.getExtension("OES_vertex_array_object"))===null||s===void 0?void 0:s.deleteVertexArrayOES(t)}unbindVAO(){this.bindVertexArray.set(null)}}class qt{constructor(t,s,n){this.func=t,this.mask=s,this.range=n}}qt.ReadOnly=!1,qt.ReadWrite=!0,qt.disabled=new qt(519,qt.ReadOnly,[0,1]);const ja=7680;class ue{constructor(t,s,n,o,c,m){this.test=t,this.ref=s,this.mask=n,this.fail=o,this.depthFail=c,this.pass=m}}ue.disabled=new ue({func:519,mask:0},0,0,ja,ja,ja);class ne{constructor(t,s,n){this.enable=t,this.mode=s,this.frontFace=n}}let Kr;function sa(u,t,s,n,o){const c=u.context,m=c.gl,g=u.useProgram("collisionBox"),y=[];let b=0,T=0;for(let N=0;N<n.length;N++){const q=n[N],F=t.getTile(q).getBucket(s);if(!F)continue;const H=o?F.textCollisionBox:F.iconCollisionBox,K=F.collisionCircleArray;if(K.length>0){const tt=p.H();p.aQ(tt,F.placementInvProjMatrix,u.transform.glCoordMatrix),p.aQ(tt,tt,F.placementViewportMatrix),y.push({circleArray:K,circleOffset:T,transform:q.posMatrix,invTransform:tt,coord:q}),b+=K.length/4,T=b}H&&g.draw(c,m.LINES,qt.disabled,ue.disabled,u.colorModeForRenderPass(),ne.disabled,{u_matrix:q.posMatrix,u_pixel_extrude_scale:[1/(S=u.transform).width,1/S.height]},u.style.map.terrain&&u.style.map.terrain.getTerrainData(q),s.id,H.layoutVertexBuffer,H.indexBuffer,H.segments,null,u.transform.zoom,null,null,H.collisionVertexBuffer)}var S;if(!o||!y.length)return;const z=u.useProgram("collisionCircle"),A=new p.aR;A.resize(4*b),A._trim();let B=0;for(const N of y)for(let q=0;q<N.circleArray.length/4;q++){const F=4*q,H=N.circleArray[F+0],K=N.circleArray[F+1],tt=N.circleArray[F+2],ot=N.circleArray[F+3];A.emplace(B++,H,K,tt,ot,0),A.emplace(B++,H,K,tt,ot,1),A.emplace(B++,H,K,tt,ot,2),A.emplace(B++,H,K,tt,ot,3)}(!Kr||Kr.length<2*b)&&(Kr=(function(N){const q=2*N,F=new p.aT;F.resize(q),F._trim();for(let H=0;H<q;H++){const K=6*H;F.uint16[K+0]=4*H+0,F.uint16[K+1]=4*H+1,F.uint16[K+2]=4*H+2,F.uint16[K+3]=4*H+2,F.uint16[K+4]=4*H+3,F.uint16[K+5]=4*H+0}return F})(b));const V=c.createIndexBuffer(Kr,!0),$=c.createVertexBuffer(A,p.aS.members,!0);for(const N of y){const q=Gr(N.transform,N.invTransform,u.transform);z.draw(c,m.TRIANGLES,qt.disabled,ue.disabled,u.colorModeForRenderPass(),ne.disabled,q,u.style.map.terrain&&u.style.map.terrain.getTerrainData(N.coord),s.id,$,V,p.a0.simpleSegment(0,2*N.circleOffset,N.circleArray.length,N.circleArray.length/2),null,u.transform.zoom,null,null,null)}$.destroy(),V.destroy()}ne.disabled=new ne(!1,1029,2305),ne.backCCW=new ne(!0,1029,2305);const aa=p.an(new Float32Array(16));function $n(u,t,s,n,o,c){const{horizontalAlign:m,verticalAlign:g}=p.au(u);return new p.P((-(m-.5)*t/o+n[0])*c,(-(g-.5)*s/o+n[1])*c)}function Jr(u,t,s,n,o,c){const m=t.tileAnchorPoint.add(new p.P(t.translation[0],t.translation[1]));if(t.pitchWithMap){let g=n.mult(c);s||(g=g.rotate(-o));const y=m.add(g);return j(y.x,y.y,t.labelPlaneMatrix,t.getElevation).point}if(s){const g=st(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(u),y=Math.atan(g.y/g.x)+(g.x<0?Math.PI:0);return u.add(n.rotate(y))}return u.add(n)}function ys(u,t,s,n,o,c,m,g,y,b,T,S,z,A){const B=u.text.placedSymbolArray,V=u.text.dynamicLayoutVertexArray,$=u.icon.dynamicLayoutVertexArray,N={};V.clear();for(let q=0;q<B.length;q++){const F=B.get(q),H=F.hidden||!F.crossTileID||u.allowVerticalPlacement&&!F.placedOrientation?null:n[F.crossTileID];if(H){const K=new p.P(F.anchorX,F.anchorY),tt={getElevation:A,width:o.width,height:o.height,labelPlaneMatrix:c,lineVertexArray:null,pitchWithMap:s,projection:T,projectionCache:null,tileAnchorPoint:K,translation:S,unwrappedTileID:z},ot=s?j(K.x,K.y,m,A):st(K.x,K.y,tt),ut=M(o.cameraToCenterDistance,ot.signedDistanceFromCamera);let xt=p.ai(u.textSizeData,y,F)*ut/p.ap;s&&(xt*=u.tilePixelRatio/g);const{width:Tt,height:ft,anchor:pt,textOffset:Et,textBoxScale:Vt}=H,gt=$n(pt,Tt,ft,Et,Vt,xt),bt=T.getPitchedTextCorrection(o,K.add(new p.P(S[0],S[1])),z),Lt=Jr(ot.point,tt,t,gt,o.angle,bt),pe=u.allowVerticalPlacement&&F.placedOrientation===p.ah.vertical?Math.PI/2:0;for(let $t=0;$t<F.numGlyphs;$t++)p.aj(V,Lt,pe);b&&F.associatedIconIndex>=0&&(N[F.associatedIconIndex]={shiftedAnchor:Lt,angle:pe})}else Dt(F.numGlyphs,V)}if(b){$.clear();const q=u.icon.placedSymbolArray;for(let F=0;F<q.length;F++){const H=q.get(F);if(H.hidden)Dt(H.numGlyphs,$);else{const K=N[F];if(K)for(let tt=0;tt<H.numGlyphs;tt++)p.aj($,K.shiftedAnchor,K.angle);else Dt(H.numGlyphs,$)}}u.icon.dynamicLayoutVertexBuffer.updateData($)}u.text.dynamicLayoutVertexBuffer.updateData(V)}function Ti(u,t,s){return s.iconsInText&&t?"symbolTextAndIcon":u?"symbolSDF":"symbolIcon"}function Nn(u,t,s,n,o,c,m,g,y,b,T,S){const z=u.context,A=z.gl,B=u.transform,V=Zr(),$=g==="map",N=y==="map",q=g!=="viewport"&&s.layout.get("symbol-placement")!=="point",F=$&&!N&&!q,H=!N&&q,K=!s.layout.get("symbol-sort-key").isConstant();let tt=!1;const ot=u.depthModeForSublayer(0,qt.ReadOnly),ut=s._unevaluatedLayout.hasValue("text-variable-anchor")||s._unevaluatedLayout.hasValue("text-variable-anchor-offset"),xt=[],Tt=V.getCircleRadiusCorrection(B);for(const ft of n){const pt=t.getTile(ft),Et=pt.getBucket(s);if(!Et)continue;const Vt=o?Et.text:Et.icon;if(!Vt||!Vt.segments.get().length||!Vt.hasVisibleVertices)continue;const gt=Vt.programConfigurations.get(s.id),bt=o||Et.sdfIcons,Lt=o?Et.textSizeData:Et.iconSizeData,pe=N||B.pitch!==0,$t=u.useProgram(Ti(bt,o,Et),gt),Xt=p.ag(Lt,B.zoom),fe=u.style.map.terrain&&u.style.map.terrain.getTerrainData(ft);let Ve,Ui,me,si,Ke=[0,0],je=null;if(o)Ui=pt.glyphAtlasTexture,me=A.LINEAR,Ve=pt.glyphAtlasTexture.size,Et.iconsInText&&(Ke=pt.imageAtlasTexture.size,je=pt.imageAtlasTexture,si=pe||u.options.rotating||u.options.zooming||Lt.kind==="composite"||Lt.kind==="camera"?A.LINEAR:A.NEAREST);else{const Wt=s.layout.get("icon-size").constantOr(0)!==1||Et.iconsNeedLinear;Ui=pt.imageAtlasTexture,me=bt||u.options.rotating||u.options.zooming||Wt||pe?A.LINEAR:A.NEAREST,Ve=pt.imageAtlasTexture.size}const Je=Gt(pt,1,u.transform.zoom),or=H?ft.posMatrix:aa,Rs=Er(or,N,$,u.transform,Je),nn=rr(or,N,$,u.transform,Je),Bs=rr(ft.posMatrix,N,$,u.transform,Je),ki=V.translatePosition(u.transform,pt,c,m),on=ut&&Et.hasTextData(),mo=s.layout.get("icon-text-fit")!=="none"&&on&&Et.hasIconData();if(q){const Wt=u.style.map.terrain?(Fs,Ls)=>u.style.map.terrain.getElevation(ft,Fs,Ls):null,is=s.layout.get("text-rotation-alignment")==="map";D(Et,ft.posMatrix,u,o,Rs,Bs,N,b,is,V,ft.toUnwrapped(),B.width,B.height,ki,Wt)}const Mi=ft.posMatrix,Ei=o&&ut||mo,Pr=q||Ei?aa:Rs,$i=nn,Be=bt&&s.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Ue;Ue=bt?Et.iconsInText?Pn(Lt.kind,Xt,F,N,q,Ei,u,Mi,Pr,$i,ki,Ve,Ke,Tt):ia(Lt.kind,Xt,F,N,q,Ei,u,Mi,Pr,$i,ki,o,Ve,!0,Tt):Vo(Lt.kind,Xt,F,N,q,Ei,u,Mi,Pr,$i,ki,o,Ve,Tt);const gi={program:$t,buffers:Vt,uniformValues:Ue,atlasTexture:Ui,atlasTextureIcon:je,atlasInterpolation:me,atlasInterpolationIcon:si,isSDF:bt,hasHalo:Be};if(K&&Et.canOverlap){tt=!0;const Wt=Vt.segments.get();for(const is of Wt)xt.push({segments:new p.a0([is]),sortKey:is.sortKey,state:gi,terrainData:fe})}else xt.push({segments:Vt.segments,sortKey:0,state:gi,terrainData:fe})}tt&&xt.sort(((ft,pt)=>ft.sortKey-pt.sortKey));for(const ft of xt){const pt=ft.state;if(z.activeTexture.set(A.TEXTURE0),pt.atlasTexture.bind(pt.atlasInterpolation,A.CLAMP_TO_EDGE),pt.atlasTextureIcon&&(z.activeTexture.set(A.TEXTURE1),pt.atlasTextureIcon&&pt.atlasTextureIcon.bind(pt.atlasInterpolationIcon,A.CLAMP_TO_EDGE)),pt.isSDF){const Et=pt.uniformValues;pt.hasHalo&&(Et.u_is_halo=1,Zn(pt.buffers,ft.segments,s,u,pt.program,ot,T,S,Et,ft.terrainData)),Et.u_is_halo=0}Zn(pt.buffers,ft.segments,s,u,pt.program,ot,T,S,pt.uniformValues,ft.terrainData)}}function Zn(u,t,s,n,o,c,m,g,y,b){const T=n.context;o.draw(T,T.gl.TRIANGLES,c,m,g,ne.disabled,y,b,s.id,u.layoutVertexBuffer,u.indexBuffer,t,s.paint,n.transform.zoom,u.programConfigurations.get(s.id),u.dynamicLayoutVertexBuffer,u.opacityVertexBuffer)}function qn(u,t,s,n){const o=u.context,c=o.gl,m=ue.disabled,g=new be([c.ONE,c.ONE],p.aM.transparent,[!0,!0,!0,!0]),y=t.getBucket(s);if(!y)return;const b=n.key;let T=s.heatmapFbos.get(b);T||(T=na(o,t.tileSize,t.tileSize),s.heatmapFbos.set(b,T)),o.bindFramebuffer.set(T.framebuffer),o.viewport.set([0,0,t.tileSize,t.tileSize]),o.clear({color:p.aM.transparent});const S=y.programConfigurations.get(s.id),z=u.useProgram("heatmap",S),A=u.style.map.terrain.getTerrainData(n);z.draw(o,c.TRIANGLES,qt.disabled,m,g,ne.disabled,ri(n.posMatrix,t,u.transform.zoom,s.paint.get("heatmap-intensity")),A,s.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,s.paint,u.transform.zoom,S)}function Yr(u,t,s){const n=u.context,o=n.gl;n.setColorMode(u.colorModeForRenderPass());const c=oa(n,t),m=s.key,g=t.heatmapFbos.get(m);g&&(n.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,g.colorAttachment.get()),n.activeTexture.set(o.TEXTURE1),c.bind(o.LINEAR,o.CLAMP_TO_EDGE),u.useProgram("heatmapTexture").draw(n,o.TRIANGLES,qt.disabled,ue.disabled,u.colorModeForRenderPass(),ne.disabled,Aa(u,t,0,1),null,t.id,u.rasterBoundsBuffer,u.quadTriangleIndexBuffer,u.rasterBoundsSegments,t.paint,u.transform.zoom),g.destroy(),t.heatmapFbos.delete(m))}function na(u,t,s){var n,o;const c=u.gl,m=c.createTexture();c.bindTexture(c.TEXTURE_2D,m),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR);const g=(n=u.HALF_FLOAT)!==null&&n!==void 0?n:c.UNSIGNED_BYTE,y=(o=u.RGBA16F)!==null&&o!==void 0?o:c.RGBA;c.texImage2D(c.TEXTURE_2D,0,y,t,s,0,c.RGBA,g,null);const b=u.createFramebuffer(t,s,!1,!1);return b.colorAttachment.set(m),b}function oa(u,t){return t.colorRampTexture||(t.colorRampTexture=new ae(u,t.colorRamp,u.gl.RGBA)),t.colorRampTexture}function xs(u,t,s,n,o){if(!s||!n||!n.imageAtlas)return;const c=n.imageAtlas.patternPositions;let m=c[s.to.toString()],g=c[s.from.toString()];if(!m&&g&&(m=g),!g&&m&&(g=m),!m||!g){const y=o.getPaintProperty(t);m=c[y],g=c[y]}m&&g&&u.setConstantPatternPositions(m,g)}function la(u,t,s,n,o,c,m){const g=u.context.gl,y="fill-pattern",b=s.paint.get(y),T=b&&b.constantOr(1),S=s.getCrossfadeParameters();let z,A,B,V,$;m?(A=T&&!s.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",z=g.LINES):(A=T?"fillPattern":"fill",z=g.TRIANGLES);const N=b.constantOr(null);for(const q of n){const F=t.getTile(q);if(T&&!F.patternsLoaded())continue;const H=F.getBucket(s);if(!H)continue;const K=H.programConfigurations.get(s.id),tt=u.useProgram(A,K),ot=u.style.map.terrain&&u.style.map.terrain.getTerrainData(q);T&&(u.context.activeTexture.set(g.TEXTURE0),F.imageAtlasTexture.bind(g.LINEAR,g.CLAMP_TO_EDGE),K.updatePaintBuffers(S)),xs(K,y,N,F,s);const ut=ot?q:null,xt=u.translatePosMatrix(ut?ut.posMatrix:q.posMatrix,F,s.paint.get("fill-translate"),s.paint.get("fill-translate-anchor"));if(m){V=H.indexBuffer2,$=H.segments2;const Tt=[g.drawingBufferWidth,g.drawingBufferHeight];B=A==="fillOutlinePattern"&&T?Bo(xt,u,S,F,Tt):jl(xt,Tt)}else V=H.indexBuffer,$=H.segments,B=T?Ro(xt,u,S,F):ms(xt);tt.draw(u.context,z,o,u.stencilModeForClipping(q),c,ne.disabled,B,ot,s.id,H.layoutVertexBuffer,V,$,s.paint,u.transform.zoom,K)}}function Ua(u,t,s,n,o,c,m){const g=u.context,y=g.gl,b="fill-extrusion-pattern",T=s.paint.get(b),S=T.constantOr(1),z=s.getCrossfadeParameters(),A=s.paint.get("fill-extrusion-opacity"),B=T.constantOr(null);for(const V of n){const $=t.getTile(V),N=$.getBucket(s);if(!N)continue;const q=u.style.map.terrain&&u.style.map.terrain.getTerrainData(V),F=N.programConfigurations.get(s.id),H=u.useProgram(S?"fillExtrusionPattern":"fillExtrusion",F);S&&(u.context.activeTexture.set(y.TEXTURE0),$.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),F.updatePaintBuffers(z)),xs(F,b,B,$,s);const K=u.translatePosMatrix(V.posMatrix,$,s.paint.get("fill-extrusion-translate"),s.paint.get("fill-extrusion-translate-anchor")),tt=s.paint.get("fill-extrusion-vertical-gradient"),ot=S?Pa(K,u,tt,A,V,z,$):ta(K,u,tt,A);H.draw(g,g.gl.TRIANGLES,o,c,m,ne.backCCW,ot,q,s.id,N.layoutVertexBuffer,N.indexBuffer,N.segments,s.paint,u.transform.zoom,F,u.style.map.terrain&&N.centroidVertexBuffer)}}function vs(u,t,s,n,o,c,m){const g=u.context,y=g.gl,b=s.fbo;if(!b)return;const T=u.useProgram("hillshade"),S=u.style.map.terrain&&u.style.map.terrain.getTerrainData(t);g.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,b.colorAttachment.get()),T.draw(g,y.TRIANGLES,o,c,m,ne.disabled,((z,A,B,V)=>{const $=B.paint.get("hillshade-shadow-color"),N=B.paint.get("hillshade-highlight-color"),q=B.paint.get("hillshade-accent-color");let F=B.paint.get("hillshade-illumination-direction")*(Math.PI/180);B.paint.get("hillshade-illumination-anchor")==="viewport"&&(F-=z.transform.angle);const H=!z.options.moving;return{u_matrix:V?V.posMatrix:z.transform.calculatePosMatrix(A.tileID.toUnwrapped(),H),u_image:0,u_latrange:Da(0,A.tileID),u_light:[B.paint.get("hillshade-exaggeration"),F],u_shadow:$,u_highlight:N,u_accent:q}})(u,s,n,S?t:null),S,n.id,u.rasterBoundsBuffer,u.quadTriangleIndexBuffer,u.rasterBoundsSegments)}function bs(u,t,s,n,o,c){const m=u.context,g=m.gl,y=t.dem;if(y&&y.data){const b=y.dim,T=y.stride,S=y.getPixels();if(m.activeTexture.set(g.TEXTURE1),m.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||u.getTileTexture(T),t.demTexture){const A=t.demTexture;A.update(S,{premultiply:!1}),A.bind(g.NEAREST,g.CLAMP_TO_EDGE)}else t.demTexture=new ae(m,S,g.RGBA,{premultiply:!1}),t.demTexture.bind(g.NEAREST,g.CLAMP_TO_EDGE);m.activeTexture.set(g.TEXTURE0);let z=t.fbo;if(!z){const A=new ae(m,{width:b,height:b,data:null},g.RGBA);A.bind(g.LINEAR,g.CLAMP_TO_EDGE),z=t.fbo=m.createFramebuffer(b,b,!0,!1),z.colorAttachment.set(A.texture)}m.bindFramebuffer.set(z.framebuffer),m.viewport.set([0,0,b,b]),u.useProgram("hillshadePrepare").draw(m,g.TRIANGLES,n,o,c,ne.disabled,((A,B)=>{const V=B.stride,$=p.H();return p.aP($,0,p.X,-p.X,0,0,1),p.J($,$,[0,-p.X,0]),{u_matrix:$,u_image:1,u_dimension:[V,V],u_zoom:A.overscaledZ,u_unpack:B.getUnpackVector()}})(t.tileID,y),null,s.id,u.rasterBoundsBuffer,u.quadTriangleIndexBuffer,u.rasterBoundsSegments),t.needsHillshadePrepare=!1}}function Yo(u,t,s,n,o,c){const m=n.paint.get("raster-fade-duration");if(!c&&m>0){const g=mt.now(),y=(g-u.timeAdded)/m,b=t?(g-t.timeAdded)/m:-1,T=s.getSource(),S=o.coveringZoomLevel({tileSize:T.tileSize,roundZoom:T.roundZoom}),z=!t||Math.abs(t.tileID.overscaledZ-S)>Math.abs(u.tileID.overscaledZ-S),A=z&&u.refreshedUponExpiration?1:p.ac(z?y:1-b,0,1);return u.refreshedUponExpiration&&y>=1&&(u.refreshedUponExpiration=!1),t?{opacity:1,mix:1-A}:{opacity:A,mix:0}}return{opacity:1,mix:0}}const Gn=new p.aM(1,0,0,1),Yt=new p.aM(0,1,0,1),$a=new p.aM(0,0,1,1),ec=new p.aM(1,0,1,1),Qo=new p.aM(0,1,1,1);function ws(u,t,s,n){Na(u,0,t+s/2,u.transform.width,s,n)}function tl(u,t,s,n){Na(u,t-s/2,0,s,u.transform.height,n)}function Na(u,t,s,n,o,c){const m=u.context,g=m.gl;g.enable(g.SCISSOR_TEST),g.scissor(t*u.pixelRatio,s*u.pixelRatio,n*u.pixelRatio,o*u.pixelRatio),m.clear({color:c}),g.disable(g.SCISSOR_TEST)}function el(u,t,s){const n=u.context,o=n.gl,c=s.posMatrix,m=u.useProgram("debug"),g=qt.disabled,y=ue.disabled,b=u.colorModeForRenderPass(),T="$debug",S=u.style.map.terrain&&u.style.map.terrain.getTerrainData(s);n.activeTexture.set(o.TEXTURE0);const z=t.getTileByID(s.key).latestRawTileData,A=Math.floor((z&&z.byteLength||0)/1024),B=t.getTile(s).tileSize,V=512/Math.min(B,512)*(s.overscaledZ/u.transform.zoom)*.5;let $=s.canonical.toString();s.overscaledZ!==s.canonical.z&&($+=` => ${s.overscaledZ}`),(function(N,q){N.initDebugOverlayCanvas();const F=N.debugOverlayCanvas,H=N.context.gl,K=N.debugOverlayCanvas.getContext("2d");K.clearRect(0,0,F.width,F.height),K.shadowColor="white",K.shadowBlur=2,K.lineWidth=1.5,K.strokeStyle="white",K.textBaseline="top",K.font="bold 36px Open Sans, sans-serif",K.fillText(q,5,5),K.strokeText(q,5,5),N.debugOverlayTexture.update(F),N.debugOverlayTexture.bind(H.LINEAR,H.CLAMP_TO_EDGE)})(u,`${$} ${A}kB`),m.draw(n,o.TRIANGLES,g,y,be.alphaBlended,ne.disabled,ea(c,p.aM.transparent,V),null,T,u.debugBuffer,u.quadTriangleIndexBuffer,u.debugSegments),m.draw(n,o.LINE_STRIP,g,y,b,ne.disabled,ea(c,p.aM.red),S,T,u.debugBuffer,u.tileBorderIndexBuffer,u.debugSegments)}function il(u,t,s){const n=u.context,o=n.gl,c=u.colorModeForRenderPass(),m=new qt(o.LEQUAL,qt.ReadWrite,u.depthRangeFor3D),g=u.useProgram("terrain"),y=t.getTerrainMesh();n.bindFramebuffer.set(null),n.viewport.set([0,0,u.width,u.height]);for(const b of s){const T=u.renderToTexture.getTexture(b),S=t.getTerrainData(b.tileID);n.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,T.texture);const z=u.transform.calculatePosMatrix(b.tileID.toUnwrapped()),A=t.getMeshFrameDelta(u.transform.zoom),B=u.transform.calculateFogMatrix(b.tileID.toUnwrapped()),V=zn(z,A,B,u.style.sky,u.transform.pitch);g.draw(n,o.TRIANGLES,m,ue.disabled,c,ne.backCCW,V,S,"terrain",y.vertexBuffer,y.indexBuffer,y.segments)}}class Za{constructor(t,s,n){this.vertexBuffer=t,this.indexBuffer=s,this.segments=n}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class qa{constructor(t,s){this.context=new tc(t),this.transform=s,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:p.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Ft.maxUnderzooming+Ft.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Mn}resize(t,s,n){if(this.width=Math.floor(t*n),this.height=Math.floor(s*n),this.pixelRatio=n,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const o of this.style._order)this.style._layers[o].resize()}setup(){const t=this.context,s=new p.aX;s.emplaceBack(0,0),s.emplaceBack(p.X,0),s.emplaceBack(0,p.X),s.emplaceBack(p.X,p.X),this.tileExtentBuffer=t.createVertexBuffer(s,qr.members),this.tileExtentSegments=p.a0.simpleSegment(0,0,4,2);const 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.debugBuffer=t.createVertexBuffer(n,qr.members),this.debugSegments=p.a0.simpleSegment(0,0,4,5);const o=new p.$;o.emplaceBack(0,0,0,0),o.emplaceBack(p.X,0,p.X,0),o.emplaceBack(0,p.X,0,p.X),o.emplaceBack(p.X,p.X,p.X,p.X),this.rasterBoundsBuffer=t.createVertexBuffer(o,kr.members),this.rasterBoundsSegments=p.a0.simpleSegment(0,0,4,2);const c=new p.aX;c.emplaceBack(0,0),c.emplaceBack(1,0),c.emplaceBack(0,1),c.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(c,qr.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 ue({func:y.ALWAYS,mask:0},0,255,y.ZERO,y.ZERO,y.ZERO)}clearStencil(){const t=this.context,s=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const n=p.H();p.aP(n,0,this.width,this.height,0,0,1),p.K(n,n,[s.drawingBufferWidth,s.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,s.TRIANGLES,qt.disabled,this.stencilClearMode,be.disabled,ne.disabled,ii(n),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,s){if(this.currentStencilSource===t.source||!t.isTileClipped()||!s||!s.length)return;this.currentStencilSource=t.source;const n=this.context,o=n.gl;this.nextStencilID+s.length>256&&this.clearStencil(),n.setColorMode(be.disabled),n.setDepthMode(qt.disabled);const c=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const m of s){const g=this._tileClippingMaskIDs[m.key]=this.nextStencilID++,y=this.style.map.terrain&&this.style.map.terrain.getTerrainData(m);c.draw(n,o.TRIANGLES,qt.disabled,new ue({func:o.ALWAYS,mask:0},g,255,o.KEEP,o.KEEP,o.REPLACE),be.disabled,ne.disabled,ii(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++,s=this.context.gl;return new ue({func:s.NOTEQUAL,mask:255},t,255,s.KEEP,s.KEEP,s.REPLACE)}stencilModeForClipping(t){const s=this.context.gl;return new ue({func:s.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,s.KEEP,s.KEEP,s.REPLACE)}stencilConfigForOverlap(t){const s=this.context.gl,n=t.sort(((m,g)=>g.overscaledZ-m.overscaledZ)),o=n[n.length-1].overscaledZ,c=n[0].overscaledZ-o+1;if(c>1){this.currentStencilSource=void 0,this.nextStencilID+c>256&&this.clearStencil();const m={};for(let g=0;g<c;g++)m[g+o]=new ue({func:s.GEQUAL,mask:255},g+this.nextStencilID,255,s.KEEP,s.KEEP,s.REPLACE);return this.nextStencilID+=c,[m,n]}return[{[o]:ue.disabled},n]}colorModeForRenderPass(){const t=this.context.gl;return this._showOverdrawInspector?new be([t.CONSTANT_COLOR,t.ONE],new p.aM(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?be.unblended:be.alphaBlended}depthModeForSublayer(t,s,n){if(!this.opaquePassEnabledForLayer())return qt.disabled;const o=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new qt(n||this.context.gl.LEQUAL,s,[o,o])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,s){this.style=t,this.options=s,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(mt.now()),this.imageManager.beginFrame();const n=this.style._order,o=this.style.sourceCaches,c={},m={},g={};for(const y in o){const b=o[y];b.used&&b.prepare(this.context),c[y]=b.getVisibleCoordinates(),m[y]=c[y].slice().reverse(),g[y]=b.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let y=0;y<n.length;y++)if(this.style._layers[n[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 n){const b=this.style._layers[y];if(!b.hasOffscreenPass()||b.isHidden(this.transform.zoom))continue;const T=m[b.source];(b.type==="custom"||T.length)&&this.renderLayer(this,o[b.source],b,T)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:s.showOverdrawInspector?p.aM.black:p.aM.transparent,depth:1}),this.clearStencil(),this.style.sky&&(function(y,b){const T=y.context,S=T.gl,z=((N,q,F)=>({u_sky_color:N.properties.get("sky-color"),u_horizon_color:N.properties.get("horizon-color"),u_horizon:(q.height/2+q.getHorizon())*F,u_sky_horizon_blend:N.properties.get("sky-horizon-blend")*q.height/2*F}))(b,y.style.map.transform,y.pixelRatio),A=new qt(S.LEQUAL,qt.ReadWrite,[0,1]),B=ue.disabled,V=y.colorModeForRenderPass(),$=y.useProgram("sky");if(!b.mesh){const N=new p.aX;N.emplaceBack(-1,-1),N.emplaceBack(1,-1),N.emplaceBack(1,1),N.emplaceBack(-1,1);const q=new p.aY;q.emplaceBack(0,1,2),q.emplaceBack(0,2,3),b.mesh=new Za(T.createVertexBuffer(N,qr.members),T.createIndexBuffer(q),p.a0.simpleSegment(0,0,N.length,q.length))}$.draw(T,S.TRIANGLES,A,B,V,ne.disabled,z,void 0,"sky",b.mesh.vertexBuffer,b.mesh.indexBuffer,b.mesh.segments)})(this,this.style.sky),this._showOverdrawInspector=s.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=n.length-1;this.currentLayer>=0;this.currentLayer--){const y=this.style._layers[n[this.currentLayer]],b=o[y.source],T=c[y.source];this._renderTileClippingMasks(y,T),this.renderLayer(this,b,y,T)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<n.length;this.currentLayer++){const y=this.style._layers[n[this.currentLayer]],b=o[y.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(y))continue;const T=(y.type==="symbol"?g:m)[y.source];this._renderTileClippingMasks(y,c[y.source]),this.renderLayer(this,b,y,T)}if(this.options.showTileBoundaries){const y=(function(b,T){let S=null;const z=Object.values(b._layers).flatMap(($=>$.source&&!$.isHidden(T)?[b.sourceCaches[$.source]]:[])),A=z.filter(($=>$.getSource().type==="vector")),B=z.filter(($=>$.getSource().type!=="vector")),V=$=>{(!S||S.getSource().maxzoom<$.getSource().maxzoom)&&(S=$)};return A.forEach(($=>V($))),S||B.forEach(($=>V($))),S})(this.style,this.transform.zoom);y&&(function(b,T,S){for(let z=0;z<S.length;z++)el(b,T,S[z])})(this,y,y.getVisibleCoordinates())}this.options.showPadding&&(function(y){const b=y.transform.padding;ws(y,y.transform.height-(b.top||0),3,Gn),ws(y,b.bottom||0,3,Yt),tl(y,b.left||0,3,$a),tl(y,y.transform.width-(b.right||0),3,ec);const T=y.transform.centerPoint;(function(S,z,A,B){Na(S,z-1,A-10,2,20,B),Na(S,z-10,A-1,20,2,B)})(y,T.x,y.transform.height-T.y,Qo)})(this),this.context.setDefault()}maybeDrawDepthAndCoords(t){if(!this.style||!this.style.map||!this.style.map.terrain)return;const s=this.terrainFacilitator.matrix,n=this.transform.modelViewProjectionMatrix;let o=this.terrainFacilitator.dirty;o||(o=t?!p.a_(s,n):!p.a$(s,n)),o||(o=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),o&&(p.b0(s,n),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,(function(c,m){const g=c.context,y=g.gl,b=be.unblended,T=new qt(y.LEQUAL,qt.ReadWrite,[0,1]),S=m.getTerrainMesh(),z=m.sourceCache.getRenderableTiles(),A=c.useProgram("terrainDepth");g.bindFramebuffer.set(m.getFramebuffer("depth").framebuffer),g.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),g.clear({color:p.aM.transparent,depth:1});for(const B of z){const V=m.getTerrainData(B.tileID),$={u_matrix:c.transform.calculatePosMatrix(B.tileID.toUnwrapped()),u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};A.draw(g,y.TRIANGLES,T,ue.disabled,b,ne.backCCW,$,V,"terrain",S.vertexBuffer,S.indexBuffer,S.segments)}g.bindFramebuffer.set(null),g.viewport.set([0,0,c.width,c.height])})(this,this.style.map.terrain),(function(c,m){const g=c.context,y=g.gl,b=be.unblended,T=new qt(y.LEQUAL,qt.ReadWrite,[0,1]),S=m.getTerrainMesh(),z=m.getCoordsTexture(),A=m.sourceCache.getRenderableTiles(),B=c.useProgram("terrainCoords");g.bindFramebuffer.set(m.getFramebuffer("coords").framebuffer),g.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),g.clear({color:p.aM.transparent,depth:1}),m.coordsIndex=[];for(const V of A){const $=m.getTerrainData(V.tileID);g.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,z.texture);const N={u_matrix:c.transform.calculatePosMatrix(V.tileID.toUnwrapped()),u_terrain_coords_id:(255-m.coordsIndex.length)/255,u_texture:0,u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};B.draw(g,y.TRIANGLES,T,ue.disabled,b,ne.backCCW,N,$,"terrain",S.vertexBuffer,S.indexBuffer,S.segments),m.coordsIndex.push(V.tileID.key)}g.bindFramebuffer.set(null),g.viewport.set([0,0,c.width,c.height])})(this,this.style.map.terrain))}renderLayer(t,s,n,o){if(!n.isHidden(this.transform.zoom)&&(n.type==="background"||n.type==="custom"||(o||[]).length))switch(this.id=n.id,n.type){case"symbol":(function(c,m,g,y,b){if(c.renderPass!=="translucent")return;const T=ue.disabled,S=c.colorModeForRenderPass();(g._unevaluatedLayout.hasValue("text-variable-anchor")||g._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&(function(z,A,B,V,$,N,q,F,H){const K=A.transform,tt=Zr(),ot=$==="map",ut=N==="map";for(const xt of z){const Tt=V.getTile(xt),ft=Tt.getBucket(B);if(!ft||!ft.text||!ft.text.segments.get().length)continue;const pt=p.ag(ft.textSizeData,K.zoom),Et=Gt(Tt,1,A.transform.zoom),Vt=Er(xt.posMatrix,ut,ot,A.transform,Et),gt=B.layout.get("icon-text-fit")!=="none"&&ft.hasIconData();if(pt){const bt=Math.pow(2,K.zoom-Tt.tileID.overscaledZ),Lt=A.style.map.terrain?($t,Xt)=>A.style.map.terrain.getElevation(xt,$t,Xt):null,pe=tt.translatePosition(K,Tt,q,F);ys(ft,ot,ut,H,K,Vt,xt.posMatrix,bt,pt,gt,tt,pe,xt.toUnwrapped(),Lt)}}})(y,c,g,m,g.layout.get("text-rotation-alignment"),g.layout.get("text-pitch-alignment"),g.paint.get("text-translate"),g.paint.get("text-translate-anchor"),b),g.paint.get("icon-opacity").constantOr(1)!==0&&Nn(c,m,g,y,!1,g.paint.get("icon-translate"),g.paint.get("icon-translate-anchor"),g.layout.get("icon-rotation-alignment"),g.layout.get("icon-pitch-alignment"),g.layout.get("icon-keep-upright"),T,S),g.paint.get("text-opacity").constantOr(1)!==0&&Nn(c,m,g,y,!0,g.paint.get("text-translate"),g.paint.get("text-translate-anchor"),g.layout.get("text-rotation-alignment"),g.layout.get("text-pitch-alignment"),g.layout.get("text-keep-upright"),T,S),m.map.showCollisionBoxes&&(sa(c,m,g,y,!0),sa(c,m,g,y,!1))})(t,s,n,o,this.style.placement.variableOffsets);break;case"circle":(function(c,m,g,y){if(c.renderPass!=="translucent")return;const b=g.paint.get("circle-opacity"),T=g.paint.get("circle-stroke-width"),S=g.paint.get("circle-stroke-opacity"),z=!g.layout.get("circle-sort-key").isConstant();if(b.constantOr(1)===0&&(T.constantOr(1)===0||S.constantOr(1)===0))return;const A=c.context,B=A.gl,V=c.depthModeForSublayer(0,qt.ReadOnly),$=ue.disabled,N=c.colorModeForRenderPass(),q=[];for(let F=0;F<y.length;F++){const H=y[F],K=m.getTile(H),tt=K.getBucket(g);if(!tt)continue;const ot=tt.programConfigurations.get(g.id),ut=c.useProgram("circle",ot),xt=tt.layoutVertexBuffer,Tt=tt.indexBuffer,ft=c.style.map.terrain&&c.style.map.terrain.getTerrainData(H),pt={programConfiguration:ot,program:ut,layoutVertexBuffer:xt,indexBuffer:Tt,uniformValues:Ul(c,H,K,g),terrainData:ft};if(z){const Et=tt.segments.get();for(const Vt of Et)q.push({segments:new p.a0([Vt]),sortKey:Vt.sortKey,state:pt})}else q.push({segments:tt.segments,sortKey:0,state:pt})}z&&q.sort(((F,H)=>F.sortKey-H.sortKey));for(const F of q){const{programConfiguration:H,program:K,layoutVertexBuffer:tt,indexBuffer:ot,uniformValues:ut,terrainData:xt}=F.state;K.draw(A,B.TRIANGLES,V,$,N,ne.disabled,ut,xt,g.id,tt,ot,F.segments,g.paint,c.transform.zoom,H)}})(t,s,n,o);break;case"heatmap":(function(c,m,g,y){if(g.paint.get("heatmap-opacity")===0)return;const b=c.context;if(c.style.map.terrain){for(const T of y){const S=m.getTile(T);m.hasRenderableParent(T)||(c.renderPass==="offscreen"?qn(c,S,g,T):c.renderPass==="translucent"&&Yr(c,g,T))}b.viewport.set([0,0,c.width,c.height])}else c.renderPass==="offscreen"?(function(T,S,z,A){const B=T.context,V=B.gl,$=ue.disabled,N=new be([V.ONE,V.ONE],p.aM.transparent,[!0,!0,!0,!0]);(function(q,F,H){const K=q.gl;q.activeTexture.set(K.TEXTURE1),q.viewport.set([0,0,F.width/4,F.height/4]);let tt=H.heatmapFbos.get(p.aU);tt?(K.bindTexture(K.TEXTURE_2D,tt.colorAttachment.get()),q.bindFramebuffer.set(tt.framebuffer)):(tt=na(q,F.width/4,F.height/4),H.heatmapFbos.set(p.aU,tt))})(B,T,z),B.clear({color:p.aM.transparent});for(let q=0;q<A.length;q++){const F=A[q];if(S.hasRenderableParent(F))continue;const H=S.getTile(F),K=H.getBucket(z);if(!K)continue;const tt=K.programConfigurations.get(z.id),ot=T.useProgram("heatmap",tt),{zoom:ut}=T.transform;ot.draw(B,V.TRIANGLES,qt.disabled,$,N,ne.disabled,ri(F.posMatrix,H,ut,z.paint.get("heatmap-intensity")),null,z.id,K.layoutVertexBuffer,K.indexBuffer,K.segments,z.paint,T.transform.zoom,tt)}B.viewport.set([0,0,T.width,T.height])})(c,m,g,y):c.renderPass==="translucent"&&(function(T,S){const z=T.context,A=z.gl;z.setColorMode(T.colorModeForRenderPass());const B=S.heatmapFbos.get(p.aU);B&&(z.activeTexture.set(A.TEXTURE0),A.bindTexture(A.TEXTURE_2D,B.colorAttachment.get()),z.activeTexture.set(A.TEXTURE1),oa(z,S).bind(A.LINEAR,A.CLAMP_TO_EDGE),T.useProgram("heatmapTexture").draw(z,A.TRIANGLES,qt.disabled,ue.disabled,T.colorModeForRenderPass(),ne.disabled,Aa(T,S,0,1),null,S.id,T.viewportBuffer,T.quadTriangleIndexBuffer,T.viewportSegments,S.paint,T.transform.zoom))})(c,g)})(t,s,n,o);break;case"line":(function(c,m,g,y){if(c.renderPass!=="translucent")return;const b=g.paint.get("line-opacity"),T=g.paint.get("line-width");if(b.constantOr(1)===0||T.constantOr(1)===0)return;const S=c.depthModeForSublayer(0,qt.ReadOnly),z=c.colorModeForRenderPass(),A=g.paint.get("line-dasharray"),B=g.paint.get("line-pattern"),V=B.constantOr(1),$=g.paint.get("line-gradient"),N=g.getCrossfadeParameters(),q=V?"linePattern":A?"lineSDF":$?"lineGradient":"line",F=c.context,H=F.gl;let K=!0;for(const tt of y){const ot=m.getTile(tt);if(V&&!ot.patternsLoaded())continue;const ut=ot.getBucket(g);if(!ut)continue;const xt=ut.programConfigurations.get(g.id),Tt=c.context.program.get(),ft=c.useProgram(q,xt),pt=K||ft.program!==Tt,Et=c.style.map.terrain&&c.style.map.terrain.getTerrainData(tt),Vt=B.constantOr(null);if(Vt&&ot.imageAtlas){const Lt=ot.imageAtlas,pe=Lt.patternPositions[Vt.to.toString()],$t=Lt.patternPositions[Vt.from.toString()];pe&&$t&&xt.setConstantPatternPositions(pe,$t)}const gt=Et?tt:null,bt=V?_s(c,ot,g,N,gt):A?$l(c,ot,g,A,N,gt):$?Fo(c,ot,g,ut.lineClipsArray.length,gt):Ra(c,ot,g,gt);if(V)F.activeTexture.set(H.TEXTURE0),ot.imageAtlasTexture.bind(H.LINEAR,H.CLAMP_TO_EDGE),xt.updatePaintBuffers(N);else if(A&&(pt||c.lineAtlas.dirty))F.activeTexture.set(H.TEXTURE0),c.lineAtlas.bind(F);else if($){const Lt=ut.gradients[g.id];let pe=Lt.texture;if(g.gradientVersion!==Lt.version){let $t=256;if(g.stepInterpolant){const Xt=m.getSource().maxzoom,fe=tt.canonical.z===Xt?Math.ceil(1<<c.transform.maxZoom-tt.canonical.z):1;$t=p.ac(p.aV(ut.maxLineLength/p.X*1024*fe),256,F.maxTextureSize)}Lt.gradient=p.aW({expression:g.gradientExpression(),evaluationKey:"lineProgress",resolution:$t,image:Lt.gradient||void 0,clips:ut.lineClipsArray}),Lt.texture?Lt.texture.update(Lt.gradient):Lt.texture=new ae(F,Lt.gradient,H.RGBA),Lt.version=g.gradientVersion,pe=Lt.texture}F.activeTexture.set(H.TEXTURE0),pe.bind(g.stepInterpolant?H.NEAREST:H.LINEAR,H.CLAMP_TO_EDGE)}ft.draw(F,H.TRIANGLES,S,c.stencilModeForClipping(tt),z,ne.disabled,bt,Et,g.id,ut.layoutVertexBuffer,ut.indexBuffer,ut.segments,g.paint,c.transform.zoom,xt,ut.layoutVertexBuffer2),K=!1}})(t,s,n,o);break;case"fill":(function(c,m,g,y){const b=g.paint.get("fill-color"),T=g.paint.get("fill-opacity");if(T.constantOr(1)===0)return;const S=c.colorModeForRenderPass(),z=g.paint.get("fill-pattern"),A=c.opaquePassEnabledForLayer()&&!z.constantOr(1)&&b.constantOr(p.aM.transparent).a===1&&T.constantOr(0)===1?"opaque":"translucent";if(c.renderPass===A){const B=c.depthModeForSublayer(1,c.renderPass==="opaque"?qt.ReadWrite:qt.ReadOnly);la(c,m,g,y,B,S,!1)}if(c.renderPass==="translucent"&&g.paint.get("fill-antialias")){const B=c.depthModeForSublayer(g.getPaintProperty("fill-outline-color")?2:0,qt.ReadOnly);la(c,m,g,y,B,S,!0)}})(t,s,n,o);break;case"fill-extrusion":(function(c,m,g,y){const b=g.paint.get("fill-extrusion-opacity");if(b!==0&&c.renderPass==="translucent"){const T=new qt(c.context.gl.LEQUAL,qt.ReadWrite,c.depthRangeFor3D);if(b!==1||g.paint.get("fill-extrusion-pattern").constantOr(1))Ua(c,m,g,y,T,ue.disabled,be.disabled),Ua(c,m,g,y,T,c.stencilModeFor3D(),c.colorModeForRenderPass());else{const S=c.colorModeForRenderPass();Ua(c,m,g,y,T,ue.disabled,S)}}})(t,s,n,o);break;case"hillshade":(function(c,m,g,y){if(c.renderPass!=="offscreen"&&c.renderPass!=="translucent")return;const b=c.context,T=c.depthModeForSublayer(0,qt.ReadOnly),S=c.colorModeForRenderPass(),[z,A]=c.renderPass==="translucent"?c.stencilConfigForOverlap(y):[{},y];for(const B of A){const V=m.getTile(B);V.needsHillshadePrepare!==void 0&&V.needsHillshadePrepare&&c.renderPass==="offscreen"?bs(c,V,g,T,ue.disabled,S):c.renderPass==="translucent"&&vs(c,B,V,g,T,z[B.overscaledZ],S)}b.viewport.set([0,0,c.width,c.height])})(t,s,n,o);break;case"raster":(function(c,m,g,y){if(c.renderPass!=="translucent"||g.paint.get("raster-opacity")===0||!y.length)return;const b=c.context,T=b.gl,S=m.getSource(),z=c.useProgram("raster"),A=c.colorModeForRenderPass(),[B,V]=S instanceof fr?[{},y]:c.stencilConfigForOverlap(y),$=V[V.length-1].overscaledZ,N=!c.options.moving;for(const q of V){const F=c.depthModeForSublayer(q.overscaledZ-$,g.paint.get("raster-opacity")===1?qt.ReadWrite:qt.ReadOnly,T.LESS),H=m.getTile(q);H.registerFadeDuration(g.paint.get("raster-fade-duration"));const K=m.findLoadedParent(q,0),tt=m.findLoadedSibling(q),ot=Yo(H,K||tt||null,m,g,c.transform,c.style.map.terrain);let ut,xt;const Tt=g.paint.get("raster-resampling")==="nearest"?T.NEAREST:T.LINEAR;b.activeTexture.set(T.TEXTURE0),H.texture.bind(Tt,T.CLAMP_TO_EDGE,T.LINEAR_MIPMAP_NEAREST),b.activeTexture.set(T.TEXTURE1),K?(K.texture.bind(Tt,T.CLAMP_TO_EDGE,T.LINEAR_MIPMAP_NEAREST),ut=Math.pow(2,K.tileID.overscaledZ-H.tileID.overscaledZ),xt=[H.tileID.canonical.x*ut%1,H.tileID.canonical.y*ut%1]):H.texture.bind(Tt,T.CLAMP_TO_EDGE,T.LINEAR_MIPMAP_NEAREST),H.texture.useMipmap&&b.extTextureFilterAnisotropic&&c.transform.pitch>20&&T.texParameterf(T.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax);const ft=c.style.map.terrain&&c.style.map.terrain.getTerrainData(q),pt=ft?q:null,Et=pt?pt.posMatrix:c.transform.calculatePosMatrix(q.toUnwrapped(),N),Vt=Nl(Et,xt||[0,0],ut||1,ot,g);S instanceof fr?z.draw(b,T.TRIANGLES,F,ue.disabled,A,ne.disabled,Vt,ft,g.id,S.boundsBuffer,c.quadTriangleIndexBuffer,S.boundsSegments):z.draw(b,T.TRIANGLES,F,B[q.overscaledZ],A,ne.disabled,Vt,ft,g.id,c.rasterBoundsBuffer,c.quadTriangleIndexBuffer,c.rasterBoundsSegments)}})(t,s,n,o);break;case"background":(function(c,m,g,y){const b=g.paint.get("background-color"),T=g.paint.get("background-opacity");if(T===0)return;const S=c.context,z=S.gl,A=c.transform,B=A.tileSize,V=g.paint.get("background-pattern");if(c.isPatternMissing(V))return;const $=!V&&b.a===1&&T===1&&c.opaquePassEnabledForLayer()?"opaque":"translucent";if(c.renderPass!==$)return;const N=ue.disabled,q=c.depthModeForSublayer(0,$==="opaque"?qt.ReadWrite:qt.ReadOnly),F=c.colorModeForRenderPass(),H=c.useProgram(V?"backgroundPattern":"background"),K=y||A.coveringTiles({tileSize:B,terrain:c.style.map.terrain});V&&(S.activeTexture.set(z.TEXTURE0),c.imageManager.bind(c.context));const tt=g.getCrossfadeParameters();for(const ot of K){const ut=y?ot.posMatrix:c.transform.calculatePosMatrix(ot.toUnwrapped()),xt=V?An(ut,T,c,V,{tileID:ot,tileSize:B},tt):Ba(ut,T,b),Tt=c.style.map.terrain&&c.style.map.terrain.getTerrainData(ot);H.draw(S,z.TRIANGLES,q,N,F,ne.disabled,xt,Tt,g.id,c.tileExtentBuffer,c.quadTriangleIndexBuffer,c.tileExtentSegments)}})(t,0,n,o);break;case"custom":(function(c,m,g){const y=c.context,b=g.implementation;if(c.renderPass==="offscreen"){const T=b.prerender;T&&(c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),T.call(b,y.gl,c.transform.customLayerMatrix()),y.setDirty(),c.setBaseState())}else if(c.renderPass==="translucent"){c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),y.setStencilMode(ue.disabled);const T=b.renderingMode==="3d"?new qt(c.context.gl.LEQUAL,qt.ReadWrite,c.depthRangeFor3D):c.depthModeForSublayer(0,qt.ReadOnly);y.setDepthMode(T),b.render(y.gl,c.transform.customLayerMatrix(),{farZ:c.transform.farZ,nearZ:c.transform.nearZ,fov:c.transform._fov,modelViewProjectionMatrix:c.transform.modelViewProjectionMatrix,projectionMatrix:c.transform.projectionMatrix}),y.setDirty(),c.setBaseState(),y.bindFramebuffer.set(null)}})(t,0,n)}}translatePosMatrix(t,s,n,o,c){if(!n[0]&&!n[1])return t;const m=c?o==="map"?this.transform.angle:0:o==="viewport"?-this.transform.angle:0;if(m){const b=Math.sin(m),T=Math.cos(m);n=[n[0]*T-n[1]*b,n[0]*b+n[1]*T]}const g=[c?n[0]:Gt(s,n[0],this.transform.zoom),c?n[1]:Gt(s,n[1],this.transform.zoom),0],y=new Float32Array(16);return p.J(y,t,g),y}saveTileTexture(t){const s=this._tileTextures[t.size[0]];s?s.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const s=this._tileTextures[t];return s&&s.length>0?s.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const s=this.imageManager.getPattern(t.from.toString()),n=this.imageManager.getPattern(t.to.toString());return!s||!n}useProgram(t,s){this.cache=this.cache||{};const n=t+(s?s.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[n]||(this.cache[n]=new Cn(this.context,zr[t],s,Dn[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[n]}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 ae(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:s}=this.context.gl;return this.width!==t||this.height!==s}}class Ts{constructor(t,s){this.points=t,this.planes=s}static fromInvProjectionMatrix(t,s,n){const o=Math.pow(2,n),c=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((g=>{const y=1/(g=p.af([],g,t))[3]/s*o;return p.b1(g,g,[y,y,1/g[3],y])})),m=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((g=>{const y=(function(z,A){var B=A[0],V=A[1],$=A[2],N=B*B+V*V+$*$;return N>0&&(N=1/Math.sqrt(N)),z[0]=A[0]*N,z[1]=A[1]*N,z[2]=A[2]*N,z})([],(function(z,A,B){var V=A[0],$=A[1],N=A[2],q=B[0],F=B[1],H=B[2];return z[0]=$*H-N*F,z[1]=N*q-V*H,z[2]=V*F-$*q,z})([],vi([],c[g[0]],c[g[1]]),vi([],c[g[2]],c[g[1]]))),b=-((T=y)[0]*(S=c[g[1]])[0]+T[1]*S[1]+T[2]*S[2]);var T,S;return y.concat(b)}));return new Ts(c,m)}}class Ss{constructor(t,s){this.min=t,this.max=s,this.center=(function(n,o,c){return n[0]=.5*o[0],n[1]=.5*o[1],n[2]=.5*o[2],n})([],(function(n,o,c){return n[0]=o[0]+c[0],n[1]=o[1]+c[1],n[2]=o[2]+c[2],n})([],this.min,this.max))}quadrant(t){const s=[t%2==0,t<2],n=Ai(this.min),o=Ai(this.max);for(let c=0;c<s.length;c++)n[c]=s[c]?this.min[c]:this.center[c],o[c]=s[c]?this.center[c]:this.max[c];return o[2]=this.max[2],new Ss(n,o)}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 s=[[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 n=!0;for(let o=0;o<t.planes.length;o++){const c=t.planes[o];let m=0;for(let g=0;g<s.length;g++)p.b2(c,s[g])>=0&&m++;if(m===0)return 0;m!==s.length&&(n=!1)}if(n)return 2;for(let o=0;o<3;o++){let c=Number.MAX_VALUE,m=-Number.MAX_VALUE;for(let g=0;g<t.points.length;g++){const y=t.points[g][o]-this.min[o];c=Math.min(c,y),m=Math.max(m,y)}if(m<0||c>this.max[o]-this.min[o])return 0}return 1}}class Is{constructor(t=0,s=0,n=0,o=0){if(isNaN(t)||t<0||isNaN(s)||s<0||isNaN(n)||n<0||isNaN(o)||o<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=s,this.left=n,this.right=o}interpolate(t,s,n){return s.top!=null&&t.top!=null&&(this.top=p.y.number(t.top,s.top,n)),s.bottom!=null&&t.bottom!=null&&(this.bottom=p.y.number(t.bottom,s.bottom,n)),s.left!=null&&t.left!=null&&(this.left=p.y.number(t.left,s.left,n)),s.right!=null&&t.right!=null&&(this.right=p.y.number(t.right,s.right,n)),this}getCenter(t,s){const n=p.ac((this.left+t-this.right)/2,0,t),o=p.ac((this.top+s-this.bottom)/2,0,s);return new p.P(n,o)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Is(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const Xn=85.051129;class ks{constructor(t,s,n,o,c){this.tileSize=512,this._renderWorldCopies=c===void 0||!!c,this._minZoom=t||0,this._maxZoom=s||22,this._minPitch=n??0,this._maxPitch=o??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new p.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Is,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const t=new ks(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.lngRange=t.lngRange,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 s=-p.b3(t,-180,180)*Math.PI/180;this.angle!==s&&(this._unmodified=!1,this.angle=s,this._calcMatrices(),this.rotationMatrix=(function(){var n=new p.A(4);return p.A!=Float32Array&&(n[1]=0,n[2]=0),n[0]=1,n[3]=1,n})(),(function(n,o,c){var m=o[0],g=o[1],y=o[2],b=o[3],T=Math.sin(c),S=Math.cos(c);n[0]=m*S+y*T,n[1]=g*S+b*T,n[2]=m*-T+y*S,n[3]=g*-T+b*S})(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const s=p.ac(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==s&&(this._unmodified=!1,this._pitch=s,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 s=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==s&&(this._unmodified=!1,this._zoom=s,this.tileZoom=Math.max(0,Math.floor(s)),this.scale=this.zoomScale(s),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,s,n){this._unmodified=!1,this._edgeInsets.interpolate(t,s,n),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const s=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,s)}getVisibleUnwrappedCoordinates(t){const s=[new p.b4(0,t)];if(this._renderWorldCopies){const n=this.pointCoordinate(new p.P(0,0)),o=this.pointCoordinate(new p.P(this.width,0)),c=this.pointCoordinate(new p.P(this.width,this.height)),m=this.pointCoordinate(new p.P(0,this.height)),g=Math.floor(Math.min(n.x,o.x,c.x,m.x)),y=Math.floor(Math.max(n.x,o.x,c.x,m.x)),b=1;for(let T=g-b;T<=y+b;T++)T!==0&&s.push(new p.b4(T,t))}return s}coveringTiles(t){var s,n;let o=this.coveringZoomLevel(t);const c=o;if(t.minzoom!==void 0&&o<t.minzoom)return[];t.maxzoom!==void 0&&o>t.maxzoom&&(o=t.maxzoom);const m=this.pointCoordinate(this.getCameraPoint()),g=p.Z.fromLngLat(this.center),y=Math.pow(2,o),b=[y*m.x,y*m.y,0],T=[y*g.x,y*g.y,0],S=Ts.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,o);let z=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(z=o);const A=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,B=F=>({aabb:new Ss([F*y,0,0],[(F+1)*y,y,0]),zoom:0,x:0,y:0,wrap:F,fullyVisible:!1}),V=[],$=[],N=o,q=t.reparseOverscaled?c:o;if(this._renderWorldCopies)for(let F=1;F<=3;F++)V.push(B(-F)),V.push(B(F));for(V.push(B(0));V.length>0;){const F=V.pop(),H=F.x,K=F.y;let tt=F.fullyVisible;if(!tt){const ft=F.aabb.intersects(S);if(ft===0)continue;tt=ft===2}const ot=t.terrain?b:T,ut=F.aabb.distanceX(ot),xt=F.aabb.distanceY(ot),Tt=Math.max(Math.abs(ut),Math.abs(xt));if(F.zoom===N||Tt>A+(1<<N-F.zoom)-2&&F.zoom>=z){const ft=N-F.zoom,pt=b[0]-.5-(H<<ft),Et=b[1]-.5-(K<<ft);$.push({tileID:new p.S(F.zoom===N?q:F.zoom,F.wrap,F.zoom,H,K),distanceSq:Ia([T[0]-.5-H,T[1]-.5-K]),tileDistanceToCamera:Math.sqrt(pt*pt+Et*Et)})}else for(let ft=0;ft<4;ft++){const pt=(H<<1)+ft%2,Et=(K<<1)+(ft>>1),Vt=F.zoom+1;let gt=F.aabb.quadrant(ft);if(t.terrain){const bt=new p.S(Vt,F.wrap,Vt,pt,Et),Lt=t.terrain.getMinMaxElevation(bt),pe=(s=Lt.minElevation)!==null&&s!==void 0?s:this.elevation,$t=(n=Lt.maxElevation)!==null&&n!==void 0?n:this.elevation;gt=new Ss([gt.min[0],gt.min[1],pe],[gt.max[0],gt.max[1],$t])}V.push({aabb:gt,zoom:Vt,x:pt,y:Et,wrap:F.wrap,fullyVisible:tt})}}return $.sort(((F,H)=>F.distanceSq-H.distanceSq)).map((F=>F.tileID))}resize(t,s){this.width=t,this.height=s,this.pixelsToGLUnits=[2/t,-2/s],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 s=p.ac(t.lat,-85.051129,Xn);return new p.P(p.O(t.lng)*this.worldSize,p.Q(s)*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 s=this.elevation,n=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,o=this.pointLocation(this.centerPoint,t),c=t.getElevationForLngLatZoom(o,this.tileZoom);if(!(this.elevation-c))return;const m=n+s-c,g=Math.cos(this._pitch)*this.cameraToCenterDistance/m/p.b5(1,o.lat),y=this.scaleZoom(g/this.tileSize);this._elevation=c,this._center=o,this.zoom=y}setLocationAtPoint(t,s){const n=this.pointCoordinate(s),o=this.pointCoordinate(this.centerPoint),c=this.locationCoordinate(t),m=new p.Z(c.x-(n.x-o.x),c.y-(n.y-o.y));this.center=this.coordinateLocation(m),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,s){return s?this.coordinatePoint(this.locationCoordinate(t),s.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,s){return this.coordinateLocation(this.pointCoordinate(t,s))}locationCoordinate(t){return p.Z.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,s){if(s){const z=s.pointCoordinate(t);if(z!=null)return z}const n=[t.x,t.y,0,1],o=[t.x,t.y,1,1];p.af(n,n,this.pixelMatrixInverse),p.af(o,o,this.pixelMatrixInverse);const c=n[3],m=o[3],g=n[1]/c,y=o[1]/m,b=n[2]/c,T=o[2]/m,S=b===T?0:(0-b)/(T-b);return new p.Z(p.y.number(n[0]/c,o[0]/m,S)/this.worldSize,p.y.number(g,y,S)/this.worldSize)}coordinatePoint(t,s=0,n=this.pixelMatrix){const o=[t.x*this.worldSize,t.y*this.worldSize,s,1];return p.af(o,o,n),new p.P(o[0]/o[3],o[1]/o[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return new it().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 it([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,Xn])}calculateTileMatrix(t){const s=t.canonical,n=this.worldSize/this.zoomScale(s.z),o=s.x+Math.pow(2,s.z)*t.wrap,c=p.an(new Float64Array(16));return p.J(c,c,[o*n,s.y*n,0]),p.K(c,c,[n/p.X,n/p.X,1]),c}calculatePosMatrix(t,s=!1){const n=t.key,o=s?this._alignedPosMatrixCache:this._posMatrixCache;if(o[n])return o[n];const c=this.calculateTileMatrix(t);return p.L(c,s?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,c),o[n]=new Float32Array(c),o[n]}calculateFogMatrix(t){const s=t.key,n=this._fogMatrixCache;if(n[s])return n[s];const o=this.calculateTileMatrix(t);return p.L(o,this.fogMatrix,o),n[s]=new Float32Array(o),n[s]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(t,s){s=p.ac(+s,this.minZoom,this.maxZoom);const n={center:new p.N(t.lng,t.lat),zoom:s};let o=this.lngRange;if(!this._renderWorldCopies&&o===null){const F=179.9999999999;o=[-F,F]}const c=this.tileSize*this.zoomScale(n.zoom);let m=0,g=c,y=0,b=c,T=0,S=0;const{x:z,y:A}=this.size;if(this.latRange){const F=this.latRange;m=p.Q(F[1])*c,g=p.Q(F[0])*c,g-m<A&&(T=A/(g-m))}o&&(y=p.b3(p.O(o[0])*c,0,c),b=p.b3(p.O(o[1])*c,0,c),b<y&&(b+=c),b-y<z&&(S=z/(b-y)));const{x:B,y:V}=this.project.call({worldSize:c},t);let $,N;const q=Math.max(S||0,T||0);if(q){const F=new p.P(S?(b+y)/2:B,T?(g+m)/2:V);return n.center=this.unproject.call({worldSize:c},F).wrap(),n.zoom+=this.scaleZoom(q),n}if(this.latRange){const F=A/2;V-F<m&&(N=m+F),V+F>g&&(N=g-F)}if(o){const F=(y+b)/2;let H=B;this._renderWorldCopies&&(H=p.b3(B,F-c/2,F+c/2));const K=z/2;H-K<y&&($=y+K),H+K>b&&($=b-K)}if($!==void 0||N!==void 0){const F=new p.P($??B,N??V);n.center=this.unproject.call({worldSize:c},F).wrap()}return n}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:s,zoom:n}=this.getConstrained(this.center,this.zoom);this.center=s,this.zoom=n,this._unmodified=t,this._constraining=!1}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,s=this.point.x,n=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=p.b5(1,this.center.lat)*this.worldSize;let o=p.an(new Float64Array(16));p.K(o,o,[this.width/2,-this.height/2,1]),p.J(o,o,[1,-1,0]),this.labelPlaneMatrix=o,o=p.an(new Float64Array(16)),p.K(o,o,[1,-1,1]),p.J(o,o,[-1,-1,0]),p.K(o,o,[2/this.width,2/this.height,1]),this.glCoordMatrix=o;const c=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),m=Math.min(this.elevation,this.minElevationForCurrentTile),g=c-m*this._pixelPerMeter/Math.cos(this._pitch),y=m<0?g:c,b=Math.PI/2+this._pitch,T=this._fov*(.5+t.y/this.height),S=Math.sin(T)*y/Math.sin(p.ac(Math.PI-b-T,.01,Math.PI-.01)),z=this.getHorizon(),A=2*Math.atan(z/this.cameraToCenterDistance)*(.5+t.y/(2*z)),B=Math.sin(A)*y/Math.sin(p.ac(Math.PI-b-A,.01,Math.PI-.01)),V=Math.min(S,B);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*V+y),this.nearZ=this.height/50,o=new Float64Array(16),p.b6(o,this._fov,this.width/this.height,this.nearZ,this.farZ),o[8]=2*-t.x/this.width,o[9]=2*t.y/this.height,this.projectionMatrix=p.ae(o),p.K(o,o,[1,-1,1]),p.J(o,o,[0,0,-this.cameraToCenterDistance]),p.b7(o,o,this._pitch),p.ad(o,o,this.angle),p.J(o,o,[-s,-n,0]),this.mercatorMatrix=p.K([],o,[this.worldSize,this.worldSize,this.worldSize]),p.K(o,o,[1,1,this._pixelPerMeter]),this.pixelMatrix=p.L(new Float64Array(16),this.labelPlaneMatrix,o),p.J(o,o,[0,0,-this.elevation]),this.modelViewProjectionMatrix=o,this.invModelViewProjectionMatrix=p.as([],o),this.fogMatrix=new Float64Array(16),p.b6(this.fogMatrix,this._fov,this.width/this.height,c,this.farZ),this.fogMatrix[8]=2*-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.ad(this.fogMatrix,this.fogMatrix,this.angle),p.J(this.fogMatrix,this.fogMatrix,[-s,-n,0]),p.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),p.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=p.L(new Float64Array(16),this.labelPlaneMatrix,o);const $=this.width%2/2,N=this.height%2/2,q=Math.cos(this.angle),F=Math.sin(this.angle),H=s-Math.round(s)+q*$+F*N,K=n-Math.round(n)+q*N+F*$,tt=new Float64Array(o);if(p.J(tt,tt,[H>.5?H-1:H,K>.5?K-1:K,0]),this.alignedModelViewProjectionMatrix=tt,o=p.as(new Float64Array(16),this.pixelMatrix),!o)throw new Error("failed to invert matrix");this.pixelMatrixInverse=o,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const t=this.pointCoordinate(new p.P(0,0)),s=[t.x*this.worldSize,t.y*this.worldSize,0,1];return p.af(s,s,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 s=this.getCameraPoint();if(t.length===1)return[t[0],s];{let n=s.x,o=s.y,c=s.x,m=s.y;for(const g of t)n=Math.min(n,g.x),o=Math.min(o,g.y),c=Math.max(c,g.x),m=Math.max(m,g.y);return[new p.P(n,o),new p.P(c,o),new p.P(c,m),new p.P(n,m),new p.P(n,o)]}}lngLatToCameraDepth(t,s){const n=this.locationCoordinate(t),o=[n.x*this.worldSize,n.y*this.worldSize,s,1];return p.af(o,o,this.modelViewProjectionMatrix),o[2]/o[3]}}function ca(u,t){let s,n=!1,o=null,c=null;const m=()=>{o=null,n&&(u.apply(c,s),o=setTimeout(m,t),n=!1)};return(...g)=>(n=!0,c=this,s=g,o||m(),o)}class Ga{constructor(t){this._getCurrentHash=()=>{const s=window.location.hash.replace("#","");if(this._hashName){let n;return s.split("&").map((o=>o.split("="))).forEach((o=>{o[0]===this._hashName&&(n=o)})),(n&&n[1]||"").split("/")}return s.split("/")},this._onHashChange=()=>{const s=this._getCurrentHash();if(s.length>=3&&!s.some((n=>isNaN(n)))){const n=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(s[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+s[2],+s[1]],zoom:+s[0],bearing:n,pitch:+(s[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const s=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,s)},this._removeHash=()=>{const s=this._getCurrentHash();if(s.length===0)return;const n=s.join("/");let o=n;o.split("&").length>0&&(o=o.split("&")[0]),this._hashName&&(o=`${this._hashName}=${n}`);let c=window.location.hash.replace(o,"");c.startsWith("#&")?c=c.slice(0,1)+c.slice(2):c==="#"&&(c="");let m=window.location.href.replace(/(#.+)?$/,c);m=m.replace("&&","&"),window.history.replaceState(window.history.state,null,m)},this._updateHash=ca(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()),this._removeHash(),delete this._map,this}getHashString(t){const s=this._map.getCenter(),n=Math.round(100*this._map.getZoom())/100,o=Math.ceil((n*Math.LN2+Math.log(512/360/.5))/Math.LN10),c=Math.pow(10,o),m=Math.round(s.lng*c)/c,g=Math.round(s.lat*c)/c,y=this._map.getBearing(),b=this._map.getPitch();let T="";if(T+=t?`/${m}/${g}/${n}`:`${n}/${g}/${m}`,(y||b)&&(T+="/"+Math.round(10*y)/10),b&&(T+=`/${Math.round(b)}`),this._hashName){const S=this._hashName;let z=!1;const A=window.location.hash.slice(1).split("&").map((B=>{const V=B.split("=")[0];return V===S?(z=!0,`${V}=${T}`):B})).filter((B=>B));return z||A.push(`${S}=${T}`),`#${A.join("&")}`}return`#${T}`}}const Xa={linearity:.3,easing:p.b8(0,0,.3,1)},Hn=p.e({deceleration:2500,maxSpeed:1400},Xa),ic=p.e({deceleration:20,maxSpeed:1400},Xa),rl=p.e({deceleration:1e3,maxSpeed:360},Xa),Ha=p.e({deceleration:1e3,maxSpeed:90},Xa);class Wn{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:mt.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,s=mt.now();for(;t.length>0&&s-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const s={zoom:0,bearing:0,pitch:0,pan:new p.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:c}of this._inertiaBuffer)s.zoom+=c.zoomDelta||0,s.bearing+=c.bearingDelta||0,s.pitch+=c.pitchDelta||0,c.panDelta&&s.pan._add(c.panDelta),c.around&&(s.around=c.around),c.pinchAround&&(s.pinchAround=c.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(s.pan.mag()){const c=ha(s.pan.mag(),n,p.e({},Hn,t||{}));o.offset=s.pan.mult(c.amount/s.pan.mag()),o.center=this._map.transform.center,ua(o,c)}if(s.zoom){const c=ha(s.zoom,n,ic);o.zoom=this._map.transform.zoom+c.amount,ua(o,c)}if(s.bearing){const c=ha(s.bearing,n,rl);o.bearing=this._map.transform.bearing+p.ac(c.amount,-179,179),ua(o,c)}if(s.pitch){const c=ha(s.pitch,n,Ha);o.pitch=this._map.transform.pitch+c.amount,ua(o,c)}if(o.zoom||o.bearing){const c=s.pinchAround===void 0?s.around:s.pinchAround;o.around=c?this._map.unproject(c):this._map.getCenter()}return this.clear(),p.e(o,{noMoveStart:!0})}}function ua(u,t){(!u.duration||u.duration<t.duration)&&(u.duration=t.duration,u.easing=t.easing)}function ha(u,t,s){const{maxSpeed:n,linearity:o,deceleration:c}=s,m=p.ac(u*o/(t/1e3),-n,n),g=Math.abs(m)/(c*o);return{easing:s.easing,duration:1e3*g,amount:m*(g/2)}}class Oe extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,s,n,o={}){const c=at.mousePos(s.getCanvas(),n),m=s.unproject(c);super(t,p.e({point:c,lngLat:m,originalEvent:n},o)),this._defaultPrevented=!1,this.target=s}}class Qr extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,s,n){const o=t==="touchend"?n.changedTouches:n.touches,c=at.touchPos(s.getCanvasContainer(),o),m=c.map((y=>s.unproject(y))),g=c.reduce(((y,b,T,S)=>y.add(b.div(S.length))),new p.P(0,0));super(t,{points:c,point:g,lngLats:m,lngLat:s.unproject(g),originalEvent:n}),this._defaultPrevented=!1}}class sl extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,s,n){super(t,{originalEvent:n}),this._defaultPrevented=!1}}class al{constructor(t,s){this._map=t,this._clickTolerance=s.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new sl(t.type,this._map,t))}mousedown(t,s){return this._mousedownPos=s,this._firePreventable(new Oe(t.type,this._map,t))}mouseup(t){this._map.fire(new Oe(t.type,this._map,t))}click(t,s){this._mousedownPos&&this._mousedownPos.dist(s)>=this._clickTolerance||this._map.fire(new Oe(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Oe(t.type,this._map,t))}mouseover(t){this._map.fire(new Oe(t.type,this._map,t))}mouseout(t){this._map.fire(new Oe(t.type,this._map,t))}touchstart(t){return this._firePreventable(new Qr(t.type,this._map,t))}touchmove(t){this._map.fire(new Qr(t.type,this._map,t))}touchend(t){this._map.fire(new Qr(t.type,this._map,t))}touchcancel(t){this._map.fire(new Qr(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class we{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Oe(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Oe("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Oe(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Vi{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 mi{constructor(t,s){this._map=t,this._tr=new Vi(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=s.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,s){this.isEnabled()&&t.shiftKey&&t.button===0&&(at.disableDrag(),this._startPos=this._lastPos=s,this._active=!0)}mousemoveWindow(t,s){if(!this._active)return;const n=s;if(this._lastPos.equals(n)||!this._box&&n.dist(this._startPos)<this._clickTolerance)return;const o=this._startPos;this._lastPos=n,this._box||(this._box=at.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));const c=Math.min(o.x,n.x),m=Math.max(o.x,n.x),g=Math.min(o.y,n.y),y=Math.max(o.y,n.y);at.setTransform(this._box,`translate(${c}px,${g}px)`),this._box.style.width=m-c+"px",this._box.style.height=y-g+"px"}mouseupWindow(t,s){if(!this._active||t.button!==0)return;const n=this._startPos,o=s;if(this.reset(),at.suppressClick(),n.x!==o.x||n.y!==o.y)return this._map.fire(new p.k("boxzoomend",{originalEvent:t})),{cameraAnimation:c=>c.fitScreenCoordinates(n,o,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&&(at.remove(this._box),this._box=null),at.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,s){return this._map.fire(new p.k(t,{originalEvent:s}))}}function da(u,t){if(u.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${u.length}, points ${t.length}`);const s={};for(let n=0;n<u.length;n++)s[u[n].identifier]=t[n];return s}class Kn{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,s,n){(this.centroid||n.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=t.timeStamp),n.length===this.numTouches&&(this.centroid=(function(o){const c=new p.P(0,0);for(const m of o)c._add(m);return c.div(o.length)})(s),this.touches=da(n,s)))}touchmove(t,s,n){if(this.aborted||!this.centroid)return;const o=da(n,s);for(const c in this.touches){const m=o[c];(!m||m.dist(this.touches[c])>30)&&(this.aborted=!0)}}touchend(t,s,n){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),n.length===0){const o=!this.aborted&&this.centroid;if(this.reset(),o)return o}}}class Wa{constructor(t){this.singleTap=new Kn(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,s,n){this.singleTap.touchstart(t,s,n)}touchmove(t,s,n){this.singleTap.touchmove(t,s,n)}touchend(t,s,n){const o=this.singleTap.touchend(t,s,n);if(o){const c=t.timeStamp-this.lastTime<500,m=!this.lastTap||this.lastTap.dist(o)<30;if(c&&m||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class Ms{constructor(t){this._tr=new Vi(t),this._zoomIn=new Wa({numTouches:1,numTaps:2}),this._zoomOut=new Wa({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,s,n){this._zoomIn.touchstart(t,s,n),this._zoomOut.touchstart(t,s,n)}touchmove(t,s,n){this._zoomIn.touchmove(t,s,n),this._zoomOut.touchmove(t,s,n)}touchend(t,s,n){const o=this._zoomIn.touchend(t,s,n),c=this._zoomOut.touchend(t,s,n),m=this._tr;return o?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:m.zoom+1,around:m.unproject(o)},{originalEvent:t})}):c?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:m.zoom-1,around:m.unproject(c)},{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 gr{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 s=this._moveFunction(...t);if(s.bearingDelta||s.pitchDelta||s.around||s.panDelta)return this._active=!0,s}dragStart(t,s){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=s.length?s[0]:s,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,s){if(!this.isEnabled())return;const n=this._lastPoint;if(!n)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const o=s.length?s[0]:s;return!this._moved&&o.dist(n)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=o,this._move(n,o))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&at.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 Jn={0:1,2:2};class Ka{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){const s=at.mouseButton(t);this._eventButton=s}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!(function(s,n){const o=Jn[n];return s.buttons===void 0||(s.buttons&o)!==o})(t,this._eventButton)}isValidEndEvent(t){return at.mouseButton(t)===this._eventButton}}class Yn{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 Ja=u=>{u.mousedown=u.dragStart,u.mousemoveWindow=u.dragMove,u.mouseup=u.dragEnd,u.contextmenu=t=>{t.preventDefault()}},Qn=({enable:u,clickTolerance:t,bearingDegreesPerPixelMoved:s=.8})=>{const n=new Ka({checkCorrectEvent:o=>at.mouseButton(o)===0&&o.ctrlKey||at.mouseButton(o)===2});return new gr({clickTolerance:t,move:(o,c)=>({bearingDelta:(c.x-o.x)*s}),moveStateManager:n,enable:u,assignEvents:Ja})},to=({enable:u,clickTolerance:t,pitchDegreesPerPixelMoved:s=-.5})=>{const n=new Ka({checkCorrectEvent:o=>at.mouseButton(o)===0&&o.ctrlKey||at.mouseButton(o)===2});return new gr({clickTolerance:t,move:(o,c)=>({pitchDelta:(c.y-o.y)*s}),moveStateManager:n,enable:u,assignEvents:Ja})};class ts{constructor(t,s){this._clickTolerance=t.clickTolerance||1,this._map=s,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new p.P(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,s,n){return this._calculateTransform(t,s,n)}touchmove(t,s,n){if(this._active){if(!this._shouldBePrevented(n.length))return t.preventDefault(),this._calculateTransform(t,s,n);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t)}}touchend(t,s,n){this._calculateTransform(t,s,n),this._active&&this._shouldBePrevented(n.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,s,n){n.length>0&&(this._active=!0);const o=da(n,s),c=new p.P(0,0),m=new p.P(0,0);let g=0;for(const b in o){const T=o[b],S=this._touches[b];S&&(c._add(T),m._add(T.sub(S)),g++,o[b]=T)}if(this._touches=o,this._shouldBePrevented(g)||!m.mag())return;const y=m.div(g);return this._sum._add(y),this._sum.mag()<this._clickTolerance?void 0:{around:c.div(g),panDelta:y}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ya{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,s,n){this._firstTwoTouches||n.length<2||(this._firstTwoTouches=[n[0].identifier,n[1].identifier],this._start([s[0],s[1]]))}touchmove(t,s,n){if(!this._firstTwoTouches)return;t.preventDefault();const[o,c]=this._firstTwoTouches,m=pa(n,s,o),g=pa(n,s,c);if(!m||!g)return;const y=this._aroundCenter?null:m.add(g).div(2);return this._move([m,g],y,t)}touchend(t,s,n){if(!this._firstTwoTouches)return;const[o,c]=this._firstTwoTouches,m=pa(n,s,o),g=pa(n,s,c);m&&g||(this._active&&at.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 pa(u,t,s){for(let n=0;n<u.length;n++)if(u[n].identifier===s)return t[n]}function eo(u,t){return Math.log(u/t)/Math.LN2}class io extends Ya{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,s){const n=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(eo(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:eo(this._distance,n),pinchAround:s}}}function ro(u,t){return 180*u.angleWith(t)/Math.PI}class so extends Ya{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,s,n){const o=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:ro(this._vector,o),pinchAround:s}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const s=25/(Math.PI*this._minDiameter)*360,n=ro(t,this._startVector);return Math.abs(n)<s}}function Qa(u){return Math.abs(u.y)>Math.abs(u.x)}class Es extends Ya{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,s,n){super.touchstart(t,s,n),this._currentTouchCount=n.length}_start(t){this._lastPoints=t,Qa(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,s,n){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const o=t[0].sub(this._lastPoints[0]),c=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(o,c,n.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+c.y)/2*-.5}):void 0}gestureBeginsVertically(t,s,n){if(this._valid!==void 0)return this._valid;const o=t.mag()>=2,c=s.mag()>=2;if(!o&&!c)return;if(!o||!c)return this._firstMove===void 0&&(this._firstMove=n),n-this._firstMove<100&&void 0;const m=t.y>0==s.y>0;return Qa(t)&&Qa(s)&&m}}const nl={panStep:100,bearingStep:15,pitchStep:10};class Si{constructor(t){this._tr=new Vi(t);const s=nl;this._panStep=s.panStep,this._bearingStep=s.bearingStep,this._pitchStep=s.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let s=0,n=0,o=0,c=0,m=0;switch(t.keyCode){case 61:case 107:case 171:case 187:s=1;break;case 189:case 109:case 173:s=-1;break;case 37:t.shiftKey?n=-1:(t.preventDefault(),c=-1);break;case 39:t.shiftKey?n=1:(t.preventDefault(),c=1);break;case 38:t.shiftKey?o=1:(t.preventDefault(),m=-1);break;case 40:t.shiftKey?o=-1:(t.preventDefault(),m=1);break;default:return}return this._rotationDisabled&&(n=0,o=0),{cameraAnimation:g=>{const y=this._tr;g.easeTo({duration:300,easeId:"keyboardHandler",easing:ar,zoom:s?Math.round(y.zoom)+s*(t.shiftKey?2:1):y.zoom,bearing:y.bearing+n*this._bearingStep,pitch:y.pitch+o*this._pitchStep,offset:[-c*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 ar(u){return u*(2-u)}const ao=4.000244140625;class ji{constructor(t,s){this._onTimeout=n=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(n)},this._map=t,this._tr=new Vi(t),this._triggerRenderFrame=s,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)}_shouldBePrevented(t){return!!this._map.cooperativeGestures.isEnabled()&&!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t))}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",t);let s=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const n=mt.now(),o=n-(this._lastWheelEventTime||0);this._lastWheelEventTime=n,s!==0&&s%ao==0?this._type="wheel":s!==0&&Math.abs(s)<4?this._type="trackpad":o>400?(this._type=null,this._lastValue=s,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(o*s)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,s+=this._lastValue)),t.shiftKey&&s&&(s/=4),this._type&&(this._lastWheelEvent=t,this._delta-=s,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 s=at.mousePos(this._map.getCanvas(),t),n=this._tr;this._around=s.y>n.transform.height/2-n.transform.getHorizon()?p.N.convert(this._aroundCenter?n.center:n.unproject(s)):p.N.convert(n.center),this._aroundPoint=n.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 y=this._type==="wheel"&&Math.abs(this._delta)>ao?this._wheelZoomRate:this._defaultZoomRate;let b=2/(1+Math.exp(-Math.abs(this._delta*y)));this._delta<0&&b!==0&&(b=1/b);const T=typeof this._targetZoom=="number"?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(T*b))),this._type==="wheel"&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const s=typeof this._targetZoom=="number"?this._targetZoom:t.zoom,n=this._startZoom,o=this._easing;let c,m=!1;const g=mt.now()-this._lastWheelEventTime;if(this._type==="wheel"&&n&&o&&g){const y=Math.min(g/200,1),b=o(y);c=p.y.number(n,s,b),y<1?this._frameId||(this._frameId=!0):m=!0}else c=s,m=!0;return this._active=!0,m&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!m,zoomDelta:c-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let s=p.b9;if(this._prevEase){const n=this._prevEase,o=(mt.now()-n.start)/n.duration,c=n.easing(o+.01)-n.easing(o),m=.27/Math.sqrt(c*c+1e-4)*.01,g=Math.sqrt(.0729-m*m);s=p.b8(m,g,.25,1)}return this._prevEase={start:mt.now(),duration:t,easing:s},s}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class es{constructor(t,s){this._clickZoom=t,this._tapZoom=s}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 rc{constructor(t){this._tr=new Vi(t),this.reset()}reset(){this._active=!1}dblclick(t,s){return t.preventDefault(),{cameraAnimation:n=>{n.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(s)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class sc{constructor(){this._tap=new Wa({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,s,n){if(!this._swipePoint)if(this._tapTime){const o=s[0],c=t.timeStamp-this._tapTime<500,m=this._tapPoint.dist(o)<30;c&&m?n.length>0&&(this._swipePoint=o,this._swipeTouch=n[0].identifier):this.reset()}else this._tap.touchstart(t,s,n)}touchmove(t,s,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;const o=s[0],c=o.y-this._swipePoint.y;return this._swipePoint=o,t.preventDefault(),this._active=!0,{zoomDelta:c/128}}}else this._tap.touchmove(t,s,n)}touchend(t,s,n){if(this._tapTime)this._swipePoint&&n.length===0&&this.reset();else{const o=this._tap.touchend(t,s,n);o&&(this._tapTime=t.timeStamp,this._tapPoint=o)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ol{constructor(t,s,n){this._el=t,this._mousePan=s,this._touchPan=n}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 ll{constructor(t,s,n){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=s,this._mousePitch=n}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class no{constructor(t,s,n,o){this._el=t,this._touchZoom=s,this._touchRotate=n,this._tapDragZoom=o,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 zs{constructor(t,s){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=t,this._options=s,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=at.create("div","maplibregl-cooperative-gesture-screen",t);let s=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(s=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const n=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),o=document.createElement("div");o.className="maplibregl-desktop-message",o.textContent=s,this._container.appendChild(o);const c=document.createElement("div");c.className="maplibregl-mobile-message",c.textContent=n,this._container.appendChild(c),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(at.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(t){return t[this._bypassKey]}notifyGestureBlocked(t,s){this._enabled&&(this._map.fire(new p.k("cooperativegestureprevented",{gestureType:t,originalEvent:s})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const Ii=u=>u.zoom||u.drag||u.pitch||u.rotate;class It extends p.k{}function tn(u){return u.panDelta&&u.panDelta.mag()||u.zoomDelta||u.bearingDelta||u.pitchDelta}class oo{constructor(t,s){this.handleWindowEvent=o=>{this.handleEvent(o,`${o.type}Window`)},this.handleEvent=(o,c)=>{if(o.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const m=o.type==="renderFrame"?void 0:o,g={needsRenderFrame:!1},y={},b={},T=o.touches,S=T?this._getMapTouches(T):void 0,z=S?at.touchPos(this._map.getCanvas(),S):at.mousePos(this._map.getCanvas(),o);for(const{handlerName:V,handler:$,allowed:N}of this._handlers){if(!$.isEnabled())continue;let q;this._blockedByActive(b,N,V)?$.reset():$[c||o.type]&&(q=$[c||o.type](o,z,S),this.mergeHandlerResult(g,y,q,V,m),q&&q.needsRenderFrame&&this._triggerRenderFrame()),(q||$.isActive())&&(b[V]=$)}const A={};for(const V in this._previousActiveHandlers)b[V]||(A[V]=m);this._previousActiveHandlers=b,(Object.keys(A).length||tn(g))&&(this._changes.push([g,y,A]),this._triggerRenderFrame()),(Object.keys(b).length||tn(g))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:B}=g;B&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],B(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Wn(t),this._bearingSnap=s.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(s);const n=this._el;this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[window,"blur",void 0]];for(const[o,c,m]of this._listeners)at.addEventListener(o,c,o===document?this.handleWindowEvent:this.handleEvent,m)}destroy(){for(const[t,s,n]of this._listeners)at.removeEventListener(t,s,t===document?this.handleWindowEvent:this.handleEvent,n)}_addDefaultHandlers(t){const s=this._map,n=s.getCanvasContainer();this._add("mapEvent",new al(s,t));const o=s.boxZoom=new mi(s,t);this._add("boxZoom",o),t.interactive&&t.boxZoom&&o.enable();const c=s.cooperativeGestures=new zs(s,t.cooperativeGestures);this._add("cooperativeGestures",c),t.cooperativeGestures&&c.enable();const m=new Ms(s),g=new rc(s);s.doubleClickZoom=new es(g,m),this._add("tapZoom",m),this._add("clickZoom",g),t.interactive&&t.doubleClickZoom&&s.doubleClickZoom.enable();const y=new sc;this._add("tapDragZoom",y);const b=s.touchPitch=new Es(s);this._add("touchPitch",b),t.interactive&&t.touchPitch&&s.touchPitch.enable(t.touchPitch);const T=Qn(t),S=to(t);s.dragRotate=new ll(t,T,S),this._add("mouseRotate",T,["mousePitch"]),this._add("mousePitch",S,["mouseRotate"]),t.interactive&&t.dragRotate&&s.dragRotate.enable();const z=(({enable:q,clickTolerance:F})=>{const H=new Ka({checkCorrectEvent:K=>at.mouseButton(K)===0&&!K.ctrlKey});return new gr({clickTolerance:F,move:(K,tt)=>({around:tt,panDelta:tt.sub(K)}),activateOnStart:!0,moveStateManager:H,enable:q,assignEvents:Ja})})(t),A=new ts(t,s);s.dragPan=new ol(n,z,A),this._add("mousePan",z),this._add("touchPan",A,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&s.dragPan.enable(t.dragPan);const B=new so,V=new io;s.touchZoomRotate=new no(n,V,B,y),this._add("touchRotate",B,["touchPan","touchZoom"]),this._add("touchZoom",V,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&s.touchZoomRotate.enable(t.touchZoomRotate);const $=s.scrollZoom=new ji(s,(()=>this._triggerRenderFrame()));this._add("scrollZoom",$,["mousePan"]),t.interactive&&t.scrollZoom&&s.scrollZoom.enable(t.scrollZoom);const N=s.keyboard=new Si(s);this._add("keyboard",N),t.interactive&&t.keyboard&&s.keyboard.enable(),this._add("blockableMapEvent",new we(s))}_add(t,s,n){this._handlers.push({handlerName:t,handler:s,allowed:n}),this._handlersById[t]=s}stop(t){if(!this._updatingCamera){for(const{handler:s}of this._handlers)s.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!!Ii(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,s,n){for(const o in t)if(o!==n&&(!s||s.indexOf(o)<0))return!0;return!1}_getMapTouches(t){const s=[];for(const n of t)this._el.contains(n.target)&&s.push(n);return s}mergeHandlerResult(t,s,n,o,c){if(!n)return;p.e(t,n);const m={handlerName:o,originalEvent:n.originalEvent||c};n.zoomDelta!==void 0&&(s.zoom=m),n.panDelta!==void 0&&(s.drag=m),n.pitchDelta!==void 0&&(s.pitch=m),n.bearingDelta!==void 0&&(s.rotate=m)}_applyChanges(){const t={},s={},n={};for(const[o,c,m]of this._changes)o.panDelta&&(t.panDelta=(t.panDelta||new p.P(0,0))._add(o.panDelta)),o.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+o.pitchDelta),o.around!==void 0&&(t.around=o.around),o.pinchAround!==void 0&&(t.pinchAround=o.pinchAround),o.noInertia&&(t.noInertia=o.noInertia),p.e(s,c),p.e(n,m);this._updateMapTransform(t,s,n),this._changes=[]}_updateMapTransform(t,s,n){const o=this._map,c=o._getTransformForUpdate(),m=o.terrain;if(!(tn(t)||m&&this._terrainMovement))return this._fireEvents(s,n,!0);let{panDelta:g,zoomDelta:y,bearingDelta:b,pitchDelta:T,around:S,pinchAround:z}=t;z!==void 0&&(S=z),o._stop(!0),S=S||o.transform.centerPoint;const A=c.pointLocation(g?S.sub(g):S);b&&(c.bearing+=b),T&&(c.pitch+=T),y&&(c.zoom+=y),m?this._terrainMovement||!s.drag&&!s.zoom?s.drag&&this._terrainMovement?c.center=c.pointLocation(c.centerPoint.sub(g)):c.setLocationAtPoint(A,S):(this._terrainMovement=!0,this._map._elevationFreeze=!0,c.setLocationAtPoint(A,S)):c.setLocationAtPoint(A,S),o._applyUpdatedTransform(c),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(s,n,!0)}_fireEvents(t,s,n){const o=Ii(this._eventsInProgress),c=Ii(t),m={};for(const S in t){const{originalEvent:z}=t[S];this._eventsInProgress[S]||(m[`${S}start`]=z),this._eventsInProgress[S]=t[S]}!o&&c&&this._fireEvent("movestart",c.originalEvent);for(const S in m)this._fireEvent(S,m[S]);c&&this._fireEvent("move",c.originalEvent);for(const S in t){const{originalEvent:z}=t[S];this._fireEvent(S,z)}const g={};let y;for(const S in this._eventsInProgress){const{handlerName:z,originalEvent:A}=this._eventsInProgress[S];this._handlersById[z].isActive()||(delete this._eventsInProgress[S],y=s[z]||A,g[`${S}end`]=y)}for(const S in g)this._fireEvent(S,g[S]);const b=Ii(this._eventsInProgress),T=(o||c)&&!b;if(T&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const S=this._map._getTransformForUpdate();S.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(S)}if(n&&T){this._updatingCamera=!0;const S=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),z=A=>A!==0&&-this._bearingSnap<A&&A<this._bearingSnap;!S||!S.essential&&mt.prefersReducedMotion?(this._map.fire(new p.k("moveend",{originalEvent:y})),z(this._map.getBearing())&&this._map.resetNorth()):(z(S.bearing||this._map.getBearing())&&(S.bearing=0),S.freezeElevation=!0,this._map.easeTo(S,{originalEvent:y})),this._updatingCamera=!1}}_fireEvent(t,s){this._map.fire(new p.k(t,s?{originalEvent:s}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new It("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class cl extends p.E{constructor(t,s){super(),this._renderFrameCallback=()=>{const n=Math.min((mt.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(n)),n<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=s.bearingSnap,this.on("moveend",(()=>{delete this._requestedCameraState}))}getCenter(){return new p.N(this.transform.center.lng,this.transform.center.lat)}setCenter(t,s){return this.jumpTo({center:t},s)}panBy(t,s,n){return t=p.P.convert(t).mult(-1),this.panTo(this.transform.center,p.e({offset:t},s),n)}panTo(t,s,n){return this.easeTo(p.e({center:t},s),n)}getZoom(){return this.transform.zoom}setZoom(t,s){return this.jumpTo({zoom:t},s),this}zoomTo(t,s,n){return this.easeTo(p.e({zoom:t},s),n)}zoomIn(t,s){return this.zoomTo(this.getZoom()+1,t,s),this}zoomOut(t,s){return this.zoomTo(this.getZoom()-1,t,s),this}getBearing(){return this.transform.bearing}setBearing(t,s){return this.jumpTo({bearing:t},s),this}getPadding(){return this.transform.padding}setPadding(t,s){return this.jumpTo({padding:t},s),this}rotateTo(t,s,n){return this.easeTo(p.e({bearing:t},s),n)}resetNorth(t,s){return this.rotateTo(0,p.e({duration:1e3},t),s),this}resetNorthPitch(t,s){return this.easeTo(p.e({bearing:0,pitch:0,duration:1e3},t),s),this}snapToNorth(t,s){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,s):this}getPitch(){return this.transform.pitch}setPitch(t,s){return this.jumpTo({pitch:t},s),this}cameraForBounds(t,s){t=it.convert(t).adjustAntiMeridian();const n=s&&s.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),n,s)}_cameraForBoxAndBearing(t,s,n,o){const c={top:0,bottom:0,right:0,left:0};if(typeof(o=p.e({padding:c,offset:[0,0],maxZoom:this.transform.maxZoom},o)).padding=="number"){const ft=o.padding;o.padding={top:ft,bottom:ft,right:ft,left:ft}}o.padding=p.e(c,o.padding);const m=this.transform,g=m.padding,y=new it(t,s),b=m.project(y.getNorthWest()),T=m.project(y.getNorthEast()),S=m.project(y.getSouthEast()),z=m.project(y.getSouthWest()),A=p.ba(-n),B=b.rotate(A),V=T.rotate(A),$=S.rotate(A),N=z.rotate(A),q=new p.P(Math.max(B.x,V.x,N.x,$.x),Math.max(B.y,V.y,N.y,$.y)),F=new p.P(Math.min(B.x,V.x,N.x,$.x),Math.min(B.y,V.y,N.y,$.y)),H=q.sub(F),K=(m.width-(g.left+g.right+o.padding.left+o.padding.right))/H.x,tt=(m.height-(g.top+g.bottom+o.padding.top+o.padding.bottom))/H.y;if(tt<0||K<0)return void p.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const ot=Math.min(m.scaleZoom(m.scale*Math.min(K,tt)),o.maxZoom),ut=p.P.convert(o.offset),xt=new p.P((o.padding.left-o.padding.right)/2,(o.padding.top-o.padding.bottom)/2).rotate(p.ba(n)),Tt=ut.add(xt).mult(m.scale/m.zoomScale(ot));return{center:m.unproject(b.add(S).div(2).sub(Tt)),zoom:ot,bearing:n}}fitBounds(t,s,n){return this._fitInternal(this.cameraForBounds(t,s),s,n)}fitScreenCoordinates(t,s,n,o,c){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(p.P.convert(t)),this.transform.pointLocation(p.P.convert(s)),n,o),o,c)}_fitInternal(t,s,n){return t?(delete(s=p.e(t,s)).padding,s.linear?this.easeTo(s,n):this.flyTo(s,n)):this}jumpTo(t,s){this.stop();const n=this._getTransformForUpdate();let o=!1,c=!1,m=!1;return"zoom"in t&&n.zoom!==+t.zoom&&(o=!0,n.zoom=+t.zoom),t.center!==void 0&&(n.center=p.N.convert(t.center)),"bearing"in t&&n.bearing!==+t.bearing&&(c=!0,n.bearing=+t.bearing),"pitch"in t&&n.pitch!==+t.pitch&&(m=!0,n.pitch=+t.pitch),t.padding==null||n.isPaddingEqual(t.padding)||(n.padding=t.padding),this._applyUpdatedTransform(n),this.fire(new p.k("movestart",s)).fire(new p.k("move",s)),o&&this.fire(new p.k("zoomstart",s)).fire(new p.k("zoom",s)).fire(new p.k("zoomend",s)),c&&this.fire(new p.k("rotatestart",s)).fire(new p.k("rotate",s)).fire(new p.k("rotateend",s)),m&&this.fire(new p.k("pitchstart",s)).fire(new p.k("pitch",s)).fire(new p.k("pitchend",s)),this.fire(new p.k("moveend",s))}calculateCameraOptionsFromTo(t,s,n,o=0){const c=p.Z.fromLngLat(t,s),m=p.Z.fromLngLat(n,o),g=m.x-c.x,y=m.y-c.y,b=m.z-c.z,T=Math.hypot(g,y,b);if(T===0)throw new Error("Can't calculate camera options with same From and To");const S=Math.hypot(g,y),z=this.transform.scaleZoom(this.transform.cameraToCenterDistance/T/this.transform.tileSize),A=180*Math.atan2(g,-y)/Math.PI;let B=180*Math.acos(S/T)/Math.PI;return B=b<0?90-B:90+B,{center:m.toLngLat(),zoom:z,pitch:B,bearing:A}}easeTo(t,s){var n;this._stop(!1,t.easeId),((t=p.e({offset:[0,0],duration:500,easing:p.b9},t)).animate===!1||!t.essential&&mt.prefersReducedMotion)&&(t.duration=0);const o=this._getTransformForUpdate(),c=o.zoom,m=o.bearing,g=o.pitch,y=o.padding,b="bearing"in t?this._normalizeBearing(t.bearing,m):m,T="pitch"in t?+t.pitch:g,S="padding"in t?t.padding:o.padding,z=p.P.convert(t.offset);let A=o.centerPoint.add(z);const B=o.pointLocation(A),{center:V,zoom:$}=o.getConstrained(p.N.convert(t.center||B),(n=t.zoom)!==null&&n!==void 0?n:c);this._normalizeCenter(V,o);const N=o.project(B),q=o.project(V).sub(N),F=o.zoomScale($-c);let H,K;t.around&&(H=p.N.convert(t.around),K=o.locationPoint(H));const tt={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||$!==c,this._rotating=this._rotating||m!==b,this._pitching=this._pitching||T!==g,this._padding=!o.isPaddingEqual(S),this._easeId=t.easeId,this._prepareEase(s,t.noMoveStart,tt),this.terrain&&this._prepareElevation(V),this._ease((ot=>{if(this._zooming&&(o.zoom=p.y.number(c,$,ot)),this._rotating&&(o.bearing=p.y.number(m,b,ot)),this._pitching&&(o.pitch=p.y.number(g,T,ot)),this._padding&&(o.interpolatePadding(y,S,ot),A=o.centerPoint.add(z)),this.terrain&&!t.freezeElevation&&this._updateElevation(ot),H)o.setLocationAtPoint(H,K);else{const ut=o.zoomScale(o.zoom-c),xt=$>c?Math.min(2,F):Math.max(.5,F),Tt=Math.pow(xt,1-ot),ft=o.unproject(N.add(q.mult(ot*Tt)).mult(ut));o.setLocationAtPoint(o.renderWorldCopies?ft.wrap():ft,A)}this._applyUpdatedTransform(o),this._fireMoveEvents(s)}),(ot=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(s,ot)}),t),this}_prepareEase(t,s,n={}){this._moving=!0,s||n.moving||this.fire(new p.k("movestart",t)),this._zooming&&!n.zooming&&this.fire(new p.k("zoomstart",t)),this._rotating&&!n.rotating&&this.fire(new p.k("rotatestart",t)),this._pitching&&!n.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 s=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&s!==this._elevationTarget){const n=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(n-(s-(n*t+this._elevationStart))/(1-t)),this._elevationTarget=s}this.transform.elevation=p.y.number(this._elevationStart,this._elevationTarget,t)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(t){const s=t.getCameraPosition(),n=this.terrain.getElevationForLngLatZoom(s.lngLat,t.zoom);if(s.altitude<n){const o=this.calculateCameraOptionsFromTo(s.lngLat,n,t.center,t.elevation);return{pitch:o.pitch,zoom:o.zoom}}return{}}_applyUpdatedTransform(t){const s=[];if(this.terrain&&s.push((o=>this._elevateCameraIfInsideTerrain(o))),this.transformCameraUpdate&&s.push((o=>this.transformCameraUpdate(o))),!s.length)return;const n=t.clone();for(const o of s){const c=n.clone(),{center:m,zoom:g,pitch:y,bearing:b,elevation:T}=o(c);m&&(c.center=m),g!==void 0&&(c.zoom=g),y!==void 0&&(c.pitch=y),b!==void 0&&(c.bearing=b),T!==void 0&&(c.elevation=T),n.apply(c)}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,s){if(this._easeId&&s&&this._easeId===s)return;delete this._easeId;const n=this._zooming,o=this._rotating,c=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,n&&this.fire(new p.k("zoomend",t)),o&&this.fire(new p.k("rotateend",t)),c&&this.fire(new p.k("pitchend",t)),this.fire(new p.k("moveend",t))}flyTo(t,s){var n;if(!t.essential&&mt.prefersReducedMotion){const bt=p.M(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(bt,s)}this.stop(),t=p.e({offset:[0,0],speed:1.2,curve:1.42,easing:p.b9},t);const o=this._getTransformForUpdate(),c=o.zoom,m=o.bearing,g=o.pitch,y=o.padding,b="bearing"in t?this._normalizeBearing(t.bearing,m):m,T="pitch"in t?+t.pitch:g,S="padding"in t?t.padding:o.padding,z=p.P.convert(t.offset);let A=o.centerPoint.add(z);const B=o.pointLocation(A),{center:V,zoom:$}=o.getConstrained(p.N.convert(t.center||B),(n=t.zoom)!==null&&n!==void 0?n:c);this._normalizeCenter(V,o);const N=o.zoomScale($-c),q=o.project(B),F=o.project(V).sub(q);let H=t.curve;const K=Math.max(o.width,o.height),tt=K/N,ot=F.mag();if("minZoom"in t){const bt=p.ac(Math.min(t.minZoom,c,$),o.minZoom,o.maxZoom),Lt=K/o.zoomScale(bt-c);H=Math.sqrt(Lt/ot*2)}const ut=H*H;function xt(bt){const Lt=(tt*tt-K*K+(bt?-1:1)*ut*ut*ot*ot)/(2*(bt?tt:K)*ut*ot);return Math.log(Math.sqrt(Lt*Lt+1)-Lt)}function Tt(bt){return(Math.exp(bt)-Math.exp(-bt))/2}function ft(bt){return(Math.exp(bt)+Math.exp(-bt))/2}const pt=xt(!1);let Et=function(bt){return ft(pt)/ft(pt+H*bt)},Vt=function(bt){return K*((ft(pt)*(Tt(Lt=pt+H*bt)/ft(Lt))-Tt(pt))/ut)/ot;var Lt},gt=(xt(!0)-pt)/H;if(Math.abs(ot)<1e-6||!isFinite(gt)){if(Math.abs(K-tt)<1e-6)return this.easeTo(t,s);const bt=tt<K?-1:1;gt=Math.abs(Math.log(tt/K))/H,Vt=()=>0,Et=Lt=>Math.exp(bt*H*Lt)}return t.duration="duration"in t?+t.duration:1e3*gt/("screenSpeed"in t?+t.screenSpeed/H:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=m!==b,this._pitching=T!==g,this._padding=!o.isPaddingEqual(S),this._prepareEase(s,!1),this.terrain&&this._prepareElevation(V),this._ease((bt=>{const Lt=bt*gt,pe=1/Et(Lt);o.zoom=bt===1?$:c+o.scaleZoom(pe),this._rotating&&(o.bearing=p.y.number(m,b,bt)),this._pitching&&(o.pitch=p.y.number(g,T,bt)),this._padding&&(o.interpolatePadding(y,S,bt),A=o.centerPoint.add(z)),this.terrain&&!t.freezeElevation&&this._updateElevation(bt);const $t=bt===1?V:o.unproject(q.add(F.mult(Vt(Lt))).mult(pe));o.setLocationAtPoint(o.renderWorldCopies?$t.wrap():$t,A),this._applyUpdatedTransform(o),this._fireMoveEvents(s)}),(()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(s)}),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,s){var n;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const o=this._onEaseEnd;delete this._onEaseEnd,o.call(this,s)}return t||(n=this.handlers)===null||n===void 0||n.stop(!1),this}_ease(t,s,n){n.animate===!1||n.duration===0?(t(1),s()):(this._easeStart=mt.now(),this._easeOptions=n,this._onEaseFrame=t,this._onEaseEnd=s,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,s){t=p.b3(t,-180,180);const n=Math.abs(t-s);return Math.abs(t-360-s)<n&&(t-=360),Math.abs(t+360-s)<n&&(t+=360),t}_normalizeCenter(t,s){if(!s.renderWorldCopies||s.lngRange)return;const n=t.lng-s.center.lng;t.lng+=n>180?-360:n<-180?360:0}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(p.N.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}const Cs={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Ps{constructor(t=Cs){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=s=>{!s||s.sourceDataType!=="metadata"&&s.sourceDataType!=="visibility"&&s.dataType!=="style"&&s.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=at.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=at.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=at.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(){at.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,s){const n=this._map._getUIString(`AttributionControl.${s}`);t.title=n,t.setAttribute("aria-label",n)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((o=>typeof o!="string"?"":o))):typeof this.options.customAttribution=="string"&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const o=this._map.style.stylesheet;this.styleOwner=o.owner,this.styleId=o.id}const s=this._map.style.sourceCaches;for(const o in s){const c=s[o];if(c.used||c.usedForTerrain){const m=c.getSource();m.attribution&&t.indexOf(m.attribution)<0&&t.push(m.attribution)}}t=t.filter((o=>String(o).trim())),t.sort(((o,c)=>o.length-c.length)),t=t.filter(((o,c)=>{for(let m=c+1;m<t.length;m++)if(t[m].indexOf(o)>=0)return!1;return!0}));const n=t.join(" | ");n!==this._attribHTML&&(this._attribHTML=n,t.length?(this._innerContainer.innerHTML=n,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class lo{constructor(t={}){this._updateCompact=()=>{const s=this._container.children;if(s.length){const n=s[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&n.classList.add("maplibregl-compact"):n.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=at.create("div","maplibregl-ctrl");const s=at.create("a","maplibregl-ctrl-logo");return s.target="_blank",s.rel="noopener nofollow",s.href="https://maplibre.org/",s.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),s.setAttribute("rel","noopener nofollow"),this._container.appendChild(s),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){at.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Ht{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const s=++this._id;return this._queue.push({callback:t,id:s,cancelled:!1}),s}remove(t){const s=this._currentlyRunning,n=s?this._queue.concat(s):this._queue;for(const o of n)if(o.id===t)return void(o.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const s=this._currentlyRunning=this._queue;this._queue=[];for(const n of s)if(!n.cancelled&&(n.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var co=p.Y([{name:"a_pos3d",type:"Int16",components:3}]);class ac 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,s){this.sourceCache.update(t,s),this._renderableTilesKeys=[];const n={};for(const o of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:s}))n[o.key]=!0,this._renderableTilesKeys.push(o.key),this._tiles[o.key]||(o.posMatrix=new Float64Array(16),p.aP(o.posMatrix,0,p.X,0,p.X,0,1),this._tiles[o.key]=new Mr(o,this.tileSize));for(const o in this._tiles)n[o]||delete this._tiles[o]}freeRtt(t){for(const s in this._tiles){const n=this._tiles[s];(!t||n.tileID.equals(t)||n.tileID.isChildOf(t)||t.isChildOf(n.tileID))&&(n.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){const s={};for(const n of this._renderableTilesKeys){const o=this._tiles[n].tileID;if(o.canonical.equals(t.canonical)){const c=t.clone();c.posMatrix=new Float64Array(16),p.aP(c.posMatrix,0,p.X,0,p.X,0,1),s[n]=c}else if(o.canonical.isChildOf(t.canonical)){const c=t.clone();c.posMatrix=new Float64Array(16);const m=o.canonical.z-t.canonical.z,g=o.canonical.x-(o.canonical.x>>m<<m),y=o.canonical.y-(o.canonical.y>>m<<m),b=p.X>>m;p.aP(c.posMatrix,0,b,0,b,0,1),p.J(c.posMatrix,c.posMatrix,[-g*b,-y*b,0]),s[n]=c}else if(t.canonical.isChildOf(o.canonical)){const c=t.clone();c.posMatrix=new Float64Array(16);const m=t.canonical.z-o.canonical.z,g=t.canonical.x-(t.canonical.x>>m<<m),y=t.canonical.y-(t.canonical.y>>m<<m),b=p.X>>m;p.aP(c.posMatrix,0,p.X,0,p.X,0,1),p.J(c.posMatrix,c.posMatrix,[g*b,y*b,0]),p.K(c.posMatrix,c.posMatrix,[1/2**m,1/2**m,0]),s[n]=c}}return s}getSourceTile(t,s){const n=this.sourceCache._source;let o=t.overscaledZ-this.deltaZoom;if(o>n.maxzoom&&(o=n.maxzoom),o<n.minzoom)return null;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(o).key);let c=this.sourceCache.getTileByID(this._sourceTileCache[t.key]);if((!c||!c.dem)&&s)for(;o>=n.minzoom&&(!c||!c.dem);)c=this.sourceCache.getTileByID(t.scaledTo(o--).key);return c}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter((s=>s.timeAdded>=t))}}class uo{constructor(t,s,n){this.painter=t,this.sourceCache=new ac(s),this.options=n,this.exaggeration=typeof n.exaggeration=="number"?n.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,s,n,o=p.X){var c;if(!(s>=0&&s<o&&n>=0&&n<o))return 0;const m=this.getTerrainData(t),g=(c=m.tile)===null||c===void 0?void 0:c.dem;if(!g)return 0;const y=(function(B,V,$){var N=V[0],q=V[1];return B[0]=$[0]*N+$[4]*q+$[12],B[1]=$[1]*N+$[5]*q+$[13],B})([],[s/o*p.X,n/o*p.X],m.u_terrain_matrix),b=[y[0]*g.dim,y[1]*g.dim],T=Math.floor(b[0]),S=Math.floor(b[1]),z=b[0]-T,A=b[1]-S;return g.get(T,S)*(1-z)*(1-A)+g.get(T+1,S)*z*(1-A)+g.get(T,S+1)*(1-z)*A+g.get(T+1,S+1)*z*A}getElevationForLngLatZoom(t,s){if(!p.bb(s,t.wrap()))return 0;const{tileID:n,mercatorX:o,mercatorY:c}=this._getOverscaledTileIDFromLngLatZoom(t,s);return this.getElevation(n,o%p.X,c%p.X,p.X)}getElevation(t,s,n,o=p.X){return this.getDEMElevation(t,s,n,o)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){const o=this.painter.context,c=new p.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new ae(o,c,o.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new ae(o,new p.R({width:1,height:1}),o.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(o.gl.NEAREST,o.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=p.an([])}const s=this.sourceCache.getSourceTile(t,!0);if(s&&s.dem&&(!s.demTexture||s.needsTerrainPrepare)){const o=this.painter.context;s.demTexture=this.painter.getTileTexture(s.dem.stride),s.demTexture?s.demTexture.update(s.dem.getPixels(),{premultiply:!1}):s.demTexture=new ae(o,s.dem.getPixels(),o.gl.RGBA,{premultiply:!1}),s.demTexture.bind(o.gl.NEAREST,o.gl.CLAMP_TO_EDGE),s.needsTerrainPrepare=!1}const n=s&&s+s.tileID.key+t.key;if(n&&!this._demMatrixCache[n]){const o=this.sourceCache.sourceCache._source.maxzoom;let c=t.canonical.z-s.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=o?c=t.canonical.z-o:p.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const m=t.canonical.x-(t.canonical.x>>c<<c),g=t.canonical.y-(t.canonical.y>>c<<c),y=p.bc(new Float64Array(16),[1/(p.X<<c),1/(p.X<<c),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:s&&s.dem&&s.dem.dim||1,u_terrain_matrix:n?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:s&&s.dem&&s.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(s&&s.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:s}}getFramebuffer(t){const s=this.painter,n=s.width/devicePixelRatio,o=s.height/devicePixelRatio;return!this._fbo||this._fbo.width===n&&this._fbo.height===o||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new ae(s.context,{width:n,height:o,data:null},s.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(s.context.gl.NEAREST,s.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new ae(s.context,{width:n,height:o,data:null},s.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(s.context.gl.NEAREST,s.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=s.context.createFramebuffer(n,o,!0,!1),this._fbo.depthAttachment.set(s.context.createRenderbuffer(s.context.gl.DEPTH_COMPONENT16,n,o))),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 s=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let c=0,m=0;c<this._coordsTextureSize;c++)for(let g=0;g<this._coordsTextureSize;g++,m+=4)s[m+0]=255&g,s[m+1]=255&c,s[m+2]=g>>8<<4|c>>8,s[m+3]=0;const n=new p.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(s.buffer)),o=new ae(t,n,t.gl.RGBA,{premultiply:!1});return o.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=o,o}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);const s=new Uint8Array(4),n=this.painter.context,o=n.gl,c=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),m=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),g=Math.round(this.painter.height/devicePixelRatio);n.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),o.readPixels(c,g-m-1,1,1,o.RGBA,o.UNSIGNED_BYTE,s),n.bindFramebuffer.set(null);const y=s[0]+(s[2]>>4<<8),b=s[1]+((15&s[2])<<8),T=this.coordsIndex[255-s[3]],S=T&&this.sourceCache.getTileByID(T);if(!S)return null;const z=this._coordsTextureSize,A=(1<<S.tileID.canonical.z)*z;return new p.Z((S.tileID.canonical.x*z+y)/A+S.tileID.wrap,(S.tileID.canonical.y*z+b)/A,this.getElevation(S.tileID,y,b,z))}depthAtPoint(t){const s=new Uint8Array(4),n=this.painter.context,o=n.gl;return n.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),o.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,o.RGBA,o.UNSIGNED_BYTE,s),n.bindFramebuffer.set(null),(s[0]/16777216+s[1]/65536+s[2]/256+s[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;const t=this.painter.context,s=new p.bd,n=new p.aY,o=this.meshSize,c=p.X/o,m=o*o;for(let S=0;S<=o;S++)for(let z=0;z<=o;z++)s.emplaceBack(z*c,S*c,0);for(let S=0;S<m;S+=o+1)for(let z=0;z<o;z++)n.emplaceBack(z+S,o+z+S+1,o+z+S+2),n.emplaceBack(z+S,o+z+S+2,z+S+1);const g=s.length,y=g+2*(o+1);for(const S of[0,1])for(let z=0;z<=o;z++)for(const A of[0,1])s.emplaceBack(z*c,S*p.X,A);for(let S=0;S<2*o;S+=2)n.emplaceBack(y+S,y+S+1,y+S+3),n.emplaceBack(y+S,y+S+3,y+S+2),n.emplaceBack(g+S,g+S+3,g+S+1),n.emplaceBack(g+S,g+S+2,g+S+3);const b=s.length,T=b+2*(o+1);for(const S of[0,1])for(let z=0;z<=o;z++)for(const A of[0,1])s.emplaceBack(S*p.X,z*c,A);for(let S=0;S<2*o;S+=2)n.emplaceBack(b+S,b+S+1,b+S+3),n.emplaceBack(b+S,b+S+3,b+S+2),n.emplaceBack(T+S,T+S+3,T+S+1),n.emplaceBack(T+S,T+S+2,T+S+3);return this._mesh=new Za(t.createVertexBuffer(s,co.members),t.createIndexBuffer(n),p.a0.simpleSegment(0,0,s.length,n.length)),this._mesh}getMeshFrameDelta(t){return 2*Math.PI*p.be/Math.pow(2,t)/5}getMinTileElevationForLngLatZoom(t,s){var n;const{tileID:o}=this._getOverscaledTileIDFromLngLatZoom(t,s);return(n=this.getMinMaxElevation(o).minElevation)!==null&&n!==void 0?n:0}getMinMaxElevation(t){const s=this.getTerrainData(t).tile,n={minElevation:null,maxElevation:null};return s&&s.dem&&(n.minElevation=s.dem.min*this.exaggeration,n.maxElevation=s.dem.max*this.exaggeration),n}_getOverscaledTileIDFromLngLatZoom(t,s){const n=p.Z.fromLngLat(t.wrap()),o=(1<<s)*p.X,c=n.x*o,m=n.y*o,g=Math.floor(c/p.X),y=Math.floor(m/p.X);return{tileID:new p.S(s,0,s,g,y),mercatorX:c,mercatorY:m}}}class nc{constructor(t,s,n){this._context=t,this._size=s,this._tileSize=n,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const s=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),n=new ae(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return n.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),s.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),s.colorAttachment.set(n.texture),{id:t,fbo:s,texture:n,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((s=>t.id!==s)),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const s of this._recentlyUsed)if(!this._objects[s].inUse)return this._objects[s];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 As={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class ul{constructor(t,s){this.painter=t,this.terrain=s,this.pool=new nc(t.context,30,s.sourceCache.tileSize*s.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,s){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter((n=>!t._layers[n].isHidden(s))),this._coordsDescendingInv={};for(const n in t.sourceCaches){this._coordsDescendingInv[n]={};const o=t.sourceCaches[n].getVisibleCoordinates();for(const c of o){const m=this.terrain.sourceCache.getTerrainCoords(c);for(const g in m)this._coordsDescendingInv[n][g]||(this._coordsDescendingInv[n][g]=[]),this._coordsDescendingInv[n][g].push(m[g])}}this._coordsDescendingInvStr={};for(const n of t._order){const o=t._layers[n],c=o.source;if(As[o.type]&&!this._coordsDescendingInvStr[c]){this._coordsDescendingInvStr[c]={};for(const m in this._coordsDescendingInv[c])this._coordsDescendingInvStr[c][m]=this._coordsDescendingInv[c][m].map((g=>g.key)).sort().join()}}for(const n of this._renderableTiles)for(const o in this._coordsDescendingInvStr){const c=this._coordsDescendingInvStr[o][n.tileID.key];c&&c!==n.rttCoords[o]&&(n.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;const s=t.type,n=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(As[s]&&(this._prevType&&As[this._prevType]||this._stacks.push([]),this._prevType=s,this._stacks[this._stacks.length-1].push(t.id),!o))return!0;if(As[this._prevType]||As[s]&&o){this._prevType=s;const c=this._stacks.length-1,m=this._stacks[c]||[];for(const g of this._renderableTiles){if(this.pool.isFull()&&(il(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(g),g.rtt[c]){const b=this.pool.getObjectForId(g.rtt[c].id);if(b.stamp===g.rtt[c].stamp){this.pool.useObject(b);continue}}const y=this.pool.getOrCreateFreeObject();this.pool.useObject(y),this.pool.stampObject(y),g.rtt[c]={id:y.id,stamp:y.stamp},n.context.bindFramebuffer.set(y.fbo.framebuffer),n.context.clear({color:p.aM.transparent,stencil:0}),n.currentStencilSource=void 0;for(let b=0;b<m.length;b++){const T=n.style._layers[m[b]],S=T.source?this._coordsDescendingInv[T.source][g.tileID.key]:[g.tileID];n.context.viewport.set([0,0,y.fbo.width,y.fbo.height]),n._renderTileClippingMasks(T,S),n.renderLayer(n,n.style.sourceCaches[T.source],T,S),T.source&&(g.rttCoords[T.source]=this._coordsDescendingInvStr[T.source][g.tileID.key])}}return il(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),As[s]}return!1}}const ho={"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"},hl=Pi,oc={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Cs,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},po=u=>{u.touchstart=u.dragStart,u.touchmoveWindow=u.dragMove,u.touchend=u.dragEnd},lc={showCompass:!0,showZoom:!0,visualizePitch:!1};class cc{constructor(t,s,n=!1){this.mousedown=m=>{this.startMouse(p.e({},m,{ctrlKey:!0,preventDefault:()=>m.preventDefault()}),at.mousePos(this.element,m)),at.addEventListener(window,"mousemove",this.mousemove),at.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=m=>{this.moveMouse(m,at.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=at.touchPos(this.element,m.targetTouches)[0],this.startTouch(m,this._startPos),at.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),at.addEventListener(window,"touchend",this.touchend))},this.touchmove=m=>{m.targetTouches.length!==1?this.reset():(this._lastPos=at.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 o=t.dragRotate._mouseRotate.getClickTolerance(),c=t.dragRotate._mousePitch.getClickTolerance();this.element=s,this.mouseRotate=Qn({clickTolerance:o,enable:!0}),this.touchRotate=(({enable:m,clickTolerance:g,bearingDegreesPerPixelMoved:y=.8})=>{const b=new Yn;return new gr({clickTolerance:g,move:(T,S)=>({bearingDelta:(S.x-T.x)*y}),moveStateManager:b,enable:m,assignEvents:po})})({clickTolerance:o,enable:!0}),this.map=t,n&&(this.mousePitch=to({clickTolerance:c,enable:!0}),this.touchPitch=(({enable:m,clickTolerance:g,pitchDegreesPerPixelMoved:y=-.5})=>{const b=new Yn;return new gr({clickTolerance:g,move:(T,S)=>({pitchDelta:(S.y-T.y)*y}),moveStateManager:b,enable:m,assignEvents:po})})({clickTolerance:c,enable:!0})),at.addEventListener(s,"mousedown",this.mousedown),at.addEventListener(s,"touchstart",this.touchstart,{passive:!1}),at.addEventListener(s,"touchcancel",this.reset)}startMouse(t,s){this.mouseRotate.dragStart(t,s),this.mousePitch&&this.mousePitch.dragStart(t,s),at.disableDrag()}startTouch(t,s){this.touchRotate.dragStart(t,s),this.touchPitch&&this.touchPitch.dragStart(t,s),at.disableDrag()}moveMouse(t,s){const n=this.map,{bearingDelta:o}=this.mouseRotate.dragMove(t,s)||{};if(o&&n.setBearing(n.getBearing()+o),this.mousePitch){const{pitchDelta:c}=this.mousePitch.dragMove(t,s)||{};c&&n.setPitch(n.getPitch()+c)}}moveTouch(t,s){const n=this.map,{bearingDelta:o}=this.touchRotate.dragMove(t,s)||{};if(o&&n.setBearing(n.getBearing()+o),this.touchPitch){const{pitchDelta:c}=this.touchPitch.dragMove(t,s)||{};c&&n.setPitch(n.getPitch()+c)}}off(){const t=this.element;at.removeEventListener(t,"mousedown",this.mousedown),at.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),at.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),at.removeEventListener(window,"touchend",this.touchend),at.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){at.enableDrag(),at.removeEventListener(window,"mousemove",this.mousemove),at.removeEventListener(window,"mouseup",this.mouseup),at.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),at.removeEventListener(window,"touchend",this.touchend)}}let _i;function de(u,t,s){const n=new p.N(u.lng,u.lat);if(u=new p.N(u.lng,u.lat),t){const o=new p.N(u.lng-360,u.lat),c=new p.N(u.lng+360,u.lat),m=s.locationPoint(u).distSqr(t);s.locationPoint(o).distSqr(t)<m?u=o:s.locationPoint(c).distSqr(t)<m&&(u=c)}for(;Math.abs(u.lng-s.center.lng)>180;){const o=s.locationPoint(u);if(o.x>=0&&o.y>=0&&o.x<=s.width&&o.y<=s.height)break;u.lng>s.center.lng?u.lng-=360:u.lng+=360}return u.lng!==n.lng&&s.locationPoint(u).y>s.height/2-s.getHorizon()?u:n}const Ds={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 en(u,t,s){const n=u.classList;for(const o in Ds)n.remove(`maplibregl-${s}-anchor-${o}`);n.add(`maplibregl-${s}-anchor-${t}`)}class rn extends p.E{constructor(t){if(super(),this._onKeyPress=s=>{const n=s.code,o=s.charCode||s.keyCode;n!=="Space"&&n!=="Enter"&&o!==32&&o!==13||this.togglePopup()},this._onMapClick=s=>{const n=s.originalEvent.target,o=this._element;this._popup&&(n===o||o.contains(n))&&this.togglePopup()},this._update=s=>{var n;if(!this._map)return;const o=this._map.loaded()&&!this._map.isMoving();((s==null?void 0:s.type)==="terrain"||(s==null?void 0:s.type)==="render"&&!o)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?de(this._lngLat,this._flatPos,this._map.transform):(n=this._lngLat)===null||n===void 0?void 0:n.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let c="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?c=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(c=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let m="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?m="rotateX(0deg)":this._pitchAlignment==="map"&&(m=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||s&&s.type!=="moveend"||(this._pos=this._pos.round()),at.setTransform(this._element,`${Ds[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${m} ${c}`),mt.frameAsync(new AbortController).then((()=>{this._updateOpacity(s&&s.type==="moveend")})).catch((()=>{}))},this._onMove=s=>{if(!this._isDragging){const n=this._clickTolerance||this._map._clickTolerance;this._isDragging=s.point.dist(this._pointerdownPos)>=n}this._isDragging&&(this._pos=s.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=s=>{this._element.contains(s.originalEvent.target)&&(s.preventDefault(),this._positionDelta=s.point.sub(this._pos).add(this._offset),this._pointerdownPos=s.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._subpixelPositioning=t&&t.subpixelPositioning||!1,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=at.create("div");const s=at.createNS("http://www.w3.org/2000/svg","svg"),n=41,o=27;s.setAttributeNS(null,"display","block"),s.setAttributeNS(null,"height",`${n}px`),s.setAttributeNS(null,"width",`${o}px`),s.setAttributeNS(null,"viewBox",`0 0 ${o} ${n}`);const c=at.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"stroke","none"),c.setAttributeNS(null,"stroke-width","1"),c.setAttributeNS(null,"fill","none"),c.setAttributeNS(null,"fill-rule","evenodd");const m=at.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"fill-rule","nonzero");const g=at.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 N of y){const q=at.createNS("http://www.w3.org/2000/svg","ellipse");q.setAttributeNS(null,"opacity","0.04"),q.setAttributeNS(null,"cx","10.5"),q.setAttributeNS(null,"cy","5.80029008"),q.setAttributeNS(null,"rx",N.rx),q.setAttributeNS(null,"ry",N.ry),g.appendChild(q)}const b=at.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill",this._color);const T=at.createNS("http://www.w3.org/2000/svg","path");T.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),b.appendChild(T);const S=at.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"opacity","0.25"),S.setAttributeNS(null,"fill","#000000");const z=at.createNS("http://www.w3.org/2000/svg","path");z.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),S.appendChild(z);const A=at.createNS("http://www.w3.org/2000/svg","g");A.setAttributeNS(null,"transform","translate(6.0, 7.0)"),A.setAttributeNS(null,"fill","#FFFFFF");const B=at.createNS("http://www.w3.org/2000/svg","g");B.setAttributeNS(null,"transform","translate(8.0, 8.0)");const V=at.createNS("http://www.w3.org/2000/svg","circle");V.setAttributeNS(null,"fill","#000000"),V.setAttributeNS(null,"opacity","0.25"),V.setAttributeNS(null,"cx","5.5"),V.setAttributeNS(null,"cy","5.5"),V.setAttributeNS(null,"r","5.4999962");const $=at.createNS("http://www.w3.org/2000/svg","circle");$.setAttributeNS(null,"fill","#FFFFFF"),$.setAttributeNS(null,"cx","5.5"),$.setAttributeNS(null,"cy","5.5"),$.setAttributeNS(null,"r","5.4999962"),B.appendChild(V),B.appendChild($),m.appendChild(g),m.appendChild(b),m.appendChild(S),m.appendChild(A),m.appendChild(B),s.appendChild(m),s.setAttributeNS(null,"height",n*this._scale+"px"),s.setAttributeNS(null,"width",o*this._scale+"px"),this._element.appendChild(s),this._offset=p.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(s=>{s.preventDefault()})),this._element.addEventListener("mousedown",(s=>{s.preventDefault()})),en(this._element,this._anchor,"marker"),t&&t.className)for(const s of t.className.split(" "))this._element.classList.add(s);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),at.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 s=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":[s,-1*(38.1-13.5+s)],"bottom-right":[-s,-1*(38.1-13.5+s)],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}setSubpixelPositioning(t){return this._subpixelPositioning=t,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 s,n;if(!(!((s=this._map)===null||s===void 0)&&s.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 o=this._map,c=o.terrain.depthAtPoint(this._pos),m=o.terrain.getElevationForLngLatZoom(this._lngLat,o.transform.tileZoom);if(o.transform.lngLatToCameraDepth(this._lngLat,m)-c<.006)return void(this._element.style.opacity=this._opacity);const g=-this._offset.y/o.transform._pixelPerMeter,y=Math.sin(o.getPitch()*Math.PI/180)*g,b=o.terrain.depthAtPoint(new p.P(this._pos.x,this._pos.y-this._offset.y)),T=o.transform.lngLatToCameraDepth(this._lngLat,m+y)-b>.006;!((n=this._popup)===null||n===void 0)&&n.isOpen()&&T&&this._popup.remove(),this._element.style.opacity=T?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,s){return t===void 0&&s===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),t!==void 0&&(this._opacity=t),s!==void 0&&(this._opacityWhenCovered=s),this._map&&this._updateOpacity(!0),this}}const dl={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let fa=0,ma=!1;const nr={maxWidth:100,unit:"metric"};function _a(u,t,s){const n=s&&s.maxWidth||100,o=u._container.clientHeight/2,c=u.unproject([0,o]),m=u.unproject([n,o]),g=c.distanceTo(m);if(s&&s.unit==="imperial"){const y=3.2808*g;y>5280?Mt(t,n,y/5280,u._getUIString("ScaleControl.Miles")):Mt(t,n,y,u._getUIString("ScaleControl.Feet"))}else s&&s.unit==="nautical"?Mt(t,n,g/1852,u._getUIString("ScaleControl.NauticalMiles")):g>=1e3?Mt(t,n,g/1e3,u._getUIString("ScaleControl.Kilometers")):Mt(t,n,g,u._getUIString("ScaleControl.Meters"))}function Mt(u,t,s,n){const o=(function(c){const m=Math.pow(10,`${Math.floor(c)}`.length-1);let g=c/m;return g=g>=10?10:g>=5?5:g>=3?3:g>=2?2:g>=1?1:(function(y){const b=Math.pow(10,Math.ceil(-Math.log(y)/Math.LN10));return Math.round(y*b)/b})(g),m*g})(s);u.style.width=t*(o/s)+"px",u.innerHTML=`${o}&nbsp;${n}`}const Bt={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},sn=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function an(u){if(u){if(typeof u=="number"){const t=Math.round(Math.abs(u)/Math.SQRT2);return{center:new p.P(0,0),top:new p.P(0,u),"top-left":new p.P(t,t),"top-right":new p.P(-t,t),bottom:new p.P(0,-u),"bottom-left":new p.P(t,-t),"bottom-right":new p.P(-t,-t),left:new p.P(u,0),right:new p.P(-u,0)}}if(u instanceof p.P||Array.isArray(u)){const t=p.P.convert(u);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(u.center||[0,0]),top:p.P.convert(u.top||[0,0]),"top-left":p.P.convert(u["top-left"]||[0,0]),"top-right":p.P.convert(u["top-right"]||[0,0]),bottom:p.P.convert(u.bottom||[0,0]),"bottom-left":p.P.convert(u["bottom-left"]||[0,0]),"bottom-right":p.P.convert(u["bottom-right"]||[0,0]),left:p.P.convert(u.left||[0,0]),right:p.P.convert(u.right||[0,0])}}return an(new p.P(0,0))}const fo=Pi;R.AJAXError=p.bh,R.Evented=p.E,R.LngLat=p.N,R.MercatorCoordinate=p.Z,R.Point=p.P,R.addProtocol=p.bi,R.config=p.a,R.removeProtocol=p.bj,R.AttributionControl=Ps,R.BoxZoomHandler=mi,R.CanvasSource=bi,R.CooperativeGesturesHandler=zs,R.DoubleClickZoomHandler=es,R.DragPanHandler=ol,R.DragRotateHandler=ll,R.EdgeInsets=Is,R.FullscreenControl=class extends p.E{constructor(u={}){super(),this._onFullscreenChange=()=>{var t;let s=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((t=s==null?void 0:s.shadowRoot)===null||t===void 0)&&t.fullscreenElement;)s=s.shadowRoot.fullscreenElement;s===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,u&&u.container&&(u.container instanceof HTMLElement?this._container=u.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(u){return this._map=u,this._container||(this._container=this._map.getContainer()),this._controlContainer=at.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){at.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const u=this._fullscreenButton=at.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);at.create("span","maplibregl-ctrl-icon",u).setAttribute("aria-hidden","true"),u.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const u=this._getTitle();this._fullscreenButton.setAttribute("aria-label",u),this._fullscreenButton.title=u}_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()}},R.GeoJSONSource=Ks,R.GeolocateControl=class extends p.E{constructor(u){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 s=new p.N(t.coords.longitude,t.coords.latitude),n=t.coords.accuracy,o=this._map.getBearing(),c=p.e({bearing:o},this.options.fitBoundsOptions),m=it.fromLngLat(s,n);this._map.fitBounds(m,c,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const s=new p.N(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(s).addTo(this._map),this._userLocationDotMarker.setLngLat(s).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 s=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=s,this._geolocateButton.setAttribute("aria-label",s),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(t.code===3&&ma)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=()=>{this._map&&(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=at.create("button","maplibregl-ctrl-geolocate",this._container),at.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(t===!1){p.w("Geolocation support is not available so the GeolocateControl will be disabled.");const s=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=s,this._geolocateButton.setAttribute("aria-label",s)}else{const s=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=s,this._geolocateButton.setAttribute("aria-label",s)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=at.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new rn({element:this._dotElement}),this._circleElement=at.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new rn({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",(s=>{s.geolocateSource||this._watchState!=="ACTIVE_LOCK"||s.originalEvent&&s.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({},dl,u)}onAdd(u){return this._map=u,this._container=at.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),(function(){return p._(this,arguments,void 0,(function*(t=!1){if(_i!==void 0&&!t)return _i;if(window.navigator.permissions===void 0)return _i=!!window.navigator.geolocation,_i;try{_i=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{_i=!!window.navigator.geolocation}return _i}))})().then((t=>this._finishSetupUI(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(),at.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,fa=0,ma=!1}_isOutOfMapMaxBounds(u){const t=this._map.getMaxBounds(),s=u.coords;return t&&(s.longitude<t.getWest()||s.longitude>t.getEast()||s.latitude<t.getSouth()||s.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 u=this._map.getBounds(),t=u.getSouthEast(),s=u.getNorthEast(),n=t.distanceTo(s),o=Math.ceil(this._accuracy/(n/this._map._container.clientHeight)*2);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`}trigger(){if(!this._setup)return p.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new p.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":fa--,ma=!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 u;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),fa++,fa>1?(u={maximumAge:6e5,timeout:0},ma=!0):(u=this.options.positionOptions,ma=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,u)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},R.Hash=Ga,R.ImageSource=fr,R.KeyboardHandler=Si,R.LngLatBounds=it,R.LogoControl=lo,R.Map=class extends cl{constructor(u){p.bf.mark(p.bg.create);const t=Object.assign(Object.assign({},oc),u);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 ks(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),{bearingSnap:t.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Ht,this._controls=[],this._mapId=p.a4(),this._contextLost=s=>{s.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new p.k("webglcontextlost",{originalEvent:s}))},this._contextRestored=s=>{this._setupPainter(),this.resize(),this._update(),this.fire(new p.k("webglcontextrestored",{originalEvent:s}))},this._onMapScroll=s=>{if(s.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({},ho),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=ui.addThrottleControl((()=>this.isMoving())),this._requestManager=new Sn(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 s=!1;const n=ca((o=>{this._trackResize&&!this._removed&&(this.resize(o),this.redraw())}),50);this._resizeObserver=new ResizeObserver((o=>{s?n(o):s=!0})),this._resizeObserver.observe(this._container)}this.handlers=new oo(this,t),this._hash=t.hash&&new Ga(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 Ps(typeof t.attributionControl=="boolean"?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new lo,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(s=>{this._update(s.dataType==="style"),this.fire(new p.k(`${s.dataType}data`,s))})),this.on("dataloading",(s=>{this.fire(new p.k(`${s.dataType}dataloading`,s))})),this.on("dataabort",(s=>{this.fire(new p.k("sourcedataabort",s))}))}_getMapId(){return this._mapId}addControl(u,t){if(t===void 0&&(t=u.getDefaultPosition?u.getDefaultPosition():"top-right"),!u||!u.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 s=u.onAdd(this);this._controls.push(u);const n=this._controlPositions[t];return t.indexOf("bottom")!==-1?n.insertBefore(s,n.firstChild):n.appendChild(s),this}removeControl(u){if(!u||!u.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(u);return t>-1&&this._controls.splice(t,1),u.onRemove(this),this}hasControl(u){return this._controls.indexOf(u)>-1}calculateCameraOptionsFromTo(u,t,s,n){return n==null&&this.terrain&&(n=this.terrain.getElevationForLngLatZoom(s,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(u,t,s,n)}resize(u){var t;const s=this._containerDimensions(),n=s[0],o=s[1],c=this._getClampedPixelRatio(n,o);if(this._resizeCanvas(n,o,c),this.painter.resize(n,o,c),this.painter.overLimit()){const g=this.painter.context.gl;this._maxCanvasSize=[g.drawingBufferWidth,g.drawingBufferHeight];const y=this._getClampedPixelRatio(n,o);this._resizeCanvas(n,o,y),this.painter.resize(n,o,y)}this.transform.resize(n,o),(t=this._requestedCameraState)===null||t===void 0||t.resize(n,o);const m=!this._moving;return m&&(this.stop(),this.fire(new p.k("movestart",u)).fire(new p.k("move",u))),this.fire(new p.k("resize",u)),m&&this.fire(new p.k("moveend",u)),this}_getClampedPixelRatio(u,t){const{0:s,1:n}=this._maxCanvasSize,o=this.getPixelRatio(),c=u*o,m=t*o;return Math.min(c>s?s/c:1,m>n?n/m:1)*o}getPixelRatio(){var u;return(u=this._overridePixelRatio)!==null&&u!==void 0?u:devicePixelRatio}setPixelRatio(u){this._overridePixelRatio=u,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(u){return this.transform.setMaxBounds(it.convert(u)),this._update()}setMinZoom(u){if((u=u??-2)>=-2&&u<=this.transform.maxZoom)return this.transform.minZoom=u,this._update(),this.getZoom()<u&&this.setZoom(u),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(u){if((u=u??22)>=this.transform.minZoom)return this.transform.maxZoom=u,this._update(),this.getZoom()>u&&this.setZoom(u),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(u){if((u=u??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(u>=0&&u<=this.transform.maxPitch)return this.transform.minPitch=u,this._update(),this.getPitch()<u&&this.setPitch(u),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(u){if((u=u??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(u>=this.transform.minPitch)return this.transform.maxPitch=u,this._update(),this.getPitch()>u&&this.setPitch(u),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(u){return this.transform.renderWorldCopies=u,this._update()}project(u){return this.transform.locationPoint(p.N.convert(u),this.style&&this.terrain)}unproject(u){return this.transform.pointLocation(p.P.convert(u),this.terrain)}isMoving(){var u;return this._moving||((u=this.handlers)===null||u===void 0?void 0:u.isMoving())}isZooming(){var u;return this._zooming||((u=this.handlers)===null||u===void 0?void 0:u.isZooming())}isRotating(){var u;return this._rotating||((u=this.handlers)===null||u===void 0?void 0:u.isRotating())}_createDelegatedListener(u,t,s){if(u==="mouseenter"||u==="mouseover"){let n=!1;return{layers:t,listener:s,delegates:{mousemove:o=>{const c=t.filter((g=>this.getLayer(g))),m=c.length!==0?this.queryRenderedFeatures(o.point,{layers:c}):[];m.length?n||(n=!0,s.call(this,new Oe(u,this,o.originalEvent,{features:m}))):n=!1},mouseout:()=>{n=!1}}}}if(u==="mouseleave"||u==="mouseout"){let n=!1;return{layers:t,listener:s,delegates:{mousemove:o=>{const c=t.filter((m=>this.getLayer(m)));(c.length!==0?this.queryRenderedFeatures(o.point,{layers:c}):[]).length?n=!0:n&&(n=!1,s.call(this,new Oe(u,this,o.originalEvent)))},mouseout:o=>{n&&(n=!1,s.call(this,new Oe(u,this,o.originalEvent)))}}}}{const n=o=>{const c=t.filter((g=>this.getLayer(g))),m=c.length!==0?this.queryRenderedFeatures(o.point,{layers:c}):[];m.length&&(o.features=m,s.call(this,o),delete o.features)};return{layers:t,listener:s,delegates:{[u]:n}}}}_saveDelegatedListener(u,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[u]=this._delegatedListeners[u]||[],this._delegatedListeners[u].push(t)}_removeDelegatedListener(u,t,s){if(!this._delegatedListeners||!this._delegatedListeners[u])return;const n=this._delegatedListeners[u];for(let o=0;o<n.length;o++){const c=n[o];if(c.listener===s&&c.layers.length===t.length&&c.layers.every((m=>t.includes(m)))){for(const m in c.delegates)this.off(m,c.delegates[m]);return void n.splice(o,1)}}}on(u,t,s){if(s===void 0)return super.on(u,t);const n=this._createDelegatedListener(u,typeof t=="string"?[t]:t,s);this._saveDelegatedListener(u,n);for(const o in n.delegates)this.on(o,n.delegates[o]);return this}once(u,t,s){if(s===void 0)return super.once(u,t);const n=typeof t=="string"?[t]:t,o=this._createDelegatedListener(u,n,s);for(const c in o.delegates){const m=o.delegates[c];o.delegates[c]=(...g)=>{this._removeDelegatedListener(u,n,s),m(...g)}}this._saveDelegatedListener(u,o);for(const c in o.delegates)this.once(c,o.delegates[c]);return this}off(u,t,s){return s===void 0?super.off(u,t):(this._removeDelegatedListener(u,typeof t=="string"?[t]:t,s),this)}queryRenderedFeatures(u,t){if(!this.style)return[];let s;const n=u instanceof p.P||Array.isArray(u),o=n?u:[[0,0],[this.transform.width,this.transform.height]];if(t=t||(n?{}:u)||{},o instanceof p.P||typeof o[0]=="number")s=[p.P.convert(o)];else{const c=p.P.convert(o[0]),m=p.P.convert(o[1]);s=[c,new p.P(m.x,c.y),m,new p.P(c.x,m.y),c]}return this.style.queryRenderedFeatures(s,t,this.transform)}querySourceFeatures(u,t){return this.style.querySourceFeatures(u,t)}setStyle(u,t){return(t=p.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},t)).diff!==!1&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&u?(this._diffStyle(u,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(u,t))}setTransformRequest(u){return this._requestManager.setTransformRequest(u),this}_getUIString(u){const t=this._locale[u];if(t==null)throw new Error(`Missing UI string '${u}'`);return t}_updateStyle(u,t){if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(u,t)));const s=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!u)),u?(this.style=new za(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof u=="string"?this.style.loadURL(u,t,s):this.style.loadJSON(u,t,s),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new za(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(u,t){if(typeof u=="string"){const s=this._requestManager.transformRequest(u,"Style");p.h(s,new AbortController).then((n=>{this._updateDiff(n.data,t)})).catch((n=>{n&&this.fire(new p.j(n))}))}else typeof u=="object"&&this._updateDiff(u,t)}_updateDiff(u,t){try{this.style.setState(u,t)&&this._update(!0)}catch(s){p.w(`Unable to perform style diff: ${s.message||s.error||s}. Rebuilding the style from scratch.`),this._updateStyle(u,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(u,t){return this._lazyInitEmptyStyle(),this.style.addSource(u,t),this._update(!0)}isSourceLoaded(u){const t=this.style&&this.style.sourceCaches[u];if(t!==void 0)return t.loaded();this.fire(new p.j(new Error(`There is no source with ID '${u}'`)))}setTerrain(u){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),u){const t=this.style.sourceCaches[u.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${u.source}`);this.terrain===null&&t.reload();for(const s in this.style._layers){const n=this.style._layers[s];n.type==="hillshade"&&n.source===u.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 uo(this.painter,t,u),this.painter.renderToTexture=new ul(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=s=>{s.dataType==="style"?this.terrain.sourceCache.freeRtt():s.dataType==="source"&&s.tile&&(s.sourceId!==u.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(s.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:u})),this}getTerrain(){var u,t;return(t=(u=this.terrain)===null||u===void 0?void 0:u.options)!==null&&t!==void 0?t:null}areTilesLoaded(){const u=this.style&&this.style.sourceCaches;for(const t in u){const s=u[t]._tiles;for(const n in s){const o=s[n];if(o.state!=="loaded"&&o.state!=="errored")return!1}}return!0}removeSource(u){return this.style.removeSource(u),this._update(!0)}getSource(u){return this.style.getSource(u)}addImage(u,t,s={}){const{pixelRatio:n=1,sdf:o=!1,stretchX:c,stretchY:m,content:g,textFitWidth:y,textFitHeight:b}=s;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:T,height:S,data:z}=t,A=t;return this.style.addImage(u,{data:new p.R({width:T,height:S},new Uint8Array(z)),pixelRatio:n,stretchX:c,stretchY:m,content:g,textFitWidth:y,textFitHeight:b,sdf:o,version:0,userImage:A}),A.onAdd&&A.onAdd(this,u),this}}{const{width:T,height:S,data:z}=mt.getImageData(t);this.style.addImage(u,{data:new p.R({width:T,height:S},z),pixelRatio:n,stretchX:c,stretchY:m,content:g,textFitWidth:y,textFitHeight:b,sdf:o,version:0})}}updateImage(u,t){const s=this.style.getImage(u);if(!s)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 n=t instanceof HTMLImageElement||p.b(t)?mt.getImageData(t):t,{width:o,height:c,data:m}=n;if(o===void 0||c===void 0)return this.fire(new p.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==s.data.width||c!==s.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 s.data.replace(m,g),this.style.updateImage(u,s),this}getImage(u){return this.style.getImage(u)}hasImage(u){return u?!!this.style.getImage(u):(this.fire(new p.j(new Error("Missing required image id"))),!1)}removeImage(u){this.style.removeImage(u)}loadImage(u){return ui.getImage(this._requestManager.transformRequest(u,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(u,t){return this._lazyInitEmptyStyle(),this.style.addLayer(u,t),this._update(!0)}moveLayer(u,t){return this.style.moveLayer(u,t),this._update(!0)}removeLayer(u){return this.style.removeLayer(u),this._update(!0)}getLayer(u){return this.style.getLayer(u)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(u,t,s){return this.style.setLayerZoomRange(u,t,s),this._update(!0)}setFilter(u,t,s={}){return this.style.setFilter(u,t,s),this._update(!0)}getFilter(u){return this.style.getFilter(u)}setPaintProperty(u,t,s,n={}){return this.style.setPaintProperty(u,t,s,n),this._update(!0)}getPaintProperty(u,t){return this.style.getPaintProperty(u,t)}setLayoutProperty(u,t,s,n={}){return this.style.setLayoutProperty(u,t,s,n),this._update(!0)}getLayoutProperty(u,t){return this.style.getLayoutProperty(u,t)}setGlyphs(u,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(u,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(u,t,s={}){return this._lazyInitEmptyStyle(),this.style.addSprite(u,t,s,(n=>{n||this._update(!0)})),this}removeSprite(u){return this._lazyInitEmptyStyle(),this.style.removeSprite(u),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(u,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(u,t,(s=>{s||this._update(!0)})),this}setLight(u,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(u,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(u){return this._lazyInitEmptyStyle(),this.style.setSky(u),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(u,t){return this.style.setFeatureState(u,t),this._update()}removeFeatureState(u,t){return this.style.removeFeatureState(u,t),this._update()}getFeatureState(u){return this.style.getFeatureState(u)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let u=0,t=0;return this._container&&(u=this._container.clientWidth||400,t=this._container.clientHeight||300),[u,t]}_setupContainer(){const u=this._container;u.classList.add("maplibregl-map");const t=this._canvasContainer=at.create("div","maplibregl-canvas-container",u);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=at.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 s=this._containerDimensions(),n=this._getClampedPixelRatio(s[0],s[1]);this._resizeCanvas(s[0],s[1],n);const o=this._controlContainer=at.create("div","maplibregl-control-container",u),c=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((m=>{c[m]=at.create("div",`maplibregl-ctrl-${m} `,o)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(u,t,s){this._canvas.width=Math.floor(s*u),this._canvas.height=Math.floor(s*t),this._canvas.style.width=`${u}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const u={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let t=null;this._canvas.addEventListener("webglcontextcreationerror",(n=>{t={requestedAttributes:u},n&&(t.statusMessage=n.statusMessage,t.type=n.type)}),{once:!0});const s=this._canvas.getContext("webgl2",u)||this._canvas.getContext("webgl",u);if(!s){const n="Failed to initialize WebGL";throw t?(t.message=n,new Error(JSON.stringify(t))):new Error(n)}this.painter=new qa(s,this.transform),Vr.testSupport(s)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(u){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||u,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(u){return this._update(),this._renderTaskQueue.add(u)}_cancelRenderFrame(u){this._renderTaskQueue.remove(u)}_render(u){const t=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(u),this._removed)return;let s=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const o=this.transform.zoom,c=mt.now();this.style.zoomHistory.update(o,c);const m=new p.z(o,{now:c,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),g=m.crossFadingFactor();g===1&&g===this._crossFadingFactor||(s=!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.bf.mark(p.bg.load),this.fire(new p.k("load"))),this.style&&(this.style.hasTransitions()||s)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const n=this._sourcesDirty||this._styleDirty||this._placementDirty;return n||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new p.k("idle")),!this._loaded||this._fullyLoaded||n||(this._fullyLoaded=!0,p.bf.mark(p.bg.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var u;this._hash&&this._hash.remove();for(const s of this._controls)s.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),ui.removeThrottleControl(this._imageQueueHandle),(u=this._resizeObserver)===null||u===void 0||u.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),at.remove(this._canvasContainer),at.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),p.bf.clearMetrics(),this._removed=!0,this.fire(new p.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,mt.frameAsync(this._frameRequest).then((u=>{p.bf.frame(u),this._frameRequest=null,this._render(u)})).catch((()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(u){this._showTileBoundaries!==u&&(this._showTileBoundaries=u,this._update())}get showPadding(){return!!this._showPadding}set showPadding(u){this._showPadding!==u&&(this._showPadding=u,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(u){this._showCollisionBoxes!==u&&(this._showCollisionBoxes=u,u?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(u){this._showOverdrawInspector!==u&&(this._showOverdrawInspector=u,this._update())}get repaint(){return!!this._repaint}set repaint(u){this._repaint!==u&&(this._repaint=u,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(u){this._vertices=u,this._update()}get version(){return hl}getCameraTargetElevation(){return this.transform.elevation}},R.MapMouseEvent=Oe,R.MapTouchEvent=Qr,R.MapWheelEvent=sl,R.Marker=rn,R.NavigationControl=class{constructor(u){this._updateZoomButtons=()=>{const t=this._map.getZoom(),s=t===this._map.getMaxZoom(),n=t===this._map.getMinZoom();this._zoomInButton.disabled=s,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute("aria-disabled",s.toString()),this._zoomOutButton.setAttribute("aria-disabled",n.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,s)=>{const n=this._map._getUIString(`NavigationControl.${s}`);t.title=n,t.setAttribute("aria-label",n)},this.options=p.e({},lc,u),this._container=at.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}))),at.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}))),at.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=at.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(u){return this._map=u,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 cc(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){at.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(u,t){const s=at.create("button",u,this._container);return s.type="button",s.addEventListener("click",t),s}},R.Popup=class extends p.E{constructor(u){super(),this.remove=()=>(this._content&&at.remove(this._content),this._container&&(at.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 s;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=at.create("div","maplibregl-popup",this._map.getContainer()),this._tip=at.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?de(this._lngLat,this._flatPos,this._map.transform):(s=this._lngLat)===null||s===void 0?void 0:s.wrap(),this._trackPointer&&!t)return;const n=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 o=this.options.anchor;const c=an(this.options.offset);if(!o){const g=this._container.offsetWidth,y=this._container.offsetHeight;let b;b=n.y+c.bottom.y<y?["top"]:n.y>this._map.transform.height-y?["bottom"]:[],n.x<g/2?b.push("left"):n.x>this._map.transform.width-g/2&&b.push("right"),o=b.length===0?"bottom":b.join("-")}let m=n.add(c[o]);this.options.subpixelPositioning||(m=m.round()),at.setTransform(this._container,`${Ds[o]} translate(${m.x}px,${m.y}px)`),en(this._container,o,"popup")},this._onClose=()=>{this.remove()},this.options=p.e(Object.create(Bt),u)}addTo(u){return this._map&&this.remove(),this._map=u,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(u){return this._lngLat=p.N.convert(u),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(u){return this.setDOMContent(document.createTextNode(u))}setHTML(u){const t=document.createDocumentFragment(),s=document.createElement("body");let n;for(s.innerHTML=u;n=s.firstChild,n;)t.appendChild(n);return this.setDOMContent(t)}getMaxWidth(){var u;return(u=this._container)===null||u===void 0?void 0:u.style.maxWidth}setMaxWidth(u){return this.options.maxWidth=u,this._update(),this}setDOMContent(u){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=at.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(u),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(u){return this._container&&this._container.classList.add(u),this}removeClassName(u){return this._container&&this._container.classList.remove(u),this}setOffset(u){return this.options.offset=u,this._update(),this}toggleClassName(u){if(this._container)return this._container.classList.toggle(u)}setSubpixelPositioning(u){this.options.subpixelPositioning=u}_createCloseButton(){this.options.closeButton&&(this._closeButton=at.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const u=this._container.querySelector(sn);u&&u.focus()}},R.RasterDEMTileSource=ye,R.RasterTileSource=te,R.ScaleControl=class{constructor(u){this._onMove=()=>{_a(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,_a(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},nr),u)}getDefaultPosition(){return"bottom-left"}onAdd(u){return this._map=u,this._container=at.create("div","maplibregl-ctrl maplibregl-ctrl-scale",u.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){at.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},R.ScrollZoomHandler=ji,R.Style=za,R.TerrainControl=class{constructor(u){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=u}onAdd(u){return this._map=u,this._container=at.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=at.create("button","maplibregl-ctrl-terrain",this._container),at.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(){at.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},R.TwoFingersTouchPitchHandler=Es,R.TwoFingersTouchRotateHandler=so,R.TwoFingersTouchZoomHandler=io,R.TwoFingersTouchZoomRotateHandler=no,R.VectorTileSource=Ws,R.VideoSource=hs,R.addSourceType=(u,t)=>p._(void 0,void 0,void 0,(function*(){if(Ys(u))throw new Error(`A source type called "${u}" already exists.`);((s,n)=>{Js[s]=n})(u,t)})),R.clearPrewarmedResources=function(){const u=hi;u&&(u.isPreloaded()&&u.numActive()===1?(u.release(Tr),hi=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},R.getMaxParallelImageRequests=function(){return p.a.MAX_PARALLEL_IMAGE_REQUESTS},R.getRTLTextPluginStatus=function(){return er().getRTLTextPluginStatus()},R.getVersion=function(){return fo},R.getWorkerCount=function(){return Qi.workerCount},R.getWorkerUrl=function(){return p.a.WORKER_URL},R.importScriptInWorkers=function(u){return Hs().broadcast("IS",u)},R.prewarm=function(){Ur().acquire(Tr)},R.setMaxParallelImageRequests=function(u){p.a.MAX_PARALLEL_IMAGE_REQUESTS=u},R.setRTLTextPlugin=function(u,t){return er().setRTLTextPlugin(u,t)},R.setWorkerCount=function(u){Qi.workerCount=u},R.setWorkerUrl=function(u){p.a.WORKER_URL=u}}));var Tn=Lr;return Tn}))})(Fl,Fl.exports)),Fl.exports}var Oh=Bp();const Fp=Ap.un(Oh),Lp=Dp({__proto__:null,default:Fp},[Oh]);exports.m=Lp;
580
+ `),F=g.createShader(g.FRAGMENT_SHADER);if(g.isContextLost())return void(this.failedToCreate=!0);if(g.shaderSource(F,N),g.compileShader(F),!g.getShaderParameter(F,g.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${g.getShaderInfoLog(F)}`);g.attachShader(this.program,F);const H=g.createShader(g.VERTEX_SHADER);if(g.isContextLost())return void(this.failedToCreate=!0);if(g.shaderSource(H,q),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 K={};this.numAttributes=T.length;for(let tt=0;tt<this.numAttributes;tt++)T[tt]&&(g.bindAttribLocation(this.program,tt,T[tt]),this.attributes[T[tt]]=tt);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(F);for(let tt=0;tt<V.length;tt++){const ot=V[tt];if(ot&&!K[ot]){const ut=g.getUniformLocation(this.program,ot);ut&&(K[ot]=ut)}}this.fixedUniforms=o(t,K),this.terrainUniforms=((tt,ot)=>({u_depth:new p.aH(tt,ot.u_depth),u_terrain:new p.aH(tt,ot.u_terrain),u_terrain_dim:new p.aI(tt,ot.u_terrain_dim),u_terrain_matrix:new p.aJ(tt,ot.u_terrain_matrix),u_terrain_unpack:new p.aK(tt,ot.u_terrain_unpack),u_terrain_exaggeration:new p.aI(tt,ot.u_terrain_exaggeration)}))(t,K),this.binderUniforms=n?n.getUniforms(t,K):[]}draw(t,s,n,o,c,m,g,y,b,T,S,z,A,B,V,$,N,q){const F=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(n),t.setStencilMode(o),t.setColorMode(c),t.setCullFace(m),y){t.activeTexture.set(F.TEXTURE2),F.bindTexture(F.TEXTURE_2D,y.depthTexture),t.activeTexture.set(F.TEXTURE3),F.bindTexture(F.TEXTURE_2D,y.texture);for(const K in this.terrainUniforms)this.terrainUniforms[K].set(y[K])}for(const K in this.fixedUniforms)this.fixedUniforms[K].set(g[K]);V&&V.setUniforms(t,this.binderUniforms,A,{zoom:B});let H=0;switch(s){case F.LINES:H=2;break;case F.TRIANGLES:H=3;break;case F.LINE_STRIP:H=1}for(const K of z.get()){const tt=K.vaos||(K.vaos={});(tt[b]||(tt[b]=new En)).bind(t,this,T,V?V.getPaintVertexBuffers():[],S,K.vertexOffset,$,N,q),F.drawElements(s,K.primitiveLength*H,F.UNSIGNED_SHORT,K.primitiveOffset*H*2)}}}function Ca(u,t,s){const n=1/Gt(s,1,t.transform.tileZoom),o=Math.pow(2,s.tileID.overscaledZ),c=s.tileSize*Math.pow(2,t.transform.tileZoom)/o,m=c*(s.tileID.canonical.x+s.tileID.wrap*o),g=c*s.tileID.canonical.y;return{u_image:0,u_texsize:s.imageAtlasTexture.size,u_scale:[n,u.fromScale,u.toScale],u_fade:u.t,u_pixel_coord_upper:[m>>16,g>>16],u_pixel_coord_lower:[65535&m,65535&g]}}const ta=(u,t,s,n)=>{const o=t.style.light,c=o.properties.get("position"),m=[c.x,c.y,c.z],g=(function(){var b=new p.A(9);return p.A!=Float32Array&&(b[1]=0,b[2]=0,b[3]=0,b[5]=0,b[6]=0,b[7]=0),b[0]=1,b[4]=1,b[8]=1,b})();o.properties.get("anchor")==="viewport"&&(function(b,T){var S=Math.sin(T),z=Math.cos(T);b[0]=z,b[1]=S,b[2]=0,b[3]=-S,b[4]=z,b[5]=0,b[6]=0,b[7]=0,b[8]=1})(g,-t.transform.angle),(function(b,T,S){var z=T[0],A=T[1],B=T[2];b[0]=z*S[0]+A*S[3]+B*S[6],b[1]=z*S[1]+A*S[4]+B*S[7],b[2]=z*S[2]+A*S[5]+B*S[8]})(m,m,g);const y=o.properties.get("color");return{u_matrix:u,u_lightpos:m,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_vertical_gradient:+s,u_opacity:n}},Pa=(u,t,s,n,o,c,m)=>p.e(ta(u,t,s,n),Ca(c,t,m),{u_height_factor:-Math.pow(2,o.overscaledZ)/m.tileSize/8}),ms=u=>({u_matrix:u}),Ro=(u,t,s,n)=>p.e(ms(u),Ca(s,t,n)),jl=(u,t)=>({u_matrix:u,u_world:t}),Bo=(u,t,s,n,o)=>p.e(Ro(u,t,s,n),{u_world:o}),Ul=(u,t,s,n)=>{const o=u.transform;let c,m;if(n.paint.get("circle-pitch-alignment")==="map"){const g=Gt(s,1,o.zoom);c=!0,m=[g,g]}else c=!1,m=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+(n.paint.get("circle-pitch-scale")==="map"),u_matrix:u.translatePosMatrix(t.posMatrix,s,n.paint.get("circle-translate"),n.paint.get("circle-translate-anchor")),u_pitch_with_map:+c,u_device_pixel_ratio:u.pixelRatio,u_extrude_scale:m}},Gr=(u,t,s)=>({u_matrix:u,u_inv_matrix:t,u_camera_to_center_distance:s.cameraToCenterDistance,u_viewport_size:[s.width,s.height]}),ea=(u,t,s=1)=>({u_matrix:u,u_color:t,u_overlay:0,u_overlay_scale:s}),ii=u=>({u_matrix:u}),ri=(u,t,s,n)=>({u_matrix:u,u_extrude_scale:Gt(t,1,s),u_intensity:n}),Aa=(u,t,s,n)=>{const o=p.H();p.aP(o,0,u.width,u.height,0,0,1);const c=u.context.gl;return{u_matrix:o,u_world:[c.drawingBufferWidth,c.drawingBufferHeight],u_image:s,u_color_ramp:n,u_opacity:t.paint.get("heatmap-opacity")}};function Da(u,t){const s=Math.pow(2,t.canonical.z),n=t.canonical.y;return[new p.Z(0,n/s).toLngLat().lat,new p.Z(0,(n+1)/s).toLngLat().lat]}const Ra=(u,t,s,n)=>{const o=u.transform;return{u_matrix:Oo(u,t,s,n),u_ratio:1/Gt(t,1,o.zoom),u_device_pixel_ratio:u.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},Fo=(u,t,s,n,o)=>p.e(Ra(u,t,s,o),{u_image:0,u_image_height:n}),_s=(u,t,s,n,o)=>{const c=u.transform,m=Lo(t,c);return{u_matrix:Oo(u,t,s,o),u_texsize:t.imageAtlasTexture.size,u_ratio:1/Gt(t,1,c.zoom),u_device_pixel_ratio:u.pixelRatio,u_image:0,u_scale:[m,n.fromScale,n.toScale],u_fade:n.t,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]]}},$l=(u,t,s,n,o,c)=>{const m=u.lineAtlas,g=Lo(t,u.transform),y=s.layout.get("line-cap")==="round",b=m.getDash(n.from,y),T=m.getDash(n.to,y),S=b.width*o.fromScale,z=T.width*o.toScale;return p.e(Ra(u,t,s,c),{u_patternscale_a:[g/S,-b.height/2],u_patternscale_b:[g/z,-T.height/2],u_sdfgamma:m.width/(256*Math.min(S,z)*u.pixelRatio)/2,u_image:0,u_tex_y_a:b.y,u_tex_y_b:T.y,u_mix:o.t})};function Lo(u,t){return 1/Gt(u,1,t.tileZoom)}function Oo(u,t,s,n){return u.translatePosMatrix(n?n.posMatrix:t.tileID.posMatrix,t,s.paint.get("line-translate"),s.paint.get("line-translate-anchor"))}const Nl=(u,t,s,n,o)=>{return{u_matrix:u,u_tl_parent:t,u_scale_parent:s,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.opacity*o.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:o.paint.get("raster-brightness-min"),u_brightness_high:o.paint.get("raster-brightness-max"),u_saturation_factor:(m=o.paint.get("raster-saturation"),m>0?1-1/(1.001-m):-m),u_contrast_factor:(c=o.paint.get("raster-contrast"),c>0?1/(1-c):1+c),u_spin_weights:Zl(o.paint.get("raster-hue-rotate"))};var c,m};function Zl(u){u*=Math.PI/180;const t=Math.sin(u),s=Math.cos(u);return[(2*s+1)/3,(-Math.sqrt(3)*t-s+1)/3,(Math.sqrt(3)*t-s+1)/3]}const Vo=(u,t,s,n,o,c,m,g,y,b,T,S,z,A)=>{const B=m.transform;return{u_is_size_zoom_constant:+(u==="constant"||u==="source"),u_is_size_feature_constant:+(u==="constant"||u==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:B.cameraToCenterDistance,u_pitch:B.pitch/360*2*Math.PI,u_rotate_symbol:+s,u_aspect_ratio:B.width/B.height,u_fade_change:m.options.fadeDuration?m.symbolFadeChange:1,u_matrix:g,u_label_plane_matrix:y,u_coord_matrix:b,u_is_text:+S,u_pitch_with_map:+n,u_is_along_line:o,u_is_variable_anchor:c,u_texsize:z,u_texture:0,u_translation:T,u_pitched_scale:A}},ia=(u,t,s,n,o,c,m,g,y,b,T,S,z,A,B)=>{const V=m.transform;return p.e(Vo(u,t,s,n,o,c,m,g,y,b,T,S,z,B),{u_gamma_scale:n?Math.cos(V._pitch)*V.cameraToCenterDistance:1,u_device_pixel_ratio:m.pixelRatio,u_is_halo:+A})},Pn=(u,t,s,n,o,c,m,g,y,b,T,S,z,A)=>p.e(ia(u,t,s,n,o,c,m,g,y,b,T,!0,S,!0,A),{u_texsize_icon:z,u_texture_icon:1}),Ba=(u,t,s)=>({u_matrix:u,u_opacity:t,u_color:s}),An=(u,t,s,n,o,c)=>p.e((function(m,g,y,b){const T=y.imageManager.getPattern(m.from.toString()),S=y.imageManager.getPattern(m.to.toString()),{width:z,height:A}=y.imageManager.getPixelSize(),B=Math.pow(2,b.tileID.overscaledZ),V=b.tileSize*Math.pow(2,y.transform.tileZoom)/B,$=V*(b.tileID.canonical.x+b.tileID.wrap*B),N=V*b.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:T.tl,u_pattern_br_a:T.br,u_pattern_tl_b:S.tl,u_pattern_br_b:S.br,u_texsize:[z,A],u_mix:g.t,u_pattern_size_a:T.displaySize,u_pattern_size_b:S.displaySize,u_scale_a:g.fromScale,u_scale_b:g.toScale,u_tile_units_to_pixels:1/Gt(b,1,y.transform.tileZoom),u_pixel_coord_upper:[$>>16,N>>16],u_pixel_coord_lower:[65535&$,65535&N]}})(n,c,s,o),{u_matrix:u,u_opacity:t}),Dn={fillExtrusion:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_lightpos:new p.aN(u,t.u_lightpos),u_lightintensity:new p.aI(u,t.u_lightintensity),u_lightcolor:new p.aN(u,t.u_lightcolor),u_vertical_gradient:new p.aI(u,t.u_vertical_gradient),u_opacity:new p.aI(u,t.u_opacity)}),fillExtrusionPattern:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_lightpos:new p.aN(u,t.u_lightpos),u_lightintensity:new p.aI(u,t.u_lightintensity),u_lightcolor:new p.aN(u,t.u_lightcolor),u_vertical_gradient:new p.aI(u,t.u_vertical_gradient),u_height_factor:new p.aI(u,t.u_height_factor),u_image:new p.aH(u,t.u_image),u_texsize:new p.aO(u,t.u_texsize),u_pixel_coord_upper:new p.aO(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(u,t.u_pixel_coord_lower),u_scale:new p.aN(u,t.u_scale),u_fade:new p.aI(u,t.u_fade),u_opacity:new p.aI(u,t.u_opacity)}),fill:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix)}),fillPattern:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_image:new p.aH(u,t.u_image),u_texsize:new p.aO(u,t.u_texsize),u_pixel_coord_upper:new p.aO(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(u,t.u_pixel_coord_lower),u_scale:new p.aN(u,t.u_scale),u_fade:new p.aI(u,t.u_fade)}),fillOutline:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_world:new p.aO(u,t.u_world)}),fillOutlinePattern:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_world:new p.aO(u,t.u_world),u_image:new p.aH(u,t.u_image),u_texsize:new p.aO(u,t.u_texsize),u_pixel_coord_upper:new p.aO(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(u,t.u_pixel_coord_lower),u_scale:new p.aN(u,t.u_scale),u_fade:new p.aI(u,t.u_fade)}),circle:(u,t)=>({u_camera_to_center_distance:new p.aI(u,t.u_camera_to_center_distance),u_scale_with_map:new p.aH(u,t.u_scale_with_map),u_pitch_with_map:new p.aH(u,t.u_pitch_with_map),u_extrude_scale:new p.aO(u,t.u_extrude_scale),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_matrix:new p.aJ(u,t.u_matrix)}),collisionBox:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_pixel_extrude_scale:new p.aO(u,t.u_pixel_extrude_scale)}),collisionCircle:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_inv_matrix:new p.aJ(u,t.u_inv_matrix),u_camera_to_center_distance:new p.aI(u,t.u_camera_to_center_distance),u_viewport_size:new p.aO(u,t.u_viewport_size)}),debug:(u,t)=>({u_color:new p.aL(u,t.u_color),u_matrix:new p.aJ(u,t.u_matrix),u_overlay:new p.aH(u,t.u_overlay),u_overlay_scale:new p.aI(u,t.u_overlay_scale)}),clippingMask:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix)}),heatmap:(u,t)=>({u_extrude_scale:new p.aI(u,t.u_extrude_scale),u_intensity:new p.aI(u,t.u_intensity),u_matrix:new p.aJ(u,t.u_matrix)}),heatmapTexture:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_world:new p.aO(u,t.u_world),u_image:new p.aH(u,t.u_image),u_color_ramp:new p.aH(u,t.u_color_ramp),u_opacity:new p.aI(u,t.u_opacity)}),hillshade:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_image:new p.aH(u,t.u_image),u_latrange:new p.aO(u,t.u_latrange),u_light:new p.aO(u,t.u_light),u_shadow:new p.aL(u,t.u_shadow),u_highlight:new p.aL(u,t.u_highlight),u_accent:new p.aL(u,t.u_accent)}),hillshadePrepare:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_image:new p.aH(u,t.u_image),u_dimension:new p.aO(u,t.u_dimension),u_zoom:new p.aI(u,t.u_zoom),u_unpack:new p.aK(u,t.u_unpack)}),line:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_ratio:new p.aI(u,t.u_ratio),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_units_to_pixels:new p.aO(u,t.u_units_to_pixels)}),lineGradient:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_ratio:new p.aI(u,t.u_ratio),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_units_to_pixels:new p.aO(u,t.u_units_to_pixels),u_image:new p.aH(u,t.u_image),u_image_height:new p.aI(u,t.u_image_height)}),linePattern:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_texsize:new p.aO(u,t.u_texsize),u_ratio:new p.aI(u,t.u_ratio),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_image:new p.aH(u,t.u_image),u_units_to_pixels:new p.aO(u,t.u_units_to_pixels),u_scale:new p.aN(u,t.u_scale),u_fade:new p.aI(u,t.u_fade)}),lineSDF:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_ratio:new p.aI(u,t.u_ratio),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_units_to_pixels:new p.aO(u,t.u_units_to_pixels),u_patternscale_a:new p.aO(u,t.u_patternscale_a),u_patternscale_b:new p.aO(u,t.u_patternscale_b),u_sdfgamma:new p.aI(u,t.u_sdfgamma),u_image:new p.aH(u,t.u_image),u_tex_y_a:new p.aI(u,t.u_tex_y_a),u_tex_y_b:new p.aI(u,t.u_tex_y_b),u_mix:new p.aI(u,t.u_mix)}),raster:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_tl_parent:new p.aO(u,t.u_tl_parent),u_scale_parent:new p.aI(u,t.u_scale_parent),u_buffer_scale:new p.aI(u,t.u_buffer_scale),u_fade_t:new p.aI(u,t.u_fade_t),u_opacity:new p.aI(u,t.u_opacity),u_image0:new p.aH(u,t.u_image0),u_image1:new p.aH(u,t.u_image1),u_brightness_low:new p.aI(u,t.u_brightness_low),u_brightness_high:new p.aI(u,t.u_brightness_high),u_saturation_factor:new p.aI(u,t.u_saturation_factor),u_contrast_factor:new p.aI(u,t.u_contrast_factor),u_spin_weights:new p.aN(u,t.u_spin_weights)}),symbolIcon:(u,t)=>({u_is_size_zoom_constant:new p.aH(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(u,t.u_is_size_feature_constant),u_size_t:new p.aI(u,t.u_size_t),u_size:new p.aI(u,t.u_size),u_camera_to_center_distance:new p.aI(u,t.u_camera_to_center_distance),u_pitch:new p.aI(u,t.u_pitch),u_rotate_symbol:new p.aH(u,t.u_rotate_symbol),u_aspect_ratio:new p.aI(u,t.u_aspect_ratio),u_fade_change:new p.aI(u,t.u_fade_change),u_matrix:new p.aJ(u,t.u_matrix),u_label_plane_matrix:new p.aJ(u,t.u_label_plane_matrix),u_coord_matrix:new p.aJ(u,t.u_coord_matrix),u_is_text:new p.aH(u,t.u_is_text),u_pitch_with_map:new p.aH(u,t.u_pitch_with_map),u_is_along_line:new p.aH(u,t.u_is_along_line),u_is_variable_anchor:new p.aH(u,t.u_is_variable_anchor),u_texsize:new p.aO(u,t.u_texsize),u_texture:new p.aH(u,t.u_texture),u_translation:new p.aO(u,t.u_translation),u_pitched_scale:new p.aI(u,t.u_pitched_scale)}),symbolSDF:(u,t)=>({u_is_size_zoom_constant:new p.aH(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(u,t.u_is_size_feature_constant),u_size_t:new p.aI(u,t.u_size_t),u_size:new p.aI(u,t.u_size),u_camera_to_center_distance:new p.aI(u,t.u_camera_to_center_distance),u_pitch:new p.aI(u,t.u_pitch),u_rotate_symbol:new p.aH(u,t.u_rotate_symbol),u_aspect_ratio:new p.aI(u,t.u_aspect_ratio),u_fade_change:new p.aI(u,t.u_fade_change),u_matrix:new p.aJ(u,t.u_matrix),u_label_plane_matrix:new p.aJ(u,t.u_label_plane_matrix),u_coord_matrix:new p.aJ(u,t.u_coord_matrix),u_is_text:new p.aH(u,t.u_is_text),u_pitch_with_map:new p.aH(u,t.u_pitch_with_map),u_is_along_line:new p.aH(u,t.u_is_along_line),u_is_variable_anchor:new p.aH(u,t.u_is_variable_anchor),u_texsize:new p.aO(u,t.u_texsize),u_texture:new p.aH(u,t.u_texture),u_gamma_scale:new p.aI(u,t.u_gamma_scale),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_is_halo:new p.aH(u,t.u_is_halo),u_translation:new p.aO(u,t.u_translation),u_pitched_scale:new p.aI(u,t.u_pitched_scale)}),symbolTextAndIcon:(u,t)=>({u_is_size_zoom_constant:new p.aH(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(u,t.u_is_size_feature_constant),u_size_t:new p.aI(u,t.u_size_t),u_size:new p.aI(u,t.u_size),u_camera_to_center_distance:new p.aI(u,t.u_camera_to_center_distance),u_pitch:new p.aI(u,t.u_pitch),u_rotate_symbol:new p.aH(u,t.u_rotate_symbol),u_aspect_ratio:new p.aI(u,t.u_aspect_ratio),u_fade_change:new p.aI(u,t.u_fade_change),u_matrix:new p.aJ(u,t.u_matrix),u_label_plane_matrix:new p.aJ(u,t.u_label_plane_matrix),u_coord_matrix:new p.aJ(u,t.u_coord_matrix),u_is_text:new p.aH(u,t.u_is_text),u_pitch_with_map:new p.aH(u,t.u_pitch_with_map),u_is_along_line:new p.aH(u,t.u_is_along_line),u_is_variable_anchor:new p.aH(u,t.u_is_variable_anchor),u_texsize:new p.aO(u,t.u_texsize),u_texsize_icon:new p.aO(u,t.u_texsize_icon),u_texture:new p.aH(u,t.u_texture),u_texture_icon:new p.aH(u,t.u_texture_icon),u_gamma_scale:new p.aI(u,t.u_gamma_scale),u_device_pixel_ratio:new p.aI(u,t.u_device_pixel_ratio),u_is_halo:new p.aH(u,t.u_is_halo),u_translation:new p.aO(u,t.u_translation),u_pitched_scale:new p.aI(u,t.u_pitched_scale)}),background:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_opacity:new p.aI(u,t.u_opacity),u_color:new p.aL(u,t.u_color)}),backgroundPattern:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_opacity:new p.aI(u,t.u_opacity),u_image:new p.aH(u,t.u_image),u_pattern_tl_a:new p.aO(u,t.u_pattern_tl_a),u_pattern_br_a:new p.aO(u,t.u_pattern_br_a),u_pattern_tl_b:new p.aO(u,t.u_pattern_tl_b),u_pattern_br_b:new p.aO(u,t.u_pattern_br_b),u_texsize:new p.aO(u,t.u_texsize),u_mix:new p.aI(u,t.u_mix),u_pattern_size_a:new p.aO(u,t.u_pattern_size_a),u_pattern_size_b:new p.aO(u,t.u_pattern_size_b),u_scale_a:new p.aI(u,t.u_scale_a),u_scale_b:new p.aI(u,t.u_scale_b),u_pixel_coord_upper:new p.aO(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(u,t.u_pixel_coord_lower),u_tile_units_to_pixels:new p.aI(u,t.u_tile_units_to_pixels)}),terrain:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_texture:new p.aH(u,t.u_texture),u_ele_delta:new p.aI(u,t.u_ele_delta),u_fog_matrix:new p.aJ(u,t.u_fog_matrix),u_fog_color:new p.aL(u,t.u_fog_color),u_fog_ground_blend:new p.aI(u,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new p.aI(u,t.u_fog_ground_blend_opacity),u_horizon_color:new p.aL(u,t.u_horizon_color),u_horizon_fog_blend:new p.aI(u,t.u_horizon_fog_blend)}),terrainDepth:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_ele_delta:new p.aI(u,t.u_ele_delta)}),terrainCoords:(u,t)=>({u_matrix:new p.aJ(u,t.u_matrix),u_texture:new p.aH(u,t.u_texture),u_terrain_coords_id:new p.aI(u,t.u_terrain_coords_id),u_ele_delta:new p.aI(u,t.u_ele_delta)}),sky:(u,t)=>({u_sky_color:new p.aL(u,t.u_sky_color),u_horizon_color:new p.aL(u,t.u_horizon_color),u_horizon:new p.aI(u,t.u_horizon),u_sky_horizon_blend:new p.aI(u,t.u_sky_horizon_blend)})};class sr{constructor(t,s,n){this.context=t;const o=t.gl;this.buffer=o.createBuffer(),this.dynamicDraw=!!n,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,s.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete s.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const s=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),s.bufferSubData(s.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const ql={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Rn{constructor(t,s,n,o){this.length=s.length,this.attributes=n,this.itemSize=s.bytesPerElement,this.dynamicDraw=o,this.context=t;const c=t.gl;this.buffer=c.createBuffer(),t.bindVertexBuffer.set(this.buffer),c.bufferData(c.ARRAY_BUFFER,s.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete s.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 s=this.context.gl;this.bind(),s.bufferSubData(s.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,s){for(let n=0;n<this.attributes.length;n++){const o=s.attributes[this.attributes[n].name];o!==void 0&&t.enableVertexAttribArray(o)}}setVertexAttribPointers(t,s,n){for(let o=0;o<this.attributes.length;o++){const c=this.attributes[o],m=s.attributes[c.name];m!==void 0&&t.vertexAttribPointer(m,c.components,t[ql[c.type]],!1,this.itemSize,c.offset+this.itemSize*(n||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Xr=new WeakMap;function Cr(u){var t;if(Xr.has(u))return Xr.get(u);{const s=(t=u.getParameter(u.VERSION))===null||t===void 0?void 0:t.startsWith("WebGL 2.0");return Xr.set(u,s),s}}class ie{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 Fa extends ie{getDefault(){return p.aM.transparent}set(t){const s=this.current;(t.r!==s.r||t.g!==s.g||t.b!==s.b||t.a!==s.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Gl extends ie{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class gs extends ie{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class Xl extends ie{getDefault(){return[!0,!0,!0,!0]}set(t){const s=this.current;(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||t[3]!==s[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class jo extends ie{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class Hl extends ie{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class Uo extends ie{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const s=this.current;(t.func!==s.func||t.ref!==s.ref||t.mask!==s.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class Bn extends ie{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const s=this.current;(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class $o extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;t?s.enable(s.STENCIL_TEST):s.disable(s.STENCIL_TEST),this.current=t,this.dirty=!1}}class No extends ie{getDefault(){return[0,1]}set(t){const s=this.current;(t[0]!==s[0]||t[1]!==s[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class Zo extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;t?s.enable(s.DEPTH_TEST):s.disable(s.DEPTH_TEST),this.current=t,this.dirty=!1}}class qo extends ie{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class Hr extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;t?s.enable(s.BLEND):s.disable(s.BLEND),this.current=t,this.dirty=!1}}class Go extends ie{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const s=this.current;(t[0]!==s[0]||t[1]!==s[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class Wl extends ie{getDefault(){return p.aM.transparent}set(t){const s=this.current;(t.r!==s.r||t.g!==s.g||t.b!==s.b||t.a!==s.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Xo extends ie{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class ra extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;t?s.enable(s.CULL_FACE):s.disable(s.CULL_FACE),this.current=t,this.dirty=!1}}class Kl extends ie{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class La extends ie{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class Jl extends ie{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Yl extends ie{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class Ho extends ie{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const s=this.current;(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||t[3]!==s[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Wo extends ie{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.bindFramebuffer(s.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Ko extends ie{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.bindRenderbuffer(s.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Fn extends ie{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.bindTexture(s.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class Jo extends ie{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.bindBuffer(s.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Oa extends ie{getDefault(){return null}set(t){const s=this.gl;s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class _r extends ie{getDefault(){return null}set(t){var s;if(t===this.current&&!this.dirty)return;const n=this.gl;Cr(n)?n.bindVertexArray(t):(s=n.getExtension("OES_vertex_array_object"))===null||s===void 0||s.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class Ln extends ie{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class On extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class Vn extends ie{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const s=this.gl;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class Va extends ie{constructor(t,s){super(t),this.context=t,this.parent=s}getDefault(){return null}}class jn extends Va{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const s=this.gl;s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class Wr extends Va{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const s=this.gl;s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Un extends Va{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const s=this.gl;s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Ql{constructor(t,s,n,o,c){this.context=t,this.width=s,this.height=n;const m=t.gl,g=this.framebuffer=m.createFramebuffer();if(this.colorAttachment=new jn(t,g),o)this.depthAttachment=c?new Un(t,g):new Wr(t,g);else if(c)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,s=this.colorAttachment.get();if(s&&t.deleteTexture(s),this.depthAttachment){const n=this.depthAttachment.get();n&&t.deleteRenderbuffer(n)}t.deleteFramebuffer(this.framebuffer)}}class be{constructor(t,s,n){this.blendFunction=t,this.blendColor=s,this.mask=n}}be.Replace=[1,0],be.disabled=new be(be.Replace,p.aM.transparent,[!1,!1,!1,!1]),be.unblended=new be(be.Replace,p.aM.transparent,[!0,!0,!0,!0]),be.alphaBlended=new be([1,771],p.aM.transparent,[!0,!0,!0,!0]);class tc{constructor(t){var s,n;if(this.gl=t,this.clearColor=new Fa(this),this.clearDepth=new Gl(this),this.clearStencil=new gs(this),this.colorMask=new Xl(this),this.depthMask=new jo(this),this.stencilMask=new Hl(this),this.stencilFunc=new Uo(this),this.stencilOp=new Bn(this),this.stencilTest=new $o(this),this.depthRange=new No(this),this.depthTest=new Zo(this),this.depthFunc=new qo(this),this.blend=new Hr(this),this.blendFunc=new Go(this),this.blendColor=new Wl(this),this.blendEquation=new Xo(this),this.cullFace=new ra(this),this.cullFaceSide=new Kl(this),this.frontFace=new La(this),this.program=new Jl(this),this.activeTexture=new Yl(this),this.viewport=new Ho(this),this.bindFramebuffer=new Wo(this),this.bindRenderbuffer=new Ko(this),this.bindTexture=new Fn(this),this.bindVertexBuffer=new Jo(this),this.bindElementBuffer=new Oa(this),this.bindVertexArray=new _r(this),this.pixelStoreUnpack=new Ln(this),this.pixelStoreUnpackPremultiplyAlpha=new On(this),this.pixelStoreUnpackFlipY=new Vn(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),Cr(t)){this.HALF_FLOAT=t.HALF_FLOAT;const o=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(s=t.RGBA16F)!==null&&s!==void 0?s:o==null?void 0:o.RGBA16F_EXT,this.RGB16F=(n=t.RGB16F)!==null&&n!==void 0?n:o==null?void 0:o.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");const o=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=o==null?void 0:o.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,s){return new sr(this,t,s)}createVertexBuffer(t,s,n){return new Rn(this,t,s,n)}createRenderbuffer(t,s,n){const o=this.gl,c=o.createRenderbuffer();return this.bindRenderbuffer.set(c),o.renderbufferStorage(o.RENDERBUFFER,t,s,n),this.bindRenderbuffer.set(null),c}createFramebuffer(t,s,n,o){return new Ql(this,t,s,n,o)}clear({color:t,depth:s,stencil:n}){const o=this.gl;let c=0;t&&(c|=o.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),s!==void 0&&(c|=o.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(s),this.depthMask.set(!0)),n!==void 0&&(c|=o.STENCIL_BUFFER_BIT,this.clearStencil.set(n),this.stencilMask.set(255)),o.clear(c)}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.aE(t.blendFunction,be.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 Cr(this.gl)?this.gl.createVertexArray():(t=this.gl.getExtension("OES_vertex_array_object"))===null||t===void 0?void 0:t.createVertexArrayOES()}deleteVertexArray(t){var s;return Cr(this.gl)?this.gl.deleteVertexArray(t):(s=this.gl.getExtension("OES_vertex_array_object"))===null||s===void 0?void 0:s.deleteVertexArrayOES(t)}unbindVAO(){this.bindVertexArray.set(null)}}class qt{constructor(t,s,n){this.func=t,this.mask=s,this.range=n}}qt.ReadOnly=!1,qt.ReadWrite=!0,qt.disabled=new qt(519,qt.ReadOnly,[0,1]);const ja=7680;class ue{constructor(t,s,n,o,c,m){this.test=t,this.ref=s,this.mask=n,this.fail=o,this.depthFail=c,this.pass=m}}ue.disabled=new ue({func:519,mask:0},0,0,ja,ja,ja);class ne{constructor(t,s,n){this.enable=t,this.mode=s,this.frontFace=n}}let Kr;function sa(u,t,s,n,o){const c=u.context,m=c.gl,g=u.useProgram("collisionBox"),y=[];let b=0,T=0;for(let N=0;N<n.length;N++){const q=n[N],F=t.getTile(q).getBucket(s);if(!F)continue;const H=o?F.textCollisionBox:F.iconCollisionBox,K=F.collisionCircleArray;if(K.length>0){const tt=p.H();p.aQ(tt,F.placementInvProjMatrix,u.transform.glCoordMatrix),p.aQ(tt,tt,F.placementViewportMatrix),y.push({circleArray:K,circleOffset:T,transform:q.posMatrix,invTransform:tt,coord:q}),b+=K.length/4,T=b}H&&g.draw(c,m.LINES,qt.disabled,ue.disabled,u.colorModeForRenderPass(),ne.disabled,{u_matrix:q.posMatrix,u_pixel_extrude_scale:[1/(S=u.transform).width,1/S.height]},u.style.map.terrain&&u.style.map.terrain.getTerrainData(q),s.id,H.layoutVertexBuffer,H.indexBuffer,H.segments,null,u.transform.zoom,null,null,H.collisionVertexBuffer)}var S;if(!o||!y.length)return;const z=u.useProgram("collisionCircle"),A=new p.aR;A.resize(4*b),A._trim();let B=0;for(const N of y)for(let q=0;q<N.circleArray.length/4;q++){const F=4*q,H=N.circleArray[F+0],K=N.circleArray[F+1],tt=N.circleArray[F+2],ot=N.circleArray[F+3];A.emplace(B++,H,K,tt,ot,0),A.emplace(B++,H,K,tt,ot,1),A.emplace(B++,H,K,tt,ot,2),A.emplace(B++,H,K,tt,ot,3)}(!Kr||Kr.length<2*b)&&(Kr=(function(N){const q=2*N,F=new p.aT;F.resize(q),F._trim();for(let H=0;H<q;H++){const K=6*H;F.uint16[K+0]=4*H+0,F.uint16[K+1]=4*H+1,F.uint16[K+2]=4*H+2,F.uint16[K+3]=4*H+2,F.uint16[K+4]=4*H+3,F.uint16[K+5]=4*H+0}return F})(b));const V=c.createIndexBuffer(Kr,!0),$=c.createVertexBuffer(A,p.aS.members,!0);for(const N of y){const q=Gr(N.transform,N.invTransform,u.transform);z.draw(c,m.TRIANGLES,qt.disabled,ue.disabled,u.colorModeForRenderPass(),ne.disabled,q,u.style.map.terrain&&u.style.map.terrain.getTerrainData(N.coord),s.id,$,V,p.a0.simpleSegment(0,2*N.circleOffset,N.circleArray.length,N.circleArray.length/2),null,u.transform.zoom,null,null,null)}$.destroy(),V.destroy()}ne.disabled=new ne(!1,1029,2305),ne.backCCW=new ne(!0,1029,2305);const aa=p.an(new Float32Array(16));function $n(u,t,s,n,o,c){const{horizontalAlign:m,verticalAlign:g}=p.au(u);return new p.P((-(m-.5)*t/o+n[0])*c,(-(g-.5)*s/o+n[1])*c)}function Jr(u,t,s,n,o,c){const m=t.tileAnchorPoint.add(new p.P(t.translation[0],t.translation[1]));if(t.pitchWithMap){let g=n.mult(c);s||(g=g.rotate(-o));const y=m.add(g);return j(y.x,y.y,t.labelPlaneMatrix,t.getElevation).point}if(s){const g=st(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(u),y=Math.atan(g.y/g.x)+(g.x<0?Math.PI:0);return u.add(n.rotate(y))}return u.add(n)}function ys(u,t,s,n,o,c,m,g,y,b,T,S,z,A){const B=u.text.placedSymbolArray,V=u.text.dynamicLayoutVertexArray,$=u.icon.dynamicLayoutVertexArray,N={};V.clear();for(let q=0;q<B.length;q++){const F=B.get(q),H=F.hidden||!F.crossTileID||u.allowVerticalPlacement&&!F.placedOrientation?null:n[F.crossTileID];if(H){const K=new p.P(F.anchorX,F.anchorY),tt={getElevation:A,width:o.width,height:o.height,labelPlaneMatrix:c,lineVertexArray:null,pitchWithMap:s,projection:T,projectionCache:null,tileAnchorPoint:K,translation:S,unwrappedTileID:z},ot=s?j(K.x,K.y,m,A):st(K.x,K.y,tt),ut=M(o.cameraToCenterDistance,ot.signedDistanceFromCamera);let xt=p.ai(u.textSizeData,y,F)*ut/p.ap;s&&(xt*=u.tilePixelRatio/g);const{width:Tt,height:ft,anchor:pt,textOffset:Et,textBoxScale:Vt}=H,gt=$n(pt,Tt,ft,Et,Vt,xt),bt=T.getPitchedTextCorrection(o,K.add(new p.P(S[0],S[1])),z),Lt=Jr(ot.point,tt,t,gt,o.angle,bt),pe=u.allowVerticalPlacement&&F.placedOrientation===p.ah.vertical?Math.PI/2:0;for(let $t=0;$t<F.numGlyphs;$t++)p.aj(V,Lt,pe);b&&F.associatedIconIndex>=0&&(N[F.associatedIconIndex]={shiftedAnchor:Lt,angle:pe})}else Dt(F.numGlyphs,V)}if(b){$.clear();const q=u.icon.placedSymbolArray;for(let F=0;F<q.length;F++){const H=q.get(F);if(H.hidden)Dt(H.numGlyphs,$);else{const K=N[F];if(K)for(let tt=0;tt<H.numGlyphs;tt++)p.aj($,K.shiftedAnchor,K.angle);else Dt(H.numGlyphs,$)}}u.icon.dynamicLayoutVertexBuffer.updateData($)}u.text.dynamicLayoutVertexBuffer.updateData(V)}function Ti(u,t,s){return s.iconsInText&&t?"symbolTextAndIcon":u?"symbolSDF":"symbolIcon"}function Nn(u,t,s,n,o,c,m,g,y,b,T,S){const z=u.context,A=z.gl,B=u.transform,V=Zr(),$=g==="map",N=y==="map",q=g!=="viewport"&&s.layout.get("symbol-placement")!=="point",F=$&&!N&&!q,H=!N&&q,K=!s.layout.get("symbol-sort-key").isConstant();let tt=!1;const ot=u.depthModeForSublayer(0,qt.ReadOnly),ut=s._unevaluatedLayout.hasValue("text-variable-anchor")||s._unevaluatedLayout.hasValue("text-variable-anchor-offset"),xt=[],Tt=V.getCircleRadiusCorrection(B);for(const ft of n){const pt=t.getTile(ft),Et=pt.getBucket(s);if(!Et)continue;const Vt=o?Et.text:Et.icon;if(!Vt||!Vt.segments.get().length||!Vt.hasVisibleVertices)continue;const gt=Vt.programConfigurations.get(s.id),bt=o||Et.sdfIcons,Lt=o?Et.textSizeData:Et.iconSizeData,pe=N||B.pitch!==0,$t=u.useProgram(Ti(bt,o,Et),gt),Xt=p.ag(Lt,B.zoom),fe=u.style.map.terrain&&u.style.map.terrain.getTerrainData(ft);let Ve,Ui,me,si,Ke=[0,0],je=null;if(o)Ui=pt.glyphAtlasTexture,me=A.LINEAR,Ve=pt.glyphAtlasTexture.size,Et.iconsInText&&(Ke=pt.imageAtlasTexture.size,je=pt.imageAtlasTexture,si=pe||u.options.rotating||u.options.zooming||Lt.kind==="composite"||Lt.kind==="camera"?A.LINEAR:A.NEAREST);else{const Wt=s.layout.get("icon-size").constantOr(0)!==1||Et.iconsNeedLinear;Ui=pt.imageAtlasTexture,me=bt||u.options.rotating||u.options.zooming||Wt||pe?A.LINEAR:A.NEAREST,Ve=pt.imageAtlasTexture.size}const Je=Gt(pt,1,u.transform.zoom),or=H?ft.posMatrix:aa,Rs=Er(or,N,$,u.transform,Je),nn=rr(or,N,$,u.transform,Je),Bs=rr(ft.posMatrix,N,$,u.transform,Je),ki=V.translatePosition(u.transform,pt,c,m),on=ut&&Et.hasTextData(),mo=s.layout.get("icon-text-fit")!=="none"&&on&&Et.hasIconData();if(q){const Wt=u.style.map.terrain?(Fs,Ls)=>u.style.map.terrain.getElevation(ft,Fs,Ls):null,is=s.layout.get("text-rotation-alignment")==="map";D(Et,ft.posMatrix,u,o,Rs,Bs,N,b,is,V,ft.toUnwrapped(),B.width,B.height,ki,Wt)}const Mi=ft.posMatrix,Ei=o&&ut||mo,Pr=q||Ei?aa:Rs,$i=nn,Be=bt&&s.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Ue;Ue=bt?Et.iconsInText?Pn(Lt.kind,Xt,F,N,q,Ei,u,Mi,Pr,$i,ki,Ve,Ke,Tt):ia(Lt.kind,Xt,F,N,q,Ei,u,Mi,Pr,$i,ki,o,Ve,!0,Tt):Vo(Lt.kind,Xt,F,N,q,Ei,u,Mi,Pr,$i,ki,o,Ve,Tt);const gi={program:$t,buffers:Vt,uniformValues:Ue,atlasTexture:Ui,atlasTextureIcon:je,atlasInterpolation:me,atlasInterpolationIcon:si,isSDF:bt,hasHalo:Be};if(K&&Et.canOverlap){tt=!0;const Wt=Vt.segments.get();for(const is of Wt)xt.push({segments:new p.a0([is]),sortKey:is.sortKey,state:gi,terrainData:fe})}else xt.push({segments:Vt.segments,sortKey:0,state:gi,terrainData:fe})}tt&&xt.sort(((ft,pt)=>ft.sortKey-pt.sortKey));for(const ft of xt){const pt=ft.state;if(z.activeTexture.set(A.TEXTURE0),pt.atlasTexture.bind(pt.atlasInterpolation,A.CLAMP_TO_EDGE),pt.atlasTextureIcon&&(z.activeTexture.set(A.TEXTURE1),pt.atlasTextureIcon&&pt.atlasTextureIcon.bind(pt.atlasInterpolationIcon,A.CLAMP_TO_EDGE)),pt.isSDF){const Et=pt.uniformValues;pt.hasHalo&&(Et.u_is_halo=1,Zn(pt.buffers,ft.segments,s,u,pt.program,ot,T,S,Et,ft.terrainData)),Et.u_is_halo=0}Zn(pt.buffers,ft.segments,s,u,pt.program,ot,T,S,pt.uniformValues,ft.terrainData)}}function Zn(u,t,s,n,o,c,m,g,y,b){const T=n.context;o.draw(T,T.gl.TRIANGLES,c,m,g,ne.disabled,y,b,s.id,u.layoutVertexBuffer,u.indexBuffer,t,s.paint,n.transform.zoom,u.programConfigurations.get(s.id),u.dynamicLayoutVertexBuffer,u.opacityVertexBuffer)}function qn(u,t,s,n){const o=u.context,c=o.gl,m=ue.disabled,g=new be([c.ONE,c.ONE],p.aM.transparent,[!0,!0,!0,!0]),y=t.getBucket(s);if(!y)return;const b=n.key;let T=s.heatmapFbos.get(b);T||(T=na(o,t.tileSize,t.tileSize),s.heatmapFbos.set(b,T)),o.bindFramebuffer.set(T.framebuffer),o.viewport.set([0,0,t.tileSize,t.tileSize]),o.clear({color:p.aM.transparent});const S=y.programConfigurations.get(s.id),z=u.useProgram("heatmap",S),A=u.style.map.terrain.getTerrainData(n);z.draw(o,c.TRIANGLES,qt.disabled,m,g,ne.disabled,ri(n.posMatrix,t,u.transform.zoom,s.paint.get("heatmap-intensity")),A,s.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,s.paint,u.transform.zoom,S)}function Yr(u,t,s){const n=u.context,o=n.gl;n.setColorMode(u.colorModeForRenderPass());const c=oa(n,t),m=s.key,g=t.heatmapFbos.get(m);g&&(n.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,g.colorAttachment.get()),n.activeTexture.set(o.TEXTURE1),c.bind(o.LINEAR,o.CLAMP_TO_EDGE),u.useProgram("heatmapTexture").draw(n,o.TRIANGLES,qt.disabled,ue.disabled,u.colorModeForRenderPass(),ne.disabled,Aa(u,t,0,1),null,t.id,u.rasterBoundsBuffer,u.quadTriangleIndexBuffer,u.rasterBoundsSegments,t.paint,u.transform.zoom),g.destroy(),t.heatmapFbos.delete(m))}function na(u,t,s){var n,o;const c=u.gl,m=c.createTexture();c.bindTexture(c.TEXTURE_2D,m),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR);const g=(n=u.HALF_FLOAT)!==null&&n!==void 0?n:c.UNSIGNED_BYTE,y=(o=u.RGBA16F)!==null&&o!==void 0?o:c.RGBA;c.texImage2D(c.TEXTURE_2D,0,y,t,s,0,c.RGBA,g,null);const b=u.createFramebuffer(t,s,!1,!1);return b.colorAttachment.set(m),b}function oa(u,t){return t.colorRampTexture||(t.colorRampTexture=new ae(u,t.colorRamp,u.gl.RGBA)),t.colorRampTexture}function xs(u,t,s,n,o){if(!s||!n||!n.imageAtlas)return;const c=n.imageAtlas.patternPositions;let m=c[s.to.toString()],g=c[s.from.toString()];if(!m&&g&&(m=g),!g&&m&&(g=m),!m||!g){const y=o.getPaintProperty(t);m=c[y],g=c[y]}m&&g&&u.setConstantPatternPositions(m,g)}function la(u,t,s,n,o,c,m){const g=u.context.gl,y="fill-pattern",b=s.paint.get(y),T=b&&b.constantOr(1),S=s.getCrossfadeParameters();let z,A,B,V,$;m?(A=T&&!s.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",z=g.LINES):(A=T?"fillPattern":"fill",z=g.TRIANGLES);const N=b.constantOr(null);for(const q of n){const F=t.getTile(q);if(T&&!F.patternsLoaded())continue;const H=F.getBucket(s);if(!H)continue;const K=H.programConfigurations.get(s.id),tt=u.useProgram(A,K),ot=u.style.map.terrain&&u.style.map.terrain.getTerrainData(q);T&&(u.context.activeTexture.set(g.TEXTURE0),F.imageAtlasTexture.bind(g.LINEAR,g.CLAMP_TO_EDGE),K.updatePaintBuffers(S)),xs(K,y,N,F,s);const ut=ot?q:null,xt=u.translatePosMatrix(ut?ut.posMatrix:q.posMatrix,F,s.paint.get("fill-translate"),s.paint.get("fill-translate-anchor"));if(m){V=H.indexBuffer2,$=H.segments2;const Tt=[g.drawingBufferWidth,g.drawingBufferHeight];B=A==="fillOutlinePattern"&&T?Bo(xt,u,S,F,Tt):jl(xt,Tt)}else V=H.indexBuffer,$=H.segments,B=T?Ro(xt,u,S,F):ms(xt);tt.draw(u.context,z,o,u.stencilModeForClipping(q),c,ne.disabled,B,ot,s.id,H.layoutVertexBuffer,V,$,s.paint,u.transform.zoom,K)}}function Ua(u,t,s,n,o,c,m){const g=u.context,y=g.gl,b="fill-extrusion-pattern",T=s.paint.get(b),S=T.constantOr(1),z=s.getCrossfadeParameters(),A=s.paint.get("fill-extrusion-opacity"),B=T.constantOr(null);for(const V of n){const $=t.getTile(V),N=$.getBucket(s);if(!N)continue;const q=u.style.map.terrain&&u.style.map.terrain.getTerrainData(V),F=N.programConfigurations.get(s.id),H=u.useProgram(S?"fillExtrusionPattern":"fillExtrusion",F);S&&(u.context.activeTexture.set(y.TEXTURE0),$.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),F.updatePaintBuffers(z)),xs(F,b,B,$,s);const K=u.translatePosMatrix(V.posMatrix,$,s.paint.get("fill-extrusion-translate"),s.paint.get("fill-extrusion-translate-anchor")),tt=s.paint.get("fill-extrusion-vertical-gradient"),ot=S?Pa(K,u,tt,A,V,z,$):ta(K,u,tt,A);H.draw(g,g.gl.TRIANGLES,o,c,m,ne.backCCW,ot,q,s.id,N.layoutVertexBuffer,N.indexBuffer,N.segments,s.paint,u.transform.zoom,F,u.style.map.terrain&&N.centroidVertexBuffer)}}function vs(u,t,s,n,o,c,m){const g=u.context,y=g.gl,b=s.fbo;if(!b)return;const T=u.useProgram("hillshade"),S=u.style.map.terrain&&u.style.map.terrain.getTerrainData(t);g.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,b.colorAttachment.get()),T.draw(g,y.TRIANGLES,o,c,m,ne.disabled,((z,A,B,V)=>{const $=B.paint.get("hillshade-shadow-color"),N=B.paint.get("hillshade-highlight-color"),q=B.paint.get("hillshade-accent-color");let F=B.paint.get("hillshade-illumination-direction")*(Math.PI/180);B.paint.get("hillshade-illumination-anchor")==="viewport"&&(F-=z.transform.angle);const H=!z.options.moving;return{u_matrix:V?V.posMatrix:z.transform.calculatePosMatrix(A.tileID.toUnwrapped(),H),u_image:0,u_latrange:Da(0,A.tileID),u_light:[B.paint.get("hillshade-exaggeration"),F],u_shadow:$,u_highlight:N,u_accent:q}})(u,s,n,S?t:null),S,n.id,u.rasterBoundsBuffer,u.quadTriangleIndexBuffer,u.rasterBoundsSegments)}function bs(u,t,s,n,o,c){const m=u.context,g=m.gl,y=t.dem;if(y&&y.data){const b=y.dim,T=y.stride,S=y.getPixels();if(m.activeTexture.set(g.TEXTURE1),m.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||u.getTileTexture(T),t.demTexture){const A=t.demTexture;A.update(S,{premultiply:!1}),A.bind(g.NEAREST,g.CLAMP_TO_EDGE)}else t.demTexture=new ae(m,S,g.RGBA,{premultiply:!1}),t.demTexture.bind(g.NEAREST,g.CLAMP_TO_EDGE);m.activeTexture.set(g.TEXTURE0);let z=t.fbo;if(!z){const A=new ae(m,{width:b,height:b,data:null},g.RGBA);A.bind(g.LINEAR,g.CLAMP_TO_EDGE),z=t.fbo=m.createFramebuffer(b,b,!0,!1),z.colorAttachment.set(A.texture)}m.bindFramebuffer.set(z.framebuffer),m.viewport.set([0,0,b,b]),u.useProgram("hillshadePrepare").draw(m,g.TRIANGLES,n,o,c,ne.disabled,((A,B)=>{const V=B.stride,$=p.H();return p.aP($,0,p.X,-p.X,0,0,1),p.J($,$,[0,-p.X,0]),{u_matrix:$,u_image:1,u_dimension:[V,V],u_zoom:A.overscaledZ,u_unpack:B.getUnpackVector()}})(t.tileID,y),null,s.id,u.rasterBoundsBuffer,u.quadTriangleIndexBuffer,u.rasterBoundsSegments),t.needsHillshadePrepare=!1}}function Yo(u,t,s,n,o,c){const m=n.paint.get("raster-fade-duration");if(!c&&m>0){const g=mt.now(),y=(g-u.timeAdded)/m,b=t?(g-t.timeAdded)/m:-1,T=s.getSource(),S=o.coveringZoomLevel({tileSize:T.tileSize,roundZoom:T.roundZoom}),z=!t||Math.abs(t.tileID.overscaledZ-S)>Math.abs(u.tileID.overscaledZ-S),A=z&&u.refreshedUponExpiration?1:p.ac(z?y:1-b,0,1);return u.refreshedUponExpiration&&y>=1&&(u.refreshedUponExpiration=!1),t?{opacity:1,mix:1-A}:{opacity:A,mix:0}}return{opacity:1,mix:0}}const Gn=new p.aM(1,0,0,1),Yt=new p.aM(0,1,0,1),$a=new p.aM(0,0,1,1),ec=new p.aM(1,0,1,1),Qo=new p.aM(0,1,1,1);function ws(u,t,s,n){Na(u,0,t+s/2,u.transform.width,s,n)}function tl(u,t,s,n){Na(u,t-s/2,0,s,u.transform.height,n)}function Na(u,t,s,n,o,c){const m=u.context,g=m.gl;g.enable(g.SCISSOR_TEST),g.scissor(t*u.pixelRatio,s*u.pixelRatio,n*u.pixelRatio,o*u.pixelRatio),m.clear({color:c}),g.disable(g.SCISSOR_TEST)}function el(u,t,s){const n=u.context,o=n.gl,c=s.posMatrix,m=u.useProgram("debug"),g=qt.disabled,y=ue.disabled,b=u.colorModeForRenderPass(),T="$debug",S=u.style.map.terrain&&u.style.map.terrain.getTerrainData(s);n.activeTexture.set(o.TEXTURE0);const z=t.getTileByID(s.key).latestRawTileData,A=Math.floor((z&&z.byteLength||0)/1024),B=t.getTile(s).tileSize,V=512/Math.min(B,512)*(s.overscaledZ/u.transform.zoom)*.5;let $=s.canonical.toString();s.overscaledZ!==s.canonical.z&&($+=` => ${s.overscaledZ}`),(function(N,q){N.initDebugOverlayCanvas();const F=N.debugOverlayCanvas,H=N.context.gl,K=N.debugOverlayCanvas.getContext("2d");K.clearRect(0,0,F.width,F.height),K.shadowColor="white",K.shadowBlur=2,K.lineWidth=1.5,K.strokeStyle="white",K.textBaseline="top",K.font="bold 36px Open Sans, sans-serif",K.fillText(q,5,5),K.strokeText(q,5,5),N.debugOverlayTexture.update(F),N.debugOverlayTexture.bind(H.LINEAR,H.CLAMP_TO_EDGE)})(u,`${$} ${A}kB`),m.draw(n,o.TRIANGLES,g,y,be.alphaBlended,ne.disabled,ea(c,p.aM.transparent,V),null,T,u.debugBuffer,u.quadTriangleIndexBuffer,u.debugSegments),m.draw(n,o.LINE_STRIP,g,y,b,ne.disabled,ea(c,p.aM.red),S,T,u.debugBuffer,u.tileBorderIndexBuffer,u.debugSegments)}function il(u,t,s){const n=u.context,o=n.gl,c=u.colorModeForRenderPass(),m=new qt(o.LEQUAL,qt.ReadWrite,u.depthRangeFor3D),g=u.useProgram("terrain"),y=t.getTerrainMesh();n.bindFramebuffer.set(null),n.viewport.set([0,0,u.width,u.height]);for(const b of s){const T=u.renderToTexture.getTexture(b),S=t.getTerrainData(b.tileID);n.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,T.texture);const z=u.transform.calculatePosMatrix(b.tileID.toUnwrapped()),A=t.getMeshFrameDelta(u.transform.zoom),B=u.transform.calculateFogMatrix(b.tileID.toUnwrapped()),V=zn(z,A,B,u.style.sky,u.transform.pitch);g.draw(n,o.TRIANGLES,m,ue.disabled,c,ne.backCCW,V,S,"terrain",y.vertexBuffer,y.indexBuffer,y.segments)}}class Za{constructor(t,s,n){this.vertexBuffer=t,this.indexBuffer=s,this.segments=n}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class qa{constructor(t,s){this.context=new tc(t),this.transform=s,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:p.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Ft.maxUnderzooming+Ft.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Mn}resize(t,s,n){if(this.width=Math.floor(t*n),this.height=Math.floor(s*n),this.pixelRatio=n,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const o of this.style._order)this.style._layers[o].resize()}setup(){const t=this.context,s=new p.aX;s.emplaceBack(0,0),s.emplaceBack(p.X,0),s.emplaceBack(0,p.X),s.emplaceBack(p.X,p.X),this.tileExtentBuffer=t.createVertexBuffer(s,qr.members),this.tileExtentSegments=p.a0.simpleSegment(0,0,4,2);const 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.debugBuffer=t.createVertexBuffer(n,qr.members),this.debugSegments=p.a0.simpleSegment(0,0,4,5);const o=new p.$;o.emplaceBack(0,0,0,0),o.emplaceBack(p.X,0,p.X,0),o.emplaceBack(0,p.X,0,p.X),o.emplaceBack(p.X,p.X,p.X,p.X),this.rasterBoundsBuffer=t.createVertexBuffer(o,kr.members),this.rasterBoundsSegments=p.a0.simpleSegment(0,0,4,2);const c=new p.aX;c.emplaceBack(0,0),c.emplaceBack(1,0),c.emplaceBack(0,1),c.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(c,qr.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 ue({func:y.ALWAYS,mask:0},0,255,y.ZERO,y.ZERO,y.ZERO)}clearStencil(){const t=this.context,s=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const n=p.H();p.aP(n,0,this.width,this.height,0,0,1),p.K(n,n,[s.drawingBufferWidth,s.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,s.TRIANGLES,qt.disabled,this.stencilClearMode,be.disabled,ne.disabled,ii(n),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,s){if(this.currentStencilSource===t.source||!t.isTileClipped()||!s||!s.length)return;this.currentStencilSource=t.source;const n=this.context,o=n.gl;this.nextStencilID+s.length>256&&this.clearStencil(),n.setColorMode(be.disabled),n.setDepthMode(qt.disabled);const c=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const m of s){const g=this._tileClippingMaskIDs[m.key]=this.nextStencilID++,y=this.style.map.terrain&&this.style.map.terrain.getTerrainData(m);c.draw(n,o.TRIANGLES,qt.disabled,new ue({func:o.ALWAYS,mask:0},g,255,o.KEEP,o.KEEP,o.REPLACE),be.disabled,ne.disabled,ii(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++,s=this.context.gl;return new ue({func:s.NOTEQUAL,mask:255},t,255,s.KEEP,s.KEEP,s.REPLACE)}stencilModeForClipping(t){const s=this.context.gl;return new ue({func:s.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,s.KEEP,s.KEEP,s.REPLACE)}stencilConfigForOverlap(t){const s=this.context.gl,n=t.sort(((m,g)=>g.overscaledZ-m.overscaledZ)),o=n[n.length-1].overscaledZ,c=n[0].overscaledZ-o+1;if(c>1){this.currentStencilSource=void 0,this.nextStencilID+c>256&&this.clearStencil();const m={};for(let g=0;g<c;g++)m[g+o]=new ue({func:s.GEQUAL,mask:255},g+this.nextStencilID,255,s.KEEP,s.KEEP,s.REPLACE);return this.nextStencilID+=c,[m,n]}return[{[o]:ue.disabled},n]}colorModeForRenderPass(){const t=this.context.gl;return this._showOverdrawInspector?new be([t.CONSTANT_COLOR,t.ONE],new p.aM(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?be.unblended:be.alphaBlended}depthModeForSublayer(t,s,n){if(!this.opaquePassEnabledForLayer())return qt.disabled;const o=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new qt(n||this.context.gl.LEQUAL,s,[o,o])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,s){this.style=t,this.options=s,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(mt.now()),this.imageManager.beginFrame();const n=this.style._order,o=this.style.sourceCaches,c={},m={},g={};for(const y in o){const b=o[y];b.used&&b.prepare(this.context),c[y]=b.getVisibleCoordinates(),m[y]=c[y].slice().reverse(),g[y]=b.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let y=0;y<n.length;y++)if(this.style._layers[n[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 n){const b=this.style._layers[y];if(!b.hasOffscreenPass()||b.isHidden(this.transform.zoom))continue;const T=m[b.source];(b.type==="custom"||T.length)&&this.renderLayer(this,o[b.source],b,T)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:s.showOverdrawInspector?p.aM.black:p.aM.transparent,depth:1}),this.clearStencil(),this.style.sky&&(function(y,b){const T=y.context,S=T.gl,z=((N,q,F)=>({u_sky_color:N.properties.get("sky-color"),u_horizon_color:N.properties.get("horizon-color"),u_horizon:(q.height/2+q.getHorizon())*F,u_sky_horizon_blend:N.properties.get("sky-horizon-blend")*q.height/2*F}))(b,y.style.map.transform,y.pixelRatio),A=new qt(S.LEQUAL,qt.ReadWrite,[0,1]),B=ue.disabled,V=y.colorModeForRenderPass(),$=y.useProgram("sky");if(!b.mesh){const N=new p.aX;N.emplaceBack(-1,-1),N.emplaceBack(1,-1),N.emplaceBack(1,1),N.emplaceBack(-1,1);const q=new p.aY;q.emplaceBack(0,1,2),q.emplaceBack(0,2,3),b.mesh=new Za(T.createVertexBuffer(N,qr.members),T.createIndexBuffer(q),p.a0.simpleSegment(0,0,N.length,q.length))}$.draw(T,S.TRIANGLES,A,B,V,ne.disabled,z,void 0,"sky",b.mesh.vertexBuffer,b.mesh.indexBuffer,b.mesh.segments)})(this,this.style.sky),this._showOverdrawInspector=s.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=n.length-1;this.currentLayer>=0;this.currentLayer--){const y=this.style._layers[n[this.currentLayer]],b=o[y.source],T=c[y.source];this._renderTileClippingMasks(y,T),this.renderLayer(this,b,y,T)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<n.length;this.currentLayer++){const y=this.style._layers[n[this.currentLayer]],b=o[y.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(y))continue;const T=(y.type==="symbol"?g:m)[y.source];this._renderTileClippingMasks(y,c[y.source]),this.renderLayer(this,b,y,T)}if(this.options.showTileBoundaries){const y=(function(b,T){let S=null;const z=Object.values(b._layers).flatMap(($=>$.source&&!$.isHidden(T)?[b.sourceCaches[$.source]]:[])),A=z.filter(($=>$.getSource().type==="vector")),B=z.filter(($=>$.getSource().type!=="vector")),V=$=>{(!S||S.getSource().maxzoom<$.getSource().maxzoom)&&(S=$)};return A.forEach(($=>V($))),S||B.forEach(($=>V($))),S})(this.style,this.transform.zoom);y&&(function(b,T,S){for(let z=0;z<S.length;z++)el(b,T,S[z])})(this,y,y.getVisibleCoordinates())}this.options.showPadding&&(function(y){const b=y.transform.padding;ws(y,y.transform.height-(b.top||0),3,Gn),ws(y,b.bottom||0,3,Yt),tl(y,b.left||0,3,$a),tl(y,y.transform.width-(b.right||0),3,ec);const T=y.transform.centerPoint;(function(S,z,A,B){Na(S,z-1,A-10,2,20,B),Na(S,z-10,A-1,20,2,B)})(y,T.x,y.transform.height-T.y,Qo)})(this),this.context.setDefault()}maybeDrawDepthAndCoords(t){if(!this.style||!this.style.map||!this.style.map.terrain)return;const s=this.terrainFacilitator.matrix,n=this.transform.modelViewProjectionMatrix;let o=this.terrainFacilitator.dirty;o||(o=t?!p.a_(s,n):!p.a$(s,n)),o||(o=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),o&&(p.b0(s,n),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,(function(c,m){const g=c.context,y=g.gl,b=be.unblended,T=new qt(y.LEQUAL,qt.ReadWrite,[0,1]),S=m.getTerrainMesh(),z=m.sourceCache.getRenderableTiles(),A=c.useProgram("terrainDepth");g.bindFramebuffer.set(m.getFramebuffer("depth").framebuffer),g.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),g.clear({color:p.aM.transparent,depth:1});for(const B of z){const V=m.getTerrainData(B.tileID),$={u_matrix:c.transform.calculatePosMatrix(B.tileID.toUnwrapped()),u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};A.draw(g,y.TRIANGLES,T,ue.disabled,b,ne.backCCW,$,V,"terrain",S.vertexBuffer,S.indexBuffer,S.segments)}g.bindFramebuffer.set(null),g.viewport.set([0,0,c.width,c.height])})(this,this.style.map.terrain),(function(c,m){const g=c.context,y=g.gl,b=be.unblended,T=new qt(y.LEQUAL,qt.ReadWrite,[0,1]),S=m.getTerrainMesh(),z=m.getCoordsTexture(),A=m.sourceCache.getRenderableTiles(),B=c.useProgram("terrainCoords");g.bindFramebuffer.set(m.getFramebuffer("coords").framebuffer),g.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),g.clear({color:p.aM.transparent,depth:1}),m.coordsIndex=[];for(const V of A){const $=m.getTerrainData(V.tileID);g.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,z.texture);const N={u_matrix:c.transform.calculatePosMatrix(V.tileID.toUnwrapped()),u_terrain_coords_id:(255-m.coordsIndex.length)/255,u_texture:0,u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};B.draw(g,y.TRIANGLES,T,ue.disabled,b,ne.backCCW,N,$,"terrain",S.vertexBuffer,S.indexBuffer,S.segments),m.coordsIndex.push(V.tileID.key)}g.bindFramebuffer.set(null),g.viewport.set([0,0,c.width,c.height])})(this,this.style.map.terrain))}renderLayer(t,s,n,o){if(!n.isHidden(this.transform.zoom)&&(n.type==="background"||n.type==="custom"||(o||[]).length))switch(this.id=n.id,n.type){case"symbol":(function(c,m,g,y,b){if(c.renderPass!=="translucent")return;const T=ue.disabled,S=c.colorModeForRenderPass();(g._unevaluatedLayout.hasValue("text-variable-anchor")||g._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&(function(z,A,B,V,$,N,q,F,H){const K=A.transform,tt=Zr(),ot=$==="map",ut=N==="map";for(const xt of z){const Tt=V.getTile(xt),ft=Tt.getBucket(B);if(!ft||!ft.text||!ft.text.segments.get().length)continue;const pt=p.ag(ft.textSizeData,K.zoom),Et=Gt(Tt,1,A.transform.zoom),Vt=Er(xt.posMatrix,ut,ot,A.transform,Et),gt=B.layout.get("icon-text-fit")!=="none"&&ft.hasIconData();if(pt){const bt=Math.pow(2,K.zoom-Tt.tileID.overscaledZ),Lt=A.style.map.terrain?($t,Xt)=>A.style.map.terrain.getElevation(xt,$t,Xt):null,pe=tt.translatePosition(K,Tt,q,F);ys(ft,ot,ut,H,K,Vt,xt.posMatrix,bt,pt,gt,tt,pe,xt.toUnwrapped(),Lt)}}})(y,c,g,m,g.layout.get("text-rotation-alignment"),g.layout.get("text-pitch-alignment"),g.paint.get("text-translate"),g.paint.get("text-translate-anchor"),b),g.paint.get("icon-opacity").constantOr(1)!==0&&Nn(c,m,g,y,!1,g.paint.get("icon-translate"),g.paint.get("icon-translate-anchor"),g.layout.get("icon-rotation-alignment"),g.layout.get("icon-pitch-alignment"),g.layout.get("icon-keep-upright"),T,S),g.paint.get("text-opacity").constantOr(1)!==0&&Nn(c,m,g,y,!0,g.paint.get("text-translate"),g.paint.get("text-translate-anchor"),g.layout.get("text-rotation-alignment"),g.layout.get("text-pitch-alignment"),g.layout.get("text-keep-upright"),T,S),m.map.showCollisionBoxes&&(sa(c,m,g,y,!0),sa(c,m,g,y,!1))})(t,s,n,o,this.style.placement.variableOffsets);break;case"circle":(function(c,m,g,y){if(c.renderPass!=="translucent")return;const b=g.paint.get("circle-opacity"),T=g.paint.get("circle-stroke-width"),S=g.paint.get("circle-stroke-opacity"),z=!g.layout.get("circle-sort-key").isConstant();if(b.constantOr(1)===0&&(T.constantOr(1)===0||S.constantOr(1)===0))return;const A=c.context,B=A.gl,V=c.depthModeForSublayer(0,qt.ReadOnly),$=ue.disabled,N=c.colorModeForRenderPass(),q=[];for(let F=0;F<y.length;F++){const H=y[F],K=m.getTile(H),tt=K.getBucket(g);if(!tt)continue;const ot=tt.programConfigurations.get(g.id),ut=c.useProgram("circle",ot),xt=tt.layoutVertexBuffer,Tt=tt.indexBuffer,ft=c.style.map.terrain&&c.style.map.terrain.getTerrainData(H),pt={programConfiguration:ot,program:ut,layoutVertexBuffer:xt,indexBuffer:Tt,uniformValues:Ul(c,H,K,g),terrainData:ft};if(z){const Et=tt.segments.get();for(const Vt of Et)q.push({segments:new p.a0([Vt]),sortKey:Vt.sortKey,state:pt})}else q.push({segments:tt.segments,sortKey:0,state:pt})}z&&q.sort(((F,H)=>F.sortKey-H.sortKey));for(const F of q){const{programConfiguration:H,program:K,layoutVertexBuffer:tt,indexBuffer:ot,uniformValues:ut,terrainData:xt}=F.state;K.draw(A,B.TRIANGLES,V,$,N,ne.disabled,ut,xt,g.id,tt,ot,F.segments,g.paint,c.transform.zoom,H)}})(t,s,n,o);break;case"heatmap":(function(c,m,g,y){if(g.paint.get("heatmap-opacity")===0)return;const b=c.context;if(c.style.map.terrain){for(const T of y){const S=m.getTile(T);m.hasRenderableParent(T)||(c.renderPass==="offscreen"?qn(c,S,g,T):c.renderPass==="translucent"&&Yr(c,g,T))}b.viewport.set([0,0,c.width,c.height])}else c.renderPass==="offscreen"?(function(T,S,z,A){const B=T.context,V=B.gl,$=ue.disabled,N=new be([V.ONE,V.ONE],p.aM.transparent,[!0,!0,!0,!0]);(function(q,F,H){const K=q.gl;q.activeTexture.set(K.TEXTURE1),q.viewport.set([0,0,F.width/4,F.height/4]);let tt=H.heatmapFbos.get(p.aU);tt?(K.bindTexture(K.TEXTURE_2D,tt.colorAttachment.get()),q.bindFramebuffer.set(tt.framebuffer)):(tt=na(q,F.width/4,F.height/4),H.heatmapFbos.set(p.aU,tt))})(B,T,z),B.clear({color:p.aM.transparent});for(let q=0;q<A.length;q++){const F=A[q];if(S.hasRenderableParent(F))continue;const H=S.getTile(F),K=H.getBucket(z);if(!K)continue;const tt=K.programConfigurations.get(z.id),ot=T.useProgram("heatmap",tt),{zoom:ut}=T.transform;ot.draw(B,V.TRIANGLES,qt.disabled,$,N,ne.disabled,ri(F.posMatrix,H,ut,z.paint.get("heatmap-intensity")),null,z.id,K.layoutVertexBuffer,K.indexBuffer,K.segments,z.paint,T.transform.zoom,tt)}B.viewport.set([0,0,T.width,T.height])})(c,m,g,y):c.renderPass==="translucent"&&(function(T,S){const z=T.context,A=z.gl;z.setColorMode(T.colorModeForRenderPass());const B=S.heatmapFbos.get(p.aU);B&&(z.activeTexture.set(A.TEXTURE0),A.bindTexture(A.TEXTURE_2D,B.colorAttachment.get()),z.activeTexture.set(A.TEXTURE1),oa(z,S).bind(A.LINEAR,A.CLAMP_TO_EDGE),T.useProgram("heatmapTexture").draw(z,A.TRIANGLES,qt.disabled,ue.disabled,T.colorModeForRenderPass(),ne.disabled,Aa(T,S,0,1),null,S.id,T.viewportBuffer,T.quadTriangleIndexBuffer,T.viewportSegments,S.paint,T.transform.zoom))})(c,g)})(t,s,n,o);break;case"line":(function(c,m,g,y){if(c.renderPass!=="translucent")return;const b=g.paint.get("line-opacity"),T=g.paint.get("line-width");if(b.constantOr(1)===0||T.constantOr(1)===0)return;const S=c.depthModeForSublayer(0,qt.ReadOnly),z=c.colorModeForRenderPass(),A=g.paint.get("line-dasharray"),B=g.paint.get("line-pattern"),V=B.constantOr(1),$=g.paint.get("line-gradient"),N=g.getCrossfadeParameters(),q=V?"linePattern":A?"lineSDF":$?"lineGradient":"line",F=c.context,H=F.gl;let K=!0;for(const tt of y){const ot=m.getTile(tt);if(V&&!ot.patternsLoaded())continue;const ut=ot.getBucket(g);if(!ut)continue;const xt=ut.programConfigurations.get(g.id),Tt=c.context.program.get(),ft=c.useProgram(q,xt),pt=K||ft.program!==Tt,Et=c.style.map.terrain&&c.style.map.terrain.getTerrainData(tt),Vt=B.constantOr(null);if(Vt&&ot.imageAtlas){const Lt=ot.imageAtlas,pe=Lt.patternPositions[Vt.to.toString()],$t=Lt.patternPositions[Vt.from.toString()];pe&&$t&&xt.setConstantPatternPositions(pe,$t)}const gt=Et?tt:null,bt=V?_s(c,ot,g,N,gt):A?$l(c,ot,g,A,N,gt):$?Fo(c,ot,g,ut.lineClipsArray.length,gt):Ra(c,ot,g,gt);if(V)F.activeTexture.set(H.TEXTURE0),ot.imageAtlasTexture.bind(H.LINEAR,H.CLAMP_TO_EDGE),xt.updatePaintBuffers(N);else if(A&&(pt||c.lineAtlas.dirty))F.activeTexture.set(H.TEXTURE0),c.lineAtlas.bind(F);else if($){const Lt=ut.gradients[g.id];let pe=Lt.texture;if(g.gradientVersion!==Lt.version){let $t=256;if(g.stepInterpolant){const Xt=m.getSource().maxzoom,fe=tt.canonical.z===Xt?Math.ceil(1<<c.transform.maxZoom-tt.canonical.z):1;$t=p.ac(p.aV(ut.maxLineLength/p.X*1024*fe),256,F.maxTextureSize)}Lt.gradient=p.aW({expression:g.gradientExpression(),evaluationKey:"lineProgress",resolution:$t,image:Lt.gradient||void 0,clips:ut.lineClipsArray}),Lt.texture?Lt.texture.update(Lt.gradient):Lt.texture=new ae(F,Lt.gradient,H.RGBA),Lt.version=g.gradientVersion,pe=Lt.texture}F.activeTexture.set(H.TEXTURE0),pe.bind(g.stepInterpolant?H.NEAREST:H.LINEAR,H.CLAMP_TO_EDGE)}ft.draw(F,H.TRIANGLES,S,c.stencilModeForClipping(tt),z,ne.disabled,bt,Et,g.id,ut.layoutVertexBuffer,ut.indexBuffer,ut.segments,g.paint,c.transform.zoom,xt,ut.layoutVertexBuffer2),K=!1}})(t,s,n,o);break;case"fill":(function(c,m,g,y){const b=g.paint.get("fill-color"),T=g.paint.get("fill-opacity");if(T.constantOr(1)===0)return;const S=c.colorModeForRenderPass(),z=g.paint.get("fill-pattern"),A=c.opaquePassEnabledForLayer()&&!z.constantOr(1)&&b.constantOr(p.aM.transparent).a===1&&T.constantOr(0)===1?"opaque":"translucent";if(c.renderPass===A){const B=c.depthModeForSublayer(1,c.renderPass==="opaque"?qt.ReadWrite:qt.ReadOnly);la(c,m,g,y,B,S,!1)}if(c.renderPass==="translucent"&&g.paint.get("fill-antialias")){const B=c.depthModeForSublayer(g.getPaintProperty("fill-outline-color")?2:0,qt.ReadOnly);la(c,m,g,y,B,S,!0)}})(t,s,n,o);break;case"fill-extrusion":(function(c,m,g,y){const b=g.paint.get("fill-extrusion-opacity");if(b!==0&&c.renderPass==="translucent"){const T=new qt(c.context.gl.LEQUAL,qt.ReadWrite,c.depthRangeFor3D);if(b!==1||g.paint.get("fill-extrusion-pattern").constantOr(1))Ua(c,m,g,y,T,ue.disabled,be.disabled),Ua(c,m,g,y,T,c.stencilModeFor3D(),c.colorModeForRenderPass());else{const S=c.colorModeForRenderPass();Ua(c,m,g,y,T,ue.disabled,S)}}})(t,s,n,o);break;case"hillshade":(function(c,m,g,y){if(c.renderPass!=="offscreen"&&c.renderPass!=="translucent")return;const b=c.context,T=c.depthModeForSublayer(0,qt.ReadOnly),S=c.colorModeForRenderPass(),[z,A]=c.renderPass==="translucent"?c.stencilConfigForOverlap(y):[{},y];for(const B of A){const V=m.getTile(B);V.needsHillshadePrepare!==void 0&&V.needsHillshadePrepare&&c.renderPass==="offscreen"?bs(c,V,g,T,ue.disabled,S):c.renderPass==="translucent"&&vs(c,B,V,g,T,z[B.overscaledZ],S)}b.viewport.set([0,0,c.width,c.height])})(t,s,n,o);break;case"raster":(function(c,m,g,y){if(c.renderPass!=="translucent"||g.paint.get("raster-opacity")===0||!y.length)return;const b=c.context,T=b.gl,S=m.getSource(),z=c.useProgram("raster"),A=c.colorModeForRenderPass(),[B,V]=S instanceof fr?[{},y]:c.stencilConfigForOverlap(y),$=V[V.length-1].overscaledZ,N=!c.options.moving;for(const q of V){const F=c.depthModeForSublayer(q.overscaledZ-$,g.paint.get("raster-opacity")===1?qt.ReadWrite:qt.ReadOnly,T.LESS),H=m.getTile(q);H.registerFadeDuration(g.paint.get("raster-fade-duration"));const K=m.findLoadedParent(q,0),tt=m.findLoadedSibling(q),ot=Yo(H,K||tt||null,m,g,c.transform,c.style.map.terrain);let ut,xt;const Tt=g.paint.get("raster-resampling")==="nearest"?T.NEAREST:T.LINEAR;b.activeTexture.set(T.TEXTURE0),H.texture.bind(Tt,T.CLAMP_TO_EDGE,T.LINEAR_MIPMAP_NEAREST),b.activeTexture.set(T.TEXTURE1),K?(K.texture.bind(Tt,T.CLAMP_TO_EDGE,T.LINEAR_MIPMAP_NEAREST),ut=Math.pow(2,K.tileID.overscaledZ-H.tileID.overscaledZ),xt=[H.tileID.canonical.x*ut%1,H.tileID.canonical.y*ut%1]):H.texture.bind(Tt,T.CLAMP_TO_EDGE,T.LINEAR_MIPMAP_NEAREST),H.texture.useMipmap&&b.extTextureFilterAnisotropic&&c.transform.pitch>20&&T.texParameterf(T.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax);const ft=c.style.map.terrain&&c.style.map.terrain.getTerrainData(q),pt=ft?q:null,Et=pt?pt.posMatrix:c.transform.calculatePosMatrix(q.toUnwrapped(),N),Vt=Nl(Et,xt||[0,0],ut||1,ot,g);S instanceof fr?z.draw(b,T.TRIANGLES,F,ue.disabled,A,ne.disabled,Vt,ft,g.id,S.boundsBuffer,c.quadTriangleIndexBuffer,S.boundsSegments):z.draw(b,T.TRIANGLES,F,B[q.overscaledZ],A,ne.disabled,Vt,ft,g.id,c.rasterBoundsBuffer,c.quadTriangleIndexBuffer,c.rasterBoundsSegments)}})(t,s,n,o);break;case"background":(function(c,m,g,y){const b=g.paint.get("background-color"),T=g.paint.get("background-opacity");if(T===0)return;const S=c.context,z=S.gl,A=c.transform,B=A.tileSize,V=g.paint.get("background-pattern");if(c.isPatternMissing(V))return;const $=!V&&b.a===1&&T===1&&c.opaquePassEnabledForLayer()?"opaque":"translucent";if(c.renderPass!==$)return;const N=ue.disabled,q=c.depthModeForSublayer(0,$==="opaque"?qt.ReadWrite:qt.ReadOnly),F=c.colorModeForRenderPass(),H=c.useProgram(V?"backgroundPattern":"background"),K=y||A.coveringTiles({tileSize:B,terrain:c.style.map.terrain});V&&(S.activeTexture.set(z.TEXTURE0),c.imageManager.bind(c.context));const tt=g.getCrossfadeParameters();for(const ot of K){const ut=y?ot.posMatrix:c.transform.calculatePosMatrix(ot.toUnwrapped()),xt=V?An(ut,T,c,V,{tileID:ot,tileSize:B},tt):Ba(ut,T,b),Tt=c.style.map.terrain&&c.style.map.terrain.getTerrainData(ot);H.draw(S,z.TRIANGLES,q,N,F,ne.disabled,xt,Tt,g.id,c.tileExtentBuffer,c.quadTriangleIndexBuffer,c.tileExtentSegments)}})(t,0,n,o);break;case"custom":(function(c,m,g){const y=c.context,b=g.implementation;if(c.renderPass==="offscreen"){const T=b.prerender;T&&(c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),T.call(b,y.gl,c.transform.customLayerMatrix()),y.setDirty(),c.setBaseState())}else if(c.renderPass==="translucent"){c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),y.setStencilMode(ue.disabled);const T=b.renderingMode==="3d"?new qt(c.context.gl.LEQUAL,qt.ReadWrite,c.depthRangeFor3D):c.depthModeForSublayer(0,qt.ReadOnly);y.setDepthMode(T),b.render(y.gl,c.transform.customLayerMatrix(),{farZ:c.transform.farZ,nearZ:c.transform.nearZ,fov:c.transform._fov,modelViewProjectionMatrix:c.transform.modelViewProjectionMatrix,projectionMatrix:c.transform.projectionMatrix}),y.setDirty(),c.setBaseState(),y.bindFramebuffer.set(null)}})(t,0,n)}}translatePosMatrix(t,s,n,o,c){if(!n[0]&&!n[1])return t;const m=c?o==="map"?this.transform.angle:0:o==="viewport"?-this.transform.angle:0;if(m){const b=Math.sin(m),T=Math.cos(m);n=[n[0]*T-n[1]*b,n[0]*b+n[1]*T]}const g=[c?n[0]:Gt(s,n[0],this.transform.zoom),c?n[1]:Gt(s,n[1],this.transform.zoom),0],y=new Float32Array(16);return p.J(y,t,g),y}saveTileTexture(t){const s=this._tileTextures[t.size[0]];s?s.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const s=this._tileTextures[t];return s&&s.length>0?s.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const s=this.imageManager.getPattern(t.from.toString()),n=this.imageManager.getPattern(t.to.toString());return!s||!n}useProgram(t,s){this.cache=this.cache||{};const n=t+(s?s.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[n]||(this.cache[n]=new Cn(this.context,zr[t],s,Dn[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[n]}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 ae(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:s}=this.context.gl;return this.width!==t||this.height!==s}}class Ts{constructor(t,s){this.points=t,this.planes=s}static fromInvProjectionMatrix(t,s,n){const o=Math.pow(2,n),c=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((g=>{const y=1/(g=p.af([],g,t))[3]/s*o;return p.b1(g,g,[y,y,1/g[3],y])})),m=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((g=>{const y=(function(z,A){var B=A[0],V=A[1],$=A[2],N=B*B+V*V+$*$;return N>0&&(N=1/Math.sqrt(N)),z[0]=A[0]*N,z[1]=A[1]*N,z[2]=A[2]*N,z})([],(function(z,A,B){var V=A[0],$=A[1],N=A[2],q=B[0],F=B[1],H=B[2];return z[0]=$*H-N*F,z[1]=N*q-V*H,z[2]=V*F-$*q,z})([],vi([],c[g[0]],c[g[1]]),vi([],c[g[2]],c[g[1]]))),b=-((T=y)[0]*(S=c[g[1]])[0]+T[1]*S[1]+T[2]*S[2]);var T,S;return y.concat(b)}));return new Ts(c,m)}}class Ss{constructor(t,s){this.min=t,this.max=s,this.center=(function(n,o,c){return n[0]=.5*o[0],n[1]=.5*o[1],n[2]=.5*o[2],n})([],(function(n,o,c){return n[0]=o[0]+c[0],n[1]=o[1]+c[1],n[2]=o[2]+c[2],n})([],this.min,this.max))}quadrant(t){const s=[t%2==0,t<2],n=Ai(this.min),o=Ai(this.max);for(let c=0;c<s.length;c++)n[c]=s[c]?this.min[c]:this.center[c],o[c]=s[c]?this.center[c]:this.max[c];return o[2]=this.max[2],new Ss(n,o)}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 s=[[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 n=!0;for(let o=0;o<t.planes.length;o++){const c=t.planes[o];let m=0;for(let g=0;g<s.length;g++)p.b2(c,s[g])>=0&&m++;if(m===0)return 0;m!==s.length&&(n=!1)}if(n)return 2;for(let o=0;o<3;o++){let c=Number.MAX_VALUE,m=-Number.MAX_VALUE;for(let g=0;g<t.points.length;g++){const y=t.points[g][o]-this.min[o];c=Math.min(c,y),m=Math.max(m,y)}if(m<0||c>this.max[o]-this.min[o])return 0}return 1}}class Is{constructor(t=0,s=0,n=0,o=0){if(isNaN(t)||t<0||isNaN(s)||s<0||isNaN(n)||n<0||isNaN(o)||o<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=s,this.left=n,this.right=o}interpolate(t,s,n){return s.top!=null&&t.top!=null&&(this.top=p.y.number(t.top,s.top,n)),s.bottom!=null&&t.bottom!=null&&(this.bottom=p.y.number(t.bottom,s.bottom,n)),s.left!=null&&t.left!=null&&(this.left=p.y.number(t.left,s.left,n)),s.right!=null&&t.right!=null&&(this.right=p.y.number(t.right,s.right,n)),this}getCenter(t,s){const n=p.ac((this.left+t-this.right)/2,0,t),o=p.ac((this.top+s-this.bottom)/2,0,s);return new p.P(n,o)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Is(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const Xn=85.051129;class ks{constructor(t,s,n,o,c){this.tileSize=512,this._renderWorldCopies=c===void 0||!!c,this._minZoom=t||0,this._maxZoom=s||22,this._minPitch=n??0,this._maxPitch=o??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new p.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Is,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const t=new ks(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.lngRange=t.lngRange,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 s=-p.b3(t,-180,180)*Math.PI/180;this.angle!==s&&(this._unmodified=!1,this.angle=s,this._calcMatrices(),this.rotationMatrix=(function(){var n=new p.A(4);return p.A!=Float32Array&&(n[1]=0,n[2]=0),n[0]=1,n[3]=1,n})(),(function(n,o,c){var m=o[0],g=o[1],y=o[2],b=o[3],T=Math.sin(c),S=Math.cos(c);n[0]=m*S+y*T,n[1]=g*S+b*T,n[2]=m*-T+y*S,n[3]=g*-T+b*S})(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const s=p.ac(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==s&&(this._unmodified=!1,this._pitch=s,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 s=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==s&&(this._unmodified=!1,this._zoom=s,this.tileZoom=Math.max(0,Math.floor(s)),this.scale=this.zoomScale(s),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,s,n){this._unmodified=!1,this._edgeInsets.interpolate(t,s,n),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const s=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,s)}getVisibleUnwrappedCoordinates(t){const s=[new p.b4(0,t)];if(this._renderWorldCopies){const n=this.pointCoordinate(new p.P(0,0)),o=this.pointCoordinate(new p.P(this.width,0)),c=this.pointCoordinate(new p.P(this.width,this.height)),m=this.pointCoordinate(new p.P(0,this.height)),g=Math.floor(Math.min(n.x,o.x,c.x,m.x)),y=Math.floor(Math.max(n.x,o.x,c.x,m.x)),b=1;for(let T=g-b;T<=y+b;T++)T!==0&&s.push(new p.b4(T,t))}return s}coveringTiles(t){var s,n;let o=this.coveringZoomLevel(t);const c=o;if(t.minzoom!==void 0&&o<t.minzoom)return[];t.maxzoom!==void 0&&o>t.maxzoom&&(o=t.maxzoom);const m=this.pointCoordinate(this.getCameraPoint()),g=p.Z.fromLngLat(this.center),y=Math.pow(2,o),b=[y*m.x,y*m.y,0],T=[y*g.x,y*g.y,0],S=Ts.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,o);let z=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(z=o);const A=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,B=F=>({aabb:new Ss([F*y,0,0],[(F+1)*y,y,0]),zoom:0,x:0,y:0,wrap:F,fullyVisible:!1}),V=[],$=[],N=o,q=t.reparseOverscaled?c:o;if(this._renderWorldCopies)for(let F=1;F<=3;F++)V.push(B(-F)),V.push(B(F));for(V.push(B(0));V.length>0;){const F=V.pop(),H=F.x,K=F.y;let tt=F.fullyVisible;if(!tt){const ft=F.aabb.intersects(S);if(ft===0)continue;tt=ft===2}const ot=t.terrain?b:T,ut=F.aabb.distanceX(ot),xt=F.aabb.distanceY(ot),Tt=Math.max(Math.abs(ut),Math.abs(xt));if(F.zoom===N||Tt>A+(1<<N-F.zoom)-2&&F.zoom>=z){const ft=N-F.zoom,pt=b[0]-.5-(H<<ft),Et=b[1]-.5-(K<<ft);$.push({tileID:new p.S(F.zoom===N?q:F.zoom,F.wrap,F.zoom,H,K),distanceSq:Ia([T[0]-.5-H,T[1]-.5-K]),tileDistanceToCamera:Math.sqrt(pt*pt+Et*Et)})}else for(let ft=0;ft<4;ft++){const pt=(H<<1)+ft%2,Et=(K<<1)+(ft>>1),Vt=F.zoom+1;let gt=F.aabb.quadrant(ft);if(t.terrain){const bt=new p.S(Vt,F.wrap,Vt,pt,Et),Lt=t.terrain.getMinMaxElevation(bt),pe=(s=Lt.minElevation)!==null&&s!==void 0?s:this.elevation,$t=(n=Lt.maxElevation)!==null&&n!==void 0?n:this.elevation;gt=new Ss([gt.min[0],gt.min[1],pe],[gt.max[0],gt.max[1],$t])}V.push({aabb:gt,zoom:Vt,x:pt,y:Et,wrap:F.wrap,fullyVisible:tt})}}return $.sort(((F,H)=>F.distanceSq-H.distanceSq)).map((F=>F.tileID))}resize(t,s){this.width=t,this.height=s,this.pixelsToGLUnits=[2/t,-2/s],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 s=p.ac(t.lat,-85.051129,Xn);return new p.P(p.O(t.lng)*this.worldSize,p.Q(s)*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 s=this.elevation,n=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,o=this.pointLocation(this.centerPoint,t),c=t.getElevationForLngLatZoom(o,this.tileZoom);if(!(this.elevation-c))return;const m=n+s-c,g=Math.cos(this._pitch)*this.cameraToCenterDistance/m/p.b5(1,o.lat),y=this.scaleZoom(g/this.tileSize);this._elevation=c,this._center=o,this.zoom=y}setLocationAtPoint(t,s){const n=this.pointCoordinate(s),o=this.pointCoordinate(this.centerPoint),c=this.locationCoordinate(t),m=new p.Z(c.x-(n.x-o.x),c.y-(n.y-o.y));this.center=this.coordinateLocation(m),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,s){return s?this.coordinatePoint(this.locationCoordinate(t),s.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,s){return this.coordinateLocation(this.pointCoordinate(t,s))}locationCoordinate(t){return p.Z.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,s){if(s){const z=s.pointCoordinate(t);if(z!=null)return z}const n=[t.x,t.y,0,1],o=[t.x,t.y,1,1];p.af(n,n,this.pixelMatrixInverse),p.af(o,o,this.pixelMatrixInverse);const c=n[3],m=o[3],g=n[1]/c,y=o[1]/m,b=n[2]/c,T=o[2]/m,S=b===T?0:(0-b)/(T-b);return new p.Z(p.y.number(n[0]/c,o[0]/m,S)/this.worldSize,p.y.number(g,y,S)/this.worldSize)}coordinatePoint(t,s=0,n=this.pixelMatrix){const o=[t.x*this.worldSize,t.y*this.worldSize,s,1];return p.af(o,o,n),new p.P(o[0]/o[3],o[1]/o[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return new it().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 it([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,Xn])}calculateTileMatrix(t){const s=t.canonical,n=this.worldSize/this.zoomScale(s.z),o=s.x+Math.pow(2,s.z)*t.wrap,c=p.an(new Float64Array(16));return p.J(c,c,[o*n,s.y*n,0]),p.K(c,c,[n/p.X,n/p.X,1]),c}calculatePosMatrix(t,s=!1){const n=t.key,o=s?this._alignedPosMatrixCache:this._posMatrixCache;if(o[n])return o[n];const c=this.calculateTileMatrix(t);return p.L(c,s?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,c),o[n]=new Float32Array(c),o[n]}calculateFogMatrix(t){const s=t.key,n=this._fogMatrixCache;if(n[s])return n[s];const o=this.calculateTileMatrix(t);return p.L(o,this.fogMatrix,o),n[s]=new Float32Array(o),n[s]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(t,s){s=p.ac(+s,this.minZoom,this.maxZoom);const n={center:new p.N(t.lng,t.lat),zoom:s};let o=this.lngRange;if(!this._renderWorldCopies&&o===null){const F=179.9999999999;o=[-F,F]}const c=this.tileSize*this.zoomScale(n.zoom);let m=0,g=c,y=0,b=c,T=0,S=0;const{x:z,y:A}=this.size;if(this.latRange){const F=this.latRange;m=p.Q(F[1])*c,g=p.Q(F[0])*c,g-m<A&&(T=A/(g-m))}o&&(y=p.b3(p.O(o[0])*c,0,c),b=p.b3(p.O(o[1])*c,0,c),b<y&&(b+=c),b-y<z&&(S=z/(b-y)));const{x:B,y:V}=this.project.call({worldSize:c},t);let $,N;const q=Math.max(S||0,T||0);if(q){const F=new p.P(S?(b+y)/2:B,T?(g+m)/2:V);return n.center=this.unproject.call({worldSize:c},F).wrap(),n.zoom+=this.scaleZoom(q),n}if(this.latRange){const F=A/2;V-F<m&&(N=m+F),V+F>g&&(N=g-F)}if(o){const F=(y+b)/2;let H=B;this._renderWorldCopies&&(H=p.b3(B,F-c/2,F+c/2));const K=z/2;H-K<y&&($=y+K),H+K>b&&($=b-K)}if($!==void 0||N!==void 0){const F=new p.P($??B,N??V);n.center=this.unproject.call({worldSize:c},F).wrap()}return n}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:s,zoom:n}=this.getConstrained(this.center,this.zoom);this.center=s,this.zoom=n,this._unmodified=t,this._constraining=!1}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,s=this.point.x,n=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=p.b5(1,this.center.lat)*this.worldSize;let o=p.an(new Float64Array(16));p.K(o,o,[this.width/2,-this.height/2,1]),p.J(o,o,[1,-1,0]),this.labelPlaneMatrix=o,o=p.an(new Float64Array(16)),p.K(o,o,[1,-1,1]),p.J(o,o,[-1,-1,0]),p.K(o,o,[2/this.width,2/this.height,1]),this.glCoordMatrix=o;const c=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),m=Math.min(this.elevation,this.minElevationForCurrentTile),g=c-m*this._pixelPerMeter/Math.cos(this._pitch),y=m<0?g:c,b=Math.PI/2+this._pitch,T=this._fov*(.5+t.y/this.height),S=Math.sin(T)*y/Math.sin(p.ac(Math.PI-b-T,.01,Math.PI-.01)),z=this.getHorizon(),A=2*Math.atan(z/this.cameraToCenterDistance)*(.5+t.y/(2*z)),B=Math.sin(A)*y/Math.sin(p.ac(Math.PI-b-A,.01,Math.PI-.01)),V=Math.min(S,B);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*V+y),this.nearZ=this.height/50,o=new Float64Array(16),p.b6(o,this._fov,this.width/this.height,this.nearZ,this.farZ),o[8]=2*-t.x/this.width,o[9]=2*t.y/this.height,this.projectionMatrix=p.ae(o),p.K(o,o,[1,-1,1]),p.J(o,o,[0,0,-this.cameraToCenterDistance]),p.b7(o,o,this._pitch),p.ad(o,o,this.angle),p.J(o,o,[-s,-n,0]),this.mercatorMatrix=p.K([],o,[this.worldSize,this.worldSize,this.worldSize]),p.K(o,o,[1,1,this._pixelPerMeter]),this.pixelMatrix=p.L(new Float64Array(16),this.labelPlaneMatrix,o),p.J(o,o,[0,0,-this.elevation]),this.modelViewProjectionMatrix=o,this.invModelViewProjectionMatrix=p.as([],o),this.fogMatrix=new Float64Array(16),p.b6(this.fogMatrix,this._fov,this.width/this.height,c,this.farZ),this.fogMatrix[8]=2*-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.ad(this.fogMatrix,this.fogMatrix,this.angle),p.J(this.fogMatrix,this.fogMatrix,[-s,-n,0]),p.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),p.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=p.L(new Float64Array(16),this.labelPlaneMatrix,o);const $=this.width%2/2,N=this.height%2/2,q=Math.cos(this.angle),F=Math.sin(this.angle),H=s-Math.round(s)+q*$+F*N,K=n-Math.round(n)+q*N+F*$,tt=new Float64Array(o);if(p.J(tt,tt,[H>.5?H-1:H,K>.5?K-1:K,0]),this.alignedModelViewProjectionMatrix=tt,o=p.as(new Float64Array(16),this.pixelMatrix),!o)throw new Error("failed to invert matrix");this.pixelMatrixInverse=o,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const t=this.pointCoordinate(new p.P(0,0)),s=[t.x*this.worldSize,t.y*this.worldSize,0,1];return p.af(s,s,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 s=this.getCameraPoint();if(t.length===1)return[t[0],s];{let n=s.x,o=s.y,c=s.x,m=s.y;for(const g of t)n=Math.min(n,g.x),o=Math.min(o,g.y),c=Math.max(c,g.x),m=Math.max(m,g.y);return[new p.P(n,o),new p.P(c,o),new p.P(c,m),new p.P(n,m),new p.P(n,o)]}}lngLatToCameraDepth(t,s){const n=this.locationCoordinate(t),o=[n.x*this.worldSize,n.y*this.worldSize,s,1];return p.af(o,o,this.modelViewProjectionMatrix),o[2]/o[3]}}function ca(u,t){let s,n=!1,o=null,c=null;const m=()=>{o=null,n&&(u.apply(c,s),o=setTimeout(m,t),n=!1)};return(...g)=>(n=!0,c=this,s=g,o||m(),o)}class Ga{constructor(t){this._getCurrentHash=()=>{const s=window.location.hash.replace("#","");if(this._hashName){let n;return s.split("&").map((o=>o.split("="))).forEach((o=>{o[0]===this._hashName&&(n=o)})),(n&&n[1]||"").split("/")}return s.split("/")},this._onHashChange=()=>{const s=this._getCurrentHash();if(s.length>=3&&!s.some((n=>isNaN(n)))){const n=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(s[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+s[2],+s[1]],zoom:+s[0],bearing:n,pitch:+(s[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const s=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,s)},this._removeHash=()=>{const s=this._getCurrentHash();if(s.length===0)return;const n=s.join("/");let o=n;o.split("&").length>0&&(o=o.split("&")[0]),this._hashName&&(o=`${this._hashName}=${n}`);let c=window.location.hash.replace(o,"");c.startsWith("#&")?c=c.slice(0,1)+c.slice(2):c==="#"&&(c="");let m=window.location.href.replace(/(#.+)?$/,c);m=m.replace("&&","&"),window.history.replaceState(window.history.state,null,m)},this._updateHash=ca(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()),this._removeHash(),delete this._map,this}getHashString(t){const s=this._map.getCenter(),n=Math.round(100*this._map.getZoom())/100,o=Math.ceil((n*Math.LN2+Math.log(512/360/.5))/Math.LN10),c=Math.pow(10,o),m=Math.round(s.lng*c)/c,g=Math.round(s.lat*c)/c,y=this._map.getBearing(),b=this._map.getPitch();let T="";if(T+=t?`/${m}/${g}/${n}`:`${n}/${g}/${m}`,(y||b)&&(T+="/"+Math.round(10*y)/10),b&&(T+=`/${Math.round(b)}`),this._hashName){const S=this._hashName;let z=!1;const A=window.location.hash.slice(1).split("&").map((B=>{const V=B.split("=")[0];return V===S?(z=!0,`${V}=${T}`):B})).filter((B=>B));return z||A.push(`${S}=${T}`),`#${A.join("&")}`}return`#${T}`}}const Xa={linearity:.3,easing:p.b8(0,0,.3,1)},Hn=p.e({deceleration:2500,maxSpeed:1400},Xa),ic=p.e({deceleration:20,maxSpeed:1400},Xa),rl=p.e({deceleration:1e3,maxSpeed:360},Xa),Ha=p.e({deceleration:1e3,maxSpeed:90},Xa);class Wn{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:mt.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,s=mt.now();for(;t.length>0&&s-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const s={zoom:0,bearing:0,pitch:0,pan:new p.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:c}of this._inertiaBuffer)s.zoom+=c.zoomDelta||0,s.bearing+=c.bearingDelta||0,s.pitch+=c.pitchDelta||0,c.panDelta&&s.pan._add(c.panDelta),c.around&&(s.around=c.around),c.pinchAround&&(s.pinchAround=c.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(s.pan.mag()){const c=ha(s.pan.mag(),n,p.e({},Hn,t||{}));o.offset=s.pan.mult(c.amount/s.pan.mag()),o.center=this._map.transform.center,ua(o,c)}if(s.zoom){const c=ha(s.zoom,n,ic);o.zoom=this._map.transform.zoom+c.amount,ua(o,c)}if(s.bearing){const c=ha(s.bearing,n,rl);o.bearing=this._map.transform.bearing+p.ac(c.amount,-179,179),ua(o,c)}if(s.pitch){const c=ha(s.pitch,n,Ha);o.pitch=this._map.transform.pitch+c.amount,ua(o,c)}if(o.zoom||o.bearing){const c=s.pinchAround===void 0?s.around:s.pinchAround;o.around=c?this._map.unproject(c):this._map.getCenter()}return this.clear(),p.e(o,{noMoveStart:!0})}}function ua(u,t){(!u.duration||u.duration<t.duration)&&(u.duration=t.duration,u.easing=t.easing)}function ha(u,t,s){const{maxSpeed:n,linearity:o,deceleration:c}=s,m=p.ac(u*o/(t/1e3),-n,n),g=Math.abs(m)/(c*o);return{easing:s.easing,duration:1e3*g,amount:m*(g/2)}}class Oe extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,s,n,o={}){const c=at.mousePos(s.getCanvas(),n),m=s.unproject(c);super(t,p.e({point:c,lngLat:m,originalEvent:n},o)),this._defaultPrevented=!1,this.target=s}}class Qr extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,s,n){const o=t==="touchend"?n.changedTouches:n.touches,c=at.touchPos(s.getCanvasContainer(),o),m=c.map((y=>s.unproject(y))),g=c.reduce(((y,b,T,S)=>y.add(b.div(S.length))),new p.P(0,0));super(t,{points:c,point:g,lngLats:m,lngLat:s.unproject(g),originalEvent:n}),this._defaultPrevented=!1}}class sl extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,s,n){super(t,{originalEvent:n}),this._defaultPrevented=!1}}class al{constructor(t,s){this._map=t,this._clickTolerance=s.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new sl(t.type,this._map,t))}mousedown(t,s){return this._mousedownPos=s,this._firePreventable(new Oe(t.type,this._map,t))}mouseup(t){this._map.fire(new Oe(t.type,this._map,t))}click(t,s){this._mousedownPos&&this._mousedownPos.dist(s)>=this._clickTolerance||this._map.fire(new Oe(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Oe(t.type,this._map,t))}mouseover(t){this._map.fire(new Oe(t.type,this._map,t))}mouseout(t){this._map.fire(new Oe(t.type,this._map,t))}touchstart(t){return this._firePreventable(new Qr(t.type,this._map,t))}touchmove(t){this._map.fire(new Qr(t.type,this._map,t))}touchend(t){this._map.fire(new Qr(t.type,this._map,t))}touchcancel(t){this._map.fire(new Qr(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class we{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Oe(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Oe("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Oe(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Vi{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 mi{constructor(t,s){this._map=t,this._tr=new Vi(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=s.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,s){this.isEnabled()&&t.shiftKey&&t.button===0&&(at.disableDrag(),this._startPos=this._lastPos=s,this._active=!0)}mousemoveWindow(t,s){if(!this._active)return;const n=s;if(this._lastPos.equals(n)||!this._box&&n.dist(this._startPos)<this._clickTolerance)return;const o=this._startPos;this._lastPos=n,this._box||(this._box=at.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));const c=Math.min(o.x,n.x),m=Math.max(o.x,n.x),g=Math.min(o.y,n.y),y=Math.max(o.y,n.y);at.setTransform(this._box,`translate(${c}px,${g}px)`),this._box.style.width=m-c+"px",this._box.style.height=y-g+"px"}mouseupWindow(t,s){if(!this._active||t.button!==0)return;const n=this._startPos,o=s;if(this.reset(),at.suppressClick(),n.x!==o.x||n.y!==o.y)return this._map.fire(new p.k("boxzoomend",{originalEvent:t})),{cameraAnimation:c=>c.fitScreenCoordinates(n,o,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&&(at.remove(this._box),this._box=null),at.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,s){return this._map.fire(new p.k(t,{originalEvent:s}))}}function da(u,t){if(u.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${u.length}, points ${t.length}`);const s={};for(let n=0;n<u.length;n++)s[u[n].identifier]=t[n];return s}class Kn{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,s,n){(this.centroid||n.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=t.timeStamp),n.length===this.numTouches&&(this.centroid=(function(o){const c=new p.P(0,0);for(const m of o)c._add(m);return c.div(o.length)})(s),this.touches=da(n,s)))}touchmove(t,s,n){if(this.aborted||!this.centroid)return;const o=da(n,s);for(const c in this.touches){const m=o[c];(!m||m.dist(this.touches[c])>30)&&(this.aborted=!0)}}touchend(t,s,n){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),n.length===0){const o=!this.aborted&&this.centroid;if(this.reset(),o)return o}}}class Wa{constructor(t){this.singleTap=new Kn(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,s,n){this.singleTap.touchstart(t,s,n)}touchmove(t,s,n){this.singleTap.touchmove(t,s,n)}touchend(t,s,n){const o=this.singleTap.touchend(t,s,n);if(o){const c=t.timeStamp-this.lastTime<500,m=!this.lastTap||this.lastTap.dist(o)<30;if(c&&m||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class Ms{constructor(t){this._tr=new Vi(t),this._zoomIn=new Wa({numTouches:1,numTaps:2}),this._zoomOut=new Wa({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,s,n){this._zoomIn.touchstart(t,s,n),this._zoomOut.touchstart(t,s,n)}touchmove(t,s,n){this._zoomIn.touchmove(t,s,n),this._zoomOut.touchmove(t,s,n)}touchend(t,s,n){const o=this._zoomIn.touchend(t,s,n),c=this._zoomOut.touchend(t,s,n),m=this._tr;return o?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:m.zoom+1,around:m.unproject(o)},{originalEvent:t})}):c?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:m.zoom-1,around:m.unproject(c)},{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 gr{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 s=this._moveFunction(...t);if(s.bearingDelta||s.pitchDelta||s.around||s.panDelta)return this._active=!0,s}dragStart(t,s){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=s.length?s[0]:s,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,s){if(!this.isEnabled())return;const n=this._lastPoint;if(!n)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const o=s.length?s[0]:s;return!this._moved&&o.dist(n)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=o,this._move(n,o))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&at.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 Jn={0:1,2:2};class Ka{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){const s=at.mouseButton(t);this._eventButton=s}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!(function(s,n){const o=Jn[n];return s.buttons===void 0||(s.buttons&o)!==o})(t,this._eventButton)}isValidEndEvent(t){return at.mouseButton(t)===this._eventButton}}class Yn{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 Ja=u=>{u.mousedown=u.dragStart,u.mousemoveWindow=u.dragMove,u.mouseup=u.dragEnd,u.contextmenu=t=>{t.preventDefault()}},Qn=({enable:u,clickTolerance:t,bearingDegreesPerPixelMoved:s=.8})=>{const n=new Ka({checkCorrectEvent:o=>at.mouseButton(o)===0&&o.ctrlKey||at.mouseButton(o)===2});return new gr({clickTolerance:t,move:(o,c)=>({bearingDelta:(c.x-o.x)*s}),moveStateManager:n,enable:u,assignEvents:Ja})},to=({enable:u,clickTolerance:t,pitchDegreesPerPixelMoved:s=-.5})=>{const n=new Ka({checkCorrectEvent:o=>at.mouseButton(o)===0&&o.ctrlKey||at.mouseButton(o)===2});return new gr({clickTolerance:t,move:(o,c)=>({pitchDelta:(c.y-o.y)*s}),moveStateManager:n,enable:u,assignEvents:Ja})};class ts{constructor(t,s){this._clickTolerance=t.clickTolerance||1,this._map=s,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new p.P(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,s,n){return this._calculateTransform(t,s,n)}touchmove(t,s,n){if(this._active){if(!this._shouldBePrevented(n.length))return t.preventDefault(),this._calculateTransform(t,s,n);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t)}}touchend(t,s,n){this._calculateTransform(t,s,n),this._active&&this._shouldBePrevented(n.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,s,n){n.length>0&&(this._active=!0);const o=da(n,s),c=new p.P(0,0),m=new p.P(0,0);let g=0;for(const b in o){const T=o[b],S=this._touches[b];S&&(c._add(T),m._add(T.sub(S)),g++,o[b]=T)}if(this._touches=o,this._shouldBePrevented(g)||!m.mag())return;const y=m.div(g);return this._sum._add(y),this._sum.mag()<this._clickTolerance?void 0:{around:c.div(g),panDelta:y}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ya{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,s,n){this._firstTwoTouches||n.length<2||(this._firstTwoTouches=[n[0].identifier,n[1].identifier],this._start([s[0],s[1]]))}touchmove(t,s,n){if(!this._firstTwoTouches)return;t.preventDefault();const[o,c]=this._firstTwoTouches,m=pa(n,s,o),g=pa(n,s,c);if(!m||!g)return;const y=this._aroundCenter?null:m.add(g).div(2);return this._move([m,g],y,t)}touchend(t,s,n){if(!this._firstTwoTouches)return;const[o,c]=this._firstTwoTouches,m=pa(n,s,o),g=pa(n,s,c);m&&g||(this._active&&at.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 pa(u,t,s){for(let n=0;n<u.length;n++)if(u[n].identifier===s)return t[n]}function eo(u,t){return Math.log(u/t)/Math.LN2}class io extends Ya{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,s){const n=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(eo(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:eo(this._distance,n),pinchAround:s}}}function ro(u,t){return 180*u.angleWith(t)/Math.PI}class so extends Ya{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,s,n){const o=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:ro(this._vector,o),pinchAround:s}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const s=25/(Math.PI*this._minDiameter)*360,n=ro(t,this._startVector);return Math.abs(n)<s}}function Qa(u){return Math.abs(u.y)>Math.abs(u.x)}class Es extends Ya{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,s,n){super.touchstart(t,s,n),this._currentTouchCount=n.length}_start(t){this._lastPoints=t,Qa(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,s,n){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const o=t[0].sub(this._lastPoints[0]),c=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(o,c,n.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+c.y)/2*-.5}):void 0}gestureBeginsVertically(t,s,n){if(this._valid!==void 0)return this._valid;const o=t.mag()>=2,c=s.mag()>=2;if(!o&&!c)return;if(!o||!c)return this._firstMove===void 0&&(this._firstMove=n),n-this._firstMove<100&&void 0;const m=t.y>0==s.y>0;return Qa(t)&&Qa(s)&&m}}const nl={panStep:100,bearingStep:15,pitchStep:10};class Si{constructor(t){this._tr=new Vi(t);const s=nl;this._panStep=s.panStep,this._bearingStep=s.bearingStep,this._pitchStep=s.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let s=0,n=0,o=0,c=0,m=0;switch(t.keyCode){case 61:case 107:case 171:case 187:s=1;break;case 189:case 109:case 173:s=-1;break;case 37:t.shiftKey?n=-1:(t.preventDefault(),c=-1);break;case 39:t.shiftKey?n=1:(t.preventDefault(),c=1);break;case 38:t.shiftKey?o=1:(t.preventDefault(),m=-1);break;case 40:t.shiftKey?o=-1:(t.preventDefault(),m=1);break;default:return}return this._rotationDisabled&&(n=0,o=0),{cameraAnimation:g=>{const y=this._tr;g.easeTo({duration:300,easeId:"keyboardHandler",easing:ar,zoom:s?Math.round(y.zoom)+s*(t.shiftKey?2:1):y.zoom,bearing:y.bearing+n*this._bearingStep,pitch:y.pitch+o*this._pitchStep,offset:[-c*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 ar(u){return u*(2-u)}const ao=4.000244140625;class ji{constructor(t,s){this._onTimeout=n=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(n)},this._map=t,this._tr=new Vi(t),this._triggerRenderFrame=s,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)}_shouldBePrevented(t){return!!this._map.cooperativeGestures.isEnabled()&&!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t))}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",t);let s=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const n=mt.now(),o=n-(this._lastWheelEventTime||0);this._lastWheelEventTime=n,s!==0&&s%ao==0?this._type="wheel":s!==0&&Math.abs(s)<4?this._type="trackpad":o>400?(this._type=null,this._lastValue=s,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(o*s)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,s+=this._lastValue)),t.shiftKey&&s&&(s/=4),this._type&&(this._lastWheelEvent=t,this._delta-=s,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 s=at.mousePos(this._map.getCanvas(),t),n=this._tr;this._around=s.y>n.transform.height/2-n.transform.getHorizon()?p.N.convert(this._aroundCenter?n.center:n.unproject(s)):p.N.convert(n.center),this._aroundPoint=n.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 y=this._type==="wheel"&&Math.abs(this._delta)>ao?this._wheelZoomRate:this._defaultZoomRate;let b=2/(1+Math.exp(-Math.abs(this._delta*y)));this._delta<0&&b!==0&&(b=1/b);const T=typeof this._targetZoom=="number"?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(T*b))),this._type==="wheel"&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const s=typeof this._targetZoom=="number"?this._targetZoom:t.zoom,n=this._startZoom,o=this._easing;let c,m=!1;const g=mt.now()-this._lastWheelEventTime;if(this._type==="wheel"&&n&&o&&g){const y=Math.min(g/200,1),b=o(y);c=p.y.number(n,s,b),y<1?this._frameId||(this._frameId=!0):m=!0}else c=s,m=!0;return this._active=!0,m&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!m,zoomDelta:c-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let s=p.b9;if(this._prevEase){const n=this._prevEase,o=(mt.now()-n.start)/n.duration,c=n.easing(o+.01)-n.easing(o),m=.27/Math.sqrt(c*c+1e-4)*.01,g=Math.sqrt(.0729-m*m);s=p.b8(m,g,.25,1)}return this._prevEase={start:mt.now(),duration:t,easing:s},s}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class es{constructor(t,s){this._clickZoom=t,this._tapZoom=s}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 rc{constructor(t){this._tr=new Vi(t),this.reset()}reset(){this._active=!1}dblclick(t,s){return t.preventDefault(),{cameraAnimation:n=>{n.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(s)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class sc{constructor(){this._tap=new Wa({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,s,n){if(!this._swipePoint)if(this._tapTime){const o=s[0],c=t.timeStamp-this._tapTime<500,m=this._tapPoint.dist(o)<30;c&&m?n.length>0&&(this._swipePoint=o,this._swipeTouch=n[0].identifier):this.reset()}else this._tap.touchstart(t,s,n)}touchmove(t,s,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;const o=s[0],c=o.y-this._swipePoint.y;return this._swipePoint=o,t.preventDefault(),this._active=!0,{zoomDelta:c/128}}}else this._tap.touchmove(t,s,n)}touchend(t,s,n){if(this._tapTime)this._swipePoint&&n.length===0&&this.reset();else{const o=this._tap.touchend(t,s,n);o&&(this._tapTime=t.timeStamp,this._tapPoint=o)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ol{constructor(t,s,n){this._el=t,this._mousePan=s,this._touchPan=n}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 ll{constructor(t,s,n){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=s,this._mousePitch=n}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class no{constructor(t,s,n,o){this._el=t,this._touchZoom=s,this._touchRotate=n,this._tapDragZoom=o,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 zs{constructor(t,s){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=t,this._options=s,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=at.create("div","maplibregl-cooperative-gesture-screen",t);let s=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(s=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const n=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),o=document.createElement("div");o.className="maplibregl-desktop-message",o.textContent=s,this._container.appendChild(o);const c=document.createElement("div");c.className="maplibregl-mobile-message",c.textContent=n,this._container.appendChild(c),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(at.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(t){return t[this._bypassKey]}notifyGestureBlocked(t,s){this._enabled&&(this._map.fire(new p.k("cooperativegestureprevented",{gestureType:t,originalEvent:s})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const Ii=u=>u.zoom||u.drag||u.pitch||u.rotate;class It extends p.k{}function tn(u){return u.panDelta&&u.panDelta.mag()||u.zoomDelta||u.bearingDelta||u.pitchDelta}class oo{constructor(t,s){this.handleWindowEvent=o=>{this.handleEvent(o,`${o.type}Window`)},this.handleEvent=(o,c)=>{if(o.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const m=o.type==="renderFrame"?void 0:o,g={needsRenderFrame:!1},y={},b={},T=o.touches,S=T?this._getMapTouches(T):void 0,z=S?at.touchPos(this._map.getCanvas(),S):at.mousePos(this._map.getCanvas(),o);for(const{handlerName:V,handler:$,allowed:N}of this._handlers){if(!$.isEnabled())continue;let q;this._blockedByActive(b,N,V)?$.reset():$[c||o.type]&&(q=$[c||o.type](o,z,S),this.mergeHandlerResult(g,y,q,V,m),q&&q.needsRenderFrame&&this._triggerRenderFrame()),(q||$.isActive())&&(b[V]=$)}const A={};for(const V in this._previousActiveHandlers)b[V]||(A[V]=m);this._previousActiveHandlers=b,(Object.keys(A).length||tn(g))&&(this._changes.push([g,y,A]),this._triggerRenderFrame()),(Object.keys(b).length||tn(g))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:B}=g;B&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],B(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Wn(t),this._bearingSnap=s.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(s);const n=this._el;this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[window,"blur",void 0]];for(const[o,c,m]of this._listeners)at.addEventListener(o,c,o===document?this.handleWindowEvent:this.handleEvent,m)}destroy(){for(const[t,s,n]of this._listeners)at.removeEventListener(t,s,t===document?this.handleWindowEvent:this.handleEvent,n)}_addDefaultHandlers(t){const s=this._map,n=s.getCanvasContainer();this._add("mapEvent",new al(s,t));const o=s.boxZoom=new mi(s,t);this._add("boxZoom",o),t.interactive&&t.boxZoom&&o.enable();const c=s.cooperativeGestures=new zs(s,t.cooperativeGestures);this._add("cooperativeGestures",c),t.cooperativeGestures&&c.enable();const m=new Ms(s),g=new rc(s);s.doubleClickZoom=new es(g,m),this._add("tapZoom",m),this._add("clickZoom",g),t.interactive&&t.doubleClickZoom&&s.doubleClickZoom.enable();const y=new sc;this._add("tapDragZoom",y);const b=s.touchPitch=new Es(s);this._add("touchPitch",b),t.interactive&&t.touchPitch&&s.touchPitch.enable(t.touchPitch);const T=Qn(t),S=to(t);s.dragRotate=new ll(t,T,S),this._add("mouseRotate",T,["mousePitch"]),this._add("mousePitch",S,["mouseRotate"]),t.interactive&&t.dragRotate&&s.dragRotate.enable();const z=(({enable:q,clickTolerance:F})=>{const H=new Ka({checkCorrectEvent:K=>at.mouseButton(K)===0&&!K.ctrlKey});return new gr({clickTolerance:F,move:(K,tt)=>({around:tt,panDelta:tt.sub(K)}),activateOnStart:!0,moveStateManager:H,enable:q,assignEvents:Ja})})(t),A=new ts(t,s);s.dragPan=new ol(n,z,A),this._add("mousePan",z),this._add("touchPan",A,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&s.dragPan.enable(t.dragPan);const B=new so,V=new io;s.touchZoomRotate=new no(n,V,B,y),this._add("touchRotate",B,["touchPan","touchZoom"]),this._add("touchZoom",V,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&s.touchZoomRotate.enable(t.touchZoomRotate);const $=s.scrollZoom=new ji(s,(()=>this._triggerRenderFrame()));this._add("scrollZoom",$,["mousePan"]),t.interactive&&t.scrollZoom&&s.scrollZoom.enable(t.scrollZoom);const N=s.keyboard=new Si(s);this._add("keyboard",N),t.interactive&&t.keyboard&&s.keyboard.enable(),this._add("blockableMapEvent",new we(s))}_add(t,s,n){this._handlers.push({handlerName:t,handler:s,allowed:n}),this._handlersById[t]=s}stop(t){if(!this._updatingCamera){for(const{handler:s}of this._handlers)s.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!!Ii(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,s,n){for(const o in t)if(o!==n&&(!s||s.indexOf(o)<0))return!0;return!1}_getMapTouches(t){const s=[];for(const n of t)this._el.contains(n.target)&&s.push(n);return s}mergeHandlerResult(t,s,n,o,c){if(!n)return;p.e(t,n);const m={handlerName:o,originalEvent:n.originalEvent||c};n.zoomDelta!==void 0&&(s.zoom=m),n.panDelta!==void 0&&(s.drag=m),n.pitchDelta!==void 0&&(s.pitch=m),n.bearingDelta!==void 0&&(s.rotate=m)}_applyChanges(){const t={},s={},n={};for(const[o,c,m]of this._changes)o.panDelta&&(t.panDelta=(t.panDelta||new p.P(0,0))._add(o.panDelta)),o.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+o.pitchDelta),o.around!==void 0&&(t.around=o.around),o.pinchAround!==void 0&&(t.pinchAround=o.pinchAround),o.noInertia&&(t.noInertia=o.noInertia),p.e(s,c),p.e(n,m);this._updateMapTransform(t,s,n),this._changes=[]}_updateMapTransform(t,s,n){const o=this._map,c=o._getTransformForUpdate(),m=o.terrain;if(!(tn(t)||m&&this._terrainMovement))return this._fireEvents(s,n,!0);let{panDelta:g,zoomDelta:y,bearingDelta:b,pitchDelta:T,around:S,pinchAround:z}=t;z!==void 0&&(S=z),o._stop(!0),S=S||o.transform.centerPoint;const A=c.pointLocation(g?S.sub(g):S);b&&(c.bearing+=b),T&&(c.pitch+=T),y&&(c.zoom+=y),m?this._terrainMovement||!s.drag&&!s.zoom?s.drag&&this._terrainMovement?c.center=c.pointLocation(c.centerPoint.sub(g)):c.setLocationAtPoint(A,S):(this._terrainMovement=!0,this._map._elevationFreeze=!0,c.setLocationAtPoint(A,S)):c.setLocationAtPoint(A,S),o._applyUpdatedTransform(c),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(s,n,!0)}_fireEvents(t,s,n){const o=Ii(this._eventsInProgress),c=Ii(t),m={};for(const S in t){const{originalEvent:z}=t[S];this._eventsInProgress[S]||(m[`${S}start`]=z),this._eventsInProgress[S]=t[S]}!o&&c&&this._fireEvent("movestart",c.originalEvent);for(const S in m)this._fireEvent(S,m[S]);c&&this._fireEvent("move",c.originalEvent);for(const S in t){const{originalEvent:z}=t[S];this._fireEvent(S,z)}const g={};let y;for(const S in this._eventsInProgress){const{handlerName:z,originalEvent:A}=this._eventsInProgress[S];this._handlersById[z].isActive()||(delete this._eventsInProgress[S],y=s[z]||A,g[`${S}end`]=y)}for(const S in g)this._fireEvent(S,g[S]);const b=Ii(this._eventsInProgress),T=(o||c)&&!b;if(T&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const S=this._map._getTransformForUpdate();S.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(S)}if(n&&T){this._updatingCamera=!0;const S=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),z=A=>A!==0&&-this._bearingSnap<A&&A<this._bearingSnap;!S||!S.essential&&mt.prefersReducedMotion?(this._map.fire(new p.k("moveend",{originalEvent:y})),z(this._map.getBearing())&&this._map.resetNorth()):(z(S.bearing||this._map.getBearing())&&(S.bearing=0),S.freezeElevation=!0,this._map.easeTo(S,{originalEvent:y})),this._updatingCamera=!1}}_fireEvent(t,s){this._map.fire(new p.k(t,s?{originalEvent:s}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new It("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class cl extends p.E{constructor(t,s){super(),this._renderFrameCallback=()=>{const n=Math.min((mt.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(n)),n<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=s.bearingSnap,this.on("moveend",(()=>{delete this._requestedCameraState}))}getCenter(){return new p.N(this.transform.center.lng,this.transform.center.lat)}setCenter(t,s){return this.jumpTo({center:t},s)}panBy(t,s,n){return t=p.P.convert(t).mult(-1),this.panTo(this.transform.center,p.e({offset:t},s),n)}panTo(t,s,n){return this.easeTo(p.e({center:t},s),n)}getZoom(){return this.transform.zoom}setZoom(t,s){return this.jumpTo({zoom:t},s),this}zoomTo(t,s,n){return this.easeTo(p.e({zoom:t},s),n)}zoomIn(t,s){return this.zoomTo(this.getZoom()+1,t,s),this}zoomOut(t,s){return this.zoomTo(this.getZoom()-1,t,s),this}getBearing(){return this.transform.bearing}setBearing(t,s){return this.jumpTo({bearing:t},s),this}getPadding(){return this.transform.padding}setPadding(t,s){return this.jumpTo({padding:t},s),this}rotateTo(t,s,n){return this.easeTo(p.e({bearing:t},s),n)}resetNorth(t,s){return this.rotateTo(0,p.e({duration:1e3},t),s),this}resetNorthPitch(t,s){return this.easeTo(p.e({bearing:0,pitch:0,duration:1e3},t),s),this}snapToNorth(t,s){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,s):this}getPitch(){return this.transform.pitch}setPitch(t,s){return this.jumpTo({pitch:t},s),this}cameraForBounds(t,s){t=it.convert(t).adjustAntiMeridian();const n=s&&s.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),n,s)}_cameraForBoxAndBearing(t,s,n,o){const c={top:0,bottom:0,right:0,left:0};if(typeof(o=p.e({padding:c,offset:[0,0],maxZoom:this.transform.maxZoom},o)).padding=="number"){const ft=o.padding;o.padding={top:ft,bottom:ft,right:ft,left:ft}}o.padding=p.e(c,o.padding);const m=this.transform,g=m.padding,y=new it(t,s),b=m.project(y.getNorthWest()),T=m.project(y.getNorthEast()),S=m.project(y.getSouthEast()),z=m.project(y.getSouthWest()),A=p.ba(-n),B=b.rotate(A),V=T.rotate(A),$=S.rotate(A),N=z.rotate(A),q=new p.P(Math.max(B.x,V.x,N.x,$.x),Math.max(B.y,V.y,N.y,$.y)),F=new p.P(Math.min(B.x,V.x,N.x,$.x),Math.min(B.y,V.y,N.y,$.y)),H=q.sub(F),K=(m.width-(g.left+g.right+o.padding.left+o.padding.right))/H.x,tt=(m.height-(g.top+g.bottom+o.padding.top+o.padding.bottom))/H.y;if(tt<0||K<0)return void p.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const ot=Math.min(m.scaleZoom(m.scale*Math.min(K,tt)),o.maxZoom),ut=p.P.convert(o.offset),xt=new p.P((o.padding.left-o.padding.right)/2,(o.padding.top-o.padding.bottom)/2).rotate(p.ba(n)),Tt=ut.add(xt).mult(m.scale/m.zoomScale(ot));return{center:m.unproject(b.add(S).div(2).sub(Tt)),zoom:ot,bearing:n}}fitBounds(t,s,n){return this._fitInternal(this.cameraForBounds(t,s),s,n)}fitScreenCoordinates(t,s,n,o,c){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(p.P.convert(t)),this.transform.pointLocation(p.P.convert(s)),n,o),o,c)}_fitInternal(t,s,n){return t?(delete(s=p.e(t,s)).padding,s.linear?this.easeTo(s,n):this.flyTo(s,n)):this}jumpTo(t,s){this.stop();const n=this._getTransformForUpdate();let o=!1,c=!1,m=!1;return"zoom"in t&&n.zoom!==+t.zoom&&(o=!0,n.zoom=+t.zoom),t.center!==void 0&&(n.center=p.N.convert(t.center)),"bearing"in t&&n.bearing!==+t.bearing&&(c=!0,n.bearing=+t.bearing),"pitch"in t&&n.pitch!==+t.pitch&&(m=!0,n.pitch=+t.pitch),t.padding==null||n.isPaddingEqual(t.padding)||(n.padding=t.padding),this._applyUpdatedTransform(n),this.fire(new p.k("movestart",s)).fire(new p.k("move",s)),o&&this.fire(new p.k("zoomstart",s)).fire(new p.k("zoom",s)).fire(new p.k("zoomend",s)),c&&this.fire(new p.k("rotatestart",s)).fire(new p.k("rotate",s)).fire(new p.k("rotateend",s)),m&&this.fire(new p.k("pitchstart",s)).fire(new p.k("pitch",s)).fire(new p.k("pitchend",s)),this.fire(new p.k("moveend",s))}calculateCameraOptionsFromTo(t,s,n,o=0){const c=p.Z.fromLngLat(t,s),m=p.Z.fromLngLat(n,o),g=m.x-c.x,y=m.y-c.y,b=m.z-c.z,T=Math.hypot(g,y,b);if(T===0)throw new Error("Can't calculate camera options with same From and To");const S=Math.hypot(g,y),z=this.transform.scaleZoom(this.transform.cameraToCenterDistance/T/this.transform.tileSize),A=180*Math.atan2(g,-y)/Math.PI;let B=180*Math.acos(S/T)/Math.PI;return B=b<0?90-B:90+B,{center:m.toLngLat(),zoom:z,pitch:B,bearing:A}}easeTo(t,s){var n;this._stop(!1,t.easeId),((t=p.e({offset:[0,0],duration:500,easing:p.b9},t)).animate===!1||!t.essential&&mt.prefersReducedMotion)&&(t.duration=0);const o=this._getTransformForUpdate(),c=o.zoom,m=o.bearing,g=o.pitch,y=o.padding,b="bearing"in t?this._normalizeBearing(t.bearing,m):m,T="pitch"in t?+t.pitch:g,S="padding"in t?t.padding:o.padding,z=p.P.convert(t.offset);let A=o.centerPoint.add(z);const B=o.pointLocation(A),{center:V,zoom:$}=o.getConstrained(p.N.convert(t.center||B),(n=t.zoom)!==null&&n!==void 0?n:c);this._normalizeCenter(V,o);const N=o.project(B),q=o.project(V).sub(N),F=o.zoomScale($-c);let H,K;t.around&&(H=p.N.convert(t.around),K=o.locationPoint(H));const tt={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||$!==c,this._rotating=this._rotating||m!==b,this._pitching=this._pitching||T!==g,this._padding=!o.isPaddingEqual(S),this._easeId=t.easeId,this._prepareEase(s,t.noMoveStart,tt),this.terrain&&this._prepareElevation(V),this._ease((ot=>{if(this._zooming&&(o.zoom=p.y.number(c,$,ot)),this._rotating&&(o.bearing=p.y.number(m,b,ot)),this._pitching&&(o.pitch=p.y.number(g,T,ot)),this._padding&&(o.interpolatePadding(y,S,ot),A=o.centerPoint.add(z)),this.terrain&&!t.freezeElevation&&this._updateElevation(ot),H)o.setLocationAtPoint(H,K);else{const ut=o.zoomScale(o.zoom-c),xt=$>c?Math.min(2,F):Math.max(.5,F),Tt=Math.pow(xt,1-ot),ft=o.unproject(N.add(q.mult(ot*Tt)).mult(ut));o.setLocationAtPoint(o.renderWorldCopies?ft.wrap():ft,A)}this._applyUpdatedTransform(o),this._fireMoveEvents(s)}),(ot=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(s,ot)}),t),this}_prepareEase(t,s,n={}){this._moving=!0,s||n.moving||this.fire(new p.k("movestart",t)),this._zooming&&!n.zooming&&this.fire(new p.k("zoomstart",t)),this._rotating&&!n.rotating&&this.fire(new p.k("rotatestart",t)),this._pitching&&!n.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 s=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&s!==this._elevationTarget){const n=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(n-(s-(n*t+this._elevationStart))/(1-t)),this._elevationTarget=s}this.transform.elevation=p.y.number(this._elevationStart,this._elevationTarget,t)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(t){const s=t.getCameraPosition(),n=this.terrain.getElevationForLngLatZoom(s.lngLat,t.zoom);if(s.altitude<n){const o=this.calculateCameraOptionsFromTo(s.lngLat,n,t.center,t.elevation);return{pitch:o.pitch,zoom:o.zoom}}return{}}_applyUpdatedTransform(t){const s=[];if(this.terrain&&s.push((o=>this._elevateCameraIfInsideTerrain(o))),this.transformCameraUpdate&&s.push((o=>this.transformCameraUpdate(o))),!s.length)return;const n=t.clone();for(const o of s){const c=n.clone(),{center:m,zoom:g,pitch:y,bearing:b,elevation:T}=o(c);m&&(c.center=m),g!==void 0&&(c.zoom=g),y!==void 0&&(c.pitch=y),b!==void 0&&(c.bearing=b),T!==void 0&&(c.elevation=T),n.apply(c)}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,s){if(this._easeId&&s&&this._easeId===s)return;delete this._easeId;const n=this._zooming,o=this._rotating,c=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,n&&this.fire(new p.k("zoomend",t)),o&&this.fire(new p.k("rotateend",t)),c&&this.fire(new p.k("pitchend",t)),this.fire(new p.k("moveend",t))}flyTo(t,s){var n;if(!t.essential&&mt.prefersReducedMotion){const bt=p.M(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(bt,s)}this.stop(),t=p.e({offset:[0,0],speed:1.2,curve:1.42,easing:p.b9},t);const o=this._getTransformForUpdate(),c=o.zoom,m=o.bearing,g=o.pitch,y=o.padding,b="bearing"in t?this._normalizeBearing(t.bearing,m):m,T="pitch"in t?+t.pitch:g,S="padding"in t?t.padding:o.padding,z=p.P.convert(t.offset);let A=o.centerPoint.add(z);const B=o.pointLocation(A),{center:V,zoom:$}=o.getConstrained(p.N.convert(t.center||B),(n=t.zoom)!==null&&n!==void 0?n:c);this._normalizeCenter(V,o);const N=o.zoomScale($-c),q=o.project(B),F=o.project(V).sub(q);let H=t.curve;const K=Math.max(o.width,o.height),tt=K/N,ot=F.mag();if("minZoom"in t){const bt=p.ac(Math.min(t.minZoom,c,$),o.minZoom,o.maxZoom),Lt=K/o.zoomScale(bt-c);H=Math.sqrt(Lt/ot*2)}const ut=H*H;function xt(bt){const Lt=(tt*tt-K*K+(bt?-1:1)*ut*ut*ot*ot)/(2*(bt?tt:K)*ut*ot);return Math.log(Math.sqrt(Lt*Lt+1)-Lt)}function Tt(bt){return(Math.exp(bt)-Math.exp(-bt))/2}function ft(bt){return(Math.exp(bt)+Math.exp(-bt))/2}const pt=xt(!1);let Et=function(bt){return ft(pt)/ft(pt+H*bt)},Vt=function(bt){return K*((ft(pt)*(Tt(Lt=pt+H*bt)/ft(Lt))-Tt(pt))/ut)/ot;var Lt},gt=(xt(!0)-pt)/H;if(Math.abs(ot)<1e-6||!isFinite(gt)){if(Math.abs(K-tt)<1e-6)return this.easeTo(t,s);const bt=tt<K?-1:1;gt=Math.abs(Math.log(tt/K))/H,Vt=()=>0,Et=Lt=>Math.exp(bt*H*Lt)}return t.duration="duration"in t?+t.duration:1e3*gt/("screenSpeed"in t?+t.screenSpeed/H:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=m!==b,this._pitching=T!==g,this._padding=!o.isPaddingEqual(S),this._prepareEase(s,!1),this.terrain&&this._prepareElevation(V),this._ease((bt=>{const Lt=bt*gt,pe=1/Et(Lt);o.zoom=bt===1?$:c+o.scaleZoom(pe),this._rotating&&(o.bearing=p.y.number(m,b,bt)),this._pitching&&(o.pitch=p.y.number(g,T,bt)),this._padding&&(o.interpolatePadding(y,S,bt),A=o.centerPoint.add(z)),this.terrain&&!t.freezeElevation&&this._updateElevation(bt);const $t=bt===1?V:o.unproject(q.add(F.mult(Vt(Lt))).mult(pe));o.setLocationAtPoint(o.renderWorldCopies?$t.wrap():$t,A),this._applyUpdatedTransform(o),this._fireMoveEvents(s)}),(()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(s)}),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,s){var n;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const o=this._onEaseEnd;delete this._onEaseEnd,o.call(this,s)}return t||(n=this.handlers)===null||n===void 0||n.stop(!1),this}_ease(t,s,n){n.animate===!1||n.duration===0?(t(1),s()):(this._easeStart=mt.now(),this._easeOptions=n,this._onEaseFrame=t,this._onEaseEnd=s,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,s){t=p.b3(t,-180,180);const n=Math.abs(t-s);return Math.abs(t-360-s)<n&&(t-=360),Math.abs(t+360-s)<n&&(t+=360),t}_normalizeCenter(t,s){if(!s.renderWorldCopies||s.lngRange)return;const n=t.lng-s.center.lng;t.lng+=n>180?-360:n<-180?360:0}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(p.N.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}const Cs={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Ps{constructor(t=Cs){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=s=>{!s||s.sourceDataType!=="metadata"&&s.sourceDataType!=="visibility"&&s.dataType!=="style"&&s.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=at.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=at.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=at.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(){at.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,s){const n=this._map._getUIString(`AttributionControl.${s}`);t.title=n,t.setAttribute("aria-label",n)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((o=>typeof o!="string"?"":o))):typeof this.options.customAttribution=="string"&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const o=this._map.style.stylesheet;this.styleOwner=o.owner,this.styleId=o.id}const s=this._map.style.sourceCaches;for(const o in s){const c=s[o];if(c.used||c.usedForTerrain){const m=c.getSource();m.attribution&&t.indexOf(m.attribution)<0&&t.push(m.attribution)}}t=t.filter((o=>String(o).trim())),t.sort(((o,c)=>o.length-c.length)),t=t.filter(((o,c)=>{for(let m=c+1;m<t.length;m++)if(t[m].indexOf(o)>=0)return!1;return!0}));const n=t.join(" | ");n!==this._attribHTML&&(this._attribHTML=n,t.length?(this._innerContainer.innerHTML=n,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class lo{constructor(t={}){this._updateCompact=()=>{const s=this._container.children;if(s.length){const n=s[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&n.classList.add("maplibregl-compact"):n.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=at.create("div","maplibregl-ctrl");const s=at.create("a","maplibregl-ctrl-logo");return s.target="_blank",s.rel="noopener nofollow",s.href="https://maplibre.org/",s.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),s.setAttribute("rel","noopener nofollow"),this._container.appendChild(s),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){at.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Ht{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const s=++this._id;return this._queue.push({callback:t,id:s,cancelled:!1}),s}remove(t){const s=this._currentlyRunning,n=s?this._queue.concat(s):this._queue;for(const o of n)if(o.id===t)return void(o.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const s=this._currentlyRunning=this._queue;this._queue=[];for(const n of s)if(!n.cancelled&&(n.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var co=p.Y([{name:"a_pos3d",type:"Int16",components:3}]);class ac 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,s){this.sourceCache.update(t,s),this._renderableTilesKeys=[];const n={};for(const o of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:s}))n[o.key]=!0,this._renderableTilesKeys.push(o.key),this._tiles[o.key]||(o.posMatrix=new Float64Array(16),p.aP(o.posMatrix,0,p.X,0,p.X,0,1),this._tiles[o.key]=new Mr(o,this.tileSize));for(const o in this._tiles)n[o]||delete this._tiles[o]}freeRtt(t){for(const s in this._tiles){const n=this._tiles[s];(!t||n.tileID.equals(t)||n.tileID.isChildOf(t)||t.isChildOf(n.tileID))&&(n.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){const s={};for(const n of this._renderableTilesKeys){const o=this._tiles[n].tileID;if(o.canonical.equals(t.canonical)){const c=t.clone();c.posMatrix=new Float64Array(16),p.aP(c.posMatrix,0,p.X,0,p.X,0,1),s[n]=c}else if(o.canonical.isChildOf(t.canonical)){const c=t.clone();c.posMatrix=new Float64Array(16);const m=o.canonical.z-t.canonical.z,g=o.canonical.x-(o.canonical.x>>m<<m),y=o.canonical.y-(o.canonical.y>>m<<m),b=p.X>>m;p.aP(c.posMatrix,0,b,0,b,0,1),p.J(c.posMatrix,c.posMatrix,[-g*b,-y*b,0]),s[n]=c}else if(t.canonical.isChildOf(o.canonical)){const c=t.clone();c.posMatrix=new Float64Array(16);const m=t.canonical.z-o.canonical.z,g=t.canonical.x-(t.canonical.x>>m<<m),y=t.canonical.y-(t.canonical.y>>m<<m),b=p.X>>m;p.aP(c.posMatrix,0,p.X,0,p.X,0,1),p.J(c.posMatrix,c.posMatrix,[g*b,y*b,0]),p.K(c.posMatrix,c.posMatrix,[1/2**m,1/2**m,0]),s[n]=c}}return s}getSourceTile(t,s){const n=this.sourceCache._source;let o=t.overscaledZ-this.deltaZoom;if(o>n.maxzoom&&(o=n.maxzoom),o<n.minzoom)return null;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(o).key);let c=this.sourceCache.getTileByID(this._sourceTileCache[t.key]);if((!c||!c.dem)&&s)for(;o>=n.minzoom&&(!c||!c.dem);)c=this.sourceCache.getTileByID(t.scaledTo(o--).key);return c}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter((s=>s.timeAdded>=t))}}class uo{constructor(t,s,n){this.painter=t,this.sourceCache=new ac(s),this.options=n,this.exaggeration=typeof n.exaggeration=="number"?n.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,s,n,o=p.X){var c;if(!(s>=0&&s<o&&n>=0&&n<o))return 0;const m=this.getTerrainData(t),g=(c=m.tile)===null||c===void 0?void 0:c.dem;if(!g)return 0;const y=(function(B,V,$){var N=V[0],q=V[1];return B[0]=$[0]*N+$[4]*q+$[12],B[1]=$[1]*N+$[5]*q+$[13],B})([],[s/o*p.X,n/o*p.X],m.u_terrain_matrix),b=[y[0]*g.dim,y[1]*g.dim],T=Math.floor(b[0]),S=Math.floor(b[1]),z=b[0]-T,A=b[1]-S;return g.get(T,S)*(1-z)*(1-A)+g.get(T+1,S)*z*(1-A)+g.get(T,S+1)*(1-z)*A+g.get(T+1,S+1)*z*A}getElevationForLngLatZoom(t,s){if(!p.bb(s,t.wrap()))return 0;const{tileID:n,mercatorX:o,mercatorY:c}=this._getOverscaledTileIDFromLngLatZoom(t,s);return this.getElevation(n,o%p.X,c%p.X,p.X)}getElevation(t,s,n,o=p.X){return this.getDEMElevation(t,s,n,o)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){const o=this.painter.context,c=new p.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new ae(o,c,o.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new ae(o,new p.R({width:1,height:1}),o.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(o.gl.NEAREST,o.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=p.an([])}const s=this.sourceCache.getSourceTile(t,!0);if(s&&s.dem&&(!s.demTexture||s.needsTerrainPrepare)){const o=this.painter.context;s.demTexture=this.painter.getTileTexture(s.dem.stride),s.demTexture?s.demTexture.update(s.dem.getPixels(),{premultiply:!1}):s.demTexture=new ae(o,s.dem.getPixels(),o.gl.RGBA,{premultiply:!1}),s.demTexture.bind(o.gl.NEAREST,o.gl.CLAMP_TO_EDGE),s.needsTerrainPrepare=!1}const n=s&&s+s.tileID.key+t.key;if(n&&!this._demMatrixCache[n]){const o=this.sourceCache.sourceCache._source.maxzoom;let c=t.canonical.z-s.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=o?c=t.canonical.z-o:p.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const m=t.canonical.x-(t.canonical.x>>c<<c),g=t.canonical.y-(t.canonical.y>>c<<c),y=p.bc(new Float64Array(16),[1/(p.X<<c),1/(p.X<<c),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:s&&s.dem&&s.dem.dim||1,u_terrain_matrix:n?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:s&&s.dem&&s.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(s&&s.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:s}}getFramebuffer(t){const s=this.painter,n=s.width/devicePixelRatio,o=s.height/devicePixelRatio;return!this._fbo||this._fbo.width===n&&this._fbo.height===o||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new ae(s.context,{width:n,height:o,data:null},s.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(s.context.gl.NEAREST,s.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new ae(s.context,{width:n,height:o,data:null},s.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(s.context.gl.NEAREST,s.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=s.context.createFramebuffer(n,o,!0,!1),this._fbo.depthAttachment.set(s.context.createRenderbuffer(s.context.gl.DEPTH_COMPONENT16,n,o))),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 s=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let c=0,m=0;c<this._coordsTextureSize;c++)for(let g=0;g<this._coordsTextureSize;g++,m+=4)s[m+0]=255&g,s[m+1]=255&c,s[m+2]=g>>8<<4|c>>8,s[m+3]=0;const n=new p.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(s.buffer)),o=new ae(t,n,t.gl.RGBA,{premultiply:!1});return o.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=o,o}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);const s=new Uint8Array(4),n=this.painter.context,o=n.gl,c=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),m=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),g=Math.round(this.painter.height/devicePixelRatio);n.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),o.readPixels(c,g-m-1,1,1,o.RGBA,o.UNSIGNED_BYTE,s),n.bindFramebuffer.set(null);const y=s[0]+(s[2]>>4<<8),b=s[1]+((15&s[2])<<8),T=this.coordsIndex[255-s[3]],S=T&&this.sourceCache.getTileByID(T);if(!S)return null;const z=this._coordsTextureSize,A=(1<<S.tileID.canonical.z)*z;return new p.Z((S.tileID.canonical.x*z+y)/A+S.tileID.wrap,(S.tileID.canonical.y*z+b)/A,this.getElevation(S.tileID,y,b,z))}depthAtPoint(t){const s=new Uint8Array(4),n=this.painter.context,o=n.gl;return n.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),o.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,o.RGBA,o.UNSIGNED_BYTE,s),n.bindFramebuffer.set(null),(s[0]/16777216+s[1]/65536+s[2]/256+s[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;const t=this.painter.context,s=new p.bd,n=new p.aY,o=this.meshSize,c=p.X/o,m=o*o;for(let S=0;S<=o;S++)for(let z=0;z<=o;z++)s.emplaceBack(z*c,S*c,0);for(let S=0;S<m;S+=o+1)for(let z=0;z<o;z++)n.emplaceBack(z+S,o+z+S+1,o+z+S+2),n.emplaceBack(z+S,o+z+S+2,z+S+1);const g=s.length,y=g+2*(o+1);for(const S of[0,1])for(let z=0;z<=o;z++)for(const A of[0,1])s.emplaceBack(z*c,S*p.X,A);for(let S=0;S<2*o;S+=2)n.emplaceBack(y+S,y+S+1,y+S+3),n.emplaceBack(y+S,y+S+3,y+S+2),n.emplaceBack(g+S,g+S+3,g+S+1),n.emplaceBack(g+S,g+S+2,g+S+3);const b=s.length,T=b+2*(o+1);for(const S of[0,1])for(let z=0;z<=o;z++)for(const A of[0,1])s.emplaceBack(S*p.X,z*c,A);for(let S=0;S<2*o;S+=2)n.emplaceBack(b+S,b+S+1,b+S+3),n.emplaceBack(b+S,b+S+3,b+S+2),n.emplaceBack(T+S,T+S+3,T+S+1),n.emplaceBack(T+S,T+S+2,T+S+3);return this._mesh=new Za(t.createVertexBuffer(s,co.members),t.createIndexBuffer(n),p.a0.simpleSegment(0,0,s.length,n.length)),this._mesh}getMeshFrameDelta(t){return 2*Math.PI*p.be/Math.pow(2,t)/5}getMinTileElevationForLngLatZoom(t,s){var n;const{tileID:o}=this._getOverscaledTileIDFromLngLatZoom(t,s);return(n=this.getMinMaxElevation(o).minElevation)!==null&&n!==void 0?n:0}getMinMaxElevation(t){const s=this.getTerrainData(t).tile,n={minElevation:null,maxElevation:null};return s&&s.dem&&(n.minElevation=s.dem.min*this.exaggeration,n.maxElevation=s.dem.max*this.exaggeration),n}_getOverscaledTileIDFromLngLatZoom(t,s){const n=p.Z.fromLngLat(t.wrap()),o=(1<<s)*p.X,c=n.x*o,m=n.y*o,g=Math.floor(c/p.X),y=Math.floor(m/p.X);return{tileID:new p.S(s,0,s,g,y),mercatorX:c,mercatorY:m}}}class nc{constructor(t,s,n){this._context=t,this._size=s,this._tileSize=n,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const s=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),n=new ae(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return n.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),s.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),s.colorAttachment.set(n.texture),{id:t,fbo:s,texture:n,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((s=>t.id!==s)),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const s of this._recentlyUsed)if(!this._objects[s].inUse)return this._objects[s];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 As={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class ul{constructor(t,s){this.painter=t,this.terrain=s,this.pool=new nc(t.context,30,s.sourceCache.tileSize*s.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,s){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter((n=>!t._layers[n].isHidden(s))),this._coordsDescendingInv={};for(const n in t.sourceCaches){this._coordsDescendingInv[n]={};const o=t.sourceCaches[n].getVisibleCoordinates();for(const c of o){const m=this.terrain.sourceCache.getTerrainCoords(c);for(const g in m)this._coordsDescendingInv[n][g]||(this._coordsDescendingInv[n][g]=[]),this._coordsDescendingInv[n][g].push(m[g])}}this._coordsDescendingInvStr={};for(const n of t._order){const o=t._layers[n],c=o.source;if(As[o.type]&&!this._coordsDescendingInvStr[c]){this._coordsDescendingInvStr[c]={};for(const m in this._coordsDescendingInv[c])this._coordsDescendingInvStr[c][m]=this._coordsDescendingInv[c][m].map((g=>g.key)).sort().join()}}for(const n of this._renderableTiles)for(const o in this._coordsDescendingInvStr){const c=this._coordsDescendingInvStr[o][n.tileID.key];c&&c!==n.rttCoords[o]&&(n.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;const s=t.type,n=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(As[s]&&(this._prevType&&As[this._prevType]||this._stacks.push([]),this._prevType=s,this._stacks[this._stacks.length-1].push(t.id),!o))return!0;if(As[this._prevType]||As[s]&&o){this._prevType=s;const c=this._stacks.length-1,m=this._stacks[c]||[];for(const g of this._renderableTiles){if(this.pool.isFull()&&(il(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(g),g.rtt[c]){const b=this.pool.getObjectForId(g.rtt[c].id);if(b.stamp===g.rtt[c].stamp){this.pool.useObject(b);continue}}const y=this.pool.getOrCreateFreeObject();this.pool.useObject(y),this.pool.stampObject(y),g.rtt[c]={id:y.id,stamp:y.stamp},n.context.bindFramebuffer.set(y.fbo.framebuffer),n.context.clear({color:p.aM.transparent,stencil:0}),n.currentStencilSource=void 0;for(let b=0;b<m.length;b++){const T=n.style._layers[m[b]],S=T.source?this._coordsDescendingInv[T.source][g.tileID.key]:[g.tileID];n.context.viewport.set([0,0,y.fbo.width,y.fbo.height]),n._renderTileClippingMasks(T,S),n.renderLayer(n,n.style.sourceCaches[T.source],T,S),T.source&&(g.rttCoords[T.source]=this._coordsDescendingInvStr[T.source][g.tileID.key])}}return il(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),As[s]}return!1}}const ho={"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"},hl=Pi,oc={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Cs,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},po=u=>{u.touchstart=u.dragStart,u.touchmoveWindow=u.dragMove,u.touchend=u.dragEnd},lc={showCompass:!0,showZoom:!0,visualizePitch:!1};class cc{constructor(t,s,n=!1){this.mousedown=m=>{this.startMouse(p.e({},m,{ctrlKey:!0,preventDefault:()=>m.preventDefault()}),at.mousePos(this.element,m)),at.addEventListener(window,"mousemove",this.mousemove),at.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=m=>{this.moveMouse(m,at.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=at.touchPos(this.element,m.targetTouches)[0],this.startTouch(m,this._startPos),at.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),at.addEventListener(window,"touchend",this.touchend))},this.touchmove=m=>{m.targetTouches.length!==1?this.reset():(this._lastPos=at.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 o=t.dragRotate._mouseRotate.getClickTolerance(),c=t.dragRotate._mousePitch.getClickTolerance();this.element=s,this.mouseRotate=Qn({clickTolerance:o,enable:!0}),this.touchRotate=(({enable:m,clickTolerance:g,bearingDegreesPerPixelMoved:y=.8})=>{const b=new Yn;return new gr({clickTolerance:g,move:(T,S)=>({bearingDelta:(S.x-T.x)*y}),moveStateManager:b,enable:m,assignEvents:po})})({clickTolerance:o,enable:!0}),this.map=t,n&&(this.mousePitch=to({clickTolerance:c,enable:!0}),this.touchPitch=(({enable:m,clickTolerance:g,pitchDegreesPerPixelMoved:y=-.5})=>{const b=new Yn;return new gr({clickTolerance:g,move:(T,S)=>({pitchDelta:(S.y-T.y)*y}),moveStateManager:b,enable:m,assignEvents:po})})({clickTolerance:c,enable:!0})),at.addEventListener(s,"mousedown",this.mousedown),at.addEventListener(s,"touchstart",this.touchstart,{passive:!1}),at.addEventListener(s,"touchcancel",this.reset)}startMouse(t,s){this.mouseRotate.dragStart(t,s),this.mousePitch&&this.mousePitch.dragStart(t,s),at.disableDrag()}startTouch(t,s){this.touchRotate.dragStart(t,s),this.touchPitch&&this.touchPitch.dragStart(t,s),at.disableDrag()}moveMouse(t,s){const n=this.map,{bearingDelta:o}=this.mouseRotate.dragMove(t,s)||{};if(o&&n.setBearing(n.getBearing()+o),this.mousePitch){const{pitchDelta:c}=this.mousePitch.dragMove(t,s)||{};c&&n.setPitch(n.getPitch()+c)}}moveTouch(t,s){const n=this.map,{bearingDelta:o}=this.touchRotate.dragMove(t,s)||{};if(o&&n.setBearing(n.getBearing()+o),this.touchPitch){const{pitchDelta:c}=this.touchPitch.dragMove(t,s)||{};c&&n.setPitch(n.getPitch()+c)}}off(){const t=this.element;at.removeEventListener(t,"mousedown",this.mousedown),at.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),at.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),at.removeEventListener(window,"touchend",this.touchend),at.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){at.enableDrag(),at.removeEventListener(window,"mousemove",this.mousemove),at.removeEventListener(window,"mouseup",this.mouseup),at.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),at.removeEventListener(window,"touchend",this.touchend)}}let _i;function de(u,t,s){const n=new p.N(u.lng,u.lat);if(u=new p.N(u.lng,u.lat),t){const o=new p.N(u.lng-360,u.lat),c=new p.N(u.lng+360,u.lat),m=s.locationPoint(u).distSqr(t);s.locationPoint(o).distSqr(t)<m?u=o:s.locationPoint(c).distSqr(t)<m&&(u=c)}for(;Math.abs(u.lng-s.center.lng)>180;){const o=s.locationPoint(u);if(o.x>=0&&o.y>=0&&o.x<=s.width&&o.y<=s.height)break;u.lng>s.center.lng?u.lng-=360:u.lng+=360}return u.lng!==n.lng&&s.locationPoint(u).y>s.height/2-s.getHorizon()?u:n}const Ds={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 en(u,t,s){const n=u.classList;for(const o in Ds)n.remove(`maplibregl-${s}-anchor-${o}`);n.add(`maplibregl-${s}-anchor-${t}`)}class rn extends p.E{constructor(t){if(super(),this._onKeyPress=s=>{const n=s.code,o=s.charCode||s.keyCode;n!=="Space"&&n!=="Enter"&&o!==32&&o!==13||this.togglePopup()},this._onMapClick=s=>{const n=s.originalEvent.target,o=this._element;this._popup&&(n===o||o.contains(n))&&this.togglePopup()},this._update=s=>{var n;if(!this._map)return;const o=this._map.loaded()&&!this._map.isMoving();((s==null?void 0:s.type)==="terrain"||(s==null?void 0:s.type)==="render"&&!o)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?de(this._lngLat,this._flatPos,this._map.transform):(n=this._lngLat)===null||n===void 0?void 0:n.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let c="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?c=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(c=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let m="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?m="rotateX(0deg)":this._pitchAlignment==="map"&&(m=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||s&&s.type!=="moveend"||(this._pos=this._pos.round()),at.setTransform(this._element,`${Ds[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${m} ${c}`),mt.frameAsync(new AbortController).then((()=>{this._updateOpacity(s&&s.type==="moveend")})).catch((()=>{}))},this._onMove=s=>{if(!this._isDragging){const n=this._clickTolerance||this._map._clickTolerance;this._isDragging=s.point.dist(this._pointerdownPos)>=n}this._isDragging&&(this._pos=s.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=s=>{this._element.contains(s.originalEvent.target)&&(s.preventDefault(),this._positionDelta=s.point.sub(this._pos).add(this._offset),this._pointerdownPos=s.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._subpixelPositioning=t&&t.subpixelPositioning||!1,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=at.create("div");const s=at.createNS("http://www.w3.org/2000/svg","svg"),n=41,o=27;s.setAttributeNS(null,"display","block"),s.setAttributeNS(null,"height",`${n}px`),s.setAttributeNS(null,"width",`${o}px`),s.setAttributeNS(null,"viewBox",`0 0 ${o} ${n}`);const c=at.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"stroke","none"),c.setAttributeNS(null,"stroke-width","1"),c.setAttributeNS(null,"fill","none"),c.setAttributeNS(null,"fill-rule","evenodd");const m=at.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"fill-rule","nonzero");const g=at.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 N of y){const q=at.createNS("http://www.w3.org/2000/svg","ellipse");q.setAttributeNS(null,"opacity","0.04"),q.setAttributeNS(null,"cx","10.5"),q.setAttributeNS(null,"cy","5.80029008"),q.setAttributeNS(null,"rx",N.rx),q.setAttributeNS(null,"ry",N.ry),g.appendChild(q)}const b=at.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill",this._color);const T=at.createNS("http://www.w3.org/2000/svg","path");T.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),b.appendChild(T);const S=at.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"opacity","0.25"),S.setAttributeNS(null,"fill","#000000");const z=at.createNS("http://www.w3.org/2000/svg","path");z.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),S.appendChild(z);const A=at.createNS("http://www.w3.org/2000/svg","g");A.setAttributeNS(null,"transform","translate(6.0, 7.0)"),A.setAttributeNS(null,"fill","#FFFFFF");const B=at.createNS("http://www.w3.org/2000/svg","g");B.setAttributeNS(null,"transform","translate(8.0, 8.0)");const V=at.createNS("http://www.w3.org/2000/svg","circle");V.setAttributeNS(null,"fill","#000000"),V.setAttributeNS(null,"opacity","0.25"),V.setAttributeNS(null,"cx","5.5"),V.setAttributeNS(null,"cy","5.5"),V.setAttributeNS(null,"r","5.4999962");const $=at.createNS("http://www.w3.org/2000/svg","circle");$.setAttributeNS(null,"fill","#FFFFFF"),$.setAttributeNS(null,"cx","5.5"),$.setAttributeNS(null,"cy","5.5"),$.setAttributeNS(null,"r","5.4999962"),B.appendChild(V),B.appendChild($),m.appendChild(g),m.appendChild(b),m.appendChild(S),m.appendChild(A),m.appendChild(B),s.appendChild(m),s.setAttributeNS(null,"height",n*this._scale+"px"),s.setAttributeNS(null,"width",o*this._scale+"px"),this._element.appendChild(s),this._offset=p.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(s=>{s.preventDefault()})),this._element.addEventListener("mousedown",(s=>{s.preventDefault()})),en(this._element,this._anchor,"marker"),t&&t.className)for(const s of t.className.split(" "))this._element.classList.add(s);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),at.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 s=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":[s,-1*(38.1-13.5+s)],"bottom-right":[-s,-1*(38.1-13.5+s)],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}setSubpixelPositioning(t){return this._subpixelPositioning=t,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 s,n;if(!(!((s=this._map)===null||s===void 0)&&s.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 o=this._map,c=o.terrain.depthAtPoint(this._pos),m=o.terrain.getElevationForLngLatZoom(this._lngLat,o.transform.tileZoom);if(o.transform.lngLatToCameraDepth(this._lngLat,m)-c<.006)return void(this._element.style.opacity=this._opacity);const g=-this._offset.y/o.transform._pixelPerMeter,y=Math.sin(o.getPitch()*Math.PI/180)*g,b=o.terrain.depthAtPoint(new p.P(this._pos.x,this._pos.y-this._offset.y)),T=o.transform.lngLatToCameraDepth(this._lngLat,m+y)-b>.006;!((n=this._popup)===null||n===void 0)&&n.isOpen()&&T&&this._popup.remove(),this._element.style.opacity=T?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,s){return t===void 0&&s===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),t!==void 0&&(this._opacity=t),s!==void 0&&(this._opacityWhenCovered=s),this._map&&this._updateOpacity(!0),this}}const dl={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let fa=0,ma=!1;const nr={maxWidth:100,unit:"metric"};function _a(u,t,s){const n=s&&s.maxWidth||100,o=u._container.clientHeight/2,c=u.unproject([0,o]),m=u.unproject([n,o]),g=c.distanceTo(m);if(s&&s.unit==="imperial"){const y=3.2808*g;y>5280?Mt(t,n,y/5280,u._getUIString("ScaleControl.Miles")):Mt(t,n,y,u._getUIString("ScaleControl.Feet"))}else s&&s.unit==="nautical"?Mt(t,n,g/1852,u._getUIString("ScaleControl.NauticalMiles")):g>=1e3?Mt(t,n,g/1e3,u._getUIString("ScaleControl.Kilometers")):Mt(t,n,g,u._getUIString("ScaleControl.Meters"))}function Mt(u,t,s,n){const o=(function(c){const m=Math.pow(10,`${Math.floor(c)}`.length-1);let g=c/m;return g=g>=10?10:g>=5?5:g>=3?3:g>=2?2:g>=1?1:(function(y){const b=Math.pow(10,Math.ceil(-Math.log(y)/Math.LN10));return Math.round(y*b)/b})(g),m*g})(s);u.style.width=t*(o/s)+"px",u.innerHTML=`${o}&nbsp;${n}`}const Bt={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},sn=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function an(u){if(u){if(typeof u=="number"){const t=Math.round(Math.abs(u)/Math.SQRT2);return{center:new p.P(0,0),top:new p.P(0,u),"top-left":new p.P(t,t),"top-right":new p.P(-t,t),bottom:new p.P(0,-u),"bottom-left":new p.P(t,-t),"bottom-right":new p.P(-t,-t),left:new p.P(u,0),right:new p.P(-u,0)}}if(u instanceof p.P||Array.isArray(u)){const t=p.P.convert(u);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(u.center||[0,0]),top:p.P.convert(u.top||[0,0]),"top-left":p.P.convert(u["top-left"]||[0,0]),"top-right":p.P.convert(u["top-right"]||[0,0]),bottom:p.P.convert(u.bottom||[0,0]),"bottom-left":p.P.convert(u["bottom-left"]||[0,0]),"bottom-right":p.P.convert(u["bottom-right"]||[0,0]),left:p.P.convert(u.left||[0,0]),right:p.P.convert(u.right||[0,0])}}return an(new p.P(0,0))}const fo=Pi;R.AJAXError=p.bh,R.Evented=p.E,R.LngLat=p.N,R.MercatorCoordinate=p.Z,R.Point=p.P,R.addProtocol=p.bi,R.config=p.a,R.removeProtocol=p.bj,R.AttributionControl=Ps,R.BoxZoomHandler=mi,R.CanvasSource=bi,R.CooperativeGesturesHandler=zs,R.DoubleClickZoomHandler=es,R.DragPanHandler=ol,R.DragRotateHandler=ll,R.EdgeInsets=Is,R.FullscreenControl=class extends p.E{constructor(u={}){super(),this._onFullscreenChange=()=>{var t;let s=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((t=s==null?void 0:s.shadowRoot)===null||t===void 0)&&t.fullscreenElement;)s=s.shadowRoot.fullscreenElement;s===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,u&&u.container&&(u.container instanceof HTMLElement?this._container=u.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(u){return this._map=u,this._container||(this._container=this._map.getContainer()),this._controlContainer=at.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){at.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const u=this._fullscreenButton=at.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);at.create("span","maplibregl-ctrl-icon",u).setAttribute("aria-hidden","true"),u.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const u=this._getTitle();this._fullscreenButton.setAttribute("aria-label",u),this._fullscreenButton.title=u}_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()}},R.GeoJSONSource=Ks,R.GeolocateControl=class extends p.E{constructor(u){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 s=new p.N(t.coords.longitude,t.coords.latitude),n=t.coords.accuracy,o=this._map.getBearing(),c=p.e({bearing:o},this.options.fitBoundsOptions),m=it.fromLngLat(s,n);this._map.fitBounds(m,c,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const s=new p.N(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(s).addTo(this._map),this._userLocationDotMarker.setLngLat(s).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 s=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=s,this._geolocateButton.setAttribute("aria-label",s),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(t.code===3&&ma)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=()=>{this._map&&(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=at.create("button","maplibregl-ctrl-geolocate",this._container),at.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(t===!1){p.w("Geolocation support is not available so the GeolocateControl will be disabled.");const s=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=s,this._geolocateButton.setAttribute("aria-label",s)}else{const s=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=s,this._geolocateButton.setAttribute("aria-label",s)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=at.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new rn({element:this._dotElement}),this._circleElement=at.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new rn({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",(s=>{s.geolocateSource||this._watchState!=="ACTIVE_LOCK"||s.originalEvent&&s.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({},dl,u)}onAdd(u){return this._map=u,this._container=at.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),(function(){return p._(this,arguments,void 0,(function*(t=!1){if(_i!==void 0&&!t)return _i;if(window.navigator.permissions===void 0)return _i=!!window.navigator.geolocation,_i;try{_i=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{_i=!!window.navigator.geolocation}return _i}))})().then((t=>this._finishSetupUI(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(),at.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,fa=0,ma=!1}_isOutOfMapMaxBounds(u){const t=this._map.getMaxBounds(),s=u.coords;return t&&(s.longitude<t.getWest()||s.longitude>t.getEast()||s.latitude<t.getSouth()||s.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 u=this._map.getBounds(),t=u.getSouthEast(),s=u.getNorthEast(),n=t.distanceTo(s),o=Math.ceil(this._accuracy/(n/this._map._container.clientHeight)*2);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`}trigger(){if(!this._setup)return p.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new p.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":fa--,ma=!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 u;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),fa++,fa>1?(u={maximumAge:6e5,timeout:0},ma=!0):(u=this.options.positionOptions,ma=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,u)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},R.Hash=Ga,R.ImageSource=fr,R.KeyboardHandler=Si,R.LngLatBounds=it,R.LogoControl=lo,R.Map=class extends cl{constructor(u){p.bf.mark(p.bg.create);const t=Object.assign(Object.assign({},oc),u);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 ks(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),{bearingSnap:t.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Ht,this._controls=[],this._mapId=p.a4(),this._contextLost=s=>{s.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new p.k("webglcontextlost",{originalEvent:s}))},this._contextRestored=s=>{this._setupPainter(),this.resize(),this._update(),this.fire(new p.k("webglcontextrestored",{originalEvent:s}))},this._onMapScroll=s=>{if(s.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({},ho),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=ui.addThrottleControl((()=>this.isMoving())),this._requestManager=new Sn(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 s=!1;const n=ca((o=>{this._trackResize&&!this._removed&&(this.resize(o),this.redraw())}),50);this._resizeObserver=new ResizeObserver((o=>{s?n(o):s=!0})),this._resizeObserver.observe(this._container)}this.handlers=new oo(this,t),this._hash=t.hash&&new Ga(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 Ps(typeof t.attributionControl=="boolean"?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new lo,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(s=>{this._update(s.dataType==="style"),this.fire(new p.k(`${s.dataType}data`,s))})),this.on("dataloading",(s=>{this.fire(new p.k(`${s.dataType}dataloading`,s))})),this.on("dataabort",(s=>{this.fire(new p.k("sourcedataabort",s))}))}_getMapId(){return this._mapId}addControl(u,t){if(t===void 0&&(t=u.getDefaultPosition?u.getDefaultPosition():"top-right"),!u||!u.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 s=u.onAdd(this);this._controls.push(u);const n=this._controlPositions[t];return t.indexOf("bottom")!==-1?n.insertBefore(s,n.firstChild):n.appendChild(s),this}removeControl(u){if(!u||!u.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(u);return t>-1&&this._controls.splice(t,1),u.onRemove(this),this}hasControl(u){return this._controls.indexOf(u)>-1}calculateCameraOptionsFromTo(u,t,s,n){return n==null&&this.terrain&&(n=this.terrain.getElevationForLngLatZoom(s,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(u,t,s,n)}resize(u){var t;const s=this._containerDimensions(),n=s[0],o=s[1],c=this._getClampedPixelRatio(n,o);if(this._resizeCanvas(n,o,c),this.painter.resize(n,o,c),this.painter.overLimit()){const g=this.painter.context.gl;this._maxCanvasSize=[g.drawingBufferWidth,g.drawingBufferHeight];const y=this._getClampedPixelRatio(n,o);this._resizeCanvas(n,o,y),this.painter.resize(n,o,y)}this.transform.resize(n,o),(t=this._requestedCameraState)===null||t===void 0||t.resize(n,o);const m=!this._moving;return m&&(this.stop(),this.fire(new p.k("movestart",u)).fire(new p.k("move",u))),this.fire(new p.k("resize",u)),m&&this.fire(new p.k("moveend",u)),this}_getClampedPixelRatio(u,t){const{0:s,1:n}=this._maxCanvasSize,o=this.getPixelRatio(),c=u*o,m=t*o;return Math.min(c>s?s/c:1,m>n?n/m:1)*o}getPixelRatio(){var u;return(u=this._overridePixelRatio)!==null&&u!==void 0?u:devicePixelRatio}setPixelRatio(u){this._overridePixelRatio=u,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(u){return this.transform.setMaxBounds(it.convert(u)),this._update()}setMinZoom(u){if((u=u??-2)>=-2&&u<=this.transform.maxZoom)return this.transform.minZoom=u,this._update(),this.getZoom()<u&&this.setZoom(u),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(u){if((u=u??22)>=this.transform.minZoom)return this.transform.maxZoom=u,this._update(),this.getZoom()>u&&this.setZoom(u),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(u){if((u=u??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(u>=0&&u<=this.transform.maxPitch)return this.transform.minPitch=u,this._update(),this.getPitch()<u&&this.setPitch(u),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(u){if((u=u??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(u>=this.transform.minPitch)return this.transform.maxPitch=u,this._update(),this.getPitch()>u&&this.setPitch(u),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(u){return this.transform.renderWorldCopies=u,this._update()}project(u){return this.transform.locationPoint(p.N.convert(u),this.style&&this.terrain)}unproject(u){return this.transform.pointLocation(p.P.convert(u),this.terrain)}isMoving(){var u;return this._moving||((u=this.handlers)===null||u===void 0?void 0:u.isMoving())}isZooming(){var u;return this._zooming||((u=this.handlers)===null||u===void 0?void 0:u.isZooming())}isRotating(){var u;return this._rotating||((u=this.handlers)===null||u===void 0?void 0:u.isRotating())}_createDelegatedListener(u,t,s){if(u==="mouseenter"||u==="mouseover"){let n=!1;return{layers:t,listener:s,delegates:{mousemove:o=>{const c=t.filter((g=>this.getLayer(g))),m=c.length!==0?this.queryRenderedFeatures(o.point,{layers:c}):[];m.length?n||(n=!0,s.call(this,new Oe(u,this,o.originalEvent,{features:m}))):n=!1},mouseout:()=>{n=!1}}}}if(u==="mouseleave"||u==="mouseout"){let n=!1;return{layers:t,listener:s,delegates:{mousemove:o=>{const c=t.filter((m=>this.getLayer(m)));(c.length!==0?this.queryRenderedFeatures(o.point,{layers:c}):[]).length?n=!0:n&&(n=!1,s.call(this,new Oe(u,this,o.originalEvent)))},mouseout:o=>{n&&(n=!1,s.call(this,new Oe(u,this,o.originalEvent)))}}}}{const n=o=>{const c=t.filter((g=>this.getLayer(g))),m=c.length!==0?this.queryRenderedFeatures(o.point,{layers:c}):[];m.length&&(o.features=m,s.call(this,o),delete o.features)};return{layers:t,listener:s,delegates:{[u]:n}}}}_saveDelegatedListener(u,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[u]=this._delegatedListeners[u]||[],this._delegatedListeners[u].push(t)}_removeDelegatedListener(u,t,s){if(!this._delegatedListeners||!this._delegatedListeners[u])return;const n=this._delegatedListeners[u];for(let o=0;o<n.length;o++){const c=n[o];if(c.listener===s&&c.layers.length===t.length&&c.layers.every((m=>t.includes(m)))){for(const m in c.delegates)this.off(m,c.delegates[m]);return void n.splice(o,1)}}}on(u,t,s){if(s===void 0)return super.on(u,t);const n=this._createDelegatedListener(u,typeof t=="string"?[t]:t,s);this._saveDelegatedListener(u,n);for(const o in n.delegates)this.on(o,n.delegates[o]);return this}once(u,t,s){if(s===void 0)return super.once(u,t);const n=typeof t=="string"?[t]:t,o=this._createDelegatedListener(u,n,s);for(const c in o.delegates){const m=o.delegates[c];o.delegates[c]=(...g)=>{this._removeDelegatedListener(u,n,s),m(...g)}}this._saveDelegatedListener(u,o);for(const c in o.delegates)this.once(c,o.delegates[c]);return this}off(u,t,s){return s===void 0?super.off(u,t):(this._removeDelegatedListener(u,typeof t=="string"?[t]:t,s),this)}queryRenderedFeatures(u,t){if(!this.style)return[];let s;const n=u instanceof p.P||Array.isArray(u),o=n?u:[[0,0],[this.transform.width,this.transform.height]];if(t=t||(n?{}:u)||{},o instanceof p.P||typeof o[0]=="number")s=[p.P.convert(o)];else{const c=p.P.convert(o[0]),m=p.P.convert(o[1]);s=[c,new p.P(m.x,c.y),m,new p.P(c.x,m.y),c]}return this.style.queryRenderedFeatures(s,t,this.transform)}querySourceFeatures(u,t){return this.style.querySourceFeatures(u,t)}setStyle(u,t){return(t=p.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},t)).diff!==!1&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&u?(this._diffStyle(u,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(u,t))}setTransformRequest(u){return this._requestManager.setTransformRequest(u),this}_getUIString(u){const t=this._locale[u];if(t==null)throw new Error(`Missing UI string '${u}'`);return t}_updateStyle(u,t){if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(u,t)));const s=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!u)),u?(this.style=new za(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof u=="string"?this.style.loadURL(u,t,s):this.style.loadJSON(u,t,s),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new za(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(u,t){if(typeof u=="string"){const s=this._requestManager.transformRequest(u,"Style");p.h(s,new AbortController).then((n=>{this._updateDiff(n.data,t)})).catch((n=>{n&&this.fire(new p.j(n))}))}else typeof u=="object"&&this._updateDiff(u,t)}_updateDiff(u,t){try{this.style.setState(u,t)&&this._update(!0)}catch(s){p.w(`Unable to perform style diff: ${s.message||s.error||s}. Rebuilding the style from scratch.`),this._updateStyle(u,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(u,t){return this._lazyInitEmptyStyle(),this.style.addSource(u,t),this._update(!0)}isSourceLoaded(u){const t=this.style&&this.style.sourceCaches[u];if(t!==void 0)return t.loaded();this.fire(new p.j(new Error(`There is no source with ID '${u}'`)))}setTerrain(u){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),u){const t=this.style.sourceCaches[u.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${u.source}`);this.terrain===null&&t.reload();for(const s in this.style._layers){const n=this.style._layers[s];n.type==="hillshade"&&n.source===u.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 uo(this.painter,t,u),this.painter.renderToTexture=new ul(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=s=>{s.dataType==="style"?this.terrain.sourceCache.freeRtt():s.dataType==="source"&&s.tile&&(s.sourceId!==u.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(s.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:u})),this}getTerrain(){var u,t;return(t=(u=this.terrain)===null||u===void 0?void 0:u.options)!==null&&t!==void 0?t:null}areTilesLoaded(){const u=this.style&&this.style.sourceCaches;for(const t in u){const s=u[t]._tiles;for(const n in s){const o=s[n];if(o.state!=="loaded"&&o.state!=="errored")return!1}}return!0}removeSource(u){return this.style.removeSource(u),this._update(!0)}getSource(u){return this.style.getSource(u)}addImage(u,t,s={}){const{pixelRatio:n=1,sdf:o=!1,stretchX:c,stretchY:m,content:g,textFitWidth:y,textFitHeight:b}=s;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:T,height:S,data:z}=t,A=t;return this.style.addImage(u,{data:new p.R({width:T,height:S},new Uint8Array(z)),pixelRatio:n,stretchX:c,stretchY:m,content:g,textFitWidth:y,textFitHeight:b,sdf:o,version:0,userImage:A}),A.onAdd&&A.onAdd(this,u),this}}{const{width:T,height:S,data:z}=mt.getImageData(t);this.style.addImage(u,{data:new p.R({width:T,height:S},z),pixelRatio:n,stretchX:c,stretchY:m,content:g,textFitWidth:y,textFitHeight:b,sdf:o,version:0})}}updateImage(u,t){const s=this.style.getImage(u);if(!s)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 n=t instanceof HTMLImageElement||p.b(t)?mt.getImageData(t):t,{width:o,height:c,data:m}=n;if(o===void 0||c===void 0)return this.fire(new p.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==s.data.width||c!==s.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 s.data.replace(m,g),this.style.updateImage(u,s),this}getImage(u){return this.style.getImage(u)}hasImage(u){return u?!!this.style.getImage(u):(this.fire(new p.j(new Error("Missing required image id"))),!1)}removeImage(u){this.style.removeImage(u)}loadImage(u){return ui.getImage(this._requestManager.transformRequest(u,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(u,t){return this._lazyInitEmptyStyle(),this.style.addLayer(u,t),this._update(!0)}moveLayer(u,t){return this.style.moveLayer(u,t),this._update(!0)}removeLayer(u){return this.style.removeLayer(u),this._update(!0)}getLayer(u){return this.style.getLayer(u)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(u,t,s){return this.style.setLayerZoomRange(u,t,s),this._update(!0)}setFilter(u,t,s={}){return this.style.setFilter(u,t,s),this._update(!0)}getFilter(u){return this.style.getFilter(u)}setPaintProperty(u,t,s,n={}){return this.style.setPaintProperty(u,t,s,n),this._update(!0)}getPaintProperty(u,t){return this.style.getPaintProperty(u,t)}setLayoutProperty(u,t,s,n={}){return this.style.setLayoutProperty(u,t,s,n),this._update(!0)}getLayoutProperty(u,t){return this.style.getLayoutProperty(u,t)}setGlyphs(u,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(u,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(u,t,s={}){return this._lazyInitEmptyStyle(),this.style.addSprite(u,t,s,(n=>{n||this._update(!0)})),this}removeSprite(u){return this._lazyInitEmptyStyle(),this.style.removeSprite(u),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(u,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(u,t,(s=>{s||this._update(!0)})),this}setLight(u,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(u,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(u){return this._lazyInitEmptyStyle(),this.style.setSky(u),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(u,t){return this.style.setFeatureState(u,t),this._update()}removeFeatureState(u,t){return this.style.removeFeatureState(u,t),this._update()}getFeatureState(u){return this.style.getFeatureState(u)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let u=0,t=0;return this._container&&(u=this._container.clientWidth||400,t=this._container.clientHeight||300),[u,t]}_setupContainer(){const u=this._container;u.classList.add("maplibregl-map");const t=this._canvasContainer=at.create("div","maplibregl-canvas-container",u);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=at.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 s=this._containerDimensions(),n=this._getClampedPixelRatio(s[0],s[1]);this._resizeCanvas(s[0],s[1],n);const o=this._controlContainer=at.create("div","maplibregl-control-container",u),c=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((m=>{c[m]=at.create("div",`maplibregl-ctrl-${m} `,o)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(u,t,s){this._canvas.width=Math.floor(s*u),this._canvas.height=Math.floor(s*t),this._canvas.style.width=`${u}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const u={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let t=null;this._canvas.addEventListener("webglcontextcreationerror",(n=>{t={requestedAttributes:u},n&&(t.statusMessage=n.statusMessage,t.type=n.type)}),{once:!0});const s=this._canvas.getContext("webgl2",u)||this._canvas.getContext("webgl",u);if(!s){const n="Failed to initialize WebGL";throw t?(t.message=n,new Error(JSON.stringify(t))):new Error(n)}this.painter=new qa(s,this.transform),Vr.testSupport(s)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(u){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||u,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(u){return this._update(),this._renderTaskQueue.add(u)}_cancelRenderFrame(u){this._renderTaskQueue.remove(u)}_render(u){const t=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(u),this._removed)return;let s=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const o=this.transform.zoom,c=mt.now();this.style.zoomHistory.update(o,c);const m=new p.z(o,{now:c,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),g=m.crossFadingFactor();g===1&&g===this._crossFadingFactor||(s=!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.bf.mark(p.bg.load),this.fire(new p.k("load"))),this.style&&(this.style.hasTransitions()||s)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const n=this._sourcesDirty||this._styleDirty||this._placementDirty;return n||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new p.k("idle")),!this._loaded||this._fullyLoaded||n||(this._fullyLoaded=!0,p.bf.mark(p.bg.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var u;this._hash&&this._hash.remove();for(const s of this._controls)s.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),ui.removeThrottleControl(this._imageQueueHandle),(u=this._resizeObserver)===null||u===void 0||u.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),at.remove(this._canvasContainer),at.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),p.bf.clearMetrics(),this._removed=!0,this.fire(new p.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,mt.frameAsync(this._frameRequest).then((u=>{p.bf.frame(u),this._frameRequest=null,this._render(u)})).catch((()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(u){this._showTileBoundaries!==u&&(this._showTileBoundaries=u,this._update())}get showPadding(){return!!this._showPadding}set showPadding(u){this._showPadding!==u&&(this._showPadding=u,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(u){this._showCollisionBoxes!==u&&(this._showCollisionBoxes=u,u?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(u){this._showOverdrawInspector!==u&&(this._showOverdrawInspector=u,this._update())}get repaint(){return!!this._repaint}set repaint(u){this._repaint!==u&&(this._repaint=u,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(u){this._vertices=u,this._update()}get version(){return hl}getCameraTargetElevation(){return this.transform.elevation}},R.MapMouseEvent=Oe,R.MapTouchEvent=Qr,R.MapWheelEvent=sl,R.Marker=rn,R.NavigationControl=class{constructor(u){this._updateZoomButtons=()=>{const t=this._map.getZoom(),s=t===this._map.getMaxZoom(),n=t===this._map.getMinZoom();this._zoomInButton.disabled=s,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute("aria-disabled",s.toString()),this._zoomOutButton.setAttribute("aria-disabled",n.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,s)=>{const n=this._map._getUIString(`NavigationControl.${s}`);t.title=n,t.setAttribute("aria-label",n)},this.options=p.e({},lc,u),this._container=at.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}))),at.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}))),at.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=at.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(u){return this._map=u,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 cc(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){at.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(u,t){const s=at.create("button",u,this._container);return s.type="button",s.addEventListener("click",t),s}},R.Popup=class extends p.E{constructor(u){super(),this.remove=()=>(this._content&&at.remove(this._content),this._container&&(at.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 s;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=at.create("div","maplibregl-popup",this._map.getContainer()),this._tip=at.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?de(this._lngLat,this._flatPos,this._map.transform):(s=this._lngLat)===null||s===void 0?void 0:s.wrap(),this._trackPointer&&!t)return;const n=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 o=this.options.anchor;const c=an(this.options.offset);if(!o){const g=this._container.offsetWidth,y=this._container.offsetHeight;let b;b=n.y+c.bottom.y<y?["top"]:n.y>this._map.transform.height-y?["bottom"]:[],n.x<g/2?b.push("left"):n.x>this._map.transform.width-g/2&&b.push("right"),o=b.length===0?"bottom":b.join("-")}let m=n.add(c[o]);this.options.subpixelPositioning||(m=m.round()),at.setTransform(this._container,`${Ds[o]} translate(${m.x}px,${m.y}px)`),en(this._container,o,"popup")},this._onClose=()=>{this.remove()},this.options=p.e(Object.create(Bt),u)}addTo(u){return this._map&&this.remove(),this._map=u,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(u){return this._lngLat=p.N.convert(u),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(u){return this.setDOMContent(document.createTextNode(u))}setHTML(u){const t=document.createDocumentFragment(),s=document.createElement("body");let n;for(s.innerHTML=u;n=s.firstChild,n;)t.appendChild(n);return this.setDOMContent(t)}getMaxWidth(){var u;return(u=this._container)===null||u===void 0?void 0:u.style.maxWidth}setMaxWidth(u){return this.options.maxWidth=u,this._update(),this}setDOMContent(u){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=at.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(u),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(u){return this._container&&this._container.classList.add(u),this}removeClassName(u){return this._container&&this._container.classList.remove(u),this}setOffset(u){return this.options.offset=u,this._update(),this}toggleClassName(u){if(this._container)return this._container.classList.toggle(u)}setSubpixelPositioning(u){this.options.subpixelPositioning=u}_createCloseButton(){this.options.closeButton&&(this._closeButton=at.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const u=this._container.querySelector(sn);u&&u.focus()}},R.RasterDEMTileSource=ye,R.RasterTileSource=te,R.ScaleControl=class{constructor(u){this._onMove=()=>{_a(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,_a(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},nr),u)}getDefaultPosition(){return"bottom-left"}onAdd(u){return this._map=u,this._container=at.create("div","maplibregl-ctrl maplibregl-ctrl-scale",u.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){at.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},R.ScrollZoomHandler=ji,R.Style=za,R.TerrainControl=class{constructor(u){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=u}onAdd(u){return this._map=u,this._container=at.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=at.create("button","maplibregl-ctrl-terrain",this._container),at.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(){at.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},R.TwoFingersTouchPitchHandler=Es,R.TwoFingersTouchRotateHandler=so,R.TwoFingersTouchZoomHandler=io,R.TwoFingersTouchZoomRotateHandler=no,R.VectorTileSource=Ws,R.VideoSource=hs,R.addSourceType=(u,t)=>p._(void 0,void 0,void 0,(function*(){if(Ys(u))throw new Error(`A source type called "${u}" already exists.`);((s,n)=>{Js[s]=n})(u,t)})),R.clearPrewarmedResources=function(){const u=hi;u&&(u.isPreloaded()&&u.numActive()===1?(u.release(Tr),hi=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},R.getMaxParallelImageRequests=function(){return p.a.MAX_PARALLEL_IMAGE_REQUESTS},R.getRTLTextPluginStatus=function(){return er().getRTLTextPluginStatus()},R.getVersion=function(){return fo},R.getWorkerCount=function(){return Qi.workerCount},R.getWorkerUrl=function(){return p.a.WORKER_URL},R.importScriptInWorkers=function(u){return Hs().broadcast("IS",u)},R.prewarm=function(){Ur().acquire(Tr)},R.setMaxParallelImageRequests=function(u){p.a.MAX_PARALLEL_IMAGE_REQUESTS=u},R.setRTLTextPlugin=function(u,t){return er().setRTLTextPlugin(u,t)},R.setWorkerCount=function(u){Qi.workerCount=u},R.setWorkerUrl=function(u){p.a.WORKER_URL=u}}));var Tn=Lr;return Tn}))})(Fl,Fl.exports)),Fl.exports}var Oh=Bp();const Fp=Ap.Mo(Oh),Lp=Dp({__proto__:null,default:Fp},[Oh]);exports.m=Lp;