geoproject-app/public/site/plugins/map-editor/index.js
isUnknown 925e98aea7
All checks were successful
Deploy / Build and Deploy to Production (push) Successful in 19s
refactor: use Kirby page title for markers and add button tooltips
- Remove custom title field from marker.yml blueprint
- Use default Kirby page title for marker names in MarkerList
- Add French tooltips to MarkerList buttons (Ajouter, Modifier, Supprimer)
- API already uses page title via $marker->title()->value()

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-29 15:17:17 +01:00

611 lines
805 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(function(){"use strict";function od(h){return h&&h.__esModule&&Object.prototype.hasOwnProperty.call(h,"default")?h.default:h}var Oo={exports:{}},ld=Oo.exports,vu;function cd(){return vu||(vu=1,(function(h,w){(function(E,L){h.exports=L()})(ld,(function(){var E,L,F;function Q(l,le){if(!E)E=le;else if(!L)L=le;else{var W="var sharedChunk = {}; ("+E+")(sharedChunk); ("+L+")(sharedChunk);",Se={};E(Se),F=le(Se),typeof window<"u"&&(F.workerUrl=window.URL.createObjectURL(new Blob([W],{type:"text/javascript"})))}}Q(["exports"],(function(l){function le(i,e,r,a){return new(r||(r=Promise))((function(o,d){function f(v){try{y(a.next(v))}catch(S){d(S)}}function m(v){try{y(a.throw(v))}catch(S){d(S)}}function y(v){var S;v.done?o(v.value):(S=v.value,S instanceof r?S:new r((function(A){A(S)}))).then(f,m)}y((a=a.apply(i,e||[])).next())}))}function W(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}typeof SuppressedError=="function"&&SuppressedError;var Se=de;function de(i,e){this.x=i,this.y=e}de.prototype={clone:function(){return new de(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),o=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=o,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},de.convert=function(i){return i instanceof de?i:Array.isArray(i)?new de(i[0],i[1]):i};var ge=W(Se),ve=$e;function $e(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}$e.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 o=this.sampleCurveX(r)-i;if(Math.abs(o)<e)return r;var d=this.sampleCurveDerivativeX(r);if(Math.abs(d)<1e-6)break;r-=o/d}var f=0,m=1;for(r=i,a=0;a<20&&(o=this.sampleCurveX(r),!(Math.abs(o-i)<e));a++)i>o?f=r:m=r,r=.5*(m-f)+f;return r},solve:function(i,e){return this.sampleCurveY(this.solveCurveX(i,e))}};var Qe=W(ve);let Ke,Ye;function st(){return Ke==null&&(Ke=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Ke}function wi(){if(Ye==null&&(Ye=!1,st())){const e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let a=0;a<25;a++){const o=4*a;e.fillStyle=`rgb(${o},${o+1},${o+2})`,e.fillRect(a%5,Math.floor(a/5),1,1)}const r=e.getImageData(0,0,5,5).data;for(let a=0;a<100;a++)if(a%4!=3&&r[a]!==a){Ye=!0;break}}}return Ye||!1}function Pi(i,e,r,a){const o=new Qe(i,e,r,a);return function(d){return o.solve(d)}}const Hr=Pi(.25,.1,.25,1);function rr(i,e,r){return Math.min(r,Math.max(e,i))}function hn(i,e,r){const a=r-e,o=((i-e)%a+a)%a+e;return o===e?r:o}function Ve(i,...e){for(const r of e)for(const a in r)i[a]=r[a];return i}let it=1;function nt(i,e,r){const a={};for(const o in i)a[o]=e.call(r||this,i[o],o,i);return a}function ji(i,e,r){const a={};for(const o in i)e.call(r||this,i[o],o,i)&&(a[o]=i[o]);return a}function Vt(i){return Array.isArray(i)?i.map(Vt):typeof i=="object"&&i?nt(i,Vt):i}const qi={};function Dt(i){qi[i]||(typeof console<"u"&&console.warn(i),qi[i]=!0)}function Zi(i,e,r){return(r.y-i.y)*(e.x-i.x)>(e.y-i.y)*(r.x-i.x)}function zr(i){let e=0;for(let r,a,o=0,d=i.length,f=d-1;o<d;f=o++)r=i[o],a=i[f],e+=(a.x-r.x)*(r.y+a.y);return e}function nr(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}let pn=null;function la(i){return typeof ImageBitmap<"u"&&i instanceof ImageBitmap}const Oa="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function ca(i,e,r,a,o){return le(this,void 0,void 0,(function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");const d=new VideoFrame(i,{timestamp:0});try{const f=d==null?void 0:d.format;if(!f||!f.startsWith("BGR")&&!f.startsWith("RGB"))throw new Error(`Unrecognized format ${f}`);const m=f.startsWith("BGR"),y=new Uint8ClampedArray(a*o*4);if(yield d.copyTo(y,(function(v,S,A,C,z){const D=4*Math.max(-S,0),O=(Math.max(0,A)-A)*C*4+D,q=4*C,H=Math.max(0,S),re=Math.max(0,A);return{rect:{x:H,y:re,width:Math.min(v.width,S+C)-H,height:Math.min(v.height,A+z)-re},layout:[{offset:O,stride:q}]}})(i,e,r,a,o)),m)for(let v=0;v<y.length;v+=4){const S=y[v];y[v]=y[v+2],y[v+2]=S}return y}finally{d.close()}}))}let vr,Et,zi,dn;const Rn={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(i){const e=requestAnimationFrame(i);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(i,e=0){return this.getImageCanvasContext(i).getImageData(-e,-e,i.width+2*e,i.height+2*e)},getImageCanvasContext(i){const e=window.document.createElement("canvas"),r=e.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("failed to create canvas 2d context");return e.width=i.width,e.height=i.height,r.drawImage(i,0,0,i.width,i.height),r},resolveURL:i=>(zi||(zi=document.createElement("a")),zi.href=i,zi.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(dn==null&&(dn=matchMedia("(prefers-reduced-motion: reduce)")),dn.matches)}},Bn={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};class Wr extends Error{constructor(e,r,a,o){super(`AJAXError: ${r} (${e}): ${a}`),this.status=e,this.statusText=r,this.url=a,this.body=o}}const mr=nr()?()=>self.worker&&self.worker.referrer:()=>(window.location.protocol==="blob:"?window.parent:window).location.href,ar=i=>Bn.REGISTERED_PROTOCOLS[i.substring(0,i.indexOf("://"))];function ua(i,e){const r=new AbortController,a=new Request(i.url,{method:i.method||"GET",body:i.body,credentials:i.credentials,headers:i.headers,cache:i.cache,referrer:mr(),signal:r.signal});let o=!1,d=!1;return i.type==="json"&&a.headers.set("Accept","application/json"),d||fetch(a).then((f=>f.ok?(m=>{(i.type==="arrayBuffer"||i.type==="image"?m.arrayBuffer():i.type==="json"?m.json():m.text()).then((y=>{d||(o=!0,e(null,y,m.headers.get("Cache-Control"),m.headers.get("Expires")))})).catch((y=>{d||e(new Error(y.message))}))})(f):f.blob().then((m=>e(new Wr(f.status,f.statusText,i.url,m)))))).catch((f=>{f.code!==20&&e(new Error(f.message))})),{cancel:()=>{d=!0,o||r.abort()}}}const Xr=function(i,e){if(/:\/\//.test(i.url)&&!/^https?:|^file:/.test(i.url)){if(nr()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",i,e);if(!nr())return(ar(i.url)||ua)(i,e)}if(!(/^file:/.test(r=i.url)||/^file:/.test(mr())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return ua(i,e);if(nr()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",i,e,void 0,!0)}var r;return(function(a,o){const d=new XMLHttpRequest;d.open(a.method||"GET",a.url,!0),a.type!=="arrayBuffer"&&a.type!=="image"||(d.responseType="arraybuffer");for(const f in a.headers)d.setRequestHeader(f,a.headers[f]);return a.type==="json"&&(d.responseType="text",d.setRequestHeader("Accept","application/json")),d.withCredentials=a.credentials==="include",d.onerror=()=>{o(new Error(d.statusText))},d.onload=()=>{if((d.status>=200&&d.status<300||d.status===0)&&d.response!==null){let f=d.response;if(a.type==="json")try{f=JSON.parse(d.response)}catch(m){return o(m)}o(null,f,d.getResponseHeader("Cache-Control"),d.getResponseHeader("Expires"))}else{const f=new Blob([d.response],{type:d.getResponseHeader("Content-Type")});o(new Wr(d.status,d.statusText,a.url,f))}},d.send(a.body),{cancel:()=>d.abort()}})(i,e)},ha=function(i,e){return Xr(Ve(i,{type:"arrayBuffer"}),e)};function Dr(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 On(i,e,r){r[i]&&r[i].indexOf(e)!==-1||(r[i]=r[i]||[],r[i].push(e))}function fn(i,e,r){if(r&&r[i]){const a=r[i].indexOf(e);a!==-1&&r[i].splice(a,1)}}class Kr{constructor(e,r={}){Ve(this,r),this.type=e}}class Yr extends Kr{constructor(e,r={}){super("error",Ve({error:e},r))}}class mn{on(e,r){return this._listeners=this._listeners||{},On(e,r,this._listeners),this}off(e,r){return fn(e,r,this._listeners),fn(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},On(e,r,this._oneTimeListeners),this):new Promise((a=>this.once(e,a)))}fire(e,r){typeof e=="string"&&(e=new Kr(e,r||{}));const a=e.type;if(this.listens(a)){e.target=this;const o=this._listeners&&this._listeners[a]?this._listeners[a].slice():[];for(const m of o)m.call(this,e);const d=this._oneTimeListeners&&this._oneTimeListeners[a]?this._oneTimeListeners[a].slice():[];for(const m of d)fn(a,m,this._oneTimeListeners),m.call(this,e);const f=this._eventedParent;f&&(Ve(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),f.fire(e))}else e instanceof Yr&&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 he={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},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":{},within:{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const Di=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function sr(i,e){const r={};for(const a in i)a!=="ref"&&(r[a]=i[a]);return Di.forEach((a=>{a in e&&(r[a]=e[a])})),r}function At(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(!At(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(!At(i[r],e[r]))return!1;return!0}return i===e}const _t={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight"};function br(i,e,r){r.push({command:_t.addSource,args:[i,e[i]]})}function Nn(i,e,r){e.push({command:_t.removeSource,args:[i]}),r[i]=!0}function Lr(i,e,r,a){Nn(i,r,a),br(i,e,r)}function Na(i,e,r){let a;for(a in i[r])if(Object.prototype.hasOwnProperty.call(i[r],a)&&a!=="data"&&!At(i[r][a],e[r][a]))return!1;for(a in e[r])if(Object.prototype.hasOwnProperty.call(e[r],a)&&a!=="data"&&!At(i[r][a],e[r][a]))return!1;return!0}function Vn(i,e,r,a,o,d){let f;for(f in e=e||{},i=i||{})Object.prototype.hasOwnProperty.call(i,f)&&(At(i[f],e[f])||r.push({command:d,args:[a,f,e[f],o]}));for(f in e)Object.prototype.hasOwnProperty.call(e,f)&&!Object.prototype.hasOwnProperty.call(i,f)&&(At(i[f],e[f])||r.push({command:d,args:[a,f,e[f],o]}))}function Jr(i){return i.id}function gn(i,e){return i[e.id]=e,i}class Ae{constructor(e,r,a,o){this.message=(e?`${e}: `:"")+a,o&&(this.identifier=o),r!=null&&r.__line__&&(this.line=r.__line__)}}function wr(i,...e){for(const r of e)for(const a in r)i[a]=r[a];return i}class Ut extends Error{constructor(e,r){super(r),this.message=r,this.key=e}}class _n{constructor(e,r=[]){this.parent=e,this.bindings={};for(const[a,o]of r)this.bindings[a]=o}concat(e){return new _n(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 Fr={kind:"null"},Ce={kind:"number"},ot={kind:"string"},et={kind:"boolean"},Si={kind:"color"},Sr={kind:"object"},rt={kind:"value"},Rr={kind:"collator"},U={kind:"formatted"},k={kind:"padding"},M={kind:"resolvedImage"},R={kind:"variableAnchorOffsetCollection"};function j(i,e){return{kind:"array",itemType:i,N:e}}function Z(i){if(i.kind==="array"){const e=Z(i.itemType);return typeof i.N=="number"?`array<${e}, ${i.N}>`:i.itemType.kind==="value"?"array":`array<${e}>`}return i.kind}const ne=[Fr,Ce,ot,et,Si,U,Sr,j(rt),k,M,R];function J(i,e){if(e.kind==="error")return null;if(i.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!J(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 ne)if(!J(r,e))return null}}return`Expected ${Z(i)} but found ${Z(e)} instead.`}function X(i,e){return e.some((r=>r.kind===i.kind))}function ie(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 pe(i,e){return i.kind==="array"&&e.kind==="array"?i.itemType.kind===e.itemType.kind&&typeof i.N=="number":i.kind===e.kind}const fe=.96422,ye=.82521,qe=4/29,Je=6/29,Re=3*Je*Je,Ge=Je*Je*Je,tt=Math.PI/180,bt=180/Math.PI;function Tt(i){return(i%=360)<0&&(i+=360),i}function gt([i,e,r,a]){let o,d;const f=mi((.2225045*(i=mt(i))+.7168786*(e=mt(e))+.0606169*(r=mt(r)))/1);i===e&&e===r?o=d=f:(o=mi((.4360747*i+.3850649*e+.1430804*r)/fe),d=mi((.0139322*i+.0971045*e+.7141733*r)/ye));const m=116*f-16;return[m<0?0:m,500*(o-f),200*(f-d),a]}function mt(i){return i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function mi(i){return i>Ge?Math.pow(i,1/3):i/Re+qe}function kt([i,e,r,a]){let o=(i+16)/116,d=isNaN(e)?o:o+e/500,f=isNaN(r)?o:o-r/200;return o=1*ui(o),d=fe*ui(d),f=ye*ui(f),[Yt(3.1338561*d-1.6168667*o-.4906146*f),Yt(-.9787684*d+1.9161415*o+.033454*f),Yt(.0719453*d-.2289914*o+1.4052427*f),a]}function Yt(i){return(i=i<=.00304?12.92*i:1.055*Math.pow(i,1/2.4)-.055)<0?0:i>1?1:i}function ui(i){return i>Je?i*i*i:Re*(i-qe)}function or(i){return parseInt(i.padEnd(2,i),16)/255}function Go(i,e){return Un(e?i/100:i,0,1)}function Un(i,e,r){return Math.min(Math.max(e,i),r)}function $n(i){return!i.some(Number.isNaN)}const dc={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 wt{constructor(e,r,a,o=1,d=!0){this.r=e,this.g=r,this.b=a,this.a=o,d||(this.r*=o,this.g*=o,this.b*=o,o||this.overwriteGetter("rgb",[e,r,a,o]))}static parse(e){if(e instanceof wt)return e;if(typeof e!="string")return;const r=(function(a){if((a=a.toLowerCase().trim())==="transparent")return[0,0,0,0];const o=dc[a];if(o){const[f,m,y]=o;return[f/255,m/255,y/255,1]}if(a.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(a)){const f=a.length<6?1:2;let m=1;return[or(a.slice(m,m+=f)),or(a.slice(m,m+=f)),or(a.slice(m,m+=f)),or(a.slice(m,m+f)||"ff")]}if(a.startsWith("rgb")){const f=a.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(f){const[m,y,v,S,A,C,z,D,O,q,H,re]=f,Y=[S||" ",z||" ",q].join("");if(Y===" "||Y===" /"||Y===",,"||Y===",,,"){const ae=[v,C,O].join(""),oe=ae==="%%%"?100:ae===""?255:0;if(oe){const _e=[Un(+y/oe,0,1),Un(+A/oe,0,1),Un(+D/oe,0,1),H?Go(+H,re):1];if($n(_e))return _e}}return}}const d=a.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(d){const[f,m,y,v,S,A,C,z,D]=d,O=[y||" ",S||" ",C].join("");if(O===" "||O===" /"||O===",,"||O===",,,"){const q=[+m,Un(+v,0,100),Un(+A,0,100),z?Go(+z,D):1];if($n(q))return(function([H,re,Y,ae]){function oe(_e){const De=(_e+H/30)%12,Oe=re*Math.min(Y,1-Y);return Y-Oe*Math.max(-1,Math.min(De-3,9-De,1))}return H=Tt(H),re/=100,Y/=100,[oe(0),oe(8),oe(4),ae]})(q)}}})(e);return r?new wt(...r,!1):void 0}get rgb(){const{r:e,g:r,b:a,a:o}=this,d=o||1/0;return this.overwriteGetter("rgb",[e/d,r/d,a/d,o])}get hcl(){return this.overwriteGetter("hcl",(function(e){const[r,a,o,d]=gt(e),f=Math.sqrt(a*a+o*o);return[Math.round(1e4*f)?Tt(Math.atan2(o,a)*bt):NaN,f,r,d]})(this.rgb))}get lab(){return this.overwriteGetter("lab",gt(this.rgb))}overwriteGetter(e,r){return Object.defineProperty(this,e,{value:r}),r}toString(){const[e,r,a,o]=this.rgb;return`rgba(${[e,r,a].map((d=>Math.round(255*d))).join(",")},${o})`}}wt.black=new wt(0,0,0,1),wt.white=new wt(1,1,1,1),wt.transparent=new wt(0,0,0,0),wt.red=new wt(1,0,0,1);class Ps{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 Va{constructor(e,r,a,o,d){this.text=e,this.image=r,this.scale=a,this.fontStack=o,this.textColor=d}}class gi{constructor(e){this.sections=e}static fromString(e){return new gi([new Va(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 gi?e:gi.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map((e=>e.text)).join("")}}class Gi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Gi)return e;if(typeof e=="number")return new Gi([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 Gi(e)}}toString(){return JSON.stringify(this.values)}}const fc=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class lr{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof lr)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],o=e[r+1];if(typeof a!="string"||!fc.has(a)||!Array.isArray(o)||o.length!==2||typeof o[0]!="number"||typeof o[1]!="number")return}return new lr(e)}}toString(){return JSON.stringify(this.values)}}class hi{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new hi({name:e,available:!1}):null}}function Ua(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 jn(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof wt||i instanceof Ps||i instanceof gi||i instanceof Gi||i instanceof lr||i instanceof hi)return!0;if(Array.isArray(i)){for(const e of i)if(!jn(e))return!1;return!0}if(typeof i=="object"){for(const e in i)if(!jn(i[e]))return!1;return!0}return!1}function Rt(i){if(i===null)return Fr;if(typeof i=="string")return ot;if(typeof i=="boolean")return et;if(typeof i=="number")return Ce;if(i instanceof wt)return Si;if(i instanceof Ps)return Rr;if(i instanceof gi)return U;if(i instanceof Gi)return k;if(i instanceof lr)return R;if(i instanceof hi)return M;if(Array.isArray(i)){const e=i.length;let r;for(const a of i){const o=Rt(a);if(r){if(r===o)continue;r=rt;break}r=o}return j(r||rt,e)}return Sr}function yt(i){const e=typeof i;return i===null?"":e==="string"||e==="number"||e==="boolean"?String(i):i instanceof wt||i instanceof gi||i instanceof Gi||i instanceof lr||i instanceof hi?i.toString():JSON.stringify(i)}class yn{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(!jn(e[1]))return r.error("invalid value");const a=e[1];let o=Rt(a);const d=r.expectedType;return o.kind!=="array"||o.N!==0||!d||d.kind!=="array"||typeof d.N=="number"&&d.N!==0||(o=d),new yn(o,a)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class $t{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const $a={string:ot,number:Ce,boolean:et,object:Sr};class cr{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,o=1;const d=e[0];if(d==="array"){let m,y;if(e.length>2){const v=e[1];if(typeof v!="string"||!(v in $a)||v==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);m=$a[v],o++}else m=rt;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);y=e[2],o++}a=j(m,y)}else{if(!$a[d])throw new Error(`Types doesn't contain name = ${d}`);a=$a[d]}const f=[];for(;o<e.length;o++){const m=r.parse(e[o],o,rt);if(!m)return null;f.push(m)}return new cr(a,f)}evaluate(e){for(let r=0;r<this.args.length;r++){const a=this.args[r].evaluate(e);if(!J(this.type,Rt(a)))return a;if(r===this.args.length-1)throw new $t(`Expected value to be of type ${Z(this.type)}, but found ${Z(Rt(a))} instead.`)}throw new Error}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const zs={"to-boolean":et,"to-color":Si,"to-number":Ce,"to-string":ot};class Qr{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(!zs[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 o=zs[a],d=[];for(let f=1;f<e.length;f++){const m=r.parse(e[f],f,rt);if(!m)return null;d.push(m)}return new Qr(o,d)}evaluate(e){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(e);case"color":{let r,a;for(const o of this.args){if(r=o.evaluate(e),a=null,r instanceof wt)return r;if(typeof r=="string"){const d=e.parseColor(r);if(d)return d}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.`:Ua(r[0],r[1],r[2],r[3]),!a))return new wt(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new $t(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 o=Gi.parse(r);if(o)return o}throw new $t(`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 o=lr.parse(r);if(o)return o}throw new $t(`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 o=Number(r);if(!isNaN(o))return o}throw new $t(`Could not convert ${JSON.stringify(r)} to number.`)}case"formatted":return gi.fromString(yt(this.args[0].evaluate(e)));case"resolvedImage":return hi.fromString(yt(this.args[0].evaluate(e)));default:return yt(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Ho=["Unknown","Point","LineString","Polygon"];class Ds{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"?Ho[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]=wt.parse(e)),r}}class ja{constructor(e,r,a=[],o,d=new _n,f=[]){this.registry=e,this.path=a,this.key=a.map((m=>`[${m}]`)).join(""),this.scope=d,this.errors=f,this.expectedType=o,this._isConstant=r}parse(e,r,a,o,d={}){return r?this.concat(r,a,o)._parse(e,d):this._parse(e,d)}_parse(e,r){function a(o,d,f){return f==="assert"?new cr(d,[o]):f==="coerce"?new Qr(d,[o]):o}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const o=e[0];if(typeof o!="string")return this.error(`Expression name must be a string, but found ${typeof o} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const d=this.registry[o];if(d){let f=d.parse(e,this);if(!f)return null;if(this.expectedType){const m=this.expectedType,y=f.type;if(m.kind!=="string"&&m.kind!=="number"&&m.kind!=="boolean"&&m.kind!=="object"&&m.kind!=="array"||y.kind!=="value")if(m.kind!=="color"&&m.kind!=="formatted"&&m.kind!=="resolvedImage"||y.kind!=="value"&&y.kind!=="string")if(m.kind!=="padding"||y.kind!=="value"&&y.kind!=="number"&&y.kind!=="array")if(m.kind!=="variableAnchorOffsetCollection"||y.kind!=="value"&&y.kind!=="array"){if(this.checkSubtype(m,y))return null}else f=a(f,m,r.typeAnnotation||"coerce");else f=a(f,m,r.typeAnnotation||"coerce");else f=a(f,m,r.typeAnnotation||"coerce");else f=a(f,m,r.typeAnnotation||"assert")}if(!(f instanceof yn)&&f.type.kind!=="resolvedImage"&&this._isConstant(f)){const m=new Ds;try{f=new yn(f.type,f.evaluate(m))}catch(y){return this.error(y.message),null}}return f}return this.error(`Unknown expression "${o}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,r,a){const o=typeof e=="number"?this.path.concat(e):this.path,d=a?this.scope.concat(a):this.scope;return new ja(this.registry,this._isConstant,o,r||null,d,this.errors)}error(e,...r){const a=`${this.key}${r.map((o=>`[${o}]`)).join("")}`;this.errors.push(new Ut(a,e))}checkSubtype(e,r){const a=J(e,r);return a&&this.error(a),a}}class qa{constructor(e,r,a){this.type=Rr,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 o=r.parse(a["case-sensitive"]!==void 0&&a["case-sensitive"],1,et);if(!o)return null;const d=r.parse(a["diacritic-sensitive"]!==void 0&&a["diacritic-sensitive"],1,et);if(!d)return null;let f=null;return a.locale&&(f=r.parse(a.locale,1,ot),!f)?null:new qa(o,d,f)}evaluate(e){return new Ps(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}const en=8192;function Ls(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 pa(i,e){return!(i[0]<=e[0]||i[2]>=e[2]||i[1]<=e[1]||i[3]>=e[3])}function Wo(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,o=Math.pow(2,e.z);return[Math.round(r*o*en),Math.round(a*o*en)]}function mc(i,e,r){const a=i[0]-e[0],o=i[1]-e[1],d=i[0]-r[0],f=i[1]-r[1];return a*f-d*o==0&&a*d<=0&&o*f<=0}function Fs(i,e){let r=!1;for(let f=0,m=e.length;f<m;f++){const y=e[f];for(let v=0,S=y.length;v<S-1;v++){if(mc(i,y[v],y[v+1]))return!1;(o=y[v])[1]>(a=i)[1]!=(d=y[v+1])[1]>a[1]&&a[0]<(d[0]-o[0])*(a[1]-o[1])/(d[1]-o[1])+o[0]&&(r=!r)}}var a,o,d;return r}function Rs(i,e){for(let r=0;r<e.length;r++)if(Fs(i,e[r]))return!0;return!1}function Xo(i,e,r,a){const o=a[0]-r[0],d=a[1]-r[1],f=(i[0]-r[0])*d-o*(i[1]-r[1]),m=(e[0]-r[0])*d-o*(e[1]-r[1]);return f>0&&m<0||f<0&&m>0}function gc(i,e,r){for(const v of r)for(let S=0;S<v.length-1;++S)if((m=[(f=v[S+1])[0]-(d=v[S])[0],f[1]-d[1]])[0]*(y=[(o=e)[0]-(a=i)[0],o[1]-a[1]])[1]-m[1]*y[0]!=0&&Xo(a,o,d,f)&&Xo(d,f,a,o))return!0;var a,o,d,f,m,y;return!1}function Ko(i,e){for(let r=0;r<i.length;++r)if(!Fs(i[r],e))return!1;for(let r=0;r<i.length-1;++r)if(gc(i[r],i[r+1],e))return!1;return!0}function Yo(i,e){for(let r=0;r<e.length;r++)if(Ko(i,e[r]))return!0;return!1}function Za(i,e,r){const a=[];for(let o=0;o<i.length;o++){const d=[];for(let f=0;f<i[o].length;f++){const m=Wo(i[o][f],r);Ls(e,m),d.push(m)}a.push(d)}return a}function Jo(i,e,r){const a=[];for(let o=0;o<i.length;o++){const d=Za(i[o],e,r);a.push(d)}return a}function Qo(i,e,r,a){if(i[0]<r[0]||i[0]>r[2]){const o=.5*a;let d=i[0]-r[0]>o?-a:r[0]-i[0]>o?a:0;d===0&&(d=i[0]-r[2]>o?-a:r[2]-i[0]>o?a:0),i[0]+=d}Ls(e,i)}function Bs(i,e,r,a){const o=Math.pow(2,a.z)*en,d=[a.x*en,a.y*en],f=[];for(const m of i)for(const y of m){const v=[y.x+d[0],y.y+d[1]];Qo(v,e,r,o),f.push(v)}return f}function Os(i,e,r,a){const o=Math.pow(2,a.z)*en,d=[a.x*en,a.y*en],f=[];for(const y of i){const v=[];for(const S of y){const A=[S.x+d[0],S.y+d[1]];Ls(e,A),v.push(A)}f.push(v)}if(e[2]-e[0]<=o/2){(m=e)[0]=m[1]=1/0,m[2]=m[3]=-1/0;for(const y of f)for(const v of y)Qo(v,e,r,o)}var m;return f}class xn{constructor(e,r){this.type=et,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(jn(e[1])){const a=e[1];if(a.type==="FeatureCollection")for(let o=0;o<a.features.length;++o){const d=a.features[o].geometry.type;if(d==="Polygon"||d==="MultiPolygon")return new xn(a,a.features[o].geometry)}else if(a.type==="Feature"){const o=a.geometry.type;if(o==="Polygon"||o==="MultiPolygon")return new xn(a,a.geometry)}else if(a.type==="Polygon"||a.type==="MultiPolygon")return new xn(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 o=[1/0,1/0,-1/0,-1/0],d=[1/0,1/0,-1/0,-1/0],f=r.canonicalID();if(a.type==="Polygon"){const m=Za(a.coordinates,d,f),y=Bs(r.geometry(),o,d,f);if(!pa(o,d))return!1;for(const v of y)if(!Fs(v,m))return!1}if(a.type==="MultiPolygon"){const m=Jo(a.coordinates,d,f),y=Bs(r.geometry(),o,d,f);if(!pa(o,d))return!1;for(const v of y)if(!Rs(v,m))return!1}return!0})(e,this.geometries);if(e.geometryType()==="LineString")return(function(r,a){const o=[1/0,1/0,-1/0,-1/0],d=[1/0,1/0,-1/0,-1/0],f=r.canonicalID();if(a.type==="Polygon"){const m=Za(a.coordinates,d,f),y=Os(r.geometry(),o,d,f);if(!pa(o,d))return!1;for(const v of y)if(!Ko(v,m))return!1}if(a.type==="MultiPolygon"){const m=Jo(a.coordinates,d,f),y=Os(r.geometry(),o,d,f);if(!pa(o,d))return!1;for(const v of y)if(!Yo(v,m))return!1}return!0})(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}class Ga{constructor(e,r){this.type=r.type,this.name=e,this.boundExpression=r}static parse(e,r){if(e.length!==2||typeof e[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");const a=e[1];return r.scope.has(a)?new Ga(a,r.scope.get(a)):r.error(`Unknown variable "${a}". Make sure "${a}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class ur{constructor(e,r,a,o){this.name=e,this.type=r,this._evaluate=a,this.args=o}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,r){const a=e[0],o=ur.definitions[a];if(!o)return r.error(`Unknown expression "${a}". If you wanted a literal array, use ["literal", [...]].`,0);const d=Array.isArray(o)?o[0]:o.type,f=Array.isArray(o)?[[o[1],o[2]]]:o.overloads,m=f.filter((([v])=>!Array.isArray(v)||v.length===e.length-1));let y=null;for(const[v,S]of m){y=new ja(r.registry,Ha,r.path,null,r.scope);const A=[];let C=!1;for(let z=1;z<e.length;z++){const D=e[z],O=Array.isArray(v)?v[z-1]:v.type,q=y.parse(D,1+A.length,O);if(!q){C=!0;break}A.push(q)}if(!C)if(Array.isArray(v)&&v.length!==A.length)y.error(`Expected ${v.length} arguments, but found ${A.length} instead.`);else{for(let z=0;z<A.length;z++){const D=Array.isArray(v)?v[z]:v.type,O=A[z];y.concat(z+1).checkSubtype(D,O.type)}if(y.errors.length===0)return new ur(a,d,S,A)}}if(m.length===1)r.errors.push(...y.errors);else{const v=(m.length?m:f).map((([A])=>{return C=A,Array.isArray(C)?`(${C.map(Z).join(", ")})`:`(${Z(C.type)}...)`;var C})).join(" | "),S=[];for(let A=1;A<e.length;A++){const C=r.parse(e[A],1+S.length);if(!C)return null;S.push(Z(C.type))}r.error(`Expected arguments of type ${v}, but found (${S.join(", ")}) instead.`)}return null}static register(e,r){ur.definitions=r;for(const a in r)e[a]=ur}}function Ha(i){if(i instanceof Ga)return Ha(i.boundExpression);if(i instanceof ur&&i.name==="error"||i instanceof qa||i instanceof xn)return!1;const e=i instanceof Qr||i instanceof cr;let r=!0;return i.eachChild((a=>{r=e?r&&Ha(a):r&&a instanceof yn})),!!r&&Wa(i)&&Xa(i,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Wa(i){if(i instanceof ur&&(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 xn)return!1;let e=!0;return i.eachChild((r=>{e&&!Wa(r)&&(e=!1)})),e}function da(i){if(i instanceof ur&&i.name==="feature-state")return!1;let e=!0;return i.eachChild((r=>{e&&!da(r)&&(e=!1)})),e}function Xa(i,e){if(i instanceof ur&&e.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild((a=>{r&&!Xa(a,e)&&(r=!1)})),r}function qn(i,e){const r=i.length-1;let a,o,d=0,f=r,m=0;for(;d<=f;)if(m=Math.floor((d+f)/2),a=i[m],o=i[m+1],a<=e){if(m===r||e<o)return m;d=m+1}else{if(!(a>e))throw new $t("Input is not a number.");f=m-1}return 0}class tn{constructor(e,r,a){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(const[o,d]of a)this.labels.push(o),this.outputs.push(d)}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,Ce);if(!a)return null;const o=[];let d=null;r.expectedType&&r.expectedType.kind!=="value"&&(d=r.expectedType);for(let f=1;f<e.length;f+=2){const m=f===1?-1/0:e[f],y=e[f+1],v=f,S=f+1;if(typeof m!="number")return r.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',v);if(o.length&&o[o.length-1][0]>=m)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',v);const A=r.parse(y,S,d);if(!A)return null;d=d||A.type,o.push([m,A])}return new tn(d,a,o)}evaluate(e){const r=this.labels,a=this.outputs;if(r.length===1)return a[0].evaluate(e);const o=this.input.evaluate(e);if(o<=r[0])return a[0].evaluate(e);const d=r.length;return o>=r[d-1]?a[d-1].evaluate(e):a[qn(r,o)].evaluate(e)}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function dt(i,e,r){return i+r*(e-i)}function Ka(i,e,r){return i.map(((a,o)=>dt(a,e[o],r)))}const Hi={number:dt,color:function(i,e,r,a="rgb"){switch(a){case"rgb":{const[o,d,f,m]=Ka(i.rgb,e.rgb,r);return new wt(o,d,f,m,!1)}case"hcl":{const[o,d,f,m]=i.hcl,[y,v,S,A]=e.hcl;let C,z;if(isNaN(o)||isNaN(y))isNaN(o)?isNaN(y)?C=NaN:(C=y,f!==1&&f!==0||(z=v)):(C=o,S!==1&&S!==0||(z=d));else{let re=y-o;y>o&&re>180?re-=360:y<o&&o-y>180&&(re+=360),C=o+r*re}const[D,O,q,H]=(function([re,Y,ae,oe]){return re=isNaN(re)?0:re*tt,kt([ae,Math.cos(re)*Y,Math.sin(re)*Y,oe])})([C,z??dt(d,v,r),dt(f,S,r),dt(m,A,r)]);return new wt(D,O,q,H,!1)}case"lab":{const[o,d,f,m]=kt(Ka(i.lab,e.lab,r));return new wt(o,d,f,m,!1)}}},array:Ka,padding:function(i,e,r){return new Gi(Ka(i.values,e.values,r))},variableAnchorOffsetCollection:function(i,e,r){const a=i.values,o=e.values;if(a.length!==o.length)throw new $t(`Cannot interpolate values of different length. from: ${i.toString()}, to: ${e.toString()}`);const d=[];for(let f=0;f<a.length;f+=2){if(a[f]!==o[f])throw new $t(`Cannot interpolate values containing mismatched anchors. from[${f}]: ${a[f]}, to[${f}]: ${o[f]}`);d.push(a[f]);const[m,y]=a[f+1],[v,S]=o[f+1];d.push([dt(m,v,r),dt(y,S,r)])}return new lr(d)}};class Wi{constructor(e,r,a,o,d){this.type=e,this.operator=r,this.interpolation=a,this.input=o,this.labels=[],this.outputs=[];for(const[f,m]of d)this.labels.push(f),this.outputs.push(m)}static interpolationFactor(e,r,a,o){let d=0;if(e.name==="exponential")d=Ns(r,e.base,a,o);else if(e.name==="linear")d=Ns(r,1,a,o);else if(e.name==="cubic-bezier"){const f=e.controlPoints;d=new Qe(f[0],f[1],f[2],f[3]).solve(Ns(r,1,a,o))}return d}static parse(e,r){let[a,o,d,...f]=e;if(!Array.isArray(o)||o.length===0)return r.error("Expected an interpolation type expression.",1);if(o[0]==="linear")o={name:"linear"};else if(o[0]==="exponential"){const v=o[1];if(typeof v!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);o={name:"exponential",base:v}}else{if(o[0]!=="cubic-bezier")return r.error(`Unknown interpolation type ${String(o[0])}`,1,0);{const v=o.slice(1);if(v.length!==4||v.some((S=>typeof S!="number"||S<0||S>1)))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);o={name:"cubic-bezier",controlPoints:v}}}if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(d=r.parse(d,2,Ce),!d)return null;const m=[];let y=null;a==="interpolate-hcl"||a==="interpolate-lab"?y=Si:r.expectedType&&r.expectedType.kind!=="value"&&(y=r.expectedType);for(let v=0;v<f.length;v+=2){const S=f[v],A=f[v+1],C=v+3,z=v+4;if(typeof S!="number")return r.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',C);if(m.length&&m[m.length-1][0]>=S)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',C);const D=r.parse(A,z,y);if(!D)return null;y=y||D.type,m.push([S,D])}return pe(y,Ce)||pe(y,Si)||pe(y,k)||pe(y,R)||pe(y,j(Ce))?new Wi(y,a,o,d,m):r.error(`Type ${Z(y)} is not interpolatable.`)}evaluate(e){const r=this.labels,a=this.outputs;if(r.length===1)return a[0].evaluate(e);const o=this.input.evaluate(e);if(o<=r[0])return a[0].evaluate(e);const d=r.length;if(o>=r[d-1])return a[d-1].evaluate(e);const f=qn(r,o),m=Wi.interpolationFactor(this.interpolation,o,r[f],r[f+1]),y=a[f].evaluate(e),v=a[f+1].evaluate(e);switch(this.operator){case"interpolate":return Hi[this.type.kind](y,v,m);case"interpolate-hcl":return Hi.color(y,v,m,"hcl");case"interpolate-lab":return Hi.color(y,v,m,"lab")}}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Ns(i,e,r,a){const o=a-r,d=i-r;return o===0?0:e===1?d/o:(Math.pow(e,d)-1)/(Math.pow(e,o)-1)}class Ya{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 o=r.expectedType;o&&o.kind!=="value"&&(a=o);const d=[];for(const m of e.slice(1)){const y=r.parse(m,1+d.length,a,void 0,{typeAnnotation:"omit"});if(!y)return null;a=a||y.type,d.push(y)}if(!a)throw new Error("No output type");const f=o&&d.some((m=>J(o,m.type)));return new Ya(f?rt:a,d)}evaluate(e){let r,a=null,o=0;for(const d of this.args)if(o++,a=d.evaluate(e),a&&a instanceof hi&&!a.available&&(r||(r=a.name),a=null,o===this.args.length&&(a=r)),a!==null)break;return a}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}class Ja{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 d=1;d<e.length-1;d+=2){const f=e[d];if(typeof f!="string")return r.error(`Expected string, but found ${typeof f} instead.`,d);if(/[^a-zA-Z0-9_]/.test(f))return r.error("Variable names must contain only alphanumeric characters or '_'.",d);const m=r.parse(e[d+1],d+1);if(!m)return null;a.push([f,m])}const o=r.parse(e[e.length-1],e.length-1,r.expectedType,a);return o?new Ja(a,o):null}outputDefined(){return this.result.outputDefined()}}class Vs{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,Ce),o=r.parse(e[2],2,j(r.expectedType||rt));return a&&o?new Vs(o.type.itemType,a,o):null}evaluate(e){const r=this.index.evaluate(e),a=this.input.evaluate(e);if(r<0)throw new $t(`Array index out of bounds: ${r} < 0.`);if(r>=a.length)throw new $t(`Array index out of bounds: ${r} > ${a.length-1}.`);if(r!==Math.floor(r))throw new $t(`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 Us{constructor(e,r){this.type=et,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,rt),o=r.parse(e[2],2,rt);return a&&o?X(a.type,[et,ot,Ce,Fr,rt])?new Us(a,o):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Z(a.type)} instead`):null}evaluate(e){const r=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!a)return!1;if(!ie(r,["boolean","string","number","null"]))throw new $t(`Expected first argument to be of type boolean, string, number or null, but found ${Z(Rt(r))} instead.`);if(!ie(a,["string","array"]))throw new $t(`Expected second argument to be of type array or string, but found ${Z(Rt(a))} instead.`);return a.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class Qa{constructor(e,r,a){this.type=Ce,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,rt),o=r.parse(e[2],2,rt);if(!a||!o)return null;if(!X(a.type,[et,ot,Ce,Fr,rt]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Z(a.type)} instead`);if(e.length===4){const d=r.parse(e[3],3,Ce);return d?new Qa(a,o,d):null}return new Qa(a,o)}evaluate(e){const r=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!ie(r,["boolean","string","number","null"]))throw new $t(`Expected first argument to be of type boolean, string, number or null, but found ${Z(Rt(r))} instead.`);if(!ie(a,["string","array"]))throw new $t(`Expected second argument to be of type array or string, but found ${Z(Rt(a))} instead.`);if(this.fromIndex){const o=this.fromIndex.evaluate(e);return a.indexOf(r,o)}return a.indexOf(r)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class $s{constructor(e,r,a,o,d,f){this.inputType=e,this.type=r,this.input=a,this.cases=o,this.outputs=d,this.otherwise=f}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,o;r.expectedType&&r.expectedType.kind!=="value"&&(o=r.expectedType);const d={},f=[];for(let v=2;v<e.length-1;v+=2){let S=e[v];const A=e[v+1];Array.isArray(S)||(S=[S]);const C=r.concat(v);if(S.length===0)return C.error("Expected at least one branch label.");for(const D of S){if(typeof D!="number"&&typeof D!="string")return C.error("Branch labels must be numbers or strings.");if(typeof D=="number"&&Math.abs(D)>Number.MAX_SAFE_INTEGER)return C.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof D=="number"&&Math.floor(D)!==D)return C.error("Numeric branch labels must be integer values.");if(a){if(C.checkSubtype(a,Rt(D)))return null}else a=Rt(D);if(d[String(D)]!==void 0)return C.error("Branch labels must be unique.");d[String(D)]=f.length}const z=r.parse(A,v,o);if(!z)return null;o=o||z.type,f.push(z)}const m=r.parse(e[1],1,rt);if(!m)return null;const y=r.parse(e[e.length-1],e.length-1,o);return y?m.type.kind!=="value"&&r.concat(1).checkSubtype(a,m.type)?null:new $s(a,o,m,d,f,y):null}evaluate(e){const r=this.input.evaluate(e);return(Rt(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 js{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 o=[];for(let f=1;f<e.length-1;f+=2){const m=r.parse(e[f],f,et);if(!m)return null;const y=r.parse(e[f+1],f+1,a);if(!y)return null;o.push([m,y]),a=a||y.type}const d=r.parse(e[e.length-1],e.length-1,a);if(!d)return null;if(!a)throw new Error("Can't infer output type");return new js(a,o,d)}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 es{constructor(e,r,a,o){this.type=e,this.input=r,this.beginIndex=a,this.endIndex=o}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const a=r.parse(e[1],1,rt),o=r.parse(e[2],2,Ce);if(!a||!o)return null;if(!X(a.type,[j(rt),ot,rt]))return r.error(`Expected first argument to be of type array or string, but found ${Z(a.type)} instead`);if(e.length===4){const d=r.parse(e[3],3,Ce);return d?new es(a.type,a,o,d):null}return new es(a.type,a,o)}evaluate(e){const r=this.input.evaluate(e),a=this.beginIndex.evaluate(e);if(!ie(r,["string","array"]))throw new $t(`Expected first argument to be of type array or string, but found ${Z(Rt(r))} instead.`);if(this.endIndex){const o=this.endIndex.evaluate(e);return r.slice(a,o)}return r.slice(a)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function el(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 tl(i,e,r,a){return a.compare(e,r)===0}function Zn(i,e,r){const a=i!=="=="&&i!=="!=";return class sd{constructor(d,f,m){this.type=et,this.lhs=d,this.rhs=f,this.collator=m,this.hasUntypedArgument=d.type.kind==="value"||f.type.kind==="value"}static parse(d,f){if(d.length!==3&&d.length!==4)return f.error("Expected two or three arguments.");const m=d[0];let y=f.parse(d[1],1,rt);if(!y)return null;if(!el(m,y.type))return f.concat(1).error(`"${m}" comparisons are not supported for type '${Z(y.type)}'.`);let v=f.parse(d[2],2,rt);if(!v)return null;if(!el(m,v.type))return f.concat(2).error(`"${m}" comparisons are not supported for type '${Z(v.type)}'.`);if(y.type.kind!==v.type.kind&&y.type.kind!=="value"&&v.type.kind!=="value")return f.error(`Cannot compare types '${Z(y.type)}' and '${Z(v.type)}'.`);a&&(y.type.kind==="value"&&v.type.kind!=="value"?y=new cr(v.type,[y]):y.type.kind!=="value"&&v.type.kind==="value"&&(v=new cr(y.type,[v])));let S=null;if(d.length===4){if(y.type.kind!=="string"&&v.type.kind!=="string"&&y.type.kind!=="value"&&v.type.kind!=="value")return f.error("Cannot use collator to compare non-string types.");if(S=f.parse(d[3],3,Rr),!S)return null}return new sd(y,v,S)}evaluate(d){const f=this.lhs.evaluate(d),m=this.rhs.evaluate(d);if(a&&this.hasUntypedArgument){const y=Rt(f),v=Rt(m);if(y.kind!==v.kind||y.kind!=="string"&&y.kind!=="number")throw new $t(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${y.kind}, ${v.kind}) instead.`)}if(this.collator&&!a&&this.hasUntypedArgument){const y=Rt(f),v=Rt(m);if(y.kind!=="string"||v.kind!=="string")return e(d,f,m)}return this.collator?r(d,f,m,this.collator.evaluate(d)):e(d,f,m)}eachChild(d){d(this.lhs),d(this.rhs),this.collator&&d(this.collator)}outputDefined(){return!0}}}const _c=Zn("==",(function(i,e,r){return e===r}),tl),yc=Zn("!=",(function(i,e,r){return e!==r}),(function(i,e,r,a){return!tl(0,e,r,a)})),xc=Zn("<",(function(i,e,r){return e<r}),(function(i,e,r,a){return a.compare(e,r)<0})),vc=Zn(">",(function(i,e,r){return e>r}),(function(i,e,r,a){return a.compare(e,r)>0})),bc=Zn("<=",(function(i,e,r){return e<=r}),(function(i,e,r,a){return a.compare(e,r)<=0})),wc=Zn(">=",(function(i,e,r){return e>=r}),(function(i,e,r,a){return a.compare(e,r)>=0}));class qs{constructor(e,r,a,o,d){this.type=ot,this.number=e,this.locale=r,this.currency=a,this.minFractionDigits=o,this.maxFractionDigits=d}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");const a=r.parse(e[1],1,Ce);if(!a)return null;const o=e[2];if(typeof o!="object"||Array.isArray(o))return r.error("NumberFormat options argument must be an object.");let d=null;if(o.locale&&(d=r.parse(o.locale,1,ot),!d))return null;let f=null;if(o.currency&&(f=r.parse(o.currency,1,ot),!f))return null;let m=null;if(o["min-fraction-digits"]&&(m=r.parse(o["min-fraction-digits"],1,Ce),!m))return null;let y=null;return o["max-fraction-digits"]&&(y=r.parse(o["max-fraction-digits"],1,Ce),!y)?null:new qs(a,d,f,m,y)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class ts{constructor(e){this.type=U,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 o=[];let d=!1;for(let f=1;f<=e.length-1;++f){const m=e[f];if(d&&typeof m=="object"&&!Array.isArray(m)){d=!1;let y=null;if(m["font-scale"]&&(y=r.parse(m["font-scale"],1,Ce),!y))return null;let v=null;if(m["text-font"]&&(v=r.parse(m["text-font"],1,j(ot)),!v))return null;let S=null;if(m["text-color"]&&(S=r.parse(m["text-color"],1,Si),!S))return null;const A=o[o.length-1];A.scale=y,A.font=v,A.textColor=S}else{const y=r.parse(e[f],1,rt);if(!y)return null;const v=y.type.kind;if(v!=="string"&&v!=="value"&&v!=="null"&&v!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");d=!0,o.push({content:y,scale:null,font:null,textColor:null})}}return new ts(o)}evaluate(e){return new gi(this.sections.map((r=>{const a=r.content.evaluate(e);return Rt(a)===M?new Va("",a,null,null,null):new Va(yt(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 Zs{constructor(e){this.type=M,this.input=e}static parse(e,r){if(e.length!==2)return r.error("Expected two arguments.");const a=r.parse(e[1],1,ot);return a?new Zs(a):r.error("No image name provided.")}evaluate(e){const r=this.input.evaluate(e),a=hi.fromString(r);return a&&e.availableImages&&(a.available=e.availableImages.indexOf(r)>-1),a}eachChild(e){e(this.input)}outputDefined(){return!1}}class Gs{constructor(e){this.type=Ce,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 ${Z(a.type)} instead.`):new Gs(a):null}evaluate(e){const r=this.input.evaluate(e);if(typeof r=="string"||Array.isArray(r))return r.length;throw new $t(`Expected value to be of type string or array, but found ${Z(Rt(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Gn={"==":_c,"!=":yc,">":vc,"<":xc,">=":wc,"<=":bc,array:cr,at:Vs,boolean:cr,case:js,coalesce:Ya,collator:qa,format:ts,image:Zs,in:Us,"index-of":Qa,interpolate:Wi,"interpolate-hcl":Wi,"interpolate-lab":Wi,length:Gs,let:Ja,literal:yn,match:$s,number:cr,"number-format":qs,object:cr,slice:es,step:tn,string:cr,"to-boolean":Qr,"to-color":Qr,"to-number":Qr,"to-string":Qr,var:Ga,within:xn};function il(i,[e,r,a,o]){e=e.evaluate(i),r=r.evaluate(i),a=a.evaluate(i);const d=o?o.evaluate(i):1,f=Ua(e,r,a,d);if(f)throw new $t(f);return new wt(e/255,r/255,a/255,d,!1)}function rl(i,e){return i in e}function Hs(i,e){const r=e[i];return r===void 0?null:r}function vn(i){return{type:i}}function nl(i){return{result:"success",value:i}}function rn(i){return{result:"error",value:i}}function Hn(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function al(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function Ws(i){return!!i.expression&&i.expression.interpolated}function xt(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":i===null?"null":typeof i}function Bt(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function Sc(i){return i}function ft(i,e){const r=e.type==="color",a=i.stops&&typeof i.stops[0][0]=="object",o=a||!(a||i.property!==void 0),d=i.type||(Ws(e)?"exponential":"interval");if(r||e.type==="padding"){const S=r?wt.parse:Gi.parse;(i=wr({},i)).stops&&(i.stops=i.stops.map((A=>[A[0],S(A[1])]))),i.default=S(i.default?i.default:e.default)}if(i.colorSpace&&(f=i.colorSpace)!=="rgb"&&f!=="hcl"&&f!=="lab")throw new Error(`Unknown color space: "${i.colorSpace}"`);var f;let m,y,v;if(d==="exponential")m=fa;else if(d==="interval")m=Lt;else if(d==="categorical"){m=Ot,y=Object.create(null);for(const S of i.stops)y[S[0]]=S[1];v=typeof i.stops[0][0]}else{if(d!=="identity")throw new Error(`Unknown function type "${d}"`);m=sl}if(a){const S={},A=[];for(let D=0;D<i.stops.length;D++){const O=i.stops[D],q=O[0].zoom;S[q]===void 0&&(S[q]={zoom:q,type:i.type,property:i.property,default:i.default,stops:[]},A.push(q)),S[q].stops.push([O[0].value,O[1]])}const C=[];for(const D of A)C.push([S[D].zoom,ft(S[D],e)]);const z={name:"linear"};return{kind:"composite",interpolationType:z,interpolationFactor:Wi.interpolationFactor.bind(void 0,z),zoomStops:C.map((D=>D[0])),evaluate:({zoom:D},O)=>fa({stops:C,base:i.base},e,D).evaluate(D,O)}}if(o){const S=d==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:S,interpolationFactor:Wi.interpolationFactor.bind(void 0,S),zoomStops:i.stops.map((A=>A[0])),evaluate:({zoom:A})=>m(i,e,A,y,v)}}return{kind:"source",evaluate(S,A){const C=A&&A.properties?A.properties[i.property]:void 0;return C===void 0?bn(i.default,e.default):m(i,e,C,y,v)}}}function bn(i,e,r){return i!==void 0?i:e!==void 0?e:r!==void 0?r:void 0}function Ot(i,e,r,a,o){return bn(typeof r===o?a[r]:void 0,i.default,e.default)}function Lt(i,e,r){if(xt(r)!=="number")return bn(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 o=qn(i.stops.map((d=>d[0])),r);return i.stops[o][1]}function fa(i,e,r){const a=i.base!==void 0?i.base:1;if(xt(r)!=="number")return bn(i.default,e.default);const o=i.stops.length;if(o===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[o-1][0])return i.stops[o-1][1];const d=qn(i.stops.map((S=>S[0])),r),f=(function(S,A,C,z){const D=z-C,O=S-C;return D===0?0:A===1?O/D:(Math.pow(A,O)-1)/(Math.pow(A,D)-1)})(r,a,i.stops[d][0],i.stops[d+1][0]),m=i.stops[d][1],y=i.stops[d+1][1],v=Hi[e.type]||Sc;return typeof m.evaluate=="function"?{evaluate(...S){const A=m.evaluate.apply(void 0,S),C=y.evaluate.apply(void 0,S);if(A!==void 0&&C!==void 0)return v(A,C,f,i.colorSpace)}}:v(m,y,f,i.colorSpace)}function sl(i,e,r){switch(e.type){case"color":r=wt.parse(r);break;case"formatted":r=gi.fromString(r.toString());break;case"resolvedImage":r=hi.fromString(r.toString());break;case"padding":r=Gi.parse(r);break;default:xt(r)===e.type||e.type==="enum"&&e.values[r]||(r=void 0)}return bn(r,i.default,e.default)}ur.register(Gn,{error:[{kind:"error"},[ot],(i,[e])=>{throw new $t(e.evaluate(i))}],typeof:[ot,[rt],(i,[e])=>Z(Rt(e.evaluate(i)))],"to-rgba":[j(Ce,4),[Si],(i,[e])=>{const[r,a,o,d]=e.evaluate(i).rgb;return[255*r,255*a,255*o,d]}],rgb:[Si,[Ce,Ce,Ce],il],rgba:[Si,[Ce,Ce,Ce,Ce],il],has:{type:et,overloads:[[[ot],(i,[e])=>rl(e.evaluate(i),i.properties())],[[ot,Sr],(i,[e,r])=>rl(e.evaluate(i),r.evaluate(i))]]},get:{type:rt,overloads:[[[ot],(i,[e])=>Hs(e.evaluate(i),i.properties())],[[ot,Sr],(i,[e,r])=>Hs(e.evaluate(i),r.evaluate(i))]]},"feature-state":[rt,[ot],(i,[e])=>Hs(e.evaluate(i),i.featureState||{})],properties:[Sr,[],i=>i.properties()],"geometry-type":[ot,[],i=>i.geometryType()],id:[rt,[],i=>i.id()],zoom:[Ce,[],i=>i.globals.zoom],"heatmap-density":[Ce,[],i=>i.globals.heatmapDensity||0],"line-progress":[Ce,[],i=>i.globals.lineProgress||0],accumulated:[rt,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[Ce,vn(Ce),(i,e)=>{let r=0;for(const a of e)r+=a.evaluate(i);return r}],"*":[Ce,vn(Ce),(i,e)=>{let r=1;for(const a of e)r*=a.evaluate(i);return r}],"-":{type:Ce,overloads:[[[Ce,Ce],(i,[e,r])=>e.evaluate(i)-r.evaluate(i)],[[Ce],(i,[e])=>-e.evaluate(i)]]},"/":[Ce,[Ce,Ce],(i,[e,r])=>e.evaluate(i)/r.evaluate(i)],"%":[Ce,[Ce,Ce],(i,[e,r])=>e.evaluate(i)%r.evaluate(i)],ln2:[Ce,[],()=>Math.LN2],pi:[Ce,[],()=>Math.PI],e:[Ce,[],()=>Math.E],"^":[Ce,[Ce,Ce],(i,[e,r])=>Math.pow(e.evaluate(i),r.evaluate(i))],sqrt:[Ce,[Ce],(i,[e])=>Math.sqrt(e.evaluate(i))],log10:[Ce,[Ce],(i,[e])=>Math.log(e.evaluate(i))/Math.LN10],ln:[Ce,[Ce],(i,[e])=>Math.log(e.evaluate(i))],log2:[Ce,[Ce],(i,[e])=>Math.log(e.evaluate(i))/Math.LN2],sin:[Ce,[Ce],(i,[e])=>Math.sin(e.evaluate(i))],cos:[Ce,[Ce],(i,[e])=>Math.cos(e.evaluate(i))],tan:[Ce,[Ce],(i,[e])=>Math.tan(e.evaluate(i))],asin:[Ce,[Ce],(i,[e])=>Math.asin(e.evaluate(i))],acos:[Ce,[Ce],(i,[e])=>Math.acos(e.evaluate(i))],atan:[Ce,[Ce],(i,[e])=>Math.atan(e.evaluate(i))],min:[Ce,vn(Ce),(i,e)=>Math.min(...e.map((r=>r.evaluate(i))))],max:[Ce,vn(Ce),(i,e)=>Math.max(...e.map((r=>r.evaluate(i))))],abs:[Ce,[Ce],(i,[e])=>Math.abs(e.evaluate(i))],round:[Ce,[Ce],(i,[e])=>{const r=e.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[Ce,[Ce],(i,[e])=>Math.floor(e.evaluate(i))],ceil:[Ce,[Ce],(i,[e])=>Math.ceil(e.evaluate(i))],"filter-==":[et,[ot,rt],(i,[e,r])=>i.properties()[e.value]===r.value],"filter-id-==":[et,[rt],(i,[e])=>i.id()===e.value],"filter-type-==":[et,[ot],(i,[e])=>i.geometryType()===e.value],"filter-<":[et,[ot,rt],(i,[e,r])=>{const a=i.properties()[e.value],o=r.value;return typeof a==typeof o&&a<o}],"filter-id-<":[et,[rt],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r<a}],"filter->":[et,[ot,rt],(i,[e,r])=>{const a=i.properties()[e.value],o=r.value;return typeof a==typeof o&&a>o}],"filter-id->":[et,[rt],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r>a}],"filter-<=":[et,[ot,rt],(i,[e,r])=>{const a=i.properties()[e.value],o=r.value;return typeof a==typeof o&&a<=o}],"filter-id-<=":[et,[rt],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r<=a}],"filter->=":[et,[ot,rt],(i,[e,r])=>{const a=i.properties()[e.value],o=r.value;return typeof a==typeof o&&a>=o}],"filter-id->=":[et,[rt],(i,[e])=>{const r=i.id(),a=e.value;return typeof r==typeof a&&r>=a}],"filter-has":[et,[rt],(i,[e])=>e.value in i.properties()],"filter-has-id":[et,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[et,[j(ot)],(i,[e])=>e.value.indexOf(i.geometryType())>=0],"filter-id-in":[et,[j(rt)],(i,[e])=>e.value.indexOf(i.id())>=0],"filter-in-small":[et,[ot,j(rt)],(i,[e,r])=>r.value.indexOf(i.properties()[e.value])>=0],"filter-in-large":[et,[ot,j(rt)],(i,[e,r])=>(function(a,o,d,f){for(;d<=f;){const m=d+f>>1;if(o[m]===a)return!0;o[m]>a?f=m-1:d=m+1}return!1})(i.properties()[e.value],r.value,0,r.value.length-1)],all:{type:et,overloads:[[[et,et],(i,[e,r])=>e.evaluate(i)&&r.evaluate(i)],[vn(et),(i,e)=>{for(const r of e)if(!r.evaluate(i))return!1;return!0}]]},any:{type:et,overloads:[[[et,et],(i,[e,r])=>e.evaluate(i)||r.evaluate(i)],[vn(et),(i,e)=>{for(const r of e)if(r.evaluate(i))return!0;return!1}]]},"!":[et,[et],(i,[e])=>!e.evaluate(i)],"is-supported-script":[et,[ot],(i,[e])=>{const r=i.globals&&i.globals.isSupportedScript;return!r||r(e.evaluate(i))}],upcase:[ot,[ot],(i,[e])=>e.evaluate(i).toUpperCase()],downcase:[ot,[ot],(i,[e])=>e.evaluate(i).toLowerCase()],concat:[ot,vn(rt),(i,e)=>e.map((r=>yt(r.evaluate(i)))).join("")],"resolved-locale":[ot,[Rr],(i,[e])=>e.evaluate(i).resolvedLocale()]});class Xs{constructor(e,r){var a;this.expression=e,this._warningHistory={},this._evaluator=new Ds,this._defaultValue=r?(a=r).type==="color"&&Bt(a.default)?new wt(0,0,0,0):a.type==="color"?wt.parse(a.default)||null:a.type==="padding"?Gi.parse(a.default)||null:a.type==="variableAnchorOffsetCollection"?lr.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,o,d,f){return this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=a,this._evaluator.canonical=o,this._evaluator.availableImages=d||null,this._evaluator.formattedSection=f,this.expression.evaluate(this._evaluator)}evaluate(e,r,a,o,d,f){this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=a||null,this._evaluator.canonical=o,this._evaluator.availableImages=d||null,this._evaluator.formattedSection=f||null;try{const m=this.expression.evaluate(this._evaluator);if(m==null||typeof m=="number"&&m!=m)return this._defaultValue;if(this._enumValues&&!(m in this._enumValues))throw new $t(`Expected value to be one of ${Object.keys(this._enumValues).map((y=>JSON.stringify(y))).join(", ")}, but found ${JSON.stringify(m)} instead.`);return m}catch(m){return this._warningHistory[m.message]||(this._warningHistory[m.message]=!0,typeof console<"u"&&console.warn(m.message)),this._defaultValue}}}function is(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in Gn}function rs(i,e){const r=new ja(Gn,Ha,[],e?(function(o){const d={color:Si,string:ot,number:Ce,enum:ot,boolean:et,formatted:U,padding:k,resolvedImage:M,variableAnchorOffsetCollection:R};return o.type==="array"?j(d[o.value]||rt,o.length):d[o.type]})(e):void 0),a=r.parse(i,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return a?nl(new Xs(a,e)):rn(r.errors)}class Ks{constructor(e,r){this.kind=e,this._styleExpression=r,this.isStateDependent=e!=="constant"&&!da(r.expression)}evaluateWithoutErrorHandling(e,r,a,o,d,f){return this._styleExpression.evaluateWithoutErrorHandling(e,r,a,o,d,f)}evaluate(e,r,a,o,d,f){return this._styleExpression.evaluate(e,r,a,o,d,f)}}class ns{constructor(e,r,a,o){this.kind=e,this.zoomStops=a,this._styleExpression=r,this.isStateDependent=e!=="camera"&&!da(r.expression),this.interpolationType=o}evaluateWithoutErrorHandling(e,r,a,o,d,f){return this._styleExpression.evaluateWithoutErrorHandling(e,r,a,o,d,f)}evaluate(e,r,a,o,d,f){return this._styleExpression.evaluate(e,r,a,o,d,f)}interpolationFactor(e,r,a){return this.interpolationType?Wi.interpolationFactor(this.interpolationType,e,r,a):0}}function Ys(i,e){const r=rs(i,e);if(r.result==="error")return r;const a=r.value.expression,o=Wa(a);if(!o&&!Hn(e))return rn([new Ut("","data expressions not supported")]);const d=Xa(a,["zoom"]);if(!d&&!al(e))return rn([new Ut("","zoom expressions not supported")]);const f=ga(a);return f||d?f instanceof Ut?rn([f]):f instanceof Wi&&!Ws(e)?rn([new Ut("",'"interpolate" expressions cannot be used with this property')]):nl(f?new ns(o?"camera":"composite",r.value,f.labels,f instanceof Wi?f.interpolation:void 0):new Ks(o?"constant":"source",r.value)):rn([new Ut("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class ma{constructor(e,r){this._parameters=e,this._specification=r,wr(this,ft(this._parameters,this._specification))}static deserialize(e){return new ma(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function ga(i){let e=null;if(i instanceof Ja)e=ga(i.result);else if(i instanceof Ya){for(const r of i.args)if(e=ga(r),e)break}else(i instanceof tn||i instanceof Wi)&&i.input instanceof ur&&i.input.name==="zoom"&&(e=i);return e instanceof Ut||i.eachChild((r=>{const a=ga(r);a instanceof Ut?e=a:!e&&a?e=new Ut("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&a&&e!==a&&(e=new Ut("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function _a(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(!_a(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}const Tc={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Js(i){if(i==null)return{filter:()=>!0,needGeometry:!1};_a(i)||(i=as(i));const e=rs(i,Tc);if(e.result==="error")throw new Error(e.value.map((r=>`${r.key}: ${r.message}`)).join(", "));return{filter:(r,a,o)=>e.value.evaluate(r,a,{},o),needGeometry:ol(i)}}function Ic(i,e){return i<e?-1:i>e?1:0}function ol(i){if(!Array.isArray(i))return!1;if(i[0]==="within")return!0;for(let e=1;e<i.length;e++)if(ol(i[e]))return!0;return!1}function as(i){if(!i)return!0;const e=i[0];return i.length<=1?e!=="any":e==="=="?Qs(i[1],i[2],"=="):e==="!="?ya(Qs(i[1],i[2],"==")):e==="<"||e===">"||e==="<="||e===">="?Qs(i[1],i[2],e):e==="any"?(r=i.slice(1),["any"].concat(r.map(as))):e==="all"?["all"].concat(i.slice(1).map(as)):e==="none"?["all"].concat(i.slice(1).map(as).map(ya)):e==="in"?ll(i[1],i.slice(2)):e==="!in"?ya(ll(i[1],i.slice(2))):e==="has"?cl(i[1]):e==="!has"?ya(cl(i[1])):e!=="within"||i;var r}function Qs(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 ll(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 cl(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function ya(i){return["!",i]}function ss(i){const e=typeof i;if(e==="number"||e==="boolean"||e==="string"||i==null)return JSON.stringify(i);if(Array.isArray(i)){let o="[";for(const d of i)o+=`${ss(d)},`;return`${o}]`}const r=Object.keys(i).sort();let a="{";for(let o=0;o<r.length;o++)a+=`${JSON.stringify(r[o])}:${ss(i[r[o]])},`;return`${a}}`}function os(i){let e="";for(const r of Di)e+=`/${ss(i[r])}`;return e}function ul(i){const e=i.value;return e?[new Ae(i.key,e,"constants have been deprecated as of v8")]:[]}function jt(i){return i instanceof Number||i instanceof String||i instanceof Boolean?i.valueOf():i}function wn(i){if(Array.isArray(i))return i.map(wn);if(i instanceof Object&&!(i instanceof Number||i instanceof String||i instanceof Boolean)){const e={};for(const r in i)e[r]=wn(i[r]);return e}return jt(i)}function Li(i){const e=i.key,r=i.value,a=i.valueSpec||{},o=i.objectElementValidators||{},d=i.style,f=i.styleSpec,m=i.validateSpec;let y=[];const v=xt(r);if(v!=="object")return[new Ae(e,r,`object expected, ${v} found`)];for(const S in r){const A=S.split(".")[0],C=a[A]||a["*"];let z;if(o[A])z=o[A];else if(a[A])z=m;else if(o["*"])z=o["*"];else{if(!a["*"]){y.push(new Ae(e,r[S],`unknown property "${S}"`));continue}z=m}y=y.concat(z({key:(e&&`${e}.`)+S,value:r[S],valueSpec:C,style:d,styleSpec:f,object:r,objectKey:S,validateSpec:m},r))}for(const S in a)o[S]||a[S].required&&a[S].default===void 0&&r[S]===void 0&&y.push(new Ae(e,r,`missing required property "${S}"`));return y}function Wn(i){const e=i.value,r=i.valueSpec,a=i.style,o=i.styleSpec,d=i.key,f=i.arrayElementValidator||i.validateSpec;if(xt(e)!=="array")return[new Ae(d,e,`array expected, ${xt(e)} found`)];if(r.length&&e.length!==r.length)return[new Ae(d,e,`array length ${r.length} expected, length ${e.length} found`)];if(r["min-length"]&&e.length<r["min-length"])return[new Ae(d,e,`array length at least ${r["min-length"]} expected, length ${e.length} found`)];let m={type:r.value,values:r.values};o.$version<7&&(m.function=r.function),xt(r.value)==="object"&&(m=r.value);let y=[];for(let v=0;v<e.length;v++)y=y.concat(f({array:e,arrayIndex:v,value:e[v],valueSpec:m,validateSpec:i.validateSpec,style:a,styleSpec:o,key:`${d}[${v}]`}));return y}function xa(i){const e=i.key,r=i.value,a=i.valueSpec;let o=xt(r);return o==="number"&&r!=r&&(o="NaN"),o!=="number"?[new Ae(e,r,`number expected, ${o} found`)]:"minimum"in a&&r<a.minimum?[new Ae(e,r,`${r} is less than the minimum value ${a.minimum}`)]:"maximum"in a&&r>a.maximum?[new Ae(e,r,`${r} is greater than the maximum value ${a.maximum}`)]:[]}function ls(i){const e=i.valueSpec,r=jt(i.value.type);let a,o,d,f={};const m=r!=="categorical"&&i.value.property===void 0,y=!m,v=xt(i.value.stops)==="array"&&xt(i.value.stops[0])==="array"&&xt(i.value.stops[0][0])==="object",S=Li({key:i.key,value:i.value,valueSpec:i.styleSpec.function,validateSpec:i.validateSpec,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(z){if(r==="identity")return[new Ae(z.key,z.value,'identity function may not have a "stops" property')];let D=[];const O=z.value;return D=D.concat(Wn({key:z.key,value:O,valueSpec:z.valueSpec,validateSpec:z.validateSpec,style:z.style,styleSpec:z.styleSpec,arrayElementValidator:A})),xt(O)==="array"&&O.length===0&&D.push(new Ae(z.key,O,"array must have at least one stop")),D},default:function(z){return z.validateSpec({key:z.key,value:z.value,valueSpec:e,validateSpec:z.validateSpec,style:z.style,styleSpec:z.styleSpec})}}});return r==="identity"&&m&&S.push(new Ae(i.key,i.value,'missing required property "property"')),r==="identity"||i.value.stops||S.push(new Ae(i.key,i.value,'missing required property "stops"')),r==="exponential"&&i.valueSpec.expression&&!Ws(i.valueSpec)&&S.push(new Ae(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(y&&!Hn(i.valueSpec)?S.push(new Ae(i.key,i.value,"property functions not supported")):m&&!al(i.valueSpec)&&S.push(new Ae(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!v||i.value.property!==void 0||S.push(new Ae(i.key,i.value,'"property" property is required')),S;function A(z){let D=[];const O=z.value,q=z.key;if(xt(O)!=="array")return[new Ae(q,O,`array expected, ${xt(O)} found`)];if(O.length!==2)return[new Ae(q,O,`array length 2 expected, length ${O.length} found`)];if(v){if(xt(O[0])!=="object")return[new Ae(q,O,`object expected, ${xt(O[0])} found`)];if(O[0].zoom===void 0)return[new Ae(q,O,"object stop key must have zoom")];if(O[0].value===void 0)return[new Ae(q,O,"object stop key must have value")];if(d&&d>jt(O[0].zoom))return[new Ae(q,O[0].zoom,"stop zoom values must appear in ascending order")];jt(O[0].zoom)!==d&&(d=jt(O[0].zoom),o=void 0,f={}),D=D.concat(Li({key:`${q}[0]`,value:O[0],valueSpec:{zoom:{}},validateSpec:z.validateSpec,style:z.style,styleSpec:z.styleSpec,objectElementValidators:{zoom:xa,value:C}}))}else D=D.concat(C({key:`${q}[0]`,value:O[0],validateSpec:z.validateSpec,style:z.style,styleSpec:z.styleSpec},O));return is(wn(O[1]))?D.concat([new Ae(`${q}[1]`,O[1],"expressions are not allowed in function stops.")]):D.concat(z.validateSpec({key:`${q}[1]`,value:O[1],valueSpec:e,validateSpec:z.validateSpec,style:z.style,styleSpec:z.styleSpec}))}function C(z,D){const O=xt(z.value),q=jt(z.value),H=z.value!==null?z.value:D;if(a){if(O!==a)return[new Ae(z.key,H,`${O} stop domain type must match previous stop domain type ${a}`)]}else a=O;if(O!=="number"&&O!=="string"&&O!=="boolean")return[new Ae(z.key,H,"stop domain value must be a number, string, or boolean")];if(O!=="number"&&r!=="categorical"){let re=`number expected, ${O} found`;return Hn(e)&&r===void 0&&(re+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ae(z.key,H,re)]}return r!=="categorical"||O!=="number"||isFinite(q)&&Math.floor(q)===q?r!=="categorical"&&O==="number"&&o!==void 0&&q<o?[new Ae(z.key,H,"stop domain values must appear in ascending order")]:(o=q,r==="categorical"&&q in f?[new Ae(z.key,H,"stop domain values must be unique")]:(f[q]=!0,[])):[new Ae(z.key,H,`integer expected, found ${q}`)]}}function Sn(i){const e=(i.expressionContext==="property"?Ys:rs)(wn(i.value),i.valueSpec);if(e.result==="error")return e.value.map((a=>new Ae(`${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 Ae(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"&&!da(r))return[new Ae(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter"&&!da(r))return[new Ae(i.key,i.value,'"feature-state" data expressions are not supported with filters.')];if(i.expressionContext&&i.expressionContext.indexOf("cluster")===0){if(!Xa(r,["zoom","feature-state"]))return[new Ae(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(i.expressionContext==="cluster-initial"&&!Wa(r))return[new Ae(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function va(i){const e=i.key,r=i.value,a=i.valueSpec,o=[];return Array.isArray(a.values)?a.values.indexOf(jt(r))===-1&&o.push(new Ae(e,r,`expected one of [${a.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(a.values).indexOf(jt(r))===-1&&o.push(new Ae(e,r,`expected one of [${Object.keys(a.values).join(", ")}], ${JSON.stringify(r)} found`)),o}function Xn(i){return _a(wn(i.value))?Sn(wr({},i,{expressionContext:"filter",valueSpec:{value:"boolean"}})):hl(i)}function hl(i){const e=i.value,r=i.key;if(xt(e)!=="array")return[new Ae(r,e,`array expected, ${xt(e)} found`)];const a=i.styleSpec;let o,d=[];if(e.length<1)return[new Ae(r,e,"filter array must have at least 1 element")];switch(d=d.concat(va({key:`${r}[0]`,value:e[0],valueSpec:a.filter_operator,style:i.style,styleSpec:i.styleSpec})),jt(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&jt(e[1])==="$type"&&d.push(new Ae(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&d.push(new Ae(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(o=xt(e[1]),o!=="string"&&d.push(new Ae(`${r}[1]`,e[1],`string expected, ${o} found`)));for(let f=2;f<e.length;f++)o=xt(e[f]),jt(e[1])==="$type"?d=d.concat(va({key:`${r}[${f}]`,value:e[f],valueSpec:a.geometry_type,style:i.style,styleSpec:i.styleSpec})):o!=="string"&&o!=="number"&&o!=="boolean"&&d.push(new Ae(`${r}[${f}]`,e[f],`string, number, or boolean expected, ${o} found`));break;case"any":case"all":case"none":for(let f=1;f<e.length;f++)d=d.concat(hl({key:`${r}[${f}]`,value:e[f],style:i.style,styleSpec:i.styleSpec}));break;case"has":case"!has":o=xt(e[1]),e.length!==2?d.push(new Ae(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):o!=="string"&&d.push(new Ae(`${r}[1]`,e[1],`string expected, ${o} found`));break;case"within":o=xt(e[1]),e.length!==2?d.push(new Ae(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):o!=="object"&&d.push(new Ae(`${r}[1]`,e[1],`object expected, ${o} found`))}return d}function pl(i,e){const r=i.key,a=i.validateSpec,o=i.style,d=i.styleSpec,f=i.value,m=i.objectKey,y=d[`${e}_${i.layerType}`];if(!y)return[];const v=m.match(/^(.*)-transition$/);if(e==="paint"&&v&&y[v[1]]&&y[v[1]].transition)return a({key:r,value:f,valueSpec:d.transition,style:o,styleSpec:d});const S=i.valueSpec||y[m];if(!S)return[new Ae(r,f,`unknown property "${m}"`)];let A;if(xt(f)==="string"&&Hn(S)&&!S.tokens&&(A=/^{([^}]+)}$/.exec(f)))return[new Ae(r,f,`"${m}" does not support interpolation syntax
Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(A[1])} }\`.`)];const C=[];return i.layerType==="symbol"&&(m==="text-field"&&o&&!o.glyphs&&C.push(new Ae(r,f,'use of "text-field" requires a style "glyphs" property')),m==="text-font"&&Bt(wn(f))&&jt(f.type)==="identity"&&C.push(new Ae(r,f,'"text-font" does not support identity functions'))),C.concat(a({key:i.key,value:f,valueSpec:S,style:o,styleSpec:d,expressionContext:"property",propertyType:e,propertyKey:m}))}function dl(i){return pl(i,"paint")}function fl(i){return pl(i,"layout")}function ml(i){let e=[];const r=i.value,a=i.key,o=i.style,d=i.styleSpec;r.type||r.ref||e.push(new Ae(a,r,'either "type" or "ref" is required'));let f=jt(r.type);const m=jt(r.ref);if(r.id){const y=jt(r.id);for(let v=0;v<i.arrayIndex;v++){const S=o.layers[v];jt(S.id)===y&&e.push(new Ae(a,r.id,`duplicate layer id "${r.id}", previously used at line ${S.id.__line__}`))}}if("ref"in r){let y;["type","source","source-layer","filter","layout"].forEach((v=>{v in r&&e.push(new Ae(a,r[v],`"${v}" is prohibited for ref layers`))})),o.layers.forEach((v=>{jt(v.id)===m&&(y=v)})),y?y.ref?e.push(new Ae(a,r.ref,"ref cannot reference another ref layer")):f=jt(y.type):e.push(new Ae(a,r.ref,`ref layer "${m}" not found`))}else if(f!=="background")if(r.source){const y=o.sources&&o.sources[r.source],v=y&&jt(y.type);y?v==="vector"&&f==="raster"?e.push(new Ae(a,r.source,`layer "${r.id}" requires a raster source`)):v!=="raster-dem"&&f==="hillshade"?e.push(new Ae(a,r.source,`layer "${r.id}" requires a raster-dem source`)):v==="raster"&&f!=="raster"?e.push(new Ae(a,r.source,`layer "${r.id}" requires a vector source`)):v!=="vector"||r["source-layer"]?v==="raster-dem"&&f!=="hillshade"?e.push(new Ae(a,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):f!=="line"||!r.paint||!r.paint["line-gradient"]||v==="geojson"&&y.lineMetrics||e.push(new Ae(a,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Ae(a,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new Ae(a,r.source,`source "${r.source}" not found`))}else e.push(new Ae(a,r,'missing required property "source"'));return e=e.concat(Li({key:a,value:r,valueSpec:d.layer,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,objectElementValidators:{"*":()=>[],type:()=>i.validateSpec({key:`${a}.type`,value:r.type,valueSpec:d.layer.type,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,object:r,objectKey:"type"}),filter:Xn,layout:y=>Li({layer:r,key:y.key,value:y.value,style:y.style,styleSpec:y.styleSpec,validateSpec:y.validateSpec,objectElementValidators:{"*":v=>fl(wr({layerType:f},v))}}),paint:y=>Li({layer:r,key:y.key,value:y.value,style:y.style,styleSpec:y.styleSpec,validateSpec:y.validateSpec,objectElementValidators:{"*":v=>dl(wr({layerType:f},v))}})}})),e}function Tr(i){const e=i.value,r=i.key,a=xt(e);return a!=="string"?[new Ae(r,e,`string expected, ${a} found`)]:[]}const ba={promoteId:function({key:i,value:e}){if(xt(e)==="string")return Tr({key:i,value:e});{const r=[];for(const a in e)r.push(...Tr({key:`${i}.${a}`,value:e[a]}));return r}}};function Xi(i){const e=i.value,r=i.key,a=i.styleSpec,o=i.style,d=i.validateSpec;if(!e.type)return[new Ae(r,e,'"type" is required')];const f=jt(e.type);let m;switch(f){case"vector":case"raster":return m=Li({key:r,value:e,valueSpec:a[`source_${f.replace("-","_")}`],style:i.style,styleSpec:a,objectElementValidators:ba,validateSpec:d}),m;case"raster-dem":return m=(function(y){var v;const S=(v=y.sourceName)!==null&&v!==void 0?v:"",A=y.value,C=y.styleSpec,z=C.source_raster_dem,D=y.style;let O=[];const q=xt(A);if(A===void 0)return O;if(q!=="object")return O.push(new Ae("source_raster_dem",A,`object expected, ${q} found`)),O;const H=jt(A.encoding)==="custom",re=["redFactor","greenFactor","blueFactor","baseShift"],Y=y.value.encoding?`"${y.value.encoding}"`:"Default";for(const ae in A)!H&&re.includes(ae)?O.push(new Ae(ae,A[ae],`In "${S}": "${ae}" is only valid when "encoding" is set to "custom". ${Y} encoding found`)):z[ae]?O=O.concat(y.validateSpec({key:ae,value:A[ae],valueSpec:z[ae],validateSpec:y.validateSpec,style:D,styleSpec:C})):O.push(new Ae(ae,A[ae],`unknown property "${ae}"`));return O})({sourceName:r,value:e,style:i.style,styleSpec:a,validateSpec:d}),m;case"geojson":if(m=Li({key:r,value:e,valueSpec:a.source_geojson,style:o,styleSpec:a,validateSpec:d,objectElementValidators:ba}),e.cluster)for(const y in e.clusterProperties){const[v,S]=e.clusterProperties[y],A=typeof v=="string"?[v,["accumulated"],["get",y]]:v;m.push(...Sn({key:`${r}.${y}.map`,value:S,expressionContext:"cluster-map"})),m.push(...Sn({key:`${r}.${y}.reduce`,value:A,expressionContext:"cluster-reduce"}))}return m;case"video":return Li({key:r,value:e,valueSpec:a.source_video,style:o,validateSpec:d,styleSpec:a});case"image":return Li({key:r,value:e,valueSpec:a.source_image,style:o,validateSpec:d,styleSpec:a});case"canvas":return[new Ae(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return va({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function wa(i){const e=i.value,r=i.styleSpec,a=r.light,o=i.style;let d=[];const f=xt(e);if(e===void 0)return d;if(f!=="object")return d=d.concat([new Ae("light",e,`object expected, ${f} found`)]),d;for(const m in e){const y=m.match(/^(.*)-transition$/);d=d.concat(y&&a[y[1]]&&a[y[1]].transition?i.validateSpec({key:m,value:e[m],valueSpec:r.transition,validateSpec:i.validateSpec,style:o,styleSpec:r}):a[m]?i.validateSpec({key:m,value:e[m],valueSpec:a[m],validateSpec:i.validateSpec,style:o,styleSpec:r}):[new Ae(m,e[m],`unknown property "${m}"`)])}return d}function gl(i){const e=i.value,r=i.styleSpec,a=r.terrain,o=i.style;let d=[];const f=xt(e);if(e===void 0)return d;if(f!=="object")return d=d.concat([new Ae("terrain",e,`object expected, ${f} found`)]),d;for(const m in e)d=d.concat(a[m]?i.validateSpec({key:m,value:e[m],valueSpec:a[m],validateSpec:i.validateSpec,style:o,styleSpec:r}):[new Ae(m,e[m],`unknown property "${m}"`)]);return d}function _l(i){let e=[];const r=i.value,a=i.key;if(Array.isArray(r)){const o=[],d=[];for(const f in r)r[f].id&&o.includes(r[f].id)&&e.push(new Ae(a,r,`all the sprites' ids must be unique, but ${r[f].id} is duplicated`)),o.push(r[f].id),r[f].url&&d.includes(r[f].url)&&e.push(new Ae(a,r,`all the sprites' URLs must be unique, but ${r[f].url} is duplicated`)),d.push(r[f].url),e=e.concat(Li({key:`${a}[${f}]`,value:r[f],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:i.validateSpec}));return e}return Tr({key:a,value:r})}const yl={"*":()=>[],array:Wn,boolean:function(i){const e=i.value,r=i.key,a=xt(e);return a!=="boolean"?[new Ae(r,e,`boolean expected, ${a} found`)]:[]},number:xa,color:function(i){const e=i.key,r=i.value,a=xt(r);return a!=="string"?[new Ae(e,r,`color expected, ${a} found`)]:wt.parse(String(r))?[]:[new Ae(e,r,`color expected, "${r}" found`)]},constants:ul,enum:va,filter:Xn,function:ls,layer:ml,object:Li,source:Xi,light:wa,terrain:gl,string:Tr,formatted:function(i){return Tr(i).length===0?[]:Sn(i)},resolvedImage:function(i){return Tr(i).length===0?[]:Sn(i)},padding:function(i){const e=i.key,r=i.value;if(xt(r)==="array"){if(r.length<1||r.length>4)return[new Ae(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const a={type:"number"};let o=[];for(let d=0;d<r.length;d++)o=o.concat(i.validateSpec({key:`${e}[${d}]`,value:r[d],validateSpec:i.validateSpec,valueSpec:a}));return o}return xa({key:e,value:r,valueSpec:{}})},variableAnchorOffsetCollection:function(i){const e=i.key,r=i.value,a=xt(r),o=i.styleSpec;if(a!=="array"||r.length<1||r.length%2!=0)return[new Ae(e,r,"variableAnchorOffsetCollection requires a non-empty array of even length")];let d=[];for(let f=0;f<r.length;f+=2)d=d.concat(va({key:`${e}[${f}]`,value:r[f],valueSpec:o.layout_symbol["text-anchor"]})),d=d.concat(Wn({key:`${e}[${f+1}]`,value:r[f+1],valueSpec:{length:2,value:"number"},validateSpec:i.validateSpec,style:i.style,styleSpec:o}));return d},sprite:_l};function nn(i){const e=i.value,r=i.valueSpec,a=i.styleSpec;return i.validateSpec=nn,r.expression&&Bt(jt(e))?ls(i):r.expression&&is(wn(e))?Sn(i):r.type&&yl[r.type]?yl[r.type](i):Li(wr({},i,{valueSpec:r.type?a[r.type]:r}))}function xl(i){const e=i.value,r=i.key,a=Tr(i);return a.length||(e.indexOf("{fontstack}")===-1&&a.push(new Ae(r,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&a.push(new Ae(r,e,'"glyphs" url must include a "{range}" token'))),a}function hr(i,e=he){let r=[];return r=r.concat(nn({key:"",value:i,valueSpec:e.$root,styleSpec:e,style:i,validateSpec:nn,objectElementValidators:{glyphs:xl,"*":()=>[]}})),i.constants&&(r=r.concat(ul({key:"constants",value:i.constants}))),cs(r)}function Br(i){return function(e){return i({...e,validateSpec:nn})}}function cs(i){return[].concat(i).sort(((e,r)=>e.line-r.line))}function Or(i){return function(...e){return cs(i.apply(this,e))}}hr.source=Or(Br(Xi)),hr.sprite=Or(Br(_l)),hr.glyphs=Or(Br(xl)),hr.light=Or(Br(wa)),hr.terrain=Or(Br(gl)),hr.layer=Or(Br(ml)),hr.filter=Or(Br(Xn)),hr.paintProperty=Or(Br(dl)),hr.layoutProperty=Or(Br(fl));const Nr=hr,Ac=Nr.light,eo=Nr.paintProperty,vl=Nr.layoutProperty;function us(i,e){let r=!1;if(e&&e.length)for(const a of e)i.fire(new Yr(new Error(a.message))),r=!0;return r}class Kn{constructor(e,r,a){const o=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const f=new Int32Array(this.arrayBuffer);e=f[0],this.d=(r=f[1])+2*(a=f[2]);for(let y=0;y<this.d*this.d;y++){const v=f[3+y],S=f[3+y+1];o.push(v===S?null:f.subarray(v,S))}const m=f[3+o.length+1];this.keys=f.subarray(f[3+o.length],m),this.bboxes=f.subarray(m),this.insert=this._insertReadonly}else{this.d=r+2*a;for(let f=0;f<this.d*this.d;f++)o.push([]);this.keys=[],this.bboxes=[]}this.n=r,this.extent=e,this.padding=a,this.scale=r/e,this.uid=0;const d=a/r*e;this.min=-d,this.max=e+d}insert(e,r,a,o,d){this._forEachCell(r,a,o,d,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(r),this.bboxes.push(a),this.bboxes.push(o),this.bboxes.push(d)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,r,a,o,d,f){this.cells[d].push(f)}query(e,r,a,o,d){const f=this.min,m=this.max;if(e<=f&&r<=f&&m<=a&&m<=o&&!d)return Array.prototype.slice.call(this.keys);{const y=[];return this._forEachCell(e,r,a,o,this._queryCell,y,{},d),y}}_queryCell(e,r,a,o,d,f,m,y){const v=this.cells[d];if(v!==null){const S=this.keys,A=this.bboxes;for(let C=0;C<v.length;C++){const z=v[C];if(m[z]===void 0){const D=4*z;(y?y(A[D+0],A[D+1],A[D+2],A[D+3]):e<=A[D+2]&&r<=A[D+3]&&a>=A[D+0]&&o>=A[D+1])?(m[z]=!0,f.push(S[z])):m[z]=!1}}}}_forEachCell(e,r,a,o,d,f,m,y){const v=this._convertToCellCoord(e),S=this._convertToCellCoord(r),A=this._convertToCellCoord(a),C=this._convertToCellCoord(o);for(let z=v;z<=A;z++)for(let D=S;D<=C;D++){const O=this.d*D+z;if((!y||y(this._convertFromCellCoord(z),this._convertFromCellCoord(D),this._convertFromCellCoord(z+1),this._convertFromCellCoord(D+1)))&&d.call(this,e,r,a,o,O,f,m,y))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,r=3+this.cells.length+1+1;let a=0;for(let f=0;f<this.cells.length;f++)a+=this.cells[f].length;const o=new Int32Array(r+a+this.keys.length+this.bboxes.length);o[0]=this.extent,o[1]=this.n,o[2]=this.padding;let d=r;for(let f=0;f<e.length;f++){const m=e[f];o[3+f]=d,o.set(m,d),d+=m.length}return o[3+e.length]=d,o.set(this.keys,d),d+=this.keys.length,o[3+e.length+1]=d,o.set(this.bboxes,d),d+=this.bboxes.length,o.buffer}static serialize(e,r){const a=e.toArrayBuffer();return r&&r.push(a),{buffer:a}}static deserialize(e){return new Kn(e.buffer)}}const Vr={};function Le(i,e,r={}){if(Vr[i])throw new Error(`${i} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:i,writeable:!1}),Vr[i]={klass:e,omit:r.omit||[],shallow:r.shallow||[]}}Le("Object",Object),Le("TransferableGridIndex",Kn),Le("Color",wt),Le("Error",Error),Le("AJAXError",Wr),Le("ResolvedImage",hi),Le("StylePropertyFunction",ma),Le("StyleExpression",Xs,{omit:["_evaluator"]}),Le("ZoomDependentExpression",ns),Le("ZoomConstantExpression",Ks),Le("CompoundExpression",ur,{omit:["_evaluate"]});for(const i in Gn)Gn[i]._classRegistryKey||Le(`Expression_${i}`,Gn[i]);function hs(i){return i&&typeof ArrayBuffer<"u"&&(i instanceof ArrayBuffer||i.constructor&&i.constructor.name==="ArrayBuffer")}function an(i,e){if(i==null||typeof i=="boolean"||typeof i=="number"||typeof i=="string"||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||i instanceof Blob)return i;if(hs(i)||la(i))return e&&e.push(i),i;if(ArrayBuffer.isView(i)){const r=i;return e&&e.push(r.buffer),r}if(i instanceof ImageData)return e&&e.push(i.data.buffer),i;if(Array.isArray(i)){const r=[];for(const a of i)r.push(an(a,e));return r}if(typeof i=="object"){const r=i.constructor,a=r._classRegistryKey;if(!a)throw new Error("can't serialize object of unregistered class");if(!Vr[a])throw new Error(`${a} is not registered.`);const o=r.serialize?r.serialize(i,e):{};if(r.serialize){if(e&&o===e[e.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const d in i){if(!i.hasOwnProperty(d)||Vr[a].omit.indexOf(d)>=0)continue;const f=i[d];o[d]=Vr[a].shallow.indexOf(d)>=0?f:an(f,e)}i instanceof Error&&(o.message=i.message)}if(o.$name)throw new Error("$name property is reserved for worker serialization logic.");return a!=="Object"&&(o.$name=a),o}throw new Error("can't serialize object of type "+typeof i)}function Yn(i){if(i==null||typeof i=="boolean"||typeof i=="number"||typeof i=="string"||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||i instanceof Blob||hs(i)||la(i)||ArrayBuffer.isView(i)||i instanceof ImageData)return i;if(Array.isArray(i))return i.map(Yn);if(typeof i=="object"){const e=i.$name||"Object";if(!Vr[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=Vr[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(i);const a=Object.create(r.prototype);for(const o of Object.keys(i)){if(o==="$name")continue;const d=i[o];a[o]=Vr[e].shallow.indexOf(o)>=0?d:Yn(d)}return a}throw new Error("can't deserialize object of type "+typeof i)}class bl{constructor(){this.first=!0}update(e,r){const a=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=a,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=a,!0):(this.lastFloorZoom>a?(this.lastIntegerZoom=a+1,this.lastIntegerZoomTime=r):this.lastFloorZoom<a&&(this.lastIntegerZoom=a,this.lastIntegerZoomTime=r),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=a,!0))}}const ze={"Latin-1 Supplement":i=>i>=128&&i<=255,Arabic:i=>i>=1536&&i<=1791,"Arabic Supplement":i=>i>=1872&&i<=1919,"Arabic Extended-A":i=>i>=2208&&i<=2303,"Hangul Jamo":i=>i>=4352&&i<=4607,"Unified Canadian Aboriginal Syllabics":i=>i>=5120&&i<=5759,Khmer:i=>i>=6016&&i<=6143,"Unified Canadian Aboriginal Syllabics Extended":i=>i>=6320&&i<=6399,"General Punctuation":i=>i>=8192&&i<=8303,"Letterlike Symbols":i=>i>=8448&&i<=8527,"Number Forms":i=>i>=8528&&i<=8591,"Miscellaneous Technical":i=>i>=8960&&i<=9215,"Control Pictures":i=>i>=9216&&i<=9279,"Optical Character Recognition":i=>i>=9280&&i<=9311,"Enclosed Alphanumerics":i=>i>=9312&&i<=9471,"Geometric Shapes":i=>i>=9632&&i<=9727,"Miscellaneous Symbols":i=>i>=9728&&i<=9983,"Miscellaneous Symbols and Arrows":i=>i>=11008&&i<=11263,"CJK Radicals Supplement":i=>i>=11904&&i<=12031,"Kangxi Radicals":i=>i>=12032&&i<=12255,"Ideographic Description Characters":i=>i>=12272&&i<=12287,"CJK Symbols and Punctuation":i=>i>=12288&&i<=12351,Hiragana:i=>i>=12352&&i<=12447,Katakana:i=>i>=12448&&i<=12543,Bopomofo:i=>i>=12544&&i<=12591,"Hangul Compatibility Jamo":i=>i>=12592&&i<=12687,Kanbun:i=>i>=12688&&i<=12703,"Bopomofo Extended":i=>i>=12704&&i<=12735,"CJK Strokes":i=>i>=12736&&i<=12783,"Katakana Phonetic Extensions":i=>i>=12784&&i<=12799,"Enclosed CJK Letters and Months":i=>i>=12800&&i<=13055,"CJK Compatibility":i=>i>=13056&&i<=13311,"CJK Unified Ideographs Extension A":i=>i>=13312&&i<=19903,"Yijing Hexagram Symbols":i=>i>=19904&&i<=19967,"CJK Unified Ideographs":i=>i>=19968&&i<=40959,"Yi Syllables":i=>i>=40960&&i<=42127,"Yi Radicals":i=>i>=42128&&i<=42191,"Hangul Jamo Extended-A":i=>i>=43360&&i<=43391,"Hangul Syllables":i=>i>=44032&&i<=55215,"Hangul Jamo Extended-B":i=>i>=55216&&i<=55295,"Private Use Area":i=>i>=57344&&i<=63743,"CJK Compatibility Ideographs":i=>i>=63744&&i<=64255,"Arabic Presentation Forms-A":i=>i>=64336&&i<=65023,"Vertical Forms":i=>i>=65040&&i<=65055,"CJK Compatibility Forms":i=>i>=65072&&i<=65103,"Small Form Variants":i=>i>=65104&&i<=65135,"Arabic Presentation Forms-B":i=>i>=65136&&i<=65279,"Halfwidth and Fullwidth Forms":i=>i>=65280&&i<=65519};function to(i){for(const e of i)if(ro(e.charCodeAt(0)))return!0;return!1}function io(i){for(const e of i)if(!kc(e.charCodeAt(0)))return!1;return!0}function kc(i){return!(ze.Arabic(i)||ze["Arabic Supplement"](i)||ze["Arabic Extended-A"](i)||ze["Arabic Presentation Forms-A"](i)||ze["Arabic Presentation Forms-B"](i))}function ro(i){return!(i!==746&&i!==747&&(i<4352||!(ze["Bopomofo Extended"](i)||ze.Bopomofo(i)||ze["CJK Compatibility Forms"](i)&&!(i>=65097&&i<=65103)||ze["CJK Compatibility Ideographs"](i)||ze["CJK Compatibility"](i)||ze["CJK Radicals Supplement"](i)||ze["CJK Strokes"](i)||!(!ze["CJK Symbols and Punctuation"](i)||i>=12296&&i<=12305||i>=12308&&i<=12319||i===12336)||ze["CJK Unified Ideographs Extension A"](i)||ze["CJK Unified Ideographs"](i)||ze["Enclosed CJK Letters and Months"](i)||ze["Hangul Compatibility Jamo"](i)||ze["Hangul Jamo Extended-A"](i)||ze["Hangul Jamo Extended-B"](i)||ze["Hangul Jamo"](i)||ze["Hangul Syllables"](i)||ze.Hiragana(i)||ze["Ideographic Description Characters"](i)||ze.Kanbun(i)||ze["Kangxi Radicals"](i)||ze["Katakana Phonetic Extensions"](i)||ze.Katakana(i)&&i!==12540||!(!ze["Halfwidth and Fullwidth Forms"](i)||i===65288||i===65289||i===65293||i>=65306&&i<=65310||i===65339||i===65341||i===65343||i>=65371&&i<=65503||i===65507||i>=65512&&i<=65519)||!(!ze["Small Form Variants"](i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||ze["Unified Canadian Aboriginal Syllabics"](i)||ze["Unified Canadian Aboriginal Syllabics Extended"](i)||ze["Vertical Forms"](i)||ze["Yijing Hexagram Symbols"](i)||ze["Yi Syllables"](i)||ze["Yi Radicals"](i))))}function wl(i){return!(ro(i)||(function(e){return!!(ze["Latin-1 Supplement"](e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||ze["General Punctuation"](e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||ze["Letterlike Symbols"](e)||ze["Number Forms"](e)||ze["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||ze["Control Pictures"](e)&&e!==9251||ze["Optical Character Recognition"](e)||ze["Enclosed Alphanumerics"](e)||ze["Geometric Shapes"](e)||ze["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||ze["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||ze["CJK Symbols and Punctuation"](e)||ze.Katakana(e)||ze["Private Use Area"](e)||ze["CJK Compatibility Forms"](e)||ze["Small Form Variants"](e)||ze["Halfwidth and Fullwidth Forms"](e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)})(i))}function Sl(i){return i>=1424&&i<=2303||ze["Arabic Presentation Forms-A"](i)||ze["Arabic Presentation Forms-B"](i)}function Tl(i,e){return!(!e&&Sl(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||ze.Khmer(i))}function Cc(i){for(const e of i)if(Sl(e.charCodeAt(0)))return!0;return!1}const no="deferred",ao="loading",so="loaded";let oo=null,Fi="unavailable",sn=null;const Sa=function(i){i&&typeof i=="string"&&i.indexOf("NetworkError")>-1&&(Fi="error"),oo&&oo(i)};function lo(){Ta.fire(new Kr("pluginStateChange",{pluginStatus:Fi,pluginURL:sn}))}const Ta=new mn,co=function(){return Fi},Il=function(){if(Fi!==no||!sn)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Fi=ao,lo(),sn&&ha({url:sn},(i=>{i?Sa(i):(Fi=so,lo())}))},Ki={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Fi===so||Ki.applyArabicShaping!=null,isLoading:()=>Fi===ao,setState(i){if(!nr())throw new Error("Cannot set the state of the rtl-text-plugin when not in the web-worker context");Fi=i.pluginStatus,sn=i.pluginURL},isParsed(){if(!nr())throw new Error("rtl-text-plugin is only parsed on the worker-threads");return Ki.applyArabicShaping!=null&&Ki.processBidirectionalText!=null&&Ki.processStyledBidirectionalText!=null},getPluginURL(){if(!nr())throw new Error("rtl-text-plugin url can only be queried from the worker threads");return sn}};class Mt{constructor(e,r){this.zoom=e,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new bl,this.transition={})}isSupportedScript(e){return(function(r,a){for(const o of r)if(!Tl(o.charCodeAt(0),a))return!1;return!0})(e,Ki.isLoaded())}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,r=e-Math.floor(e),a=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*a}:{fromScale:.5,toScale:1,t:1-(1-a)*r}}}class ps{constructor(e,r){this.property=e,this.value=r,this.expression=(function(a,o){if(Bt(a))return new ma(a,o);if(is(a)){const d=Ys(a,o);if(d.result==="error")throw new Error(d.value.map((f=>`${f.key}: ${f.message}`)).join(", "));return d.value}{let d=a;return o.type==="color"&&typeof a=="string"?d=wt.parse(a):o.type!=="padding"||typeof a!="number"&&!Array.isArray(a)?o.type==="variableAnchorOffsetCollection"&&Array.isArray(a)&&(d=lr.parse(a)):d=Gi.parse(a),{kind:"constant",evaluate:()=>d}}})(r===void 0?e.specification.default:r,e.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,r,a){return this.property.possiblyEvaluate(this,e,r,a)}}class uo{constructor(e){this.property=e,this.value=new ps(e,void 0)}transitioned(e,r){return new kl(this.property,this.value,r,Ve({},e.transition,this.transition),e.now)}untransitioned(){return new kl(this.property,this.value,null,{},0)}}class Al{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return Vt(this._values[e].value.value)}setValue(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new uo(this._values[e].property)),this._values[e].value=new ps(this._values[e].property,r===null?void 0:Vt(r))}getTransition(e){return Vt(this._values[e].transition)}setTransition(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new uo(this._values[e].property)),this._values[e].transition=Vt(r)||void 0}serialize(){const e={};for(const r of Object.keys(this._values)){const a=this.getValue(r);a!==void 0&&(e[r]=a);const o=this.getTransition(r);o!==void 0&&(e[`${r}-transition`]=o)}return e}transitioned(e,r){const a=new Cl(this._properties);for(const o of Object.keys(this._values))a._values[o]=this._values[o].transitioned(e,r._values[o]);return a}untransitioned(){const e=new Cl(this._properties);for(const r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class kl{constructor(e,r,a,o,d){this.property=e,this.value=r,this.begin=d+o.delay||0,this.end=this.begin+o.duration||0,e.specification.transition&&(o.delay||o.duration)&&(this.prior=a)}possiblyEvaluate(e,r,a){const o=e.now||0,d=this.value.possiblyEvaluate(e,r,a),f=this.prior;if(f){if(o>this.end)return this.prior=null,d;if(this.value.isDataDriven())return this.prior=null,d;if(o<this.begin)return f.possiblyEvaluate(e,r,a);{const m=(o-this.begin)/(this.end-this.begin);return this.property.interpolate(f.possiblyEvaluate(e,r,a),d,(function(y){if(y<=0)return 0;if(y>=1)return 1;const v=y*y,S=v*y;return 4*(y<.5?S:3*(y-v)+S-.75)})(m))}}return d}}class Cl{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,r,a){const o=new ds(this._properties);for(const d of Object.keys(this._values))o._values[d]=this._values[d].possiblyEvaluate(e,r,a);return o}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Ec{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}hasValue(e){return this._values[e].value!==void 0}getValue(e){return Vt(this._values[e].value)}setValue(e,r){this._values[e]=new ps(this._values[e].property,r===null?void 0:Vt(r))}serialize(){const e={};for(const r of Object.keys(this._values)){const a=this.getValue(r);a!==void 0&&(e[r]=a)}return e}possiblyEvaluate(e,r,a){const o=new ds(this._properties);for(const d of Object.keys(this._values))o._values[d]=this._values[d].possiblyEvaluate(e,r,a);return o}}class Ti{constructor(e,r,a){this.property=e,this.value=r,this.parameters=a}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,r,a,o){return this.property.evaluate(this.value,this.parameters,e,r,a,o)}}class ds{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class je{constructor(e){this.specification=e}possiblyEvaluate(e,r){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(r)}interpolate(e,r,a){const o=Hi[this.specification.type];return o?o(e,r,a):e}}class He{constructor(e,r){this.specification=e,this.overrides=r}possiblyEvaluate(e,r,a,o){return new Ti(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(r,null,{},a,o)}:e.expression,r)}interpolate(e,r,a){if(e.value.kind!=="constant"||r.value.kind!=="constant")return e;if(e.value.value===void 0||r.value.value===void 0)return new Ti(this,{kind:"constant",value:void 0},e.parameters);const o=Hi[this.specification.type];if(o){const d=o(e.value.value,r.value.value,a);return new Ti(this,{kind:"constant",value:d},e.parameters)}return e}evaluate(e,r,a,o,d,f){return e.kind==="constant"?e.value:e.evaluate(r,a,o,d,f)}}class Ia extends He{possiblyEvaluate(e,r,a,o){if(e.value===void 0)return new Ti(this,{kind:"constant",value:void 0},r);if(e.expression.kind==="constant"){const d=e.expression.evaluate(r,null,{},a,o),f=e.property.specification.type==="resolvedImage"&&typeof d!="string"?d.name:d,m=this._calculate(f,f,f,r);return new Ti(this,{kind:"constant",value:m},r)}if(e.expression.kind==="camera"){const d=this._calculate(e.expression.evaluate({zoom:r.zoom-1}),e.expression.evaluate({zoom:r.zoom}),e.expression.evaluate({zoom:r.zoom+1}),r);return new Ti(this,{kind:"constant",value:d},r)}return new Ti(this,e.expression,r)}evaluate(e,r,a,o,d,f){if(e.kind==="source"){const m=e.evaluate(r,a,o,d,f);return this._calculate(m,m,m,r)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(r.zoom)-1},a,o),e.evaluate({zoom:Math.floor(r.zoom)},a,o),e.evaluate({zoom:Math.floor(r.zoom)+1},a,o),r):e.value}_calculate(e,r,a,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:a,to:r}}interpolate(e){return e}}class ho{constructor(e){this.specification=e}possiblyEvaluate(e,r,a,o){if(e.value!==void 0){if(e.expression.kind==="constant"){const d=e.expression.evaluate(r,null,{},a,o);return this._calculate(d,d,d,r)}return this._calculate(e.expression.evaluate(new Mt(Math.floor(r.zoom-1),r)),e.expression.evaluate(new Mt(Math.floor(r.zoom),r)),e.expression.evaluate(new Mt(Math.floor(r.zoom+1),r)),r)}}_calculate(e,r,a,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:a,to:r}}interpolate(e){return e}}class po{constructor(e){this.specification=e}possiblyEvaluate(e,r,a,o){return!!e.expression.evaluate(r,null,{},a,o)}interpolate(){return!1}}class Wt{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const r in e){const a=e[r];a.specification.overridable&&this.overridableProperties.push(r);const o=this.defaultPropertyValues[r]=new ps(a,void 0),d=this.defaultTransitionablePropertyValues[r]=new uo(a);this.defaultTransitioningPropertyValues[r]=d.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=o.possiblyEvaluate({})}}}Le("DataDrivenProperty",He),Le("DataConstantProperty",je),Le("CrossFadedDataDrivenProperty",Ia),Le("CrossFadedProperty",ho),Le("ColorRampProperty",po);const fo="-transition";class pr extends mn{constructor(e,r){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1},e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),r.layout&&(this._unevaluatedLayout=new Ec(r.layout)),r.paint)){this._transitionablePaint=new Al(r.paint);for(const a in e.paint)this.setPaintProperty(a,e.paint[a],{validate:!1});for(const a in e.layout)this.setLayoutProperty(a,e.layout[a],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new ds(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,r,a={}){r!=null&&this._validate(vl,`layers.${this.id}.layout.${e}`,e,r,a)||(e!=="visibility"?this._unevaluatedLayout.setValue(e,r):this.visibility=r)}getPaintProperty(e){return e.endsWith(fo)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,r,a={}){if(r!=null&&this._validate(eo,`layers.${this.id}.paint.${e}`,e,r,a))return!1;if(e.endsWith(fo))return this._transitionablePaint.setTransition(e.slice(0,-11),r||void 0),!1;{const o=this._transitionablePaint._values[e],d=o.property.specification["property-type"]==="cross-faded-data-driven",f=o.value.isDataDriven(),m=o.value;this._transitionablePaint.setValue(e,r),this._handleSpecialPaintPropertyUpdate(e);const y=this._transitionablePaint._values[e].value;return y.isDataDriven()||f||d||this._handleOverridablePaintPropertyUpdate(e,m,y)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,r,a){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,r){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,r)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),ji(e,((r,a)=>!(r===void 0||a==="layout"&&!Object.keys(r).length||a==="paint"&&!Object.keys(r).length)))}_validate(e,r,a,o,d={}){return(!d||d.validate!==!1)&&us(this,e.call(Nr,{key:r,layerType:this.type,objectKey:a,value:o,styleSpec:he,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const r=this.paint.get(e);if(r instanceof Ti&&Hn(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}}const El={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Tn{constructor(e,r){this._structArray=e,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class qt{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,r){return e._trim(),r&&(e.isTransferred=!0,r.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const r=Object.create(this.prototype);return r.arrayBuffer=e.arrayBuffer,r.length=e.length,r.capacity=e.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Nt(i,e=1){let r=0,a=0;return{members:i.map((o=>{const d=El[o.type].BYTES_PER_ELEMENT,f=r=Jn(r,Math.max(e,d)),m=o.components||1;return a=Math.max(a,d),r+=d*m,{name:o.name,type:o.type,components:m,offset:f}})),size:Jn(r,Math.max(a,e)),alignment:e}}function Jn(i,e){return Math.ceil(i/e)*e}class Aa extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r){const a=this.length;return this.resize(a+1),this.emplace(a,e,r)}emplace(e,r,a){const o=2*e;return this.int16[o+0]=r,this.int16[o+1]=a,e}}Aa.prototype.bytesPerElement=4,Le("StructArrayLayout2i4",Aa);class ka extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a){const o=this.length;return this.resize(o+1),this.emplace(o,e,r,a)}emplace(e,r,a,o){const d=3*e;return this.int16[d+0]=r,this.int16[d+1]=a,this.int16[d+2]=o,e}}ka.prototype.bytesPerElement=6,Le("StructArrayLayout3i6",ka);class In extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,o){const d=this.length;return this.resize(d+1),this.emplace(d,e,r,a,o)}emplace(e,r,a,o,d){const f=4*e;return this.int16[f+0]=r,this.int16[f+1]=a,this.int16[f+2]=o,this.int16[f+3]=d,e}}In.prototype.bytesPerElement=8,Le("StructArrayLayout4i8",In);class mo extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,o,d,f){const m=this.length;return this.resize(m+1),this.emplace(m,e,r,a,o,d,f)}emplace(e,r,a,o,d,f,m){const y=6*e;return this.int16[y+0]=r,this.int16[y+1]=a,this.int16[y+2]=o,this.int16[y+3]=d,this.int16[y+4]=f,this.int16[y+5]=m,e}}mo.prototype.bytesPerElement=12,Le("StructArrayLayout2i4i12",mo);class go extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,o,d,f){const m=this.length;return this.resize(m+1),this.emplace(m,e,r,a,o,d,f)}emplace(e,r,a,o,d,f,m){const y=4*e,v=8*e;return this.int16[y+0]=r,this.int16[y+1]=a,this.uint8[v+4]=o,this.uint8[v+5]=d,this.uint8[v+6]=f,this.uint8[v+7]=m,e}}go.prototype.bytesPerElement=8,Le("StructArrayLayout2i4ub8",go);class Qn extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r){const a=this.length;return this.resize(a+1),this.emplace(a,e,r)}emplace(e,r,a){const o=2*e;return this.float32[o+0]=r,this.float32[o+1]=a,e}}Qn.prototype.bytesPerElement=8,Le("StructArrayLayout2f8",Qn);class _o extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a,o,d,f,m,y,v,S){const A=this.length;return this.resize(A+1),this.emplace(A,e,r,a,o,d,f,m,y,v,S)}emplace(e,r,a,o,d,f,m,y,v,S,A){const C=10*e;return this.uint16[C+0]=r,this.uint16[C+1]=a,this.uint16[C+2]=o,this.uint16[C+3]=d,this.uint16[C+4]=f,this.uint16[C+5]=m,this.uint16[C+6]=y,this.uint16[C+7]=v,this.uint16[C+8]=S,this.uint16[C+9]=A,e}}_o.prototype.bytesPerElement=20,Le("StructArrayLayout10ui20",_o);class yo extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a,o,d,f,m,y,v,S,A,C){const z=this.length;return this.resize(z+1),this.emplace(z,e,r,a,o,d,f,m,y,v,S,A,C)}emplace(e,r,a,o,d,f,m,y,v,S,A,C,z){const D=12*e;return this.int16[D+0]=r,this.int16[D+1]=a,this.int16[D+2]=o,this.int16[D+3]=d,this.uint16[D+4]=f,this.uint16[D+5]=m,this.uint16[D+6]=y,this.uint16[D+7]=v,this.int16[D+8]=S,this.int16[D+9]=A,this.int16[D+10]=C,this.int16[D+11]=z,e}}yo.prototype.bytesPerElement=24,Le("StructArrayLayout4i4ui4i24",yo);class vt extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a){const o=this.length;return this.resize(o+1),this.emplace(o,e,r,a)}emplace(e,r,a,o){const d=3*e;return this.float32[d+0]=r,this.float32[d+1]=a,this.float32[d+2]=o,e}}vt.prototype.bytesPerElement=12,Le("StructArrayLayout3f12",vt);class u extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint32[1*e+0]=r,e}}u.prototype.bytesPerElement=4,Le("StructArrayLayout1ul4",u);class t extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a,o,d,f,m,y,v){const S=this.length;return this.resize(S+1),this.emplace(S,e,r,a,o,d,f,m,y,v)}emplace(e,r,a,o,d,f,m,y,v,S){const A=10*e,C=5*e;return this.int16[A+0]=r,this.int16[A+1]=a,this.int16[A+2]=o,this.int16[A+3]=d,this.int16[A+4]=f,this.int16[A+5]=m,this.uint32[C+3]=y,this.uint16[A+8]=v,this.uint16[A+9]=S,e}}t.prototype.bytesPerElement=20,Le("StructArrayLayout6i1ul2ui20",t);class n extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,o,d,f){const m=this.length;return this.resize(m+1),this.emplace(m,e,r,a,o,d,f)}emplace(e,r,a,o,d,f,m){const y=6*e;return this.int16[y+0]=r,this.int16[y+1]=a,this.int16[y+2]=o,this.int16[y+3]=d,this.int16[y+4]=f,this.int16[y+5]=m,e}}n.prototype.bytesPerElement=12,Le("StructArrayLayout2i2i2i12",n);class s extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,a,o,d){const f=this.length;return this.resize(f+1),this.emplace(f,e,r,a,o,d)}emplace(e,r,a,o,d,f){const m=4*e,y=8*e;return this.float32[m+0]=r,this.float32[m+1]=a,this.float32[m+2]=o,this.int16[y+6]=d,this.int16[y+7]=f,e}}s.prototype.bytesPerElement=16,Le("StructArrayLayout2f1f2i16",s);class c extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a,o){const d=this.length;return this.resize(d+1),this.emplace(d,e,r,a,o)}emplace(e,r,a,o,d){const f=12*e,m=3*e;return this.uint8[f+0]=r,this.uint8[f+1]=a,this.float32[m+1]=o,this.float32[m+2]=d,e}}c.prototype.bytesPerElement=12,Le("StructArrayLayout2ub2f12",c);class p extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a){const o=this.length;return this.resize(o+1),this.emplace(o,e,r,a)}emplace(e,r,a,o){const d=3*e;return this.uint16[d+0]=r,this.uint16[d+1]=a,this.uint16[d+2]=o,e}}p.prototype.bytesPerElement=6,Le("StructArrayLayout3ui6",p);class g extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a,o,d,f,m,y,v,S,A,C,z,D,O,q,H){const re=this.length;return this.resize(re+1),this.emplace(re,e,r,a,o,d,f,m,y,v,S,A,C,z,D,O,q,H)}emplace(e,r,a,o,d,f,m,y,v,S,A,C,z,D,O,q,H,re){const Y=24*e,ae=12*e,oe=48*e;return this.int16[Y+0]=r,this.int16[Y+1]=a,this.uint16[Y+2]=o,this.uint16[Y+3]=d,this.uint32[ae+2]=f,this.uint32[ae+3]=m,this.uint32[ae+4]=y,this.uint16[Y+10]=v,this.uint16[Y+11]=S,this.uint16[Y+12]=A,this.float32[ae+7]=C,this.float32[ae+8]=z,this.uint8[oe+36]=D,this.uint8[oe+37]=O,this.uint8[oe+38]=q,this.uint32[ae+10]=H,this.int16[Y+22]=re,e}}g.prototype.bytesPerElement=48,Le("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",g);class _ extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a,o,d,f,m,y,v,S,A,C,z,D,O,q,H,re,Y,ae,oe,_e,De,Oe,Pe,Me,Ie,Fe){const ke=this.length;return this.resize(ke+1),this.emplace(ke,e,r,a,o,d,f,m,y,v,S,A,C,z,D,O,q,H,re,Y,ae,oe,_e,De,Oe,Pe,Me,Ie,Fe)}emplace(e,r,a,o,d,f,m,y,v,S,A,C,z,D,O,q,H,re,Y,ae,oe,_e,De,Oe,Pe,Me,Ie,Fe,ke){const we=32*e,Ze=16*e;return this.int16[we+0]=r,this.int16[we+1]=a,this.int16[we+2]=o,this.int16[we+3]=d,this.int16[we+4]=f,this.int16[we+5]=m,this.int16[we+6]=y,this.int16[we+7]=v,this.uint16[we+8]=S,this.uint16[we+9]=A,this.uint16[we+10]=C,this.uint16[we+11]=z,this.uint16[we+12]=D,this.uint16[we+13]=O,this.uint16[we+14]=q,this.uint16[we+15]=H,this.uint16[we+16]=re,this.uint16[we+17]=Y,this.uint16[we+18]=ae,this.uint16[we+19]=oe,this.uint16[we+20]=_e,this.uint16[we+21]=De,this.uint16[we+22]=Oe,this.uint32[Ze+12]=Pe,this.float32[Ze+13]=Me,this.float32[Ze+14]=Ie,this.uint16[we+30]=Fe,this.uint16[we+31]=ke,e}}_.prototype.bytesPerElement=64,Le("StructArrayLayout8i15ui1ul2f2ui64",_);class x extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.float32[1*e+0]=r,e}}x.prototype.bytesPerElement=4,Le("StructArrayLayout1f4",x);class b extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a){const o=this.length;return this.resize(o+1),this.emplace(o,e,r,a)}emplace(e,r,a,o){const d=3*e;return this.uint16[6*e+0]=r,this.float32[d+1]=a,this.float32[d+2]=o,e}}b.prototype.bytesPerElement=12,Le("StructArrayLayout1ui2f12",b);class T extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,a){const o=this.length;return this.resize(o+1),this.emplace(o,e,r,a)}emplace(e,r,a,o){const d=4*e;return this.uint32[2*e+0]=r,this.uint16[d+2]=a,this.uint16[d+3]=o,e}}T.prototype.bytesPerElement=8,Le("StructArrayLayout1ul2ui8",T);class I extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r){const a=this.length;return this.resize(a+1),this.emplace(a,e,r)}emplace(e,r,a){const o=2*e;return this.uint16[o+0]=r,this.uint16[o+1]=a,e}}I.prototype.bytesPerElement=4,Le("StructArrayLayout2ui4",I);class P extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint16[1*e+0]=r,e}}P.prototype.bytesPerElement=2,Le("StructArrayLayout1ui2",P);class V extends qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,a,o){const d=this.length;return this.resize(d+1),this.emplace(d,e,r,a,o)}emplace(e,r,a,o,d){const f=4*e;return this.float32[f+0]=r,this.float32[f+1]=a,this.float32[f+2]=o,this.float32[f+3]=d,e}}V.prototype.bytesPerElement=16,Le("StructArrayLayout4f16",V);class N extends Tn{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new ge(this.anchorPointX,this.anchorPointY)}}N.prototype.size=20;class $ extends t{get(e){return new N(this,e)}}Le("CollisionBoxArray",$);class B extends Tn{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}B.prototype.size=48;class ee extends g{get(e){return new B(this,e)}}Le("PlacedSymbolArray",ee);class se extends Tn{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}se.prototype.size=64;class G extends _{get(e){return new se(this,e)}}Le("SymbolInstanceArray",G);class te extends x{getoffsetX(e){return this.float32[1*e+0]}}Le("GlyphOffsetArray",te);class ce extends ka{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}Le("SymbolLineVertexArray",ce);class ue extends Tn{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}ue.prototype.size=12;class me extends b{get(e){return new ue(this,e)}}Le("TextAnchorOffsetArray",me);class be extends Tn{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}be.prototype.size=8;class xe extends T{get(e){return new be(this,e)}}Le("FeatureIndexArray",xe);class Te extends Aa{}class Be extends Aa{}class ut extends Aa{}class Ee extends mo{}class We extends go{}class Ne extends Qn{}class St extends _o{}class ct extends yo{}class at extends vt{}class ht extends u{}class Zt extends n{}class Ct extends c{}class pi extends p{}class ei extends I{}const Xt=Nt([{name:"a_pos",components:2,type:"Int16"}],4),{members:Yi}=Xt;class Pt{constructor(e=[]){this.segments=e}prepareSegment(e,r,a,o){let d=this.segments[this.segments.length-1];return e>Pt.MAX_VERTEX_ARRAY_LENGTH&&Dt(`Max vertices per segment is ${Pt.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!d||d.vertexLength+e>Pt.MAX_VERTEX_ARRAY_LENGTH||d.sortKey!==o)&&(d={vertexOffset:r.length,primitiveOffset:a.length,vertexLength:0,primitiveLength:0},o!==void 0&&(d.sortKey=o),this.segments.push(d)),d}get(){return this.segments}destroy(){for(const e of this.segments)for(const r in e.vaos)e.vaos[r].destroy()}static simpleSegment(e,r,a,o){return new Pt([{vertexOffset:e,primitiveOffset:r,vertexLength:a,primitiveLength:o,vaos:{},sortKey:0}])}}function Ir(i,e){return 256*(i=rr(Math.floor(i),0,255))+rr(Math.floor(e),0,255)}Pt.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Le("SegmentVector",Pt);const Ar=Nt([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var on={exports:{}},An={exports:{}};An.exports=function(i,e){var r,a,o,d,f,m,y,v;for(a=i.length-(r=3&i.length),o=e,f=3432918353,m=461845907,v=0;v<a;)y=255&i.charCodeAt(v)|(255&i.charCodeAt(++v))<<8|(255&i.charCodeAt(++v))<<16|(255&i.charCodeAt(++v))<<24,++v,o=27492+(65535&(d=5*(65535&(o=(o^=y=(65535&(y=(y=(65535&y)*f+(((y>>>16)*f&65535)<<16)&4294967295)<<15|y>>>17))*m+(((y>>>16)*m&65535)<<16)&4294967295)<<13|o>>>19))+((5*(o>>>16)&65535)<<16)&4294967295))+((58964+(d>>>16)&65535)<<16);switch(y=0,r){case 3:y^=(255&i.charCodeAt(v+2))<<16;case 2:y^=(255&i.charCodeAt(v+1))<<8;case 1:o^=y=(65535&(y=(y=(65535&(y^=255&i.charCodeAt(v)))*f+(((y>>>16)*f&65535)<<16)&4294967295)<<15|y>>>17))*m+(((y>>>16)*m&65535)<<16)&4294967295}return o^=i.length,o=2246822507*(65535&(o^=o>>>16))+((2246822507*(o>>>16)&65535)<<16)&4294967295,o=3266489909*(65535&(o^=o>>>13))+((3266489909*(o>>>16)&65535)<<16)&4294967295,(o^=o>>>16)>>>0};var ea=An.exports,_i={exports:{}};_i.exports=function(i,e){for(var r,a=i.length,o=e^a,d=0;a>=4;)r=1540483477*(65535&(r=255&i.charCodeAt(d)|(255&i.charCodeAt(++d))<<8|(255&i.charCodeAt(++d))<<16|(255&i.charCodeAt(++d))<<24))+((1540483477*(r>>>16)&65535)<<16),o=1540483477*(65535&o)+((1540483477*(o>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),a-=4,++d;switch(a){case 3:o^=(255&i.charCodeAt(d+2))<<16;case 2:o^=(255&i.charCodeAt(d+1))<<8;case 1:o=1540483477*(65535&(o^=255&i.charCodeAt(d)))+((1540483477*(o>>>16)&65535)<<16)}return o=1540483477*(65535&(o^=o>>>13))+((1540483477*(o>>>16)&65535)<<16),(o^=o>>>15)>>>0};var di=ea,Ii=_i.exports;on.exports=di,on.exports.murmur3=di,on.exports.murmur2=Ii;var kn=W(on.exports);class Gt{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,r,a,o){this.ids.push(ti(e)),this.positions.push(r,a,o)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const r=ti(e);let a=0,o=this.ids.length-1;for(;a<o;){const f=a+o>>1;this.ids[f]>=r?o=f:a=f+1}const d=[];for(;this.ids[a]===r;)d.push({index:this.positions[3*a],start:this.positions[3*a+1],end:this.positions[3*a+2]}),a++;return d}static serialize(e,r){const a=new Float64Array(e.ids),o=new Uint32Array(e.positions);return Ri(a,o,0,a.length-1),r&&r.push(a.buffer,o.buffer),{ids:a,positions:o}}static deserialize(e){const r=new Gt;return r.ids=e.ids,r.positions=e.positions,r.indexed=!0,r}}function ti(i){const e=+i;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:kn(String(i))}function Ri(i,e,r,a){for(;r<a;){const o=i[r+a>>1];let d=r-1,f=a+1;for(;;){do d++;while(i[d]<o);do f--;while(i[f]>o);if(d>=f)break;Ht(i,d,f),Ht(e,3*d,3*f),Ht(e,3*d+1,3*f+1),Ht(e,3*d+2,3*f+2)}f-r<a-f?(Ri(i,e,r,f),r=f+1):(Ri(i,e,f+1,a),a=f)}}function Ht(i,e,r){const a=i[e];i[e]=i[r],i[r]=a}Le("FeaturePositionMap",Gt);class Cn{constructor(e,r){this.gl=e.gl,this.location=r}}class fs extends Cn{constructor(e,r){super(e,r),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class Ml extends Cn{constructor(e,r){super(e,r),this.current=[0,0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]&&e[3]===this.current[3]||(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}}class Pl extends Cn{constructor(e,r){super(e,r),this.current=wt.transparent}set(e){e.r===this.current.r&&e.g===this.current.g&&e.b===this.current.b&&e.a===this.current.a||(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}}const Mc=new Float32Array(16);function xo(i){return[Ir(255*i.r,255*i.g),Ir(255*i.b,255*i.a)]}class kr{constructor(e,r,a){this.value=e,this.uniformNames=r.map((o=>`u_${o}`)),this.type=a}setUniform(e,r,a){e.set(a.constantOr(this.value))}getBinding(e,r,a){return this.type==="color"?new Pl(e,r):new fs(e,r)}}class En{constructor(e,r){this.uniformNames=r.map((a=>`u_${a}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=e.tlbr}setUniform(e,r,a,o){const d=o==="u_pattern_to"?this.patternTo:o==="u_pattern_from"?this.patternFrom:o==="u_pixel_ratio_to"?this.pixelRatioTo:o==="u_pixel_ratio_from"?this.pixelRatioFrom:null;d&&e.set(d)}getBinding(e,r,a){return a.substr(0,9)==="u_pattern"?new Ml(e,r):new fs(e,r)}}class Cr{constructor(e,r,a,o){this.expression=e,this.type=a,this.maxValue=0,this.paintVertexAttributes=r.map((d=>({name:`a_${d}`,type:"Float32",components:a==="color"?2:1,offset:0}))),this.paintVertexArray=new o}populatePaintArray(e,r,a,o,d){const f=this.paintVertexArray.length,m=this.expression.evaluate(new Mt(0),r,{},o,[],d);this.paintVertexArray.resize(e),this._setPaintValue(f,e,m)}updatePaintArray(e,r,a,o){const d=this.expression.evaluate({zoom:0},a,o);this._setPaintValue(e,r,d)}_setPaintValue(e,r,a){if(this.type==="color"){const o=xo(a);for(let d=e;d<r;d++)this.paintVertexArray.emplace(d,o[0],o[1])}else{for(let o=e;o<r;o++)this.paintVertexArray.emplace(o,a);this.maxValue=Math.max(this.maxValue,Math.abs(a))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class dr{constructor(e,r,a,o,d,f){this.expression=e,this.uniformNames=r.map((m=>`u_${m}_t`)),this.type=a,this.useIntegerZoom=o,this.zoom=d,this.maxValue=0,this.paintVertexAttributes=r.map((m=>({name:`a_${m}`,type:"Float32",components:a==="color"?4:2,offset:0}))),this.paintVertexArray=new f}populatePaintArray(e,r,a,o,d){const f=this.expression.evaluate(new Mt(this.zoom),r,{},o,[],d),m=this.expression.evaluate(new Mt(this.zoom+1),r,{},o,[],d),y=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(y,e,f,m)}updatePaintArray(e,r,a,o){const d=this.expression.evaluate({zoom:this.zoom},a,o),f=this.expression.evaluate({zoom:this.zoom+1},a,o);this._setPaintValue(e,r,d,f)}_setPaintValue(e,r,a,o){if(this.type==="color"){const d=xo(a),f=xo(o);for(let m=e;m<r;m++)this.paintVertexArray.emplace(m,d[0],d[1],f[0],f[1])}else{for(let d=e;d<r;d++)this.paintVertexArray.emplace(d,a,o);this.maxValue=Math.max(this.maxValue,Math.abs(a),Math.abs(o))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,r){const a=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,o=rr(this.expression.interpolationFactor(a,this.zoom,this.zoom+1),0,1);e.set(o)}getBinding(e,r,a){return new fs(e,r)}}class Er{constructor(e,r,a,o,d,f){this.expression=e,this.type=r,this.useIntegerZoom=a,this.zoom=o,this.layerId=f,this.zoomInPaintVertexArray=new d,this.zoomOutPaintVertexArray=new d}populatePaintArray(e,r,a){const o=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(o,e,r.patterns&&r.patterns[this.layerId],a)}updatePaintArray(e,r,a,o,d){this._setPaintValues(e,r,a.patterns&&a.patterns[this.layerId],d)}_setPaintValues(e,r,a,o){if(!o||!a)return;const{min:d,mid:f,max:m}=a,y=o[d],v=o[f],S=o[m];if(y&&v&&S)for(let A=e;A<r;A++)this.zoomInPaintVertexArray.emplace(A,v.tl[0],v.tl[1],v.br[0],v.br[1],y.tl[0],y.tl[1],y.br[0],y.br[1],v.pixelRatio,y.pixelRatio),this.zoomOutPaintVertexArray.emplace(A,v.tl[0],v.tl[1],v.br[0],v.br[1],S.tl[0],S.tl[1],S.br[0],S.br[1],v.pixelRatio,S.pixelRatio)}upload(e){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,Ar.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,Ar.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class vo{constructor(e,r,a){this.binders={},this._buffers=[];const o=[];for(const d in e.paint._values){if(!a(d))continue;const f=e.paint.get(d);if(!(f instanceof Ti&&Hn(f.property.specification)))continue;const m=tg(d,e.type),y=f.value,v=f.property.specification.type,S=f.property.useIntegerZoom,A=f.property.specification["property-type"],C=A==="cross-faded"||A==="cross-faded-data-driven";if(y.kind==="constant")this.binders[d]=C?new En(y.value,m):new kr(y.value,m,v),o.push(`/u_${d}`);else if(y.kind==="source"||C){const z=Ah(d,v,"source");this.binders[d]=C?new Er(y,v,S,r,z,e.id):new Cr(y,m,v,z),o.push(`/a_${d}`)}else{const z=Ah(d,v,"composite");this.binders[d]=new dr(y,m,v,S,r,z),o.push(`/z_${d}`)}}this.cacheKey=o.sort().join("")}getMaxValue(e){const r=this.binders[e];return r instanceof Cr||r instanceof dr?r.maxValue:0}populatePaintArrays(e,r,a,o,d){for(const f in this.binders){const m=this.binders[f];(m instanceof Cr||m instanceof dr||m instanceof Er)&&m.populatePaintArray(e,r,a,o,d)}}setConstantPatternPositions(e,r){for(const a in this.binders){const o=this.binders[a];o instanceof En&&o.setConstantPatternPositions(e,r)}}updatePaintArrays(e,r,a,o,d){let f=!1;for(const m in e){const y=r.getPositions(m);for(const v of y){const S=a.feature(v.index);for(const A in this.binders){const C=this.binders[A];if((C instanceof Cr||C instanceof dr||C instanceof Er)&&C.expression.isStateDependent===!0){const z=o.paint.get(A);C.expression=z.value,C.updatePaintArray(v.start,v.end,S,e[m],d),f=!0}}}}return f}defines(){const e=[];for(const r in this.binders){const a=this.binders[r];(a instanceof kr||a instanceof En)&&e.push(...a.uniformNames.map((o=>`#define HAS_UNIFORM_${o}`)))}return e}getBinderAttributes(){const e=[];for(const r in this.binders){const a=this.binders[r];if(a instanceof Cr||a instanceof dr)for(let o=0;o<a.paintVertexAttributes.length;o++)e.push(a.paintVertexAttributes[o].name);else if(a instanceof Er)for(let o=0;o<Ar.members.length;o++)e.push(Ar.members[o].name)}return e}getBinderUniforms(){const e=[];for(const r in this.binders){const a=this.binders[r];if(a instanceof kr||a instanceof En||a instanceof dr)for(const o of a.uniformNames)e.push(o)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,r){const a=[];for(const o in this.binders){const d=this.binders[o];if(d instanceof kr||d instanceof En||d instanceof dr){for(const f of d.uniformNames)if(r[f]){const m=d.getBinding(e,r[f],f);a.push({name:f,property:o,binding:m})}}}return a}setUniforms(e,r,a,o){for(const{name:d,property:f,binding:m}of r)this.binders[f].setUniform(m,o,a.get(f),d)}updatePaintBuffers(e){this._buffers=[];for(const r in this.binders){const a=this.binders[r];if(e&&a instanceof Er){const o=e.fromScale===2?a.zoomInPaintVertexBuffer:a.zoomOutPaintVertexBuffer;o&&this._buffers.push(o)}else(a instanceof Cr||a instanceof dr)&&a.paintVertexBuffer&&this._buffers.push(a.paintVertexBuffer)}}upload(e){for(const r in this.binders){const a=this.binders[r];(a instanceof Cr||a instanceof dr||a instanceof Er)&&a.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const r=this.binders[e];(r instanceof Cr||r instanceof dr||r instanceof Er)&&r.destroy()}}}class Ur{constructor(e,r,a=(()=>!0)){this.programConfigurations={};for(const o of e)this.programConfigurations[o.id]=new vo(o,r,a);this.needsUpload=!1,this._featureMap=new Gt,this._bufferOffset=0}populatePaintArrays(e,r,a,o,d,f){for(const m in this.programConfigurations)this.programConfigurations[m].populatePaintArrays(e,r,o,d,f);r.id!==void 0&&this._featureMap.add(r.id,a,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,r,a,o){for(const d of a)this.needsUpload=this.programConfigurations[d.id].updatePaintArrays(e,this._featureMap,r,d,o)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function tg(i,e){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[i]||[i.replace(`${e}-`,"").replace(/-/g,"_")]}function Ah(i,e,r){const a={color:{source:Qn,composite:V},number:{source:x,composite:Qn}},o=(function(d){return{"line-pattern":{source:St,composite:St},"fill-pattern":{source:St,composite:St},"fill-extrusion-pattern":{source:St,composite:St}}[d]})(i);return o&&o[r]||a[e][r]}Le("ConstantBinder",kr),Le("CrossFadedConstantBinder",En),Le("SourceExpressionBinder",Cr),Le("CrossFadedCompositeBinder",Er),Le("CompositeExpressionBinder",dr),Le("ProgramConfiguration",vo,{omit:["_buffers"]}),Le("ProgramConfigurationSet",Ur);const Jt=8192,Pc=Math.pow(2,14)-1,kh=-Pc-1;function Ca(i){const e=Jt/i.extent,r=i.loadGeometry();for(let a=0;a<r.length;a++){const o=r[a];for(let d=0;d<o.length;d++){const f=o[d],m=Math.round(f.x*e),y=Math.round(f.y*e);f.x=rr(m,kh,Pc),f.y=rr(y,kh,Pc),(m<f.x||m>f.x+1||y<f.y||y>f.y+1)&&Dt("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function Ea(i,e){return{type:i.type,id:i.id,properties:i.properties,geometry:e?Ca(i):[]}}function zl(i,e,r,a,o){i.emplaceBack(2*e+(a+1)/2,2*r+(o+1)/2)}class zc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new Be,this.indexArray=new pi,this.segments=new Pt,this.programConfigurations=new Ur(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,a){const o=this.layers[0],d=[];let f=null,m=!1;o.type==="circle"&&(f=o.layout.get("circle-sort-key"),m=!f.isConstant());for(const{feature:y,id:v,index:S,sourceLayerIndex:A}of e){const C=this.layers[0]._featureFilter.needGeometry,z=Ea(y,C);if(!this.layers[0]._featureFilter.filter(new Mt(this.zoom),z,a))continue;const D=m?f.evaluate(z,{},a):void 0,O={id:v,properties:y.properties,type:y.type,sourceLayerIndex:A,index:S,geometry:C?z.geometry:Ca(y),patterns:{},sortKey:D};d.push(O)}m&&d.sort(((y,v)=>y.sortKey-v.sortKey));for(const y of d){const{geometry:v,index:S,sourceLayerIndex:A}=y,C=e[S].feature;this.addFeature(y,v,S,a),r.featureIndex.insert(C,v,S,A,this.index)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Yi),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,r,a,o){for(const d of r)for(const f of d){const m=f.x,y=f.y;if(m<0||m>=Jt||y<0||y>=Jt)continue;const v=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),S=v.vertexLength;zl(this.layoutVertexArray,m,y,-1,-1),zl(this.layoutVertexArray,m,y,1,-1),zl(this.layoutVertexArray,m,y,1,1),zl(this.layoutVertexArray,m,y,-1,1),this.indexArray.emplaceBack(S,S+1,S+2),this.indexArray.emplaceBack(S,S+3,S+2),v.vertexLength+=4,v.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,{},o)}}function Ch(i,e){for(let r=0;r<i.length;r++)if(ms(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(ms(i,e[r]))return!0;return!!Dc(i,e)}function ig(i,e,r){return!!ms(i,e)||!!Lc(e,i,r)}function Eh(i,e){if(i.length===1)return Ph(e,i[0]);for(let r=0;r<e.length;r++){const a=e[r];for(let o=0;o<a.length;o++)if(ms(i,a[o]))return!0}for(let r=0;r<i.length;r++)if(Ph(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(Dc(i,e[r]))return!0;return!1}function rg(i,e,r){if(i.length>1){if(Dc(i,e))return!0;for(let a=0;a<e.length;a++)if(Lc(e[a],i,r))return!0}for(let a=0;a<i.length;a++)if(Lc(i[a],e,r))return!0;return!1}function Dc(i,e){if(i.length===0||e.length===0)return!1;for(let r=0;r<i.length-1;r++){const a=i[r],o=i[r+1];for(let d=0;d<e.length-1;d++)if(ng(a,o,e[d],e[d+1]))return!0}return!1}function ng(i,e,r,a){return Zi(i,r,a)!==Zi(e,r,a)&&Zi(i,e,r)!==Zi(i,e,a)}function Lc(i,e,r){const a=r*r;if(e.length===1)return i.distSqr(e[0])<a;for(let o=1;o<e.length;o++)if(Mh(i,e[o-1],e[o])<a)return!0;return!1}function Mh(i,e,r){const a=e.distSqr(r);if(a===0)return i.distSqr(e);const o=((i.x-e.x)*(r.x-e.x)+(i.y-e.y)*(r.y-e.y))/a;return i.distSqr(o<0?e:o>1?r:r.sub(e)._mult(o)._add(e))}function Ph(i,e){let r,a,o,d=!1;for(let f=0;f<i.length;f++){r=i[f];for(let m=0,y=r.length-1;m<r.length;y=m++)a=r[m],o=r[y],a.y>e.y!=o.y>e.y&&e.x<(o.x-a.x)*(e.y-a.y)/(o.y-a.y)+a.x&&(d=!d)}return d}function ms(i,e){let r=!1;for(let a=0,o=i.length-1;a<i.length;o=a++){const d=i[a],f=i[o];d.y>e.y!=f.y>e.y&&e.x<(f.x-d.x)*(e.y-d.y)/(f.y-d.y)+d.x&&(r=!r)}return r}function ag(i,e,r){const a=r[0],o=r[2];if(i.x<a.x&&e.x<a.x||i.x>o.x&&e.x>o.x||i.y<a.y&&e.y<a.y||i.y>o.y&&e.y>o.y)return!1;const d=Zi(i,e,r[0]);return d!==Zi(i,e,r[1])||d!==Zi(i,e,r[2])||d!==Zi(i,e,r[3])}function bo(i,e,r){const a=e.paint.get(i).value;return a.kind==="constant"?a.value:r.programConfigurations.get(e.id).getMaxValue(i)}function Dl(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function Ll(i,e,r,a,o){if(!e[0]&&!e[1])return i;const d=ge.convert(e)._mult(o);r==="viewport"&&d._rotate(-a);const f=[];for(let m=0;m<i.length;m++)f.push(i[m].sub(d));return f}let zh,Dh;Le("CircleBucket",zc,{omit:["layers"]});var sg={get paint(){return Dh=Dh||new Wt({"circle-radius":new He(he.paint_circle["circle-radius"]),"circle-color":new He(he.paint_circle["circle-color"]),"circle-blur":new He(he.paint_circle["circle-blur"]),"circle-opacity":new He(he.paint_circle["circle-opacity"]),"circle-translate":new je(he.paint_circle["circle-translate"]),"circle-translate-anchor":new je(he.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new je(he.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new je(he.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new He(he.paint_circle["circle-stroke-width"]),"circle-stroke-color":new He(he.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new He(he.paint_circle["circle-stroke-opacity"])})},get layout(){return zh=zh||new Wt({"circle-sort-key":new He(he.layout_circle["circle-sort-key"])})}},Bi=1e-6,gs=typeof Float32Array<"u"?Float32Array:Array;function Fc(i){return i[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=1,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i}function Lh(i,e,r){var a=e[0],o=e[1],d=e[2],f=e[3],m=e[4],y=e[5],v=e[6],S=e[7],A=e[8],C=e[9],z=e[10],D=e[11],O=e[12],q=e[13],H=e[14],re=e[15],Y=r[0],ae=r[1],oe=r[2],_e=r[3];return i[0]=Y*a+ae*m+oe*A+_e*O,i[1]=Y*o+ae*y+oe*C+_e*q,i[2]=Y*d+ae*v+oe*z+_e*H,i[3]=Y*f+ae*S+oe*D+_e*re,i[4]=(Y=r[4])*a+(ae=r[5])*m+(oe=r[6])*A+(_e=r[7])*O,i[5]=Y*o+ae*y+oe*C+_e*q,i[6]=Y*d+ae*v+oe*z+_e*H,i[7]=Y*f+ae*S+oe*D+_e*re,i[8]=(Y=r[8])*a+(ae=r[9])*m+(oe=r[10])*A+(_e=r[11])*O,i[9]=Y*o+ae*y+oe*C+_e*q,i[10]=Y*d+ae*v+oe*z+_e*H,i[11]=Y*f+ae*S+oe*D+_e*re,i[12]=(Y=r[12])*a+(ae=r[13])*m+(oe=r[14])*A+(_e=r[15])*O,i[13]=Y*o+ae*y+oe*C+_e*q,i[14]=Y*d+ae*v+oe*z+_e*H,i[15]=Y*f+ae*S+oe*D+_e*re,i}Math.hypot||(Math.hypot=function(){for(var i=0,e=arguments.length;e--;)i+=arguments[e]*arguments[e];return Math.sqrt(i)});var wo,og=Lh;function Fl(i,e,r){var a=e[0],o=e[1],d=e[2],f=e[3];return i[0]=r[0]*a+r[4]*o+r[8]*d+r[12]*f,i[1]=r[1]*a+r[5]*o+r[9]*d+r[13]*f,i[2]=r[2]*a+r[6]*o+r[10]*d+r[14]*f,i[3]=r[3]*a+r[7]*o+r[11]*d+r[15]*f,i}wo=new gs(4),gs!=Float32Array&&(wo[0]=0,wo[1]=0,wo[2]=0,wo[3]=0);class lg extends pr{constructor(e){super(e,sg)}createBucket(e){return new zc(e)}queryRadius(e){const r=e;return bo("circle-radius",this,r)+bo("circle-stroke-width",this,r)+Dl(this.paint.get("circle-translate"))}queryIntersectsFeature(e,r,a,o,d,f,m,y){const v=Ll(e,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),f.angle,m),S=this.paint.get("circle-radius").evaluate(r,a)+this.paint.get("circle-stroke-width").evaluate(r,a),A=this.paint.get("circle-pitch-alignment")==="map",C=A?v:(function(D,O){return D.map((q=>Fh(q,O)))})(v,y),z=A?S*m:S;for(const D of o)for(const O of D){const q=A?O:Fh(O,y);let H=z;const re=Fl([],[O.x,O.y,0,1],y);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?H*=re[3]/f.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(H*=f.cameraToCenterDistance/re[3]),ig(C,q,H))return!0}return!1}}function Fh(i,e){const r=Fl([],[i.x,i.y,0,1],e);return new ge(r[0]/r[3],r[1]/r[3])}class Rh extends zc{}let Bh;Le("HeatmapBucket",Rh,{omit:["layers"]});var cg={get paint(){return Bh=Bh||new Wt({"heatmap-radius":new He(he.paint_heatmap["heatmap-radius"]),"heatmap-weight":new He(he.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new je(he.paint_heatmap["heatmap-intensity"]),"heatmap-color":new po(he.paint_heatmap["heatmap-color"]),"heatmap-opacity":new je(he.paint_heatmap["heatmap-opacity"])})}};function Rc(i,{width:e,height:r},a,o){if(o){if(o instanceof Uint8ClampedArray)o=new Uint8Array(o.buffer);else if(o.length!==e*r*a)throw new RangeError(`mismatched image size. expected: ${o.length} but got: ${e*r*a}`)}else o=new Uint8Array(e*r*a);return i.width=e,i.height=r,i.data=o,i}function Oh(i,{width:e,height:r},a){if(e===i.width&&r===i.height)return;const o=Rc({},{width:e,height:r},a);Bc(i,o,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,e),height:Math.min(i.height,r)},a),i.width=e,i.height=r,i.data=o.data}function Bc(i,e,r,a,o,d){if(o.width===0||o.height===0)return e;if(o.width>i.width||o.height>i.height||r.x>i.width-o.width||r.y>i.height-o.height)throw new RangeError("out of range source coordinates for image copy");if(o.width>e.width||o.height>e.height||a.x>e.width-o.width||a.y>e.height-o.height)throw new RangeError("out of range destination coordinates for image copy");const f=i.data,m=e.data;if(f===m)throw new Error("srcData equals dstData, so image is already copied");for(let y=0;y<o.height;y++){const v=((r.y+y)*i.width+r.x)*d,S=((a.y+y)*e.width+a.x)*d;for(let A=0;A<o.width*d;A++)m[S+A]=f[v+A]}return e}class So{constructor(e,r){Rc(this,e,1,r)}resize(e){Oh(this,e,1)}clone(){return new So({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,a,o,d){Bc(e,r,a,o,d,1)}}class gr{constructor(e,r){Rc(this,e,4,r)}resize(e){Oh(this,e,4)}replace(e,r){r?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new gr({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,a,o,d){Bc(e,r,a,o,d,4)}}function Nh(i){const e={},r=i.resolution||256,a=i.clips?i.clips.length:1,o=i.image||new gr({width:r,height:a});if(Math.log(r)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${r}`);const d=(f,m,y)=>{e[i.evaluationKey]=y;const v=i.expression.evaluate(e);o.data[f+m+0]=Math.floor(255*v.r/v.a),o.data[f+m+1]=Math.floor(255*v.g/v.a),o.data[f+m+2]=Math.floor(255*v.b/v.a),o.data[f+m+3]=Math.floor(255*v.a)};if(i.clips)for(let f=0,m=0;f<a;++f,m+=4*r)for(let y=0,v=0;y<r;y++,v+=4){const S=y/(r-1),{start:A,end:C}=i.clips[f];d(m,v,A*(1-S)+C*S)}else for(let f=0,m=0;f<r;f++,m+=4)d(0,m,f/(r-1));return o}Le("AlphaImage",So),Le("RGBAImage",gr);class ug extends pr{createBucket(e){return new Rh(e)}constructor(e){super(e,cg),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){e==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Nh({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}}let Vh;var hg={get paint(){return Vh=Vh||new Wt({"hillshade-illumination-direction":new je(he.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new je(he.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new je(he.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new je(he.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new je(he.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new je(he.paint_hillshade["hillshade-accent-color"])})}};class pg extends pr{constructor(e){super(e,hg)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}}const dg=Nt([{name:"a_pos",components:2,type:"Int16"}],4),{members:fg}=dg;var Oc={exports:{}};function Rl(i,e,r){r=r||2;var a,o,d,f,m,y,v,S=e&&e.length,A=S?e[0]*r:i.length,C=Uh(i,0,A,r,!0),z=[];if(!C||C.next===C.prev)return z;if(S&&(C=(function(O,q,H,re){var Y,ae,oe,_e=[];for(Y=0,ae=q.length;Y<ae;Y++)(oe=Uh(O,q[Y]*re,Y<ae-1?q[Y+1]*re:O.length,re,!1))===oe.next&&(oe.steiner=!0),_e.push(wg(oe));for(_e.sort(xg),Y=0;Y<_e.length;Y++)H=vg(_e[Y],H);return H})(i,e,C,r)),i.length>80*r){a=d=i[0],o=f=i[1];for(var D=r;D<A;D+=r)(m=i[D])<a&&(a=m),(y=i[D+1])<o&&(o=y),m>d&&(d=m),y>f&&(f=y);v=(v=Math.max(d-a,f-o))!==0?32767/v:0}return To(C,z,r,a,o,v,0),z}function Uh(i,e,r,a,o){var d,f;if(o===Uc(i,e,r,a)>0)for(d=e;d<r;d+=a)f=qh(d,i[d],i[d+1],f);else for(d=r-a;d>=e;d-=a)f=qh(d,i[d],i[d+1],f);return f&&Bl(f,f.next)&&(Ao(f),f=f.next),f}function Ma(i,e){if(!i)return i;e||(e=i);var r,a=i;do if(r=!1,a.steiner||!Bl(a,a.next)&&Kt(a.prev,a,a.next)!==0)a=a.next;else{if(Ao(a),(a=e=a.prev)===a.next)break;r=!0}while(r||a!==e);return e}function To(i,e,r,a,o,d,f){if(i){!f&&d&&(function(S,A,C,z){var D=S;do D.z===0&&(D.z=Nc(D.x,D.y,A,C,z)),D.prevZ=D.prev,D.nextZ=D.next,D=D.next;while(D!==S);D.prevZ.nextZ=null,D.prevZ=null,(function(O){var q,H,re,Y,ae,oe,_e,De,Oe=1;do{for(H=O,O=null,ae=null,oe=0;H;){for(oe++,re=H,_e=0,q=0;q<Oe&&(_e++,re=re.nextZ);q++);for(De=Oe;_e>0||De>0&&re;)_e!==0&&(De===0||!re||H.z<=re.z)?(Y=H,H=H.nextZ,_e--):(Y=re,re=re.nextZ,De--),ae?ae.nextZ=Y:O=Y,Y.prevZ=ae,ae=Y;H=re}ae.nextZ=null,Oe*=2}while(oe>1)})(D)})(i,a,o,d);for(var m,y,v=i;i.prev!==i.next;)if(m=i.prev,y=i.next,d?gg(i,a,o,d):mg(i))e.push(m.i/r|0),e.push(i.i/r|0),e.push(y.i/r|0),Ao(i),i=y.next,v=y.next;else if((i=y)===v){f?f===1?To(i=_g(Ma(i),e,r),e,r,a,o,d,2):f===2&&yg(i,e,r,a,o,d):To(Ma(i),e,r,a,o,d,1);break}}}function mg(i){var e=i.prev,r=i,a=i.next;if(Kt(e,r,a)>=0)return!1;for(var o=e.x,d=r.x,f=a.x,m=e.y,y=r.y,v=a.y,S=o<d?o<f?o:f:d<f?d:f,A=m<y?m<v?m:v:y<v?y:v,C=o>d?o>f?o:f:d>f?d:f,z=m>y?m>v?m:v:y>v?y:v,D=a.next;D!==e;){if(D.x>=S&&D.x<=C&&D.y>=A&&D.y<=z&&_s(o,m,d,y,f,v,D.x,D.y)&&Kt(D.prev,D,D.next)>=0)return!1;D=D.next}return!0}function gg(i,e,r,a){var o=i.prev,d=i,f=i.next;if(Kt(o,d,f)>=0)return!1;for(var m=o.x,y=d.x,v=f.x,S=o.y,A=d.y,C=f.y,z=m<y?m<v?m:v:y<v?y:v,D=S<A?S<C?S:C:A<C?A:C,O=m>y?m>v?m:v:y>v?y:v,q=S>A?S>C?S:C:A>C?A:C,H=Nc(z,D,e,r,a),re=Nc(O,q,e,r,a),Y=i.prevZ,ae=i.nextZ;Y&&Y.z>=H&&ae&&ae.z<=re;){if(Y.x>=z&&Y.x<=O&&Y.y>=D&&Y.y<=q&&Y!==o&&Y!==f&&_s(m,S,y,A,v,C,Y.x,Y.y)&&Kt(Y.prev,Y,Y.next)>=0||(Y=Y.prevZ,ae.x>=z&&ae.x<=O&&ae.y>=D&&ae.y<=q&&ae!==o&&ae!==f&&_s(m,S,y,A,v,C,ae.x,ae.y)&&Kt(ae.prev,ae,ae.next)>=0))return!1;ae=ae.nextZ}for(;Y&&Y.z>=H;){if(Y.x>=z&&Y.x<=O&&Y.y>=D&&Y.y<=q&&Y!==o&&Y!==f&&_s(m,S,y,A,v,C,Y.x,Y.y)&&Kt(Y.prev,Y,Y.next)>=0)return!1;Y=Y.prevZ}for(;ae&&ae.z<=re;){if(ae.x>=z&&ae.x<=O&&ae.y>=D&&ae.y<=q&&ae!==o&&ae!==f&&_s(m,S,y,A,v,C,ae.x,ae.y)&&Kt(ae.prev,ae,ae.next)>=0)return!1;ae=ae.nextZ}return!0}function _g(i,e,r){var a=i;do{var o=a.prev,d=a.next.next;!Bl(o,d)&&$h(o,a,a.next,d)&&Io(o,d)&&Io(d,o)&&(e.push(o.i/r|0),e.push(a.i/r|0),e.push(d.i/r|0),Ao(a),Ao(a.next),a=i=d),a=a.next}while(a!==i);return Ma(a)}function yg(i,e,r,a,o,d){var f=i;do{for(var m=f.next.next;m!==f.prev;){if(f.i!==m.i&&Sg(f,m)){var y=jh(f,m);return f=Ma(f,f.next),y=Ma(y,y.next),To(f,e,r,a,o,d,0),void To(y,e,r,a,o,d,0)}m=m.next}f=f.next}while(f!==i)}function xg(i,e){return i.x-e.x}function vg(i,e){var r=(function(o,d){var f,m=d,y=o.x,v=o.y,S=-1/0;do{if(v<=m.y&&v>=m.next.y&&m.next.y!==m.y){var A=m.x+(v-m.y)*(m.next.x-m.x)/(m.next.y-m.y);if(A<=y&&A>S&&(S=A,f=m.x<m.next.x?m:m.next,A===y))return f}m=m.next}while(m!==d);if(!f)return null;var C,z=f,D=f.x,O=f.y,q=1/0;m=f;do y>=m.x&&m.x>=D&&y!==m.x&&_s(v<O?y:S,v,D,O,v<O?S:y,v,m.x,m.y)&&(C=Math.abs(v-m.y)/(y-m.x),Io(m,o)&&(C<q||C===q&&(m.x>f.x||m.x===f.x&&bg(f,m)))&&(f=m,q=C)),m=m.next;while(m!==z);return f})(i,e);if(!r)return e;var a=jh(r,i);return Ma(a,a.next),Ma(r,r.next)}function bg(i,e){return Kt(i.prev,i,e.prev)<0&&Kt(e.next,i,i.next)<0}function Nc(i,e,r,a,o){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-r)*o|0)|i<<8))|i<<4))|i<<2))|i<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-a)*o|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function wg(i){var e=i,r=i;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==i);return r}function _s(i,e,r,a,o,d,f,m){return(o-f)*(e-m)>=(i-f)*(d-m)&&(i-f)*(a-m)>=(r-f)*(e-m)&&(r-f)*(d-m)>=(o-f)*(a-m)}function Sg(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!(function(r,a){var o=r;do{if(o.i!==r.i&&o.next.i!==r.i&&o.i!==a.i&&o.next.i!==a.i&&$h(o,o.next,r,a))return!0;o=o.next}while(o!==r);return!1})(i,e)&&(Io(i,e)&&Io(e,i)&&(function(r,a){var o=r,d=!1,f=(r.x+a.x)/2,m=(r.y+a.y)/2;do o.y>m!=o.next.y>m&&o.next.y!==o.y&&f<(o.next.x-o.x)*(m-o.y)/(o.next.y-o.y)+o.x&&(d=!d),o=o.next;while(o!==r);return d})(i,e)&&(Kt(i.prev,i,e.prev)||Kt(i,e.prev,e))||Bl(i,e)&&Kt(i.prev,i,i.next)>0&&Kt(e.prev,e,e.next)>0)}function Kt(i,e,r){return(e.y-i.y)*(r.x-e.x)-(e.x-i.x)*(r.y-e.y)}function Bl(i,e){return i.x===e.x&&i.y===e.y}function $h(i,e,r,a){var o=Nl(Kt(i,e,r)),d=Nl(Kt(i,e,a)),f=Nl(Kt(r,a,i)),m=Nl(Kt(r,a,e));return o!==d&&f!==m||!(o!==0||!Ol(i,r,e))||!(d!==0||!Ol(i,a,e))||!(f!==0||!Ol(r,i,a))||!(m!==0||!Ol(r,e,a))}function Ol(i,e,r){return e.x<=Math.max(i.x,r.x)&&e.x>=Math.min(i.x,r.x)&&e.y<=Math.max(i.y,r.y)&&e.y>=Math.min(i.y,r.y)}function Nl(i){return i>0?1:i<0?-1:0}function Io(i,e){return Kt(i.prev,i,i.next)<0?Kt(i,e,i.next)>=0&&Kt(i,i.prev,e)>=0:Kt(i,e,i.prev)<0||Kt(i,i.next,e)<0}function jh(i,e){var r=new Vc(i.i,i.x,i.y),a=new Vc(e.i,e.x,e.y),o=i.next,d=e.prev;return i.next=e,e.prev=i,r.next=o,o.prev=r,a.next=r,r.prev=a,d.next=a,a.prev=d,a}function qh(i,e,r,a){var o=new Vc(i,e,r);return a?(o.next=a.next,o.prev=a,a.next.prev=o,a.next=o):(o.prev=o,o.next=o),o}function Ao(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Vc(i,e,r){this.i=i,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Uc(i,e,r,a){for(var o=0,d=e,f=r-a;d<r;d+=a)o+=(i[f]-i[d])*(i[d+1]+i[f+1]),f=d;return o}Oc.exports=Rl,Oc.exports.default=Rl,Rl.deviation=function(i,e,r,a){var o=e&&e.length,d=Math.abs(Uc(i,0,o?e[0]*r:i.length,r));if(o)for(var f=0,m=e.length;f<m;f++)d-=Math.abs(Uc(i,e[f]*r,f<m-1?e[f+1]*r:i.length,r));var y=0;for(f=0;f<a.length;f+=3){var v=a[f]*r,S=a[f+1]*r,A=a[f+2]*r;y+=Math.abs((i[v]-i[A])*(i[S+1]-i[v+1])-(i[v]-i[S])*(i[A+1]-i[v+1]))}return d===0&&y===0?0:Math.abs((y-d)/d)},Rl.flatten=function(i){for(var e=i[0][0].length,r={vertices:[],holes:[],dimensions:e},a=0,o=0;o<i.length;o++){for(var d=0;d<i[o].length;d++)for(var f=0;f<e;f++)r.vertices.push(i[o][d][f]);o>0&&r.holes.push(a+=i[o-1].length)}return r};var Zh=W(Oc.exports);function Tg(i,e,r,a,o){Gh(i,e,r,a||i.length-1,o||Ig)}function Gh(i,e,r,a,o){for(;a>r;){if(a-r>600){var d=a-r+1,f=e-r+1,m=Math.log(d),y=.5*Math.exp(2*m/3),v=.5*Math.sqrt(m*y*(d-y)/d)*(f-d/2<0?-1:1);Gh(i,e,Math.max(r,Math.floor(e-f*y/d+v)),Math.min(a,Math.floor(e+(d-f)*y/d+v)),o)}var S=i[e],A=r,C=a;for(ko(i,r,e),o(i[a],S)>0&&ko(i,r,a);A<C;){for(ko(i,A,C),A++,C--;o(i[A],S)<0;)A++;for(;o(i[C],S)>0;)C--}o(i[r],S)===0?ko(i,r,C):ko(i,++C,a),C<=e&&(r=C+1),e<=C&&(a=C-1)}}function ko(i,e,r){var a=i[e];i[e]=i[r],i[r]=a}function Ig(i,e){return i<e?-1:i>e?1:0}function $c(i,e){const r=i.length;if(r<=1)return[i];const a=[];let o,d;for(let f=0;f<r;f++){const m=zr(i[f]);m!==0&&(i[f].area=Math.abs(m),d===void 0&&(d=m<0),d===m<0?(o&&a.push(o),o=[i[f]]):o.push(i[f]))}if(o&&a.push(o),e>1)for(let f=0;f<a.length;f++)a[f].length<=e||(Tg(a[f],e,1,a[f].length-1,Ag),a[f]=a[f].slice(0,e));return a}function Ag(i,e){return e.area-i.area}function jc(i,e,r){const a=r.patternDependencies;let o=!1;for(const d of e){const f=d.paint.get(`${i}-pattern`);f.isConstant()||(o=!0);const m=f.constantOr(null);m&&(o=!0,a[m.to]=!0,a[m.from]=!0)}return o}function qc(i,e,r,a,o){const d=o.patternDependencies;for(const f of e){const m=f.paint.get(`${i}-pattern`).value;if(m.kind!=="constant"){let y=m.evaluate({zoom:a-1},r,{},o.availableImages),v=m.evaluate({zoom:a},r,{},o.availableImages),S=m.evaluate({zoom:a+1},r,{},o.availableImages);y=y&&y.name?y.name:y,v=v&&v.name?v.name:v,S=S&&S.name?S.name:S,d[y]=!0,d[v]=!0,d[S]=!0,r.patterns[f.id]={min:y,mid:v,max:S}}}return r}class Zc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new ut,this.indexArray=new pi,this.indexArray2=new ei,this.programConfigurations=new Ur(e.layers,e.zoom),this.segments=new Pt,this.segments2=new Pt,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,a){this.hasPattern=jc("fill",this.layers,r);const o=this.layers[0].layout.get("fill-sort-key"),d=!o.isConstant(),f=[];for(const{feature:m,id:y,index:v,sourceLayerIndex:S}of e){const A=this.layers[0]._featureFilter.needGeometry,C=Ea(m,A);if(!this.layers[0]._featureFilter.filter(new Mt(this.zoom),C,a))continue;const z=d?o.evaluate(C,{},a,r.availableImages):void 0,D={id:y,properties:m.properties,type:m.type,sourceLayerIndex:S,index:v,geometry:A?C.geometry:Ca(m),patterns:{},sortKey:z};f.push(D)}d&&f.sort(((m,y)=>m.sortKey-y.sortKey));for(const m of f){const{geometry:y,index:v,sourceLayerIndex:S}=m;if(this.hasPattern){const A=qc("fill",this.layers,m,this.zoom,r);this.patternFeatures.push(A)}else this.addFeature(m,y,v,a,{});r.featureIndex.insert(e[v].feature,y,v,S,this.index)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}addFeatures(e,r,a){for(const o of this.patternFeatures)this.addFeature(o,o.geometry,o.index,r,a)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,fg),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,r,a,o,d){for(const f of $c(r,500)){let m=0;for(const z of f)m+=z.length;const y=this.segments.prepareSegment(m,this.layoutVertexArray,this.indexArray),v=y.vertexLength,S=[],A=[];for(const z of f){if(z.length===0)continue;z!==f[0]&&A.push(S.length/2);const D=this.segments2.prepareSegment(z.length,this.layoutVertexArray,this.indexArray2),O=D.vertexLength;this.layoutVertexArray.emplaceBack(z[0].x,z[0].y),this.indexArray2.emplaceBack(O+z.length-1,O),S.push(z[0].x),S.push(z[0].y);for(let q=1;q<z.length;q++)this.layoutVertexArray.emplaceBack(z[q].x,z[q].y),this.indexArray2.emplaceBack(O+q-1,O+q),S.push(z[q].x),S.push(z[q].y);D.vertexLength+=z.length,D.primitiveLength+=z.length}const C=Zh(S,A);for(let z=0;z<C.length;z+=3)this.indexArray.emplaceBack(v+C[z],v+C[z+1],v+C[z+2]);y.vertexLength+=m,y.primitiveLength+=C.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,d,o)}}let Hh,Wh;Le("FillBucket",Zc,{omit:["layers","patternFeatures"]});var kg={get paint(){return Wh=Wh||new Wt({"fill-antialias":new je(he.paint_fill["fill-antialias"]),"fill-opacity":new He(he.paint_fill["fill-opacity"]),"fill-color":new He(he.paint_fill["fill-color"]),"fill-outline-color":new He(he.paint_fill["fill-outline-color"]),"fill-translate":new je(he.paint_fill["fill-translate"]),"fill-translate-anchor":new je(he.paint_fill["fill-translate-anchor"]),"fill-pattern":new Ia(he.paint_fill["fill-pattern"])})},get layout(){return Hh=Hh||new Wt({"fill-sort-key":new He(he.layout_fill["fill-sort-key"])})}};class Cg extends pr{constructor(e){super(e,kg)}recalculate(e,r){super.recalculate(e,r);const a=this.paint._values["fill-outline-color"];a.value.kind==="constant"&&a.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new Zc(e)}queryRadius(){return Dl(this.paint.get("fill-translate"))}queryIntersectsFeature(e,r,a,o,d,f,m){return Eh(Ll(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),f.angle,m),o)}isTileClipped(){return!0}}const Eg=Nt([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Mg=Nt([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Pg}=Eg;var ta={},zg=Se,Xh=ys;function ys(i,e,r,a,o){this.properties={},this.extent=r,this.type=0,this._pbf=i,this._geometry=-1,this._keys=a,this._values=o,i.readFields(Dg,this,e)}function Dg(i,e,r){i==1?e.id=r.readVarint():i==2?(function(a,o){for(var d=a.readVarint()+a.pos;a.pos<d;){var f=o._keys[a.readVarint()],m=o._values[a.readVarint()];o.properties[f]=m}})(r,e):i==3?e.type=r.readVarint():i==4&&(e._geometry=r.pos)}function Lg(i){for(var e,r,a=0,o=0,d=i.length,f=d-1;o<d;f=o++)a+=((r=i[f]).x-(e=i[o]).x)*(e.y+r.y);return a}ys.types=["Unknown","Point","LineString","Polygon"],ys.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var e,r=i.readVarint()+i.pos,a=1,o=0,d=0,f=0,m=[];i.pos<r;){if(o<=0){var y=i.readVarint();a=7&y,o=y>>3}if(o--,a===1||a===2)d+=i.readSVarint(),f+=i.readSVarint(),a===1&&(e&&m.push(e),e=[]),e.push(new zg(d,f));else{if(a!==7)throw new Error("unknown command "+a);e&&e.push(e[0].clone())}}return e&&m.push(e),m},ys.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var e=i.readVarint()+i.pos,r=1,a=0,o=0,d=0,f=1/0,m=-1/0,y=1/0,v=-1/0;i.pos<e;){if(a<=0){var S=i.readVarint();r=7&S,a=S>>3}if(a--,r===1||r===2)(o+=i.readSVarint())<f&&(f=o),o>m&&(m=o),(d+=i.readSVarint())<y&&(y=d),d>v&&(v=d);else if(r!==7)throw new Error("unknown command "+r)}return[f,y,m,v]},ys.prototype.toGeoJSON=function(i,e,r){var a,o,d=this.extent*Math.pow(2,r),f=this.extent*i,m=this.extent*e,y=this.loadGeometry(),v=ys.types[this.type];function S(z){for(var D=0;D<z.length;D++){var O=z[D];z[D]=[360*(O.x+f)/d-180,360/Math.PI*Math.atan(Math.exp((180-360*(O.y+m)/d)*Math.PI/180))-90]}}switch(this.type){case 1:var A=[];for(a=0;a<y.length;a++)A[a]=y[a][0];S(y=A);break;case 2:for(a=0;a<y.length;a++)S(y[a]);break;case 3:for(y=(function(z){var D=z.length;if(D<=1)return[z];for(var O,q,H=[],re=0;re<D;re++){var Y=Lg(z[re]);Y!==0&&(q===void 0&&(q=Y<0),q===Y<0?(O&&H.push(O),O=[z[re]]):O.push(z[re]))}return O&&H.push(O),H})(y),a=0;a<y.length;a++)for(o=0;o<y[a].length;o++)S(y[a][o])}y.length===1?y=y[0]:v="Multi"+v;var C={type:"Feature",geometry:{type:v,coordinates:y},properties:this.properties};return"id"in this&&(C.id=this.id),C};var Fg=Xh,Kh=Yh;function Yh(i,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=i,this._keys=[],this._values=[],this._features=[],i.readFields(Rg,this,e),this.length=this._features.length}function Rg(i,e,r){i===15?e.version=r.readVarint():i===1?e.name=r.readString():i===5?e.extent=r.readVarint():i===2?e._features.push(r.pos):i===3?e._keys.push(r.readString()):i===4&&e._values.push((function(a){for(var o=null,d=a.readVarint()+a.pos;a.pos<d;){var f=a.readVarint()>>3;o=f===1?a.readString():f===2?a.readFloat():f===3?a.readDouble():f===4?a.readVarint64():f===5?a.readVarint():f===6?a.readSVarint():f===7?a.readBoolean():null}return o})(r))}Yh.prototype.feature=function(i){if(i<0||i>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[i];var e=this._pbf.readVarint()+this._pbf.pos;return new Fg(this._pbf,e,this.extent,this._keys,this._values)};var Bg=Kh;function Og(i,e,r){if(i===3){var a=new Bg(r,r.readVarint()+r.pos);a.length&&(e[a.name]=a)}}ta.VectorTile=function(i,e){this.layers=i.readFields(Og,{},e)},ta.VectorTileFeature=Xh,ta.VectorTileLayer=Kh;const Ng=ta.VectorTileFeature.types,Gc=Math.pow(2,13);function Co(i,e,r,a,o,d,f,m){i.emplaceBack(e,r,2*Math.floor(a*Gc)+f,o*Gc*2,d*Gc*2,Math.round(m))}class Hc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new Ee,this.centroidVertexArray=new Te,this.indexArray=new pi,this.programConfigurations=new Ur(e.layers,e.zoom),this.segments=new Pt,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,a){this.features=[],this.hasPattern=jc("fill-extrusion",this.layers,r);for(const{feature:o,id:d,index:f,sourceLayerIndex:m}of e){const y=this.layers[0]._featureFilter.needGeometry,v=Ea(o,y);if(!this.layers[0]._featureFilter.filter(new Mt(this.zoom),v,a))continue;const S={id:d,sourceLayerIndex:m,index:f,geometry:y?v.geometry:Ca(o),properties:o.properties,type:o.type,patterns:{}};this.hasPattern?this.features.push(qc("fill-extrusion",this.layers,S,this.zoom,r)):this.addFeature(S,S.geometry,f,a,{}),r.featureIndex.insert(o,S.geometry,f,m,this.index,!0)}}addFeatures(e,r,a){for(const o of this.features){const{geometry:d}=o;this.addFeature(o,d,o.index,r,a)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Pg),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Mg.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,r,a,o,d){const f={x:0,y:0,vertexCount:0};for(const m of $c(r,500)){let y=0;for(const D of m)y+=D.length;let v=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const D of m){if(D.length===0||Ug(D))continue;let O=0;for(let q=0;q<D.length;q++){const H=D[q];if(q>=1){const re=D[q-1];if(!Vg(H,re)){v.vertexLength+4>Pt.MAX_VERTEX_ARRAY_LENGTH&&(v=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const Y=H.sub(re)._perp()._unit(),ae=re.dist(H);O+ae>32768&&(O=0),Co(this.layoutVertexArray,H.x,H.y,Y.x,Y.y,0,0,O),Co(this.layoutVertexArray,H.x,H.y,Y.x,Y.y,0,1,O),f.x+=2*H.x,f.y+=2*H.y,f.vertexCount+=2,O+=ae,Co(this.layoutVertexArray,re.x,re.y,Y.x,Y.y,0,0,O),Co(this.layoutVertexArray,re.x,re.y,Y.x,Y.y,0,1,O),f.x+=2*re.x,f.y+=2*re.y,f.vertexCount+=2;const oe=v.vertexLength;this.indexArray.emplaceBack(oe,oe+2,oe+1),this.indexArray.emplaceBack(oe+1,oe+2,oe+3),v.vertexLength+=4,v.primitiveLength+=2}}}}if(v.vertexLength+y>Pt.MAX_VERTEX_ARRAY_LENGTH&&(v=this.segments.prepareSegment(y,this.layoutVertexArray,this.indexArray)),Ng[e.type]!=="Polygon")continue;const S=[],A=[],C=v.vertexLength;for(const D of m)if(D.length!==0){D!==m[0]&&A.push(S.length/2);for(let O=0;O<D.length;O++){const q=D[O];Co(this.layoutVertexArray,q.x,q.y,0,0,1,1,0),f.x+=q.x,f.y+=q.y,f.vertexCount+=1,S.push(q.x),S.push(q.y)}}const z=Zh(S,A);for(let D=0;D<z.length;D+=3)this.indexArray.emplaceBack(C+z[D],C+z[D+2],C+z[D+1]);v.primitiveLength+=z.length/3,v.vertexLength+=y}for(let m=0;m<f.vertexCount;m++)this.centroidVertexArray.emplaceBack(Math.floor(f.x/f.vertexCount),Math.floor(f.y/f.vertexCount));this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,d,o)}}function Vg(i,e){return i.x===e.x&&(i.x<0||i.x>Jt)||i.y===e.y&&(i.y<0||i.y>Jt)}function Ug(i){return i.every((e=>e.x<0))||i.every((e=>e.x>Jt))||i.every((e=>e.y<0))||i.every((e=>e.y>Jt))}let Jh;Le("FillExtrusionBucket",Hc,{omit:["layers","features"]});var $g={get paint(){return Jh=Jh||new Wt({"fill-extrusion-opacity":new je(he["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new He(he["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new je(he["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new je(he["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Ia(he["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new He(he["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new He(he["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new je(he["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class jg extends pr{constructor(e){super(e,$g)}createBucket(e){return new Hc(e)}queryRadius(){return Dl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(e,r,a,o,d,f,m,y){const v=Ll(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),f.angle,m),S=this.paint.get("fill-extrusion-height").evaluate(r,a),A=this.paint.get("fill-extrusion-base").evaluate(r,a),C=(function(D,O,q,H){const re=[];for(const Y of D){const ae=[Y.x,Y.y,0,1];Fl(ae,ae,O),re.push(new ge(ae[0]/ae[3],ae[1]/ae[3]))}return re})(v,y),z=(function(D,O,q,H){const re=[],Y=[],ae=H[8]*O,oe=H[9]*O,_e=H[10]*O,De=H[11]*O,Oe=H[8]*q,Pe=H[9]*q,Me=H[10]*q,Ie=H[11]*q;for(const Fe of D){const ke=[],we=[];for(const Ze of Fe){const Ue=Ze.x,lt=Ze.y,zt=H[0]*Ue+H[4]*lt+H[12],Ft=H[1]*Ue+H[5]*lt+H[13],ri=H[2]*Ue+H[6]*lt+H[14],fr=H[3]*Ue+H[7]*lt+H[15],Oi=ri+_e,Qt=fr+De,fi=zt+Oe,xi=Ft+Pe,Ni=ri+Me,Vi=fr+Ie,ni=new ge((zt+ae)/Qt,(Ft+oe)/Qt);ni.z=Oi/Qt,ke.push(ni);const ai=new ge(fi/Vi,xi/Vi);ai.z=Ni/Vi,we.push(ai)}re.push(ke),Y.push(we)}return[re,Y]})(o,A,S,y);return(function(D,O,q){let H=1/0;Eh(q,O)&&(H=Qh(q,O[0]));for(let re=0;re<O.length;re++){const Y=O[re],ae=D[re];for(let oe=0;oe<Y.length-1;oe++){const _e=Y[oe],De=[_e,Y[oe+1],ae[oe+1],ae[oe],_e];Ch(q,De)&&(H=Math.min(H,Qh(q,De)))}}return H!==1/0&&H})(z[0],z[1],C)}}function Eo(i,e){return i.x*e.x+i.y*e.y}function Qh(i,e){if(i.length===1){let r=0;const a=e[r++];let o;for(;!o||a.equals(o);)if(o=e[r++],!o)return 1/0;for(;r<e.length;r++){const d=e[r],f=i[0],m=o.sub(a),y=d.sub(a),v=f.sub(a),S=Eo(m,m),A=Eo(m,y),C=Eo(y,y),z=Eo(v,m),D=Eo(v,y),O=S*C-A*A,q=(C*z-A*D)/O,H=(S*D-A*z)/O,re=a.z*(1-q-H)+o.z*q+d.z*H;if(isFinite(re))return re}return 1/0}{let r=1/0;for(const a of e)r=Math.min(r,a.z);return r}}const qg=Nt([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:Zg}=qg,Gg=Nt([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:Hg}=Gg,Wg=ta.VectorTileFeature.types,Xg=Math.cos(Math.PI/180*37.5),ep=Math.pow(2,14)/.5;class Wc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((r=>{this.gradients[r.id]={}})),this.layoutVertexArray=new We,this.layoutVertexArray2=new Ne,this.indexArray=new pi,this.programConfigurations=new Ur(e.layers,e.zoom),this.segments=new Pt,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,a){this.hasPattern=jc("line",this.layers,r);const o=this.layers[0].layout.get("line-sort-key"),d=!o.isConstant(),f=[];for(const{feature:m,id:y,index:v,sourceLayerIndex:S}of e){const A=this.layers[0]._featureFilter.needGeometry,C=Ea(m,A);if(!this.layers[0]._featureFilter.filter(new Mt(this.zoom),C,a))continue;const z=d?o.evaluate(C,{},a):void 0,D={id:y,properties:m.properties,type:m.type,sourceLayerIndex:S,index:v,geometry:A?C.geometry:Ca(m),patterns:{},sortKey:z};f.push(D)}d&&f.sort(((m,y)=>m.sortKey-y.sortKey));for(const m of f){const{geometry:y,index:v,sourceLayerIndex:S}=m;if(this.hasPattern){const A=qc("line",this.layers,m,this.zoom,r);this.patternFeatures.push(A)}else this.addFeature(m,y,v,a,{});r.featureIndex.insert(e[v].feature,y,v,S,this.index)}}update(e,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,a)}addFeatures(e,r,a){for(const o of this.patternFeatures)this.addFeature(o,o.geometry,o.index,r,a)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Hg)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Zg),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,r,a,o,d){const f=this.layers[0].layout,m=f.get("line-join").evaluate(e,{}),y=f.get("line-cap"),v=f.get("line-miter-limit"),S=f.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const A of r)this.addLine(A,e,m,y,v,S);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,d,o)}addLine(e,r,a,o,d,f){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let H=0;H<e.length-1;H++)this.totalDistance+=e[H].dist(e[H+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const m=Wg[r.type]==="Polygon";let y=e.length;for(;y>=2&&e[y-1].equals(e[y-2]);)y--;let v=0;for(;v<y-1&&e[v].equals(e[v+1]);)v++;if(y<(m?3:2))return;a==="bevel"&&(d=1.05);const S=this.overscaling<=16?15*Jt/(512*this.overscaling):0,A=this.segments.prepareSegment(10*y,this.layoutVertexArray,this.indexArray);let C,z,D,O,q;this.e1=this.e2=-1,m&&(C=e[y-2],q=e[v].sub(C)._unit()._perp());for(let H=v;H<y;H++){if(D=H===y-1?m?e[v+1]:void 0:e[H+1],D&&e[H].equals(D))continue;q&&(O=q),C&&(z=C),C=e[H],q=D?D.sub(C)._unit()._perp():O,O=O||q;let re=O.add(q);re.x===0&&re.y===0||re._unit();const Y=O.x*q.x+O.y*q.y,ae=re.x*q.x+re.y*q.y,oe=ae!==0?1/ae:1/0,_e=2*Math.sqrt(2-2*ae),De=ae<Xg&&z&&D,Oe=O.x*q.y-O.y*q.x>0;if(De&&H>v){const Ie=C.dist(z);if(Ie>2*S){const Fe=C.sub(C.sub(z)._mult(S/Ie)._round());this.updateDistance(z,Fe),this.addCurrentVertex(Fe,O,0,0,A),z=Fe}}const Pe=z&&D;let Me=Pe?a:m?"butt":o;if(Pe&&Me==="round"&&(oe<f?Me="miter":oe<=2&&(Me="fakeround")),Me==="miter"&&oe>d&&(Me="bevel"),Me==="bevel"&&(oe>2&&(Me="flipbevel"),oe<d&&(Me="miter")),z&&this.updateDistance(z,C),Me==="miter")re._mult(oe),this.addCurrentVertex(C,re,0,0,A);else if(Me==="flipbevel"){if(oe>100)re=q.mult(-1);else{const Ie=oe*O.add(q).mag()/O.sub(q).mag();re._perp()._mult(Ie*(Oe?-1:1))}this.addCurrentVertex(C,re,0,0,A),this.addCurrentVertex(C,re.mult(-1),0,0,A)}else if(Me==="bevel"||Me==="fakeround"){const Ie=-Math.sqrt(oe*oe-1),Fe=Oe?Ie:0,ke=Oe?0:Ie;if(z&&this.addCurrentVertex(C,O,Fe,ke,A),Me==="fakeround"){const we=Math.round(180*_e/Math.PI/20);for(let Ze=1;Ze<we;Ze++){let Ue=Ze/we;if(Ue!==.5){const zt=Ue-.5;Ue+=Ue*zt*(Ue-1)*((1.0904+Y*(Y*(3.55645-1.43519*Y)-3.2452))*zt*zt+(.848013+Y*(.215638*Y-1.06021)))}const lt=q.sub(O)._mult(Ue)._add(O)._unit()._mult(Oe?-1:1);this.addHalfVertex(C,lt.x,lt.y,!1,Oe,0,A)}}D&&this.addCurrentVertex(C,q,-Fe,-ke,A)}else if(Me==="butt")this.addCurrentVertex(C,re,0,0,A);else if(Me==="square"){const Ie=z?1:-1;this.addCurrentVertex(C,re,Ie,Ie,A)}else Me==="round"&&(z&&(this.addCurrentVertex(C,O,0,0,A),this.addCurrentVertex(C,O,1,1,A,!0)),D&&(this.addCurrentVertex(C,q,-1,-1,A,!0),this.addCurrentVertex(C,q,0,0,A)));if(De&&H<y-1){const Ie=C.dist(D);if(Ie>2*S){const Fe=C.add(D.sub(C)._mult(S/Ie)._round());this.updateDistance(C,Fe),this.addCurrentVertex(Fe,q,0,0,A),C=Fe}}}}addCurrentVertex(e,r,a,o,d,f=!1){const m=r.y*o-r.x,y=-r.y-r.x*o;this.addHalfVertex(e,r.x+r.y*a,r.y-r.x*a,f,!1,a,d),this.addHalfVertex(e,m,y,f,!0,-o,d),this.distance>ep/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,r,a,o,d,f))}addHalfVertex({x:e,y:r},a,o,d,f,m,y){const v=.5*(this.lineClips?this.scaledDistance*(ep-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(d?1:0),(r<<1)+(f?1:0),Math.round(63*a)+128,Math.round(63*o)+128,1+(m===0?0:m<0?-1:1)|(63&v)<<2,v>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const S=y.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,S),y.primitiveLength++),f?this.e2=S:this.e1=S}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,r){this.distance+=e.dist(r),this.updateScaledDistance()}}let tp,ip;Le("LineBucket",Wc,{omit:["layers","patternFeatures"]});var rp={get paint(){return ip=ip||new Wt({"line-opacity":new He(he.paint_line["line-opacity"]),"line-color":new He(he.paint_line["line-color"]),"line-translate":new je(he.paint_line["line-translate"]),"line-translate-anchor":new je(he.paint_line["line-translate-anchor"]),"line-width":new He(he.paint_line["line-width"]),"line-gap-width":new He(he.paint_line["line-gap-width"]),"line-offset":new He(he.paint_line["line-offset"]),"line-blur":new He(he.paint_line["line-blur"]),"line-dasharray":new ho(he.paint_line["line-dasharray"]),"line-pattern":new Ia(he.paint_line["line-pattern"]),"line-gradient":new po(he.paint_line["line-gradient"])})},get layout(){return tp=tp||new Wt({"line-cap":new je(he.layout_line["line-cap"]),"line-join":new He(he.layout_line["line-join"]),"line-miter-limit":new je(he.layout_line["line-miter-limit"]),"line-round-limit":new je(he.layout_line["line-round-limit"]),"line-sort-key":new He(he.layout_line["line-sort-key"])})}};class Kg extends He{possiblyEvaluate(e,r){return r=new Mt(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(e,r)}evaluate(e,r,a,o){return r=Ve({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(e,r,a,o)}}let Vl;class Yg extends pr{constructor(e){super(e,rp),this.gradientVersion=0,Vl||(Vl=new Kg(rp.paint.properties["line-width"].specification),Vl.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e==="line-gradient"){const r=this.gradientExpression();this.stepInterpolant=!!(function(a){return a._styleExpression!==void 0})(r)&&r._styleExpression.expression instanceof tn,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,r){super.recalculate(e,r),this.paint._values["line-floorwidth"]=Vl.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Wc(e)}queryRadius(e){const r=e,a=np(bo("line-width",this,r),bo("line-gap-width",this,r)),o=bo("line-offset",this,r);return a/2+Math.abs(o)+Dl(this.paint.get("line-translate"))}queryIntersectsFeature(e,r,a,o,d,f,m){const y=Ll(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),f.angle,m),v=m/2*np(this.paint.get("line-width").evaluate(r,a),this.paint.get("line-gap-width").evaluate(r,a)),S=this.paint.get("line-offset").evaluate(r,a);return S&&(o=(function(A,C){const z=[];for(let D=0;D<A.length;D++){const O=A[D],q=[];for(let H=0;H<O.length;H++){const re=O[H-1],Y=O[H],ae=O[H+1],oe=H===0?new ge(0,0):Y.sub(re)._unit()._perp(),_e=H===O.length-1?new ge(0,0):ae.sub(Y)._unit()._perp(),De=oe._add(_e)._unit(),Oe=De.x*_e.x+De.y*_e.y;Oe!==0&&De._mult(1/Oe),q.push(De._mult(C)._add(Y))}z.push(q)}return z})(o,S*m)),(function(A,C,z){for(let D=0;D<C.length;D++){const O=C[D];if(A.length>=3){for(let q=0;q<O.length;q++)if(ms(A,O[q]))return!0}if(rg(A,O,z))return!0}return!1})(y,o,v)}isTileClipped(){return!0}}function np(i,e){return e>0?e+2*i:i}const Jg=Nt([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Qg=Nt([{name:"a_projected_pos",components:3,type:"Float32"}],4);Nt([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const e_=Nt([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);Nt([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const ap=Nt([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),t_=Nt([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function i_(i,e,r){return i.sections.forEach((a=>{a.text=(function(o,d,f){const m=d.layout.get("text-transform").evaluate(f,{});return m==="uppercase"?o=o.toLocaleUpperCase():m==="lowercase"&&(o=o.toLocaleLowerCase()),Ki.applyArabicShaping&&(o=Ki.applyArabicShaping(o)),o})(a.text,e,r)})),i}Nt([{name:"triangle",components:3,type:"Uint16"}]),Nt([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Nt([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),Nt([{type:"Float32",name:"offsetX"}]),Nt([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Nt([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Mo={"!":"︕","#":"",$:"","%":"","&":"","(":"︵",")":"︶","*":"","+":"",",":"︐","-":"︲",".":"・","/":"",":":"︓",";":"︔","<":"︿","=":"",">":"﹀","?":"︖","@":"","[":"﹇","\\":"","]":"﹈","^":"",_:"︳","`":"","{":"︷","|":"―","}":"︸","~":"","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","":"︲","—":"︱","":"﹃","":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","":"︹","":"︺","〖":"︗","〗":"︘","":"︕","":"︵","":"︶","":"︐","":"︲","":"・","":"︓","":"︔","":"︿","":"﹀","":"︖","":"﹇","":"﹈","_":"︳","":"︷","":"―","":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var ii=24,sp=It,op=function(i,e,r,a,o){var d,f,m=8*o-a-1,y=(1<<m)-1,v=y>>1,S=-7,A=o-1,C=-1,z=i[e+A];for(A+=C,d=z&(1<<-S)-1,z>>=-S,S+=m;S>0;d=256*d+i[e+A],A+=C,S-=8);for(f=d&(1<<-S)-1,d>>=-S,S+=a;S>0;f=256*f+i[e+A],A+=C,S-=8);if(d===0)d=1-v;else{if(d===y)return f?NaN:1/0*(z?-1:1);f+=Math.pow(2,a),d-=v}return(z?-1:1)*f*Math.pow(2,d-a)},lp=function(i,e,r,a,o,d){var f,m,y,v=8*d-o-1,S=(1<<v)-1,A=S>>1,C=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,z=0,D=1,O=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(m=isNaN(e)?1:0,f=S):(f=Math.floor(Math.log(e)/Math.LN2),e*(y=Math.pow(2,-f))<1&&(f--,y*=2),(e+=f+A>=1?C/y:C*Math.pow(2,1-A))*y>=2&&(f++,y/=2),f+A>=S?(m=0,f=S):f+A>=1?(m=(e*y-1)*Math.pow(2,o),f+=A):(m=e*Math.pow(2,A-1)*Math.pow(2,o),f=0));o>=8;i[r+z]=255&m,z+=D,m/=256,o-=8);for(f=f<<o|m,v+=o;v>0;i[r+z]=255&f,z+=D,f/=256,v-=8);i[r+z-D]|=128*O};function It(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}It.Varint=0,It.Fixed64=1,It.Bytes=2,It.Fixed32=5;var Xc=4294967296,cp=1/Xc,up=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function Mn(i){return i.type===It.Bytes?i.readVarint()+i.pos:i.pos+1}function xs(i,e,r){return r?4294967296*e+(i>>>0):4294967296*(e>>>0)+(i>>>0)}function hp(i,e,r){var a=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(a);for(var o=r.pos-1;o>=i;o--)r.buf[o+a]=r.buf[o]}function r_(i,e){for(var r=0;r<i.length;r++)e.writeVarint(i[r])}function n_(i,e){for(var r=0;r<i.length;r++)e.writeSVarint(i[r])}function a_(i,e){for(var r=0;r<i.length;r++)e.writeFloat(i[r])}function s_(i,e){for(var r=0;r<i.length;r++)e.writeDouble(i[r])}function o_(i,e){for(var r=0;r<i.length;r++)e.writeBoolean(i[r])}function l_(i,e){for(var r=0;r<i.length;r++)e.writeFixed32(i[r])}function c_(i,e){for(var r=0;r<i.length;r++)e.writeSFixed32(i[r])}function u_(i,e){for(var r=0;r<i.length;r++)e.writeFixed64(i[r])}function h_(i,e){for(var r=0;r<i.length;r++)e.writeSFixed64(i[r])}function Ul(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16)+16777216*i[e+3]}function vs(i,e,r){i[r]=e,i[r+1]=e>>>8,i[r+2]=e>>>16,i[r+3]=e>>>24}function pp(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16)+(i[e+3]<<24)}It.prototype={destroy:function(){this.buf=null},readFields:function(i,e,r){for(r=r||this.length;this.pos<r;){var a=this.readVarint(),o=a>>3,d=this.pos;this.type=7&a,i(o,e,this),this.pos===d&&this.skip(a)}return e},readMessage:function(i,e){return this.readFields(i,e,this.readVarint()+this.pos)},readFixed32:function(){var i=Ul(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=pp(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=Ul(this.buf,this.pos)+Ul(this.buf,this.pos+4)*Xc;return this.pos+=8,i},readSFixed64:function(){var i=Ul(this.buf,this.pos)+pp(this.buf,this.pos+4)*Xc;return this.pos+=8,i},readFloat:function(){var i=op(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=op(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var e,r,a=this.buf;return e=127&(r=a[this.pos++]),r<128?e:(e|=(127&(r=a[this.pos++]))<<7,r<128?e:(e|=(127&(r=a[this.pos++]))<<14,r<128?e:(e|=(127&(r=a[this.pos++]))<<21,r<128?e:(function(o,d,f){var m,y,v=f.buf;if(m=(112&(y=v[f.pos++]))>>4,y<128||(m|=(127&(y=v[f.pos++]))<<3,y<128)||(m|=(127&(y=v[f.pos++]))<<10,y<128)||(m|=(127&(y=v[f.pos++]))<<17,y<128)||(m|=(127&(y=v[f.pos++]))<<24,y<128)||(m|=(1&(y=v[f.pos++]))<<31,y<128))return xs(o,m,d);throw new Error("Expected varint not more than 10 bytes")})(e|=(15&(r=a[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?(i+1)/-2:i/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var i=this.readVarint()+this.pos,e=this.pos;return this.pos=i,i-e>=12&&up?(function(r,a,o){return up.decode(r.subarray(a,o))})(this.buf,e,i):(function(r,a,o){for(var d="",f=a;f<o;){var m,y,v,S=r[f],A=null,C=S>239?4:S>223?3:S>191?2:1;if(f+C>o)break;C===1?S<128&&(A=S):C===2?(192&(m=r[f+1]))==128&&(A=(31&S)<<6|63&m)<=127&&(A=null):C===3?(y=r[f+2],(192&(m=r[f+1]))==128&&(192&y)==128&&((A=(15&S)<<12|(63&m)<<6|63&y)<=2047||A>=55296&&A<=57343)&&(A=null)):C===4&&(y=r[f+2],v=r[f+3],(192&(m=r[f+1]))==128&&(192&y)==128&&(192&v)==128&&((A=(15&S)<<18|(63&m)<<12|(63&y)<<6|63&v)<=65535||A>=1114112)&&(A=null)),A===null?(A=65533,C=1):A>65535&&(A-=65536,d+=String.fromCharCode(A>>>10&1023|55296),A=56320|1023&A),d+=String.fromCharCode(A),f+=C}return d})(this.buf,e,i)},readBytes:function(){var i=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,i);return this.pos=i,e},readPackedVarint:function(i,e){if(this.type!==It.Bytes)return i.push(this.readVarint(e));var r=Mn(this);for(i=i||[];this.pos<r;)i.push(this.readVarint(e));return i},readPackedSVarint:function(i){if(this.type!==It.Bytes)return i.push(this.readSVarint());var e=Mn(this);for(i=i||[];this.pos<e;)i.push(this.readSVarint());return i},readPackedBoolean:function(i){if(this.type!==It.Bytes)return i.push(this.readBoolean());var e=Mn(this);for(i=i||[];this.pos<e;)i.push(this.readBoolean());return i},readPackedFloat:function(i){if(this.type!==It.Bytes)return i.push(this.readFloat());var e=Mn(this);for(i=i||[];this.pos<e;)i.push(this.readFloat());return i},readPackedDouble:function(i){if(this.type!==It.Bytes)return i.push(this.readDouble());var e=Mn(this);for(i=i||[];this.pos<e;)i.push(this.readDouble());return i},readPackedFixed32:function(i){if(this.type!==It.Bytes)return i.push(this.readFixed32());var e=Mn(this);for(i=i||[];this.pos<e;)i.push(this.readFixed32());return i},readPackedSFixed32:function(i){if(this.type!==It.Bytes)return i.push(this.readSFixed32());var e=Mn(this);for(i=i||[];this.pos<e;)i.push(this.readSFixed32());return i},readPackedFixed64:function(i){if(this.type!==It.Bytes)return i.push(this.readFixed64());var e=Mn(this);for(i=i||[];this.pos<e;)i.push(this.readFixed64());return i},readPackedSFixed64:function(i){if(this.type!==It.Bytes)return i.push(this.readSFixed64());var e=Mn(this);for(i=i||[];this.pos<e;)i.push(this.readSFixed64());return i},skip:function(i){var e=7&i;if(e===It.Varint)for(;this.buf[this.pos++]>127;);else if(e===It.Bytes)this.pos=this.readVarint()+this.pos;else if(e===It.Fixed32)this.pos+=4;else{if(e!==It.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(i,e){this.writeVarint(i<<3|e)},realloc:function(i){for(var e=this.length||16;e<this.pos+i;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(i){this.realloc(4),vs(this.buf,i,this.pos),this.pos+=4},writeSFixed32:function(i){this.realloc(4),vs(this.buf,i,this.pos),this.pos+=4},writeFixed64:function(i){this.realloc(8),vs(this.buf,-1&i,this.pos),vs(this.buf,Math.floor(i*cp),this.pos+4),this.pos+=8},writeSFixed64:function(i){this.realloc(8),vs(this.buf,-1&i,this.pos),vs(this.buf,Math.floor(i*cp),this.pos+4),this.pos+=8},writeVarint:function(i){(i=+i||0)>268435455||i<0?(function(e,r){var a,o;if(e>=0?(a=e%4294967296|0,o=e/4294967296|0):(o=~(-e/4294967296),4294967295^(a=~(-e%4294967296))?a=a+1|0:(a=0,o=o+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),(function(d,f,m){m.buf[m.pos++]=127&d|128,d>>>=7,m.buf[m.pos++]=127&d|128,d>>>=7,m.buf[m.pos++]=127&d|128,d>>>=7,m.buf[m.pos++]=127&d|128,m.buf[m.pos]=127&(d>>>=7)})(a,0,r),(function(d,f){var m=(7&d)<<4;f.buf[f.pos++]|=m|((d>>>=3)?128:0),d&&(f.buf[f.pos++]=127&d|((d>>>=7)?128:0),d&&(f.buf[f.pos++]=127&d|((d>>>=7)?128:0),d&&(f.buf[f.pos++]=127&d|((d>>>=7)?128:0),d&&(f.buf[f.pos++]=127&d|((d>>>=7)?128:0),d&&(f.buf[f.pos++]=127&d)))))})(o,r)})(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?2*-i-1:2*i)},writeBoolean:function(i){this.writeVarint(!!i)},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var e=this.pos;this.pos=(function(a,o,d){for(var f,m,y=0;y<o.length;y++){if((f=o.charCodeAt(y))>55295&&f<57344){if(!m){f>56319||y+1===o.length?(a[d++]=239,a[d++]=191,a[d++]=189):m=f;continue}if(f<56320){a[d++]=239,a[d++]=191,a[d++]=189,m=f;continue}f=m-55296<<10|f-56320|65536,m=null}else m&&(a[d++]=239,a[d++]=191,a[d++]=189,m=null);f<128?a[d++]=f:(f<2048?a[d++]=f>>6|192:(f<65536?a[d++]=f>>12|224:(a[d++]=f>>18|240,a[d++]=f>>12&63|128),a[d++]=f>>6&63|128),a[d++]=63&f|128)}return d})(this.buf,i,this.pos);var r=this.pos-e;r>=128&&hp(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(i){this.realloc(4),lp(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),lp(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var e=i.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=i[r]},writeRawMessage:function(i,e){this.pos++;var r=this.pos;i(e,this);var a=this.pos-r;a>=128&&hp(r,a,this),this.pos=r-1,this.writeVarint(a),this.pos+=a},writeMessage:function(i,e,r){this.writeTag(i,It.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(i,e){e.length&&this.writeMessage(i,r_,e)},writePackedSVarint:function(i,e){e.length&&this.writeMessage(i,n_,e)},writePackedBoolean:function(i,e){e.length&&this.writeMessage(i,o_,e)},writePackedFloat:function(i,e){e.length&&this.writeMessage(i,a_,e)},writePackedDouble:function(i,e){e.length&&this.writeMessage(i,s_,e)},writePackedFixed32:function(i,e){e.length&&this.writeMessage(i,l_,e)},writePackedSFixed32:function(i,e){e.length&&this.writeMessage(i,c_,e)},writePackedFixed64:function(i,e){e.length&&this.writeMessage(i,u_,e)},writePackedSFixed64:function(i,e){e.length&&this.writeMessage(i,h_,e)},writeBytesField:function(i,e){this.writeTag(i,It.Bytes),this.writeBytes(e)},writeFixed32Field:function(i,e){this.writeTag(i,It.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(i,e){this.writeTag(i,It.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(i,e){this.writeTag(i,It.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(i,e){this.writeTag(i,It.Fixed64),this.writeSFixed64(e)},writeVarintField:function(i,e){this.writeTag(i,It.Varint),this.writeVarint(e)},writeSVarintField:function(i,e){this.writeTag(i,It.Varint),this.writeSVarint(e)},writeStringField:function(i,e){this.writeTag(i,It.Bytes),this.writeString(e)},writeFloatField:function(i,e){this.writeTag(i,It.Fixed32),this.writeFloat(e)},writeDoubleField:function(i,e){this.writeTag(i,It.Fixed64),this.writeDouble(e)},writeBooleanField:function(i,e){this.writeVarintField(i,!!e)}};var Kc=W(sp);const Yc=3;function p_(i,e,r){i===1&&r.readMessage(d_,e)}function d_(i,e,r){if(i===3){const{id:a,bitmap:o,width:d,height:f,left:m,top:y,advance:v}=r.readMessage(f_,{});e.push({id:a,bitmap:new So({width:d+2*Yc,height:f+2*Yc},o),metrics:{width:d,height:f,left:m,top:y,advance:v}})}}function f_(i,e,r){i===1?e.id=r.readVarint():i===2?e.bitmap=r.readBytes():i===3?e.width=r.readVarint():i===4?e.height=r.readVarint():i===5?e.left=r.readSVarint():i===6?e.top=r.readSVarint():i===7&&(e.advance=r.readVarint())}const dp=Yc;function fp(i){let e=0,r=0;for(const f of i)e+=f.w*f.h,r=Math.max(r,f.w);i.sort(((f,m)=>m.h-f.h));const a=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let o=0,d=0;for(const f of i)for(let m=a.length-1;m>=0;m--){const y=a[m];if(!(f.w>y.w||f.h>y.h)){if(f.x=y.x,f.y=y.y,d=Math.max(d,f.y+f.h),o=Math.max(o,f.x+f.w),f.w===y.w&&f.h===y.h){const v=a.pop();m<a.length&&(a[m]=v)}else f.h===y.h?(y.x+=f.w,y.w-=f.w):f.w===y.w?(y.y+=f.h,y.h-=f.h):(a.push({x:y.x+f.w,y:y.y,w:y.w-f.w,h:f.h}),y.y+=f.h,y.h-=f.h);break}}return{w:o,h:d,fill:e/(o*d)||0}}const Ji=1;class Jc{constructor(e,{pixelRatio:r,version:a,stretchX:o,stretchY:d,content:f}){this.paddedRect=e,this.pixelRatio=r,this.stretchX=o,this.stretchY=d,this.content=f,this.version=a}get tl(){return[this.paddedRect.x+Ji,this.paddedRect.y+Ji]}get br(){return[this.paddedRect.x+this.paddedRect.w-Ji,this.paddedRect.y+this.paddedRect.h-Ji]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2*Ji)/this.pixelRatio,(this.paddedRect.h-2*Ji)/this.pixelRatio]}}class mp{constructor(e,r){const a={},o={};this.haveRenderCallbacks=[];const d=[];this.addImages(e,a,d),this.addImages(r,o,d);const{w:f,h:m}=fp(d),y=new gr({width:f||1,height:m||1});for(const v in e){const S=e[v],A=a[v].paddedRect;gr.copy(S.data,y,{x:0,y:0},{x:A.x+Ji,y:A.y+Ji},S.data)}for(const v in r){const S=r[v],A=o[v].paddedRect,C=A.x+Ji,z=A.y+Ji,D=S.data.width,O=S.data.height;gr.copy(S.data,y,{x:0,y:0},{x:C,y:z},S.data),gr.copy(S.data,y,{x:0,y:O-1},{x:C,y:z-1},{width:D,height:1}),gr.copy(S.data,y,{x:0,y:0},{x:C,y:z+O},{width:D,height:1}),gr.copy(S.data,y,{x:D-1,y:0},{x:C-1,y:z},{width:1,height:O}),gr.copy(S.data,y,{x:0,y:0},{x:C+D,y:z},{width:1,height:O})}this.image=y,this.iconPositions=a,this.patternPositions=o}addImages(e,r,a){for(const o in e){const d=e[o],f={x:0,y:0,w:d.data.width+2*Ji,h:d.data.height+2*Ji};a.push(f),r[o]=new Jc(f,d),d.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(e,r){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const a in e.updatedImages)this.patchUpdatedImage(this.iconPositions[a],e.getImage(a),r),this.patchUpdatedImage(this.patternPositions[a],e.getImage(a),r)}patchUpdatedImage(e,r,a){if(!e||!r||e.version===r.version)return;e.version=r.version;const[o,d]=e.tl;a.update(r.data,void 0,{x:o,y:d})}}var ia;Le("ImagePosition",Jc),Le("ImageAtlas",mp),l.ai=void 0,(ia=l.ai||(l.ai={}))[ia.none=0]="none",ia[ia.horizontal=1]="horizontal",ia[ia.vertical=2]="vertical",ia[ia.horizontalOnly=3]="horizontalOnly";const Po=-17;class zo{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,r){const a=new zo;return a.scale=e||1,a.fontStack=r,a}static forImage(e){const r=new zo;return r.imageName=e,r}}class bs{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,r){const a=new bs;for(let o=0;o<e.sections.length;o++){const d=e.sections[o];d.image?a.addImageSection(d):a.addTextSection(d,r)}return a}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSectionIndex(e){return this.sectionIndex[e]}getCharCode(e){return this.text.charCodeAt(e)}verticalizePunctuation(){this.text=(function(e){let r="";for(let a=0;a<e.length;a++){const o=e.charCodeAt(a+1)||null,d=e.charCodeAt(a-1)||null;r+=o&&wl(o)&&!Mo[e[a+1]]||d&&wl(d)&&!Mo[e[a-1]]||!Mo[e[a]]?e[a]:Mo[e[a]]}return r})(this.text)}trim(){let e=0;for(let a=0;a<this.text.length&&jl[this.text.charCodeAt(a)];a++)e++;let r=this.text.length;for(let a=this.text.length-1;a>=0&&a>=e&&jl[this.text.charCodeAt(a)];a--)r--;this.text=this.text.substring(e,r),this.sectionIndex=this.sectionIndex.slice(e,r)}substring(e,r){const a=new bs;return a.text=this.text.substring(e,r),a.sectionIndex=this.sectionIndex.slice(e,r),a.sections=this.sections,a}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,r)=>Math.max(e,this.sections[r].scale)),0)}addTextSection(e,r){this.text+=e.text,this.sections.push(zo.forText(e.scale,e.fontStack||r));const a=this.sections.length-1;for(let o=0;o<e.text.length;++o)this.sectionIndex.push(a)}addImageSection(e){const r=e.image?e.image.name:"";if(r.length===0)return void Dt("Can't add FormattedSection with an empty image.");const a=this.getNextImageSectionCharCode();a?(this.text+=String.fromCharCode(a),this.sections.push(zo.forImage(r)),this.sectionIndex.push(this.sections.length-1)):Dt("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function $l(i,e,r,a,o,d,f,m,y,v,S,A,C,z,D,O){const q=bs.fromFeature(i,o);let H;A===l.ai.vertical&&q.verticalizePunctuation();const{processBidirectionalText:re,processStyledBidirectionalText:Y}=Ki;if(re&&q.sections.length===1){H=[];const _e=re(q.toString(),Qc(q,v,d,e,a,z,D));for(const De of _e){const Oe=new bs;Oe.text=De,Oe.sections=q.sections;for(let Pe=0;Pe<De.length;Pe++)Oe.sectionIndex.push(0);H.push(Oe)}}else if(Y){H=[];const _e=Y(q.text,q.sectionIndex,Qc(q,v,d,e,a,z,D));for(const De of _e){const Oe=new bs;Oe.text=De[0],Oe.sectionIndex=De[1],Oe.sections=q.sections,H.push(Oe)}}else H=(function(_e,De){const Oe=[],Pe=_e.text;let Me=0;for(const Ie of De)Oe.push(_e.substring(Me,Ie)),Me=Ie;return Me<Pe.length&&Oe.push(_e.substring(Me,Pe.length)),Oe})(q,Qc(q,v,d,e,a,z,D));const ae=[],oe={positionedLines:ae,text:q.toString(),top:S[1],bottom:S[1],left:S[0],right:S[0],writingMode:A,iconsInText:!1,verticalizable:!1};return(function(_e,De,Oe,Pe,Me,Ie,Fe,ke,we,Ze,Ue,lt){let zt=0,Ft=Po,ri=0,fr=0;const Oi=ke==="right"?1:ke==="left"?0:.5;let Qt=0;for(const ni of Me){ni.trim();const ai=ni.getMaxScale(),Ai=(ai-1)*ii,Ui={positionedGlyphs:[],lineOffset:0};_e.positionedLines[Qt]=Ui;const ki=Ui.positionedGlyphs;let Qi=0;if(!ni.length()){Ft+=Ie,++Qt;continue}for(let si=0;si<ni.length();si++){const pt=ni.getSection(si),Ci=ni.getSectionIndex(si),vi=ni.getCharCode(si);let oi=0,Mr=null,$r=null,jr=null,Pn=ii;const Pr=!(we===l.ai.horizontal||!Ue&&!ro(vi)||Ue&&(jl[vi]||(fi=vi,ze.Arabic(fi)||ze["Arabic Supplement"](fi)||ze["Arabic Extended-A"](fi)||ze["Arabic Presentation Forms-A"](fi)||ze["Arabic Presentation Forms-B"](fi))));if(pt.imageName){const yr=Pe[pt.imageName];if(!yr)continue;jr=pt.imageName,_e.iconsInText=_e.iconsInText||!0,$r=yr.paddedRect;const tr=yr.displaySize;pt.scale=pt.scale*ii/lt,Mr={width:tr[0],height:tr[1],left:Ji,top:-dp,advance:Pr?tr[1]:tr[0]},oi=Ai+(ii-tr[1]*pt.scale),Pn=Mr.advance;const zn=Pr?tr[0]*pt.scale-ii*ai:tr[1]*pt.scale-ii*ai;zn>0&&zn>Qi&&(Qi=zn)}else{const yr=Oe[pt.fontStack],tr=yr&&yr[vi];if(tr&&tr.rect)$r=tr.rect,Mr=tr.metrics;else{const zn=De[pt.fontStack],Bo=zn&&zn[vi];if(!Bo)continue;Mr=Bo.metrics}oi=(ai-pt.scale)*ii}Pr?(_e.verticalizable=!0,ki.push({glyph:vi,imageName:jr,x:zt,y:Ft+oi,vertical:Pr,scale:pt.scale,fontStack:pt.fontStack,sectionIndex:Ci,metrics:Mr,rect:$r}),zt+=Pn*pt.scale+Ze):(ki.push({glyph:vi,imageName:jr,x:zt,y:Ft+oi,vertical:Pr,scale:pt.scale,fontStack:pt.fontStack,sectionIndex:Ci,metrics:Mr,rect:$r}),zt+=Mr.advance*pt.scale+Ze)}ki.length!==0&&(ri=Math.max(zt-Ze,ri),__(ki,0,ki.length-1,Oi,Qi)),zt=0;const er=Ie*ai+Qi;Ui.lineOffset=Math.max(Qi,Ai),Ft+=er,fr=Math.max(er,fr),++Qt}var fi;const xi=Ft-Po,{horizontalAlign:Ni,verticalAlign:Vi}=eu(Fe);(function(ni,ai,Ai,Ui,ki,Qi,er,si,pt){const Ci=(ai-Ai)*ki;let vi=0;vi=Qi!==er?-si*Ui-Po:(-Ui*pt+.5)*er;for(const oi of ni)for(const Mr of oi.positionedGlyphs)Mr.x+=Ci,Mr.y+=vi})(_e.positionedLines,Oi,Ni,Vi,ri,fr,Ie,xi,Me.length),_e.top+=-Vi*xi,_e.bottom=_e.top+xi,_e.left+=-Ni*ri,_e.right=_e.left+ri})(oe,e,r,a,H,f,m,y,A,v,C,O),!(function(_e){for(const De of _e)if(De.positionedGlyphs.length!==0)return!1;return!0})(ae)&&oe}const jl={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},m_={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function gp(i,e,r,a,o,d){if(e.imageName){const f=a[e.imageName];return f?f.displaySize[0]*e.scale*ii/d+o:0}{const f=r[e.fontStack],m=f&&f[i];return m?m.metrics.advance*e.scale+o:0}}function _p(i,e,r,a){const o=Math.pow(i-e,2);return a?i<e?o/2:2*o:o+Math.abs(r)*r}function g_(i,e,r){let a=0;return i===10&&(a-=1e4),r&&(a+=150),i!==40&&i!==65288||(a+=50),e!==41&&e!==65289||(a+=50),a}function yp(i,e,r,a,o,d){let f=null,m=_p(e,r,o,d);for(const y of a){const v=_p(e-y.x,r,o,d)+y.badness;v<=m&&(f=y,m=v)}return{index:i,x:e,priorBreak:f,badness:m}}function xp(i){return i?xp(i.priorBreak).concat(i.index):[]}function Qc(i,e,r,a,o,d,f){if(d!=="point")return[];if(!i)return[];const m=[],y=(function(C,z,D,O,q,H){let re=0;for(let Y=0;Y<C.length();Y++){const ae=C.getSection(Y);re+=gp(C.getCharCode(Y),ae,O,q,z,H)}return re/Math.max(1,Math.ceil(re/D))})(i,e,r,a,o,f),v=i.text.indexOf("")>=0;let S=0;for(let C=0;C<i.length();C++){const z=i.getSection(C),D=i.getCharCode(C);if(jl[D]||(S+=gp(D,z,a,o,e,f)),C<i.length()-1){const O=!((A=D)<11904||!(ze["Bopomofo Extended"](A)||ze.Bopomofo(A)||ze["CJK Compatibility Forms"](A)||ze["CJK Compatibility Ideographs"](A)||ze["CJK Compatibility"](A)||ze["CJK Radicals Supplement"](A)||ze["CJK Strokes"](A)||ze["CJK Symbols and Punctuation"](A)||ze["CJK Unified Ideographs Extension A"](A)||ze["CJK Unified Ideographs"](A)||ze["Enclosed CJK Letters and Months"](A)||ze["Halfwidth and Fullwidth Forms"](A)||ze.Hiragana(A)||ze["Ideographic Description Characters"](A)||ze["Kangxi Radicals"](A)||ze["Katakana Phonetic Extensions"](A)||ze.Katakana(A)||ze["Vertical Forms"](A)||ze["Yi Radicals"](A)||ze["Yi Syllables"](A)));(m_[D]||O||z.imageName)&&m.push(yp(C+1,S,y,m,g_(D,i.getCharCode(C+1),O&&v),!1))}}var A;return xp(yp(i.length(),S,y,m,0,!0))}function eu(i){let e=.5,r=.5;switch(i){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(i){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:e,verticalAlign:r}}function __(i,e,r,a,o){if(!a&&!o)return;const d=i[r],f=(i[r].x+d.metrics.advance*d.scale)*a;for(let m=e;m<=r;m++)i[m].x-=f,i[m].y+=o}function y_(i,e,r){const{horizontalAlign:a,verticalAlign:o}=eu(r),d=e[0]-i.displaySize[0]*a,f=e[1]-i.displaySize[1]*o;return{image:i,top:f,bottom:f+i.displaySize[1],left:d,right:d+i.displaySize[0]}}function vp(i,e,r,a,o,d){const f=i.image;let m;if(f.content){const q=f.content,H=f.pixelRatio||1;m=[q[0]/H,q[1]/H,f.displaySize[0]-q[2]/H,f.displaySize[1]-q[3]/H]}const y=e.left*d,v=e.right*d;let S,A,C,z;r==="width"||r==="both"?(z=o[0]+y-a[3],A=o[0]+v+a[1]):(z=o[0]+(y+v-f.displaySize[0])/2,A=z+f.displaySize[0]);const D=e.top*d,O=e.bottom*d;return r==="height"||r==="both"?(S=o[1]+D-a[0],C=o[1]+O+a[2]):(S=o[1]+(D+O-f.displaySize[1])/2,C=S+f.displaySize[1]),{image:f,top:S,right:A,bottom:C,left:z,collisionPadding:m}}const Do=255,ln=128,ra=Do*ln;function bp(i,e){const{expression:r}=e;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new Mt(i+1))};if(r.kind==="source")return{kind:"source"};{const{zoomStops:a,interpolationType:o}=r;let d=0;for(;d<a.length&&a[d]<=i;)d++;d=Math.max(0,d-1);let f=d;for(;f<a.length&&a[f]<i+1;)f++;f=Math.min(a.length-1,f);const m=a[d],y=a[f];return r.kind==="composite"?{kind:"composite",minZoom:m,maxZoom:y,interpolationType:o}:{kind:"camera",minZoom:m,maxZoom:y,minSize:r.evaluate(new Mt(m)),maxSize:r.evaluate(new Mt(y)),interpolationType:o}}}function tu(i,e,r){let a="never";const o=i.get(e);return o?a=o:i.get(r)&&(a="always"),a}const x_=ta.VectorTileFeature.types,v_=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function ql(i,e,r,a,o,d,f,m,y,v,S,A,C){const z=m?Math.min(ra,Math.round(m[0])):0,D=m?Math.min(ra,Math.round(m[1])):0;i.emplaceBack(e,r,Math.round(32*a),Math.round(32*o),d,f,(z<<1)+(y?1:0),D,16*v,16*S,256*A,256*C)}function iu(i,e,r){i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r)}function b_(i){for(const e of i.sections)if(Cc(e.text))return!0;return!1}class ru{constructor(e){this.layoutVertexArray=new ct,this.indexArray=new pi,this.programConfigurations=e,this.segments=new Pt,this.dynamicLayoutVertexArray=new at,this.opacityVertexArray=new ht,this.hasVisibleVertices=!1,this.placedSymbolArray=new ee}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,r,a,o){this.isEmpty()||(a&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Jg.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Qg.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,v_,!0),this.opacityVertexBuffer.itemSize=1),(a||o)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}Le("SymbolBuffers",ru);class nu{constructor(e,r,a){this.layoutVertexArray=new e,this.layoutAttributes=r,this.indexArray=new a,this.segments=new Pt,this.collisionVertexArray=new Ct}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,e_.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}Le("CollisionBuffers",nu);class ws{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((f=>f.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Fc([]),this.placementViewportMatrix=Fc([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=bp(this.zoom,r["text-size"]),this.iconSizeData=bp(this.zoom,r["icon-size"]);const a=this.layers[0].layout,o=a.get("symbol-sort-key"),d=a.get("symbol-z-order");this.canOverlap=tu(a,"text-overlap","text-allow-overlap")!=="never"||tu(a,"icon-overlap","icon-allow-overlap")!=="never"||a.get("text-ignore-placement")||a.get("icon-ignore-placement"),this.sortFeaturesByKey=d!=="viewport-y"&&!o.isConstant(),this.sortFeaturesByY=(d==="viewport-y"||d==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,a.get("symbol-placement")==="point"&&(this.writingModes=a.get("text-writing-mode").map((f=>l.ai[f]))),this.stateDependentLayerIds=this.layers.filter((f=>f.isStateDependent())).map((f=>f.id)),this.sourceID=e.sourceID}createArrays(){this.text=new ru(new Ur(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new ru(new Ur(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new te,this.lineVertexArray=new ce,this.symbolInstances=new G,this.textAnchorOffsets=new me}calculateGlyphDependencies(e,r,a,o,d){for(let f=0;f<e.length;f++)if(r[e.charCodeAt(f)]=!0,(a||o)&&d){const m=Mo[e.charAt(f)];m&&(r[m.charCodeAt(0)]=!0)}}populate(e,r,a){const o=this.layers[0],d=o.layout,f=d.get("text-font"),m=d.get("text-field"),y=d.get("icon-image"),v=(m.value.kind!=="constant"||m.value.value instanceof gi&&!m.value.value.isEmpty()||m.value.value.toString().length>0)&&(f.value.kind!=="constant"||f.value.value.length>0),S=y.value.kind!=="constant"||!!y.value.value||Object.keys(y.parameters).length>0,A=d.get("symbol-sort-key");if(this.features=[],!v&&!S)return;const C=r.iconDependencies,z=r.glyphDependencies,D=r.availableImages,O=new Mt(this.zoom);for(const{feature:q,id:H,index:re,sourceLayerIndex:Y}of e){const ae=o._featureFilter.needGeometry,oe=Ea(q,ae);if(!o._featureFilter.filter(O,oe,a))continue;let _e,De;if(ae||(oe.geometry=Ca(q)),v){const Pe=o.getValueAndResolveTokens("text-field",oe,a,D),Me=gi.factory(Pe);b_(Me)&&(this.hasRTLText=!0),(!this.hasRTLText||co()==="unavailable"||this.hasRTLText&&Ki.isParsed())&&(_e=i_(Me,o,oe))}if(S){const Pe=o.getValueAndResolveTokens("icon-image",oe,a,D);De=Pe instanceof hi?Pe:hi.fromString(Pe)}if(!_e&&!De)continue;const Oe=this.sortFeaturesByKey?A.evaluate(oe,{},a):void 0;if(this.features.push({id:H,text:_e,icon:De,index:re,sourceLayerIndex:Y,geometry:oe.geometry,properties:q.properties,type:x_[q.type],sortKey:Oe}),De&&(C[De.name]=!0),_e){const Pe=f.evaluate(oe,{},a).join(","),Me=d.get("text-rotation-alignment")!=="viewport"&&d.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(l.ai.vertical)>=0;for(const Ie of _e.sections)if(Ie.image)C[Ie.image.name]=!0;else{const Fe=to(_e.toString()),ke=Ie.fontStack||Pe,we=z[ke]=z[ke]||{};this.calculateGlyphDependencies(Ie.text,we,Me,this.allowVerticalPlacement,Fe)}}}d.get("symbol-placement")==="line"&&(this.features=(function(q){const H={},re={},Y=[];let ae=0;function oe(Pe){Y.push(q[Pe]),ae++}function _e(Pe,Me,Ie){const Fe=re[Pe];return delete re[Pe],re[Me]=Fe,Y[Fe].geometry[0].pop(),Y[Fe].geometry[0]=Y[Fe].geometry[0].concat(Ie[0]),Fe}function De(Pe,Me,Ie){const Fe=H[Me];return delete H[Me],H[Pe]=Fe,Y[Fe].geometry[0].shift(),Y[Fe].geometry[0]=Ie[0].concat(Y[Fe].geometry[0]),Fe}function Oe(Pe,Me,Ie){const Fe=Ie?Me[0][Me[0].length-1]:Me[0][0];return`${Pe}:${Fe.x}:${Fe.y}`}for(let Pe=0;Pe<q.length;Pe++){const Me=q[Pe],Ie=Me.geometry,Fe=Me.text?Me.text.toString():null;if(!Fe){oe(Pe);continue}const ke=Oe(Fe,Ie),we=Oe(Fe,Ie,!0);if(ke in re&&we in H&&re[ke]!==H[we]){const Ze=De(ke,we,Ie),Ue=_e(ke,we,Y[Ze].geometry);delete H[ke],delete re[we],re[Oe(Fe,Y[Ue].geometry,!0)]=Ue,Y[Ze].geometry=null}else ke in re?_e(ke,we,Ie):we in H?De(ke,we,Ie):(oe(Pe),H[ke]=ae-1,re[we]=ae-1)}return Y.filter((Pe=>Pe.geometry))})(this.features)),this.sortFeaturesByKey&&this.features.sort(((q,H)=>q.sortKey-H.sortKey))}update(e,r,a){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,r,this.layers,a),this.icon.programConfigurations.updatePaintArrays(e,r,this.layers,a))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,r){const a=this.lineVertexArray.length;if(e.segment!==void 0){let o=e.dist(r[e.segment+1]),d=e.dist(r[e.segment]);const f={};for(let m=e.segment+1;m<r.length;m++)f[m]={x:r[m].x,y:r[m].y,tileUnitDistanceFromAnchor:o},m<r.length-1&&(o+=r[m+1].dist(r[m]));for(let m=e.segment||0;m>=0;m--)f[m]={x:r[m].x,y:r[m].y,tileUnitDistanceFromAnchor:d},m>0&&(d+=r[m-1].dist(r[m]));for(let m=0;m<r.length;m++){const y=f[m];this.lineVertexArray.emplaceBack(y.x,y.y,y.tileUnitDistanceFromAnchor)}}return{lineStartIndex:a,lineLength:this.lineVertexArray.length-a}}addSymbols(e,r,a,o,d,f,m,y,v,S,A,C){const z=e.indexArray,D=e.layoutVertexArray,O=e.segments.prepareSegment(4*r.length,D,z,this.canOverlap?f.sortKey:void 0),q=this.glyphOffsetArray.length,H=O.vertexLength,re=this.allowVerticalPlacement&&m===l.ai.vertical?Math.PI/2:0,Y=f.text&&f.text.sections;for(let ae=0;ae<r.length;ae++){const{tl:oe,tr:_e,bl:De,br:Oe,tex:Pe,pixelOffsetTL:Me,pixelOffsetBR:Ie,minFontScaleX:Fe,minFontScaleY:ke,glyphOffset:we,isSDF:Ze,sectionIndex:Ue}=r[ae],lt=O.vertexLength,zt=we[1];ql(D,y.x,y.y,oe.x,zt+oe.y,Pe.x,Pe.y,a,Ze,Me.x,Me.y,Fe,ke),ql(D,y.x,y.y,_e.x,zt+_e.y,Pe.x+Pe.w,Pe.y,a,Ze,Ie.x,Me.y,Fe,ke),ql(D,y.x,y.y,De.x,zt+De.y,Pe.x,Pe.y+Pe.h,a,Ze,Me.x,Ie.y,Fe,ke),ql(D,y.x,y.y,Oe.x,zt+Oe.y,Pe.x+Pe.w,Pe.y+Pe.h,a,Ze,Ie.x,Ie.y,Fe,ke),iu(e.dynamicLayoutVertexArray,y,re),z.emplaceBack(lt,lt+1,lt+2),z.emplaceBack(lt+1,lt+2,lt+3),O.vertexLength+=4,O.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(we[0]),ae!==r.length-1&&Ue===r[ae+1].sectionIndex||e.programConfigurations.populatePaintArrays(D.length,f,f.index,{},C,Y&&Y[Ue])}e.placedSymbolArray.emplaceBack(y.x,y.y,q,this.glyphOffsetArray.length-q,H,v,S,y.segment,a?a[0]:0,a?a[1]:0,o[0],o[1],m,0,!1,0,A)}_addCollisionDebugVertex(e,r,a,o,d,f){return r.emplaceBack(0,0),e.emplaceBack(a.x,a.y,o,d,Math.round(f.x),Math.round(f.y))}addCollisionDebugVertices(e,r,a,o,d,f,m){const y=d.segments.prepareSegment(4,d.layoutVertexArray,d.indexArray),v=y.vertexLength,S=d.layoutVertexArray,A=d.collisionVertexArray,C=m.anchorX,z=m.anchorY;this._addCollisionDebugVertex(S,A,f,C,z,new ge(e,r)),this._addCollisionDebugVertex(S,A,f,C,z,new ge(a,r)),this._addCollisionDebugVertex(S,A,f,C,z,new ge(a,o)),this._addCollisionDebugVertex(S,A,f,C,z,new ge(e,o)),y.vertexLength+=4;const D=d.indexArray;D.emplaceBack(v,v+1),D.emplaceBack(v+1,v+2),D.emplaceBack(v+2,v+3),D.emplaceBack(v+3,v),y.primitiveLength+=4}addDebugCollisionBoxes(e,r,a,o){for(let d=e;d<r;d++){const f=this.collisionBoxArray.get(d);this.addCollisionDebugVertices(f.x1,f.y1,f.x2,f.y2,o?this.textCollisionBox:this.iconCollisionBox,f.anchorPoint,a)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new nu(Zt,ap.members,ei),this.iconCollisionBox=new nu(Zt,ap.members,ei);for(let e=0;e<this.symbolInstances.length;e++){const r=this.symbolInstances.get(e);this.addDebugCollisionBoxes(r.textBoxStartIndex,r.textBoxEndIndex,r,!0),this.addDebugCollisionBoxes(r.verticalTextBoxStartIndex,r.verticalTextBoxEndIndex,r,!0),this.addDebugCollisionBoxes(r.iconBoxStartIndex,r.iconBoxEndIndex,r,!1),this.addDebugCollisionBoxes(r.verticalIconBoxStartIndex,r.verticalIconBoxEndIndex,r,!1)}}_deserializeCollisionBoxesForSymbol(e,r,a,o,d,f,m,y,v){const S={};for(let A=r;A<a;A++){const C=e.get(A);S.textBox={x1:C.x1,y1:C.y1,x2:C.x2,y2:C.y2,anchorPointX:C.anchorPointX,anchorPointY:C.anchorPointY},S.textFeatureIndex=C.featureIndex;break}for(let A=o;A<d;A++){const C=e.get(A);S.verticalTextBox={x1:C.x1,y1:C.y1,x2:C.x2,y2:C.y2,anchorPointX:C.anchorPointX,anchorPointY:C.anchorPointY},S.verticalTextFeatureIndex=C.featureIndex;break}for(let A=f;A<m;A++){const C=e.get(A);S.iconBox={x1:C.x1,y1:C.y1,x2:C.x2,y2:C.y2,anchorPointX:C.anchorPointX,anchorPointY:C.anchorPointY},S.iconFeatureIndex=C.featureIndex;break}for(let A=y;A<v;A++){const C=e.get(A);S.verticalIconBox={x1:C.x1,y1:C.y1,x2:C.x2,y2:C.y2,anchorPointX:C.anchorPointX,anchorPointY:C.anchorPointY},S.verticalIconFeatureIndex=C.featureIndex;break}return S}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let r=0;r<this.symbolInstances.length;r++){const a=this.symbolInstances.get(r);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,a.textBoxStartIndex,a.textBoxEndIndex,a.verticalTextBoxStartIndex,a.verticalTextBoxEndIndex,a.iconBoxStartIndex,a.iconBoxEndIndex,a.verticalIconBoxStartIndex,a.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,r){const a=e.placedSymbolArray.get(r),o=a.vertexStartIndex+4*a.numGlyphs;for(let d=a.vertexStartIndex;d<o;d+=4)e.indexArray.emplaceBack(d,d+1,d+2),e.indexArray.emplaceBack(d+1,d+2,d+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const r=Math.sin(e),a=Math.cos(e),o=[],d=[],f=[];for(let m=0;m<this.symbolInstances.length;++m){f.push(m);const y=this.symbolInstances.get(m);o.push(0|Math.round(r*y.anchorX+a*y.anchorY)),d.push(y.featureIndex)}return f.sort(((m,y)=>o[m]-o[y]||d[y]-d[m])),f}addToSortKeyRanges(e,r){const a=this.sortKeyRanges[this.sortKeyRanges.length-1];a&&a.sortKey===r?a.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const r of this.symbolInstanceIndexes){const a=this.symbolInstances.get(r);this.featureSortOrder.push(a.featureIndex),[a.rightJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.leftJustifiedTextSymbolIndex].forEach(((o,d,f)=>{o>=0&&f.indexOf(o)===d&&this.addIndicesForPlacedSymbol(this.text,o)})),a.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,a.verticalPlacedTextSymbolIndex),a.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.placedIconSymbolIndex),a.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let wp,Sp;Le("SymbolBucket",ws,{omit:["layers","collisionBoxArray","features","compareText"]}),ws.MAX_GLYPHS=65535,ws.addDynamicAttributes=iu;var au={get paint(){return Sp=Sp||new Wt({"icon-opacity":new He(he.paint_symbol["icon-opacity"]),"icon-color":new He(he.paint_symbol["icon-color"]),"icon-halo-color":new He(he.paint_symbol["icon-halo-color"]),"icon-halo-width":new He(he.paint_symbol["icon-halo-width"]),"icon-halo-blur":new He(he.paint_symbol["icon-halo-blur"]),"icon-translate":new je(he.paint_symbol["icon-translate"]),"icon-translate-anchor":new je(he.paint_symbol["icon-translate-anchor"]),"text-opacity":new He(he.paint_symbol["text-opacity"]),"text-color":new He(he.paint_symbol["text-color"],{runtimeType:Si,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new He(he.paint_symbol["text-halo-color"]),"text-halo-width":new He(he.paint_symbol["text-halo-width"]),"text-halo-blur":new He(he.paint_symbol["text-halo-blur"]),"text-translate":new je(he.paint_symbol["text-translate"]),"text-translate-anchor":new je(he.paint_symbol["text-translate-anchor"])})},get layout(){return wp=wp||new Wt({"symbol-placement":new je(he.layout_symbol["symbol-placement"]),"symbol-spacing":new je(he.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new je(he.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new He(he.layout_symbol["symbol-sort-key"]),"symbol-z-order":new je(he.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new je(he.layout_symbol["icon-allow-overlap"]),"icon-overlap":new je(he.layout_symbol["icon-overlap"]),"icon-ignore-placement":new je(he.layout_symbol["icon-ignore-placement"]),"icon-optional":new je(he.layout_symbol["icon-optional"]),"icon-rotation-alignment":new je(he.layout_symbol["icon-rotation-alignment"]),"icon-size":new He(he.layout_symbol["icon-size"]),"icon-text-fit":new je(he.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new je(he.layout_symbol["icon-text-fit-padding"]),"icon-image":new He(he.layout_symbol["icon-image"]),"icon-rotate":new He(he.layout_symbol["icon-rotate"]),"icon-padding":new He(he.layout_symbol["icon-padding"]),"icon-keep-upright":new je(he.layout_symbol["icon-keep-upright"]),"icon-offset":new He(he.layout_symbol["icon-offset"]),"icon-anchor":new He(he.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new je(he.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new je(he.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new je(he.layout_symbol["text-rotation-alignment"]),"text-field":new He(he.layout_symbol["text-field"]),"text-font":new He(he.layout_symbol["text-font"]),"text-size":new He(he.layout_symbol["text-size"]),"text-max-width":new He(he.layout_symbol["text-max-width"]),"text-line-height":new je(he.layout_symbol["text-line-height"]),"text-letter-spacing":new He(he.layout_symbol["text-letter-spacing"]),"text-justify":new He(he.layout_symbol["text-justify"]),"text-radial-offset":new He(he.layout_symbol["text-radial-offset"]),"text-variable-anchor":new je(he.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new He(he.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new He(he.layout_symbol["text-anchor"]),"text-max-angle":new je(he.layout_symbol["text-max-angle"]),"text-writing-mode":new je(he.layout_symbol["text-writing-mode"]),"text-rotate":new He(he.layout_symbol["text-rotate"]),"text-padding":new je(he.layout_symbol["text-padding"]),"text-keep-upright":new je(he.layout_symbol["text-keep-upright"]),"text-transform":new He(he.layout_symbol["text-transform"]),"text-offset":new He(he.layout_symbol["text-offset"]),"text-allow-overlap":new je(he.layout_symbol["text-allow-overlap"]),"text-overlap":new je(he.layout_symbol["text-overlap"]),"text-ignore-placement":new je(he.layout_symbol["text-ignore-placement"]),"text-optional":new je(he.layout_symbol["text-optional"])})}};class Tp{constructor(e){if(e.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Fr,this.defaultValue=e}evaluate(e){if(e.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(e.formattedSection))return r.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Le("FormatSectionOverride",Tp,{omit:["defaultValue"]});class Zl extends pr{constructor(e){super(e,au)}recalculate(e,r){if(super.recalculate(e,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const a=this.layout.get("text-writing-mode");if(a){const o=[];for(const d of a)o.indexOf(d)<0&&o.push(d);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,r,a,o){const d=this.layout.get(e).evaluate(r,{},a,o),f=this._unevaluatedLayout._values[e];return f.isDataDriven()||is(f.value)||!d?d:(function(m,y){return y.replace(/{([^{}]+)}/g,((v,S)=>m&&S in m?String(m[S]):""))})(r.properties,d)}createBucket(e){return new ws(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of au.paint.overridableProperties){if(!Zl.hasPaintOverride(this.layout,e))continue;const r=this.paint.get(e),a=new Tp(r),o=new Xs(a,r.property.specification);let d=null;d=r.value.kind==="constant"||r.value.kind==="source"?new Ks("source",o):new ns("composite",o,r.value.zoomStops),this.paint._values[e]=new Ti(r.property,d,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,a){return!(!this.layout||r.isDataDriven()||a.isDataDriven())&&Zl.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){const a=e.get("text-field"),o=au.paint.properties[r];let d=!1;const f=m=>{for(const y of m)if(o.overrides&&o.overrides.hasOverride(y))return void(d=!0)};if(a.value.kind==="constant"&&a.value.value instanceof gi)f(a.value.value.sections);else if(a.value.kind==="source"){const m=v=>{d||(v instanceof yn&&Rt(v.value)===U?f(v.value.sections):v instanceof ts?f(v.sections):v.eachChild(m))},y=a.value;y._styleExpression&&m(y._styleExpression.expression)}return d}}let Ip;var w_={get paint(){return Ip=Ip||new Wt({"background-color":new je(he.paint_background["background-color"]),"background-pattern":new ho(he.paint_background["background-pattern"]),"background-opacity":new je(he.paint_background["background-opacity"])})}};class S_ extends pr{constructor(e){super(e,w_)}}let Ap;var T_={get paint(){return Ap=Ap||new Wt({"raster-opacity":new je(he.paint_raster["raster-opacity"]),"raster-hue-rotate":new je(he.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new je(he.paint_raster["raster-brightness-min"]),"raster-brightness-max":new je(he.paint_raster["raster-brightness-max"]),"raster-saturation":new je(he.paint_raster["raster-saturation"]),"raster-contrast":new je(he.paint_raster["raster-contrast"]),"raster-resampling":new je(he.paint_raster["raster-resampling"]),"raster-fade-duration":new je(he.paint_raster["raster-fade-duration"])})}};class I_ extends pr{constructor(e){super(e,T_)}}class A_ extends pr{constructor(e){super(e,{}),this.onAdd=r=>{this.implementation.onAdd&&this.implementation.onAdd(r,r.painter.context.gl)},this.onRemove=r=>{this.implementation.onRemove&&this.implementation.onRemove(r,r.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class k_{constructor(e){this._callback=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){delete this._channel,this._callback=()=>{}}}const su=63710088e-1;class na{constructor(e,r){if(isNaN(e)||isNaN(r))throw new Error(`Invalid LngLat object: (${e}, ${r})`);if(this.lng=+e,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new na(hn(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const r=Math.PI/180,a=this.lat*r,o=e.lat*r,d=Math.sin(a)*Math.sin(o)+Math.cos(a)*Math.cos(o)*Math.cos((e.lng-this.lng)*r);return su*Math.acos(Math.min(d,1))}static convert(e){if(e instanceof na)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new na(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new na(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const kp=2*Math.PI*su;function Cp(i){return kp*Math.cos(i*Math.PI/180)}function Ep(i){return(180+i)/360}function Mp(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function Pp(i,e){return i/Cp(e)}function zp(i){return 360*i-180}function ou(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class Gl{constructor(e,r,a=0){this.x=+e,this.y=+r,this.z=+a}static fromLngLat(e,r=0){const a=na.convert(e);return new Gl(Ep(a.lng),Mp(a.lat),Pp(r,a.lat))}toLngLat(){return new na(zp(this.x),ou(this.y))}toAltitude(){return this.z*Cp(ou(this.y))}meterInMercatorCoordinateUnits(){return 1/kp*(e=ou(this.y),1/Math.cos(e*Math.PI/180));var e}}function Dp(i,e,r){var a=2*Math.PI*6378137/256/Math.pow(2,r);return[i*a-2*Math.PI*6378137/2,e*a-2*Math.PI*6378137/2]}class lu{constructor(e,r,a){if(e<0||e>25||a<0||a>=Math.pow(2,e)||r<0||r>=Math.pow(2,e))throw new Error(`x=${r}, y=${a}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=r,this.y=a,this.key=Lo(0,e,e,r,a)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,r,a){const o=(f=this.y,m=this.z,y=Dp(256*(d=this.x),256*(f=Math.pow(2,m)-f-1),m),v=Dp(256*(d+1),256*(f+1),m),y[0]+","+y[1]+","+v[0]+","+v[1]);var d,f,m,y,v;const S=(function(A,C,z){let D,O="";for(let q=A;q>0;q--)D=1<<q-1,O+=(C&D?1:0)+(z&D?2:0);return O})(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(a==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,r>1?"@2x":"").replace(/{quadkey}/g,S).replace(/{bbox-epsg-3857}/g,o)}isChildOf(e){const r=this.z-e.z;return r>0&&e.x===this.x>>r&&e.y===this.y>>r}getTilePoint(e){const r=Math.pow(2,this.z);return new ge((e.x*r-this.x)*Jt,(e.y*r-this.y)*Jt)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Lp{constructor(e,r){this.wrap=e,this.canonical=r,this.key=Lo(e,r.z,r.z,r.x,r.y)}}class _r{constructor(e,r,a,o,d){if(e<a)throw new Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${a}`);this.overscaledZ=e,this.wrap=r,this.canonical=new lu(a,+o,+d),this.key=Lo(r,e,a,o,d)}clone(){return new _r(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-e;return e>this.canonical.z?new _r(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new _r(e,this.wrap,e,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(e,r){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const a=this.canonical.z-e;return e>this.canonical.z?Lo(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y):Lo(this.wrap*+r,e,e,this.canonical.x>>a,this.canonical.y>>a)}isChildOf(e){if(e.wrap!==this.wrap)return!1;const r=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ<this.overscaledZ&&e.canonical.x===this.canonical.x>>r&&e.canonical.y===this.canonical.y>>r}children(e){if(this.overscaledZ>=e)return[new _r(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,a=2*this.canonical.x,o=2*this.canonical.y;return[new _r(r,this.wrap,r,a,o),new _r(r,this.wrap,r,a+1,o),new _r(r,this.wrap,r,a,o+1),new _r(r,this.wrap,r,a+1,o+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new _r(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new _r(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Lp(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new Gl(e.x-this.wrap,e.y))}}function Lo(i,e,r,a,o){(i*=2)<0&&(i=-1*i-1);const d=1<<r;return(d*d*i+d*o+a).toString(36)+r.toString(36)+e.toString(36)}Le("CanonicalTileID",lu),Le("OverscaledTileID",_r,{omit:["posMatrix"]});class Fp{constructor(e,r,a,o=1,d=1,f=1,m=0){if(this.uid=e,r.height!==r.width)throw new RangeError("DEM tiles must be square");if(a&&!["mapbox","terrarium","custom"].includes(a))return void Dt(`"${a}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=r.height;const y=this.dim=r.height-2;switch(this.data=new Uint32Array(r.data.buffer),a){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=o,this.greenFactor=d,this.blueFactor=f,this.baseShift=m;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let v=0;v<y;v++)this.data[this._idx(-1,v)]=this.data[this._idx(0,v)],this.data[this._idx(y,v)]=this.data[this._idx(y-1,v)],this.data[this._idx(v,-1)]=this.data[this._idx(v,0)],this.data[this._idx(v,y)]=this.data[this._idx(v,y-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(y,-1)]=this.data[this._idx(y-1,0)],this.data[this._idx(-1,y)]=this.data[this._idx(0,y-1)],this.data[this._idx(y,y)]=this.data[this._idx(y-1,y-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let v=0;v<y;v++)for(let S=0;S<y;S++){const A=this.get(v,S);A>this.max&&(this.max=A),A<this.min&&(this.min=A)}}get(e,r){const a=new Uint8Array(this.data.buffer),o=4*this._idx(e,r);return this.unpack(a[o],a[o+1],a[o+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,r){if(e<-1||e>=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(e+1)}unpack(e,r,a){return e*this.redFactor+r*this.greenFactor+a*this.blueFactor-this.baseShift}getPixels(){return new gr({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,r,a){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let o=r*this.dim,d=r*this.dim+this.dim,f=a*this.dim,m=a*this.dim+this.dim;switch(r){case-1:o=d-1;break;case 1:d=o+1}switch(a){case-1:f=m-1;break;case 1:m=f+1}const y=-r*this.dim,v=-a*this.dim;for(let S=f;S<m;S++)for(let A=o;A<d;A++)this.data[this._idx(A,S)]=e.data[this._idx(A+y,S+v)]}}Le("DEMData",Fp);class Rp{constructor(e){this._stringToNumber={},this._numberToString=[];for(let r=0;r<e.length;r++){const a=e[r];this._stringToNumber[a]=r,this._numberToString[r]=a}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Bp{constructor(e,r,a,o,d){this.type="Feature",this._vectorTileFeature=e,e._z=r,e._x=a,e._y=o,this.properties=e.properties,this.id=d}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const r in this)r!=="_geometry"&&r!=="_vectorTileFeature"&&(e[r]=this[r]);return e}}class Op{constructor(e,r){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Kn(Jt,16,0),this.grid3D=new Kn(Jt,16,0),this.featureIndexArray=new xe,this.promoteId=r}insert(e,r,a,o,d,f){const m=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(a,o,d);const y=f?this.grid3D:this.grid;for(let v=0;v<r.length;v++){const S=r[v],A=[1/0,1/0,-1/0,-1/0];for(let C=0;C<S.length;C++){const z=S[C];A[0]=Math.min(A[0],z.x),A[1]=Math.min(A[1],z.y),A[2]=Math.max(A[2],z.x),A[3]=Math.max(A[3],z.y)}A[0]<Jt&&A[1]<Jt&&A[2]>=0&&A[3]>=0&&y.insert(m,A[0],A[1],A[2],A[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new ta.VectorTile(new Kc(this.rawTileData)).layers,this.sourceLayerCoder=new Rp(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(e,r,a,o){this.loadVTLayers();const d=e.params||{},f=Jt/e.tileSize/e.scale,m=Js(d.filter),y=e.queryGeometry,v=e.queryPadding*f,S=Vp(y),A=this.grid.query(S.minX-v,S.minY-v,S.maxX+v,S.maxY+v),C=Vp(e.cameraQueryGeometry),z=this.grid3D.query(C.minX-v,C.minY-v,C.maxX+v,C.maxY+v,((q,H,re,Y)=>(function(ae,oe,_e,De,Oe){for(const Me of ae)if(oe<=Me.x&&_e<=Me.y&&De>=Me.x&&Oe>=Me.y)return!0;const Pe=[new ge(oe,_e),new ge(oe,Oe),new ge(De,Oe),new ge(De,_e)];if(ae.length>2){for(const Me of Pe)if(ms(ae,Me))return!0}for(let Me=0;Me<ae.length-1;Me++)if(ag(ae[Me],ae[Me+1],Pe))return!0;return!1})(e.cameraQueryGeometry,q-v,H-v,re+v,Y+v)));for(const q of z)A.push(q);A.sort(C_);const D={};let O;for(let q=0;q<A.length;q++){const H=A[q];if(H===O)continue;O=H;const re=this.featureIndexArray.get(H);let Y=null;this.loadMatchingFeature(D,re.bucketIndex,re.sourceLayerIndex,re.featureIndex,m,d.layers,d.availableImages,r,a,o,((ae,oe,_e)=>(Y||(Y=Ca(ae)),oe.queryIntersectsFeature(y,ae,_e,Y,this.z,e.transform,f,e.pixelPosMatrix))))}return D}loadMatchingFeature(e,r,a,o,d,f,m,y,v,S,A){const C=this.bucketLayerIDs[r];if(f&&!(function(q,H){for(let re=0;re<q.length;re++)if(H.indexOf(q[re])>=0)return!0;return!1})(f,C))return;const z=this.sourceLayerCoder.decode(a),D=this.vtLayers[z].feature(o);if(d.needGeometry){const q=Ea(D,!0);if(!d.filter(new Mt(this.tileID.overscaledZ),q,this.tileID.canonical))return}else if(!d.filter(new Mt(this.tileID.overscaledZ),D))return;const O=this.getId(D,z);for(let q=0;q<C.length;q++){const H=C[q];if(f&&f.indexOf(H)<0)continue;const re=y[H];if(!re)continue;let Y={};O&&S&&(Y=S.getState(re.sourceLayer||"_geojsonTileLayer",O));const ae=Ve({},v[H]);ae.paint=Np(ae.paint,re.paint,D,Y,m),ae.layout=Np(ae.layout,re.layout,D,Y,m);const oe=!A||A(D,re,Y);if(!oe)continue;const _e=new Bp(D,this.z,this.x,this.y,O);_e.layer=ae;let De=e[H];De===void 0&&(De=e[H]=[]),De.push({featureIndex:o,feature:_e,intersectionZ:oe})}}lookupSymbolFeatures(e,r,a,o,d,f,m,y){const v={};this.loadVTLayers();const S=Js(d);for(const A of e)this.loadMatchingFeature(v,a,o,A,S,f,m,y,r);return v}hasLayer(e){for(const r of this.bucketLayerIDs)for(const a of r)if(e===a)return!0;return!1}getId(e,r){let a=e.id;return this.promoteId&&(a=e.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[r]],typeof a=="boolean"&&(a=Number(a))),a}}function Np(i,e,r,a,o){return nt(i,((d,f)=>{const m=e instanceof ds?e.get(f):null;return m&&m.evaluate?m.evaluate(r,a,o):m}))}function Vp(i){let e=1/0,r=1/0,a=-1/0,o=-1/0;for(const d of i)e=Math.min(e,d.x),r=Math.min(r,d.y),a=Math.max(a,d.x),o=Math.max(o,d.y);return{minX:e,minY:r,maxX:a,maxY:o}}function C_(i,e){return e-i}function Up(i,e,r,a,o){const d=[];for(let f=0;f<i.length;f++){const m=i[f];let y;for(let v=0;v<m.length-1;v++){let S=m[v],A=m[v+1];S.x<e&&A.x<e||(S.x<e?S=new ge(e,S.y+(e-S.x)/(A.x-S.x)*(A.y-S.y))._round():A.x<e&&(A=new ge(e,S.y+(e-S.x)/(A.x-S.x)*(A.y-S.y))._round()),S.y<r&&A.y<r||(S.y<r?S=new ge(S.x+(r-S.y)/(A.y-S.y)*(A.x-S.x),r)._round():A.y<r&&(A=new ge(S.x+(r-S.y)/(A.y-S.y)*(A.x-S.x),r)._round()),S.x>=a&&A.x>=a||(S.x>=a?S=new ge(a,S.y+(a-S.x)/(A.x-S.x)*(A.y-S.y))._round():A.x>=a&&(A=new ge(a,S.y+(a-S.x)/(A.x-S.x)*(A.y-S.y))._round()),S.y>=o&&A.y>=o||(S.y>=o?S=new ge(S.x+(o-S.y)/(A.y-S.y)*(A.x-S.x),o)._round():A.y>=o&&(A=new ge(S.x+(o-S.y)/(A.y-S.y)*(A.x-S.x),o)._round()),y&&S.equals(y[y.length-1])||(y=[S],d.push(y)),y.push(A)))))}}return d}Le("FeatureIndex",Op,{omit:["rawTileData","sourceLayerCoder"]});class aa extends ge{constructor(e,r,a,o){super(e,r),this.angle=a,o!==void 0&&(this.segment=o)}clone(){return new aa(this.x,this.y,this.angle,this.segment)}}function $p(i,e,r,a,o){if(e.segment===void 0||r===0)return!0;let d=e,f=e.segment+1,m=0;for(;m>-r/2;){if(f--,f<0)return!1;m-=i[f].dist(d),d=i[f]}m+=i[f].dist(i[f+1]),f++;const y=[];let v=0;for(;m<r/2;){const S=i[f],A=i[f+1];if(!A)return!1;let C=i[f-1].angleTo(S)-S.angleTo(A);for(C=Math.abs((C+3*Math.PI)%(2*Math.PI)-Math.PI),y.push({distance:m,angleDelta:C}),v+=C;m-y[0].distance>a;)v-=y.shift().angleDelta;if(v>o)return!1;f++,m+=S.dist(A)}return!0}function jp(i){let e=0;for(let r=0;r<i.length-1;r++)e+=i[r].dist(i[r+1]);return e}function qp(i,e,r){return i?.6*e*r:0}function Zp(i,e){return Math.max(i?i.right-i.left:0,e?e.right-e.left:0)}function E_(i,e,r,a,o,d){const f=qp(r,o,d),m=Zp(r,a)*d;let y=0;const v=jp(i)/2;for(let S=0;S<i.length-1;S++){const A=i[S],C=i[S+1],z=A.dist(C);if(y+z>v){const D=(v-y)/z,O=Hi.number(A.x,C.x,D),q=Hi.number(A.y,C.y,D),H=new aa(O,q,C.angleTo(A),S);return H._round(),!f||$p(i,H,m,f,e)?H:void 0}y+=z}}function M_(i,e,r,a,o,d,f,m,y){const v=qp(a,d,f),S=Zp(a,o),A=S*f,C=i[0].x===0||i[0].x===y||i[0].y===0||i[0].y===y;return e-A<e/4&&(e=A+e/4),Gp(i,C?e/2*m%e:(S/2+2*d)*f*m%e,e,v,r,A,C,!1,y)}function Gp(i,e,r,a,o,d,f,m,y){const v=d/2,S=jp(i);let A=0,C=e-r,z=[];for(let D=0;D<i.length-1;D++){const O=i[D],q=i[D+1],H=O.dist(q),re=q.angleTo(O);for(;C+r<A+H;){C+=r;const Y=(C-A)/H,ae=Hi.number(O.x,q.x,Y),oe=Hi.number(O.y,q.y,Y);if(ae>=0&&ae<y&&oe>=0&&oe<y&&C-v>=0&&C+v<=S){const _e=new aa(ae,oe,re,D);_e._round(),a&&!$p(i,_e,d,a,o)||z.push(_e)}}A+=H}return m||z.length||f||(z=Gp(i,A/2,r,a,o,d,f,!0,y)),z}Le("Anchor",aa);const Ss=Ji;function Hp(i,e,r,a){const o=[],d=i.image,f=d.pixelRatio,m=d.paddedRect.w-2*Ss,y=d.paddedRect.h-2*Ss,v=i.right-i.left,S=i.bottom-i.top,A=d.stretchX||[[0,m]],C=d.stretchY||[[0,y]],z=(Ie,Fe)=>Ie+Fe[1]-Fe[0],D=A.reduce(z,0),O=C.reduce(z,0),q=m-D,H=y-O;let re=0,Y=D,ae=0,oe=O,_e=0,De=q,Oe=0,Pe=H;if(d.content&&a){const Ie=d.content;re=Hl(A,0,Ie[0]),ae=Hl(C,0,Ie[1]),Y=Hl(A,Ie[0],Ie[2]),oe=Hl(C,Ie[1],Ie[3]),_e=Ie[0]-re,Oe=Ie[1]-ae,De=Ie[2]-Ie[0]-Y,Pe=Ie[3]-Ie[1]-oe}const Me=(Ie,Fe,ke,we)=>{const Ze=Wl(Ie.stretch-re,Y,v,i.left),Ue=Xl(Ie.fixed-_e,De,Ie.stretch,D),lt=Wl(Fe.stretch-ae,oe,S,i.top),zt=Xl(Fe.fixed-Oe,Pe,Fe.stretch,O),Ft=Wl(ke.stretch-re,Y,v,i.left),ri=Xl(ke.fixed-_e,De,ke.stretch,D),fr=Wl(we.stretch-ae,oe,S,i.top),Oi=Xl(we.fixed-Oe,Pe,we.stretch,O),Qt=new ge(Ze,lt),fi=new ge(Ft,lt),xi=new ge(Ft,fr),Ni=new ge(Ze,fr),Vi=new ge(Ue/f,zt/f),ni=new ge(ri/f,Oi/f),ai=e*Math.PI/180;if(ai){const ki=Math.sin(ai),Qi=Math.cos(ai),er=[Qi,-ki,ki,Qi];Qt._matMult(er),fi._matMult(er),Ni._matMult(er),xi._matMult(er)}const Ai=Ie.stretch+Ie.fixed,Ui=Fe.stretch+Fe.fixed;return{tl:Qt,tr:fi,bl:Ni,br:xi,tex:{x:d.paddedRect.x+Ss+Ai,y:d.paddedRect.y+Ss+Ui,w:ke.stretch+ke.fixed-Ai,h:we.stretch+we.fixed-Ui},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Vi,pixelOffsetBR:ni,minFontScaleX:De/f/v,minFontScaleY:Pe/f/S,isSDF:r}};if(a&&(d.stretchX||d.stretchY)){const Ie=Wp(A,q,D),Fe=Wp(C,H,O);for(let ke=0;ke<Ie.length-1;ke++){const we=Ie[ke],Ze=Ie[ke+1];for(let Ue=0;Ue<Fe.length-1;Ue++)o.push(Me(we,Fe[Ue],Ze,Fe[Ue+1]))}}else o.push(Me({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:m+1},{fixed:0,stretch:y+1}));return o}function Hl(i,e,r){let a=0;for(const o of i)a+=Math.max(e,Math.min(r,o[1]))-Math.max(e,Math.min(r,o[0]));return a}function Wp(i,e,r){const a=[{fixed:-Ss,stretch:0}];for(const[o,d]of i){const f=a[a.length-1];a.push({fixed:o-f.stretch,stretch:f.stretch}),a.push({fixed:o-f.stretch,stretch:f.stretch+(d-o)})}return a.push({fixed:e+Ss,stretch:r}),a}function Wl(i,e,r,a){return i/e*r+a}function Xl(i,e,r,a){return i-e*r/a}class Kl{constructor(e,r,a,o,d,f,m,y,v,S){if(this.boxStartIndex=e.length,v){let A=f.top,C=f.bottom;const z=f.collisionPadding;z&&(A-=z[1],C+=z[3]);let D=C-A;D>0&&(D=Math.max(10,D),this.circleDiameter=D)}else{let A=f.top*m-y[0],C=f.bottom*m+y[2],z=f.left*m-y[3],D=f.right*m+y[1];const O=f.collisionPadding;if(O&&(z-=O[0]*m,A-=O[1]*m,D+=O[2]*m,C+=O[3]*m),S){const q=new ge(z,A),H=new ge(D,A),re=new ge(z,C),Y=new ge(D,C),ae=S*Math.PI/180;q._rotate(ae),H._rotate(ae),re._rotate(ae),Y._rotate(ae),z=Math.min(q.x,H.x,re.x,Y.x),D=Math.max(q.x,H.x,re.x,Y.x),A=Math.min(q.y,H.y,re.y,Y.y),C=Math.max(q.y,H.y,re.y,Y.y)}e.emplaceBack(r.x,r.y,z,A,D,C,a,o,d)}this.boxEndIndex=e.length}}class P_{constructor(e=[],r=z_){if(this.data=e,this.length=this.data.length,this.compare=r,this.length>0)for(let a=(this.length>>1)-1;a>=0;a--)this._down(a)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:r,compare:a}=this,o=r[e];for(;e>0;){const d=e-1>>1,f=r[d];if(a(o,f)>=0)break;r[e]=f,e=d}r[e]=o}_down(e){const{data:r,compare:a}=this,o=this.length>>1,d=r[e];for(;e<o;){let f=1+(e<<1),m=r[f];const y=f+1;if(y<this.length&&a(r[y],m)<0&&(f=y,m=r[y]),a(m,d)>=0)break;r[e]=m,e=f}r[e]=d}}function z_(i,e){return i<e?-1:i>e?1:0}function D_(i,e=1,r=!1){let a=1/0,o=1/0,d=-1/0,f=-1/0;const m=i[0];for(let z=0;z<m.length;z++){const D=m[z];(!z||D.x<a)&&(a=D.x),(!z||D.y<o)&&(o=D.y),(!z||D.x>d)&&(d=D.x),(!z||D.y>f)&&(f=D.y)}const y=Math.min(d-a,f-o);let v=y/2;const S=new P_([],L_);if(y===0)return new ge(a,o);for(let z=a;z<d;z+=y)for(let D=o;D<f;D+=y)S.push(new Ts(z+v,D+v,v,i));let A=(function(z){let D=0,O=0,q=0;const H=z[0];for(let re=0,Y=H.length,ae=Y-1;re<Y;ae=re++){const oe=H[re],_e=H[ae],De=oe.x*_e.y-_e.x*oe.y;O+=(oe.x+_e.x)*De,q+=(oe.y+_e.y)*De,D+=3*De}return new Ts(O/D,q/D,0,z)})(i),C=S.length;for(;S.length;){const z=S.pop();(z.d>A.d||!A.d)&&(A=z,r&&console.log("found best %d after %d probes",Math.round(1e4*z.d)/1e4,C)),z.max-A.d<=e||(v=z.h/2,S.push(new Ts(z.p.x-v,z.p.y-v,v,i)),S.push(new Ts(z.p.x+v,z.p.y-v,v,i)),S.push(new Ts(z.p.x-v,z.p.y+v,v,i)),S.push(new Ts(z.p.x+v,z.p.y+v,v,i)),C+=4)}return r&&(console.log(`num probes: ${C}`),console.log(`best distance: ${A.d}`)),A.p}function L_(i,e){return e.max-i.max}function Ts(i,e,r,a){this.p=new ge(i,e),this.h=r,this.d=(function(o,d){let f=!1,m=1/0;for(let y=0;y<d.length;y++){const v=d[y];for(let S=0,A=v.length,C=A-1;S<A;C=S++){const z=v[S],D=v[C];z.y>o.y!=D.y>o.y&&o.x<(D.x-z.x)*(o.y-z.y)/(D.y-z.y)+z.x&&(f=!f),m=Math.min(m,Mh(o,z,D))}}return(f?1:-1)*Math.sqrt(m)})(this.p,a),this.max=this.d+this.h*Math.SQRT2}var yi;l.aq=void 0,(yi=l.aq||(l.aq={}))[yi.center=1]="center",yi[yi.left=2]="left",yi[yi.right=3]="right",yi[yi.top=4]="top",yi[yi.bottom=5]="bottom",yi[yi["top-left"]=6]="top-left",yi[yi["top-right"]=7]="top-right",yi[yi["bottom-left"]=8]="bottom-left",yi[yi["bottom-right"]=9]="bottom-right";const sa=7,cu=Number.POSITIVE_INFINITY;function Xp(i,e){return e[1]!==cu?(function(r,a,o){let d=0,f=0;switch(a=Math.abs(a),o=Math.abs(o),r){case"top-right":case"top-left":case"top":f=o-sa;break;case"bottom-right":case"bottom-left":case"bottom":f=-o+sa}switch(r){case"top-right":case"bottom-right":case"right":d=-a;break;case"top-left":case"bottom-left":case"left":d=a}return[d,f]})(i,e[0],e[1]):(function(r,a){let o=0,d=0;a<0&&(a=0);const f=a/Math.SQRT2;switch(r){case"top-right":case"top-left":d=f-sa;break;case"bottom-right":case"bottom-left":d=-f+sa;break;case"bottom":d=-a+sa;break;case"top":d=a-sa}switch(r){case"top-right":case"bottom-right":o=-f;break;case"top-left":case"bottom-left":o=f;break;case"left":o=a;break;case"right":o=-a}return[o,d]})(i,e[0])}function Kp(i,e,r){var a;const o=i.layout,d=(a=o.get("text-variable-anchor-offset"))===null||a===void 0?void 0:a.evaluate(e,{},r);if(d){const m=d.values,y=[];for(let v=0;v<m.length;v+=2){const S=y[v]=m[v],A=m[v+1].map((C=>C*ii));S.startsWith("top")?A[1]-=sa:S.startsWith("bottom")&&(A[1]+=sa),y[v+1]=A}return new lr(y)}const f=o.get("text-variable-anchor");if(f){let m;m=i._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[o.get("text-radial-offset").evaluate(e,{},r)*ii,cu]:o.get("text-offset").evaluate(e,{},r).map((v=>v*ii));const y=[];for(const v of f)y.push(v,Xp(v,m));return new lr(y)}return null}function uu(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function F_(i,e,r,a,o,d,f,m,y,v,S){let A=d.textMaxSize.evaluate(e,{});A===void 0&&(A=f);const C=i.layers[0].layout,z=C.get("icon-offset").evaluate(e,{},S),D=Jp(r.horizontal),O=f/24,q=i.tilePixelRatio*O,H=i.tilePixelRatio*A/24,re=i.tilePixelRatio*m,Y=i.tilePixelRatio*C.get("symbol-spacing"),ae=C.get("text-padding")*i.tilePixelRatio,oe=(function(we,Ze,Ue,lt=1){const zt=we.get("icon-padding").evaluate(Ze,{},Ue),Ft=zt&&zt.values;return[Ft[0]*lt,Ft[1]*lt,Ft[2]*lt,Ft[3]*lt]})(C,e,S,i.tilePixelRatio),_e=C.get("text-max-angle")/180*Math.PI,De=C.get("text-rotation-alignment")!=="viewport"&&C.get("symbol-placement")!=="point",Oe=C.get("icon-rotation-alignment")==="map"&&C.get("symbol-placement")!=="point",Pe=C.get("symbol-placement"),Me=Y/2,Ie=C.get("icon-text-fit");let Fe;a&&Ie!=="none"&&(i.allowVerticalPlacement&&r.vertical&&(Fe=vp(a,r.vertical,Ie,C.get("icon-text-fit-padding"),z,O)),D&&(a=vp(a,D,Ie,C.get("icon-text-fit-padding"),z,O)));const ke=(we,Ze)=>{Ze.x<0||Ze.x>=Jt||Ze.y<0||Ze.y>=Jt||(function(Ue,lt,zt,Ft,ri,fr,Oi,Qt,fi,xi,Ni,Vi,ni,ai,Ai,Ui,ki,Qi,er,si,pt,Ci,vi,oi,Mr){const $r=Ue.addToLineVertexArray(lt,zt);let jr,Pn,Pr,yr,tr=0,zn=0,Bo=0,id=0,yu=-1,xu=-1;const Dn={};let rd=kn("");if(Ue.allowVerticalPlacement&&Ft.vertical){const Ei=Qt.layout.get("text-rotate").evaluate(pt,{},oi)+90;Pr=new Kl(fi,lt,xi,Ni,Vi,Ft.vertical,ni,ai,Ai,Ei),Oi&&(yr=new Kl(fi,lt,xi,Ni,Vi,Oi,ki,Qi,Ai,Ei))}if(ri){const Ei=Qt.layout.get("icon-rotate").evaluate(pt,{}),xr=Qt.layout.get("icon-text-fit")!=="none",Pa=Hp(ri,Ei,vi,xr),Zr=Oi?Hp(Oi,Ei,vi,xr):void 0;Pn=new Kl(fi,lt,xi,Ni,Vi,ri,ki,Qi,!1,Ei),tr=4*Pa.length;const za=Ue.iconSizeData;let cn=null;za.kind==="source"?(cn=[ln*Qt.layout.get("icon-size").evaluate(pt,{})],cn[0]>ra&&Dt(`${Ue.layerIds[0]}: Value for "icon-size" is >= ${Do}. Reduce your "icon-size".`)):za.kind==="composite"&&(cn=[ln*Ci.compositeIconSizes[0].evaluate(pt,{},oi),ln*Ci.compositeIconSizes[1].evaluate(pt,{},oi)],(cn[0]>ra||cn[1]>ra)&&Dt(`${Ue.layerIds[0]}: Value for "icon-size" is >= ${Do}. Reduce your "icon-size".`)),Ue.addSymbols(Ue.icon,Pa,cn,si,er,pt,l.ai.none,lt,$r.lineStartIndex,$r.lineLength,-1,oi),yu=Ue.icon.placedSymbolArray.length-1,Zr&&(zn=4*Zr.length,Ue.addSymbols(Ue.icon,Zr,cn,si,er,pt,l.ai.vertical,lt,$r.lineStartIndex,$r.lineLength,-1,oi),xu=Ue.icon.placedSymbolArray.length-1)}const nd=Object.keys(Ft.horizontal);for(const Ei of nd){const xr=Ft.horizontal[Ei];if(!jr){rd=kn(xr.text);const Zr=Qt.layout.get("text-rotate").evaluate(pt,{},oi);jr=new Kl(fi,lt,xi,Ni,Vi,xr,ni,ai,Ai,Zr)}const Pa=xr.positionedLines.length===1;if(Bo+=Yp(Ue,lt,xr,fr,Qt,Ai,pt,Ui,$r,Ft.vertical?l.ai.horizontal:l.ai.horizontalOnly,Pa?nd:[Ei],Dn,yu,Ci,oi),Pa)break}Ft.vertical&&(id+=Yp(Ue,lt,Ft.vertical,fr,Qt,Ai,pt,Ui,$r,l.ai.vertical,["vertical"],Dn,xu,Ci,oi));const O_=jr?jr.boxStartIndex:Ue.collisionBoxArray.length,N_=jr?jr.boxEndIndex:Ue.collisionBoxArray.length,V_=Pr?Pr.boxStartIndex:Ue.collisionBoxArray.length,U_=Pr?Pr.boxEndIndex:Ue.collisionBoxArray.length,$_=Pn?Pn.boxStartIndex:Ue.collisionBoxArray.length,j_=Pn?Pn.boxEndIndex:Ue.collisionBoxArray.length,q_=yr?yr.boxStartIndex:Ue.collisionBoxArray.length,Z_=yr?yr.boxEndIndex:Ue.collisionBoxArray.length;let qr=-1;const Jl=(Ei,xr)=>Ei&&Ei.circleDiameter?Math.max(Ei.circleDiameter,xr):xr;qr=Jl(jr,qr),qr=Jl(Pr,qr),qr=Jl(Pn,qr),qr=Jl(yr,qr);const ad=qr>-1?1:0;ad&&(qr*=Mr/ii),Ue.glyphOffsetArray.length>=ws.MAX_GLYPHS&&Dt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),pt.sortKey!==void 0&&Ue.addToSortKeyRanges(Ue.symbolInstances.length,pt.sortKey);const G_=Kp(Qt,pt,oi),[H_,W_]=(function(Ei,xr){const Pa=Ei.length,Zr=xr==null?void 0:xr.values;if((Zr==null?void 0:Zr.length)>0)for(let za=0;za<Zr.length;za+=2){const cn=Zr[za+1];Ei.emplaceBack(l.aq[Zr[za]],cn[0],cn[1])}return[Pa,Ei.length]})(Ue.textAnchorOffsets,G_);Ue.symbolInstances.emplaceBack(lt.x,lt.y,Dn.right>=0?Dn.right:-1,Dn.center>=0?Dn.center:-1,Dn.left>=0?Dn.left:-1,Dn.vertical||-1,yu,xu,rd,O_,N_,V_,U_,$_,j_,q_,Z_,xi,Bo,id,tr,zn,ad,0,ni,qr,H_,W_)})(i,Ze,we,r,a,o,Fe,i.layers[0],i.collisionBoxArray,e.index,e.sourceLayerIndex,i.index,q,[ae,ae,ae,ae],De,y,re,oe,Oe,z,e,d,v,S,f)};if(Pe==="line")for(const we of Up(e.geometry,0,0,Jt,Jt)){const Ze=M_(we,Y,_e,r.vertical||D,a,24,H,i.overscaling,Jt);for(const Ue of Ze)D&&R_(i,D.text,Me,Ue)||ke(we,Ue)}else if(Pe==="line-center"){for(const we of e.geometry)if(we.length>1){const Ze=E_(we,_e,r.vertical||D,a,24,H);Ze&&ke(we,Ze)}}else if(e.type==="Polygon")for(const we of $c(e.geometry,0)){const Ze=D_(we,16);ke(we[0],new aa(Ze.x,Ze.y,0))}else if(e.type==="LineString")for(const we of e.geometry)ke(we,new aa(we[0].x,we[0].y,0));else if(e.type==="Point")for(const we of e.geometry)for(const Ze of we)ke([Ze],new aa(Ze.x,Ze.y,0))}function Yp(i,e,r,a,o,d,f,m,y,v,S,A,C,z,D){const O=(function(re,Y,ae,oe,_e,De,Oe,Pe){const Me=oe.layout.get("text-rotate").evaluate(De,{})*Math.PI/180,Ie=[];for(const Fe of Y.positionedLines)for(const ke of Fe.positionedGlyphs){if(!ke.rect)continue;const we=ke.rect||{};let Ze=dp+1,Ue=!0,lt=1,zt=0;const Ft=(_e||Pe)&&ke.vertical,ri=ke.metrics.advance*ke.scale/2;if(Pe&&Y.verticalizable&&(zt=Fe.lineOffset/2-(ke.imageName?-(ii-ke.metrics.width*ke.scale)/2:(ke.scale-1)*ii)),ke.imageName){const si=Oe[ke.imageName];Ue=si.sdf,lt=si.pixelRatio,Ze=Ji/lt}const fr=_e?[ke.x+ri,ke.y]:[0,0];let Oi=_e?[0,0]:[ke.x+ri+ae[0],ke.y+ae[1]-zt],Qt=[0,0];Ft&&(Qt=Oi,Oi=[0,0]);const fi=ke.metrics.isDoubleResolution?2:1,xi=(ke.metrics.left-Ze)*ke.scale-ri+Oi[0],Ni=(-ke.metrics.top-Ze)*ke.scale+Oi[1],Vi=xi+we.w/fi*ke.scale/lt,ni=Ni+we.h/fi*ke.scale/lt,ai=new ge(xi,Ni),Ai=new ge(Vi,Ni),Ui=new ge(xi,ni),ki=new ge(Vi,ni);if(Ft){const si=new ge(-ri,ri-Po),pt=-Math.PI/2,Ci=ii/2-ri,vi=new ge(5-Po-Ci,-(ke.imageName?Ci:0)),oi=new ge(...Qt);ai._rotateAround(pt,si)._add(vi)._add(oi),Ai._rotateAround(pt,si)._add(vi)._add(oi),Ui._rotateAround(pt,si)._add(vi)._add(oi),ki._rotateAround(pt,si)._add(vi)._add(oi)}if(Me){const si=Math.sin(Me),pt=Math.cos(Me),Ci=[pt,-si,si,pt];ai._matMult(Ci),Ai._matMult(Ci),Ui._matMult(Ci),ki._matMult(Ci)}const Qi=new ge(0,0),er=new ge(0,0);Ie.push({tl:ai,tr:Ai,bl:Ui,br:ki,tex:we,writingMode:Y.writingMode,glyphOffset:fr,sectionIndex:ke.sectionIndex,isSDF:Ue,pixelOffsetTL:Qi,pixelOffsetBR:er,minFontScaleX:0,minFontScaleY:0})}return Ie})(0,r,m,o,d,f,a,i.allowVerticalPlacement),q=i.textSizeData;let H=null;q.kind==="source"?(H=[ln*o.layout.get("text-size").evaluate(f,{})],H[0]>ra&&Dt(`${i.layerIds[0]}: Value for "text-size" is >= ${Do}. Reduce your "text-size".`)):q.kind==="composite"&&(H=[ln*z.compositeTextSizes[0].evaluate(f,{},D),ln*z.compositeTextSizes[1].evaluate(f,{},D)],(H[0]>ra||H[1]>ra)&&Dt(`${i.layerIds[0]}: Value for "text-size" is >= ${Do}. Reduce your "text-size".`)),i.addSymbols(i.text,O,H,m,d,f,v,e,y.lineStartIndex,y.lineLength,C,D);for(const re of S)A[re]=i.text.placedSymbolArray.length-1;return 4*O.length}function Jp(i){for(const e in i)return i[e];return null}function R_(i,e,r,a){const o=i.compareText;if(e in o){const d=o[e];for(let f=d.length-1;f>=0;f--)if(a.dist(d[f])<r)return!0}else o[e]=[];return o[e].push(a),!1}const Qp=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class hu{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[r,a]=new Uint8Array(e,0,2);if(r!==219)throw new Error("Data does not appear to be in a KDBush format.");const o=a>>4;if(o!==1)throw new Error(`Got v${o} data when expected v1.`);const d=Qp[15&a];if(!d)throw new Error("Unrecognized array type.");const[f]=new Uint16Array(e,2,1),[m]=new Uint32Array(e,4,1);return new hu(m,f,d,e)}constructor(e,r=64,a=Float64Array,o){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=a,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const d=Qp.indexOf(this.ArrayType),f=2*e*this.ArrayType.BYTES_PER_ELEMENT,m=e*this.IndexArrayType.BYTES_PER_ELEMENT,y=(8-m%8)%8;if(d<0)throw new Error(`Unexpected typed array class: ${a}.`);o&&o instanceof ArrayBuffer?(this.data=o,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+m+y,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+f+m+y),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+m+y,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+d]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=e)}add(e,r){const a=this._pos>>1;return this.ids[a]=a,this.coords[this._pos++]=e,this.coords[this._pos++]=r,a}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return pu(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,r,a,o){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:d,coords:f,nodeSize:m}=this,y=[0,d.length-1,0],v=[];for(;y.length;){const S=y.pop()||0,A=y.pop()||0,C=y.pop()||0;if(A-C<=m){for(let q=C;q<=A;q++){const H=f[2*q],re=f[2*q+1];H>=e&&H<=a&&re>=r&&re<=o&&v.push(d[q])}continue}const z=C+A>>1,D=f[2*z],O=f[2*z+1];D>=e&&D<=a&&O>=r&&O<=o&&v.push(d[z]),(S===0?e<=D:r<=O)&&(y.push(C),y.push(z-1),y.push(1-S)),(S===0?a>=D:o>=O)&&(y.push(z+1),y.push(A),y.push(1-S))}return v}within(e,r,a){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:o,coords:d,nodeSize:f}=this,m=[0,o.length-1,0],y=[],v=a*a;for(;m.length;){const S=m.pop()||0,A=m.pop()||0,C=m.pop()||0;if(A-C<=f){for(let q=C;q<=A;q++)td(d[2*q],d[2*q+1],e,r)<=v&&y.push(o[q]);continue}const z=C+A>>1,D=d[2*z],O=d[2*z+1];td(D,O,e,r)<=v&&y.push(o[z]),(S===0?e-a<=D:r-a<=O)&&(m.push(C),m.push(z-1),m.push(1-S)),(S===0?e+a>=D:r+a>=O)&&(m.push(z+1),m.push(A),m.push(1-S))}return y}}function pu(i,e,r,a,o,d){if(o-a<=r)return;const f=a+o>>1;ed(i,e,f,a,o,d),pu(i,e,r,a,f-1,1-d),pu(i,e,r,f+1,o,1-d)}function ed(i,e,r,a,o,d){for(;o>a;){if(o-a>600){const v=o-a+1,S=r-a+1,A=Math.log(v),C=.5*Math.exp(2*A/3),z=.5*Math.sqrt(A*C*(v-C)/v)*(S-v/2<0?-1:1);ed(i,e,r,Math.max(a,Math.floor(r-S*C/v+z)),Math.min(o,Math.floor(r+(v-S)*C/v+z)),d)}const f=e[2*r+d];let m=a,y=o;for(Fo(i,e,a,r),e[2*o+d]>f&&Fo(i,e,a,o);m<y;){for(Fo(i,e,m,y),m++,y--;e[2*m+d]<f;)m++;for(;e[2*y+d]>f;)y--}e[2*a+d]===f?Fo(i,e,a,y):(y++,Fo(i,e,y,o)),y<=r&&(a=y+1),r<=y&&(o=y-1)}}function Fo(i,e,r,a){du(i,r,a),du(e,2*r,2*a),du(e,2*r+1,2*a+1)}function du(i,e,r){const a=i[e];i[e]=i[r],i[r]=a}function td(i,e,r,a){const o=i-r,d=e-a;return o*o+d*d}var fu;l.bh=void 0,(fu=l.bh||(l.bh={})).create="create",fu.load="load",fu.fullLoad="fullLoad";let Yl=null,Ro=[];const mu=1e3/60,gu="loadTime",_u="fullLoadTime",B_={mark(i){performance.mark(i)},frame(i){const e=i;Yl!=null&&Ro.push(e-Yl),Yl=e},clearMetrics(){Yl=null,Ro=[],performance.clearMeasures(gu),performance.clearMeasures(_u);for(const i in l.bh)performance.clearMarks(l.bh[i])},getPerformanceMetrics(){performance.measure(gu,l.bh.create,l.bh.load),performance.measure(_u,l.bh.create,l.bh.fullLoad);const i=performance.getEntriesByName(gu)[0].duration,e=performance.getEntriesByName(_u)[0].duration,r=Ro.length,a=1/(Ro.reduce(((d,f)=>d+f),0)/r/1e3),o=Ro.filter((d=>d>mu)).reduce(((d,f)=>d+(f-mu)/mu),0);return{loadTime:i,fullLoadTime:e,fps:a,percentDroppedFrames:o/(r+o)*100,totalFrames:r}}};l.$=function(i,e,r){var a,o,d,f,m,y,v,S,A,C,z,D,O=r[0],q=r[1],H=r[2];return e===i?(i[12]=e[0]*O+e[4]*q+e[8]*H+e[12],i[13]=e[1]*O+e[5]*q+e[9]*H+e[13],i[14]=e[2]*O+e[6]*q+e[10]*H+e[14],i[15]=e[3]*O+e[7]*q+e[11]*H+e[15]):(o=e[1],d=e[2],f=e[3],m=e[4],y=e[5],v=e[6],S=e[7],A=e[8],C=e[9],z=e[10],D=e[11],i[0]=a=e[0],i[1]=o,i[2]=d,i[3]=f,i[4]=m,i[5]=y,i[6]=v,i[7]=S,i[8]=A,i[9]=C,i[10]=z,i[11]=D,i[12]=a*O+m*q+A*H+e[12],i[13]=o*O+y*q+C*H+e[13],i[14]=d*O+v*q+z*H+e[14],i[15]=f*O+S*q+D*H+e[15]),i},l.A=gs,l.B=Hi,l.C=class{constructor(i,e,r){this.receive=a=>{const o=a.data,d=o.id;if(d&&(!o.targetMapId||this.mapId===o.targetMapId))if(o.type==="<cancel>"){delete this.tasks[d];const f=this.cancelCallbacks[d];delete this.cancelCallbacks[d],f&&f()}else nr()||o.mustQueue?(this.tasks[d]=o,this.taskQueue.push(d),this.invoker.trigger()):this.processTask(d,o)},this.process=()=>{if(!this.taskQueue.length)return;const a=this.taskQueue.shift(),o=this.tasks[a];delete this.tasks[a],this.taskQueue.length&&this.invoker.trigger(),o&&this.processTask(a,o)},this.target=i,this.parent=e,this.mapId=r,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},this.invoker=new k_(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=nr()?i:window}send(i,e,r,a,o=!1){const d=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(this.callbacks[d]=r);const f=[],m={id:d,type:i,hasCallback:!!r,targetMapId:a,mustQueue:o,sourceMapId:this.mapId,data:an(e,f)};return this.target.postMessage(m,{transfer:f}),{cancel:()=>{r&&delete this.callbacks[d],this.target.postMessage({id:d,type:"<cancel>",targetMapId:a,sourceMapId:this.mapId})}}}processTask(i,e){if(e.type==="<response>"){const r=this.callbacks[i];delete this.callbacks[i],r&&(e.error?r(Yn(e.error)):r(null,Yn(e.data)))}else{let r=!1;const a=[],o=e.hasCallback?(m,y)=>{r=!0,delete this.cancelCallbacks[i];const v={id:i,type:"<response>",sourceMapId:this.mapId,error:m?an(m):null,data:an(y,a)};this.target.postMessage(v,{transfer:a})}:m=>{r=!0};let d=null;const f=Yn(e.data);if(this.parent[e.type])d=this.parent[e.type](e.sourceMapId,f,o);else if("getWorkerSource"in this.parent){const m=e.type.split(".");d=this.parent.getWorkerSource(e.sourceMapId,m[0],f.source)[m[1]](f,o)}else o(new Error(`Could not find function ${e.type}`));!r&&d&&d.cancel&&(this.cancelCallbacks[i]=d.cancel)}}remove(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)}},l.D=je,l.E=mn,l.F=function(i,e){const r={};for(let a=0;a<e.length;a++){const o=e[a];o in i&&(r[o]=i[o])}return r},l.G=Ep,l.H=Mp,l.I=Jc,l.J=st,l.K=wi,l.L=na,l.M=ca,l.N=Jt,l.O=_r,l.P=ge,l.Q=Nt,l.R=gr,l.S=Pt,l.T=Al,l.U=Gl,l.V=class extends In{},l.W=lu,l.X=function(i,e){const r=window.document.createElement("video");r.muted=!0,r.onloadstart=function(){e(null,r)};for(let a=0;a<i.length;a++){const o=window.document.createElement("source");Dr(i[a])||(r.crossOrigin="Anonymous"),o.src=i[a],r.appendChild(o)}return{cancel:()=>{}}},l.Y=Ae,l.Z=function(){var i=new gs(16);return gs!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},l._=le,l.a=la,l.a$=class extends P{},l.a0=function(i,e,r){var a=r[0],o=r[1],d=r[2];return i[0]=e[0]*a,i[1]=e[1]*a,i[2]=e[2]*a,i[3]=e[3]*a,i[4]=e[4]*o,i[5]=e[5]*o,i[6]=e[6]*o,i[7]=e[7]*o,i[8]=e[8]*d,i[9]=e[9]*d,i[10]=e[10]*d,i[11]=e[11]*d,i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},l.a1=Lh,l.a2=function(){return it++},l.a3=$,l.a4=ws,l.a5=function(){Ki.isLoading()||Ki.isLoaded()||co()!=="deferred"||Il()},l.a6=Js,l.a7=Ea,l.a8=Mt,l.a9=Bp,l.aA=Sa,l.aB=function(i){i=i.slice();const e=Object.create(null);for(let r=0;r<i.length;r++)e[i[r].id]=i[r];for(let r=0;r<i.length;r++)"ref"in i[r]&&(i[r]=sr(i[r],e[i[r].ref]));return i},l.aC=function(i){if(i.type==="custom")return new A_(i);switch(i.type){case"background":return new S_(i);case"circle":return new lg(i);case"fill":return new Cg(i);case"fill-extrusion":return new jg(i);case"heatmap":return new ug(i);case"hillshade":return new pg(i);case"line":return new Yg(i);case"raster":return new I_(i);case"symbol":return new Zl(i)}},l.aD=Vt,l.aE=function(i,e){if(!i)return[{command:_t.setStyle,args:[e]}];let r=[];try{if(!At(i.version,e.version))return[{command:_t.setStyle,args:[e]}];At(i.center,e.center)||r.push({command:_t.setCenter,args:[e.center]}),At(i.zoom,e.zoom)||r.push({command:_t.setZoom,args:[e.zoom]}),At(i.bearing,e.bearing)||r.push({command:_t.setBearing,args:[e.bearing]}),At(i.pitch,e.pitch)||r.push({command:_t.setPitch,args:[e.pitch]}),At(i.sprite,e.sprite)||r.push({command:_t.setSprite,args:[e.sprite]}),At(i.glyphs,e.glyphs)||r.push({command:_t.setGlyphs,args:[e.glyphs]}),At(i.transition,e.transition)||r.push({command:_t.setTransition,args:[e.transition]}),At(i.light,e.light)||r.push({command:_t.setLight,args:[e.light]});const a={},o=[];(function(f,m,y,v){let S;for(S in m=m||{},f=f||{})Object.prototype.hasOwnProperty.call(f,S)&&(Object.prototype.hasOwnProperty.call(m,S)||Nn(S,y,v));for(S in m)Object.prototype.hasOwnProperty.call(m,S)&&(Object.prototype.hasOwnProperty.call(f,S)?At(f[S],m[S])||(f[S].type==="geojson"&&m[S].type==="geojson"&&Na(f,m,S)?y.push({command:_t.setGeoJSONSourceData,args:[S,m[S].data]}):Lr(S,m,y,v)):br(S,m,y))})(i.sources,e.sources,o,a);const d=[];i.layers&&i.layers.forEach((f=>{a[f.source]?r.push({command:_t.removeLayer,args:[f.id]}):d.push(f)})),r=r.concat(o),(function(f,m,y){m=m||[];const v=(f=f||[]).map(Jr),S=m.map(Jr),A=f.reduce(gn,{}),C=m.reduce(gn,{}),z=v.slice(),D=Object.create(null);let O,q,H,re,Y,ae,oe;for(O=0,q=0;O<v.length;O++)H=v[O],Object.prototype.hasOwnProperty.call(C,H)?q++:(y.push({command:_t.removeLayer,args:[H]}),z.splice(z.indexOf(H,q),1));for(O=0,q=0;O<S.length;O++)H=S[S.length-1-O],z[z.length-1-O]!==H&&(Object.prototype.hasOwnProperty.call(A,H)?(y.push({command:_t.removeLayer,args:[H]}),z.splice(z.lastIndexOf(H,z.length-q),1)):q++,ae=z[z.length-O],y.push({command:_t.addLayer,args:[C[H],ae]}),z.splice(z.length-O,0,H),D[H]=!0);for(O=0;O<S.length;O++)if(H=S[O],re=A[H],Y=C[H],!D[H]&&!At(re,Y))if(At(re.source,Y.source)&&At(re["source-layer"],Y["source-layer"])&&At(re.type,Y.type)){for(oe in Vn(re.layout,Y.layout,y,H,null,_t.setLayoutProperty),Vn(re.paint,Y.paint,y,H,null,_t.setPaintProperty),At(re.filter,Y.filter)||y.push({command:_t.setFilter,args:[H,Y.filter]}),At(re.minzoom,Y.minzoom)&&At(re.maxzoom,Y.maxzoom)||y.push({command:_t.setLayerZoomRange,args:[H,Y.minzoom,Y.maxzoom]}),re)Object.prototype.hasOwnProperty.call(re,oe)&&oe!=="layout"&&oe!=="paint"&&oe!=="filter"&&oe!=="metadata"&&oe!=="minzoom"&&oe!=="maxzoom"&&(oe.indexOf("paint.")===0?Vn(re[oe],Y[oe],y,H,oe.slice(6),_t.setPaintProperty):At(re[oe],Y[oe])||y.push({command:_t.setLayerProperty,args:[H,oe,Y[oe]]}));for(oe in Y)Object.prototype.hasOwnProperty.call(Y,oe)&&!Object.prototype.hasOwnProperty.call(re,oe)&&oe!=="layout"&&oe!=="paint"&&oe!=="filter"&&oe!=="metadata"&&oe!=="minzoom"&&oe!=="maxzoom"&&(oe.indexOf("paint.")===0?Vn(re[oe],Y[oe],y,H,oe.slice(6),_t.setPaintProperty):At(re[oe],Y[oe])||y.push({command:_t.setLayerProperty,args:[H,oe,Y[oe]]}))}else y.push({command:_t.removeLayer,args:[H]}),ae=z[z.lastIndexOf(H)+1],y.push({command:_t.addLayer,args:[Y,ae]})})(d,e.layers,r)}catch(a){console.warn("Unable to compute style diff:",a),r=[{command:_t.setStyle,args:[e]}]}return r},l.aF=function(i){const e=[],r=i.id;return r===void 0&&e.push({message:`layers.${r}: missing required property "id"`}),i.render===void 0&&e.push({message:`layers.${r}: missing required method "render"`}),i.renderingMode&&i.renderingMode!=="2d"&&i.renderingMode!=="3d"&&e.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),e},l.aG=function i(e,r){if(Array.isArray(e)){if(!Array.isArray(r)||e.length!==r.length)return!1;for(let a=0;a<e.length;a++)if(!i(e[a],r[a]))return!1;return!0}if(typeof e=="object"&&e!==null&&r!==null){if(typeof r!="object"||Object.keys(e).length!==Object.keys(r).length)return!1;for(const a in e)if(!i(e[a],r[a]))return!1;return!0}return e===r},l.aH=nt,l.aI=ji,l.aJ=Ta,l.aK=function(i){return i({pluginStatus:Fi,pluginURL:sn}),Ta.on("pluginStateChange",i),i},l.aL=class extends Cn{constructor(i,e){super(i,e),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},l.aM=fs,l.aN=class extends Cn{constructor(i,e){super(i,e),this.current=Mc}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let e=1;e<16;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},l.aO=Ml,l.aP=class extends Cn{constructor(i,e){super(i,e),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},l.aQ=class extends Cn{constructor(i,e){super(i,e),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},l.aR=Pl,l.aS=function(i,e,r,a,o,d,f){var m=1/(e-r),y=1/(a-o),v=1/(d-f);return i[0]=-2*m,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*y,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*v,i[11]=0,i[12]=(e+r)*m,i[13]=(o+a)*y,i[14]=(f+d)*v,i[15]=1,i},l.aT=wt,l.aU=og,l.aV=class extends s{},l.aW=t_,l.aX=class extends p{},l.aY=function(i){return i<=1?1:Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))},l.aZ=Nh,l.a_=Te,l.aa=function(i){const e={};if(i.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((r,a,o,d)=>{const f=o||d;return e[a]=!f||f.toLowerCase(),""})),e["max-age"]){const r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e},l.ab=function(i,e){const r=[];for(const a in i)a in e||r.push(a);return r},l.ac=function(i){if(pn==null){const e=i.navigator?i.navigator.userAgent:null;pn=!!i.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return pn},l.ad=rr,l.ae=function(i,e,r){var a=Math.sin(r),o=Math.cos(r),d=e[0],f=e[1],m=e[2],y=e[3],v=e[4],S=e[5],A=e[6],C=e[7];return e!==i&&(i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[0]=d*o+v*a,i[1]=f*o+S*a,i[2]=m*o+A*a,i[3]=y*o+C*a,i[4]=v*o-d*a,i[5]=S*o-f*a,i[6]=A*o-m*a,i[7]=C*o-y*a,i},l.af=function(i){var e=new gs(16);return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],e},l.ag=Fl,l.ah=function(i,e){let r=0,a=0;if(i.kind==="constant")a=i.layoutSize;else if(i.kind!=="source"){const{interpolationType:o,minZoom:d,maxZoom:f}=i,m=o?rr(Wi.interpolationFactor(o,e,d,f),0,1):0;i.kind==="camera"?a=Hi.number(i.minSize,i.maxSize,m):r=m}return{uSizeT:r,uSize:a}},l.aj=function(i,{uSize:e,uSizeT:r},{lowerSize:a,upperSize:o}){return i.kind==="source"?a/ln:i.kind==="composite"?Hi.number(a/ln,o/ln,r):e},l.ak=iu,l.al=function(i,e,r,a){const o=e.y-i.y,d=e.x-i.x,f=a.y-r.y,m=a.x-r.x,y=f*d-m*o;if(y===0)return null;const v=(m*(i.y-r.y)-f*(i.x-r.x))/y;return new ge(i.x+v*d,i.y+v*o)},l.am=Up,l.an=Ch,l.ao=Fc,l.ap=ii,l.ar=tu,l.as=function(i,e){var r=e[0],a=e[1],o=e[2],d=e[3],f=e[4],m=e[5],y=e[6],v=e[7],S=e[8],A=e[9],C=e[10],z=e[11],D=e[12],O=e[13],q=e[14],H=e[15],re=r*m-a*f,Y=r*y-o*f,ae=r*v-d*f,oe=a*y-o*m,_e=a*v-d*m,De=o*v-d*y,Oe=S*O-A*D,Pe=S*q-C*D,Me=S*H-z*D,Ie=A*q-C*O,Fe=A*H-z*O,ke=C*H-z*q,we=re*ke-Y*Fe+ae*Ie+oe*Me-_e*Pe+De*Oe;return we?(i[0]=(m*ke-y*Fe+v*Ie)*(we=1/we),i[1]=(o*Fe-a*ke-d*Ie)*we,i[2]=(O*De-q*_e+H*oe)*we,i[3]=(C*_e-A*De-z*oe)*we,i[4]=(y*Me-f*ke-v*Pe)*we,i[5]=(r*ke-o*Me+d*Pe)*we,i[6]=(q*ae-D*De-H*Y)*we,i[7]=(S*De-C*ae+z*Y)*we,i[8]=(f*Fe-m*Me+v*Oe)*we,i[9]=(a*Me-r*Fe-d*Oe)*we,i[10]=(D*_e-O*ae+H*re)*we,i[11]=(A*ae-S*_e-z*re)*we,i[12]=(m*Pe-f*Ie-y*Oe)*we,i[13]=(r*Ie-a*Pe+o*Oe)*we,i[14]=(O*Y-D*oe-q*re)*we,i[15]=(S*oe-A*Y+C*re)*we,i):null},l.at=uu,l.au=eu,l.av=hu,l.aw=function(){const i={},e=he.$version;for(const r in he.$root){const a=he.$root[r];if(a.required){let o=null;o=r==="version"?e:a.type==="array"?[]:{},o!=null&&(i[r]=o)}}return i},l.ax=_t,l.ay=bl,l.az=mr,l.b=function(i,e){const r=new Blob([new Uint8Array(i)],{type:"image/png"});createImageBitmap(r).then((a=>{e(null,a)})).catch((a=>{e(new Error(`Could not load image because of ${a.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))},l.b0=pi,l.b1=function(i,e){var r=i[0],a=i[1],o=i[2],d=i[3],f=i[4],m=i[5],y=i[6],v=i[7],S=i[8],A=i[9],C=i[10],z=i[11],D=i[12],O=i[13],q=i[14],H=i[15],re=e[0],Y=e[1],ae=e[2],oe=e[3],_e=e[4],De=e[5],Oe=e[6],Pe=e[7],Me=e[8],Ie=e[9],Fe=e[10],ke=e[11],we=e[12],Ze=e[13],Ue=e[14],lt=e[15];return Math.abs(r-re)<=Bi*Math.max(1,Math.abs(r),Math.abs(re))&&Math.abs(a-Y)<=Bi*Math.max(1,Math.abs(a),Math.abs(Y))&&Math.abs(o-ae)<=Bi*Math.max(1,Math.abs(o),Math.abs(ae))&&Math.abs(d-oe)<=Bi*Math.max(1,Math.abs(d),Math.abs(oe))&&Math.abs(f-_e)<=Bi*Math.max(1,Math.abs(f),Math.abs(_e))&&Math.abs(m-De)<=Bi*Math.max(1,Math.abs(m),Math.abs(De))&&Math.abs(y-Oe)<=Bi*Math.max(1,Math.abs(y),Math.abs(Oe))&&Math.abs(v-Pe)<=Bi*Math.max(1,Math.abs(v),Math.abs(Pe))&&Math.abs(S-Me)<=Bi*Math.max(1,Math.abs(S),Math.abs(Me))&&Math.abs(A-Ie)<=Bi*Math.max(1,Math.abs(A),Math.abs(Ie))&&Math.abs(C-Fe)<=Bi*Math.max(1,Math.abs(C),Math.abs(Fe))&&Math.abs(z-ke)<=Bi*Math.max(1,Math.abs(z),Math.abs(ke))&&Math.abs(D-we)<=Bi*Math.max(1,Math.abs(D),Math.abs(we))&&Math.abs(O-Ze)<=Bi*Math.max(1,Math.abs(O),Math.abs(Ze))&&Math.abs(q-Ue)<=Bi*Math.max(1,Math.abs(q),Math.abs(Ue))&&Math.abs(H-lt)<=Bi*Math.max(1,Math.abs(H),Math.abs(lt))},l.b2=function(i,e){return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},l.b3=function(i,e,r){return i[0]=e[0]*r[0],i[1]=e[1]*r[1],i[2]=e[2]*r[2],i[3]=e[3]*r[3],i},l.b4=function(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]+i[3]*e[3]},l.b5=hn,l.b6=Lp,l.b7=Pp,l.b8=function(i,e,r,a,o){var d,f=1/Math.tan(e/2);return i[0]=f/r,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=f,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,o!=null&&o!==1/0?(i[10]=(o+a)*(d=1/(a-o)),i[14]=2*o*a*d):(i[10]=-1,i[14]=-2*a),i},l.b9=function(i,e,r){var a=Math.sin(r),o=Math.cos(r),d=e[4],f=e[5],m=e[6],y=e[7],v=e[8],S=e[9],A=e[10],C=e[11];return e!==i&&(i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[4]=d*o+v*a,i[5]=f*o+S*a,i[6]=m*o+A*a,i[7]=y*o+C*a,i[8]=v*o-d*a,i[9]=S*o-f*a,i[10]=A*o-m*a,i[11]=C*o-y*a,i},l.bA=Se,l.bB=sp,l.bC=rs,l.bD=Ki,l.ba=Pi,l.bb=Hr,l.bc=function(i,e){return i[0]=e[0],i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=e[1],i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=e[2],i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},l.bd=class extends ka{},l.be=su,l.bf=zp,l.bg=B_,l.bi=Wr,l.bj=function(i,e,r=!1){if(Fi===no||Fi===ao||Fi===so)throw new Error("setRTLTextPlugin cannot be called multiple times.");sn=Rn.resolveURL(i),Fi=no,oo=e,lo(),r||Il()},l.bk=co,l.bl=function(i,e){const r={};for(let o=0;o<i.length;o++){const d=e&&e[i[o].id]||os(i[o]);e&&(e[i[o].id]=d);let f=r[d];f||(f=r[d]=[]),f.push(i[o])}const a=[];for(const o in r)a.push(r[o]);return a},l.bm=Le,l.bn=Rp,l.bo=Op,l.bp=mp,l.bq=function(i){i.bucket.createArrays(),i.bucket.tilePixelRatio=Jt/(512*i.bucket.overscaling),i.bucket.compareText={},i.bucket.iconsNeedLinear=!1;const e=i.bucket.layers[0],r=e.layout,a=e._unevaluatedLayout._values,o={layoutIconSize:a["icon-size"].possiblyEvaluate(new Mt(i.bucket.zoom+1),i.canonical),layoutTextSize:a["text-size"].possiblyEvaluate(new Mt(i.bucket.zoom+1),i.canonical),textMaxSize:a["text-size"].possiblyEvaluate(new Mt(18))};if(i.bucket.textSizeData.kind==="composite"){const{minZoom:v,maxZoom:S}=i.bucket.textSizeData;o.compositeTextSizes=[a["text-size"].possiblyEvaluate(new Mt(v),i.canonical),a["text-size"].possiblyEvaluate(new Mt(S),i.canonical)]}if(i.bucket.iconSizeData.kind==="composite"){const{minZoom:v,maxZoom:S}=i.bucket.iconSizeData;o.compositeIconSizes=[a["icon-size"].possiblyEvaluate(new Mt(v),i.canonical),a["icon-size"].possiblyEvaluate(new Mt(S),i.canonical)]}const d=r.get("text-line-height")*ii,f=r.get("text-rotation-alignment")!=="viewport"&&r.get("symbol-placement")!=="point",m=r.get("text-keep-upright"),y=r.get("text-size");for(const v of i.bucket.features){const S=r.get("text-font").evaluate(v,{},i.canonical).join(","),A=y.evaluate(v,{},i.canonical),C=o.layoutTextSize.evaluate(v,{},i.canonical),z=o.layoutIconSize.evaluate(v,{},i.canonical),D={horizontal:{},vertical:void 0},O=v.text;let q,H=[0,0];if(O){const ae=O.toString(),oe=r.get("text-letter-spacing").evaluate(v,{},i.canonical)*ii,_e=io(ae)?oe:0,De=r.get("text-anchor").evaluate(v,{},i.canonical),Oe=Kp(e,v,i.canonical);if(!Oe){const ke=r.get("text-radial-offset").evaluate(v,{},i.canonical);H=ke?Xp(De,[ke*ii,cu]):r.get("text-offset").evaluate(v,{},i.canonical).map((we=>we*ii))}let Pe=f?"center":r.get("text-justify").evaluate(v,{},i.canonical);const Me=r.get("symbol-placement"),Ie=Me==="point"?r.get("text-max-width").evaluate(v,{},i.canonical)*ii:0,Fe=()=>{i.bucket.allowVerticalPlacement&&to(ae)&&(D.vertical=$l(O,i.glyphMap,i.glyphPositions,i.imagePositions,S,Ie,d,De,"left",_e,H,l.ai.vertical,!0,Me,C,A))};if(!f&&Oe){const ke=new Set;if(Pe==="auto")for(let Ze=0;Ze<Oe.values.length;Ze+=2)ke.add(uu(Oe.values[Ze]));else ke.add(Pe);let we=!1;for(const Ze of ke)if(!D.horizontal[Ze])if(we)D.horizontal[Ze]=D.horizontal[0];else{const Ue=$l(O,i.glyphMap,i.glyphPositions,i.imagePositions,S,Ie,d,"center",Ze,_e,H,l.ai.horizontal,!1,Me,C,A);Ue&&(D.horizontal[Ze]=Ue,we=Ue.positionedLines.length===1)}Fe()}else{Pe==="auto"&&(Pe=uu(De));const ke=$l(O,i.glyphMap,i.glyphPositions,i.imagePositions,S,Ie,d,De,Pe,_e,H,l.ai.horizontal,!1,Me,C,A);ke&&(D.horizontal[Pe]=ke),Fe(),to(ae)&&f&&m&&(D.vertical=$l(O,i.glyphMap,i.glyphPositions,i.imagePositions,S,Ie,d,De,Pe,_e,H,l.ai.vertical,!1,Me,C,A))}}let re=!1;if(v.icon&&v.icon.name){const ae=i.imageMap[v.icon.name];ae&&(q=y_(i.imagePositions[v.icon.name],r.get("icon-offset").evaluate(v,{},i.canonical),r.get("icon-anchor").evaluate(v,{},i.canonical)),re=!!ae.sdf,i.bucket.sdfIcons===void 0?i.bucket.sdfIcons=re:i.bucket.sdfIcons!==re&&Dt("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(ae.pixelRatio!==i.bucket.pixelRatio||r.get("icon-rotate").constantOr(1)!==0)&&(i.bucket.iconsNeedLinear=!0))}const Y=Jp(D.horizontal)||D.vertical;i.bucket.iconsInText=!!Y&&Y.iconsInText,(Y||q)&&F_(i.bucket,v,D,q,i.imageMap,o,C,z,H,re,i.canonical)}i.showCollisionBoxes&&i.bucket.generateCollisionDebugBuffers()},l.br=Wc,l.bs=Zc,l.bt=Hc,l.bu=class{constructor(i){this._marks={start:[i.url,"start"].join("#"),end:[i.url,"end"].join("#"),measure:i.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let i=performance.getEntriesByName(this._marks.measure);return i.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),i=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),i}},l.bv=Kc,l.bw=ta,l.bx=function(i,e,r,a,o){return le(this,void 0,void 0,(function*(){if(wi())try{return yield ca(i,e,r,a,o)}catch{}return(function(d,f,m,y,v){const S=d.width,A=d.height;vr&&Et||(vr=new OffscreenCanvas(S,A),Et=vr.getContext("2d",{willReadFrequently:!0})),vr.width=S,vr.height=A,Et.drawImage(d,0,0,S,A);const C=Et.getImageData(f,m,y,v);return Et.clearRect(0,0,S,A),C.data})(i,e,r,a,o)}))},l.by=Fp,l.bz=W,l.c=Bn,l.d=function(i,e){const r=new Image;r.onload=()=>{e(null,r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame((()=>{r.src=Oa}))},r.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const a=new Blob([new Uint8Array(i)],{type:"image/png"});r.src=i.byteLength?URL.createObjectURL(a):Oa},l.e=Ve,l.f=function(i,e){return Xr(Ve(i,{type:"json"}),e)},l.g=ar,l.h=Rn,l.i=nr,l.j=Yr,l.k=Kr,l.l=ha,l.m=Xr,l.n=function(i){return new Kc(i).readFields(p_,[])},l.o=function(i,e,r){if(!i.length)return r(null,[]);let a=i.length;const o=new Array(i.length);let d=null;i.forEach(((f,m)=>{e(f,((y,v)=>{y&&(d=y),o[m]=v,--a==0&&r(d,o)}))}))},l.p=fp,l.q=So,l.r=Wt,l.s=Dr,l.t=Ac,l.u=ze,l.v=he,l.w=Dt,l.x=us,l.y=Nr,l.z=function([i,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:i*Math.cos(e)*Math.sin(r),y:i*Math.sin(e)*Math.sin(r),z:i*Math.cos(r)}}})),Q(["./shared"],(function(l){class le{constructor(k){this.keyCache={},k&&this.replace(k)}replace(k){this._layerConfigs={},this._layers={},this.update(k,[])}update(k,M){for(const j of k){this._layerConfigs[j.id]=j;const Z=this._layers[j.id]=l.aC(j);Z._featureFilter=l.a6(Z.filter),this.keyCache[j.id]&&delete this.keyCache[j.id]}for(const j of M)delete this.keyCache[j],delete this._layerConfigs[j],delete this._layers[j];this.familiesBySource={};const R=l.bl(Object.values(this._layerConfigs),this.keyCache);for(const j of R){const Z=j.map((fe=>this._layers[fe.id])),ne=Z[0];if(ne.visibility==="none")continue;const J=ne.source||"";let X=this.familiesBySource[J];X||(X=this.familiesBySource[J]={});const ie=ne.sourceLayer||"_geojsonTileLayer";let pe=X[ie];pe||(pe=X[ie]=[]),pe.push(Z)}}}class W{constructor(k){const M={},R=[];for(const J in k){const X=k[J],ie=M[J]={};for(const pe in X){const fe=X[+pe];if(!fe||fe.bitmap.width===0||fe.bitmap.height===0)continue;const ye={x:0,y:0,w:fe.bitmap.width+2,h:fe.bitmap.height+2};R.push(ye),ie[pe]={rect:ye,metrics:fe.metrics}}}const{w:j,h:Z}=l.p(R),ne=new l.q({width:j||1,height:Z||1});for(const J in k){const X=k[J];for(const ie in X){const pe=X[+ie];if(!pe||pe.bitmap.width===0||pe.bitmap.height===0)continue;const fe=M[J][ie].rect;l.q.copy(pe.bitmap,ne,{x:0,y:0},{x:fe.x+1,y:fe.y+1},pe.bitmap)}}this.image=ne,this.positions=M}}l.bm("GlyphAtlas",W);class Se{constructor(k){this.tileID=new l.O(k.tileID.overscaledZ,k.tileID.wrap,k.tileID.canonical.z,k.tileID.canonical.x,k.tileID.canonical.y),this.uid=k.uid,this.zoom=k.zoom,this.pixelRatio=k.pixelRatio,this.tileSize=k.tileSize,this.source=k.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=k.showCollisionBoxes,this.collectResourceTiming=!!k.collectResourceTiming,this.returnDependencies=!!k.returnDependencies,this.promoteId=k.promoteId,this.inFlightDependencies=[],this.dependencySentinel=-1}parse(k,M,R,j,Z){this.status="parsing",this.data=k,this.collisionBoxArray=new l.a3;const ne=new l.bn(Object.keys(k.layers).sort()),J=new l.bo(this.tileID,this.promoteId);J.bucketLayerIDs=[];const X={},ie={featureIndex:J,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:R},pe=M.familiesBySource[this.source];for(const gt in pe){const mt=k.layers[gt];if(!mt)continue;mt.version===1&&l.w(`Vector tile source "${this.source}" layer "${gt}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const mi=ne.encode(gt),kt=[];for(let Yt=0;Yt<mt.length;Yt++){const ui=mt.feature(Yt),or=J.getId(ui,gt);kt.push({feature:ui,id:or,index:Yt,sourceLayerIndex:mi})}for(const Yt of pe[gt]){const ui=Yt[0];ui.source!==this.source&&l.w(`layer.source = ${ui.source} does not equal this.source = ${this.source}`),ui.minzoom&&this.zoom<Math.floor(ui.minzoom)||ui.maxzoom&&this.zoom>=ui.maxzoom||ui.visibility!=="none"&&(de(Yt,this.zoom,R),(X[ui.id]=ui.createBucket({index:J.bucketLayerIDs.length,layers:Yt,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:mi,sourceID:this.source})).populate(kt,ie,this.tileID.canonical),J.bucketLayerIDs.push(Yt.map((or=>or.id))))}}let fe,ye,qe,Je;const Re=l.aH(ie.glyphDependencies,(gt=>Object.keys(gt).map(Number)));this.inFlightDependencies.forEach((gt=>gt==null?void 0:gt.cancel())),this.inFlightDependencies=[];const Ge=++this.dependencySentinel;Object.keys(Re).length?this.inFlightDependencies.push(j.send("getGlyphs",{uid:this.uid,stacks:Re,source:this.source,tileID:this.tileID,type:"glyphs"},((gt,mt)=>{Ge===this.dependencySentinel&&(fe||(fe=gt,ye=mt,Tt.call(this)))}))):ye={};const tt=Object.keys(ie.iconDependencies);tt.length?this.inFlightDependencies.push(j.send("getImages",{icons:tt,source:this.source,tileID:this.tileID,type:"icons"},((gt,mt)=>{Ge===this.dependencySentinel&&(fe||(fe=gt,qe=mt,Tt.call(this)))}))):qe={};const bt=Object.keys(ie.patternDependencies);function Tt(){if(fe)return Z(fe);if(ye&&qe&&Je){const gt=new W(ye),mt=new l.bp(qe,Je);for(const mi in X){const kt=X[mi];kt instanceof l.a4?(de(kt.layers,this.zoom,R),l.bq({bucket:kt,glyphMap:ye,glyphPositions:gt.positions,imageMap:qe,imagePositions:mt.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):kt.hasPattern&&(kt instanceof l.br||kt instanceof l.bs||kt instanceof l.bt)&&(de(kt.layers,this.zoom,R),kt.addFeatures(ie,this.tileID.canonical,mt.patternPositions))}this.status="done",Z(null,{buckets:Object.values(X).filter((mi=>!mi.isEmpty())),featureIndex:J,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:gt.image,imageAtlas:mt,glyphMap:this.returnDependencies?ye:null,iconMap:this.returnDependencies?qe:null,glyphPositions:this.returnDependencies?gt.positions:null})}}bt.length?this.inFlightDependencies.push(j.send("getImages",{icons:bt,source:this.source,tileID:this.tileID,type:"patterns"},((gt,mt)=>{Ge===this.dependencySentinel&&(fe||(fe=gt,Je=mt,Tt.call(this)))}))):Je={},Tt.call(this)}}function de(U,k,M){const R=new l.a8(k);for(const j of U)j.recalculate(R,M)}function ge(U,k){const M=l.l(U.request,((R,j,Z,ne)=>{if(R)k(R);else if(j)try{const J=new l.bw.VectorTile(new l.bv(j));k(null,{vectorTile:J,rawData:j,cacheControl:Z,expires:ne})}catch(J){const X=new Uint8Array(j);let ie=`Unable to parse the tile at ${U.request.url}, `;ie+=X[0]===31&&X[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${J.messge}`,k(new Error(ie))}}));return()=>{M.cancel(),k()}}class ve{constructor(k,M,R,j){this.actor=k,this.layerIndex=M,this.availableImages=R,this.loadVectorData=j||ge,this.fetching={},this.loading={},this.loaded={}}loadTile(k,M){const R=k.uid;this.loading||(this.loading={});const j=!!(k&&k.request&&k.request.collectResourceTiming)&&new l.bu(k.request),Z=this.loading[R]=new Se(k);Z.abort=this.loadVectorData(k,((ne,J)=>{if(delete this.loading[R],ne||!J)return Z.status="done",this.loaded[R]=Z,M(ne);const X=J.rawData,ie={};J.expires&&(ie.expires=J.expires),J.cacheControl&&(ie.cacheControl=J.cacheControl);const pe={};if(j){const fe=j.finish();fe&&(pe.resourceTiming=JSON.parse(JSON.stringify(fe)))}Z.vectorTile=J.vectorTile,Z.parse(J.vectorTile,this.layerIndex,this.availableImages,this.actor,((fe,ye)=>{if(delete this.fetching[R],fe||!ye)return M(fe);M(null,l.e({rawTileData:X.slice(0)},ye,ie,pe))})),this.loaded=this.loaded||{},this.loaded[R]=Z,this.fetching[R]={rawTileData:X,cacheControl:ie,resourceTiming:pe}}))}reloadTile(k,M){const R=this.loaded,j=k.uid;if(R&&R[j]){const Z=R[j];Z.showCollisionBoxes=k.showCollisionBoxes,Z.status==="parsing"?Z.parse(Z.vectorTile,this.layerIndex,this.availableImages,this.actor,((ne,J)=>{if(ne||!J)return M(ne,J);let X;if(this.fetching[j]){const{rawTileData:ie,cacheControl:pe,resourceTiming:fe}=this.fetching[j];delete this.fetching[j],X=l.e({rawTileData:ie.slice(0)},J,pe,fe)}else X=J;M(null,X)})):Z.status==="done"&&(Z.vectorTile?Z.parse(Z.vectorTile,this.layerIndex,this.availableImages,this.actor,M):M())}}abortTile(k,M){const R=this.loading,j=k.uid;R&&R[j]&&R[j].abort&&(R[j].abort(),delete R[j]),M()}removeTile(k,M){const R=this.loaded,j=k.uid;R&&R[j]&&delete R[j],M()}}class $e{constructor(){this.loaded={}}loadTile(k,M){return l._(this,void 0,void 0,(function*(){const{uid:R,encoding:j,rawImageData:Z,redFactor:ne,greenFactor:J,blueFactor:X,baseShift:ie}=k,pe=Z.width+2,fe=Z.height+2,ye=l.a(Z)?new l.R({width:pe,height:fe},yield l.bx(Z,-1,-1,pe,fe)):Z,qe=new l.by(R,ye,j,ne,J,X,ie);this.loaded=this.loaded||{},this.loaded[R]=qe,M(null,qe)}))}removeTile(k){const M=this.loaded,R=k.uid;M&&M[R]&&delete M[R]}}function Qe(U,k){if(U.length!==0){Ke(U[0],k);for(var M=1;M<U.length;M++)Ke(U[M],!k)}}function Ke(U,k){for(var M=0,R=0,j=0,Z=U.length,ne=Z-1;j<Z;ne=j++){var J=(U[j][0]-U[ne][0])*(U[ne][1]+U[j][1]),X=M+J;R+=Math.abs(M)>=Math.abs(J)?M-X+J:J-X+M,M=X}M+R>=0!=!!k&&U.reverse()}var Ye=l.bz((function U(k,M){var R,j=k&&k.type;if(j==="FeatureCollection")for(R=0;R<k.features.length;R++)U(k.features[R],M);else if(j==="GeometryCollection")for(R=0;R<k.geometries.length;R++)U(k.geometries[R],M);else if(j==="Feature")U(k.geometry,M);else if(j==="Polygon")Qe(k.coordinates,M);else if(j==="MultiPolygon")for(R=0;R<k.coordinates.length;R++)Qe(k.coordinates[R],M);return k}));const st=l.bw.VectorTileFeature.prototype.toGeoJSON;var wi={exports:{}},Pi=l.bA,Hr=l.bw.VectorTileFeature,rr=hn;function hn(U,k){this.options=k||{},this.features=U,this.length=U.length}function Ve(U,k){this.id=typeof U.id=="number"?U.id:void 0,this.type=U.type,this.rawGeometry=U.type===1?[U.geometry]:U.geometry,this.properties=U.tags,this.extent=k||4096}hn.prototype.feature=function(U){return new Ve(this.features[U],this.options.extent)},Ve.prototype.loadGeometry=function(){var U=this.rawGeometry;this.geometry=[];for(var k=0;k<U.length;k++){for(var M=U[k],R=[],j=0;j<M.length;j++)R.push(new Pi(M[j][0],M[j][1]));this.geometry.push(R)}return this.geometry},Ve.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var U=this.geometry,k=1/0,M=-1/0,R=1/0,j=-1/0,Z=0;Z<U.length;Z++)for(var ne=U[Z],J=0;J<ne.length;J++){var X=ne[J];k=Math.min(k,X.x),M=Math.max(M,X.x),R=Math.min(R,X.y),j=Math.max(j,X.y)}return[k,R,M,j]},Ve.prototype.toGeoJSON=Hr.prototype.toGeoJSON;var it=l.bB,nt=rr;function ji(U){var k=new it;return(function(M,R){for(var j in M.layers)R.writeMessage(3,Vt,M.layers[j])})(U,k),k.finish()}function Vt(U,k){var M;k.writeVarintField(15,U.version||1),k.writeStringField(1,U.name||""),k.writeVarintField(5,U.extent||4096);var R={keys:[],values:[],keycache:{},valuecache:{}};for(M=0;M<U.length;M++)R.feature=U.feature(M),k.writeMessage(2,qi,R);var j=R.keys;for(M=0;M<j.length;M++)k.writeStringField(3,j[M]);var Z=R.values;for(M=0;M<Z.length;M++)k.writeMessage(4,pn,Z[M])}function qi(U,k){var M=U.feature;M.id!==void 0&&k.writeVarintField(1,M.id),k.writeMessage(2,Dt,U),k.writeVarintField(3,M.type),k.writeMessage(4,nr,M)}function Dt(U,k){var M=U.feature,R=U.keys,j=U.values,Z=U.keycache,ne=U.valuecache;for(var J in M.properties){var X=M.properties[J],ie=Z[J];if(X!==null){ie===void 0&&(R.push(J),Z[J]=ie=R.length-1),k.writeVarint(ie);var pe=typeof X;pe!=="string"&&pe!=="boolean"&&pe!=="number"&&(X=JSON.stringify(X));var fe=pe+":"+X,ye=ne[fe];ye===void 0&&(j.push(X),ne[fe]=ye=j.length-1),k.writeVarint(ye)}}}function Zi(U,k){return(k<<3)+(7&U)}function zr(U){return U<<1^U>>31}function nr(U,k){for(var M=U.loadGeometry(),R=U.type,j=0,Z=0,ne=M.length,J=0;J<ne;J++){var X=M[J],ie=1;R===1&&(ie=X.length),k.writeVarint(Zi(1,ie));for(var pe=R===3?X.length-1:X.length,fe=0;fe<pe;fe++){fe===1&&R!==1&&k.writeVarint(Zi(2,pe-1));var ye=X[fe].x-j,qe=X[fe].y-Z;k.writeVarint(zr(ye)),k.writeVarint(zr(qe)),j+=ye,Z+=qe}R===3&&k.writeVarint(Zi(7,1))}}function pn(U,k){var M=typeof U;M==="string"?k.writeStringField(1,U):M==="boolean"?k.writeBooleanField(7,U):M==="number"&&(U%1!=0?k.writeDoubleField(3,U):U<0?k.writeSVarintField(6,U):k.writeVarintField(5,U))}wi.exports=ji,wi.exports.fromVectorTileJs=ji,wi.exports.fromGeojsonVt=function(U,k){k=k||{};var M={};for(var R in U)M[R]=new nt(U[R].features,k),M[R].name=R,M[R].version=k.version,M[R].extent=k.extent;return ji({layers:M})},wi.exports.GeoJSONWrapper=nt;var la=l.bz(wi.exports);const Oa={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:U=>U},ca=Math.fround||(vr=new Float32Array(1),U=>(vr[0]=+U,vr[0]));var vr;const Et=3,zi=5,dn=6;class Rn{constructor(k){this.options=Object.assign(Object.create(Oa),k),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(k){const{log:M,minZoom:R,maxZoom:j}=this.options;M&&console.time("total time");const Z=`prepare ${k.length} points`;M&&console.time(Z),this.points=k;const ne=[];for(let X=0;X<k.length;X++){const ie=k[X];if(!ie.geometry)continue;const[pe,fe]=ie.geometry.coordinates,ye=ca(mr(pe)),qe=ca(ar(fe));ne.push(ye,qe,1/0,X,-1,1),this.options.reduce&&ne.push(0)}let J=this.trees[j+1]=this._createTree(ne);M&&console.timeEnd(Z);for(let X=j;X>=R;X--){const ie=+Date.now();J=this.trees[X]=this._createTree(this._cluster(J,X)),M&&console.log("z%d: %d clusters in %dms",X,J.numItems,+Date.now()-ie)}return M&&console.timeEnd("total time"),this}getClusters(k,M){let R=((k[0]+180)%360+360)%360-180;const j=Math.max(-90,Math.min(90,k[1]));let Z=k[2]===180?180:((k[2]+180)%360+360)%360-180;const ne=Math.max(-90,Math.min(90,k[3]));if(k[2]-k[0]>=360)R=-180,Z=180;else if(R>Z){const fe=this.getClusters([R,j,180,ne],M),ye=this.getClusters([-180,j,Z,ne],M);return fe.concat(ye)}const J=this.trees[this._limitZoom(M)],X=J.range(mr(R),ar(ne),mr(Z),ar(j)),ie=J.data,pe=[];for(const fe of X){const ye=this.stride*fe;pe.push(ie[ye+zi]>1?Bn(ie,ye,this.clusterProps):this.points[ie[ye+Et]])}return pe}getChildren(k){const M=this._getOriginId(k),R=this._getOriginZoom(k),j="No cluster with the specified id.",Z=this.trees[R];if(!Z)throw new Error(j);const ne=Z.data;if(M*this.stride>=ne.length)throw new Error(j);const J=this.options.radius/(this.options.extent*Math.pow(2,R-1)),X=Z.within(ne[M*this.stride],ne[M*this.stride+1],J),ie=[];for(const pe of X){const fe=pe*this.stride;ne[fe+4]===k&&ie.push(ne[fe+zi]>1?Bn(ne,fe,this.clusterProps):this.points[ne[fe+Et]])}if(ie.length===0)throw new Error(j);return ie}getLeaves(k,M,R){const j=[];return this._appendLeaves(j,k,M=M||10,R=R||0,0),j}getTile(k,M,R){const j=this.trees[this._limitZoom(k)],Z=Math.pow(2,k),{extent:ne,radius:J}=this.options,X=J/ne,ie=(R-X)/Z,pe=(R+1+X)/Z,fe={features:[]};return this._addTileFeatures(j.range((M-X)/Z,ie,(M+1+X)/Z,pe),j.data,M,R,Z,fe),M===0&&this._addTileFeatures(j.range(1-X/Z,ie,1,pe),j.data,Z,R,Z,fe),M===Z-1&&this._addTileFeatures(j.range(0,ie,X/Z,pe),j.data,-1,R,Z,fe),fe.features.length?fe:null}getClusterExpansionZoom(k){let M=this._getOriginZoom(k)-1;for(;M<=this.options.maxZoom;){const R=this.getChildren(k);if(M++,R.length!==1)break;k=R[0].properties.cluster_id}return M}_appendLeaves(k,M,R,j,Z){const ne=this.getChildren(M);for(const J of ne){const X=J.properties;if(X&&X.cluster?Z+X.point_count<=j?Z+=X.point_count:Z=this._appendLeaves(k,X.cluster_id,R,j,Z):Z<j?Z++:k.push(J),k.length===R)break}return Z}_createTree(k){const M=new l.av(k.length/this.stride|0,this.options.nodeSize,Float32Array);for(let R=0;R<k.length;R+=this.stride)M.add(k[R],k[R+1]);return M.finish(),M.data=k,M}_addTileFeatures(k,M,R,j,Z,ne){for(const J of k){const X=J*this.stride,ie=M[X+zi]>1;let pe,fe,ye;if(ie)pe=Wr(M,X,this.clusterProps),fe=M[X],ye=M[X+1];else{const Re=this.points[M[X+Et]];pe=Re.properties;const[Ge,tt]=Re.geometry.coordinates;fe=mr(Ge),ye=ar(tt)}const qe={type:1,geometry:[[Math.round(this.options.extent*(fe*Z-R)),Math.round(this.options.extent*(ye*Z-j))]],tags:pe};let Je;Je=ie||this.options.generateId?M[X+Et]:this.points[M[X+Et]].id,Je!==void 0&&(qe.id=Je),ne.features.push(qe)}}_limitZoom(k){return Math.max(this.options.minZoom,Math.min(Math.floor(+k),this.options.maxZoom+1))}_cluster(k,M){const{radius:R,extent:j,reduce:Z,minPoints:ne}=this.options,J=R/(j*Math.pow(2,M)),X=k.data,ie=[],pe=this.stride;for(let fe=0;fe<X.length;fe+=pe){if(X[fe+2]<=M)continue;X[fe+2]=M;const ye=X[fe],qe=X[fe+1],Je=k.within(X[fe],X[fe+1],J),Re=X[fe+zi];let Ge=Re;for(const tt of Je){const bt=tt*pe;X[bt+2]>M&&(Ge+=X[bt+zi])}if(Ge>Re&&Ge>=ne){let tt,bt=ye*Re,Tt=qe*Re,gt=-1;const mt=((fe/pe|0)<<5)+(M+1)+this.points.length;for(const mi of Je){const kt=mi*pe;if(X[kt+2]<=M)continue;X[kt+2]=M;const Yt=X[kt+zi];bt+=X[kt]*Yt,Tt+=X[kt+1]*Yt,X[kt+4]=mt,Z&&(tt||(tt=this._map(X,fe,!0),gt=this.clusterProps.length,this.clusterProps.push(tt)),Z(tt,this._map(X,kt)))}X[fe+4]=mt,ie.push(bt/Ge,Tt/Ge,1/0,mt,-1,Ge),Z&&ie.push(gt)}else{for(let tt=0;tt<pe;tt++)ie.push(X[fe+tt]);if(Ge>1)for(const tt of Je){const bt=tt*pe;if(!(X[bt+2]<=M)){X[bt+2]=M;for(let Tt=0;Tt<pe;Tt++)ie.push(X[bt+Tt])}}}}return ie}_getOriginId(k){return k-this.points.length>>5}_getOriginZoom(k){return(k-this.points.length)%32}_map(k,M,R){if(k[M+zi]>1){const ne=this.clusterProps[k[M+dn]];return R?Object.assign({},ne):ne}const j=this.points[k[M+Et]].properties,Z=this.options.map(j);return R&&Z===j?Object.assign({},Z):Z}}function Bn(U,k,M){return{type:"Feature",id:U[k+Et],properties:Wr(U,k,M),geometry:{type:"Point",coordinates:[(R=U[k],360*(R-.5)),ua(U[k+1])]}};var R}function Wr(U,k,M){const R=U[k+zi],j=R>=1e4?`${Math.round(R/1e3)}k`:R>=1e3?Math.round(R/100)/10+"k":R,Z=U[k+dn],ne=Z===-1?{}:Object.assign({},M[Z]);return Object.assign(ne,{cluster:!0,cluster_id:U[k+Et],point_count:R,point_count_abbreviated:j})}function mr(U){return U/360+.5}function ar(U){const k=Math.sin(U*Math.PI/180),M=.5-.25*Math.log((1+k)/(1-k))/Math.PI;return M<0?0:M>1?1:M}function ua(U){const k=(180-360*U)*Math.PI/180;return 360*Math.atan(Math.exp(k))/Math.PI-90}function Xr(U,k,M,R){for(var j,Z=R,ne=M-k>>1,J=M-k,X=U[k],ie=U[k+1],pe=U[M],fe=U[M+1],ye=k+3;ye<M;ye+=3){var qe=ha(U[ye],U[ye+1],X,ie,pe,fe);if(qe>Z)j=ye,Z=qe;else if(qe===Z){var Je=Math.abs(ye-ne);Je<J&&(j=ye,J=Je)}}Z>R&&(j-k>3&&Xr(U,k,j,R),U[j+2]=Z,M-j>3&&Xr(U,j,M,R))}function ha(U,k,M,R,j,Z){var ne=j-M,J=Z-R;if(ne!==0||J!==0){var X=((U-M)*ne+(k-R)*J)/(ne*ne+J*J);X>1?(M=j,R=Z):X>0&&(M+=ne*X,R+=J*X)}return(ne=U-M)*ne+(J=k-R)*J}function Dr(U,k,M,R){var j={id:U===void 0?null:U,type:k,geometry:M,tags:R,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return(function(Z){var ne=Z.geometry,J=Z.type;if(J==="Point"||J==="MultiPoint"||J==="LineString")On(Z,ne);else if(J==="Polygon"||J==="MultiLineString")for(var X=0;X<ne.length;X++)On(Z,ne[X]);else if(J==="MultiPolygon")for(X=0;X<ne.length;X++)for(var ie=0;ie<ne[X].length;ie++)On(Z,ne[X][ie])})(j),j}function On(U,k){for(var M=0;M<k.length;M+=3)U.minX=Math.min(U.minX,k[M]),U.minY=Math.min(U.minY,k[M+1]),U.maxX=Math.max(U.maxX,k[M]),U.maxY=Math.max(U.maxY,k[M+1])}function fn(U,k,M,R){if(k.geometry){var j=k.geometry.coordinates,Z=k.geometry.type,ne=Math.pow(M.tolerance/((1<<M.maxZoom)*M.extent),2),J=[],X=k.id;if(M.promoteId?X=k.properties[M.promoteId]:M.generateId&&(X=R||0),Z==="Point")Kr(j,J);else if(Z==="MultiPoint")for(var ie=0;ie<j.length;ie++)Kr(j[ie],J);else if(Z==="LineString")Yr(j,J,ne,!1);else if(Z==="MultiLineString"){if(M.lineMetrics){for(ie=0;ie<j.length;ie++)Yr(j[ie],J=[],ne,!1),U.push(Dr(X,"LineString",J,k.properties));return}mn(j,J,ne,!1)}else if(Z==="Polygon")mn(j,J,ne,!0);else{if(Z!=="MultiPolygon"){if(Z==="GeometryCollection"){for(ie=0;ie<k.geometry.geometries.length;ie++)fn(U,{id:X,geometry:k.geometry.geometries[ie],properties:k.properties},M,R);return}throw new Error("Input data is not a valid GeoJSON object.")}for(ie=0;ie<j.length;ie++){var pe=[];mn(j[ie],pe,ne,!0),J.push(pe)}}U.push(Dr(X,Z,J,k.properties))}}function Kr(U,k){k.push(he(U[0])),k.push(Di(U[1])),k.push(0)}function Yr(U,k,M,R){for(var j,Z,ne=0,J=0;J<U.length;J++){var X=he(U[J][0]),ie=Di(U[J][1]);k.push(X),k.push(ie),k.push(0),J>0&&(ne+=R?(j*ie-X*Z)/2:Math.sqrt(Math.pow(X-j,2)+Math.pow(ie-Z,2))),j=X,Z=ie}var pe=k.length-3;k[2]=1,Xr(k,0,pe,M),k[pe+2]=1,k.size=Math.abs(ne),k.start=0,k.end=k.size}function mn(U,k,M,R){for(var j=0;j<U.length;j++){var Z=[];Yr(U[j],Z,M,R),k.push(Z)}}function he(U){return U/360+.5}function Di(U){var k=Math.sin(U*Math.PI/180),M=.5-.25*Math.log((1+k)/(1-k))/Math.PI;return M<0?0:M>1?1:M}function sr(U,k,M,R,j,Z,ne,J){if(R/=k,Z>=(M/=k)&&ne<R)return U;if(ne<M||Z>=R)return null;for(var X=[],ie=0;ie<U.length;ie++){var pe=U[ie],fe=pe.geometry,ye=pe.type,qe=j===0?pe.minX:pe.minY,Je=j===0?pe.maxX:pe.maxY;if(qe>=M&&Je<R)X.push(pe);else if(!(Je<M||qe>=R)){var Re=[];if(ye==="Point"||ye==="MultiPoint")At(fe,Re,M,R,j);else if(ye==="LineString")_t(fe,Re,M,R,j,!1,J.lineMetrics);else if(ye==="MultiLineString")Nn(fe,Re,M,R,j,!1);else if(ye==="Polygon")Nn(fe,Re,M,R,j,!0);else if(ye==="MultiPolygon")for(var Ge=0;Ge<fe.length;Ge++){var tt=[];Nn(fe[Ge],tt,M,R,j,!0),tt.length&&Re.push(tt)}if(Re.length){if(J.lineMetrics&&ye==="LineString"){for(Ge=0;Ge<Re.length;Ge++)X.push(Dr(pe.id,ye,Re[Ge],pe.tags));continue}ye!=="LineString"&&ye!=="MultiLineString"||(Re.length===1?(ye="LineString",Re=Re[0]):ye="MultiLineString"),ye!=="Point"&&ye!=="MultiPoint"||(ye=Re.length===3?"Point":"MultiPoint"),X.push(Dr(pe.id,ye,Re,pe.tags))}}}return X.length?X:null}function At(U,k,M,R,j){for(var Z=0;Z<U.length;Z+=3){var ne=U[Z+j];ne>=M&&ne<=R&&(k.push(U[Z]),k.push(U[Z+1]),k.push(U[Z+2]))}}function _t(U,k,M,R,j,Z,ne){for(var J,X,ie=br(U),pe=j===0?Na:Vn,fe=U.start,ye=0;ye<U.length-3;ye+=3){var qe=U[ye],Je=U[ye+1],Re=U[ye+2],Ge=U[ye+3],tt=U[ye+4],bt=j===0?qe:Je,Tt=j===0?Ge:tt,gt=!1;ne&&(J=Math.sqrt(Math.pow(qe-Ge,2)+Math.pow(Je-tt,2))),bt<M?Tt>M&&(X=pe(ie,qe,Je,Ge,tt,M),ne&&(ie.start=fe+J*X)):bt>R?Tt<R&&(X=pe(ie,qe,Je,Ge,tt,R),ne&&(ie.start=fe+J*X)):Lr(ie,qe,Je,Re),Tt<M&&bt>=M&&(X=pe(ie,qe,Je,Ge,tt,M),gt=!0),Tt>R&&bt<=R&&(X=pe(ie,qe,Je,Ge,tt,R),gt=!0),!Z&&gt&&(ne&&(ie.end=fe+J*X),k.push(ie),ie=br(U)),ne&&(fe+=J)}var mt=U.length-3;qe=U[mt],Je=U[mt+1],Re=U[mt+2],(bt=j===0?qe:Je)>=M&&bt<=R&&Lr(ie,qe,Je,Re),mt=ie.length-3,Z&&mt>=3&&(ie[mt]!==ie[0]||ie[mt+1]!==ie[1])&&Lr(ie,ie[0],ie[1],ie[2]),ie.length&&k.push(ie)}function br(U){var k=[];return k.size=U.size,k.start=U.start,k.end=U.end,k}function Nn(U,k,M,R,j,Z){for(var ne=0;ne<U.length;ne++)_t(U[ne],k,M,R,j,Z,!1)}function Lr(U,k,M,R){U.push(k),U.push(M),U.push(R)}function Na(U,k,M,R,j,Z){var ne=(Z-k)/(R-k);return U.push(Z),U.push(M+(j-M)*ne),U.push(1),ne}function Vn(U,k,M,R,j,Z){var ne=(Z-M)/(j-M);return U.push(k+(R-k)*ne),U.push(Z),U.push(1),ne}function Jr(U,k){for(var M=[],R=0;R<U.length;R++){var j,Z=U[R],ne=Z.type;if(ne==="Point"||ne==="MultiPoint"||ne==="LineString")j=gn(Z.geometry,k);else if(ne==="MultiLineString"||ne==="Polygon"){j=[];for(var J=0;J<Z.geometry.length;J++)j.push(gn(Z.geometry[J],k))}else if(ne==="MultiPolygon")for(j=[],J=0;J<Z.geometry.length;J++){for(var X=[],ie=0;ie<Z.geometry[J].length;ie++)X.push(gn(Z.geometry[J][ie],k));j.push(X)}M.push(Dr(Z.id,ne,j,Z.tags))}return M}function gn(U,k){var M=[];M.size=U.size,U.start!==void 0&&(M.start=U.start,M.end=U.end);for(var R=0;R<U.length;R+=3)M.push(U[R]+k,U[R+1],U[R+2]);return M}function Ae(U,k){if(U.transformed)return U;var M,R,j,Z=1<<U.z,ne=U.x,J=U.y;for(M=0;M<U.features.length;M++){var X=U.features[M],ie=X.geometry,pe=X.type;if(X.geometry=[],pe===1)for(R=0;R<ie.length;R+=2)X.geometry.push(wr(ie[R],ie[R+1],k,Z,ne,J));else for(R=0;R<ie.length;R++){var fe=[];for(j=0;j<ie[R].length;j+=2)fe.push(wr(ie[R][j],ie[R][j+1],k,Z,ne,J));X.geometry.push(fe)}}return U.transformed=!0,U}function wr(U,k,M,R,j,Z){return[Math.round(M*(U*R-j)),Math.round(M*(k*R-Z))]}function Ut(U,k,M,R,j){for(var Z=k===j.maxZoom?0:j.tolerance/((1<<k)*j.extent),ne={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:M,y:R,z:k,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},J=0;J<U.length;J++){ne.numFeatures++,_n(ne,U[J],Z,j);var X=U[J].minX,ie=U[J].minY,pe=U[J].maxX,fe=U[J].maxY;X<ne.minX&&(ne.minX=X),ie<ne.minY&&(ne.minY=ie),pe>ne.maxX&&(ne.maxX=pe),fe>ne.maxY&&(ne.maxY=fe)}return ne}function _n(U,k,M,R){var j=k.geometry,Z=k.type,ne=[];if(Z==="Point"||Z==="MultiPoint")for(var J=0;J<j.length;J+=3)ne.push(j[J]),ne.push(j[J+1]),U.numPoints++,U.numSimplified++;else if(Z==="LineString")Fr(ne,j,U,M,!1,!1);else if(Z==="MultiLineString"||Z==="Polygon")for(J=0;J<j.length;J++)Fr(ne,j[J],U,M,Z==="Polygon",J===0);else if(Z==="MultiPolygon")for(var X=0;X<j.length;X++){var ie=j[X];for(J=0;J<ie.length;J++)Fr(ne,ie[J],U,M,!0,J===0)}if(ne.length){var pe=k.tags||null;if(Z==="LineString"&&R.lineMetrics){for(var fe in pe={},k.tags)pe[fe]=k.tags[fe];pe.mapbox_clip_start=j.start/j.size,pe.mapbox_clip_end=j.end/j.size}var ye={geometry:ne,type:Z==="Polygon"||Z==="MultiPolygon"?3:Z==="LineString"||Z==="MultiLineString"?2:1,tags:pe};k.id!==null&&(ye.id=k.id),U.features.push(ye)}}function Fr(U,k,M,R,j,Z){var ne=R*R;if(R>0&&k.size<(j?ne:R))M.numPoints+=k.length/3;else{for(var J=[],X=0;X<k.length;X+=3)(R===0||k[X+2]>ne)&&(M.numSimplified++,J.push(k[X]),J.push(k[X+1])),M.numPoints++;j&&(function(ie,pe){for(var fe=0,ye=0,qe=ie.length,Je=qe-2;ye<qe;Je=ye,ye+=2)fe+=(ie[ye]-ie[Je])*(ie[ye+1]+ie[Je+1]);if(fe>0===pe)for(ye=0,qe=ie.length;ye<qe/2;ye+=2){var Re=ie[ye],Ge=ie[ye+1];ie[ye]=ie[qe-2-ye],ie[ye+1]=ie[qe-1-ye],ie[qe-2-ye]=Re,ie[qe-1-ye]=Ge}})(J,Z),U.push(J)}}function Ce(U,k){var M=(k=this.options=(function(j,Z){for(var ne in Z)j[ne]=Z[ne];return j})(Object.create(this.options),k)).debug;if(M&&console.time("preprocess data"),k.maxZoom<0||k.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(k.promoteId&&k.generateId)throw new Error("promoteId and generateId cannot be used together.");var R=(function(j,Z){var ne=[];if(j.type==="FeatureCollection")for(var J=0;J<j.features.length;J++)fn(ne,j.features[J],Z,J);else fn(ne,j.type==="Feature"?j:{geometry:j},Z);return ne})(U,k);this.tiles={},this.tileCoords=[],M&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",k.indexMaxZoom,k.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),R=(function(j,Z){var ne=Z.buffer/Z.extent,J=j,X=sr(j,1,-1-ne,ne,0,-1,2,Z),ie=sr(j,1,1-ne,2+ne,0,-1,2,Z);return(X||ie)&&(J=sr(j,1,-ne,1+ne,0,-1,2,Z)||[],X&&(J=Jr(X,1).concat(J)),ie&&(J=J.concat(Jr(ie,-1)))),J})(R,k),R.length&&this.splitTile(R,0,0,0),M&&(R.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function ot(U,k,M){return 32*((1<<U)*M+k)+U}function et(U,k){return k?U.properties[k]:U.id}function Si(U,k){if(U==null)return!0;if(U.type==="Feature")return et(U,k)!=null;if(U.type==="FeatureCollection"){const M=new Set;for(const R of U.features){const j=et(R,k);if(j==null||M.has(j))return!1;M.add(j)}return!0}return!1}function Sr(U,k){const M=new Map;if(U!=null)if(U.type==="Feature")M.set(et(U,k),U);else for(const R of U.features)M.set(et(R,k),R);return M}Ce.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},Ce.prototype.splitTile=function(U,k,M,R,j,Z,ne){for(var J=[U,k,M,R],X=this.options,ie=X.debug;J.length;){R=J.pop(),M=J.pop(),k=J.pop(),U=J.pop();var pe=1<<k,fe=ot(k,M,R),ye=this.tiles[fe];if(!ye&&(ie>1&&console.time("creation"),ye=this.tiles[fe]=Ut(U,k,M,R,X),this.tileCoords.push({z:k,x:M,y:R}),ie)){ie>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",k,M,R,ye.numFeatures,ye.numPoints,ye.numSimplified),console.timeEnd("creation"));var qe="z"+k;this.stats[qe]=(this.stats[qe]||0)+1,this.total++}if(ye.source=U,j){if(k===X.maxZoom||k===j)continue;var Je=1<<j-k;if(M!==Math.floor(Z/Je)||R!==Math.floor(ne/Je))continue}else if(k===X.indexMaxZoom||ye.numPoints<=X.indexMaxPoints)continue;if(ye.source=null,U.length!==0){ie>1&&console.time("clipping");var Re,Ge,tt,bt,Tt,gt,mt=.5*X.buffer/X.extent,mi=.5-mt,kt=.5+mt,Yt=1+mt;Re=Ge=tt=bt=null,Tt=sr(U,pe,M-mt,M+kt,0,ye.minX,ye.maxX,X),gt=sr(U,pe,M+mi,M+Yt,0,ye.minX,ye.maxX,X),U=null,Tt&&(Re=sr(Tt,pe,R-mt,R+kt,1,ye.minY,ye.maxY,X),Ge=sr(Tt,pe,R+mi,R+Yt,1,ye.minY,ye.maxY,X),Tt=null),gt&&(tt=sr(gt,pe,R-mt,R+kt,1,ye.minY,ye.maxY,X),bt=sr(gt,pe,R+mi,R+Yt,1,ye.minY,ye.maxY,X),gt=null),ie>1&&console.timeEnd("clipping"),J.push(Re||[],k+1,2*M,2*R),J.push(Ge||[],k+1,2*M,2*R+1),J.push(tt||[],k+1,2*M+1,2*R),J.push(bt||[],k+1,2*M+1,2*R+1)}}},Ce.prototype.getTile=function(U,k,M){var R=this.options,j=R.extent,Z=R.debug;if(U<0||U>24)return null;var ne=1<<U,J=ot(U,k=(k%ne+ne)%ne,M);if(this.tiles[J])return Ae(this.tiles[J],j);Z>1&&console.log("drilling down to z%d-%d-%d",U,k,M);for(var X,ie=U,pe=k,fe=M;!X&&ie>0;)ie--,pe=Math.floor(pe/2),fe=Math.floor(fe/2),X=this.tiles[ot(ie,pe,fe)];return X&&X.source?(Z>1&&console.log("found parent tile z%d-%d-%d",ie,pe,fe),Z>1&&console.time("drilling down"),this.splitTile(X.source,ie,pe,fe,U,k,M),Z>1&&console.timeEnd("drilling down"),this.tiles[J]?Ae(this.tiles[J],j):null):null};class rt extends ve{constructor(k,M,R,j){super(k,M,R),this._dataUpdateable=new Map,this.loadGeoJSON=(Z,ne)=>{const{promoteId:J}=Z;if(Z.request)return l.f(Z.request,((X,ie,pe,fe)=>{this._dataUpdateable=Si(ie,J)?Sr(ie,J):void 0,ne(X,ie,pe,fe)}));if(typeof Z.data=="string")try{const X=JSON.parse(Z.data);this._dataUpdateable=Si(X,J)?Sr(X,J):void 0,ne(null,X)}catch{ne(new Error(`Input data given to '${Z.source}' is not a valid GeoJSON object.`))}else Z.dataDiff?this._dataUpdateable?((function(X,ie,pe){var fe,ye,qe,Je;if(ie.removeAll&&X.clear(),ie.remove)for(const Re of ie.remove)X.delete(Re);if(ie.add)for(const Re of ie.add){const Ge=et(Re,pe);Ge!=null&&X.set(Ge,Re)}if(ie.update)for(const Re of ie.update){let Ge=X.get(Re.id);if(Ge==null)continue;const tt=!Re.removeAllProperties&&(((fe=Re.removeProperties)===null||fe===void 0?void 0:fe.length)>0||((ye=Re.addOrUpdateProperties)===null||ye===void 0?void 0:ye.length)>0);if((Re.newGeometry||Re.removeAllProperties||tt)&&(Ge=Object.assign({},Ge),X.set(Re.id,Ge),tt&&(Ge.properties=Object.assign({},Ge.properties))),Re.newGeometry&&(Ge.geometry=Re.newGeometry),Re.removeAllProperties)Ge.properties={};else if(((qe=Re.removeProperties)===null||qe===void 0?void 0:qe.length)>0)for(const bt of Re.removeProperties)Object.prototype.hasOwnProperty.call(Ge.properties,bt)&&delete Ge.properties[bt];if(((Je=Re.addOrUpdateProperties)===null||Je===void 0?void 0:Je.length)>0)for(const{key:bt,value:Tt}of Re.addOrUpdateProperties)Ge.properties[bt]=Tt}})(this._dataUpdateable,Z.dataDiff,J),ne(null,{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())})):ne(new Error(`Cannot update existing geojson data in ${Z.source}`)):ne(new Error(`Input data given to '${Z.source}' is not a valid GeoJSON object.`));return{cancel:()=>{}}},this.loadVectorData=this.loadGeoJSONTile,j&&(this.loadGeoJSON=j)}loadGeoJSONTile(k,M){const R=k.tileID.canonical;if(!this._geoJSONIndex)return M(null,null);const j=this._geoJSONIndex.getTile(R.z,R.x,R.y);if(!j)return M(null,null);const Z=new class{constructor(J){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=l.N,this.length=J.length,this._features=J}feature(J){return new class{constructor(X){this._feature=X,this.extent=l.N,this.type=X.type,this.properties=X.tags,"id"in X&&!isNaN(X.id)&&(this.id=parseInt(X.id,10))}loadGeometry(){if(this._feature.type===1){const X=[];for(const ie of this._feature.geometry)X.push([new l.P(ie[0],ie[1])]);return X}{const X=[];for(const ie of this._feature.geometry){const pe=[];for(const fe of ie)pe.push(new l.P(fe[0],fe[1]));X.push(pe)}return X}}toGeoJSON(X,ie,pe){return st.call(this,X,ie,pe)}}(this._features[J])}}(j.features);let ne=la(Z);ne.byteOffset===0&&ne.byteLength===ne.buffer.byteLength||(ne=new Uint8Array(ne)),M(null,{vectorTile:Z,rawData:ne.buffer})}loadData(k,M){var R;(R=this._pendingRequest)===null||R===void 0||R.cancel(),this._pendingCallback&&this._pendingCallback(null,{abandoned:!0});const j=!!(k&&k.request&&k.request.collectResourceTiming)&&new l.bu(k.request);this._pendingCallback=M,this._pendingRequest=this.loadGeoJSON(k,((Z,ne)=>{if(delete this._pendingCallback,delete this._pendingRequest,Z||!ne)return M(Z);if(typeof ne!="object")return M(new Error(`Input data given to '${k.source}' is not a valid GeoJSON object.`));{Ye(ne,!0);try{if(k.filter){const X=l.bC(k.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(X.result==="error")throw new Error(X.value.map((pe=>`${pe.key}: ${pe.message}`)).join(", "));ne={type:"FeatureCollection",features:ne.features.filter((pe=>X.value.evaluate({zoom:0},pe)))}}this._geoJSONIndex=k.cluster?new Rn((function({superclusterOptions:X,clusterProperties:ie}){if(!ie||!X)return X;const pe={},fe={},ye={accumulated:null,zoom:0},qe={properties:null},Je=Object.keys(ie);for(const Re of Je){const[Ge,tt]=ie[Re],bt=l.bC(tt),Tt=l.bC(typeof Ge=="string"?[Ge,["accumulated"],["get",Re]]:Ge);pe[Re]=bt.value,fe[Re]=Tt.value}return X.map=Re=>{qe.properties=Re;const Ge={};for(const tt of Je)Ge[tt]=pe[tt].evaluate(ye,qe);return Ge},X.reduce=(Re,Ge)=>{qe.properties=Ge;for(const tt of Je)ye.accumulated=Re[tt],Re[tt]=fe[tt].evaluate(ye,qe)},X})(k)).load(ne.features):(function(X,ie){return new Ce(X,ie)})(ne,k.geojsonVtOptions)}catch(X){return M(X)}this.loaded={};const J={};if(j){const X=j.finish();X&&(J.resourceTiming={},J.resourceTiming[k.source]=JSON.parse(JSON.stringify(X)))}M(null,J)}}))}reloadTile(k,M){const R=this.loaded;return R&&R[k.uid]?super.reloadTile(k,M):this.loadTile(k,M)}removeSource(k,M){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),M()}getClusterExpansionZoom(k,M){try{M(null,this._geoJSONIndex.getClusterExpansionZoom(k.clusterId))}catch(R){M(R)}}getClusterChildren(k,M){try{M(null,this._geoJSONIndex.getChildren(k.clusterId))}catch(R){M(R)}}getClusterLeaves(k,M){try{M(null,this._geoJSONIndex.getLeaves(k.clusterId,k.limit,k.offset))}catch(R){M(R)}}}class Rr{constructor(k){this.self=k,this.actor=new l.C(k,this),this.layerIndexes={},this.availableImages={},this.workerSourceTypes={vector:ve,geojson:rt},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(M,R)=>{if(this.workerSourceTypes[M])throw new Error(`Worker source with name "${M}" already registered.`);this.workerSourceTypes[M]=R},this.self.registerRTLTextPlugin=M=>{if(l.bD.isParsed())throw new Error("RTL text plugin already registered.");l.bD.applyArabicShaping=M.applyArabicShaping,l.bD.processBidirectionalText=M.processBidirectionalText,l.bD.processStyledBidirectionalText=M.processStyledBidirectionalText}}setReferrer(k,M){this.referrer=M}setImages(k,M,R){this.availableImages[k]=M;for(const j in this.workerSources[k]){const Z=this.workerSources[k][j];for(const ne in Z)Z[ne].availableImages=M}R()}setLayers(k,M,R){this.getLayerIndex(k).replace(M),R()}updateLayers(k,M,R){this.getLayerIndex(k).update(M.layers,M.removedIds),R()}loadTile(k,M,R){this.getWorkerSource(k,M.type,M.source).loadTile(M,R)}loadDEMTile(k,M,R){this.getDEMWorkerSource(k,M.source).loadTile(M,R)}reloadTile(k,M,R){this.getWorkerSource(k,M.type,M.source).reloadTile(M,R)}abortTile(k,M,R){this.getWorkerSource(k,M.type,M.source).abortTile(M,R)}removeTile(k,M,R){this.getWorkerSource(k,M.type,M.source).removeTile(M,R)}removeDEMTile(k,M){this.getDEMWorkerSource(k,M.source).removeTile(M)}removeSource(k,M,R){if(!this.workerSources[k]||!this.workerSources[k][M.type]||!this.workerSources[k][M.type][M.source])return;const j=this.workerSources[k][M.type][M.source];delete this.workerSources[k][M.type][M.source],j.removeSource!==void 0?j.removeSource(M,R):R()}loadWorkerSource(k,M,R){try{this.self.importScripts(M.url),R()}catch(j){R(j.toString())}}syncRTLPluginState(k,M,R){try{l.bD.setState(M);const j=l.bD.getPluginURL();if(l.bD.isLoaded()&&!l.bD.isParsed()&&j!=null){this.self.importScripts(j);const Z=l.bD.isParsed();R(Z?void 0:new Error(`RTL Text Plugin failed to import scripts from ${j}`),Z)}}catch(j){R(j.toString())}}getAvailableImages(k){let M=this.availableImages[k];return M||(M=[]),M}getLayerIndex(k){let M=this.layerIndexes[k];return M||(M=this.layerIndexes[k]=new le),M}getWorkerSource(k,M,R){return this.workerSources[k]||(this.workerSources[k]={}),this.workerSources[k][M]||(this.workerSources[k][M]={}),this.workerSources[k][M][R]||(this.workerSources[k][M][R]=new this.workerSourceTypes[M]({send:(j,Z,ne)=>{this.actor.send(j,Z,ne,k)}},this.getLayerIndex(k),this.getAvailableImages(k))),this.workerSources[k][M][R]}getDEMWorkerSource(k,M){return this.demWorkerSources[k]||(this.demWorkerSources[k]={}),this.demWorkerSources[k][M]||(this.demWorkerSources[k][M]=new $e),this.demWorkerSources[k][M]}}return l.i()&&(self.worker=new Rr(self)),Rr})),Q(["./shared"],(function(l){var le="3.6.2";class W{static testProp(t){if(!W.docStyle)return t[0];for(let n=0;n<t.length;n++)if(t[n]in W.docStyle)return t[n];return t[0]}static create(t,n,s){const c=window.document.createElement(t);return n!==void 0&&(c.className=n),s&&s.appendChild(c),c}static createNS(t,n){return window.document.createElementNS(t,n)}static disableDrag(){W.docStyle&&W.selectProp&&(W.userSelect=W.docStyle[W.selectProp],W.docStyle[W.selectProp]="none")}static enableDrag(){W.docStyle&&W.selectProp&&(W.docStyle[W.selectProp]=W.userSelect)}static setTransform(t,n){t.style[W.transformProp]=n}static addEventListener(t,n,s,c={}){t.addEventListener(n,s,"passive"in c?c:c.capture)}static removeEventListener(t,n,s,c={}){t.removeEventListener(n,s,"passive"in c?c:c.capture)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",W.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",W.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",W.suppressClickInternal,!0)}),0)}static mousePos(t,n){const s=t.getBoundingClientRect();return new l.P(n.clientX-s.left-t.clientLeft,n.clientY-s.top-t.clientTop)}static touchPos(t,n){const s=t.getBoundingClientRect(),c=[];for(let p=0;p<n.length;p++)c.push(new l.P(n[p].clientX-s.left-t.clientLeft,n[p].clientY-s.top-t.clientTop));return c}static mouseButton(t){return t.button}static remove(t){t.parentNode&&t.parentNode.removeChild(t)}}W.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,W.selectProp=W.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),W.transformProp=W.testProp(["transform","WebkitTransform"]);const Se={supported:!1,testSupport:function(u){!ve&&ge&&($e?Qe(u):de=u)}};let de,ge,ve=!1,$e=!1;function Qe(u){const t=u.createTexture();u.bindTexture(u.TEXTURE_2D,t);try{if(u.texImage2D(u.TEXTURE_2D,0,u.RGBA,u.RGBA,u.UNSIGNED_BYTE,ge),u.isContextLost())return;Se.supported=!0}catch{}u.deleteTexture(t),ve=!0}var Ke,Ye;typeof document<"u"&&(ge=document.createElement("img"),ge.onload=function(){de&&Qe(de),de=null,$e=!0},ge.onerror=function(){ve=!0,de=null},ge.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),(function(u){let t,n,s,c;u.resetRequestQueue=()=>{t=[],n=0,s=0,c={}},u.addThrottleControl=b=>{const T=s++;return c[T]=b,T},u.removeThrottleControl=b=>{delete c[b],_()},u.getImage=(b,T,I=!0)=>{Se.supported&&(b.headers||(b.headers={}),b.headers.accept="image/webp,*/*");const P={requestParameters:b,supportImageRefresh:I,callback:T,cancelled:!1,completed:!1,cancel:()=>{P.completed||P.cancelled||(P.cancelled=!0,P.innerRequest&&(P.innerRequest.cancel(),n--),_())}};return t.push(P),_(),P};const p=b=>{const{requestParameters:T,supportImageRefresh:I,callback:P}=b;return l.e(T,{type:"image"}),(I!==!1||l.i()||l.g(T.url)||T.headers&&!Object.keys(T.headers).reduce(((V,N)=>V&&N==="accept"),!0)?l.m:x)(T,((V,N,$,B)=>{g(b,P,V,N,$,B)}))},g=(b,T,I,P,V,N)=>{I?T(I):P instanceof HTMLImageElement||l.a(P)?T(null,P):P&&(($,B)=>{typeof createImageBitmap=="function"?l.b($,B):l.d($,B)})(P,(($,B)=>{$!=null?T($):B!=null&&T(null,B,{cacheControl:V,expires:N})})),b.cancelled||(b.completed=!0,n--,_())},_=()=>{const b=(()=>{const T=Object.keys(c);let I=!1;if(T.length>0){for(const P of T)if(I=c[P](),I)break}return I})()?l.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:l.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let T=n;T<b&&t.length>0;T++){const I=t.shift();if(I.cancelled){T--;continue}const P=p(I);n++,I.innerRequest=P}},x=(b,T)=>{const I=new Image,P=b.url;let V=!1;const N=b.credentials;return N&&N==="include"?I.crossOrigin="use-credentials":(N&&N==="same-origin"||!l.s(P))&&(I.crossOrigin="anonymous"),I.fetchPriority="high",I.onload=()=>{T(null,I),I.onerror=I.onload=null},I.onerror=()=>{V||T(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.")),I.onerror=I.onload=null},I.src=P,{cancel:()=>{V=!0,I.src=""}}}})(Ke||(Ke={})),Ke.resetRequestQueue(),(function(u){u.Glyphs="Glyphs",u.Image="Image",u.Source="Source",u.SpriteImage="SpriteImage",u.SpriteJSON="SpriteJSON",u.Style="Style",u.Tile="Tile",u.Unknown="Unknown"})(Ye||(Ye={}));class st{constructor(t){this._transformRequestFn=t}transformRequest(t,n){return this._transformRequestFn&&this._transformRequestFn(t,n)||{url:t}}normalizeSpriteURL(t,n,s){const c=(function(p){const g=p.match(wi);if(!g)throw new Error(`Unable to parse URL "${p}"`);return{protocol:g[1],authority:g[2],path:g[3]||"/",params:g[4]?g[4].split("&"):[]}})(t);return c.path+=`${n}${s}`,(function(p){const g=p.params.length?`?${p.params.join("&")}`:"";return`${p.protocol}://${p.authority}${p.path}${g}`})(c)}setTransformRequest(t){this._transformRequestFn=t}}const wi=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Pi(u){var t=new l.A(3);return t[0]=u[0],t[1]=u[1],t[2]=u[2],t}var Hr,rr=function(u,t,n){return u[0]=t[0]-n[0],u[1]=t[1]-n[1],u[2]=t[2]-n[2],u};Hr=new l.A(3),l.A!=Float32Array&&(Hr[0]=0,Hr[1]=0,Hr[2]=0);var hn=function(u){var t=u[0],n=u[1];return t*t+n*n};function Ve(u){const t=[];if(typeof u=="string")t.push({id:"default",url:u});else if(u&&u.length>0){const n=[];for(const{id:s,url:c}of u){const p=`${s}${c}`;n.indexOf(p)===-1&&(n.push(p),t.push({id:s,url:c}))}}return t}function it(u,t,n,s,c){if(s)return void u(s);if(c!==Object.values(t).length||c!==Object.values(n).length)return;const p={};for(const g in t){p[g]={};const _=l.h.getImageCanvasContext(n[g]),x=t[g];for(const b in x){const{width:T,height:I,x:P,y:V,sdf:N,pixelRatio:$,stretchX:B,stretchY:ee,content:se}=x[b];p[g][b]={data:null,pixelRatio:$,sdf:N,stretchX:B,stretchY:ee,content:se,spriteData:{width:T,height:I,x:P,y:V,context:_}}}}u(null,p)}(function(){var u=new l.A(2);l.A!=Float32Array&&(u[0]=0,u[1]=0)})();class nt{constructor(t,n,s,c){this.context=t,this.format=s,this.texture=t.gl.createTexture(),this.update(n,c)}update(t,n,s){const{width:c,height:p}=t,g=!(this.size&&this.size[0]===c&&this.size[1]===p||s),{context:_}=this,{gl:x}=_;if(this.useMipmap=!!(n&&n.useMipmap),x.bindTexture(x.TEXTURE_2D,this.texture),_.pixelStoreUnpackFlipY.set(!1),_.pixelStoreUnpack.set(1),_.pixelStoreUnpackPremultiplyAlpha.set(this.format===x.RGBA&&(!n||n.premultiply!==!1)),g)this.size=[c,p],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||l.a(t)?x.texImage2D(x.TEXTURE_2D,0,this.format,this.format,x.UNSIGNED_BYTE,t):x.texImage2D(x.TEXTURE_2D,0,this.format,c,p,0,this.format,x.UNSIGNED_BYTE,t.data);else{const{x:b,y:T}=s||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||l.a(t)?x.texSubImage2D(x.TEXTURE_2D,0,b,T,x.RGBA,x.UNSIGNED_BYTE,t):x.texSubImage2D(x.TEXTURE_2D,0,b,T,c,p,x.RGBA,x.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&x.generateMipmap(x.TEXTURE_2D)}bind(t,n,s){const{context:c}=this,{gl:p}=c;p.bindTexture(p.TEXTURE_2D,this.texture),s!==p.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(s=p.LINEAR),t!==this.filter&&(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,t),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,s||t),this.filter=t),n!==this.wrap&&(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,n),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,n),this.wrap=n)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}function ji(u){const{userImage:t}=u;return!!(t&&t.render&&t.render())&&(u.data.replace(new Uint8Array(t.data.buffer)),!0)}class Vt extends l.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new l.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:n,callback:s}of this.requestors)this._notify(n,s);this.requestors=[]}}getImage(t){const n=this.images[t];if(n&&!n.data&&n.spriteData){const s=n.spriteData;n.data=new l.R({width:s.width,height:s.height},s.context.getImageData(s.x,s.y,s.width,s.height).data),n.spriteData=null}return n}addImage(t,n){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,n)&&(this.images[t]=n)}_validate(t,n){let s=!0;const c=n.data||n.spriteData;return this._validateStretch(n.stretchX,c&&c.width)||(this.fire(new l.j(new Error(`Image "${t}" has invalid "stretchX" value`))),s=!1),this._validateStretch(n.stretchY,c&&c.height)||(this.fire(new l.j(new Error(`Image "${t}" has invalid "stretchY" value`))),s=!1),this._validateContent(n.content,n)||(this.fire(new l.j(new Error(`Image "${t}" has invalid "content" value`))),s=!1),s}_validateStretch(t,n){if(!t)return!0;let s=0;for(const c of t){if(c[0]<s||c[1]<c[0]||n<c[1])return!1;s=c[1]}return!0}_validateContent(t,n){if(!t)return!0;if(t.length!==4)return!1;const s=n.spriteData,c=s&&s.width||n.data.width,p=s&&s.height||n.data.height;return!(t[0]<0||c<t[0]||t[1]<0||p<t[1]||t[2]<0||c<t[2]||t[3]<0||p<t[3]||t[2]<t[0]||t[3]<t[1])}updateImage(t,n,s=!0){const c=this.getImage(t);if(s&&(c.data.width!==n.data.width||c.data.height!==n.data.height))throw new Error(`size mismatch between old image (${c.data.width}x${c.data.height}) and new image (${n.data.width}x${n.data.height}).`);n.version=c.version+1,this.images[t]=n,this.updatedImages[t]=!0}removeImage(t){const n=this.images[t];delete this.images[t],delete this.patterns[t],n.userImage&&n.userImage.onRemove&&n.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t,n){let s=!0;if(!this.isLoaded())for(const c of t)this.images[c]||(s=!1);this.isLoaded()||s?this._notify(t,n):this.requestors.push({ids:t,callback:n})}_notify(t,n){const s={};for(const c of t){let p=this.getImage(c);p||(this.fire(new l.k("styleimagemissing",{id:c})),p=this.getImage(c)),p?s[c]={data:p.data.clone(),pixelRatio:p.pixelRatio,sdf:p.sdf,version:p.version,stretchX:p.stretchX,stretchY:p.stretchY,content:p.content,hasRenderCallback:!!(p.userImage&&p.userImage.render)}:l.w(`Image "${c}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}n(null,s)}getPixelSize(){const{width:t,height:n}=this.atlasImage;return{width:t,height:n}}getPattern(t){const n=this.patterns[t],s=this.getImage(t);if(!s)return null;if(n&&n.position.version===s.version)return n.position;if(n)n.position.version=s.version;else{const c={w:s.data.width+2,h:s.data.height+2,x:0,y:0},p=new l.I(c,s);this.patterns[t]={bin:c,position:p}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const n=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new nt(t,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const p in this.patterns)t.push(this.patterns[p].bin);const{w:n,h:s}=l.p(t),c=this.atlasImage;c.resize({width:n||1,height:s||1});for(const p in this.patterns){const{bin:g}=this.patterns[p],_=g.x+1,x=g.y+1,b=this.getImage(p).data,T=b.width,I=b.height;l.R.copy(b,c,{x:0,y:0},{x:_,y:x},{width:T,height:I}),l.R.copy(b,c,{x:0,y:I-1},{x:_,y:x-1},{width:T,height:1}),l.R.copy(b,c,{x:0,y:0},{x:_,y:x+I},{width:T,height:1}),l.R.copy(b,c,{x:T-1,y:0},{x:_-1,y:x},{width:1,height:I}),l.R.copy(b,c,{x:0,y:0},{x:_+T,y:x},{width:1,height:I})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const n of t){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;const s=this.getImage(n);s||l.w(`Image with ID: "${n}" was not found`),ji(s)&&this.updateImage(n,s)}}}const qi=1e20;function Dt(u,t,n,s,c,p,g,_,x){for(let b=t;b<t+s;b++)Zi(u,n*p+b,p,c,g,_,x);for(let b=n;b<n+c;b++)Zi(u,b*p+t,1,s,g,_,x)}function Zi(u,t,n,s,c,p,g){p[0]=0,g[0]=-qi,g[1]=qi,c[0]=u[t];for(let _=1,x=0,b=0;_<s;_++){c[_]=u[t+_*n];const T=_*_;do{const I=p[x];b=(c[_]-c[I]+T-I*I)/(_-I)/2}while(b<=g[x]&&--x>-1);x++,p[x]=_,g[x]=b,g[x+1]=qi}for(let _=0,x=0;_<s;_++){for(;g[x+1]<_;)x++;const b=p[x],T=_-b;u[t+_*n]=c[b]+T*T}}class zr{constructor(t,n){this.requestManager=t,this.localIdeographFontFamily=n,this.entries={}}setURL(t){this.url=t}getGlyphs(t,n){const s=[];for(const c in t)for(const p of t[c])s.push({stack:c,id:p});l.o(s,(({stack:c,id:p},g)=>{let _=this.entries[c];_||(_=this.entries[c]={glyphs:{},requests:{},ranges:{}});let x=_.glyphs[p];if(x!==void 0)return void g(null,{stack:c,id:p,glyph:x});if(x=this._tinySDF(_,c,p),x)return _.glyphs[p]=x,void g(null,{stack:c,id:p,glyph:x});const b=Math.floor(p/256);if(256*b>65535)return void g(new Error("glyphs > 65535 not supported"));if(_.ranges[b])return void g(null,{stack:c,id:p,glyph:x});if(!this.url)return void g(new Error("glyphsUrl is not set"));let T=_.requests[b];T||(T=_.requests[b]=[],zr.loadGlyphRange(c,b,this.url,this.requestManager,((I,P)=>{if(P){for(const V in P)this._doesCharSupportLocalGlyph(+V)||(_.glyphs[+V]=P[+V]);_.ranges[b]=!0}for(const V of T)V(I,P);delete _.requests[b]}))),T.push(((I,P)=>{I?g(I):P&&g(null,{stack:c,id:p,glyph:P[p]||null})}))}),((c,p)=>{if(c)n(c);else if(p){const g={};for(const{stack:_,id:x,glyph:b}of p)(g[_]||(g[_]={}))[x]=b&&{id:b.id,bitmap:b.bitmap.clone(),metrics:b.metrics};n(null,g)}}))}_doesCharSupportLocalGlyph(t){return!!this.localIdeographFontFamily&&(l.u["CJK Unified Ideographs"](t)||l.u["Hangul Syllables"](t)||l.u.Hiragana(t)||l.u.Katakana(t))}_tinySDF(t,n,s){const c=this.localIdeographFontFamily;if(!c||!this._doesCharSupportLocalGlyph(s))return;let p=t.tinySDF;if(!p){let _="400";/bold/i.test(n)?_="900":/medium/i.test(n)?_="500":/light/i.test(n)&&(_="200"),p=t.tinySDF=new zr.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:c,fontWeight:_})}const g=p.draw(String.fromCharCode(s));return{id:s,bitmap:new l.q({width:g.width||60,height:g.height||60},g.data),metrics:{width:g.glyphWidth/2||24,height:g.glyphHeight/2||24,left:g.glyphLeft/2+.5||0,top:g.glyphTop/2-27.5||-8,advance:g.glyphAdvance/2||24,isDoubleResolution:!0}}}}zr.loadGlyphRange=function(u,t,n,s,c){const p=256*t,g=p+255,_=s.transformRequest(n.replace("{fontstack}",u).replace("{range}",`${p}-${g}`),Ye.Glyphs);l.l(_,((x,b)=>{if(x)c(x);else if(b){const T={};for(const I of l.n(b))T[I.id]=I;c(null,T)}}))},zr.TinySDF=class{constructor({fontSize:u=24,buffer:t=3,radius:n=8,cutoff:s=.25,fontFamily:c="sans-serif",fontWeight:p="normal",fontStyle:g="normal"}={}){this.buffer=t,this.cutoff=s,this.radius=n;const _=this.size=u+4*t,x=this._createCanvas(_),b=this.ctx=x.getContext("2d",{willReadFrequently:!0});b.font=`${g} ${p} ${u}px ${c}`,b.textBaseline="alphabetic",b.textAlign="left",b.fillStyle="black",this.gridOuter=new Float64Array(_*_),this.gridInner=new Float64Array(_*_),this.f=new Float64Array(_),this.z=new Float64Array(_+1),this.v=new Uint16Array(_)}_createCanvas(u){const t=document.createElement("canvas");return t.width=t.height=u,t}draw(u){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:s,actualBoundingBoxLeft:c,actualBoundingBoxRight:p}=this.ctx.measureText(u),g=Math.ceil(n),_=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(p-c))),x=Math.min(this.size-this.buffer,g+Math.ceil(s)),b=_+2*this.buffer,T=x+2*this.buffer,I=Math.max(b*T,0),P=new Uint8ClampedArray(I),V={data:P,width:b,height:T,glyphWidth:_,glyphHeight:x,glyphTop:g,glyphLeft:0,glyphAdvance:t};if(_===0||x===0)return V;const{ctx:N,buffer:$,gridInner:B,gridOuter:ee}=this;N.clearRect($,$,_,x),N.fillText(u,$,$+g);const se=N.getImageData($,$,_,x);ee.fill(qi,0,I),B.fill(0,0,I);for(let G=0;G<x;G++)for(let te=0;te<_;te++){const ce=se.data[4*(G*_+te)+3]/255;if(ce===0)continue;const ue=(G+$)*b+te+$;if(ce===1)ee[ue]=0,B[ue]=qi;else{const me=.5-ce;ee[ue]=me>0?me*me:0,B[ue]=me<0?me*me:0}}Dt(ee,0,0,b,T,b,this.f,this.v,this.z),Dt(B,$,$,_,x,b,this.f,this.v,this.z);for(let G=0;G<I;G++){const te=Math.sqrt(ee[G])-Math.sqrt(B[G]);P[G]=Math.round(255-255*(te/this.radius+this.cutoff))}return V}};class nr{constructor(){this.specification=l.v.light.position}possiblyEvaluate(t,n){return l.z(t.expression.evaluate(n))}interpolate(t,n,s){return{x:l.B.number(t.x,n.x,s),y:l.B.number(t.y,n.y,s),z:l.B.number(t.z,n.z,s)}}}let pn;class la extends l.E{constructor(t){super(),pn=pn||new l.r({anchor:new l.D(l.v.light.anchor),position:new nr,color:new l.D(l.v.light.color),intensity:new l.D(l.v.light.intensity)}),this._transitionable=new l.T(pn),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,n={}){if(!this._validate(l.t,t,n))for(const s in t){const c=t[s];s.endsWith("-transition")?this._transitionable.setTransition(s.slice(0,-11),c):this._transitionable.setValue(s,c)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,n,s){return(!s||s.validate!==!1)&&l.x(this,t.call(l.y,l.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:l.v})))}}class Oa{constructor(t,n){this.width=t,this.height=n,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,n){const s=t.join(",")+String(n);return this.dashEntry[s]||(this.dashEntry[s]=this.addDash(t,n)),this.dashEntry[s]}getDashRanges(t,n,s){const c=[];let p=t.length%2==1?-t[t.length-1]*s:0,g=t[0]*s,_=!0;c.push({left:p,right:g,isDash:_,zeroLength:t[0]===0});let x=t[0];for(let b=1;b<t.length;b++){_=!_;const T=t[b];p=x*s,x+=T,g=x*s,c.push({left:p,right:g,isDash:_,zeroLength:T===0})}return c}addRoundDash(t,n,s){const c=n/2;for(let p=-s;p<=s;p++){const g=this.width*(this.nextRow+s+p);let _=0,x=t[_];for(let b=0;b<this.width;b++){b/x.right>1&&(x=t[++_]);const T=Math.abs(b-x.left),I=Math.abs(b-x.right),P=Math.min(T,I);let V;const N=p/s*(c+1);if(x.isDash){const $=c-Math.abs(N);V=Math.sqrt(P*P+$*$)}else V=c-Math.sqrt(P*P+N*N);this.data[g+b]=Math.max(0,Math.min(255,V+128))}}}addRegularDash(t){for(let _=t.length-1;_>=0;--_){const x=t[_],b=t[_+1];x.zeroLength?t.splice(_,1):b&&b.isDash===x.isDash&&(b.left=x.left,t.splice(_,1))}const n=t[0],s=t[t.length-1];n.isDash===s.isDash&&(n.left=s.left-this.width,s.right=n.right+this.width);const c=this.width*this.nextRow;let p=0,g=t[p];for(let _=0;_<this.width;_++){_/g.right>1&&(g=t[++p]);const x=Math.abs(_-g.left),b=Math.abs(_-g.right),T=Math.min(x,b);this.data[c+_]=Math.max(0,Math.min(255,(g.isDash?T:-T)+128))}}addDash(t,n){const s=n?7:0,c=2*s+1;if(this.nextRow+c>this.height)return l.w("LineAtlas out of space"),null;let p=0;for(let _=0;_<t.length;_++)p+=t[_];if(p!==0){const _=this.width/p,x=this.getDashRanges(t,this.width,_);n?this.addRoundDash(x,_,s):this.addRegularDash(x)}const g={y:(this.nextRow+s+.5)/this.height,height:2*s/this.height,width:p};return this.nextRow+=c,this.dirty=!0,g}bind(t){const n=t.gl;this.texture?(n.bindTexture(n.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,n.texSubImage2D(n.TEXTURE_2D,0,0,0,this.width,this.height,n.ALPHA,n.UNSIGNED_BYTE,this.data))):(this.texture=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this.texture),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texImage2D(n.TEXTURE_2D,0,n.ALPHA,this.width,this.height,0,n.ALPHA,n.UNSIGNED_BYTE,this.data))}}class ca{constructor(t,n,s){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=s;const c=this.workerPool.acquire(s);for(let p=0;p<c.length;p++){const g=new l.C(c[p],n,s);g.name=`Worker ${p}`,this.actors.push(g)}if(!this.actors.length)throw new Error("No actors found")}broadcast(t,n,s){l.o(this.actors,((c,p)=>{c.send(t,n,p)}),s=s||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.actors.forEach((n=>{n.remove()})),this.actors=[],t&&this.workerPool.release(this.id)}}function vr(u,t,n){const s=function(c,p){if(c)return n(c);if(p){const g=l.F(l.e(p,u),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);p.vector_layers&&(g.vectorLayers=p.vector_layers,g.vectorLayerIds=g.vectorLayers.map((_=>_.id))),n(null,g)}};return u.url?l.f(t.transformRequest(u.url,Ye.Source),s):l.h.frame((()=>s(null,u)))}class Et{constructor(t,n){t&&(n?this.setSouthWest(t).setNorthEast(n):Array.isArray(t)&&(t.length===4?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof l.L?new l.L(t.lng,t.lat):l.L.convert(t),this}setSouthWest(t){return this._sw=t instanceof l.L?new l.L(t.lng,t.lat):l.L.convert(t),this}extend(t){const n=this._sw,s=this._ne;let c,p;if(t instanceof l.L)c=t,p=t;else{if(!(t instanceof Et))return Array.isArray(t)?t.length===4||t.every(Array.isArray)?this.extend(Et.convert(t)):this.extend(l.L.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(l.L.convert(t)):this;if(c=t._sw,p=t._ne,!c||!p)return this}return n||s?(n.lng=Math.min(c.lng,n.lng),n.lat=Math.min(c.lat,n.lat),s.lng=Math.max(p.lng,s.lng),s.lat=Math.max(p.lat,s.lat)):(this._sw=new l.L(c.lng,c.lat),this._ne=new l.L(p.lng,p.lat)),this}getCenter(){return new l.L((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new l.L(this.getWest(),this.getNorth())}getSouthEast(){return new l.L(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:n,lat:s}=l.L.convert(t);let c=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(c=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=s&&s<=this._ne.lat&&c}static convert(t){return t instanceof Et?t:t&&new Et(t)}static fromLngLat(t,n=0){const s=360*n/40075017,c=s/Math.cos(Math.PI/180*t.lat);return new Et(new l.L(t.lng-c,t.lat-s),new l.L(t.lng+c,t.lat+s))}}class zi{constructor(t,n,s){this.bounds=Et.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=s||24}validateBounds(t){return Array.isArray(t)&&t.length===4?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const n=Math.pow(2,t.z),s=Math.floor(l.G(this.bounds.getWest())*n),c=Math.floor(l.H(this.bounds.getNorth())*n),p=Math.ceil(l.G(this.bounds.getEast())*n),g=Math.ceil(l.H(this.bounds.getSouth())*n);return t.x>=s&&t.x<p&&t.y>=c&&t.y<g}}class dn extends l.E{constructor(t,n,s,c){if(super(),this.load=()=>{this._loaded=!1,this.fire(new l.k("dataloading",{dataType:"source"})),this._tileJSONRequest=vr(this._options,this.map._requestManager,((p,g)=>{this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),p?this.fire(new l.j(p)):g&&(l.e(this,g),g.bounds&&(this.tileBounds=new zi(g.bounds,this.minzoom,this.maxzoom)),this.fire(new l.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new l.k("data",{dataType:"source",sourceDataType:"content"})))}))},this.serialize=()=>l.e({},this._options),this.id=t,this.dispatcher=s,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,l.e(this,l.F(n,["url","scheme","tileSize","promoteId"])),this._options=l.e({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(c)}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.load()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}loadTile(t,n){const s=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),c={request:this.map._requestManager.transformRequest(s,Ye.Tile),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};function p(g,_){return delete t.request,t.aborted?n(null):g&&g.status!==404?n(g):(_&&_.resourceTiming&&(t.resourceTiming=_.resourceTiming),this.map._refreshExpiredTiles&&_&&t.setExpiryData(_),t.loadVectorData(_,this.map.painter),n(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}c.request.collectResourceTiming=this._collectResourceTiming,t.actor&&t.state!=="expired"?t.state==="loading"?t.reloadCallback=n:t.request=t.actor.send("reloadTile",c,p.bind(this)):(t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",c,p.bind(this)))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id},void 0)}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id},void 0)}hasTransition(){return!1}}class Rn extends l.E{constructor(t,n,s,c){super(),this.id=t,this.dispatcher=s,this.setEventedParent(c),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=l.e({type:"raster"},n),l.e(this,l.F(n,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new l.k("dataloading",{dataType:"source"})),this._tileJSONRequest=vr(this._options,this.map._requestManager,((t,n)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new l.j(t)):n&&(l.e(this,n),n.bounds&&(this.tileBounds=new zi(n.bounds,this.minzoom,this.maxzoom)),this.fire(new l.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new l.k("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.load()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}serialize(){return l.e({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t,n){const s=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.request=Ke.getImage(this.map._requestManager.transformRequest(s,Ye.Tile),((c,p,g)=>{if(delete t.request,t.aborted)t.state="unloaded",n(null);else if(c)t.state="errored",n(c);else if(p){this.map._refreshExpiredTiles&&g&&t.setExpiryData(g);const _=this.map.painter.context,x=_.gl;t.texture=this.map.painter.getTileTexture(p.width),t.texture?t.texture.update(p,{useMipmap:!0}):(t.texture=new nt(_,p,x.RGBA,{useMipmap:!0}),t.texture.bind(x.LINEAR,x.CLAMP_TO_EDGE,x.LINEAR_MIPMAP_NEAREST),_.extTextureFilterAnisotropic&&x.texParameterf(x.TEXTURE_2D,_.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,_.extTextureFilterAnisotropicMax)),t.state="loaded",n(null)}}),this.map._refreshExpiredTiles)}abortTile(t,n){t.request&&(t.request.cancel(),delete t.request),n()}unloadTile(t,n){t.texture&&this.map.painter.saveTileTexture(t.texture),n()}hasTransition(){return!1}}class Bn extends Rn{constructor(t,n,s,c){super(t,n,s,c),this.type="raster-dem",this.maxzoom=22,this._options=l.e({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox",this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(t,n){const s=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),c=this.map._requestManager.transformRequest(s,Ye.Tile);function p(g,_){g&&(t.state="errored",n(g)),_&&(t.dem=_,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded",n(null))}t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.request=Ke.getImage(c,((g,_,x)=>l._(this,void 0,void 0,(function*(){if(delete t.request,t.aborted)t.state="unloaded",n(null);else if(g)t.state="errored",n(g);else if(_){this.map._refreshExpiredTiles&&t.setExpiryData(x);const b=l.a(_)&&l.J()?_:yield(function(I){return l._(this,void 0,void 0,(function*(){if(typeof VideoFrame<"u"&&l.K()){const P=I.width+2,V=I.height+2;try{return new l.R({width:P,height:V},yield l.M(I,-1,-1,P,V))}catch{}}return l.h.getImageData(I,1)}))})(_),T={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:b,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};t.actor&&t.state!=="expired"||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",T,p))}}))),this.map._refreshExpiredTiles)}_getNeighboringTiles(t){const n=t.canonical,s=Math.pow(2,n.z),c=(n.x-1+s)%s,p=n.x===0?t.wrap-1:t.wrap,g=(n.x+1+s)%s,_=n.x+1===s?t.wrap+1:t.wrap,x={};return x[new l.O(t.overscaledZ,p,n.z,c,n.y).key]={backfilled:!1},x[new l.O(t.overscaledZ,_,n.z,g,n.y).key]={backfilled:!1},n.y>0&&(x[new l.O(t.overscaledZ,p,n.z,c,n.y-1).key]={backfilled:!1},x[new l.O(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},x[new l.O(t.overscaledZ,_,n.z,g,n.y-1).key]={backfilled:!1}),n.y+1<s&&(x[new l.O(t.overscaledZ,p,n.z,c,n.y+1).key]={backfilled:!1},x[new l.O(t.overscaledZ,t.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},x[new l.O(t.overscaledZ,_,n.z,g,n.y+1).key]={backfilled:!1}),x}unloadTile(t){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded",t.actor&&t.actor.send("removeDEMTile",{uid:t.uid,source:this.id})}}class Wr extends l.E{constructor(t,n,s,c){super(),this.load=()=>{this._updateWorkerData()},this.serialize=()=>l.e({},this._options,{type:this.type,data:this._data}),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._pendingLoads=0,this.actor=s.getActor(),this.setEventedParent(c),this._data=n.data,this._options=l.e({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId;const p=l.N/this.tileSize;this.workerOptions=l.e({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:(n.buffer!==void 0?n.buffer:128)*p,tolerance:(n.tolerance!==void 0?n.tolerance:.375)*p,extent:l.N,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1},superclusterOptions:{maxZoom:n.clusterMaxZoom!==void 0?n.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,n.clusterMinPoints||2),extent:l.N,radius:(n.clusterRadius||50)*p,log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}onAdd(t){this.map=t,this.load()}setData(t){return this._data=t,this._updateWorkerData(),this}updateData(t){return this._updateWorkerData(t),this}setClusterOptions(t){return this.workerOptions.cluster=t.cluster,t&&(t.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=t.clusterRadius),t.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=t.clusterMaxZoom)),this._updateWorkerData(),this}getClusterExpansionZoom(t,n){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},n),this}getClusterChildren(t,n){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},n),this}getClusterLeaves(t,n,s,c){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:n,offset:s},c),this}_updateWorkerData(t){const n=l.e({},this.workerOptions);t?n.dataDiff=t:typeof this._data=="string"?(n.request=this.map._requestManager.transformRequest(l.h.resolveURL(this._data),Ye.Source),n.request.collectResourceTiming=this._collectResourceTiming):n.data=JSON.stringify(this._data),this._pendingLoads++,this.fire(new l.k("dataloading",{dataType:"source"})),this.actor.send(`${this.type}.loadData`,n,((s,c)=>{if(this._pendingLoads--,this._removed||c&&c.abandoned)return void this.fire(new l.k("dataabort",{dataType:"source"}));let p=null;if(c&&c.resourceTiming&&c.resourceTiming[this.id]&&(p=c.resourceTiming[this.id].slice(0)),s)return void this.fire(new l.j(s));const g={dataType:"source"};this._collectResourceTiming&&p&&p.length>0&&l.e(g,{resourceTiming:p}),this.fire(new l.k("data",Object.assign(Object.assign({},g),{sourceDataType:"metadata"}))),this.fire(new l.k("data",Object.assign(Object.assign({},g),{sourceDataType:"content"})))}))}loaded(){return this._pendingLoads===0}loadTile(t,n){const s=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const c={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};t.request=this.actor.send(s,c,((p,g)=>(delete t.request,t.unloadVectorData(),t.aborted?n(null):p?n(p):(t.loadVectorData(g,this.map.painter,s==="reloadTile"),n(null)))))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._removed=!0,this.actor.send("removeSource",{type:this.type,source:this.id})}hasTransition(){return!1}}var mr=l.Q([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class ar extends l.E{constructor(t,n,s,c){super(),this.load=(p,g)=>{this._loaded=!1,this.fire(new l.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=Ke.getImage(this.map._requestManager.transformRequest(this.url,Ye.Image),((_,x)=>{this._request=null,this._loaded=!0,_?this.fire(new l.j(_)):x&&(this.image=x,p&&(this.coordinates=p),g&&g(),this._finishLoading())}))},this.prepare=()=>{if(Object.keys(this.tiles).length===0||!this.image)return;const p=this.map.painter.context,g=p.gl;this.boundsBuffer||(this.boundsBuffer=p.createVertexBuffer(this._boundsArray,mr.members)),this.boundsSegments||(this.boundsSegments=l.S.simpleSegment(0,0,4,2)),this.texture||(this.texture=new nt(p,this.image,g.RGBA),this.texture.bind(g.LINEAR,g.CLAMP_TO_EDGE));let _=!1;for(const x in this.tiles){const b=this.tiles[x];b.state!=="loaded"&&(b.state="loaded",b.texture=this.texture,_=!0)}_&&this.fire(new l.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))},this.serialize=()=>({type:"image",url:this.options.url,coordinates:this.coordinates}),this.id=t,this.dispatcher=s,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(c),this.options=n}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.cancel(),this._request=null),this.options.url=t.url,this.load(t.coordinates,(()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new l.k("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.cancel(),this._request=null)}setCoordinates(t){this.coordinates=t;const n=t.map(l.U.fromLngLat);this.tileID=(function(c){let p=1/0,g=1/0,_=-1/0,x=-1/0;for(const P of c)p=Math.min(p,P.x),g=Math.min(g,P.y),_=Math.max(_,P.x),x=Math.max(x,P.y);const b=Math.max(_-p,x-g),T=Math.max(0,Math.floor(-Math.log(b)/Math.LN2)),I=Math.pow(2,T);return new l.W(T,Math.floor((p+_)/2*I),Math.floor((g+x)/2*I))})(n),this.minzoom=this.maxzoom=this.tileID.z;const s=n.map((c=>this.tileID.getTilePoint(c)._round()));return this._boundsArray=new l.V,this._boundsArray.emplaceBack(s[0].x,s[0].y,0,0),this._boundsArray.emplaceBack(s[1].x,s[1].y,l.N,0),this._boundsArray.emplaceBack(s[3].x,s[3].y,0,l.N),this._boundsArray.emplaceBack(s[2].x,s[2].y,l.N,l.N),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new l.k("data",{dataType:"source",sourceDataType:"content"})),this}loadTile(t,n){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},n(null)):(t.state="errored",n(null))}hasTransition(){return!1}}class ua extends ar{constructor(t,n,s,c){super(t,n,s,c),this.load=()=>{this._loaded=!1;const p=this.options;this.urls=[];for(const g of p.urls)this.urls.push(this.map._requestManager.transformRequest(g,Ye.Source).url);l.X(this.urls,((g,_)=>{this._loaded=!0,g?this.fire(new l.j(g)):_&&(this.video=_,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading())}))},this.prepare=()=>{if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const p=this.map.painter.context,g=p.gl;this.boundsBuffer||(this.boundsBuffer=p.createVertexBuffer(this._boundsArray,mr.members)),this.boundsSegments||(this.boundsSegments=l.S.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(g.LINEAR,g.CLAMP_TO_EDGE),g.texSubImage2D(g.TEXTURE_2D,0,0,0,g.RGBA,g.UNSIGNED_BYTE,this.video)):(this.texture=new nt(p,this.video,g.RGBA),this.texture.bind(g.LINEAR,g.CLAMP_TO_EDGE));let _=!1;for(const x in this.tiles){const b=this.tiles[x];b.state!=="loaded"&&(b.state="loaded",b.texture=this.texture,_=!0)}_&&this.fire(new l.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))},this.serialize=()=>({type:"video",urls:this.urls,coordinates:this.coordinates}),this.roundZoom=!0,this.type="video",this.options=n}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const n=this.video.seekable;t<n.start(0)||t>n.end(0)?this.fire(new l.j(new l.Y(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}hasTransition(){return this.video&&!this.video.paused}}class Xr extends ar{constructor(t,n,s,c){super(t,n,s,c),this.load=()=>{this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new l.j(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())},this.prepare=()=>{let p=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,p=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,p=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const g=this.map.painter.context,_=g.gl;this.boundsBuffer||(this.boundsBuffer=g.createVertexBuffer(this._boundsArray,mr.members)),this.boundsSegments||(this.boundsSegments=l.S.simpleSegment(0,0,4,2)),this.texture?(p||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new nt(g,this.canvas,_.RGBA,{premultiply:!0});let x=!1;for(const b in this.tiles){const T=this.tiles[b];T.state!=="loaded"&&(T.state="loaded",T.texture=this.texture,x=!0)}x&&this.fire(new l.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))},this.serialize=()=>({type:"canvas",coordinates:this.coordinates}),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some((p=>!Array.isArray(p)||p.length!==2||p.some((g=>typeof g!="number"))))||this.fire(new l.j(new l.Y(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new l.j(new l.Y(`sources.${t}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new l.j(new l.Y(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new l.j(new l.Y(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new l.j(new l.Y(`sources.${t}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const ha={},Dr=u=>{switch(u){case"geojson":return Wr;case"image":return ar;case"raster":return Rn;case"raster-dem":return Bn;case"vector":return dn;case"video":return ua;case"canvas":return Xr}return ha[u]};function On(u,t){const n=l.Z();return l.$(n,n,[1,1,0]),l.a0(n,n,[.5*u.width,.5*u.height,1]),l.a1(n,n,u.calculatePosMatrix(t.toUnwrapped()))}function fn(u,t,n,s,c,p){const g=(function(I,P,V){if(I)for(const N of I){const $=P[N];if($&&$.source===V&&$.type==="fill-extrusion")return!0}else for(const N in P){const $=P[N];if($.source===V&&$.type==="fill-extrusion")return!0}return!1})(c&&c.layers,t,u.id),_=p.maxPitchScaleFactor(),x=u.tilesIn(s,_,g);x.sort(Kr);const b=[];for(const I of x)b.push({wrappedTileID:I.tileID.wrapped().key,queryResults:I.tile.queryRenderedFeatures(t,n,u._state,I.queryGeometry,I.cameraQueryGeometry,I.scale,c,p,_,On(u.transform,I.tileID))});const T=(function(I){const P={},V={};for(const N of I){const $=N.queryResults,B=N.wrappedTileID,ee=V[B]=V[B]||{};for(const se in $){const G=$[se],te=ee[se]=ee[se]||{},ce=P[se]=P[se]||[];for(const ue of G)te[ue.featureIndex]||(te[ue.featureIndex]=!0,ce.push(ue))}}return P})(b);for(const I in T)T[I].forEach((P=>{const V=P.feature,N=u.getFeatureState(V.layer["source-layer"],V.id);V.source=V.layer.source,V.layer["source-layer"]&&(V.sourceLayer=V.layer["source-layer"]),V.state=N}));return T}function Kr(u,t){const n=u.tileID,s=t.tileID;return n.overscaledZ-s.overscaledZ||n.canonical.y-s.canonical.y||n.wrap-s.wrap||n.canonical.x-s.canonical.x}class Yr{constructor(t,n){this.timeAdded=0,this.fadeEndTime=0,this.tileID=t,this.uid=l.a2(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(t){const n=t+this.timeAdded;n<this.fadeEndTime||(this.fadeEndTime=n)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(t,n,s){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=(function(c,p){const g={};if(!p)return g;for(const _ of c){const x=_.layerIds.map((b=>p.getLayer(b))).filter(Boolean);if(x.length!==0){_.layers=x,_.stateDependentLayerIds&&(_.stateDependentLayers=_.stateDependentLayerIds.map((b=>x.filter((T=>T.id===b))[0])));for(const b of x)g[b.id]=_}}return g})(t.buckets,n.style),this.hasSymbolBuckets=!1;for(const c in this.buckets){const p=this.buckets[c];if(p instanceof l.a4){if(this.hasSymbolBuckets=!0,!s)break;p.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const c in this.buckets){const p=this.buckets[c];if(p instanceof l.a4&&p.hasRTLText){this.hasRTLText=!0,l.a5();break}}this.queryPadding=0;for(const c in this.buckets){const p=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(c).queryRadius(p))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage)}else this.collisionBoxArray=new l.a3}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const s in this.buckets){const c=this.buckets[s];c.uploadPending()&&c.upload(t)}const n=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new nt(t,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new nt(t,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,n,s,c,p,g,_,x,b,T){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:c,cameraQueryGeometry:p,scale:g,tileSize:this.tileSize,pixelPosMatrix:T,transform:x,params:_,queryPadding:this.queryPadding*b},t,n,s):{}}querySourceFeatures(t,n){const s=this.latestFeatureIndex;if(!s||!s.rawTileData)return;const c=s.loadVTLayers(),p=n&&n.sourceLayer?n.sourceLayer:"",g=c._geojsonTileLayer||c[p];if(!g)return;const _=l.a6(n&&n.filter),{z:x,x:b,y:T}=this.tileID.canonical,I={z:x,x:b,y:T};for(let P=0;P<g.length;P++){const V=g.feature(P);if(_.needGeometry){const B=l.a7(V,!0);if(!_.filter(new l.a8(this.tileID.overscaledZ),B,this.tileID.canonical))continue}else if(!_.filter(new l.a8(this.tileID.overscaledZ),V))continue;const N=s.getId(V,p),$=new l.a9(V,x,b,T,N);$.tile=I,t.push($)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const n=this.expirationTime;if(t.cacheControl){const s=l.aa(t.cacheControl);s["max-age"]&&(this.expirationTime=Date.now()+1e3*s["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const s=Date.now();let c=!1;if(this.expirationTime>s)c=!1;else if(n)if(this.expirationTime<n)c=!0;else{const p=this.expirationTime-n;p?this.expirationTime=s+Math.max(p,3e4):c=!0}else c=!0;c?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(t,n){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(t).length===0)return;const s=this.latestFeatureIndex.loadVTLayers();for(const c in this.buckets){if(!n.style.hasLayer(c))continue;const p=this.buckets[c],g=p.layers[0].sourceLayer||"_geojsonTileLayer",_=s[g],x=t[g];if(!_||!x||Object.keys(x).length===0)continue;p.update(x,_,this.imageAtlas&&this.imageAtlas.patternPositions||{});const b=n&&n.style&&n.style.getLayer(c);b&&(this.queryPadding=Math.max(this.queryPadding,b.queryRadius(p)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<l.h.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=l.h.now()+t}setDependencies(t,n){const s={};for(const c of n)s[c]=!0;this.dependencies[t]=s}hasDependency(t,n){for(const s of t){const c=this.dependencies[s];if(c){for(const p of n)if(c[p])return!0}}return!1}}class mn{constructor(t,n){this.max=t,this.onRemove=n,this.reset()}reset(){for(const t in this.data)for(const n of this.data[t])n.timeout&&clearTimeout(n.timeout),this.onRemove(n.value);return this.data={},this.order=[],this}add(t,n,s){const c=t.wrapped().key;this.data[c]===void 0&&(this.data[c]=[]);const p={value:n,timeout:void 0};if(s!==void 0&&(p.timeout=setTimeout((()=>{this.remove(t,p)}),s)),this.data[c].push(p),this.order.push(c),this.order.length>this.max){const g=this._getAndRemoveByKey(this.order[0]);g&&this.onRemove(g)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const n=this.data[t].shift();return n.timeout&&clearTimeout(n.timeout),this.data[t].length===0&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),n.value}getByKey(t){const n=this.data[t];return n?n[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,n){if(!this.has(t))return this;const s=t.wrapped().key,c=n===void 0?0:this.data[s].indexOf(n),p=this.data[s][c];return this.data[s].splice(c,1),p.timeout&&clearTimeout(p.timeout),this.data[s].length===0&&delete this.data[s],this.onRemove(p.value),this.order.splice(this.order.indexOf(s),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}filter(t){const n=[];for(const s in this.data)for(const c of this.data[s])t(c.value)||n.push(c);for(const s of n)this.remove(s.value.tileID,s)}}class he{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,n,s){const c=String(n);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][c]=this.stateChanges[t][c]||{},l.e(this.stateChanges[t][c],s),this.deletedStates[t]===null){this.deletedStates[t]={};for(const p in this.state[t])p!==c&&(this.deletedStates[t][p]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][c]===null){this.deletedStates[t][c]={};for(const p in this.state[t][c])s[p]||(this.deletedStates[t][c][p]=null)}else for(const p in s)this.deletedStates[t]&&this.deletedStates[t][c]&&this.deletedStates[t][c][p]===null&&delete this.deletedStates[t][c][p]}removeFeatureState(t,n,s){if(this.deletedStates[t]===null)return;const c=String(n);if(this.deletedStates[t]=this.deletedStates[t]||{},s&&n!==void 0)this.deletedStates[t][c]!==null&&(this.deletedStates[t][c]=this.deletedStates[t][c]||{},this.deletedStates[t][c][s]=null);else if(n!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][c])for(s in this.deletedStates[t][c]={},this.stateChanges[t][c])this.deletedStates[t][c][s]=null;else this.deletedStates[t][c]=null;else this.deletedStates[t]=null}getState(t,n){const s=String(n),c=l.e({},(this.state[t]||{})[s],(this.stateChanges[t]||{})[s]);if(this.deletedStates[t]===null)return{};if(this.deletedStates[t]){const p=this.deletedStates[t][n];if(p===null)return{};for(const g in p)delete c[g]}return c}initializeTileState(t,n){t.setFeatureState(this.state,n)}coalesceChanges(t,n){const s={};for(const c in this.stateChanges){this.state[c]=this.state[c]||{};const p={};for(const g in this.stateChanges[c])this.state[c][g]||(this.state[c][g]={}),l.e(this.state[c][g],this.stateChanges[c][g]),p[g]=this.state[c][g];s[c]=p}for(const c in this.deletedStates){this.state[c]=this.state[c]||{};const p={};if(this.deletedStates[c]===null)for(const g in this.state[c])p[g]={},this.state[c][g]={};else for(const g in this.deletedStates[c]){if(this.deletedStates[c][g]===null)this.state[c][g]={};else for(const _ of Object.keys(this.deletedStates[c][g]))delete this.state[c][g][_];p[g]=this.state[c][g]}s[c]=s[c]||{},l.e(s[c],p)}if(this.stateChanges={},this.deletedStates={},Object.keys(s).length!==0)for(const c in t)t[c].setFeatureState(s,n)}}class Di extends l.E{constructor(t,n,s){super(),this.id=t,this.dispatcher=s,this.on("data",(c=>{c.dataType==="source"&&c.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&c.dataType==="source"&&c.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)})),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((c,p,g,_)=>{const x=new(Dr(p.type))(c,p,g,_);if(x.id!==c)throw new Error(`Expected Source id to be ${c} instead of ${x.id}`);return x})(t,n,s,this),this._tiles={},this._cache=new mn(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new he,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const t in this._tiles){const n=this._tiles[t];if(n.state!=="loaded"&&n.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(t,n){return this._source.loadTile(t,n)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(t){this._source.abortTile&&this._source.abortTile(t,(()=>{})),this._source.fire(new l.k("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const n in this._tiles){const s=this._tiles[n];s.upload(t),s.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map((t=>t.tileID)).sort(sr).map((t=>t.key))}getRenderableIds(t){const n=[];for(const s in this._tiles)this._isIdRenderable(s,t)&&n.push(this._tiles[s]);return t?n.sort(((s,c)=>{const p=s.tileID,g=c.tileID,_=new l.P(p.canonical.x,p.canonical.y)._rotate(this.transform.angle),x=new l.P(g.canonical.x,g.canonical.y)._rotate(this.transform.angle);return p.overscaledZ-g.overscaledZ||x.y-_.y||x.x-_.x})).map((s=>s.tileID.key)):n.map((s=>s.tileID)).sort(sr).map((s=>s.key))}hasRenderableParent(t){const n=this.findLoadedParent(t,0);return!!n&&this._isIdRenderable(n.tileID.key)}_isIdRenderable(t,n){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(n||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)this._tiles[t].state!=="errored"&&this._reloadTile(t,"reloading")}}_reloadTile(t,n){const s=this._tiles[t];s&&(s.state!=="loading"&&(s.state=n),this._loadTile(s,this._tileLoaded.bind(this,s,t,n)))}_tileLoaded(t,n,s,c){if(c)return t.state="errored",void(c.status!==404?this._source.fire(new l.j(c,{tile:t})):this.update(this.transform,this.terrain));t.timeAdded=l.h.now(),s==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(n,t),this.getSource().type==="raster-dem"&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new l.k("data",{dataType:"source",tile:t,coord:t.tileID}))}_backfillDEM(t){const n=this.getRenderableIds();for(let c=0;c<n.length;c++){const p=n[c];if(t.neighboringTiles&&t.neighboringTiles[p]){const g=this.getTileByID(p);s(t,g),s(g,t)}}function s(c,p){c.needsHillshadePrepare=!0,c.needsTerrainPrepare=!0;let g=p.tileID.canonical.x-c.tileID.canonical.x;const _=p.tileID.canonical.y-c.tileID.canonical.y,x=Math.pow(2,c.tileID.canonical.z),b=p.tileID.key;g===0&&_===0||Math.abs(_)>1||(Math.abs(g)>1&&(Math.abs(g+x)===1?g+=x:Math.abs(g-x)===1&&(g-=x)),p.dem&&c.dem&&(c.dem.backfillBorder(p.dem,g,_),c.neighboringTiles&&c.neighboringTiles[b]&&(c.neighboringTiles[b].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,n,s,c){for(const p in this._tiles){let g=this._tiles[p];if(c[p]||!g.hasData()||g.tileID.overscaledZ<=n||g.tileID.overscaledZ>s)continue;let _=g.tileID;for(;g&&g.tileID.overscaledZ>n+1;){const b=g.tileID.scaledTo(g.tileID.overscaledZ-1);g=this._tiles[b.key],g&&g.hasData()&&(_=b)}let x=_;for(;x.overscaledZ>n;)if(x=x.scaledTo(x.overscaledZ-1),t[x.key]){c[_.key]=_;break}}}findLoadedParent(t,n){if(t.key in this._loadedParentTiles){const s=this._loadedParentTiles[t.key];return s&&s.tileID.overscaledZ>=n?s:null}for(let s=t.overscaledZ-1;s>=n;s--){const c=t.scaledTo(s),p=this._getLoadedTile(c);if(p)return p}}_getLoadedTile(t){const n=this._tiles[t.key];return n&&n.hasData()?n:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const n=Math.ceil(t.width/this._source.tileSize)+1,s=Math.ceil(t.height/this._source.tileSize)+1,c=Math.floor(n*s*(this._maxTileCacheZoomLevels===null?l.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),p=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,c):c;this._cache.setMaxSize(p)}handleWrapJump(t){const n=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);if(this._prevLng=t,n){const s={};for(const c in this._tiles){const p=this._tiles[c];p.tileID=p.tileID.unwrapTo(p.tileID.wrap+n),s[p.tileID.key]=p}this._tiles=s;for(const c in this._timers)clearTimeout(this._timers[c]),delete this._timers[c];for(const c in this._tiles)this._setTileReloadTimer(c,this._tiles[c])}}update(t,n){if(this.transform=t,this.terrain=n,!this._sourceLoaded||this._paused)return;let s;this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?s=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((T=>new l.O(T.canonical.z,T.wrap,T.canonical.z,T.canonical.x,T.canonical.y))):(s=t.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n}),this._source.hasTile&&(s=s.filter((T=>this._source.hasTile(T))))):s=[];const c=t.coveringZoomLevel(this._source),p=Math.max(c-Di.maxOverzooming,this._source.minzoom),g=Math.max(c+Di.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const T={};for(const I of s)if(I.canonical.z>this._source.minzoom){const P=I.scaledTo(I.canonical.z-1);T[P.key]=P;const V=I.scaledTo(Math.max(this._source.minzoom,Math.min(I.canonical.z,5)));T[V.key]=V}s=s.concat(Object.values(T))}const _=s.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,_&&this.fire(new l.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const x=this._updateRetainedTiles(s,c);if(At(this._source.type)){const T={},I={},P=Object.keys(x),V=l.h.now();for(const N of P){const $=x[N],B=this._tiles[N];if(!B||B.fadeEndTime!==0&&B.fadeEndTime<=V)continue;const ee=this.findLoadedParent($,p);ee&&(this._addTile(ee.tileID),T[ee.tileID.key]=ee.tileID),I[N]=$}this._retainLoadedChildren(I,c,g,x);for(const N in T)x[N]||(this._coveredTiles[N]=!0,x[N]=T[N]);if(n){const N={},$={};for(const B of s)this._tiles[B.key].hasData()?N[B.key]=B:$[B.key]=B;for(const B in $){const ee=$[B].children(this._source.maxzoom);this._tiles[ee[0].key]&&this._tiles[ee[1].key]&&this._tiles[ee[2].key]&&this._tiles[ee[3].key]&&(N[ee[0].key]=x[ee[0].key]=ee[0],N[ee[1].key]=x[ee[1].key]=ee[1],N[ee[2].key]=x[ee[2].key]=ee[2],N[ee[3].key]=x[ee[3].key]=ee[3],delete $[B])}for(const B in $){const ee=this.findLoadedParent($[B],this._source.minzoom);if(ee){N[ee.tileID.key]=x[ee.tileID.key]=ee.tileID;for(const se in N)N[se].isChildOf(ee.tileID)&&delete N[se]}}for(const B in this._tiles)N[B]||(this._coveredTiles[B]=!0)}}for(const T in x)this._tiles[T].clearFadeHold();const b=l.ab(this._tiles,x);for(const T of b){const I=this._tiles[T];I.hasSymbolBuckets&&!I.holdingForFade()?I.setHoldDuration(this.map._fadeDuration):I.hasSymbolBuckets&&!I.symbolFadeFinished()||this._removeTile(T)}this._updateLoadedParentTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,n){const s={},c={},p=Math.max(n-Di.maxOverzooming,this._source.minzoom),g=Math.max(n+Di.maxUnderzooming,this._source.minzoom),_={};for(const x of t){const b=this._addTile(x);s[x.key]=x,b.hasData()||n<this._source.maxzoom&&(_[x.key]=x)}this._retainLoadedChildren(_,n,g,s);for(const x of t){let b=this._tiles[x.key];if(b.hasData())continue;if(n+1>this._source.maxzoom){const I=x.children(this._source.maxzoom)[0],P=this.getTile(I);if(P&&P.hasData()){s[I.key]=I;continue}}else{const I=x.children(this._source.maxzoom);if(s[I[0].key]&&s[I[1].key]&&s[I[2].key]&&s[I[3].key])continue}let T=b.wasRequested();for(let I=x.overscaledZ-1;I>=p;--I){const P=x.scaledTo(I);if(c[P.key])break;if(c[P.key]=!0,b=this.getTile(P),!b&&T&&(b=this._addTile(P)),b){const V=b.hasData();if((T||V)&&(s[P.key]=P),T=b.wasRequested(),V)break}}}return s}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const n=[];let s,c=this._tiles[t].tileID;for(;c.overscaledZ>0;){if(c.key in this._loadedParentTiles){s=this._loadedParentTiles[c.key];break}n.push(c.key);const p=c.scaledTo(c.overscaledZ-1);if(s=this._getLoadedTile(p),s)break;c=p}for(const p of n)this._loadedParentTiles[p]=s}}_addTile(t){let n=this._tiles[t.key];if(n)return n;n=this._cache.getAndRemove(t),n&&(this._setTileReloadTimer(t.key,n),n.tileID=t,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,n)));const s=n;return n||(n=new Yr(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(n,this._tileLoaded.bind(this,n,t.key,n.state))),n.uses++,this._tiles[t.key]=n,s||this._source.fire(new l.k("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(t,n){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const s=n.getExpiryTimeout();s&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),s))}_removeTile(t){const n=this._tiles[t];n&&(n.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._cache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(t,n,s){const c=[],p=this.transform;if(!p)return c;const g=s?p.getCameraQueryGeometry(t):t,_=t.map((N=>p.pointCoordinate(N,this.terrain))),x=g.map((N=>p.pointCoordinate(N,this.terrain))),b=this.getIds();let T=1/0,I=1/0,P=-1/0,V=-1/0;for(const N of x)T=Math.min(T,N.x),I=Math.min(I,N.y),P=Math.max(P,N.x),V=Math.max(V,N.y);for(let N=0;N<b.length;N++){const $=this._tiles[b[N]];if($.holdingForFade())continue;const B=$.tileID,ee=Math.pow(2,p.zoom-$.tileID.overscaledZ),se=n*$.queryPadding*l.N/$.tileSize/ee,G=[B.getTilePoint(new l.U(T,I)),B.getTilePoint(new l.U(P,V))];if(G[0].x-se<l.N&&G[0].y-se<l.N&&G[1].x+se>=0&&G[1].y+se>=0){const te=_.map((ue=>B.getTilePoint(ue))),ce=x.map((ue=>B.getTilePoint(ue)));c.push({tile:$,tileID:B,queryGeometry:te,cameraQueryGeometry:ce,scale:ee})}}return c}getVisibleCoordinates(t){const n=this.getRenderableIds(t).map((s=>this._tiles[s].tileID));for(const s of n)s.posMatrix=this.transform.calculatePosMatrix(s.toUnwrapped());return n}hasTransition(){if(this._source.hasTransition())return!0;if(At(this._source.type)){const t=l.h.now();for(const n in this._tiles)if(this._tiles[n].fadeEndTime>=t)return!0}return!1}setFeatureState(t,n,s){this._state.updateState(t=t||"_geojsonTileLayer",n,s)}removeFeatureState(t,n,s){this._state.removeFeatureState(t=t||"_geojsonTileLayer",n,s)}getFeatureState(t,n){return this._state.getState(t=t||"_geojsonTileLayer",n)}setDependencies(t,n,s){const c=this._tiles[t];c&&c.setDependencies(n,s)}reloadTilesForDependencies(t,n){for(const s in this._tiles)this._tiles[s].hasDependency(t,n)&&this._reloadTile(s,"reloading");this._cache.filter((s=>!s.hasDependency(t,n)))}}function sr(u,t){const n=Math.abs(2*u.wrap)-+(u.wrap<0),s=Math.abs(2*t.wrap)-+(t.wrap<0);return u.overscaledZ-t.overscaledZ||s-n||t.canonical.y-u.canonical.y||t.canonical.x-u.canonical.x}function At(u){return u==="raster"||u==="image"||u==="video"}Di.maxOverzooming=10,Di.maxUnderzooming=3;const _t="mapboxgl_preloaded_worker_pool";class br{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<br.workerCount;)this.workers.push(new Worker(l.c.WORKER_URL));return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],this.numActive()===0&&(this.workers.forEach((n=>{n.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[_t]}numActive(){return Object.keys(this.active).length}}const Nn=Math.floor(l.h.hardwareConcurrency/2);let Lr;function Na(){return Lr||(Lr=new br),Lr}br.workerCount=l.ac(globalThis)?Math.max(Math.min(Nn,3),1):1;class Vn{constructor(t,n){this.reset(t,n)}reset(t,n){this.points=t||[],this._distances=[0];for(let s=1;s<this.points.length;s++)this._distances[s]=this._distances[s-1]+this.points[s].dist(this.points[s-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(n||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(this.points.length===1)return this.points[0];t=l.ad(t,0,1);let n=1,s=this._distances[n];const c=t*this.paddedLength+this.padding;for(;s<c&&n<this._distances.length;)s=this._distances[++n];const p=n-1,g=this._distances[p],_=s-g,x=_>0?(c-g)/_:0;return this.points[p].mult(1-x).add(this.points[n].mult(x))}}function Jr(u,t){let n=!0;return u==="always"||u!=="never"&&t!=="never"||(n=!1),n}class gn{constructor(t,n,s){const c=this.boxCells=[],p=this.circleCells=[];this.xCellCount=Math.ceil(t/s),this.yCellCount=Math.ceil(n/s);for(let g=0;g<this.xCellCount*this.yCellCount;g++)c.push([]),p.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=n,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/n,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,n,s,c,p){this._forEachCell(n,s,c,p,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(n),this.bboxes.push(s),this.bboxes.push(c),this.bboxes.push(p)}insertCircle(t,n,s,c){this._forEachCell(n-c,s-c,n+c,s+c,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(n),this.circles.push(s),this.circles.push(c)}_insertBoxCell(t,n,s,c,p,g){this.boxCells[p].push(g)}_insertCircleCell(t,n,s,c,p,g){this.circleCells[p].push(g)}_query(t,n,s,c,p,g,_){if(s<0||t>this.width||c<0||n>this.height)return[];const x=[];if(t<=0&&n<=0&&this.width<=s&&this.height<=c){if(p)return[{key:null,x1:t,y1:n,x2:s,y2:c}];for(let b=0;b<this.boxKeys.length;b++)x.push({key:this.boxKeys[b],x1:this.bboxes[4*b],y1:this.bboxes[4*b+1],x2:this.bboxes[4*b+2],y2:this.bboxes[4*b+3]});for(let b=0;b<this.circleKeys.length;b++){const T=this.circles[3*b],I=this.circles[3*b+1],P=this.circles[3*b+2];x.push({key:this.circleKeys[b],x1:T-P,y1:I-P,x2:T+P,y2:I+P})}}else this._forEachCell(t,n,s,c,this._queryCell,x,{hitTest:p,overlapMode:g,seenUids:{box:{},circle:{}}},_);return x}query(t,n,s,c){return this._query(t,n,s,c,!1,null)}hitTest(t,n,s,c,p,g){return this._query(t,n,s,c,!0,p,g).length>0}hitTestCircle(t,n,s,c,p){const g=t-s,_=t+s,x=n-s,b=n+s;if(_<0||g>this.width||b<0||x>this.height)return!1;const T=[];return this._forEachCell(g,x,_,b,this._queryCellCircle,T,{hitTest:!0,overlapMode:c,circle:{x:t,y:n,radius:s},seenUids:{box:{},circle:{}}},p),T.length>0}_queryCell(t,n,s,c,p,g,_,x){const{seenUids:b,hitTest:T,overlapMode:I}=_,P=this.boxCells[p];if(P!==null){const N=this.bboxes;for(const $ of P)if(!b.box[$]){b.box[$]=!0;const B=4*$,ee=this.boxKeys[$];if(t<=N[B+2]&&n<=N[B+3]&&s>=N[B+0]&&c>=N[B+1]&&(!x||x(ee))&&(!T||!Jr(I,ee.overlapMode))&&(g.push({key:ee,x1:N[B],y1:N[B+1],x2:N[B+2],y2:N[B+3]}),T))return!0}}const V=this.circleCells[p];if(V!==null){const N=this.circles;for(const $ of V)if(!b.circle[$]){b.circle[$]=!0;const B=3*$,ee=this.circleKeys[$];if(this._circleAndRectCollide(N[B],N[B+1],N[B+2],t,n,s,c)&&(!x||x(ee))&&(!T||!Jr(I,ee.overlapMode))){const se=N[B],G=N[B+1],te=N[B+2];if(g.push({key:ee,x1:se-te,y1:G-te,x2:se+te,y2:G+te}),T)return!0}}}return!1}_queryCellCircle(t,n,s,c,p,g,_,x){const{circle:b,seenUids:T,overlapMode:I}=_,P=this.boxCells[p];if(P!==null){const N=this.bboxes;for(const $ of P)if(!T.box[$]){T.box[$]=!0;const B=4*$,ee=this.boxKeys[$];if(this._circleAndRectCollide(b.x,b.y,b.radius,N[B+0],N[B+1],N[B+2],N[B+3])&&(!x||x(ee))&&!Jr(I,ee.overlapMode))return g.push(!0),!0}}const V=this.circleCells[p];if(V!==null){const N=this.circles;for(const $ of V)if(!T.circle[$]){T.circle[$]=!0;const B=3*$,ee=this.circleKeys[$];if(this._circlesCollide(N[B],N[B+1],N[B+2],b.x,b.y,b.radius)&&(!x||x(ee))&&!Jr(I,ee.overlapMode))return g.push(!0),!0}}}_forEachCell(t,n,s,c,p,g,_,x){const b=this._convertToXCellCoord(t),T=this._convertToYCellCoord(n),I=this._convertToXCellCoord(s),P=this._convertToYCellCoord(c);for(let V=b;V<=I;V++)for(let N=T;N<=P;N++)if(p.call(this,t,n,s,c,this.xCellCount*N+V,g,_,x))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,n,s,c,p,g){const _=c-t,x=p-n,b=s+g;return b*b>_*_+x*x}_circleAndRectCollide(t,n,s,c,p,g,_){const x=(g-c)/2,b=Math.abs(t-(c+x));if(b>x+s)return!1;const T=(_-p)/2,I=Math.abs(n-(p+T));if(I>T+s)return!1;if(b<=x||I<=T)return!0;const P=b-x,V=I-T;return P*P+V*V<=s*s}}function Ae(u,t,n,s,c){const p=l.Z();return t?(l.a0(p,p,[1/c,1/c,1]),n||l.ae(p,p,s.angle)):l.a1(p,s.labelPlaneMatrix,u),p}function wr(u,t,n,s,c){if(t){const p=l.af(u);return l.a0(p,p,[c,c,1]),n||l.ae(p,p,-s.angle),p}return s.glCoordMatrix}function Ut(u,t,n){let s;n?(s=[u.x,u.y,n(u.x,u.y),1],l.ag(s,s,t)):(s=[u.x,u.y,0,1],j(s,s,t));const c=s[3];return{point:new l.P(s[0]/c,s[1]/c),signedDistanceFromCamera:c}}function _n(u,t){return .5+u/t*.5}function Fr(u,t){const n=u[0]/u[3],s=u[1]/u[3];return n>=-t[0]&&n<=t[0]&&s>=-t[1]&&s<=t[1]}function Ce(u,t,n,s,c,p,g,_,x,b){const T=s?u.textSizeData:u.iconSizeData,I=l.ah(T,n.transform.zoom),P=[256/n.width*2+1,256/n.height*2+1],V=s?u.text.dynamicLayoutVertexArray:u.icon.dynamicLayoutVertexArray;V.clear();const N=u.lineVertexArray,$=s?u.text.placedSymbolArray:u.icon.placedSymbolArray,B=n.transform.width/n.transform.height;let ee=!1;for(let se=0;se<$.length;se++){const G=$.get(se);if(G.hidden||G.writingMode===l.ai.vertical&&!ee){R(G.numGlyphs,V);continue}let te;if(ee=!1,b?(te=[G.anchorX,G.anchorY,b(G.anchorX,G.anchorY),1],l.ag(te,te,t)):(te=[G.anchorX,G.anchorY,0,1],j(te,te,t)),!Fr(te,P)){R(G.numGlyphs,V);continue}const ce=_n(n.transform.cameraToCenterDistance,te[3]),ue=l.aj(T,I,G),me=g?ue/ce:ue*ce,be=new l.P(G.anchorX,G.anchorY),xe=Ut(be,c,b).point,Te={projections:{},offsets:{}},Be=Si(G,me,!1,_,t,c,p,u.glyphOffsetArray,N,V,xe,be,Te,B,x,b);ee=Be.useVertical,(Be.notEnoughRoom||ee||Be.needsFlipping&&Si(G,me,!0,_,t,c,p,u.glyphOffsetArray,N,V,xe,be,Te,B,x,b).notEnoughRoom)&&R(G.numGlyphs,V)}s?u.text.dynamicLayoutVertexBuffer.updateData(V):u.icon.dynamicLayoutVertexBuffer.updateData(V)}function ot(u,t,n,s,c,p,g,_,x,b,T,I,P){const V=_.glyphStartIndex+_.numGlyphs,N=_.lineStartIndex,$=_.lineStartIndex+_.lineLength,B=t.getoffsetX(_.glyphStartIndex),ee=t.getoffsetX(V-1),se=k(u*B,n,s,c,p,g,_.segment,N,$,x,b,T,I,P);if(!se)return null;const G=k(u*ee,n,s,c,p,g,_.segment,N,$,x,b,T,I,P);return G?{first:se,last:G}:null}function et(u,t,n,s){return u===l.ai.horizontal&&Math.abs(n.y-t.y)>Math.abs(n.x-t.x)*s?{useVertical:!0}:(u===l.ai.vertical?t.y<n.y:t.x>n.x)?{needsFlipping:!0}:null}function Si(u,t,n,s,c,p,g,_,x,b,T,I,P,V,N,$){const B=t/24,ee=u.lineOffsetX*B,se=u.lineOffsetY*B;let G;if(u.numGlyphs>1){const te=u.glyphStartIndex+u.numGlyphs,ce=u.lineStartIndex,ue=u.lineStartIndex+u.lineLength,me=ot(B,_,ee,se,n,T,I,u,x,p,P,N,$);if(!me)return{notEnoughRoom:!0};const be=Ut(me.first.point,g,$).point,xe=Ut(me.last.point,g,$).point;if(s&&!n){const Te=et(u.writingMode,be,xe,V);if(Te)return Te}G=[me.first];for(let Te=u.glyphStartIndex+1;Te<te-1;Te++)G.push(k(B*_.getoffsetX(Te),ee,se,n,T,I,u.segment,ce,ue,x,p,P,N,$));G.push(me.last)}else{if(s&&!n){const ce=Ut(I,c,$).point,ue=u.lineStartIndex+u.segment+1,me=new l.P(x.getx(ue),x.gety(ue)),be=Ut(me,c,$),xe=be.signedDistanceFromCamera>0?be.point:Sr(I,me,ce,1,c,$),Te=et(u.writingMode,ce,xe,V);if(Te)return Te}const te=k(B*_.getoffsetX(u.glyphStartIndex),ee,se,n,T,I,u.segment,u.lineStartIndex,u.lineStartIndex+u.lineLength,x,p,P,N,$);if(!te)return{notEnoughRoom:!0};G=[te]}for(const te of G)l.ak(b,te.point,te.angle);return{}}function Sr(u,t,n,s,c,p){const g=Ut(u.add(u.sub(t)._unit()),c,p).point,_=n.sub(g);return n.add(_._mult(s/_.mag()))}function rt(u,t){const{projectionCache:n,lineVertexArray:s,labelPlaneMatrix:c,tileAnchorPoint:p,distanceFromAnchor:g,getElevation:_,previousVertex:x,direction:b,absOffsetX:T}=t;if(n.projections[u])return n.projections[u];const I=new l.P(s.getx(u),s.gety(u)),P=Ut(I,c,_);if(P.signedDistanceFromCamera>0)return n.projections[u]=P.point,P.point;const V=u-b;return Sr(g===0?p:new l.P(s.getx(V),s.gety(V)),I,x,T-g+1,c,_)}function Rr(u,t,n){return u._unit()._perp()._mult(t*n)}function U(u,t,n,s,c,p,g,_){const{projectionCache:x,direction:b}=_;if(x.offsets[u])return x.offsets[u];const T=n.add(t);if(u+b<s||u+b>=c)return x.offsets[u]=T,T;const I=rt(u+b,_),P=Rr(I.sub(n),g,b),V=n.add(P),N=I.add(P);return x.offsets[u]=l.al(p,T,V,N)||T,x.offsets[u]}function k(u,t,n,s,c,p,g,_,x,b,T,I,P,V){const N=s?u-t:u+t;let $=N>0?1:-1,B=0;s&&($*=-1,B=Math.PI),$<0&&(B+=Math.PI);let ee,se,G=$>0?_+g:_+g+1,te=c,ce=c,ue=0,me=0;const be=Math.abs(N),xe=[];let Te;for(;ue+me<=be;){if(G+=$,G<_||G>=x)return null;ue+=me,ce=te,se=ee;const Ee={projectionCache:I,lineVertexArray:b,labelPlaneMatrix:T,tileAnchorPoint:p,distanceFromAnchor:ue,getElevation:V,previousVertex:ce,direction:$,absOffsetX:be};if(te=rt(G,Ee),n===0)xe.push(ce),Te=te.sub(ce);else{let We;const Ne=te.sub(ce);We=Ne.mag()===0?Rr(rt(G+$,Ee).sub(te),n,$):Rr(Ne,n,$),se||(se=ce.add(We)),ee=U(G,We,te,_,x,se,n,Ee),xe.push(se),Te=ee.sub(se)}me=Te.mag()}const Be=Te._mult((be-ue)/me)._add(se||ce),ut=B+Math.atan2(te.y-ce.y,te.x-ce.x);return xe.push(Be),{point:Be,angle:P?ut:0,path:xe}}const M=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function R(u,t){for(let n=0;n<u;n++){const s=t.length;t.resize(s+4),t.float32.set(M,3*s)}}function j(u,t,n){const s=t[0],c=t[1];return u[0]=n[0]*s+n[4]*c+n[12],u[1]=n[1]*s+n[5]*c+n[13],u[3]=n[3]*s+n[7]*c+n[15],u}const Z=100;class ne{constructor(t,n=new gn(t.width+200,t.height+200,25),s=new gn(t.width+200,t.height+200,25)){this.transform=t,this.grid=n,this.ignoredGrid=s,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+Z,this.screenBottomBoundary=t.height+Z,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,n,s,c,p,g){const _=this.projectAndGetPerspectiveRatio(c,t.anchorPointX,t.anchorPointY,g),x=s*_.perspectiveRatio,b=t.x1*x+_.point.x,T=t.y1*x+_.point.y,I=t.x2*x+_.point.x,P=t.y2*x+_.point.y;return!this.isInsideGrid(b,T,I,P)||n!=="always"&&this.grid.hitTest(b,T,I,P,n,p)||_.perspectiveRatio<this.perspectiveRatioCutoff?{box:[],offscreen:!1}:{box:[b,T,I,P],offscreen:this.isOffscreen(b,T,I,P)}}placeCollisionCircles(t,n,s,c,p,g,_,x,b,T,I,P,V,N){const $=[],B=new l.P(n.anchorX,n.anchorY),ee=Ut(B,g,N),se=_n(this.transform.cameraToCenterDistance,ee.signedDistanceFromCamera),G=(T?p/se:p*se)/l.ap,te=Ut(B,_,N).point,ce=ot(G,c,n.lineOffsetX*G,n.lineOffsetY*G,!1,te,B,n,s,_,{projections:{},offsets:{}},!1,N);let ue=!1,me=!1,be=!0;if(ce){const xe=.5*P*se+V,Te=new l.P(-100,-100),Be=new l.P(this.screenRightBoundary,this.screenBottomBoundary),ut=new Vn,Ee=ce.first,We=ce.last;let Ne=[];for(let at=Ee.path.length-1;at>=1;at--)Ne.push(Ee.path[at]);for(let at=1;at<We.path.length;at++)Ne.push(We.path[at]);const St=2.5*xe;if(x){const at=Ne.map((ht=>Ut(ht,x,N)));Ne=at.some((ht=>ht.signedDistanceFromCamera<=0))?[]:at.map((ht=>ht.point))}let ct=[];if(Ne.length>0){const at=Ne[0].clone(),ht=Ne[0].clone();for(let Zt=1;Zt<Ne.length;Zt++)at.x=Math.min(at.x,Ne[Zt].x),at.y=Math.min(at.y,Ne[Zt].y),ht.x=Math.max(ht.x,Ne[Zt].x),ht.y=Math.max(ht.y,Ne[Zt].y);ct=at.x>=Te.x&&ht.x<=Be.x&&at.y>=Te.y&&ht.y<=Be.y?[Ne]:ht.x<Te.x||at.x>Be.x||ht.y<Te.y||at.y>Be.y?[]:l.am([Ne],Te.x,Te.y,Be.x,Be.y)}for(const at of ct){ut.reset(at,.25*xe);let ht=0;ht=ut.length<=.5*xe?1:Math.ceil(ut.paddedLength/St)+1;for(let Zt=0;Zt<ht;Zt++){const Ct=Zt/Math.max(ht-1,1),pi=ut.lerp(Ct),ei=pi.x+Z,Xt=pi.y+Z;$.push(ei,Xt,xe,0);const Yi=ei-xe,Pt=Xt-xe,Ir=ei+xe,Ar=Xt+xe;if(be=be&&this.isOffscreen(Yi,Pt,Ir,Ar),me=me||this.isInsideGrid(Yi,Pt,Ir,Ar),t!=="always"&&this.grid.hitTestCircle(ei,Xt,xe,t,I)&&(ue=!0,!b))return{circles:[],offscreen:!1,collisionDetected:ue}}}}return{circles:!b&&ue||!me||se<this.perspectiveRatioCutoff?[]:$,offscreen:be,collisionDetected:ue}}queryRenderedSymbols(t){if(t.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const n=[];let s=1/0,c=1/0,p=-1/0,g=-1/0;for(const T of t){const I=new l.P(T.x+Z,T.y+Z);s=Math.min(s,I.x),c=Math.min(c,I.y),p=Math.max(p,I.x),g=Math.max(g,I.y),n.push(I)}const _=this.grid.query(s,c,p,g).concat(this.ignoredGrid.query(s,c,p,g)),x={},b={};for(const T of _){const I=T.key;if(x[I.bucketInstanceId]===void 0&&(x[I.bucketInstanceId]={}),x[I.bucketInstanceId][I.featureIndex])continue;const P=[new l.P(T.x1,T.y1),new l.P(T.x2,T.y1),new l.P(T.x2,T.y2),new l.P(T.x1,T.y2)];l.an(n,P)&&(x[I.bucketInstanceId][I.featureIndex]=!0,b[I.bucketInstanceId]===void 0&&(b[I.bucketInstanceId]=[]),b[I.bucketInstanceId].push(I.featureIndex))}return b}insertCollisionBox(t,n,s,c,p,g){(s?this.ignoredGrid:this.grid).insert({bucketInstanceId:c,featureIndex:p,collisionGroupID:g,overlapMode:n},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,n,s,c,p,g){const _=s?this.ignoredGrid:this.grid,x={bucketInstanceId:c,featureIndex:p,collisionGroupID:g,overlapMode:n};for(let b=0;b<t.length;b+=4)_.insertCircle(x,t[b],t[b+1],t[b+2])}projectAndGetPerspectiveRatio(t,n,s,c){let p;return c?(p=[n,s,c(n,s),1],l.ag(p,p,t)):(p=[n,s,0,1],j(p,p,t)),{point:new l.P((p[0]/p[3]+1)/2*this.transform.width+Z,(-p[1]/p[3]+1)/2*this.transform.height+Z),perspectiveRatio:.5+this.transform.cameraToCenterDistance/p[3]*.5}}isOffscreen(t,n,s,c){return s<Z||t>=this.screenRightBoundary||c<Z||n>this.screenBottomBoundary}isInsideGrid(t,n,s,c){return s>=0&&t<this.gridRightBoundary&&c>=0&&n<this.gridBottomBoundary}getViewportMatrix(){const t=l.ao([]);return l.$(t,t,[-100,-100,0]),t}}function J(u,t,n){return t*(l.N/(u.tileSize*Math.pow(2,n-u.tileID.overscaledZ)))}class X{constructor(t,n,s,c){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?n:-n))):c&&s?1:0,this.placed=s}isHidden(){return this.opacity===0&&!this.placed}}class ie{constructor(t,n,s,c,p){this.text=new X(t?t.text:null,n,s,p),this.icon=new X(t?t.icon:null,n,c,p)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class pe{constructor(t,n,s){this.text=t,this.icon=n,this.skipFade=s}}class fe{constructor(){this.invProjMatrix=l.Z(),this.viewportMatrix=l.Z(),this.circles=[]}}class ye{constructor(t,n,s,c,p){this.bucketInstanceId=t,this.featureIndex=n,this.sourceLayerIndex=s,this.bucketIndex=c,this.tileID=p}}class qe{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const n=++this.maxGroupID;this.collisionGroups[t]={ID:n,predicate:s=>s.collisionGroupID===n}}return this.collisionGroups[t]}}function Je(u,t,n,s,c){const{horizontalAlign:p,verticalAlign:g}=l.au(u);return new l.P(-(p-.5)*t+s[0]*c,-(g-.5)*n+s[1]*c)}function Re(u,t,n,s,c,p){const{x1:g,x2:_,y1:x,y2:b,anchorPointX:T,anchorPointY:I}=u,P=new l.P(t,n);return s&&P._rotate(c?p:-p),{x1:g+P.x,y1:x+P.y,x2:_+P.x,y2:b+P.y,anchorPointX:T,anchorPointY:I}}class Ge{constructor(t,n,s,c,p){this.transform=t.clone(),this.terrain=n,this.collisionIndex=new ne(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=s,this.retainedQueryData={},this.collisionGroups=new qe(c),this.collisionCircleArrays={},this.prevPlacement=p,p&&(p.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,n,s,c){const p=s.getBucket(n),g=s.latestFeatureIndex;if(!p||!g||n.id!==p.layerIds[0])return;const _=s.collisionBoxArray,x=p.layers[0].layout,b=Math.pow(2,this.transform.zoom-s.tileID.overscaledZ),T=s.tileSize/l.N,I=this.transform.calculatePosMatrix(s.tileID.toUnwrapped()),P=x.get("text-pitch-alignment")==="map",V=x.get("text-rotation-alignment")==="map",N=J(s,1,this.transform.zoom),$=Ae(I,P,V,this.transform,N);let B=null;if(P){const se=wr(I,P,V,this.transform,N);B=l.a1([],this.transform.labelPlaneMatrix,se)}this.retainedQueryData[p.bucketInstanceId]=new ye(p.bucketInstanceId,g,p.sourceLayerIndex,p.index,s.tileID);const ee={bucket:p,layout:x,posMatrix:I,textLabelPlaneMatrix:$,labelToScreenMatrix:B,scale:b,textPixelRatio:T,holdingForFade:s.holdingForFade(),collisionBoxArray:_,partiallyEvaluatedTextSize:l.ah(p.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(p.sourceID)};if(c)for(const se of p.sortKeyRanges){const{sortKey:G,symbolInstanceStart:te,symbolInstanceEnd:ce}=se;t.push({sortKey:G,symbolInstanceStart:te,symbolInstanceEnd:ce,parameters:ee})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:p.symbolInstances.length,parameters:ee})}attemptAnchorPlacement(t,n,s,c,p,g,_,x,b,T,I,P,V,N,$,B){const ee=l.aq[t.textAnchor],se=[t.textOffset0,t.textOffset1],G=Je(ee,s,c,se,p),te=this.collisionIndex.placeCollisionBox(Re(n,G.x,G.y,g,_,this.transform.angle),I,x,b,T.predicate,B);if((!$||this.collisionIndex.placeCollisionBox(Re($,G.x,G.y,g,_,this.transform.angle),I,x,b,T.predicate,B).box.length!==0)&&te.box.length>0){let ce;if(this.prevPlacement&&this.prevPlacement.variableOffsets[P.crossTileID]&&this.prevPlacement.placements[P.crossTileID]&&this.prevPlacement.placements[P.crossTileID].text&&(ce=this.prevPlacement.variableOffsets[P.crossTileID].anchor),P.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[P.crossTileID]={textOffset:se,width:s,height:c,anchor:ee,textBoxScale:p,prevAnchor:ce},this.markUsedJustification(V,ee,P,N),V.allowVerticalPlacement&&(this.markUsedOrientation(V,N,P),this.placedOrientations[P.crossTileID]=N),{shift:G,placedGlyphBoxes:te}}}placeLayerBucketPart(t,n,s){const{bucket:c,layout:p,posMatrix:g,textLabelPlaneMatrix:_,labelToScreenMatrix:x,textPixelRatio:b,holdingForFade:T,collisionBoxArray:I,partiallyEvaluatedTextSize:P,collisionGroup:V}=t.parameters,N=p.get("text-optional"),$=p.get("icon-optional"),B=l.ar(p,"text-overlap","text-allow-overlap"),ee=B==="always",se=l.ar(p,"icon-overlap","icon-allow-overlap"),G=se==="always",te=p.get("text-rotation-alignment")==="map",ce=p.get("text-pitch-alignment")==="map",ue=p.get("icon-text-fit")!=="none",me=p.get("symbol-z-order")==="viewport-y",be=ee&&(G||!c.hasIconData()||$),xe=G&&(ee||!c.hasTextData()||N);!c.collisionArrays&&I&&c.deserializeCollisionBoxes(I);const Te=this.retainedQueryData[c.bucketInstanceId].tileID,Be=this.terrain?(Ee,We)=>this.terrain.getElevation(Te,Ee,We):null,ut=(Ee,We)=>{var Ne,St;if(n[Ee.crossTileID])return;if(T)return void(this.placements[Ee.crossTileID]=new pe(!1,!1,!1));let ct=!1,at=!1,ht=!0,Zt=null,Ct={box:null,offscreen:null},pi={box:null},ei=null,Xt=null,Yi=null,Pt=0,Ir=0,Ar=0;We.textFeatureIndex?Pt=We.textFeatureIndex:Ee.useRuntimeCollisionCircles&&(Pt=Ee.featureIndex),We.verticalTextFeatureIndex&&(Ir=We.verticalTextFeatureIndex);const on=We.textBox;if(on){const _i=Gt=>{let ti=l.ai.horizontal;if(c.allowVerticalPlacement&&!Gt&&this.prevPlacement){const Ri=this.prevPlacement.placedOrientations[Ee.crossTileID];Ri&&(this.placedOrientations[Ee.crossTileID]=Ri,ti=Ri,this.markUsedOrientation(c,ti,Ee))}return ti},di=(Gt,ti)=>{if(c.allowVerticalPlacement&&Ee.numVerticalGlyphVertices>0&&We.verticalTextBox){for(const Ri of c.writingModes)if(Ri===l.ai.vertical?(Ct=ti(),pi=Ct):Ct=Gt(),Ct&&Ct.box&&Ct.box.length)break}else Ct=Gt()},Ii=Ee.textAnchorOffsetStartIndex,kn=Ee.textAnchorOffsetEndIndex;if(kn===Ii){const Gt=(ti,Ri)=>{const Ht=this.collisionIndex.placeCollisionBox(ti,B,b,g,V.predicate,Be);return Ht&&Ht.box&&Ht.box.length&&(this.markUsedOrientation(c,Ri,Ee),this.placedOrientations[Ee.crossTileID]=Ri),Ht};di((()=>Gt(on,l.ai.horizontal)),(()=>{const ti=We.verticalTextBox;return c.allowVerticalPlacement&&Ee.numVerticalGlyphVertices>0&&ti?Gt(ti,l.ai.vertical):{box:null,offscreen:null}})),_i(Ct&&Ct.box&&Ct.box.length)}else{let Gt=l.aq[(St=(Ne=this.prevPlacement)===null||Ne===void 0?void 0:Ne.variableOffsets[Ee.crossTileID])===null||St===void 0?void 0:St.anchor];const ti=(Ht,Cn,fs)=>{const Ml=Ht.x2-Ht.x1,Pl=Ht.y2-Ht.y1,Mc=Ee.textBoxScale,xo=ue&&se==="never"?Cn:null;let kr={box:[],offscreen:!1},En=B==="never"?1:2,Cr="never";Gt&&En++;for(let dr=0;dr<En;dr++){for(let Er=Ii;Er<kn;Er++){const vo=c.textAnchorOffsets.get(Er);if(Gt&&vo.textAnchor!==Gt)continue;const Ur=this.attemptAnchorPlacement(vo,Ht,Ml,Pl,Mc,te,ce,b,g,V,Cr,Ee,c,fs,xo,Be);if(Ur&&(kr=Ur.placedGlyphBoxes,kr&&kr.box&&kr.box.length))return ct=!0,Zt=Ur.shift,kr}Gt?Gt=null:Cr=B}return kr};di((()=>ti(on,We.iconBox,l.ai.horizontal)),(()=>{const Ht=We.verticalTextBox;return c.allowVerticalPlacement&&!(Ct&&Ct.box&&Ct.box.length)&&Ee.numVerticalGlyphVertices>0&&Ht?ti(Ht,We.verticalIconBox,l.ai.vertical):{box:null,offscreen:null}})),Ct&&(ct=Ct.box,ht=Ct.offscreen);const Ri=_i(Ct&&Ct.box);if(!ct&&this.prevPlacement){const Ht=this.prevPlacement.variableOffsets[Ee.crossTileID];Ht&&(this.variableOffsets[Ee.crossTileID]=Ht,this.markUsedJustification(c,Ht.anchor,Ee,Ri))}}}if(ei=Ct,ct=ei&&ei.box&&ei.box.length>0,ht=ei&&ei.offscreen,Ee.useRuntimeCollisionCircles){const _i=c.text.placedSymbolArray.get(Ee.centerJustifiedTextSymbolIndex),di=l.aj(c.textSizeData,P,_i),Ii=p.get("text-padding");Xt=this.collisionIndex.placeCollisionCircles(B,_i,c.lineVertexArray,c.glyphOffsetArray,di,g,_,x,s,ce,V.predicate,Ee.collisionCircleDiameter,Ii,Be),Xt.circles.length&&Xt.collisionDetected&&!s&&l.w("Collisions detected, but collision boxes are not shown"),ct=ee||Xt.circles.length>0&&!Xt.collisionDetected,ht=ht&&Xt.offscreen}if(We.iconFeatureIndex&&(Ar=We.iconFeatureIndex),We.iconBox){const _i=di=>{const Ii=ue&&Zt?Re(di,Zt.x,Zt.y,te,ce,this.transform.angle):di;return this.collisionIndex.placeCollisionBox(Ii,se,b,g,V.predicate,Be)};pi&&pi.box&&pi.box.length&&We.verticalIconBox?(Yi=_i(We.verticalIconBox),at=Yi.box.length>0):(Yi=_i(We.iconBox),at=Yi.box.length>0),ht=ht&&Yi.offscreen}const An=N||Ee.numHorizontalGlyphVertices===0&&Ee.numVerticalGlyphVertices===0,ea=$||Ee.numIconVertices===0;if(An||ea?ea?An||(at=at&&ct):ct=at&&ct:at=ct=at&&ct,ct&&ei&&ei.box&&this.collisionIndex.insertCollisionBox(ei.box,B,p.get("text-ignore-placement"),c.bucketInstanceId,pi&&pi.box&&Ir?Ir:Pt,V.ID),at&&Yi&&this.collisionIndex.insertCollisionBox(Yi.box,se,p.get("icon-ignore-placement"),c.bucketInstanceId,Ar,V.ID),Xt&&(ct&&this.collisionIndex.insertCollisionCircles(Xt.circles,B,p.get("text-ignore-placement"),c.bucketInstanceId,Pt,V.ID),s)){const _i=c.bucketInstanceId;let di=this.collisionCircleArrays[_i];di===void 0&&(di=this.collisionCircleArrays[_i]=new fe);for(let Ii=0;Ii<Xt.circles.length;Ii+=4)di.circles.push(Xt.circles[Ii+0]),di.circles.push(Xt.circles[Ii+1]),di.circles.push(Xt.circles[Ii+2]),di.circles.push(Xt.collisionDetected?1:0)}if(Ee.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(c.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[Ee.crossTileID]=new pe(ct||be,at||xe,ht||c.justReloaded),n[Ee.crossTileID]=!0};if(me){if(t.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const Ee=c.getSortedSymbolIndexes(this.transform.angle);for(let We=Ee.length-1;We>=0;--We){const Ne=Ee[We];ut(c.symbolInstances.get(Ne),c.collisionArrays[Ne])}}else for(let Ee=t.symbolInstanceStart;Ee<t.symbolInstanceEnd;Ee++)ut(c.symbolInstances.get(Ee),c.collisionArrays[Ee]);if(s&&c.bucketInstanceId in this.collisionCircleArrays){const Ee=this.collisionCircleArrays[c.bucketInstanceId];l.as(Ee.invProjMatrix,g),Ee.viewportMatrix=this.collisionIndex.getViewportMatrix()}c.justReloaded=!1}markUsedJustification(t,n,s,c){let p;p=c===l.ai.vertical?s.verticalPlacedTextSymbolIndex:{left:s.leftJustifiedTextSymbolIndex,center:s.centerJustifiedTextSymbolIndex,right:s.rightJustifiedTextSymbolIndex}[l.at(n)];const g=[s.leftJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.rightJustifiedTextSymbolIndex,s.verticalPlacedTextSymbolIndex];for(const _ of g)_>=0&&(t.text.placedSymbolArray.get(_).crossTileID=p>=0&&_!==p?0:s.crossTileID)}markUsedOrientation(t,n,s){const c=n===l.ai.horizontal||n===l.ai.horizontalOnly?n:0,p=n===l.ai.vertical?n:0,g=[s.leftJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.rightJustifiedTextSymbolIndex];for(const _ of g)t.text.placedSymbolArray.get(_).placedOrientation=c;s.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(s.verticalPlacedTextSymbolIndex).placedOrientation=p)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let s=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const c=n?n.symbolFadeChange(t):1,p=n?n.opacities:{},g=n?n.variableOffsets:{},_=n?n.placedOrientations:{};for(const x in this.placements){const b=this.placements[x],T=p[x];T?(this.opacities[x]=new ie(T,c,b.text,b.icon),s=s||b.text!==T.text.placed||b.icon!==T.icon.placed):(this.opacities[x]=new ie(null,c,b.text,b.icon,b.skipFade),s=s||b.text||b.icon)}for(const x in p){const b=p[x];if(!this.opacities[x]){const T=new ie(b,c,!1,!1);T.isHidden()||(this.opacities[x]=T,s=s||b.text.placed||b.icon.placed)}}for(const x in g)this.variableOffsets[x]||!this.opacities[x]||this.opacities[x].isHidden()||(this.variableOffsets[x]=g[x]);for(const x in _)this.placedOrientations[x]||!this.opacities[x]||this.opacities[x].isHidden()||(this.placedOrientations[x]=_[x]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");s?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:t)}updateLayerOpacities(t,n){const s={};for(const c of n){const p=c.getBucket(t);p&&c.latestFeatureIndex&&t.id===p.layerIds[0]&&this.updateBucketOpacities(p,s,c.collisionBoxArray)}}updateBucketOpacities(t,n,s){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const c=t.layers[0],p=c.layout,g=new ie(null,0,!1,!1,!0),_=p.get("text-allow-overlap"),x=p.get("icon-allow-overlap"),b=c._unevaluatedLayout.hasValue("text-variable-anchor")||c._unevaluatedLayout.hasValue("text-variable-anchor-offset"),T=p.get("text-rotation-alignment")==="map",I=p.get("text-pitch-alignment")==="map",P=p.get("icon-text-fit")!=="none",V=new ie(null,0,_&&(x||!t.hasIconData()||p.get("icon-optional")),x&&(_||!t.hasTextData()||p.get("text-optional")),!0);!t.collisionArrays&&s&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(s);const N=($,B,ee)=>{for(let se=0;se<B/4;se++)$.opacityVertexArray.emplaceBack(ee);$.hasVisibleVertices=$.hasVisibleVertices||ee!==or};for(let $=0;$<t.symbolInstances.length;$++){const B=t.symbolInstances.get($),{numHorizontalGlyphVertices:ee,numVerticalGlyphVertices:se,crossTileID:G}=B;let te=this.opacities[G];n[G]?te=g:te||(te=V,this.opacities[G]=te),n[G]=!0;const ce=B.numIconVertices>0,ue=this.placedOrientations[B.crossTileID],me=ue===l.ai.vertical,be=ue===l.ai.horizontal||ue===l.ai.horizontalOnly;if(ee>0||se>0){const xe=ui(te.text);N(t.text,ee,me?or:xe),N(t.text,se,be?or:xe);const Te=te.text.isHidden();[B.rightJustifiedTextSymbolIndex,B.centerJustifiedTextSymbolIndex,B.leftJustifiedTextSymbolIndex].forEach((Ee=>{Ee>=0&&(t.text.placedSymbolArray.get(Ee).hidden=Te||me?1:0)})),B.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(B.verticalPlacedTextSymbolIndex).hidden=Te||be?1:0);const Be=this.variableOffsets[B.crossTileID];Be&&this.markUsedJustification(t,Be.anchor,B,ue);const ut=this.placedOrientations[B.crossTileID];ut&&(this.markUsedJustification(t,"left",B,ut),this.markUsedOrientation(t,ut,B))}if(ce){const xe=ui(te.icon),Te=!(P&&B.verticalPlacedIconSymbolIndex&&me);B.placedIconSymbolIndex>=0&&(N(t.icon,B.numIconVertices,Te?xe:or),t.icon.placedSymbolArray.get(B.placedIconSymbolIndex).hidden=te.icon.isHidden()),B.verticalPlacedIconSymbolIndex>=0&&(N(t.icon,B.numVerticalIconVertices,Te?or:xe),t.icon.placedSymbolArray.get(B.verticalPlacedIconSymbolIndex).hidden=te.icon.isHidden())}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const xe=t.collisionArrays[$];if(xe){let Te=new l.P(0,0);if(xe.textBox||xe.verticalTextBox){let ut=!0;if(b){const Ee=this.variableOffsets[G];Ee?(Te=Je(Ee.anchor,Ee.width,Ee.height,Ee.textOffset,Ee.textBoxScale),T&&Te._rotate(I?this.transform.angle:-this.transform.angle)):ut=!1}xe.textBox&&tt(t.textCollisionBox.collisionVertexArray,te.text.placed,!ut||me,Te.x,Te.y),xe.verticalTextBox&&tt(t.textCollisionBox.collisionVertexArray,te.text.placed,!ut||be,Te.x,Te.y)}const Be=!!(!be&&xe.verticalIconBox);xe.iconBox&&tt(t.iconCollisionBox.collisionVertexArray,te.icon.placed,Be,P?Te.x:0,P?Te.y:0),xe.verticalIconBox&&tt(t.iconCollisionBox.collisionVertexArray,te.icon.placed,!Be,P?Te.x:0,P?Te.y:0)}}}if(t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);if(t.bucketInstanceId in this.collisionCircleArrays){const $=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=$.invProjMatrix,t.placementViewportMatrix=$.viewportMatrix,t.collisionCircleArray=$.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return this.fadeDuration===0?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,n){const s=this.zoomAtLastRecencyCheck===n?1-this.zoomAdjustment(n):1;return this.zoomAtLastRecencyCheck=n,this.commitTime+this.fadeDuration*s>t}setStale(){this.stale=!0}}function tt(u,t,n,s,c){u.emplaceBack(t?1:0,n?1:0,s||0,c||0),u.emplaceBack(t?1:0,n?1:0,s||0,c||0),u.emplaceBack(t?1:0,n?1:0,s||0,c||0),u.emplaceBack(t?1:0,n?1:0,s||0,c||0)}const bt=Math.pow(2,25),Tt=Math.pow(2,24),gt=Math.pow(2,17),mt=Math.pow(2,16),mi=Math.pow(2,9),kt=Math.pow(2,8),Yt=Math.pow(2,1);function ui(u){if(u.opacity===0&&!u.placed)return 0;if(u.opacity===1&&u.placed)return 4294967295;const t=u.placed?1:0,n=Math.floor(127*u.opacity);return n*bt+t*Tt+n*gt+t*mt+n*mi+t*kt+n*Yt+t}const or=0;class Go{constructor(t){this._sortAcrossTiles=t.layout.get("symbol-z-order")!=="viewport-y"&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,n,s,c,p){const g=this._bucketParts;for(;this._currentTileIndex<t.length;)if(n.getBucketParts(g,c,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,p())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,g.sort(((_,x)=>_.sortKey-x.sortKey)));this._currentPartIndex<g.length;)if(n.placeLayerBucketPart(g[this._currentPartIndex],this._seenCrossTileIDs,s),this._currentPartIndex++,p())return!0;return!1}}class Un{constructor(t,n,s,c,p,g,_,x){this.placement=new Ge(t,n,g,_,x),this._currentPlacementIndex=s.length-1,this._forceFullPlacement=c,this._showCollisionBoxes=p,this._done=!1}isDone(){return this._done}continuePlacement(t,n,s){const c=l.h.now(),p=()=>!this._forceFullPlacement&&l.h.now()-c>2;for(;this._currentPlacementIndex>=0;){const g=n[t[this._currentPlacementIndex]],_=this.placement.collisionIndex.transform.zoom;if(g.type==="symbol"&&(!g.minzoom||g.minzoom<=_)&&(!g.maxzoom||g.maxzoom>_)){if(this._inProgressLayer||(this._inProgressLayer=new Go(g)),this._inProgressLayer.continuePlacement(s[g.source],this.placement,this._showCollisionBoxes,g,p))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const $n=512/l.N/2;class dc{constructor(t,n,s){this.tileID=t,this.bucketInstanceId=s,this._symbolsByKey={};const c=new Map;for(let p=0;p<n.length;p++){const g=n.get(p),_=g.key,x=c.get(_);x?x.push(g):c.set(_,[g])}for(const[p,g]of c){const _={positions:g.map((x=>({x:Math.floor(x.anchorX*$n),y:Math.floor(x.anchorY*$n)}))),crossTileIDs:g.map((x=>x.crossTileID))};if(_.positions.length>128){const x=new l.av(_.positions.length,16,Uint16Array);for(const{x:b,y:T}of _.positions)x.add(b,T);x.finish(),delete _.positions,_.index=x}this._symbolsByKey[p]=_}}getScaledCoordinates(t,n){const{x:s,y:c,z:p}=this.tileID.canonical,{x:g,y:_,z:x}=n.canonical,b=$n/Math.pow(2,x-p),T=(_*l.N+t.anchorY)*b,I=c*l.N*$n;return{x:Math.floor((g*l.N+t.anchorX)*b-s*l.N*$n),y:Math.floor(T-I)}}findMatches(t,n,s){const c=this.tileID.canonical.z<n.canonical.z?1:Math.pow(2,this.tileID.canonical.z-n.canonical.z);for(let p=0;p<t.length;p++){const g=t.get(p);if(g.crossTileID)continue;const _=this._symbolsByKey[g.key];if(!_)continue;const x=this.getScaledCoordinates(g,n);if(_.index){const b=_.index.range(x.x-c,x.y-c,x.x+c,x.y+c).sort();for(const T of b){const I=_.crossTileIDs[T];if(!s[I]){s[I]=!0,g.crossTileID=I;break}}}else if(_.positions)for(let b=0;b<_.positions.length;b++){const T=_.positions[b],I=_.crossTileIDs[b];if(Math.abs(T.x-x.x)<=c&&Math.abs(T.y-x.y)<=c&&!s[I]){s[I]=!0,g.crossTileID=I;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:t})=>t))}}class wt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Ps{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const n=Math.round((t-this.lng)/360);if(n!==0)for(const s in this.indexes){const c=this.indexes[s],p={};for(const g in c){const _=c[g];_.tileID=_.tileID.unwrapTo(_.tileID.wrap+n),p[_.tileID.key]=_}this.indexes[s]=p}this.lng=t}addBucket(t,n,s){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let p=0;p<n.symbolInstances.length;p++)n.symbolInstances.get(p).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const c=this.usedCrossTileIDs[t.overscaledZ];for(const p in this.indexes){const g=this.indexes[p];if(Number(p)>t.overscaledZ)for(const _ in g){const x=g[_];x.tileID.isChildOf(t)&&x.findMatches(n.symbolInstances,t,c)}else{const _=g[t.scaledTo(Number(p)).key];_&&_.findMatches(n.symbolInstances,t,c)}}for(let p=0;p<n.symbolInstances.length;p++){const g=n.symbolInstances.get(p);g.crossTileID||(g.crossTileID=s.generate(),c[g.crossTileID]=!0)}return this.indexes[t.overscaledZ]===void 0&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new dc(t,n.symbolInstances,n.bucketInstanceId),!0}removeBucketCrossTileIDs(t,n){for(const s of n.getCrossTileIDsLists())for(const c of s)delete this.usedCrossTileIDs[t][c]}removeStaleBuckets(t){let n=!1;for(const s in this.indexes){const c=this.indexes[s];for(const p in c)t[c[p].bucketInstanceId]||(this.removeBucketCrossTileIDs(s,c[p]),delete c[p],n=!0)}return n}}class Va{constructor(){this.layerIndexes={},this.crossTileIDs=new wt,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,n,s){let c=this.layerIndexes[t.id];c===void 0&&(c=this.layerIndexes[t.id]=new Ps);let p=!1;const g={};c.handleWrapJump(s);for(const _ of n){const x=_.getBucket(t);x&&t.id===x.layerIds[0]&&(x.bucketInstanceId||(x.bucketInstanceId=++this.maxBucketInstanceId),c.addBucket(_.tileID,x,this.crossTileIDs)&&(p=!0),g[x.bucketInstanceId]=!0)}return c.removeStaleBuckets(g)&&(p=!0),p}pruneUnusedLayers(t){const n={};t.forEach((s=>{n[s]=!0}));for(const s in this.layerIndexes)n[s]||delete this.layerIndexes[s]}}const gi=(u,t)=>l.x(u,t&&t.filter((n=>n.identifier!=="source.canvas"))),Gi=l.F(l.ax,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setGlyphs","setSprite"]),fc=l.F(l.ax,["setCenter","setZoom","setBearing","setPitch"]),lr=l.aw();class hi extends l.E{constructor(t,n={}){super(),this.map=t,this.dispatcher=new ca(Na(),this,t._getMapId()),this.imageManager=new Vt,this.imageManager.setEventedParent(this),this.glyphManager=new zr(t._requestManager,n.localIdeographFontFamily),this.lineAtlas=new Oa(256,512),this.crossTileSymbolIndex=new Va,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new l.ay,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("setReferrer",l.az());const s=this;this._rtlTextPluginCallback=hi.registerForPluginStateChange((c=>{s.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:c.pluginStatus,pluginURL:c.pluginURL},((p,g)=>{if(l.aA(p),g&&g.every((_=>_)))for(const _ in s.sourceCaches){const x=s.sourceCaches[_].getSource().type;x!=="vector"&&x!=="geojson"||s.sourceCaches[_].reload()}}))})),this.on("data",(c=>{if(c.dataType!=="source"||c.sourceDataType!=="metadata")return;const p=this.sourceCaches[c.sourceId];if(!p)return;const g=p.getSource();if(g&&g.vectorLayerIds)for(const _ in this._layers){const x=this._layers[_];x.source===g.id&&this._validateLayer(x)}}))}loadURL(t,n={},s){this.fire(new l.k("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const c=this.map._requestManager.transformRequest(t,Ye.Style);this._request=l.f(c,((p,g)=>{this._request=null,p?this.fire(new l.j(p)):g&&this._load(g,n,s)}))}loadJSON(t,n={},s){this.fire(new l.k("dataloading",{dataType:"style"})),this._request=l.h.frame((()=>{this._request=null,n.validate=n.validate!==!1,this._load(t,n,s)}))}loadEmpty(){this.fire(new l.k("dataloading",{dataType:"style"})),this._load(lr,{validate:!1})}_load(t,n,s){var c;const p=n.transformStyle?n.transformStyle(s,t):t;if(!n.validate||!gi(this,l.y(p))){this._loaded=!0,this.stylesheet=p;for(const g in p.sources)this.addSource(g,p.sources[g],{validate:!1});p.sprite?this._loadSprite(p.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(p.glyphs),this._createLayers(),this.light=new la(this.stylesheet.light),this.map.setTerrain((c=this.stylesheet.terrain)!==null&&c!==void 0?c:null),this.fire(new l.k("data",{dataType:"style"})),this.fire(new l.k("style.load"))}}_createLayers(){const t=l.aB(this.stylesheet.layers);this.dispatcher.broadcast("setLayers",t),this._order=t.map((n=>n.id)),this._layers={},this._serializedLayers=null;for(const n of t){const s=l.aC(n);s.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=s}}_loadSprite(t,n=!1,s=void 0){this.imageManager.setLoaded(!1),this._spriteRequest=(function(c,p,g,_){const x=Ve(c),b=x.length,T=g>1?"@2x":"",I={},P={},V={};for(const{id:N,url:$}of x){const B=p.transformRequest(p.normalizeSpriteURL($,T,".json"),Ye.SpriteJSON),ee=`${N}_${B.url}`;I[ee]=l.f(B,((te,ce)=>{delete I[ee],P[N]=ce,it(_,P,V,te,b)}));const se=p.transformRequest(p.normalizeSpriteURL($,T,".png"),Ye.SpriteImage),G=`${N}_${se.url}`;I[G]=Ke.getImage(se,((te,ce)=>{delete I[G],V[N]=ce,it(_,P,V,te,b)}))}return{cancel(){for(const N of Object.values(I))N.cancel()}}})(t,this.map._requestManager,this.map.getPixelRatio(),((c,p)=>{if(this._spriteRequest=null,c)this.fire(new l.j(c));else if(p)for(const g in p){this._spritesImagesIds[g]=[];const _=this._spritesImagesIds[g]?this._spritesImagesIds[g].filter((x=>!(x in p))):[];for(const x of _)this.imageManager.removeImage(x),this._changedImages[x]=!0;for(const x in p[g]){const b=g==="default"?x:`${g}:${x}`;this._spritesImagesIds[g].push(b),b in this.imageManager.images?this.imageManager.updateImage(b,p[g][x],!1):this.imageManager.addImage(b,p[g][x]),n&&(this._changedImages[b]=!0)}}this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new l.k("data",{dataType:"style"})),s&&s(c)}))}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new l.k("data",{dataType:"style"}))}_validateLayer(t){const n=this.sourceCaches[t.source];if(!n)return;const s=t.sourceLayer;if(!s)return;const c=n.getSource();(c.type==="geojson"||c.vectorLayerIds&&c.vectorLayerIds.indexOf(s)===-1)&&this.fire(new l.j(new Error(`Source layer "${s}" does not exist on source "${c.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(t){const n=this._serializedAllLayers();if(!t||t.length===0)return Object.values(n);const s=[];for(const c of t)n[c]&&s.push(n[c]);return s}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const n=Object.keys(this._layers);for(const s of n){const c=this._layers[s];c.type!=="custom"&&(t[s]=c.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;for(const t in this.sourceCaches)if(this.sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const n=this._changed;if(this._changed){const c=Object.keys(this._updatedLayers),p=Object.keys(this._removedLayers);(c.length||p.length)&&this._updateWorkerLayers(c,p);for(const g in this._updatedSources){const _=this._updatedSources[g];if(_==="reload")this._reloadSource(g);else{if(_!=="clear")throw new Error(`Invalid action ${_}`);this._clearSource(g)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const g in this._updatedPaintProps)this._layers[g].updateTransitions(t);this.light.updateTransitions(t),this._resetUpdates()}const s={};for(const c in this.sourceCaches){const p=this.sourceCaches[c];s[c]=p.used,p.used=!1}for(const c of this._order){const p=this._layers[c];p.recalculate(t,this._availableImages),!p.isHidden(t.zoom)&&p.source&&(this.sourceCaches[p.source].used=!0)}for(const c in s){const p=this.sourceCaches[c];s[c]!==p.used&&p.fire(new l.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:c}))}this.light.recalculate(t),this.z=t.zoom,n&&this.fire(new l.k("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const n in this.sourceCaches)this.sourceCaches[n].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,n){this.dispatcher.broadcast("updateLayers",{layers:this._serializeByIds(t),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,n={}){this._checkLoaded();const s=this.serialize();if(t=n.transformStyle?n.transformStyle(s,t):t,gi(this,l.y(t)))return!1;(t=l.aD(t)).layers=l.aB(t.layers);const c=l.aE(s,t).filter((g=>!(g.command in fc)));if(c.length===0)return!1;const p=c.filter((g=>!(g.command in Gi)));if(p.length>0)throw new Error(`Unimplemented: ${p.map((g=>g.command)).join(", ")}.`);for(const g of c)g.command!=="setTransition"&&this[g.command].apply(this,g.args);return this.stylesheet=t,this._serializedLayers=null,!0}addImage(t,n){if(this.getImage(t))return this.fire(new l.j(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,n),this._afterImageUpdated(t)}updateImage(t,n){this.imageManager.updateImage(t,n)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new l.j(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new l.k("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,n,s={}){if(this._checkLoaded(),this.sourceCaches[t]!==void 0)throw new Error(`Source "${t}" already exists.`);if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(l.y.source,`sources.${t}`,n,null,s))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const c=this.sourceCaches[t]=new Di(t,n,this.dispatcher);c.style=this,c.setEventedParent(this,(()=>({isSourceLoaded:c.loaded(),source:c.serialize(),sourceId:t}))),c.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),this.sourceCaches[t]===void 0)throw new Error("There is no source with this ID");for(const s in this._layers)if(this._layers[s].source===t)return this.fire(new l.j(new Error(`Source "${t}" cannot be removed while layer "${s}" is using it.`)));const n=this.sourceCaches[t];delete this.sourceCaches[t],delete this._updatedSources[t],n.fire(new l.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,n){if(this._checkLoaded(),this.sourceCaches[t]===void 0)throw new Error(`There is no source with this ID=${t}`);const s=this.sourceCaches[t].getSource();if(s.type!=="geojson")throw new Error(`geojsonSource.type is ${s.type}, which is !== 'geojson`);s.setData(n),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(t,n,s={}){this._checkLoaded();const c=t.id;if(this.getLayer(c))return void this.fire(new l.j(new Error(`Layer "${c}" already exists on this map.`)));let p;if(t.type==="custom"){if(gi(this,l.aF(t)))return;p=l.aC(t)}else{if("source"in t&&typeof t.source=="object"&&(this.addSource(c,t.source),t=l.aD(t),t=l.e(t,{source:c})),this._validate(l.y.layer,`layers.${c}`,t,{arrayIndex:-1},s))return;p=l.aC(t),this._validateLayer(p),p.setEventedParent(this,{layer:{id:c}})}const g=n?this._order.indexOf(n):this._order.length;if(n&&g===-1)this.fire(new l.j(new Error(`Cannot add layer "${c}" before non-existing layer "${n}".`)));else{if(this._order.splice(g,0,c),this._layerOrderChanged=!0,this._layers[c]=p,this._removedLayers[c]&&p.source&&p.type!=="custom"){const _=this._removedLayers[c];delete this._removedLayers[c],_.type!==p.type?this._updatedSources[p.source]="clear":(this._updatedSources[p.source]="reload",this.sourceCaches[p.source].pause())}this._updateLayer(p),p.onAdd&&p.onAdd(this.map)}}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new l.j(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===n)return;const s=this._order.indexOf(t);this._order.splice(s,1);const c=n?this._order.indexOf(n):this._order.length;n&&c===-1?this.fire(new l.j(new Error(`Cannot move layer "${t}" before non-existing layer "${n}".`))):(this._order.splice(c,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const n=this._layers[t];if(!n)return void this.fire(new l.j(new Error(`Cannot remove non-existing layer "${t}".`)));n.setEventedParent(null);const s=this._order.indexOf(t);this._order.splice(s,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,n,s){this._checkLoaded();const c=this.getLayer(t);c?c.minzoom===n&&c.maxzoom===s||(n!=null&&(c.minzoom=n),s!=null&&(c.maxzoom=s),this._updateLayer(c)):this.fire(new l.j(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,n,s={}){this._checkLoaded();const c=this.getLayer(t);if(c){if(!l.aG(c.filter,n))return n==null?(c.filter=void 0,void this._updateLayer(c)):void(this._validate(l.y.filter,`layers.${c.id}.filter`,n,null,s)||(c.filter=l.aD(n),this._updateLayer(c)))}else this.fire(new l.j(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return l.aD(this.getLayer(t).filter)}setLayoutProperty(t,n,s,c={}){this._checkLoaded();const p=this.getLayer(t);p?l.aG(p.getLayoutProperty(n),s)||(p.setLayoutProperty(n,s,c),this._updateLayer(p)):this.fire(new l.j(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,n){const s=this.getLayer(t);if(s)return s.getLayoutProperty(n);this.fire(new l.j(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,n,s,c={}){this._checkLoaded();const p=this.getLayer(t);p?l.aG(p.getPaintProperty(n),s)||(p.setPaintProperty(n,s,c)&&this._updateLayer(p),this._changed=!0,this._updatedPaintProps[t]=!0):this.fire(new l.j(new Error(`Cannot style non-existing layer "${t}".`)))}getPaintProperty(t,n){return this.getLayer(t).getPaintProperty(n)}setFeatureState(t,n){this._checkLoaded();const s=t.source,c=t.sourceLayer,p=this.sourceCaches[s];if(p===void 0)return void this.fire(new l.j(new Error(`The source '${s}' does not exist in the map's style.`)));const g=p.getSource().type;g==="geojson"&&c?this.fire(new l.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):g!=="vector"||c?(t.id===void 0&&this.fire(new l.j(new Error("The feature id parameter must be provided."))),p.setFeatureState(c,t.id,n)):this.fire(new l.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,n){this._checkLoaded();const s=t.source,c=this.sourceCaches[s];if(c===void 0)return void this.fire(new l.j(new Error(`The source '${s}' does not exist in the map's style.`)));const p=c.getSource().type,g=p==="vector"?t.sourceLayer:void 0;p!=="vector"||g?n&&typeof t.id!="string"&&typeof t.id!="number"?this.fire(new l.j(new Error("A feature id is required to remove its specific state property."))):c.removeFeatureState(g,t.id,n):this.fire(new l.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const n=t.source,s=t.sourceLayer,c=this.sourceCaches[n];if(c!==void 0)return c.getSource().type!=="vector"||s?(t.id===void 0&&this.fire(new l.j(new Error("The feature id parameter must be provided."))),c.getFeatureState(s,t.id)):void this.fire(new l.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new l.j(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return l.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=l.aH(this.sourceCaches,(p=>p.serialize())),n=this._serializeByIds(this._order),s=this.map.getTerrain()||void 0,c=this.stylesheet;return l.aI({version:c.version,name:c.name,metadata:c.metadata,light:c.light,center:c.center,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch,sprite:c.sprite,glyphs:c.glyphs,transition:c.transition,sources:t,layers:n,terrain:s},(p=>p!==void 0))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&this.sourceCaches[t.source].getSource().type!=="raster"&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){const n=g=>this._layers[g].type==="fill-extrusion",s={},c=[];for(let g=this._order.length-1;g>=0;g--){const _=this._order[g];if(n(_)){s[_]=g;for(const x of t){const b=x[_];if(b)for(const T of b)c.push(T)}}}c.sort(((g,_)=>_.intersectionZ-g.intersectionZ));const p=[];for(let g=this._order.length-1;g>=0;g--){const _=this._order[g];if(n(_))for(let x=c.length-1;x>=0;x--){const b=c[x].feature;if(s[b.layer.id]<g)break;p.push(b),c.pop()}else for(const x of t){const b=x[_];if(b)for(const T of b)p.push(T.feature)}}return p}queryRenderedFeatures(t,n,s){n&&n.filter&&this._validate(l.y.filter,"queryRenderedFeatures.filter",n.filter,null,n);const c={};if(n&&n.layers){if(!Array.isArray(n.layers))return this.fire(new l.j(new Error("parameters.layers must be an Array."))),[];for(const _ of n.layers){const x=this._layers[_];if(!x)return this.fire(new l.j(new Error(`The layer '${_}' does not exist in the map's style and cannot be queried for features.`))),[];c[x.source]=!0}}const p=[];n.availableImages=this._availableImages;const g=this._serializedAllLayers();for(const _ in this.sourceCaches)n.layers&&!c[_]||p.push(fn(this.sourceCaches[_],this._layers,g,t,n,s));return this.placement&&p.push((function(_,x,b,T,I,P,V){const N={},$=P.queryRenderedSymbols(T),B=[];for(const ee of Object.keys($).map(Number))B.push(V[ee]);B.sort(Kr);for(const ee of B){const se=ee.featureIndex.lookupSymbolFeatures($[ee.bucketInstanceId],x,ee.bucketIndex,ee.sourceLayerIndex,I.filter,I.layers,I.availableImages,_);for(const G in se){const te=N[G]=N[G]||[],ce=se[G];ce.sort(((ue,me)=>{const be=ee.featureSortOrder;if(be){const xe=be.indexOf(ue.featureIndex);return be.indexOf(me.featureIndex)-xe}return me.featureIndex-ue.featureIndex}));for(const ue of ce)te.push(ue)}}for(const ee in N)N[ee].forEach((se=>{const G=se.feature,te=b[_[ee].source].getFeatureState(G.layer["source-layer"],G.id);G.source=G.layer.source,G.layer["source-layer"]&&(G.sourceLayer=G.layer["source-layer"]),G.state=te}));return N})(this._layers,g,this.sourceCaches,t,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(p)}querySourceFeatures(t,n){n&&n.filter&&this._validate(l.y.filter,"querySourceFeatures.filter",n.filter,null,n);const s=this.sourceCaches[t];return s?(function(c,p){const g=c.getRenderableIds().map((b=>c.getTileByID(b))),_=[],x={};for(let b=0;b<g.length;b++){const T=g[b],I=T.tileID.canonical.key;x[I]||(x[I]=!0,T.querySourceFeatures(_,p))}return _})(s,n):[]}addSourceType(t,n,s){return Dr(t)?s(new Error(`A source type called "${t}" already exists.`)):(((c,p)=>{ha[c]=p})(t,n),n.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:n.workerSourceURL},s):s(null,null))}getLight(){return this.light.getLight()}setLight(t,n={}){this._checkLoaded();const s=this.light.getLight();let c=!1;for(const g in t)if(!l.aG(t[g],s[g])){c=!0;break}if(!c)return;const p={now:l.h.now(),transition:l.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,n),this.light.updateTransitions(p)}_validate(t,n,s,c,p={}){return(!p||p.validate!==!1)&&gi(this,t.call(l.y,l.e({key:n,style:this.serialize(),value:s,styleSpec:l.v},c)))}_remove(t=!0){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),l.aJ.off("pluginStateChange",this._rtlTextPluginCallback);for(const n in this._layers)this._layers[n].setEventedParent(null);for(const n in this.sourceCaches){const s=this.sourceCaches[n];s.setEventedParent(null),s.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove(t)}_clearSource(t){this.sourceCaches[t].clearTiles()}_reloadSource(t){this.sourceCaches[t].resume(),this.sourceCaches[t].reload()}_updateSources(t){for(const n in this.sourceCaches)this.sourceCaches[n].update(t,this.map.terrain)}_generateCollisionBoxes(){for(const t in this.sourceCaches)this._reloadSource(t)}_updatePlacement(t,n,s,c,p=!1){let g=!1,_=!1;const x={};for(const b of this._order){const T=this._layers[b];if(T.type!=="symbol")continue;if(!x[T.source]){const P=this.sourceCaches[T.source];x[T.source]=P.getRenderableIds(!0).map((V=>P.getTileByID(V))).sort(((V,N)=>N.tileID.overscaledZ-V.tileID.overscaledZ||(V.tileID.isLessThan(N.tileID)?-1:1)))}const I=this.crossTileSymbolIndex.addLayer(T,x[T.source],t.center.lng);g=g||I}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((p=p||this._layerOrderChanged||s===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(l.h.now(),t.zoom))&&(this.pauseablePlacement=new Un(t,this.map.terrain,this._order,p,n,s,c,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,x),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(l.h.now()),_=!0),g&&this.pauseablePlacement.placement.setStale()),_||g)for(const b of this._order){const T=this._layers[b];T.type==="symbol"&&this.placement.updateLayerOpacities(T,x[T.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(l.h.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,n,s){this.imageManager.getImages(n.icons,s),this._updateTilesForChangedImages();const c=this.sourceCaches[n.source];c&&c.setDependencies(n.tileID.key,n.type,n.icons)}getGlyphs(t,n,s){this.glyphManager.getGlyphs(n.stacks,s);const c=this.sourceCaches[n.source];c&&c.setDependencies(n.tileID.key,n.type,[""])}getResource(t,n,s){return l.m(n,s)}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,n={}){this._checkLoaded(),t&&this._validate(l.y.glyphs,"glyphs",t,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}addSprite(t,n,s={},c){this._checkLoaded();const p=[{id:t,url:n}],g=[...Ve(this.stylesheet.sprite),...p];this._validate(l.y.sprite,"sprite",g,null,s)||(this.stylesheet.sprite=g,this._loadSprite(p,!0,c))}removeSprite(t){this._checkLoaded();const n=Ve(this.stylesheet.sprite);if(n.find((s=>s.id===t))){if(this._spritesImagesIds[t])for(const s of this._spritesImagesIds[t])this.imageManager.removeImage(s),this._changedImages[s]=!0;n.splice(n.findIndex((s=>s.id===t)),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new l.k("data",{dataType:"style"}))}else this.fire(new l.j(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return Ve(this.stylesheet.sprite)}setSprite(t,n={},s){this._checkLoaded(),t&&this._validate(l.y.sprite,"sprite",t,null,n)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,s):(this._unloadSprite(),s&&s(null)))}}hi.registerForPluginStateChange=l.aK;var Ua=l.Q([{name:"a_pos",type:"Int16",components:2}]),jn="attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_depth;void main() {float extent=8192.0;float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/extent;gl_Position=u_matrix*vec4(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}";const Rt={prelude:yt(`#ifdef GL_ES
precision mediump float;
#else
#if !defined(lowp)
#define lowp
#endif
#if !defined(mediump)
#define mediump
#endif
#if !defined(highp)
#define highp
#endif
#endif
`,`#ifdef GL_ES
precision highp float;
#else
#if !defined(lowp)
#define lowp
#endif
#if !defined(mediump)
#define mediump
#endif
#if !defined(highp)
#define highp
#endif
#endif
vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}
#ifdef TERRAIN3D
uniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;
#endif
const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {
#ifdef TERRAIN3D
highp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));
#else
return 1.0;
#endif
}float calculate_visibility(vec4 pos) {
#ifdef TERRAIN3D
vec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;
#else
return 1.0;
#endif
}float ele(vec2 pos) {
#ifdef TERRAIN3D
vec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;
#else
return 0.0;
#endif
}float get_elevation(vec2 pos) {
#ifdef TERRAIN3D
vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;
#else
return 0.0;
#endif
}`),background:yt(`uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,"attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:yt(`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,"uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:yt(`varying vec3 v_data;varying float v_visibility;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define mediump float radius
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define highp vec4 stroke_color
#pragma mapbox: define mediump float stroke_width
#pragma mapbox: define lowp float stroke_opacity
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize mediump float radius
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize highp vec4 stroke_color
#pragma mapbox: initialize mediump float stroke_width
#pragma mapbox: initialize lowp float stroke_opacity
vec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define mediump float radius
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define highp vec4 stroke_color
#pragma mapbox: define mediump float stroke_width
#pragma mapbox: define lowp float stroke_opacity
void main(void) {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize mediump float radius
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize highp vec4 stroke_color
#pragma mapbox: initialize mediump float stroke_width
#pragma mapbox: initialize lowp float stroke_opacity
vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}`),clippingMask:yt("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:yt(`uniform highp float u_intensity;varying vec2 v_extrude;
#pragma mapbox: define highp float weight
#define GAUSS_COEF 0.3989422804014327
void main() {
#pragma mapbox: initialize highp float weight
float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude;
#pragma mapbox: define highp float weight
#pragma mapbox: define mediump float radius
const highp float ZERO=1.0/255.0/16.0;
#define GAUSS_COEF 0.3989422804014327
void main(void) {
#pragma mapbox: initialize highp float weight
#pragma mapbox: initialize mediump float radius
vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,0,1);gl_Position=u_matrix*pos;}`),heatmapTexture:yt(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(0.0);
#endif
}`,"uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:yt("varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}","attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:yt("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:yt("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}"),fill:yt(`#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float opacity
gl_FragColor=color*opacity;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`attribute vec2 a_pos;uniform mat4 u_matrix;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float opacity
gl_Position=u_matrix*vec4(a_pos,0,1);}`),fillOutline:yt(`varying vec2 v_pos;
#pragma mapbox: define highp vec4 outline_color
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize highp vec4 outline_color
#pragma mapbox: initialize lowp float opacity
float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;
#pragma mapbox: define highp vec4 outline_color
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize highp vec4 outline_color
#pragma mapbox: initialize lowp float opacity
gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}`),fillOutlinePattern:yt(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp vec4 pattern_from
#pragma mapbox: define lowp vec4 pattern_to
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump vec4 pattern_from
#pragma mapbox: initialize mediump vec4 pattern_to
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp vec4 pattern_from
#pragma mapbox: define lowp vec4 pattern_to
#pragma mapbox: define lowp float pixel_ratio_from
#pragma mapbox: define lowp float pixel_ratio_to
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump vec4 pattern_from
#pragma mapbox: initialize mediump vec4 pattern_to
#pragma mapbox: initialize lowp float pixel_ratio_from
#pragma mapbox: initialize lowp float pixel_ratio_to
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}`),fillPattern:yt(`#ifdef GL_ES
precision highp float;
#endif
uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp vec4 pattern_from
#pragma mapbox: define lowp vec4 pattern_to
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump vec4 pattern_from
#pragma mapbox: initialize mediump vec4 pattern_to
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp vec4 pattern_from
#pragma mapbox: define lowp vec4 pattern_to
#pragma mapbox: define lowp float pixel_ratio_from
#pragma mapbox: define lowp float pixel_ratio_to
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump vec4 pattern_from
#pragma mapbox: initialize mediump vec4 pattern_to
#pragma mapbox: initialize lowp float pixel_ratio_from
#pragma mapbox: initialize lowp float pixel_ratio_to
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}`),fillExtrusion:yt(`varying vec4 v_color;void main() {gl_FragColor=v_color;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed;
#ifdef TERRAIN3D
attribute vec2 a_centroid;
#endif
varying vec4 v_color;
#pragma mapbox: define highp float base
#pragma mapbox: define highp float height
#pragma mapbox: define highp vec4 color
void main() {
#pragma mapbox: initialize highp float base
#pragma mapbox: initialize highp float height
#pragma mapbox: initialize highp vec4 color
vec3 normal=a_normal_ed.xyz;
#ifdef TERRAIN3D
float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
#else
float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
#endif
base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}`),fillExtrusionPattern:yt(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;
#pragma mapbox: define lowp float base
#pragma mapbox: define lowp float height
#pragma mapbox: define lowp vec4 pattern_from
#pragma mapbox: define lowp vec4 pattern_to
#pragma mapbox: define lowp float pixel_ratio_from
#pragma mapbox: define lowp float pixel_ratio_to
void main() {
#pragma mapbox: initialize lowp float base
#pragma mapbox: initialize lowp float height
#pragma mapbox: initialize mediump vec4 pattern_from
#pragma mapbox: initialize mediump vec4 pattern_to
#pragma mapbox: initialize lowp float pixel_ratio_from
#pragma mapbox: initialize lowp float pixel_ratio_to
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;
#ifdef TERRAIN3D
attribute vec2 a_centroid;
#endif
varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;
#pragma mapbox: define lowp float base
#pragma mapbox: define lowp float height
#pragma mapbox: define lowp vec4 pattern_from
#pragma mapbox: define lowp vec4 pattern_to
#pragma mapbox: define lowp float pixel_ratio_from
#pragma mapbox: define lowp float pixel_ratio_to
void main() {
#pragma mapbox: initialize lowp float base
#pragma mapbox: initialize lowp float height
#pragma mapbox: initialize mediump vec4 pattern_from
#pragma mapbox: initialize mediump vec4 pattern_to
#pragma mapbox: initialize lowp float pixel_ratio_from
#pragma mapbox: initialize lowp float pixel_ratio_to
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;
#ifdef TERRAIN3D
float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
#else
float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
#endif
base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0
? a_pos
: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}`),hillshadePrepare:yt(`#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,"uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:yt(`uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;
#define PI 3.141592653589793
void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,"uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}"),line:yt(`uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`
#define scale 0.015873016
attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define mediump float gapwidth
#pragma mapbox: define lowp float offset
#pragma mapbox: define mediump float width
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump float gapwidth
#pragma mapbox: initialize lowp float offset
#pragma mapbox: initialize mediump float width
float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;
#ifdef TERRAIN3D
v_gamma_scale=1.0;
#else
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
#endif
v_width2=vec2(outset,inset);}`),lineGradient:yt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`
#define scale 0.015873016
attribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define mediump float gapwidth
#pragma mapbox: define lowp float offset
#pragma mapbox: define mediump float width
void main() {
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump float gapwidth
#pragma mapbox: initialize lowp float offset
#pragma mapbox: initialize mediump float width
float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;
#ifdef TERRAIN3D
v_gamma_scale=1.0;
#else
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
#endif
v_width2=vec2(outset,inset);}`),linePattern:yt(`#ifdef GL_ES
precision highp float;
#endif
uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
#pragma mapbox: define lowp vec4 pattern_from
#pragma mapbox: define lowp vec4 pattern_to
#pragma mapbox: define lowp float pixel_ratio_from
#pragma mapbox: define lowp float pixel_ratio_to
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize mediump vec4 pattern_from
#pragma mapbox: initialize mediump vec4 pattern_to
#pragma mapbox: initialize lowp float pixel_ratio_from
#pragma mapbox: initialize lowp float pixel_ratio_to
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`
#define scale 0.015873016
#define LINE_DISTANCE_SCALE 2.0
attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float offset
#pragma mapbox: define mediump float gapwidth
#pragma mapbox: define mediump float width
#pragma mapbox: define lowp float floorwidth
#pragma mapbox: define lowp vec4 pattern_from
#pragma mapbox: define lowp vec4 pattern_to
#pragma mapbox: define lowp float pixel_ratio_from
#pragma mapbox: define lowp float pixel_ratio_to
void main() {
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float offset
#pragma mapbox: initialize mediump float gapwidth
#pragma mapbox: initialize mediump float width
#pragma mapbox: initialize lowp float floorwidth
#pragma mapbox: initialize mediump vec4 pattern_from
#pragma mapbox: initialize mediump vec4 pattern_to
#pragma mapbox: initialize lowp float pixel_ratio_from
#pragma mapbox: initialize lowp float pixel_ratio_to
float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;
#ifdef TERRAIN3D
v_gamma_scale=1.0;
#else
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
#endif
v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:yt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define mediump float width
#pragma mapbox: define lowp float floorwidth
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump float width
#pragma mapbox: initialize lowp float floorwidth
float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`
#define scale 0.015873016
#define LINE_DISTANCE_SCALE 2.0
attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define mediump float gapwidth
#pragma mapbox: define lowp float offset
#pragma mapbox: define mediump float width
#pragma mapbox: define lowp float floorwidth
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump float gapwidth
#pragma mapbox: initialize lowp float offset
#pragma mapbox: initialize mediump float width
#pragma mapbox: initialize lowp float floorwidth
float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;
#ifdef TERRAIN3D
v_gamma_scale=1.0;
#else
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
#endif
v_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}`),raster:yt(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,"uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:yt(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize lowp float opacity
lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize lowp float opacity
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
camera_to_anchor_distance/u_camera_to_center_distance :
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0),z,1.0);v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}`),symbolSDF:yt(`#define SDF_PX 8.0
uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;
#pragma mapbox: define highp vec4 fill_color
#pragma mapbox: define highp vec4 halo_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
void main() {
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;varying vec2 v_data0;varying vec3 v_data1;
#pragma mapbox: define highp vec4 fill_color
#pragma mapbox: define highp vec4 halo_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
void main() {
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
camera_to_anchor_distance/u_camera_to_center_distance :
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}`),symbolTextAndIcon:yt(`#define SDF_PX 8.0
#define SDF 1.0
#define ICON 0.0
uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;
#pragma mapbox: define highp vec4 fill_color
#pragma mapbox: define highp vec4 halo_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
void main() {
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;varying vec4 v_data0;varying vec4 v_data1;
#pragma mapbox: define highp vec4 fill_color
#pragma mapbox: define highp vec4 halo_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
void main() {
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
camera_to_anchor_distance/u_camera_to_center_distance :
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}`),terrain:yt("uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}",jn),terrainDepth:yt("varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}",jn),terrainCoords:yt("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}",jn)};function yt(u,t){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=t.match(/attribute ([\w]+) ([\w]+)/g),c=u.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),p=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),g=p?p.concat(c):c,_={};return{fragmentSource:u=u.replace(n,((x,b,T,I,P)=>(_[P]=!0,b==="define"?`
#ifndef HAS_UNIFORM_u_${P}
varying ${T} ${I} ${P};
#else
uniform ${T} ${I} u_${P};
#endif
`:`
#ifdef HAS_UNIFORM_u_${P}
${T} ${I} ${P} = u_${P};
#endif
`))),vertexSource:t=t.replace(n,((x,b,T,I,P)=>{const V=I==="float"?"vec2":"vec4",N=P.match(/color/)?"color":V;return _[P]?b==="define"?`
#ifndef HAS_UNIFORM_u_${P}
uniform lowp float u_${P}_t;
attribute ${T} ${V} a_${P};
varying ${T} ${I} ${P};
#else
uniform ${T} ${I} u_${P};
#endif
`:N==="vec4"?`
#ifndef HAS_UNIFORM_u_${P}
${P} = a_${P};
#else
${T} ${I} ${P} = u_${P};
#endif
`:`
#ifndef HAS_UNIFORM_u_${P}
${P} = unpack_mix_${N}(a_${P}, u_${P}_t);
#else
${T} ${I} ${P} = u_${P};
#endif
`:b==="define"?`
#ifndef HAS_UNIFORM_u_${P}
uniform lowp float u_${P}_t;
attribute ${T} ${V} a_${P};
#else
uniform ${T} ${I} u_${P};
#endif
`:N==="vec4"?`
#ifndef HAS_UNIFORM_u_${P}
${T} ${I} ${P} = a_${P};
#else
${T} ${I} ${P} = u_${P};
#endif
`:`
#ifndef HAS_UNIFORM_u_${P}
${T} ${I} ${P} = unpack_mix_${N}(a_${P}, u_${P}_t);
#else
${T} ${I} ${P} = u_${P};
#endif
`})),staticAttributes:s,staticUniforms:g}}class yn{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,n,s,c,p,g,_,x,b){this.context=t;let T=this.boundPaintVertexBuffers.length!==c.length;for(let I=0;!T&&I<c.length;I++)this.boundPaintVertexBuffers[I]!==c[I]&&(T=!0);!this.vao||this.boundProgram!==n||this.boundLayoutVertexBuffer!==s||T||this.boundIndexBuffer!==p||this.boundVertexOffset!==g||this.boundDynamicVertexBuffer!==_||this.boundDynamicVertexBuffer2!==x||this.boundDynamicVertexBuffer3!==b?this.freshBind(n,s,c,p,g,_,x,b):(t.bindVertexArray.set(this.vao),_&&_.bind(),p&&p.dynamicDraw&&p.bind(),x&&x.bind(),b&&b.bind())}freshBind(t,n,s,c,p,g,_,x){const b=t.numAttributes,T=this.context,I=T.gl;this.vao&&this.destroy(),this.vao=T.createVertexArray(),T.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=n,this.boundPaintVertexBuffers=s,this.boundIndexBuffer=c,this.boundVertexOffset=p,this.boundDynamicVertexBuffer=g,this.boundDynamicVertexBuffer2=_,this.boundDynamicVertexBuffer3=x,n.enableAttributes(I,t);for(const P of s)P.enableAttributes(I,t);g&&g.enableAttributes(I,t),_&&_.enableAttributes(I,t),x&&x.enableAttributes(I,t),n.bind(),n.setVertexAttribPointers(I,t,p);for(const P of s)P.bind(),P.setVertexAttribPointers(I,t,p);g&&(g.bind(),g.setVertexAttribPointers(I,t,p)),c&&c.bind(),_&&(_.bind(),_.setVertexAttribPointers(I,t,p)),x&&(x.bind(),x.setVertexAttribPointers(I,t,p)),T.currentNumAttributes=b}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}function $t(u){const t=[];for(let n=0;n<u.length;n++){if(u[n]===null)continue;const s=u[n].split(" ");t.push(s.pop())}return t}class $a{constructor(t,n,s,c,p,g){const _=t.gl;this.program=_.createProgram();const x=$t(n.staticAttributes),b=s?s.getBinderAttributes():[],T=x.concat(b),I=Rt.prelude.staticUniforms?$t(Rt.prelude.staticUniforms):[],P=n.staticUniforms?$t(n.staticUniforms):[],V=s?s.getBinderUniforms():[],N=I.concat(P).concat(V),$=[];for(const ue of N)$.indexOf(ue)<0&&$.push(ue);const B=s?s.defines():[];p&&B.push("#define OVERDRAW_INSPECTOR;"),g&&B.push("#define TERRAIN3D;");const ee=B.concat(Rt.prelude.fragmentSource,n.fragmentSource).join(`
`),se=B.concat(Rt.prelude.vertexSource,n.vertexSource).join(`
`),G=_.createShader(_.FRAGMENT_SHADER);if(_.isContextLost())return void(this.failedToCreate=!0);if(_.shaderSource(G,ee),_.compileShader(G),!_.getShaderParameter(G,_.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${_.getShaderInfoLog(G)}`);_.attachShader(this.program,G);const te=_.createShader(_.VERTEX_SHADER);if(_.isContextLost())return void(this.failedToCreate=!0);if(_.shaderSource(te,se),_.compileShader(te),!_.getShaderParameter(te,_.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${_.getShaderInfoLog(te)}`);_.attachShader(this.program,te),this.attributes={};const ce={};this.numAttributes=T.length;for(let ue=0;ue<this.numAttributes;ue++)T[ue]&&(_.bindAttribLocation(this.program,ue,T[ue]),this.attributes[T[ue]]=ue);if(_.linkProgram(this.program),!_.getProgramParameter(this.program,_.LINK_STATUS))throw new Error(`Program failed to link: ${_.getProgramInfoLog(this.program)}`);_.deleteShader(te),_.deleteShader(G);for(let ue=0;ue<$.length;ue++){const me=$[ue];if(me&&!ce[me]){const be=_.getUniformLocation(this.program,me);be&&(ce[me]=be)}}this.fixedUniforms=c(t,ce),this.terrainUniforms=((ue,me)=>({u_depth:new l.aL(ue,me.u_depth),u_terrain:new l.aL(ue,me.u_terrain),u_terrain_dim:new l.aM(ue,me.u_terrain_dim),u_terrain_matrix:new l.aN(ue,me.u_terrain_matrix),u_terrain_unpack:new l.aO(ue,me.u_terrain_unpack),u_terrain_exaggeration:new l.aM(ue,me.u_terrain_exaggeration)}))(t,ce),this.binderUniforms=s?s.getUniforms(t,ce):[]}draw(t,n,s,c,p,g,_,x,b,T,I,P,V,N,$,B,ee,se){const G=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(s),t.setStencilMode(c),t.setColorMode(p),t.setCullFace(g),x){t.activeTexture.set(G.TEXTURE2),G.bindTexture(G.TEXTURE_2D,x.depthTexture),t.activeTexture.set(G.TEXTURE3),G.bindTexture(G.TEXTURE_2D,x.texture);for(const ce in this.terrainUniforms)this.terrainUniforms[ce].set(x[ce])}for(const ce in this.fixedUniforms)this.fixedUniforms[ce].set(_[ce]);$&&$.setUniforms(t,this.binderUniforms,V,{zoom:N});let te=0;switch(n){case G.LINES:te=2;break;case G.TRIANGLES:te=3;break;case G.LINE_STRIP:te=1}for(const ce of P.get()){const ue=ce.vaos||(ce.vaos={});(ue[b]||(ue[b]=new yn)).bind(t,this,T,$?$.getPaintVertexBuffers():[],I,ce.vertexOffset,B,ee,se),G.drawElements(n,ce.primitiveLength*te,G.UNSIGNED_SHORT,ce.primitiveOffset*te*2)}}}function cr(u,t,n){const s=1/J(n,1,t.transform.tileZoom),c=Math.pow(2,n.tileID.overscaledZ),p=n.tileSize*Math.pow(2,t.transform.tileZoom)/c,g=p*(n.tileID.canonical.x+n.tileID.wrap*c),_=p*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[s,u.fromScale,u.toScale],u_fade:u.t,u_pixel_coord_upper:[g>>16,_>>16],u_pixel_coord_lower:[65535&g,65535&_]}}const zs=(u,t,n,s)=>{const c=t.style.light,p=c.properties.get("position"),g=[p.x,p.y,p.z],_=(function(){var b=new l.A(9);return l.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})();c.properties.get("anchor")==="viewport"&&(function(b,T){var I=Math.sin(T),P=Math.cos(T);b[0]=P,b[1]=I,b[2]=0,b[3]=-I,b[4]=P,b[5]=0,b[6]=0,b[7]=0,b[8]=1})(_,-t.transform.angle),(function(b,T,I){var P=T[0],V=T[1],N=T[2];b[0]=P*I[0]+V*I[3]+N*I[6],b[1]=P*I[1]+V*I[4]+N*I[7],b[2]=P*I[2]+V*I[5]+N*I[8]})(g,g,_);const x=c.properties.get("color");return{u_matrix:u,u_lightpos:g,u_lightintensity:c.properties.get("intensity"),u_lightcolor:[x.r,x.g,x.b],u_vertical_gradient:+n,u_opacity:s}},Qr=(u,t,n,s,c,p,g)=>l.e(zs(u,t,n,s),cr(p,t,g),{u_height_factor:-Math.pow(2,c.overscaledZ)/g.tileSize/8}),Ho=u=>({u_matrix:u}),Ds=(u,t,n,s)=>l.e(Ho(u),cr(n,t,s)),ja=(u,t)=>({u_matrix:u,u_world:t}),qa=(u,t,n,s,c)=>l.e(Ds(u,t,n,s),{u_world:c}),en=(u,t,n,s)=>{const c=u.transform;let p,g;if(s.paint.get("circle-pitch-alignment")==="map"){const _=J(n,1,c.zoom);p=!0,g=[_,_]}else p=!1,g=c.pixelsToGLUnits;return{u_camera_to_center_distance:c.cameraToCenterDistance,u_scale_with_map:+(s.paint.get("circle-pitch-scale")==="map"),u_matrix:u.translatePosMatrix(t.posMatrix,n,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_pitch_with_map:+p,u_device_pixel_ratio:u.pixelRatio,u_extrude_scale:g}},Ls=(u,t,n)=>{const s=J(n,1,t.zoom),c=Math.pow(2,t.zoom-n.tileID.overscaledZ),p=n.tileID.overscaleFactor();return{u_matrix:u,u_camera_to_center_distance:t.cameraToCenterDistance,u_pixels_to_tile_units:s,u_extrude_scale:[t.pixelsToGLUnits[0]/(s*c),t.pixelsToGLUnits[1]/(s*c)],u_overscale_factor:p}},pa=(u,t,n=1)=>({u_matrix:u,u_color:t,u_overlay:0,u_overlay_scale:n}),Wo=u=>({u_matrix:u}),mc=(u,t,n,s)=>({u_matrix:u,u_extrude_scale:J(t,1,n),u_intensity:s});function Fs(u,t){const n=Math.pow(2,t.canonical.z),s=t.canonical.y;return[new l.U(0,s/n).toLngLat().lat,new l.U(0,(s+1)/n).toLngLat().lat]}const Rs=(u,t,n,s)=>{const c=u.transform;return{u_matrix:Za(u,t,n,s),u_ratio:1/J(t,1,c.zoom),u_device_pixel_ratio:u.pixelRatio,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]]}},Xo=(u,t,n,s,c)=>l.e(Rs(u,t,n,c),{u_image:0,u_image_height:s}),gc=(u,t,n,s,c)=>{const p=u.transform,g=Yo(t,p);return{u_matrix:Za(u,t,n,c),u_texsize:t.imageAtlasTexture.size,u_ratio:1/J(t,1,p.zoom),u_device_pixel_ratio:u.pixelRatio,u_image:0,u_scale:[g,s.fromScale,s.toScale],u_fade:s.t,u_units_to_pixels:[1/p.pixelsToGLUnits[0],1/p.pixelsToGLUnits[1]]}},Ko=(u,t,n,s,c,p)=>{const g=u.lineAtlas,_=Yo(t,u.transform),x=n.layout.get("line-cap")==="round",b=g.getDash(s.from,x),T=g.getDash(s.to,x),I=b.width*c.fromScale,P=T.width*c.toScale;return l.e(Rs(u,t,n,p),{u_patternscale_a:[_/I,-b.height/2],u_patternscale_b:[_/P,-T.height/2],u_sdfgamma:g.width/(256*Math.min(I,P)*u.pixelRatio)/2,u_image:0,u_tex_y_a:b.y,u_tex_y_b:T.y,u_mix:c.t})};function Yo(u,t){return 1/J(u,1,t.tileZoom)}function Za(u,t,n,s){return u.translatePosMatrix(s?s.posMatrix:t.tileID.posMatrix,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const Jo=(u,t,n,s,c)=>{return{u_matrix:u,u_tl_parent:t,u_scale_parent:n,u_buffer_scale:1,u_fade_t:s.mix,u_opacity:s.opacity*c.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:c.paint.get("raster-brightness-min"),u_brightness_high:c.paint.get("raster-brightness-max"),u_saturation_factor:(g=c.paint.get("raster-saturation"),g>0?1-1/(1.001-g):-g),u_contrast_factor:(p=c.paint.get("raster-contrast"),p>0?1/(1-p):1+p),u_spin_weights:Qo(c.paint.get("raster-hue-rotate"))};var p,g};function Qo(u){u*=Math.PI/180;const t=Math.sin(u),n=Math.cos(u);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const Bs=(u,t,n,s,c,p,g,_,x,b)=>{const T=c.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:T.cameraToCenterDistance,u_pitch:T.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:T.width/T.height,u_fade_change:c.options.fadeDuration?c.symbolFadeChange:1,u_matrix:p,u_label_plane_matrix:g,u_coord_matrix:_,u_is_text:+x,u_pitch_with_map:+s,u_texsize:b,u_texture:0}},Os=(u,t,n,s,c,p,g,_,x,b,T)=>{const I=c.transform;return l.e(Bs(u,t,n,s,c,p,g,_,x,b),{u_gamma_scale:s?Math.cos(I._pitch)*I.cameraToCenterDistance:1,u_device_pixel_ratio:c.pixelRatio,u_is_halo:1})},xn=(u,t,n,s,c,p,g,_,x,b)=>l.e(Os(u,t,n,s,c,p,g,_,!0,x),{u_texsize_icon:b,u_texture_icon:1}),Ga=(u,t,n)=>({u_matrix:u,u_opacity:t,u_color:n}),ur=(u,t,n,s,c,p)=>l.e((function(g,_,x,b){const T=x.imageManager.getPattern(g.from.toString()),I=x.imageManager.getPattern(g.to.toString()),{width:P,height:V}=x.imageManager.getPixelSize(),N=Math.pow(2,b.tileID.overscaledZ),$=b.tileSize*Math.pow(2,x.transform.tileZoom)/N,B=$*(b.tileID.canonical.x+b.tileID.wrap*N),ee=$*b.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:T.tl,u_pattern_br_a:T.br,u_pattern_tl_b:I.tl,u_pattern_br_b:I.br,u_texsize:[P,V],u_mix:_.t,u_pattern_size_a:T.displaySize,u_pattern_size_b:I.displaySize,u_scale_a:_.fromScale,u_scale_b:_.toScale,u_tile_units_to_pixels:1/J(b,1,x.transform.tileZoom),u_pixel_coord_upper:[B>>16,ee>>16],u_pixel_coord_lower:[65535&B,65535&ee]}})(s,p,n,c),{u_matrix:u,u_opacity:t}),Ha={fillExtrusion:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_lightpos:new l.aP(u,t.u_lightpos),u_lightintensity:new l.aM(u,t.u_lightintensity),u_lightcolor:new l.aP(u,t.u_lightcolor),u_vertical_gradient:new l.aM(u,t.u_vertical_gradient),u_opacity:new l.aM(u,t.u_opacity)}),fillExtrusionPattern:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_lightpos:new l.aP(u,t.u_lightpos),u_lightintensity:new l.aM(u,t.u_lightintensity),u_lightcolor:new l.aP(u,t.u_lightcolor),u_vertical_gradient:new l.aM(u,t.u_vertical_gradient),u_height_factor:new l.aM(u,t.u_height_factor),u_image:new l.aL(u,t.u_image),u_texsize:new l.aQ(u,t.u_texsize),u_pixel_coord_upper:new l.aQ(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new l.aQ(u,t.u_pixel_coord_lower),u_scale:new l.aP(u,t.u_scale),u_fade:new l.aM(u,t.u_fade),u_opacity:new l.aM(u,t.u_opacity)}),fill:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix)}),fillPattern:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_image:new l.aL(u,t.u_image),u_texsize:new l.aQ(u,t.u_texsize),u_pixel_coord_upper:new l.aQ(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new l.aQ(u,t.u_pixel_coord_lower),u_scale:new l.aP(u,t.u_scale),u_fade:new l.aM(u,t.u_fade)}),fillOutline:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_world:new l.aQ(u,t.u_world)}),fillOutlinePattern:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_world:new l.aQ(u,t.u_world),u_image:new l.aL(u,t.u_image),u_texsize:new l.aQ(u,t.u_texsize),u_pixel_coord_upper:new l.aQ(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new l.aQ(u,t.u_pixel_coord_lower),u_scale:new l.aP(u,t.u_scale),u_fade:new l.aM(u,t.u_fade)}),circle:(u,t)=>({u_camera_to_center_distance:new l.aM(u,t.u_camera_to_center_distance),u_scale_with_map:new l.aL(u,t.u_scale_with_map),u_pitch_with_map:new l.aL(u,t.u_pitch_with_map),u_extrude_scale:new l.aQ(u,t.u_extrude_scale),u_device_pixel_ratio:new l.aM(u,t.u_device_pixel_ratio),u_matrix:new l.aN(u,t.u_matrix)}),collisionBox:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_camera_to_center_distance:new l.aM(u,t.u_camera_to_center_distance),u_pixels_to_tile_units:new l.aM(u,t.u_pixels_to_tile_units),u_extrude_scale:new l.aQ(u,t.u_extrude_scale),u_overscale_factor:new l.aM(u,t.u_overscale_factor)}),collisionCircle:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_inv_matrix:new l.aN(u,t.u_inv_matrix),u_camera_to_center_distance:new l.aM(u,t.u_camera_to_center_distance),u_viewport_size:new l.aQ(u,t.u_viewport_size)}),debug:(u,t)=>({u_color:new l.aR(u,t.u_color),u_matrix:new l.aN(u,t.u_matrix),u_overlay:new l.aL(u,t.u_overlay),u_overlay_scale:new l.aM(u,t.u_overlay_scale)}),clippingMask:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix)}),heatmap:(u,t)=>({u_extrude_scale:new l.aM(u,t.u_extrude_scale),u_intensity:new l.aM(u,t.u_intensity),u_matrix:new l.aN(u,t.u_matrix)}),heatmapTexture:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_world:new l.aQ(u,t.u_world),u_image:new l.aL(u,t.u_image),u_color_ramp:new l.aL(u,t.u_color_ramp),u_opacity:new l.aM(u,t.u_opacity)}),hillshade:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_image:new l.aL(u,t.u_image),u_latrange:new l.aQ(u,t.u_latrange),u_light:new l.aQ(u,t.u_light),u_shadow:new l.aR(u,t.u_shadow),u_highlight:new l.aR(u,t.u_highlight),u_accent:new l.aR(u,t.u_accent)}),hillshadePrepare:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_image:new l.aL(u,t.u_image),u_dimension:new l.aQ(u,t.u_dimension),u_zoom:new l.aM(u,t.u_zoom),u_unpack:new l.aO(u,t.u_unpack)}),line:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_ratio:new l.aM(u,t.u_ratio),u_device_pixel_ratio:new l.aM(u,t.u_device_pixel_ratio),u_units_to_pixels:new l.aQ(u,t.u_units_to_pixels)}),lineGradient:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_ratio:new l.aM(u,t.u_ratio),u_device_pixel_ratio:new l.aM(u,t.u_device_pixel_ratio),u_units_to_pixels:new l.aQ(u,t.u_units_to_pixels),u_image:new l.aL(u,t.u_image),u_image_height:new l.aM(u,t.u_image_height)}),linePattern:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_texsize:new l.aQ(u,t.u_texsize),u_ratio:new l.aM(u,t.u_ratio),u_device_pixel_ratio:new l.aM(u,t.u_device_pixel_ratio),u_image:new l.aL(u,t.u_image),u_units_to_pixels:new l.aQ(u,t.u_units_to_pixels),u_scale:new l.aP(u,t.u_scale),u_fade:new l.aM(u,t.u_fade)}),lineSDF:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_ratio:new l.aM(u,t.u_ratio),u_device_pixel_ratio:new l.aM(u,t.u_device_pixel_ratio),u_units_to_pixels:new l.aQ(u,t.u_units_to_pixels),u_patternscale_a:new l.aQ(u,t.u_patternscale_a),u_patternscale_b:new l.aQ(u,t.u_patternscale_b),u_sdfgamma:new l.aM(u,t.u_sdfgamma),u_image:new l.aL(u,t.u_image),u_tex_y_a:new l.aM(u,t.u_tex_y_a),u_tex_y_b:new l.aM(u,t.u_tex_y_b),u_mix:new l.aM(u,t.u_mix)}),raster:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_tl_parent:new l.aQ(u,t.u_tl_parent),u_scale_parent:new l.aM(u,t.u_scale_parent),u_buffer_scale:new l.aM(u,t.u_buffer_scale),u_fade_t:new l.aM(u,t.u_fade_t),u_opacity:new l.aM(u,t.u_opacity),u_image0:new l.aL(u,t.u_image0),u_image1:new l.aL(u,t.u_image1),u_brightness_low:new l.aM(u,t.u_brightness_low),u_brightness_high:new l.aM(u,t.u_brightness_high),u_saturation_factor:new l.aM(u,t.u_saturation_factor),u_contrast_factor:new l.aM(u,t.u_contrast_factor),u_spin_weights:new l.aP(u,t.u_spin_weights)}),symbolIcon:(u,t)=>({u_is_size_zoom_constant:new l.aL(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new l.aL(u,t.u_is_size_feature_constant),u_size_t:new l.aM(u,t.u_size_t),u_size:new l.aM(u,t.u_size),u_camera_to_center_distance:new l.aM(u,t.u_camera_to_center_distance),u_pitch:new l.aM(u,t.u_pitch),u_rotate_symbol:new l.aL(u,t.u_rotate_symbol),u_aspect_ratio:new l.aM(u,t.u_aspect_ratio),u_fade_change:new l.aM(u,t.u_fade_change),u_matrix:new l.aN(u,t.u_matrix),u_label_plane_matrix:new l.aN(u,t.u_label_plane_matrix),u_coord_matrix:new l.aN(u,t.u_coord_matrix),u_is_text:new l.aL(u,t.u_is_text),u_pitch_with_map:new l.aL(u,t.u_pitch_with_map),u_texsize:new l.aQ(u,t.u_texsize),u_texture:new l.aL(u,t.u_texture)}),symbolSDF:(u,t)=>({u_is_size_zoom_constant:new l.aL(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new l.aL(u,t.u_is_size_feature_constant),u_size_t:new l.aM(u,t.u_size_t),u_size:new l.aM(u,t.u_size),u_camera_to_center_distance:new l.aM(u,t.u_camera_to_center_distance),u_pitch:new l.aM(u,t.u_pitch),u_rotate_symbol:new l.aL(u,t.u_rotate_symbol),u_aspect_ratio:new l.aM(u,t.u_aspect_ratio),u_fade_change:new l.aM(u,t.u_fade_change),u_matrix:new l.aN(u,t.u_matrix),u_label_plane_matrix:new l.aN(u,t.u_label_plane_matrix),u_coord_matrix:new l.aN(u,t.u_coord_matrix),u_is_text:new l.aL(u,t.u_is_text),u_pitch_with_map:new l.aL(u,t.u_pitch_with_map),u_texsize:new l.aQ(u,t.u_texsize),u_texture:new l.aL(u,t.u_texture),u_gamma_scale:new l.aM(u,t.u_gamma_scale),u_device_pixel_ratio:new l.aM(u,t.u_device_pixel_ratio),u_is_halo:new l.aL(u,t.u_is_halo)}),symbolTextAndIcon:(u,t)=>({u_is_size_zoom_constant:new l.aL(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new l.aL(u,t.u_is_size_feature_constant),u_size_t:new l.aM(u,t.u_size_t),u_size:new l.aM(u,t.u_size),u_camera_to_center_distance:new l.aM(u,t.u_camera_to_center_distance),u_pitch:new l.aM(u,t.u_pitch),u_rotate_symbol:new l.aL(u,t.u_rotate_symbol),u_aspect_ratio:new l.aM(u,t.u_aspect_ratio),u_fade_change:new l.aM(u,t.u_fade_change),u_matrix:new l.aN(u,t.u_matrix),u_label_plane_matrix:new l.aN(u,t.u_label_plane_matrix),u_coord_matrix:new l.aN(u,t.u_coord_matrix),u_is_text:new l.aL(u,t.u_is_text),u_pitch_with_map:new l.aL(u,t.u_pitch_with_map),u_texsize:new l.aQ(u,t.u_texsize),u_texsize_icon:new l.aQ(u,t.u_texsize_icon),u_texture:new l.aL(u,t.u_texture),u_texture_icon:new l.aL(u,t.u_texture_icon),u_gamma_scale:new l.aM(u,t.u_gamma_scale),u_device_pixel_ratio:new l.aM(u,t.u_device_pixel_ratio),u_is_halo:new l.aL(u,t.u_is_halo)}),background:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_opacity:new l.aM(u,t.u_opacity),u_color:new l.aR(u,t.u_color)}),backgroundPattern:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_opacity:new l.aM(u,t.u_opacity),u_image:new l.aL(u,t.u_image),u_pattern_tl_a:new l.aQ(u,t.u_pattern_tl_a),u_pattern_br_a:new l.aQ(u,t.u_pattern_br_a),u_pattern_tl_b:new l.aQ(u,t.u_pattern_tl_b),u_pattern_br_b:new l.aQ(u,t.u_pattern_br_b),u_texsize:new l.aQ(u,t.u_texsize),u_mix:new l.aM(u,t.u_mix),u_pattern_size_a:new l.aQ(u,t.u_pattern_size_a),u_pattern_size_b:new l.aQ(u,t.u_pattern_size_b),u_scale_a:new l.aM(u,t.u_scale_a),u_scale_b:new l.aM(u,t.u_scale_b),u_pixel_coord_upper:new l.aQ(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new l.aQ(u,t.u_pixel_coord_lower),u_tile_units_to_pixels:new l.aM(u,t.u_tile_units_to_pixels)}),terrain:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_texture:new l.aL(u,t.u_texture),u_ele_delta:new l.aM(u,t.u_ele_delta)}),terrainDepth:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_ele_delta:new l.aM(u,t.u_ele_delta)}),terrainCoords:(u,t)=>({u_matrix:new l.aN(u,t.u_matrix),u_texture:new l.aL(u,t.u_texture),u_terrain_coords_id:new l.aM(u,t.u_terrain_coords_id),u_ele_delta:new l.aM(u,t.u_ele_delta)})};class Wa{constructor(t,n,s){this.context=t;const c=t.gl;this.buffer=c.createBuffer(),this.dynamicDraw=!!s,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const da={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Xa{constructor(t,n,s,c){this.length=n.length,this.attributes=s,this.itemSize=n.bytesPerElement,this.dynamicDraw=c,this.context=t;const p=t.gl;this.buffer=p.createBuffer(),t.bindVertexBuffer.set(this.buffer),p.bufferData(p.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?p.DYNAMIC_DRAW:p.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,n){for(let s=0;s<this.attributes.length;s++){const c=n.attributes[this.attributes[s].name];c!==void 0&&t.enableVertexAttribArray(c)}}setVertexAttribPointers(t,n,s){for(let c=0;c<this.attributes.length;c++){const p=this.attributes[c],g=n.attributes[p.name];g!==void 0&&t.vertexAttribPointer(g,p.components,t[da[p.type]],!1,this.itemSize,p.offset+this.itemSize*(s||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const qn=new WeakMap;function tn(u){var t;if(qn.has(u))return qn.get(u);{const n=(t=u.getParameter(u.VERSION))===null||t===void 0?void 0:t.startsWith("WebGL 2.0");return qn.set(u,n),n}}class dt{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 Ka extends dt{getDefault(){return l.aT.transparent}set(t){const n=this.current;(t.r!==n.r||t.g!==n.g||t.b!==n.b||t.a!==n.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Hi extends dt{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class Wi extends dt{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class Ns extends dt{getDefault(){return[!0,!0,!0,!0]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Ya extends dt{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class Ja extends dt{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class Vs extends dt{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const n=this.current;(t.func!==n.func||t.ref!==n.ref||t.mask!==n.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class Us extends dt{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class Qa extends dt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),this.current=t,this.dirty=!1}}class $s extends dt{getDefault(){return[0,1]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class js extends dt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),this.current=t,this.dirty=!1}}class es extends dt{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class el extends dt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.BLEND):n.disable(n.BLEND),this.current=t,this.dirty=!1}}class tl extends dt{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class Zn extends dt{getDefault(){return l.aT.transparent}set(t){const n=this.current;(t.r!==n.r||t.g!==n.g||t.b!==n.b||t.a!==n.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class _c extends dt{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class yc extends dt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.CULL_FACE):n.disable(n.CULL_FACE),this.current=t,this.dirty=!1}}class xc extends dt{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class vc extends dt{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class bc extends dt{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class wc extends dt{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class qs extends dt{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class ts extends dt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindFramebuffer(n.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Zs extends dt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindRenderbuffer(n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Gs extends dt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindTexture(n.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class Gn extends dt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindBuffer(n.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class il extends dt{getDefault(){return null}set(t){const n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class rl extends dt{getDefault(){return null}set(t){var n;if(t===this.current&&!this.dirty)return;const s=this.gl;tn(s)?s.bindVertexArray(t):(n=s.getExtension("OES_vertex_array_object"))===null||n===void 0||n.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class Hs extends dt{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class vn extends dt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class nl extends dt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class rn extends dt{constructor(t,n){super(t),this.context=t,this.parent=n}getDefault(){return null}}class Hn extends rn{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class al extends rn{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Ws extends rn{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class xt{constructor(t,n,s,c,p){this.context=t,this.width=n,this.height=s;const g=t.gl,_=this.framebuffer=g.createFramebuffer();if(this.colorAttachment=new Hn(t,_),c)this.depthAttachment=p?new Ws(t,_):new al(t,_);else if(p)throw new Error("Stencil cannot be setted without depth");if(g.checkFramebufferStatus(g.FRAMEBUFFER)!==g.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer is not complete")}destroy(){const t=this.context.gl,n=this.colorAttachment.get();if(n&&t.deleteTexture(n),this.depthAttachment){const s=this.depthAttachment.get();s&&t.deleteRenderbuffer(s)}t.deleteFramebuffer(this.framebuffer)}}class Bt{constructor(t,n,s){this.blendFunction=t,this.blendColor=n,this.mask=s}}Bt.Replace=[1,0],Bt.disabled=new Bt(Bt.Replace,l.aT.transparent,[!1,!1,!1,!1]),Bt.unblended=new Bt(Bt.Replace,l.aT.transparent,[!0,!0,!0,!0]),Bt.alphaBlended=new Bt([1,771],l.aT.transparent,[!0,!0,!0,!0]);class Sc{constructor(t){var n,s;if(this.gl=t,this.clearColor=new Ka(this),this.clearDepth=new Hi(this),this.clearStencil=new Wi(this),this.colorMask=new Ns(this),this.depthMask=new Ya(this),this.stencilMask=new Ja(this),this.stencilFunc=new Vs(this),this.stencilOp=new Us(this),this.stencilTest=new Qa(this),this.depthRange=new $s(this),this.depthTest=new js(this),this.depthFunc=new es(this),this.blend=new el(this),this.blendFunc=new tl(this),this.blendColor=new Zn(this),this.blendEquation=new _c(this),this.cullFace=new yc(this),this.cullFaceSide=new xc(this),this.frontFace=new vc(this),this.program=new bc(this),this.activeTexture=new wc(this),this.viewport=new qs(this),this.bindFramebuffer=new ts(this),this.bindRenderbuffer=new Zs(this),this.bindTexture=new Gs(this),this.bindVertexBuffer=new Gn(this),this.bindElementBuffer=new il(this),this.bindVertexArray=new rl(this),this.pixelStoreUnpack=new Hs(this),this.pixelStoreUnpackPremultiplyAlpha=new vn(this),this.pixelStoreUnpackFlipY=new nl(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),tn(t)){this.HALF_FLOAT=t.HALF_FLOAT;const c=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(n=t.RGBA16F)!==null&&n!==void 0?n:c==null?void 0:c.RGBA16F_EXT,this.RGB16F=(s=t.RGB16F)!==null&&s!==void 0?s:c==null?void 0:c.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");const c=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=c==null?void 0:c.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,n){return new Wa(this,t,n)}createVertexBuffer(t,n,s){return new Xa(this,t,n,s)}createRenderbuffer(t,n,s){const c=this.gl,p=c.createRenderbuffer();return this.bindRenderbuffer.set(p),c.renderbufferStorage(c.RENDERBUFFER,t,n,s),this.bindRenderbuffer.set(null),p}createFramebuffer(t,n,s,c){return new xt(this,t,n,s,c)}clear({color:t,depth:n,stencil:s}){const c=this.gl;let p=0;t&&(p|=c.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),n!==void 0&&(p|=c.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),s!==void 0&&(p|=c.STENCIL_BUFFER_BIT,this.clearStencil.set(s),this.stencilMask.set(255)),c.clear(p)}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){l.aG(t.blendFunction,Bt.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 tn(this.gl)?this.gl.createVertexArray():(t=this.gl.getExtension("OES_vertex_array_object"))===null||t===void 0?void 0:t.createVertexArrayOES()}deleteVertexArray(t){var n;return tn(this.gl)?this.gl.deleteVertexArray(t):(n=this.gl.getExtension("OES_vertex_array_object"))===null||n===void 0?void 0:n.deleteVertexArrayOES(t)}unbindVAO(){this.bindVertexArray.set(null)}}class ft{constructor(t,n,s){this.func=t,this.mask=n,this.range=s}}ft.ReadOnly=!1,ft.ReadWrite=!0,ft.disabled=new ft(519,ft.ReadOnly,[0,1]);const bn=7680;class Ot{constructor(t,n,s,c,p,g){this.test=t,this.ref=n,this.mask=s,this.fail=c,this.depthFail=p,this.pass=g}}Ot.disabled=new Ot({func:519,mask:0},0,0,bn,bn,bn);class Lt{constructor(t,n,s){this.enable=t,this.mode=n,this.frontFace=s}}let fa;function sl(u,t,n,s,c,p,g){const _=u.context,x=_.gl,b=u.useProgram("collisionBox"),T=[];let I=0,P=0;for(let G=0;G<s.length;G++){const te=s[G],ce=t.getTile(te),ue=ce.getBucket(n);if(!ue)continue;let me=te.posMatrix;c[0]===0&&c[1]===0||(me=u.translatePosMatrix(te.posMatrix,ce,c,p));const be=g?ue.textCollisionBox:ue.iconCollisionBox,xe=ue.collisionCircleArray;if(xe.length>0){const Te=l.Z(),Be=me;l.aU(Te,ue.placementInvProjMatrix,u.transform.glCoordMatrix),l.aU(Te,Te,ue.placementViewportMatrix),T.push({circleArray:xe,circleOffset:P,transform:Be,invTransform:Te,coord:te}),I+=xe.length/4,P=I}be&&b.draw(_,x.LINES,ft.disabled,Ot.disabled,u.colorModeForRenderPass(),Lt.disabled,Ls(me,u.transform,ce),u.style.map.terrain&&u.style.map.terrain.getTerrainData(te),n.id,be.layoutVertexBuffer,be.indexBuffer,be.segments,null,u.transform.zoom,null,null,be.collisionVertexBuffer)}if(!g||!T.length)return;const V=u.useProgram("collisionCircle"),N=new l.aV;N.resize(4*I),N._trim();let $=0;for(const G of T)for(let te=0;te<G.circleArray.length/4;te++){const ce=4*te,ue=G.circleArray[ce+0],me=G.circleArray[ce+1],be=G.circleArray[ce+2],xe=G.circleArray[ce+3];N.emplace($++,ue,me,be,xe,0),N.emplace($++,ue,me,be,xe,1),N.emplace($++,ue,me,be,xe,2),N.emplace($++,ue,me,be,xe,3)}(!fa||fa.length<2*I)&&(fa=(function(G){const te=2*G,ce=new l.aX;ce.resize(te),ce._trim();for(let ue=0;ue<te;ue++){const me=6*ue;ce.uint16[me+0]=4*ue+0,ce.uint16[me+1]=4*ue+1,ce.uint16[me+2]=4*ue+2,ce.uint16[me+3]=4*ue+2,ce.uint16[me+4]=4*ue+3,ce.uint16[me+5]=4*ue+0}return ce})(I));const B=_.createIndexBuffer(fa,!0),ee=_.createVertexBuffer(N,l.aW.members,!0);for(const G of T){const te={u_matrix:G.transform,u_inv_matrix:G.invTransform,u_camera_to_center_distance:(se=u.transform).cameraToCenterDistance,u_viewport_size:[se.width,se.height]};V.draw(_,x.TRIANGLES,ft.disabled,Ot.disabled,u.colorModeForRenderPass(),Lt.disabled,te,u.style.map.terrain&&u.style.map.terrain.getTerrainData(G.coord),n.id,ee,B,l.S.simpleSegment(0,2*G.circleOffset,G.circleArray.length,G.circleArray.length/2),null,u.transform.zoom,null,null,null)}var se;ee.destroy(),B.destroy()}Lt.disabled=new Lt(!1,1029,2305),Lt.backCCW=new Lt(!0,1029,2305);const Xs=l.ao(new Float32Array(16));function is(u,t,n,s,c,p){const{horizontalAlign:g,verticalAlign:_}=l.au(u);return new l.P((-(g-.5)*t/c+s[0])*p,(-(_-.5)*n/c+s[1])*p)}function rs(u,t,n,s,c,p,g,_,x,b,T){const I=u.text.placedSymbolArray,P=u.text.dynamicLayoutVertexArray,V=u.icon.dynamicLayoutVertexArray,N={};P.clear();for(let $=0;$<I.length;$++){const B=I.get($),ee=B.hidden||!B.crossTileID||u.allowVerticalPlacement&&!B.placedOrientation?null:s[B.crossTileID];if(ee){const se=new l.P(B.anchorX,B.anchorY),G=Ut(se,n?g:p,T),te=_n(c.cameraToCenterDistance,G.signedDistanceFromCamera);let ce=l.aj(u.textSizeData,x,B)*te/l.ap;n&&(ce*=u.tilePixelRatio/_);const{width:ue,height:me,anchor:be,textOffset:xe,textBoxScale:Te}=ee,Be=is(be,ue,me,xe,Te,ce),ut=n?Ut(se.add(Be),p,T).point:G.point.add(t?Be.rotate(-c.angle):Be),Ee=u.allowVerticalPlacement&&B.placedOrientation===l.ai.vertical?Math.PI/2:0;for(let We=0;We<B.numGlyphs;We++)l.ak(P,ut,Ee);b&&B.associatedIconIndex>=0&&(N[B.associatedIconIndex]={shiftedAnchor:ut,angle:Ee})}else R(B.numGlyphs,P)}if(b){V.clear();const $=u.icon.placedSymbolArray;for(let B=0;B<$.length;B++){const ee=$.get(B);if(ee.hidden)R(ee.numGlyphs,V);else{const se=N[B];if(se)for(let G=0;G<ee.numGlyphs;G++)l.ak(V,se.shiftedAnchor,se.angle);else R(ee.numGlyphs,V)}}u.icon.dynamicLayoutVertexBuffer.updateData(V)}u.text.dynamicLayoutVertexBuffer.updateData(P)}function Ks(u,t,n){return n.iconsInText&&t?"symbolTextAndIcon":u?"symbolSDF":"symbolIcon"}function ns(u,t,n,s,c,p,g,_,x,b,T,I){const P=u.context,V=P.gl,N=u.transform,$=_==="map",B=x==="map",ee=_!=="viewport"&&n.layout.get("symbol-placement")!=="point",se=$&&!B&&!ee,G=!n.layout.get("symbol-sort-key").isConstant();let te=!1;const ce=u.depthModeForSublayer(0,ft.ReadOnly),ue=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),me=[];for(const be of s){const xe=t.getTile(be),Te=xe.getBucket(n);if(!Te)continue;const Be=c?Te.text:Te.icon;if(!Be||!Be.segments.get().length||!Be.hasVisibleVertices)continue;const ut=Be.programConfigurations.get(n.id),Ee=c||Te.sdfIcons,We=c?Te.textSizeData:Te.iconSizeData,Ne=B||N.pitch!==0,St=u.useProgram(Ks(Ee,c,Te),ut),ct=l.ah(We,N.zoom),at=u.style.map.terrain&&u.style.map.terrain.getTerrainData(be);let ht,Zt,Ct,pi,ei=[0,0],Xt=null;if(c)Zt=xe.glyphAtlasTexture,Ct=V.LINEAR,ht=xe.glyphAtlasTexture.size,Te.iconsInText&&(ei=xe.imageAtlasTexture.size,Xt=xe.imageAtlasTexture,pi=Ne||u.options.rotating||u.options.zooming||We.kind==="composite"||We.kind==="camera"?V.LINEAR:V.NEAREST);else{const Gt=n.layout.get("icon-size").constantOr(0)!==1||Te.iconsNeedLinear;Zt=xe.imageAtlasTexture,Ct=Ee||u.options.rotating||u.options.zooming||Gt||Ne?V.LINEAR:V.NEAREST,ht=xe.imageAtlasTexture.size}const Yi=J(xe,1,u.transform.zoom),Pt=Ae(be.posMatrix,B,$,u.transform,Yi),Ir=wr(be.posMatrix,B,$,u.transform,Yi),Ar=ue&&Te.hasTextData(),on=n.layout.get("icon-text-fit")!=="none"&&Ar&&Te.hasIconData();if(ee){const Gt=u.style.map.terrain?(Ri,Ht)=>u.style.map.terrain.getElevation(be,Ri,Ht):null,ti=n.layout.get("text-rotation-alignment")==="map";Ce(Te,be.posMatrix,u,c,Pt,Ir,B,b,ti,Gt)}const An=u.translatePosMatrix(be.posMatrix,xe,p,g),ea=ee||c&&ue||on?Xs:Pt,_i=u.translatePosMatrix(Ir,xe,p,g,!0),di=Ee&&n.paint.get(c?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Ii;Ii=Ee?Te.iconsInText?xn(We.kind,ct,se,B,u,An,ea,_i,ht,ei):Os(We.kind,ct,se,B,u,An,ea,_i,c,ht):Bs(We.kind,ct,se,B,u,An,ea,_i,c,ht);const kn={program:St,buffers:Be,uniformValues:Ii,atlasTexture:Zt,atlasTextureIcon:Xt,atlasInterpolation:Ct,atlasInterpolationIcon:pi,isSDF:Ee,hasHalo:di};if(G&&Te.canOverlap){te=!0;const Gt=Be.segments.get();for(const ti of Gt)me.push({segments:new l.S([ti]),sortKey:ti.sortKey,state:kn,terrainData:at})}else me.push({segments:Be.segments,sortKey:0,state:kn,terrainData:at})}te&&me.sort(((be,xe)=>be.sortKey-xe.sortKey));for(const be of me){const xe=be.state;if(P.activeTexture.set(V.TEXTURE0),xe.atlasTexture.bind(xe.atlasInterpolation,V.CLAMP_TO_EDGE),xe.atlasTextureIcon&&(P.activeTexture.set(V.TEXTURE1),xe.atlasTextureIcon&&xe.atlasTextureIcon.bind(xe.atlasInterpolationIcon,V.CLAMP_TO_EDGE)),xe.isSDF){const Te=xe.uniformValues;xe.hasHalo&&(Te.u_is_halo=1,Ys(xe.buffers,be.segments,n,u,xe.program,ce,T,I,Te,be.terrainData)),Te.u_is_halo=0}Ys(xe.buffers,be.segments,n,u,xe.program,ce,T,I,xe.uniformValues,be.terrainData)}}function Ys(u,t,n,s,c,p,g,_,x,b){const T=s.context;c.draw(T,T.gl.TRIANGLES,p,g,_,Lt.disabled,x,b,n.id,u.layoutVertexBuffer,u.indexBuffer,t,n.paint,s.transform.zoom,u.programConfigurations.get(n.id),u.dynamicLayoutVertexBuffer,u.opacityVertexBuffer)}function ma(u,t,n,s,c){if(!n||!s||!s.imageAtlas)return;const p=s.imageAtlas.patternPositions;let g=p[n.to.toString()],_=p[n.from.toString()];if(!g&&_&&(g=_),!_&&g&&(_=g),!g||!_){const x=c.getPaintProperty(t);g=p[x],_=p[x]}g&&_&&u.setConstantPatternPositions(g,_)}function ga(u,t,n,s,c,p,g){const _=u.context.gl,x="fill-pattern",b=n.paint.get(x),T=b&&b.constantOr(1),I=n.getCrossfadeParameters();let P,V,N,$,B;g?(V=T&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",P=_.LINES):(V=T?"fillPattern":"fill",P=_.TRIANGLES);const ee=b.constantOr(null);for(const se of s){const G=t.getTile(se);if(T&&!G.patternsLoaded())continue;const te=G.getBucket(n);if(!te)continue;const ce=te.programConfigurations.get(n.id),ue=u.useProgram(V,ce),me=u.style.map.terrain&&u.style.map.terrain.getTerrainData(se);T&&(u.context.activeTexture.set(_.TEXTURE0),G.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),ce.updatePaintBuffers(I)),ma(ce,x,ee,G,n);const be=me?se:null,xe=u.translatePosMatrix(be?be.posMatrix:se.posMatrix,G,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(g){$=te.indexBuffer2,B=te.segments2;const Te=[_.drawingBufferWidth,_.drawingBufferHeight];N=V==="fillOutlinePattern"&&T?qa(xe,u,I,G,Te):ja(xe,Te)}else $=te.indexBuffer,B=te.segments,N=T?Ds(xe,u,I,G):Ho(xe);ue.draw(u.context,P,c,u.stencilModeForClipping(se),p,Lt.disabled,N,me,n.id,te.layoutVertexBuffer,$,B,n.paint,u.transform.zoom,ce)}}function _a(u,t,n,s,c,p,g){const _=u.context,x=_.gl,b="fill-extrusion-pattern",T=n.paint.get(b),I=T.constantOr(1),P=n.getCrossfadeParameters(),V=n.paint.get("fill-extrusion-opacity"),N=T.constantOr(null);for(const $ of s){const B=t.getTile($),ee=B.getBucket(n);if(!ee)continue;const se=u.style.map.terrain&&u.style.map.terrain.getTerrainData($),G=ee.programConfigurations.get(n.id),te=u.useProgram(I?"fillExtrusionPattern":"fillExtrusion",G);I&&(u.context.activeTexture.set(x.TEXTURE0),B.imageAtlasTexture.bind(x.LINEAR,x.CLAMP_TO_EDGE),G.updatePaintBuffers(P)),ma(G,b,N,B,n);const ce=u.translatePosMatrix($.posMatrix,B,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),ue=n.paint.get("fill-extrusion-vertical-gradient"),me=I?Qr(ce,u,ue,V,$,P,B):zs(ce,u,ue,V);te.draw(_,_.gl.TRIANGLES,c,p,g,Lt.backCCW,me,se,n.id,ee.layoutVertexBuffer,ee.indexBuffer,ee.segments,n.paint,u.transform.zoom,G,u.style.map.terrain&&ee.centroidVertexBuffer)}}function Tc(u,t,n,s,c,p,g){const _=u.context,x=_.gl,b=n.fbo;if(!b)return;const T=u.useProgram("hillshade"),I=u.style.map.terrain&&u.style.map.terrain.getTerrainData(t);_.activeTexture.set(x.TEXTURE0),x.bindTexture(x.TEXTURE_2D,b.colorAttachment.get()),T.draw(_,x.TRIANGLES,c,p,g,Lt.disabled,((P,V,N,$)=>{const B=N.paint.get("hillshade-shadow-color"),ee=N.paint.get("hillshade-highlight-color"),se=N.paint.get("hillshade-accent-color");let G=N.paint.get("hillshade-illumination-direction")*(Math.PI/180);N.paint.get("hillshade-illumination-anchor")==="viewport"&&(G-=P.transform.angle);const te=!P.options.moving;return{u_matrix:$?$.posMatrix:P.transform.calculatePosMatrix(V.tileID.toUnwrapped(),te),u_image:0,u_latrange:Fs(0,V.tileID),u_light:[N.paint.get("hillshade-exaggeration"),G],u_shadow:B,u_highlight:ee,u_accent:se}})(u,n,s,I?t:null),I,s.id,u.rasterBoundsBuffer,u.quadTriangleIndexBuffer,u.rasterBoundsSegments)}function Js(u,t,n,s,c,p){const g=u.context,_=g.gl,x=t.dem;if(x&&x.data){const b=x.dim,T=x.stride,I=x.getPixels();if(g.activeTexture.set(_.TEXTURE1),g.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||u.getTileTexture(T),t.demTexture){const V=t.demTexture;V.update(I,{premultiply:!1}),V.bind(_.NEAREST,_.CLAMP_TO_EDGE)}else t.demTexture=new nt(g,I,_.RGBA,{premultiply:!1}),t.demTexture.bind(_.NEAREST,_.CLAMP_TO_EDGE);g.activeTexture.set(_.TEXTURE0);let P=t.fbo;if(!P){const V=new nt(g,{width:b,height:b,data:null},_.RGBA);V.bind(_.LINEAR,_.CLAMP_TO_EDGE),P=t.fbo=g.createFramebuffer(b,b,!0,!1),P.colorAttachment.set(V.texture)}g.bindFramebuffer.set(P.framebuffer),g.viewport.set([0,0,b,b]),u.useProgram("hillshadePrepare").draw(g,_.TRIANGLES,s,c,p,Lt.disabled,((V,N)=>{const $=N.stride,B=l.Z();return l.aS(B,0,l.N,-l.N,0,0,1),l.$(B,B,[0,-l.N,0]),{u_matrix:B,u_image:1,u_dimension:[$,$],u_zoom:V.overscaledZ,u_unpack:N.getUnpackVector()}})(t.tileID,x),null,n.id,u.rasterBoundsBuffer,u.quadTriangleIndexBuffer,u.rasterBoundsSegments),t.needsHillshadePrepare=!1}}function Ic(u,t,n,s,c,p){const g=s.paint.get("raster-fade-duration");if(!p&&g>0){const _=l.h.now(),x=(_-u.timeAdded)/g,b=t?(_-t.timeAdded)/g:-1,T=n.getSource(),I=c.coveringZoomLevel({tileSize:T.tileSize,roundZoom:T.roundZoom}),P=!t||Math.abs(t.tileID.overscaledZ-I)>Math.abs(u.tileID.overscaledZ-I),V=P&&u.refreshedUponExpiration?1:l.ad(P?x:1-b,0,1);return u.refreshedUponExpiration&&x>=1&&(u.refreshedUponExpiration=!1),t?{opacity:1,mix:1-V}:{opacity:V,mix:0}}return{opacity:1,mix:0}}const ol=new l.aT(1,0,0,1),as=new l.aT(0,1,0,1),Qs=new l.aT(0,0,1,1),ll=new l.aT(1,0,1,1),cl=new l.aT(0,1,1,1);function ya(u,t,n,s){os(u,0,t+n/2,u.transform.width,n,s)}function ss(u,t,n,s){os(u,t-n/2,0,n,u.transform.height,s)}function os(u,t,n,s,c,p){const g=u.context,_=g.gl;_.enable(_.SCISSOR_TEST),_.scissor(t*u.pixelRatio,n*u.pixelRatio,s*u.pixelRatio,c*u.pixelRatio),g.clear({color:p}),_.disable(_.SCISSOR_TEST)}function ul(u,t,n){const s=u.context,c=s.gl,p=n.posMatrix,g=u.useProgram("debug"),_=ft.disabled,x=Ot.disabled,b=u.colorModeForRenderPass(),T="$debug",I=u.style.map.terrain&&u.style.map.terrain.getTerrainData(n);s.activeTexture.set(c.TEXTURE0);const P=t.getTileByID(n.key).latestRawTileData,V=Math.floor((P&&P.byteLength||0)/1024),N=t.getTile(n).tileSize,$=512/Math.min(N,512)*(n.overscaledZ/u.transform.zoom)*.5;let B=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(B+=` => ${n.overscaledZ}`),(function(ee,se){ee.initDebugOverlayCanvas();const G=ee.debugOverlayCanvas,te=ee.context.gl,ce=ee.debugOverlayCanvas.getContext("2d");ce.clearRect(0,0,G.width,G.height),ce.shadowColor="white",ce.shadowBlur=2,ce.lineWidth=1.5,ce.strokeStyle="white",ce.textBaseline="top",ce.font="bold 36px Open Sans, sans-serif",ce.fillText(se,5,5),ce.strokeText(se,5,5),ee.debugOverlayTexture.update(G),ee.debugOverlayTexture.bind(te.LINEAR,te.CLAMP_TO_EDGE)})(u,`${B} ${V}kB`),g.draw(s,c.TRIANGLES,_,x,Bt.alphaBlended,Lt.disabled,pa(p,l.aT.transparent,$),null,T,u.debugBuffer,u.quadTriangleIndexBuffer,u.debugSegments),g.draw(s,c.LINE_STRIP,_,x,b,Lt.disabled,pa(p,l.aT.red),I,T,u.debugBuffer,u.tileBorderIndexBuffer,u.debugSegments)}function jt(u,t,n){const s=u.context,c=s.gl,p=u.colorModeForRenderPass(),g=new ft(c.LEQUAL,ft.ReadWrite,u.depthRangeFor3D),_=u.useProgram("terrain"),x=t.getTerrainMesh();s.bindFramebuffer.set(null),s.viewport.set([0,0,u.width,u.height]);for(const b of n){const T=u.renderToTexture.getTexture(b),I=t.getTerrainData(b.tileID);s.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,T.texture);const P={u_matrix:u.transform.calculatePosMatrix(b.tileID.toUnwrapped()),u_texture:0,u_ele_delta:t.getMeshFrameDelta(u.transform.zoom)};_.draw(s,c.TRIANGLES,g,Ot.disabled,p,Lt.backCCW,P,I,"terrain",x.vertexBuffer,x.indexBuffer,x.segments)}}class wn{constructor(t,n){this.context=new Sc(t),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:l.Z(),renderTime:0},this.setup(),this.numSublayers=Di.maxUnderzooming+Di.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Va}resize(t,n,s){if(this.width=Math.floor(t*s),this.height=Math.floor(n*s),this.pixelRatio=s,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const c of this.style._order)this.style._layers[c].resize()}setup(){const t=this.context,n=new l.a_;n.emplaceBack(0,0),n.emplaceBack(l.N,0),n.emplaceBack(0,l.N),n.emplaceBack(l.N,l.N),this.tileExtentBuffer=t.createVertexBuffer(n,Ua.members),this.tileExtentSegments=l.S.simpleSegment(0,0,4,2);const s=new l.a_;s.emplaceBack(0,0),s.emplaceBack(l.N,0),s.emplaceBack(0,l.N),s.emplaceBack(l.N,l.N),this.debugBuffer=t.createVertexBuffer(s,Ua.members),this.debugSegments=l.S.simpleSegment(0,0,4,5);const c=new l.V;c.emplaceBack(0,0,0,0),c.emplaceBack(l.N,0,l.N,0),c.emplaceBack(0,l.N,0,l.N),c.emplaceBack(l.N,l.N,l.N,l.N),this.rasterBoundsBuffer=t.createVertexBuffer(c,mr.members),this.rasterBoundsSegments=l.S.simpleSegment(0,0,4,2);const p=new l.a_;p.emplaceBack(0,0),p.emplaceBack(1,0),p.emplaceBack(0,1),p.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(p,Ua.members),this.viewportSegments=l.S.simpleSegment(0,0,4,2);const g=new l.a$;g.emplaceBack(0),g.emplaceBack(1),g.emplaceBack(3),g.emplaceBack(2),g.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(g);const _=new l.b0;_.emplaceBack(0,1,2),_.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(_);const x=this.context.gl;this.stencilClearMode=new Ot({func:x.ALWAYS,mask:0},0,255,x.ZERO,x.ZERO,x.ZERO)}clearStencil(){const t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const s=l.Z();l.aS(s,0,this.width,this.height,0,0,1),l.a0(s,s,[n.drawingBufferWidth,n.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,n.TRIANGLES,ft.disabled,this.stencilClearMode,Bt.disabled,Lt.disabled,Wo(s),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,n){if(this.currentStencilSource===t.source||!t.isTileClipped()||!n||!n.length)return;this.currentStencilSource=t.source;const s=this.context,c=s.gl;this.nextStencilID+n.length>256&&this.clearStencil(),s.setColorMode(Bt.disabled),s.setDepthMode(ft.disabled);const p=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const g of n){const _=this._tileClippingMaskIDs[g.key]=this.nextStencilID++,x=this.style.map.terrain&&this.style.map.terrain.getTerrainData(g);p.draw(s,c.TRIANGLES,ft.disabled,new Ot({func:c.ALWAYS,mask:0},_,255,c.KEEP,c.KEEP,c.REPLACE),Bt.disabled,Lt.disabled,Wo(g.posMatrix),x,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,n=this.context.gl;return new Ot({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){const n=this.context.gl;return new Ot({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(t){const n=this.context.gl,s=t.sort(((g,_)=>_.overscaledZ-g.overscaledZ)),c=s[s.length-1].overscaledZ,p=s[0].overscaledZ-c+1;if(p>1){this.currentStencilSource=void 0,this.nextStencilID+p>256&&this.clearStencil();const g={};for(let _=0;_<p;_++)g[_+c]=new Ot({func:n.GEQUAL,mask:255},_+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=p,[g,s]}return[{[c]:Ot.disabled},s]}colorModeForRenderPass(){const t=this.context.gl;return this._showOverdrawInspector?new Bt([t.CONSTANT_COLOR,t.ONE],new l.aT(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?Bt.unblended:Bt.alphaBlended}depthModeForSublayer(t,n,s){if(!this.opaquePassEnabledForLayer())return ft.disabled;const c=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new ft(s||this.context.gl.LEQUAL,n,[c,c])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,n){this.style=t,this.options=n,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(l.h.now()),this.imageManager.beginFrame();const s=this.style._order,c=this.style.sourceCaches,p={},g={},_={};for(const x in c){const b=c[x];b.used&&b.prepare(this.context),p[x]=b.getVisibleCoordinates(),g[x]=p[x].slice().reverse(),_[x]=b.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let x=0;x<s.length;x++)if(this.style._layers[s[x]].is3D()){this.opaquePassCutoff=x;break}if(this.renderToTexture){this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0;const x=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime);(this.terrainFacilitator.dirty||!l.b1(this.terrainFacilitator.matrix,this.transform.projMatrix)||x.length)&&(l.b2(this.terrainFacilitator.matrix,this.transform.projMatrix),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,(function(b,T){const I=b.context,P=I.gl,V=Bt.unblended,N=new ft(P.LEQUAL,ft.ReadWrite,[0,1]),$=T.getTerrainMesh(),B=T.sourceCache.getRenderableTiles(),ee=b.useProgram("terrainDepth");I.bindFramebuffer.set(T.getFramebuffer("depth").framebuffer),I.viewport.set([0,0,b.width/devicePixelRatio,b.height/devicePixelRatio]),I.clear({color:l.aT.transparent,depth:1});for(const se of B){const G=T.getTerrainData(se.tileID),te={u_matrix:b.transform.calculatePosMatrix(se.tileID.toUnwrapped()),u_ele_delta:T.getMeshFrameDelta(b.transform.zoom)};ee.draw(I,P.TRIANGLES,N,Ot.disabled,V,Lt.backCCW,te,G,"terrain",$.vertexBuffer,$.indexBuffer,$.segments)}I.bindFramebuffer.set(null),I.viewport.set([0,0,b.width,b.height])})(this,this.style.map.terrain),(function(b,T){const I=b.context,P=I.gl,V=Bt.unblended,N=new ft(P.LEQUAL,ft.ReadWrite,[0,1]),$=T.getTerrainMesh(),B=T.getCoordsTexture(),ee=T.sourceCache.getRenderableTiles(),se=b.useProgram("terrainCoords");I.bindFramebuffer.set(T.getFramebuffer("coords").framebuffer),I.viewport.set([0,0,b.width/devicePixelRatio,b.height/devicePixelRatio]),I.clear({color:l.aT.transparent,depth:1}),T.coordsIndex=[];for(const G of ee){const te=T.getTerrainData(G.tileID);I.activeTexture.set(P.TEXTURE0),P.bindTexture(P.TEXTURE_2D,B.texture);const ce={u_matrix:b.transform.calculatePosMatrix(G.tileID.toUnwrapped()),u_terrain_coords_id:(255-T.coordsIndex.length)/255,u_texture:0,u_ele_delta:T.getMeshFrameDelta(b.transform.zoom)};se.draw(I,P.TRIANGLES,N,Ot.disabled,V,Lt.backCCW,ce,te,"terrain",$.vertexBuffer,$.indexBuffer,$.segments),T.coordsIndex.push(G.tileID.key)}I.bindFramebuffer.set(null),I.viewport.set([0,0,b.width,b.height])})(this,this.style.map.terrain))}this.renderPass="offscreen";for(const x of s){const b=this.style._layers[x];if(!b.hasOffscreenPass()||b.isHidden(this.transform.zoom))continue;const T=g[b.source];(b.type==="custom"||T.length)&&this.renderLayer(this,c[b.source],b,T)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?l.aT.black:l.aT.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=s.length-1;this.currentLayer>=0;this.currentLayer--){const x=this.style._layers[s[this.currentLayer]],b=c[x.source],T=p[x.source];this._renderTileClippingMasks(x,T),this.renderLayer(this,b,x,T)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<s.length;this.currentLayer++){const x=this.style._layers[s[this.currentLayer]],b=c[x.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(x))continue;const T=(x.type==="symbol"?_:g)[x.source];this._renderTileClippingMasks(x,p[x.source]),this.renderLayer(this,b,x,T)}if(this.options.showTileBoundaries){const x=(function(b,T){let I=null;const P=Object.values(b._layers).flatMap((B=>B.source&&!B.isHidden(T)?[b.sourceCaches[B.source]]:[])),V=P.filter((B=>B.getSource().type==="vector")),N=P.filter((B=>B.getSource().type!=="vector")),$=B=>{(!I||I.getSource().maxzoom<B.getSource().maxzoom)&&(I=B)};return V.forEach((B=>$(B))),I||N.forEach((B=>$(B))),I})(this.style,this.transform.zoom);x&&(function(b,T,I){for(let P=0;P<I.length;P++)ul(b,T,I[P])})(this,x,x.getVisibleCoordinates())}this.options.showPadding&&(function(x){const b=x.transform.padding;ya(x,x.transform.height-(b.top||0),3,ol),ya(x,b.bottom||0,3,as),ss(x,b.left||0,3,Qs),ss(x,x.transform.width-(b.right||0),3,ll);const T=x.transform.centerPoint;(function(I,P,V,N){os(I,P-1,V-10,2,20,N),os(I,P-10,V-1,20,2,N)})(x,T.x,x.transform.height-T.y,cl)})(this),this.context.setDefault()}renderLayer(t,n,s,c){if(!s.isHidden(this.transform.zoom)&&(s.type==="background"||s.type==="custom"||(c||[]).length))switch(this.id=s.id,s.type){case"symbol":(function(p,g,_,x,b){if(p.renderPass!=="translucent")return;const T=Ot.disabled,I=p.colorModeForRenderPass();(_._unevaluatedLayout.hasValue("text-variable-anchor")||_._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&(function(P,V,N,$,B,ee,se){const G=V.transform,te=B==="map",ce=ee==="map";for(const ue of P){const me=$.getTile(ue),be=me.getBucket(N);if(!be||!be.text||!be.text.segments.get().length)continue;const xe=l.ah(be.textSizeData,G.zoom),Te=J(me,1,V.transform.zoom),Be=Ae(ue.posMatrix,ce,te,V.transform,Te),ut=N.layout.get("icon-text-fit")!=="none"&&be.hasIconData();if(xe){const Ee=Math.pow(2,G.zoom-me.tileID.overscaledZ);rs(be,te,ce,se,G,Be,ue.posMatrix,Ee,xe,ut,V.style.map.terrain?(We,Ne)=>V.style.map.terrain.getElevation(ue,We,Ne):null)}}})(x,p,_,g,_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),b),_.paint.get("icon-opacity").constantOr(1)!==0&&ns(p,g,_,x,!1,_.paint.get("icon-translate"),_.paint.get("icon-translate-anchor"),_.layout.get("icon-rotation-alignment"),_.layout.get("icon-pitch-alignment"),_.layout.get("icon-keep-upright"),T,I),_.paint.get("text-opacity").constantOr(1)!==0&&ns(p,g,_,x,!0,_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),_.layout.get("text-keep-upright"),T,I),g.map.showCollisionBoxes&&(sl(p,g,_,x,_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),!0),sl(p,g,_,x,_.paint.get("icon-translate"),_.paint.get("icon-translate-anchor"),!1))})(t,n,s,c,this.style.placement.variableOffsets);break;case"circle":(function(p,g,_,x){if(p.renderPass!=="translucent")return;const b=_.paint.get("circle-opacity"),T=_.paint.get("circle-stroke-width"),I=_.paint.get("circle-stroke-opacity"),P=!_.layout.get("circle-sort-key").isConstant();if(b.constantOr(1)===0&&(T.constantOr(1)===0||I.constantOr(1)===0))return;const V=p.context,N=V.gl,$=p.depthModeForSublayer(0,ft.ReadOnly),B=Ot.disabled,ee=p.colorModeForRenderPass(),se=[];for(let G=0;G<x.length;G++){const te=x[G],ce=g.getTile(te),ue=ce.getBucket(_);if(!ue)continue;const me=ue.programConfigurations.get(_.id),be=p.useProgram("circle",me),xe=ue.layoutVertexBuffer,Te=ue.indexBuffer,Be=p.style.map.terrain&&p.style.map.terrain.getTerrainData(te),ut={programConfiguration:me,program:be,layoutVertexBuffer:xe,indexBuffer:Te,uniformValues:en(p,te,ce,_),terrainData:Be};if(P){const Ee=ue.segments.get();for(const We of Ee)se.push({segments:new l.S([We]),sortKey:We.sortKey,state:ut})}else se.push({segments:ue.segments,sortKey:0,state:ut})}P&&se.sort(((G,te)=>G.sortKey-te.sortKey));for(const G of se){const{programConfiguration:te,program:ce,layoutVertexBuffer:ue,indexBuffer:me,uniformValues:be,terrainData:xe}=G.state;ce.draw(V,N.TRIANGLES,$,B,ee,Lt.disabled,be,xe,_.id,ue,me,G.segments,_.paint,p.transform.zoom,te)}})(t,n,s,c);break;case"heatmap":(function(p,g,_,x){if(_.paint.get("heatmap-opacity")!==0)if(p.renderPass==="offscreen"){const b=p.context,T=b.gl,I=Ot.disabled,P=new Bt([T.ONE,T.ONE],l.aT.transparent,[!0,!0,!0,!0]);(function(V,N,$){const B=V.gl;V.activeTexture.set(B.TEXTURE1),V.viewport.set([0,0,N.width/4,N.height/4]);let ee=$.heatmapFbo;if(ee)B.bindTexture(B.TEXTURE_2D,ee.colorAttachment.get()),V.bindFramebuffer.set(ee.framebuffer);else{const se=B.createTexture();B.bindTexture(B.TEXTURE_2D,se),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_WRAP_S,B.CLAMP_TO_EDGE),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_WRAP_T,B.CLAMP_TO_EDGE),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_MIN_FILTER,B.LINEAR),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_MAG_FILTER,B.LINEAR),ee=$.heatmapFbo=V.createFramebuffer(N.width/4,N.height/4,!1,!1),(function(G,te,ce,ue){var me,be;const xe=G.gl,Te=(me=G.HALF_FLOAT)!==null&&me!==void 0?me:xe.UNSIGNED_BYTE,Be=(be=G.RGBA16F)!==null&&be!==void 0?be:xe.RGBA;xe.texImage2D(xe.TEXTURE_2D,0,Be,te.width/4,te.height/4,0,xe.RGBA,Te,null),ue.colorAttachment.set(ce)})(V,N,se,ee)}})(b,p,_),b.clear({color:l.aT.transparent});for(let V=0;V<x.length;V++){const N=x[V];if(g.hasRenderableParent(N))continue;const $=g.getTile(N),B=$.getBucket(_);if(!B)continue;const ee=B.programConfigurations.get(_.id),se=p.useProgram("heatmap",ee),{zoom:G}=p.transform;se.draw(b,T.TRIANGLES,ft.disabled,I,P,Lt.disabled,mc(N.posMatrix,$,G,_.paint.get("heatmap-intensity")),null,_.id,B.layoutVertexBuffer,B.indexBuffer,B.segments,_.paint,p.transform.zoom,ee)}b.viewport.set([0,0,p.width,p.height])}else p.renderPass==="translucent"&&(p.context.setColorMode(p.colorModeForRenderPass()),(function(b,T){const I=b.context,P=I.gl,V=T.heatmapFbo;if(!V)return;I.activeTexture.set(P.TEXTURE0),P.bindTexture(P.TEXTURE_2D,V.colorAttachment.get()),I.activeTexture.set(P.TEXTURE1);let N=T.colorRampTexture;N||(N=T.colorRampTexture=new nt(I,T.colorRamp,P.RGBA)),N.bind(P.LINEAR,P.CLAMP_TO_EDGE),b.useProgram("heatmapTexture").draw(I,P.TRIANGLES,ft.disabled,Ot.disabled,b.colorModeForRenderPass(),Lt.disabled,(($,B,ee,se)=>{const G=l.Z();l.aS(G,0,$.width,$.height,0,0,1);const te=$.context.gl;return{u_matrix:G,u_world:[te.drawingBufferWidth,te.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:B.paint.get("heatmap-opacity")}})(b,T),null,T.id,b.viewportBuffer,b.quadTriangleIndexBuffer,b.viewportSegments,T.paint,b.transform.zoom)})(p,_))})(t,n,s,c);break;case"line":(function(p,g,_,x){if(p.renderPass!=="translucent")return;const b=_.paint.get("line-opacity"),T=_.paint.get("line-width");if(b.constantOr(1)===0||T.constantOr(1)===0)return;const I=p.depthModeForSublayer(0,ft.ReadOnly),P=p.colorModeForRenderPass(),V=_.paint.get("line-dasharray"),N=_.paint.get("line-pattern"),$=N.constantOr(1),B=_.paint.get("line-gradient"),ee=_.getCrossfadeParameters(),se=$?"linePattern":V?"lineSDF":B?"lineGradient":"line",G=p.context,te=G.gl;let ce=!0;for(const ue of x){const me=g.getTile(ue);if($&&!me.patternsLoaded())continue;const be=me.getBucket(_);if(!be)continue;const xe=be.programConfigurations.get(_.id),Te=p.context.program.get(),Be=p.useProgram(se,xe),ut=ce||Be.program!==Te,Ee=p.style.map.terrain&&p.style.map.terrain.getTerrainData(ue),We=N.constantOr(null);if(We&&me.imageAtlas){const ct=me.imageAtlas,at=ct.patternPositions[We.to.toString()],ht=ct.patternPositions[We.from.toString()];at&&ht&&xe.setConstantPatternPositions(at,ht)}const Ne=Ee?ue:null,St=$?gc(p,me,_,ee,Ne):V?Ko(p,me,_,V,ee,Ne):B?Xo(p,me,_,be.lineClipsArray.length,Ne):Rs(p,me,_,Ne);if($)G.activeTexture.set(te.TEXTURE0),me.imageAtlasTexture.bind(te.LINEAR,te.CLAMP_TO_EDGE),xe.updatePaintBuffers(ee);else if(V&&(ut||p.lineAtlas.dirty))G.activeTexture.set(te.TEXTURE0),p.lineAtlas.bind(G);else if(B){const ct=be.gradients[_.id];let at=ct.texture;if(_.gradientVersion!==ct.version){let ht=256;if(_.stepInterpolant){const Zt=g.getSource().maxzoom,Ct=ue.canonical.z===Zt?Math.ceil(1<<p.transform.maxZoom-ue.canonical.z):1;ht=l.ad(l.aY(be.maxLineLength/l.N*1024*Ct),256,G.maxTextureSize)}ct.gradient=l.aZ({expression:_.gradientExpression(),evaluationKey:"lineProgress",resolution:ht,image:ct.gradient||void 0,clips:be.lineClipsArray}),ct.texture?ct.texture.update(ct.gradient):ct.texture=new nt(G,ct.gradient,te.RGBA),ct.version=_.gradientVersion,at=ct.texture}G.activeTexture.set(te.TEXTURE0),at.bind(_.stepInterpolant?te.NEAREST:te.LINEAR,te.CLAMP_TO_EDGE)}Be.draw(G,te.TRIANGLES,I,p.stencilModeForClipping(ue),P,Lt.disabled,St,Ee,_.id,be.layoutVertexBuffer,be.indexBuffer,be.segments,_.paint,p.transform.zoom,xe,be.layoutVertexBuffer2),ce=!1}})(t,n,s,c);break;case"fill":(function(p,g,_,x){const b=_.paint.get("fill-color"),T=_.paint.get("fill-opacity");if(T.constantOr(1)===0)return;const I=p.colorModeForRenderPass(),P=_.paint.get("fill-pattern"),V=p.opaquePassEnabledForLayer()&&!P.constantOr(1)&&b.constantOr(l.aT.transparent).a===1&&T.constantOr(0)===1?"opaque":"translucent";if(p.renderPass===V){const N=p.depthModeForSublayer(1,p.renderPass==="opaque"?ft.ReadWrite:ft.ReadOnly);ga(p,g,_,x,N,I,!1)}if(p.renderPass==="translucent"&&_.paint.get("fill-antialias")){const N=p.depthModeForSublayer(_.getPaintProperty("fill-outline-color")?2:0,ft.ReadOnly);ga(p,g,_,x,N,I,!0)}})(t,n,s,c);break;case"fill-extrusion":(function(p,g,_,x){const b=_.paint.get("fill-extrusion-opacity");if(b!==0&&p.renderPass==="translucent"){const T=new ft(p.context.gl.LEQUAL,ft.ReadWrite,p.depthRangeFor3D);if(b!==1||_.paint.get("fill-extrusion-pattern").constantOr(1))_a(p,g,_,x,T,Ot.disabled,Bt.disabled),_a(p,g,_,x,T,p.stencilModeFor3D(),p.colorModeForRenderPass());else{const I=p.colorModeForRenderPass();_a(p,g,_,x,T,Ot.disabled,I)}}})(t,n,s,c);break;case"hillshade":(function(p,g,_,x){if(p.renderPass!=="offscreen"&&p.renderPass!=="translucent")return;const b=p.context,T=p.depthModeForSublayer(0,ft.ReadOnly),I=p.colorModeForRenderPass(),[P,V]=p.renderPass==="translucent"?p.stencilConfigForOverlap(x):[{},x];for(const N of V){const $=g.getTile(N);$.needsHillshadePrepare!==void 0&&$.needsHillshadePrepare&&p.renderPass==="offscreen"?Js(p,$,_,T,Ot.disabled,I):p.renderPass==="translucent"&&Tc(p,N,$,_,T,P[N.overscaledZ],I)}b.viewport.set([0,0,p.width,p.height])})(t,n,s,c);break;case"raster":(function(p,g,_,x){if(p.renderPass!=="translucent"||_.paint.get("raster-opacity")===0||!x.length)return;const b=p.context,T=b.gl,I=g.getSource(),P=p.useProgram("raster"),V=p.colorModeForRenderPass(),[N,$]=I instanceof ar?[{},x]:p.stencilConfigForOverlap(x),B=$[$.length-1].overscaledZ,ee=!p.options.moving;for(const se of $){const G=p.depthModeForSublayer(se.overscaledZ-B,_.paint.get("raster-opacity")===1?ft.ReadWrite:ft.ReadOnly,T.LESS),te=g.getTile(se);te.registerFadeDuration(_.paint.get("raster-fade-duration"));const ce=g.findLoadedParent(se,0),ue=Ic(te,ce,g,_,p.transform,p.style.map.terrain);let me,be;const xe=_.paint.get("raster-resampling")==="nearest"?T.NEAREST:T.LINEAR;b.activeTexture.set(T.TEXTURE0),te.texture.bind(xe,T.CLAMP_TO_EDGE,T.LINEAR_MIPMAP_NEAREST),b.activeTexture.set(T.TEXTURE1),ce?(ce.texture.bind(xe,T.CLAMP_TO_EDGE,T.LINEAR_MIPMAP_NEAREST),me=Math.pow(2,ce.tileID.overscaledZ-te.tileID.overscaledZ),be=[te.tileID.canonical.x*me%1,te.tileID.canonical.y*me%1]):te.texture.bind(xe,T.CLAMP_TO_EDGE,T.LINEAR_MIPMAP_NEAREST);const Te=p.style.map.terrain&&p.style.map.terrain.getTerrainData(se),Be=Te?se:null,ut=Be?Be.posMatrix:p.transform.calculatePosMatrix(se.toUnwrapped(),ee),Ee=Jo(ut,be||[0,0],me||1,ue,_);I instanceof ar?P.draw(b,T.TRIANGLES,G,Ot.disabled,V,Lt.disabled,Ee,Te,_.id,I.boundsBuffer,p.quadTriangleIndexBuffer,I.boundsSegments):P.draw(b,T.TRIANGLES,G,N[se.overscaledZ],V,Lt.disabled,Ee,Te,_.id,p.rasterBoundsBuffer,p.quadTriangleIndexBuffer,p.rasterBoundsSegments)}})(t,n,s,c);break;case"background":(function(p,g,_,x){const b=_.paint.get("background-color"),T=_.paint.get("background-opacity");if(T===0)return;const I=p.context,P=I.gl,V=p.transform,N=V.tileSize,$=_.paint.get("background-pattern");if(p.isPatternMissing($))return;const B=!$&&b.a===1&&T===1&&p.opaquePassEnabledForLayer()?"opaque":"translucent";if(p.renderPass!==B)return;const ee=Ot.disabled,se=p.depthModeForSublayer(0,B==="opaque"?ft.ReadWrite:ft.ReadOnly),G=p.colorModeForRenderPass(),te=p.useProgram($?"backgroundPattern":"background"),ce=x||V.coveringTiles({tileSize:N,terrain:p.style.map.terrain});$&&(I.activeTexture.set(P.TEXTURE0),p.imageManager.bind(p.context));const ue=_.getCrossfadeParameters();for(const me of ce){const be=x?me.posMatrix:p.transform.calculatePosMatrix(me.toUnwrapped()),xe=$?ur(be,T,p,$,{tileID:me,tileSize:N},ue):Ga(be,T,b),Te=p.style.map.terrain&&p.style.map.terrain.getTerrainData(me);te.draw(I,P.TRIANGLES,se,ee,G,Lt.disabled,xe,Te,_.id,p.tileExtentBuffer,p.quadTriangleIndexBuffer,p.tileExtentSegments)}})(t,0,s,c);break;case"custom":(function(p,g,_){const x=p.context,b=_.implementation;if(p.renderPass==="offscreen"){const T=b.prerender;T&&(p.setCustomLayerDefaults(),x.setColorMode(p.colorModeForRenderPass()),T.call(b,x.gl,p.transform.customLayerMatrix()),x.setDirty(),p.setBaseState())}else if(p.renderPass==="translucent"){p.setCustomLayerDefaults(),x.setColorMode(p.colorModeForRenderPass()),x.setStencilMode(Ot.disabled);const T=b.renderingMode==="3d"?new ft(p.context.gl.LEQUAL,ft.ReadWrite,p.depthRangeFor3D):p.depthModeForSublayer(0,ft.ReadOnly);x.setDepthMode(T),b.render(x.gl,p.transform.customLayerMatrix()),x.setDirty(),p.setBaseState(),x.bindFramebuffer.set(null)}})(t,0,s)}}translatePosMatrix(t,n,s,c,p){if(!s[0]&&!s[1])return t;const g=p?c==="map"?this.transform.angle:0:c==="viewport"?-this.transform.angle:0;if(g){const b=Math.sin(g),T=Math.cos(g);s=[s[0]*T-s[1]*b,s[0]*b+s[1]*T]}const _=[p?s[0]:J(n,s[0],this.transform.zoom),p?s[1]:J(n,s[1],this.transform.zoom),0],x=new Float32Array(16);return l.$(x,t,_),x}saveTileTexture(t){const n=this._tileTextures[t.size[0]];n?n.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const n=this._tileTextures[t];return n&&n.length>0?n.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const n=this.imageManager.getPattern(t.from.toString()),s=this.imageManager.getPattern(t.to.toString());return!n||!s}useProgram(t,n){this.cache=this.cache||{};const s=t+(n?n.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[s]||(this.cache[s]=new $a(this.context,Rt[t],n,Ha[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[s]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new nt(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:n}=this.context.gl;return this.width!==t||this.height!==n}}class Li{constructor(t,n){this.points=t,this.planes=n}static fromInvProjectionMatrix(t,n,s){const c=Math.pow(2,s),p=[[-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((_=>{const x=1/(_=l.ag([],_,t))[3]/n*c;return l.b3(_,_,[x,x,1/_[3],x])})),g=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((_=>{const x=(function(P,V){var N=V[0],$=V[1],B=V[2],ee=N*N+$*$+B*B;return ee>0&&(ee=1/Math.sqrt(ee)),P[0]=V[0]*ee,P[1]=V[1]*ee,P[2]=V[2]*ee,P})([],(function(P,V,N){var $=V[0],B=V[1],ee=V[2],se=N[0],G=N[1],te=N[2];return P[0]=B*te-ee*G,P[1]=ee*se-$*te,P[2]=$*G-B*se,P})([],rr([],p[_[0]],p[_[1]]),rr([],p[_[2]],p[_[1]]))),b=-((T=x)[0]*(I=p[_[1]])[0]+T[1]*I[1]+T[2]*I[2]);var T,I;return x.concat(b)}));return new Li(p,g)}}class Wn{constructor(t,n){this.min=t,this.max=n,this.center=(function(s,c,p){return s[0]=.5*c[0],s[1]=.5*c[1],s[2]=.5*c[2],s})([],(function(s,c,p){return s[0]=c[0]+p[0],s[1]=c[1]+p[1],s[2]=c[2]+p[2],s})([],this.min,this.max))}quadrant(t){const n=[t%2==0,t<2],s=Pi(this.min),c=Pi(this.max);for(let p=0;p<n.length;p++)s[p]=n[p]?this.min[p]:this.center[p],c[p]=n[p]?this.center[p]:this.max[p];return c[2]=this.max[2],new Wn(s,c)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersects(t){const n=[[this.min[0],this.min[1],this.min[2],1],[this.max[0],this.min[1],this.min[2],1],[this.max[0],this.max[1],this.min[2],1],[this.min[0],this.max[1],this.min[2],1],[this.min[0],this.min[1],this.max[2],1],[this.max[0],this.min[1],this.max[2],1],[this.max[0],this.max[1],this.max[2],1],[this.min[0],this.max[1],this.max[2],1]];let s=!0;for(let c=0;c<t.planes.length;c++){const p=t.planes[c];let g=0;for(let _=0;_<n.length;_++)l.b4(p,n[_])>=0&&g++;if(g===0)return 0;g!==n.length&&(s=!1)}if(s)return 2;for(let c=0;c<3;c++){let p=Number.MAX_VALUE,g=-Number.MAX_VALUE;for(let _=0;_<t.points.length;_++){const x=t.points[_][c]-this.min[c];p=Math.min(p,x),g=Math.max(g,x)}if(g<0||p>this.max[c]-this.min[c])return 0}return 1}}class xa{constructor(t=0,n=0,s=0,c=0){if(isNaN(t)||t<0||isNaN(n)||n<0||isNaN(s)||s<0||isNaN(c)||c<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=n,this.left=s,this.right=c}interpolate(t,n,s){return n.top!=null&&t.top!=null&&(this.top=l.B.number(t.top,n.top,s)),n.bottom!=null&&t.bottom!=null&&(this.bottom=l.B.number(t.bottom,n.bottom,s)),n.left!=null&&t.left!=null&&(this.left=l.B.number(t.left,n.left,s)),n.right!=null&&t.right!=null&&(this.right=l.B.number(t.right,n.right,s)),this}getCenter(t,n){const s=l.ad((this.left+t-this.right)/2,0,t),c=l.ad((this.top+n-this.bottom)/2,0,n);return new l.P(s,c)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new xa(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class ls{constructor(t,n,s,c,p){this.tileSize=512,this.maxValidLatitude=85.051129,this._renderWorldCopies=p===void 0||!!p,this._minZoom=t||0,this._maxZoom=n||22,this._minPitch=s??0,this._maxPitch=c??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new l.L(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new xa,this._posMatrixCache={},this._alignedPosMatrixCache={},this._minEleveationForCurrentTile=0}clone(){const t=new ls(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.apply(this),t}apply(t){this.tileSize=t.tileSize,this.latRange=t.latRange,this.width=t.width,this.height=t.height,this._center=t._center,this._elevation=t._elevation,this._minEleveationForCurrentTile=t._minEleveationForCurrentTile,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 l.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){const n=-l.b5(t,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=(function(){var s=new l.A(4);return l.A!=Float32Array&&(s[1]=0,s[2]=0),s[0]=1,s[3]=1,s})(),(function(s,c,p){var g=c[0],_=c[1],x=c[2],b=c[3],T=Math.sin(p),I=Math.cos(p);s[0]=g*I+x*T,s[1]=_*I+b*T,s[2]=g*-T+x*I,s[3]=_*-T+b*I})(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const n=l.ad(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(t){const n=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this.tileZoom=Math.max(0,Math.floor(n)),this.scale=this.zoomScale(n),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,n,s){this._unmodified=!1,this._edgeInsets.interpolate(t,n,s),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const n=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,n)}getVisibleUnwrappedCoordinates(t){const n=[new l.b6(0,t)];if(this._renderWorldCopies){const s=this.pointCoordinate(new l.P(0,0)),c=this.pointCoordinate(new l.P(this.width,0)),p=this.pointCoordinate(new l.P(this.width,this.height)),g=this.pointCoordinate(new l.P(0,this.height)),_=Math.floor(Math.min(s.x,c.x,p.x,g.x)),x=Math.floor(Math.max(s.x,c.x,p.x,g.x)),b=1;for(let T=_-b;T<=x+b;T++)T!==0&&n.push(new l.b6(T,t))}return n}coveringTiles(t){var n,s;let c=this.coveringZoomLevel(t);const p=c;if(t.minzoom!==void 0&&c<t.minzoom)return[];t.maxzoom!==void 0&&c>t.maxzoom&&(c=t.maxzoom);const g=this.pointCoordinate(this.getCameraPoint()),_=l.U.fromLngLat(this.center),x=Math.pow(2,c),b=[x*g.x,x*g.y,0],T=[x*_.x,x*_.y,0],I=Li.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,c);let P=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(P=c);const V=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,N=G=>({aabb:new Wn([G*x,0,0],[(G+1)*x,x,0]),zoom:0,x:0,y:0,wrap:G,fullyVisible:!1}),$=[],B=[],ee=c,se=t.reparseOverscaled?p:c;if(this._renderWorldCopies)for(let G=1;G<=3;G++)$.push(N(-G)),$.push(N(G));for($.push(N(0));$.length>0;){const G=$.pop(),te=G.x,ce=G.y;let ue=G.fullyVisible;if(!ue){const Be=G.aabb.intersects(I);if(Be===0)continue;ue=Be===2}const me=t.terrain?b:T,be=G.aabb.distanceX(me),xe=G.aabb.distanceY(me),Te=Math.max(Math.abs(be),Math.abs(xe));if(G.zoom===ee||Te>V+(1<<ee-G.zoom)-2&&G.zoom>=P){const Be=ee-G.zoom,ut=b[0]-.5-(te<<Be),Ee=b[1]-.5-(ce<<Be);B.push({tileID:new l.O(G.zoom===ee?se:G.zoom,G.wrap,G.zoom,te,ce),distanceSq:hn([T[0]-.5-te,T[1]-.5-ce]),tileDistanceToCamera:Math.sqrt(ut*ut+Ee*Ee)})}else for(let Be=0;Be<4;Be++){const ut=(te<<1)+Be%2,Ee=(ce<<1)+(Be>>1),We=G.zoom+1;let Ne=G.aabb.quadrant(Be);if(t.terrain){const St=new l.O(We,G.wrap,We,ut,Ee),ct=t.terrain.getMinMaxElevation(St),at=(n=ct.minElevation)!==null&&n!==void 0?n:this.elevation,ht=(s=ct.maxElevation)!==null&&s!==void 0?s:this.elevation;Ne=new Wn([Ne.min[0],Ne.min[1],at],[Ne.max[0],Ne.max[1],ht])}$.push({aabb:Ne,zoom:We,x:ut,y:Ee,wrap:G.wrap,fullyVisible:ue})}}return B.sort(((G,te)=>G.distanceSq-te.distanceSq)).map((G=>G.tileID))}resize(t,n){this.width=t,this.height=n,this.pixelsToGLUnits=[2/t,-2/n],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){const n=l.ad(t.lat,-this.maxValidLatitude,this.maxValidLatitude);return new l.P(l.G(t.lng)*this.worldSize,l.H(n)*this.worldSize)}unproject(t){return new l.U(t.x/this.worldSize,t.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(t){const n=this.pointLocation(this.centerPoint,t),s=t.getElevationForLngLatZoom(n,this.tileZoom);if(!(this.elevation-s))return;const c=this.getCameraPosition(),p=l.U.fromLngLat(c.lngLat,c.altitude),g=l.U.fromLngLat(n,s),_=p.x-g.x,x=p.y-g.y,b=p.z-g.z,T=Math.sqrt(_*_+x*x+b*b),I=this.scaleZoom(this.cameraToCenterDistance/T/this.tileSize);this._elevation=s,this._center=n,this.zoom=I}setLocationAtPoint(t,n){const s=this.pointCoordinate(n),c=this.pointCoordinate(this.centerPoint),p=this.locationCoordinate(t),g=new l.U(p.x-(s.x-c.x),p.y-(s.y-c.y));this.center=this.coordinateLocation(g),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,n){return n?this.coordinatePoint(this.locationCoordinate(t),n.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,n){return this.coordinateLocation(this.pointCoordinate(t,n))}locationCoordinate(t){return l.U.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,n){if(n){const P=n.pointCoordinate(t);if(P!=null)return P}const s=[t.x,t.y,0,1],c=[t.x,t.y,1,1];l.ag(s,s,this.pixelMatrixInverse),l.ag(c,c,this.pixelMatrixInverse);const p=s[3],g=c[3],_=s[1]/p,x=c[1]/g,b=s[2]/p,T=c[2]/g,I=b===T?0:(0-b)/(T-b);return new l.U(l.B.number(s[0]/p,c[0]/g,I)/this.worldSize,l.B.number(_,x,I)/this.worldSize)}coordinatePoint(t,n=0,s=this.pixelMatrix){const c=[t.x*this.worldSize,t.y*this.worldSize,n,1];return l.ag(c,c,s),new l.P(c[0]/c[3],c[1]/c[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return new Et().extend(this.pointLocation(new l.P(0,t))).extend(this.pointLocation(new l.P(this.width,t))).extend(this.pointLocation(new l.P(this.width,this.height))).extend(this.pointLocation(new l.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new Et([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-this.maxValidLatitude,this.maxValidLatitude])}calculatePosMatrix(t,n=!1){const s=t.key,c=n?this._alignedPosMatrixCache:this._posMatrixCache;if(c[s])return c[s];const p=t.canonical,g=this.worldSize/this.zoomScale(p.z),_=p.x+Math.pow(2,p.z)*t.wrap,x=l.ao(new Float64Array(16));return l.$(x,x,[_*g,p.y*g,0]),l.a0(x,x,[g/l.N,g/l.N,1]),l.a1(x,n?this.alignedProjMatrix:this.projMatrix,x),c[s]=new Float32Array(x),c[s]}customLayerMatrix(){return this.mercatorMatrix.slice()}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let t,n,s,c,p=-90,g=90,_=-180,x=180;const b=this.size,T=this._unmodified;if(this.latRange){const V=this.latRange;p=l.H(V[1])*this.worldSize,g=l.H(V[0])*this.worldSize,t=g-p<b.y?b.y/(g-p):0}if(this.lngRange){const V=this.lngRange;_=l.b5(l.G(V[0])*this.worldSize,0,this.worldSize),x=l.b5(l.G(V[1])*this.worldSize,0,this.worldSize),x<_&&(x+=this.worldSize),n=x-_<b.x?b.x/(x-_):0}const I=this.point,P=Math.max(n||0,t||0);if(P)return this.center=this.unproject(new l.P(n?(x+_)/2:I.x,t?(g+p)/2:I.y)),this.zoom+=this.scaleZoom(P),this._unmodified=T,void(this._constraining=!1);if(this.latRange){const V=I.y,N=b.y/2;V-N<p&&(c=p+N),V+N>g&&(c=g-N)}if(this.lngRange){const V=(_+x)/2,N=l.b5(I.x,V-this.worldSize/2,V+this.worldSize/2),$=b.x/2;N-$<_&&(s=_+$),N+$>x&&(s=x-$)}s===void 0&&c===void 0||(this.center=this.unproject(new l.P(s!==void 0?s:I.x,c!==void 0?c:I.y)).wrap()),this._unmodified=T,this._constraining=!1}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,n=this.point.x,s=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=l.b7(1,this.center.lat)*this.worldSize;let c=l.ao(new Float64Array(16));l.a0(c,c,[this.width/2,-this.height/2,1]),l.$(c,c,[1,-1,0]),this.labelPlaneMatrix=c,c=l.ao(new Float64Array(16)),l.a0(c,c,[1,-1,1]),l.$(c,c,[-1,-1,0]),l.a0(c,c,[2/this.width,2/this.height,1]),this.glCoordMatrix=c;const p=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),g=Math.min(this.elevation,this._minEleveationForCurrentTile),_=p-g*this._pixelPerMeter/Math.cos(this._pitch),x=g<0?_:p,b=Math.PI/2+this._pitch,T=this._fov*(.5+t.y/this.height),I=Math.sin(T)*x/Math.sin(l.ad(Math.PI-b-T,.01,Math.PI-.01)),P=this.getHorizon(),V=2*Math.atan(P/this.cameraToCenterDistance)*(.5+t.y/(2*P)),N=Math.sin(V)*x/Math.sin(l.ad(Math.PI-b-V,.01,Math.PI-.01)),$=Math.min(I,N),B=1.01*(Math.cos(Math.PI/2-this._pitch)*$+x),ee=this.height/50;c=new Float64Array(16),l.b8(c,this._fov,this.width/this.height,ee,B),c[8]=2*-t.x/this.width,c[9]=2*t.y/this.height,l.a0(c,c,[1,-1,1]),l.$(c,c,[0,0,-this.cameraToCenterDistance]),l.b9(c,c,this._pitch),l.ae(c,c,this.angle),l.$(c,c,[-n,-s,0]),this.mercatorMatrix=l.a0([],c,[this.worldSize,this.worldSize,this.worldSize]),l.a0(c,c,[1,1,this._pixelPerMeter]),this.pixelMatrix=l.a1(new Float64Array(16),this.labelPlaneMatrix,c),l.$(c,c,[0,0,-this.elevation]),this.projMatrix=c,this.invProjMatrix=l.as([],c),this.pixelMatrix3D=l.a1(new Float64Array(16),this.labelPlaneMatrix,c);const se=this.width%2/2,G=this.height%2/2,te=Math.cos(this.angle),ce=Math.sin(this.angle),ue=n-Math.round(n)+te*se+ce*G,me=s-Math.round(s)+te*G+ce*se,be=new Float64Array(c);if(l.$(be,be,[ue>.5?ue-1:ue,me>.5?me-1:me,0]),this.alignedProjMatrix=be,c=l.as(new Float64Array(16),this.pixelMatrix),!c)throw new Error("failed to invert matrix");this.pixelMatrixInverse=c,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const t=this.pointCoordinate(new l.P(0,0)),n=[t.x*this.worldSize,t.y*this.worldSize,0,1];return l.ag(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new l.P(0,t))}getCameraQueryGeometry(t){const n=this.getCameraPoint();if(t.length===1)return[t[0],n];{let s=n.x,c=n.y,p=n.x,g=n.y;for(const _ of t)s=Math.min(s,_.x),c=Math.min(c,_.y),p=Math.max(p,_.x),g=Math.max(g,_.y);return[new l.P(s,c),new l.P(p,c),new l.P(p,g),new l.P(s,g),new l.P(s,c)]}}}function Sn(u,t){let n,s=!1,c=null,p=null;const g=()=>{c=null,s&&(u.apply(p,n),c=setTimeout(g,t),s=!1)};return(..._)=>(s=!0,p=this,n=_,c||g(),c)}class va{constructor(t){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let s;return n.split("&").map((c=>c.split("="))).forEach((c=>{c[0]===this._hashName&&(s=c)})),(s&&s[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(n.length>=3&&!n.some((s=>isNaN(s)))){const s=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:s,pitch:+(n[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const n=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,n)}catch{}},this._updateHash=Sn(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(t){const n=this._map.getCenter(),s=Math.round(100*this._map.getZoom())/100,c=Math.ceil((s*Math.LN2+Math.log(512/360/.5))/Math.LN10),p=Math.pow(10,c),g=Math.round(n.lng*p)/p,_=Math.round(n.lat*p)/p,x=this._map.getBearing(),b=this._map.getPitch();let T="";if(T+=t?`/${g}/${_}/${s}`:`${s}/${_}/${g}`,(x||b)&&(T+="/"+Math.round(10*x)/10),b&&(T+=`/${Math.round(b)}`),this._hashName){const I=this._hashName;let P=!1;const V=window.location.hash.slice(1).split("&").map((N=>{const $=N.split("=")[0];return $===I?(P=!0,`${$}=${T}`):N})).filter((N=>N));return P||V.push(`${I}=${T}`),`#${V.join("&")}`}return`#${T}`}}const Xn={linearity:.3,easing:l.ba(0,0,.3,1)},hl=l.e({deceleration:2500,maxSpeed:1400},Xn),pl=l.e({deceleration:20,maxSpeed:1400},Xn),dl=l.e({deceleration:1e3,maxSpeed:360},Xn),fl=l.e({deceleration:1e3,maxSpeed:90},Xn);class ml{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:l.h.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=l.h.now();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new l.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:p}of this._inertiaBuffer)n.zoom+=p.zoomDelta||0,n.bearing+=p.bearingDelta||0,n.pitch+=p.pitchDelta||0,p.panDelta&&n.pan._add(p.panDelta),p.around&&(n.around=p.around),p.pinchAround&&(n.pinchAround=p.pinchAround);const s=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,c={};if(n.pan.mag()){const p=ba(n.pan.mag(),s,l.e({},hl,t||{}));c.offset=n.pan.mult(p.amount/n.pan.mag()),c.center=this._map.transform.center,Tr(c,p)}if(n.zoom){const p=ba(n.zoom,s,pl);c.zoom=this._map.transform.zoom+p.amount,Tr(c,p)}if(n.bearing){const p=ba(n.bearing,s,dl);c.bearing=this._map.transform.bearing+l.ad(p.amount,-179,179),Tr(c,p)}if(n.pitch){const p=ba(n.pitch,s,fl);c.pitch=this._map.transform.pitch+p.amount,Tr(c,p)}if(c.zoom||c.bearing){const p=n.pinchAround===void 0?n.around:n.pinchAround;c.around=p?this._map.unproject(p):this._map.getCenter()}return this.clear(),l.e(c,{noMoveStart:!0})}}function Tr(u,t){(!u.duration||u.duration<t.duration)&&(u.duration=t.duration,u.easing=t.easing)}function ba(u,t,n){const{maxSpeed:s,linearity:c,deceleration:p}=n,g=l.ad(u*c/(t/1e3),-s,s),_=Math.abs(g)/(p*c);return{easing:n.easing,duration:1e3*_,amount:g*(_/2)}}class Xi extends l.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,s,c={}){const p=W.mousePos(n.getCanvasContainer(),s),g=n.unproject(p);super(t,l.e({point:p,lngLat:g,originalEvent:s},c)),this._defaultPrevented=!1,this.target=n}}class wa extends l.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,s){const c=t==="touchend"?s.changedTouches:s.touches,p=W.touchPos(n.getCanvasContainer(),c),g=p.map((x=>n.unproject(x))),_=p.reduce(((x,b,T,I)=>x.add(b.div(I.length))),new l.P(0,0));super(t,{points:p,point:_,lngLats:g,lngLat:n.unproject(_),originalEvent:s}),this._defaultPrevented=!1}}class gl extends l.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,s){super(t,{originalEvent:s}),this._defaultPrevented=!1}}class _l{constructor(t,n){this._map=t,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new gl(t.type,this._map,t))}mousedown(t,n){return this._mousedownPos=n,this._firePreventable(new Xi(t.type,this._map,t))}mouseup(t){this._map.fire(new Xi(t.type,this._map,t))}click(t,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new Xi(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Xi(t.type,this._map,t))}mouseover(t){this._map.fire(new Xi(t.type,this._map,t))}mouseout(t){this._map.fire(new Xi(t.type,this._map,t))}touchstart(t){return this._firePreventable(new wa(t.type,this._map,t))}touchmove(t){this._map.fire(new wa(t.type,this._map,t))}touchend(t){this._map.fire(new wa(t.type,this._map,t))}touchcancel(t){this._map.fire(new wa(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class yl{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Xi(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Xi("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Xi(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class nn{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(l.P.convert(t),this._map.terrain)}}class xl{constructor(t,n){this._map=t,this._tr=new nn(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,n){this.isEnabled()&&t.shiftKey&&t.button===0&&(W.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(t,n){if(!this._active)return;const s=n;if(this._lastPos.equals(s)||!this._box&&s.dist(this._startPos)<this._clickTolerance)return;const c=this._startPos;this._lastPos=s,this._box||(this._box=W.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));const p=Math.min(c.x,s.x),g=Math.max(c.x,s.x),_=Math.min(c.y,s.y),x=Math.max(c.y,s.y);W.setTransform(this._box,`translate(${p}px,${_}px)`),this._box.style.width=g-p+"px",this._box.style.height=x-_+"px"}mouseupWindow(t,n){if(!this._active||t.button!==0)return;const s=this._startPos,c=n;if(this.reset(),W.suppressClick(),s.x!==c.x||s.y!==c.y)return this._map.fire(new l.k("boxzoomend",{originalEvent:t})),{cameraAnimation:p=>p.fitScreenCoordinates(s,c,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&&(W.remove(this._box),this._box=null),W.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new l.k(t,{originalEvent:n}))}}function hr(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 n={};for(let s=0;s<u.length;s++)n[u[s].identifier]=t[s];return n}class Br{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,n,s){(this.centroid||s.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=t.timeStamp),s.length===this.numTouches&&(this.centroid=(function(c){const p=new l.P(0,0);for(const g of c)p._add(g);return p.div(c.length)})(n),this.touches=hr(s,n)))}touchmove(t,n,s){if(this.aborted||!this.centroid)return;const c=hr(s,n);for(const p in this.touches){const g=c[p];(!g||g.dist(this.touches[p])>30)&&(this.aborted=!0)}}touchend(t,n,s){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),s.length===0){const c=!this.aborted&&this.centroid;if(this.reset(),c)return c}}}class cs{constructor(t){this.singleTap=new Br(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,n,s){this.singleTap.touchstart(t,n,s)}touchmove(t,n,s){this.singleTap.touchmove(t,n,s)}touchend(t,n,s){const c=this.singleTap.touchend(t,n,s);if(c){const p=t.timeStamp-this.lastTime<500,g=!this.lastTap||this.lastTap.dist(c)<30;if(p&&g||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=c,this.count===this.numTaps)return this.reset(),c}}}class Or{constructor(t){this._tr=new nn(t),this._zoomIn=new cs({numTouches:1,numTaps:2}),this._zoomOut=new cs({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,n,s){this._zoomIn.touchstart(t,n,s),this._zoomOut.touchstart(t,n,s)}touchmove(t,n,s){this._zoomIn.touchmove(t,n,s),this._zoomOut.touchmove(t,n,s)}touchend(t,n,s){const c=this._zoomIn.touchend(t,n,s),p=this._zoomOut.touchend(t,n,s),g=this._tr;return c?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:g.zoom+1,around:g.unproject(c)},{originalEvent:t})}):p?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:g.zoom-1,around:g.unproject(p)},{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 Nr{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const n=this._moveFunction(...t);if(n.bearingDelta||n.pitchDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(t,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=n.length?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,n){if(!this.isEnabled())return;const s=this._lastPoint;if(!s)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const c=n.length?n[0]:n;return!this._moved&&c.dist(s)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=c,this._move(s,c))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&W.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 Ac={0:1,2:2};class eo{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){const n=W.mouseButton(t);this._eventButton=n}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!(function(n,s){const c=Ac[s];return n.buttons===void 0||(n.buttons&c)!==c})(t,this._eventButton)}isValidEndEvent(t){return W.mouseButton(t)===this._eventButton}}class vl{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 us=u=>{u.mousedown=u.dragStart,u.mousemoveWindow=u.dragMove,u.mouseup=u.dragEnd,u.contextmenu=function(t){t.preventDefault()}},Kn=({enable:u,clickTolerance:t,bearingDegreesPerPixelMoved:n=.8})=>{const s=new eo({checkCorrectEvent:c=>W.mouseButton(c)===0&&c.ctrlKey||W.mouseButton(c)===2});return new Nr({clickTolerance:t,move:(c,p)=>({bearingDelta:(p.x-c.x)*n}),moveStateManager:s,enable:u,assignEvents:us})},Vr=({enable:u,clickTolerance:t,pitchDegreesPerPixelMoved:n=-.5})=>{const s=new eo({checkCorrectEvent:c=>W.mouseButton(c)===0&&c.ctrlKey||W.mouseButton(c)===2});return new Nr({clickTolerance:t,move:(c,p)=>({pitchDelta:(p.y-c.y)*n}),moveStateManager:s,enable:u,assignEvents:us})};class Le{constructor(t,n){this._minTouches=t.cooperativeGestures?2:1,this._clickTolerance=t.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new l.P(0,0),setTimeout((()=>{this._cancelCooperativeMessage=!1}),200)}touchstart(t,n,s){return this._calculateTransform(t,n,s)}touchmove(t,n,s){if(this._map._cooperativeGestures&&(this._minTouches===2&&s.length<2&&!this._cancelCooperativeMessage?this._map._onCooperativeGesture(t,!1,s.length):this._cancelCooperativeMessage||(this._cancelCooperativeMessage=!0)),this._active&&!(s.length<this._minTouches))return t.preventDefault(),this._calculateTransform(t,n,s)}touchend(t,n,s){this._calculateTransform(t,n,s),this._active&&s.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,n,s){s.length>0&&(this._active=!0);const c=hr(s,n),p=new l.P(0,0),g=new l.P(0,0);let _=0;for(const b in c){const T=c[b],I=this._touches[b];I&&(p._add(T),g._add(T.sub(I)),_++,c[b]=T)}if(this._touches=c,_<this._minTouches||!g.mag())return;const x=g.div(_);return this._sum._add(x),this._sum.mag()<this._clickTolerance?void 0:{around:p.div(_),panDelta:x}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class hs{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,n,s){this._firstTwoTouches||s.length<2||(this._firstTwoTouches=[s[0].identifier,s[1].identifier],this._start([n[0],n[1]]))}touchmove(t,n,s){if(!this._firstTwoTouches)return;t.preventDefault();const[c,p]=this._firstTwoTouches,g=an(s,n,c),_=an(s,n,p);if(!g||!_)return;const x=this._aroundCenter?null:g.add(_).div(2);return this._move([g,_],x,t)}touchend(t,n,s){if(!this._firstTwoTouches)return;const[c,p]=this._firstTwoTouches,g=an(s,n,c),_=an(s,n,p);g&&_||(this._active&&W.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 an(u,t,n){for(let s=0;s<u.length;s++)if(u[s].identifier===n)return t[s]}function Yn(u,t){return Math.log(u/t)/Math.LN2}class bl extends hs{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,n){const s=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(Yn(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Yn(this._distance,s),pinchAround:n}}}function ze(u,t){return 180*u.angleWith(t)/Math.PI}class to extends hs{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,n){const s=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:ze(this._vector,s),pinchAround:n}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const n=25/(Math.PI*this._minDiameter)*360,s=ze(t,this._startVector);return Math.abs(s)<n}}function io(u){return Math.abs(u.y)>Math.abs(u.x)}class kc extends hs{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,n,s){super.touchstart(t,n,s),this._currentTouchCount=s.length}_start(t){this._lastPoints=t,io(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,n,s){if(this._map._cooperativeGestures&&this._currentTouchCount<3)return;const c=t[0].sub(this._lastPoints[0]),p=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(c,p,s.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(c.y+p.y)/2*-.5}):void 0}gestureBeginsVertically(t,n,s){if(this._valid!==void 0)return this._valid;const c=t.mag()>=2,p=n.mag()>=2;if(!c&&!p)return;if(!c||!p)return this._firstMove===void 0&&(this._firstMove=s),s-this._firstMove<100&&void 0;const g=t.y>0==n.y>0;return io(t)&&io(n)&&g}}const ro={panStep:100,bearingStep:15,pitchStep:10};class wl{constructor(t){this._tr=new nn(t);const n=ro;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=0,s=0,c=0,p=0,g=0;switch(t.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:t.shiftKey?s=-1:(t.preventDefault(),p=-1);break;case 39:t.shiftKey?s=1:(t.preventDefault(),p=1);break;case 38:t.shiftKey?c=1:(t.preventDefault(),g=-1);break;case 40:t.shiftKey?c=-1:(t.preventDefault(),g=1);break;default:return}return this._rotationDisabled&&(s=0,c=0),{cameraAnimation:_=>{const x=this._tr;_.easeTo({duration:300,easeId:"keyboardHandler",easing:Sl,zoom:n?Math.round(x.zoom)+n*(t.shiftKey?2:1):x.zoom,bearing:x.bearing+s*this._bearingStep,pitch:x.pitch+c*this._pitchStep,offset:[-p*this._panStep,-g*this._panStep],center:x.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 Sl(u){return u*(2-u)}const Tl=4.000244140625;class Cc{constructor(t,n){this._onTimeout=s=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(s)},this._map=t,this._tr=new nn(t),this._el=t.getCanvasContainer(),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&t.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!t[this._map._metaKey])return;t.preventDefault()}let n=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const s=l.h.now(),c=s-(this._lastWheelEventTime||0);this._lastWheelEventTime=s,n!==0&&n%Tl==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":c>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(c*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const n=W.mousePos(this._el,t),s=this._tr;this._around=l.L.convert(this._aroundCenter?s.center:s.unproject(n)),this._aroundPoint=s.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 _=this._type==="wheel"&&Math.abs(this._delta)>Tl?this._wheelZoomRate:this._defaultZoomRate;let x=2/(1+Math.exp(-Math.abs(this._delta*_)));this._delta<0&&x!==0&&(x=1/x);const b=typeof this._targetZoom=="number"?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(b*x))),this._type==="wheel"&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom=="number"?this._targetZoom:t.zoom,s=this._startZoom,c=this._easing;let p,g=!1;if(this._type==="wheel"&&s&&c){const _=Math.min((l.h.now()-this._lastWheelEventTime)/200,1),x=c(_);p=l.B.number(s,n,x),_<1?this._frameId||(this._frameId=!0):g=!0}else p=n,g=!0;return this._active=!0,g&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!g,zoomDelta:p-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=l.bb;if(this._prevEase){const s=this._prevEase,c=(l.h.now()-s.start)/s.duration,p=s.easing(c+.01)-s.easing(c),g=.27/Math.sqrt(p*p+1e-4)*.01,_=Math.sqrt(.0729-g*g);n=l.ba(g,_,.25,1)}return this._prevEase={start:l.h.now(),duration:t,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class no{constructor(t,n){this._clickZoom=t,this._tapZoom=n}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class ao{constructor(t){this._tr=new nn(t),this.reset()}reset(){this._active=!1}dblclick(t,n){return t.preventDefault(),{cameraAnimation:s=>{s.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class so{constructor(){this._tap=new cs({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,n,s){if(!this._swipePoint)if(this._tapTime){const c=n[0],p=t.timeStamp-this._tapTime<500,g=this._tapPoint.dist(c)<30;p&&g?s.length>0&&(this._swipePoint=c,this._swipeTouch=s[0].identifier):this.reset()}else this._tap.touchstart(t,n,s)}touchmove(t,n,s){if(this._tapTime){if(this._swipePoint){if(s[0].identifier!==this._swipeTouch)return;const c=n[0],p=c.y-this._swipePoint.y;return this._swipePoint=c,t.preventDefault(),this._active=!0,{zoomDelta:p/128}}}else this._tap.touchmove(t,n,s)}touchend(t,n,s){if(this._tapTime)this._swipePoint&&s.length===0&&this.reset();else{const c=this._tap.touchend(t,n,s);c&&(this._tapTime=t.timeStamp,this._tapPoint=c)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class oo{constructor(t,n,s){this._el=t,this._mousePan=n,this._touchPan=s}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Fi{constructor(t,n,s){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=n,this._mousePitch=s}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class sn{constructor(t,n,s,c){this._el=t,this._touchZoom=n,this._touchRotate=s,this._tapDragZoom=c,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Sa=u=>u.zoom||u.drag||u.pitch||u.rotate;class lo extends l.k{}function Ta(u){return u.panDelta&&u.panDelta.mag()||u.zoomDelta||u.bearingDelta||u.pitchDelta}class co{constructor(t,n){this.handleWindowEvent=c=>{this.handleEvent(c,`${c.type}Window`)},this.handleEvent=(c,p)=>{if(c.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const g=c.type==="renderFrame"?void 0:c,_={needsRenderFrame:!1},x={},b={},T=c.touches,I=T?this._getMapTouches(T):void 0,P=I?W.touchPos(this._el,I):W.mousePos(this._el,c);for(const{handlerName:$,handler:B,allowed:ee}of this._handlers){if(!B.isEnabled())continue;let se;this._blockedByActive(b,ee,$)?B.reset():B[p||c.type]&&(se=B[p||c.type](c,P,I),this.mergeHandlerResult(_,x,se,$,g),se&&se.needsRenderFrame&&this._triggerRenderFrame()),(se||B.isActive())&&(b[$]=B)}const V={};for(const $ in this._previousActiveHandlers)b[$]||(V[$]=g);this._previousActiveHandlers=b,(Object.keys(V).length||Ta(_))&&(this._changes.push([_,x,V]),this._triggerRenderFrame()),(Object.keys(b).length||Ta(_))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:N}=_;N&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],N(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ml(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const s=this._el;this._listeners=[[s,"touchstart",{passive:!0}],[s,"touchmove",{passive:!1}],[s,"touchend",void 0],[s,"touchcancel",void 0],[s,"mousedown",void 0],[s,"mousemove",void 0],[s,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[s,"mouseover",void 0],[s,"mouseout",void 0],[s,"dblclick",void 0],[s,"click",void 0],[s,"keydown",{capture:!1}],[s,"keyup",void 0],[s,"wheel",{passive:!1}],[s,"contextmenu",void 0],[window,"blur",void 0]];for(const[c,p,g]of this._listeners)W.addEventListener(c,p,c===document?this.handleWindowEvent:this.handleEvent,g)}destroy(){for(const[t,n,s]of this._listeners)W.removeEventListener(t,n,t===document?this.handleWindowEvent:this.handleEvent,s)}_addDefaultHandlers(t){const n=this._map,s=n.getCanvasContainer();this._add("mapEvent",new _l(n,t));const c=n.boxZoom=new xl(n,t);this._add("boxZoom",c),t.interactive&&t.boxZoom&&c.enable();const p=new Or(n),g=new ao(n);n.doubleClickZoom=new no(g,p),this._add("tapZoom",p),this._add("clickZoom",g),t.interactive&&t.doubleClickZoom&&n.doubleClickZoom.enable();const _=new so;this._add("tapDragZoom",_);const x=n.touchPitch=new kc(n);this._add("touchPitch",x),t.interactive&&t.touchPitch&&n.touchPitch.enable(t.touchPitch);const b=Kn(t),T=Vr(t);n.dragRotate=new Fi(t,b,T),this._add("mouseRotate",b,["mousePitch"]),this._add("mousePitch",T,["mouseRotate"]),t.interactive&&t.dragRotate&&n.dragRotate.enable();const I=(({enable:ee,clickTolerance:se})=>{const G=new eo({checkCorrectEvent:te=>W.mouseButton(te)===0&&!te.ctrlKey});return new Nr({clickTolerance:se,move:(te,ce)=>({around:ce,panDelta:ce.sub(te)}),activateOnStart:!0,moveStateManager:G,enable:ee,assignEvents:us})})(t),P=new Le(t,n);n.dragPan=new oo(s,I,P),this._add("mousePan",I),this._add("touchPan",P,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&n.dragPan.enable(t.dragPan);const V=new to,N=new bl;n.touchZoomRotate=new sn(s,N,V,_),this._add("touchRotate",V,["touchPan","touchZoom"]),this._add("touchZoom",N,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&n.touchZoomRotate.enable(t.touchZoomRotate);const $=n.scrollZoom=new Cc(n,(()=>this._triggerRenderFrame()));this._add("scrollZoom",$,["mousePan"]),t.interactive&&t.scrollZoom&&n.scrollZoom.enable(t.scrollZoom);const B=n.keyboard=new wl(n);this._add("keyboard",B),t.interactive&&t.keyboard&&n.keyboard.enable(),this._add("blockableMapEvent",new yl(n))}_add(t,n,s){this._handlers.push({handlerName:t,handler:n,allowed:s}),this._handlersById[t]=n}stop(t){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Sa(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,n,s){for(const c in t)if(c!==s&&(!n||n.indexOf(c)<0))return!0;return!1}_getMapTouches(t){const n=[];for(const s of t)this._el.contains(s.target)&&n.push(s);return n}mergeHandlerResult(t,n,s,c,p){if(!s)return;l.e(t,s);const g={handlerName:c,originalEvent:s.originalEvent||p};s.zoomDelta!==void 0&&(n.zoom=g),s.panDelta!==void 0&&(n.drag=g),s.pitchDelta!==void 0&&(n.pitch=g),s.bearingDelta!==void 0&&(n.rotate=g)}_applyChanges(){const t={},n={},s={};for(const[c,p,g]of this._changes)c.panDelta&&(t.panDelta=(t.panDelta||new l.P(0,0))._add(c.panDelta)),c.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+c.zoomDelta),c.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+c.bearingDelta),c.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+c.pitchDelta),c.around!==void 0&&(t.around=c.around),c.pinchAround!==void 0&&(t.pinchAround=c.pinchAround),c.noInertia&&(t.noInertia=c.noInertia),l.e(n,p),l.e(s,g);this._updateMapTransform(t,n,s),this._changes=[]}_updateMapTransform(t,n,s){const c=this._map,p=c._getTransformForUpdate(),g=c.terrain;if(!(Ta(t)||g&&this._terrainMovement))return this._fireEvents(n,s,!0);let{panDelta:_,zoomDelta:x,bearingDelta:b,pitchDelta:T,around:I,pinchAround:P}=t;P!==void 0&&(I=P),c._stop(!0),I=I||c.transform.centerPoint;const V=p.pointLocation(_?I.sub(_):I);b&&(p.bearing+=b),T&&(p.pitch+=T),x&&(p.zoom+=x),g?this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?p.center=p.pointLocation(p.centerPoint.sub(_)):p.setLocationAtPoint(V,I):(this._terrainMovement=!0,this._map._elevationFreeze=!0,p.setLocationAtPoint(V,I),this._map.once("moveend",(()=>{this._map._elevationFreeze=!1,this._terrainMovement=!1,p.recalculateZoom(c.terrain)}))):p.setLocationAtPoint(V,I),c._applyUpdatedTransform(p),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,s,!0)}_fireEvents(t,n,s){const c=Sa(this._eventsInProgress),p=Sa(t),g={};for(const T in t){const{originalEvent:I}=t[T];this._eventsInProgress[T]||(g[`${T}start`]=I),this._eventsInProgress[T]=t[T]}!c&&p&&this._fireEvent("movestart",p.originalEvent);for(const T in g)this._fireEvent(T,g[T]);p&&this._fireEvent("move",p.originalEvent);for(const T in t){const{originalEvent:I}=t[T];this._fireEvent(T,I)}const _={};let x;for(const T in this._eventsInProgress){const{handlerName:I,originalEvent:P}=this._eventsInProgress[T];this._handlersById[I].isActive()||(delete this._eventsInProgress[T],x=n[I]||P,_[`${T}end`]=x)}for(const T in _)this._fireEvent(T,_[T]);const b=Sa(this._eventsInProgress);if(s&&(c||p)&&!b){this._updatingCamera=!0;const T=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),I=P=>P!==0&&-this._bearingSnap<P&&P<this._bearingSnap;!T||!T.essential&&l.h.prefersReducedMotion?(this._map.fire(new l.k("moveend",{originalEvent:x})),I(this._map.getBearing())&&this._map.resetNorth()):(I(T.bearing||this._map.getBearing())&&(T.bearing=0),T.freezeElevation=!0,this._map.easeTo(T,{originalEvent:x})),this._updatingCamera=!1}}_fireEvent(t,n){this._map.fire(new l.k(t,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new lo("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Il extends l.E{constructor(t,n){super(),this._renderFrameCallback=()=>{const s=Math.min((l.h.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(s)),s<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=n.bearingSnap,this.on("moveend",(()=>{delete this._requestedCameraState}))}getCenter(){return new l.L(this.transform.center.lng,this.transform.center.lat)}setCenter(t,n){return this.jumpTo({center:t},n)}panBy(t,n,s){return t=l.P.convert(t).mult(-1),this.panTo(this.transform.center,l.e({offset:t},n),s)}panTo(t,n,s){return this.easeTo(l.e({center:t},n),s)}getZoom(){return this.transform.zoom}setZoom(t,n){return this.jumpTo({zoom:t},n),this}zoomTo(t,n,s){return this.easeTo(l.e({zoom:t},n),s)}zoomIn(t,n){return this.zoomTo(this.getZoom()+1,t,n),this}zoomOut(t,n){return this.zoomTo(this.getZoom()-1,t,n),this}getBearing(){return this.transform.bearing}setBearing(t,n){return this.jumpTo({bearing:t},n),this}getPadding(){return this.transform.padding}setPadding(t,n){return this.jumpTo({padding:t},n),this}rotateTo(t,n,s){return this.easeTo(l.e({bearing:t},n),s)}resetNorth(t,n){return this.rotateTo(0,l.e({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(l.e({bearing:0,pitch:0,duration:1e3},t),n),this}snapToNorth(t,n){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,n):this}getPitch(){return this.transform.pitch}setPitch(t,n){return this.jumpTo({pitch:t},n),this}cameraForBounds(t,n){t=Et.convert(t);const s=n&&n.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),s,n)}_cameraForBoxAndBearing(t,n,s,c){const p={top:0,bottom:0,right:0,left:0};if(typeof(c=l.e({padding:p,offset:[0,0],maxZoom:this.transform.maxZoom},c)).padding=="number"){const ce=c.padding;c.padding={top:ce,bottom:ce,right:ce,left:ce}}c.padding=l.e(p,c.padding);const g=this.transform,_=g.padding,x=g.project(l.L.convert(t)),b=g.project(l.L.convert(n)),T=x.rotate(-s*Math.PI/180),I=b.rotate(-s*Math.PI/180),P=new l.P(Math.max(T.x,I.x),Math.max(T.y,I.y)),V=new l.P(Math.min(T.x,I.x),Math.min(T.y,I.y)),N=P.sub(V),$=(g.width-(_.left+_.right+c.padding.left+c.padding.right))/N.x,B=(g.height-(_.top+_.bottom+c.padding.top+c.padding.bottom))/N.y;if(B<0||$<0)return void l.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const ee=Math.min(g.scaleZoom(g.scale*Math.min($,B)),c.maxZoom),se=l.P.convert(c.offset),G=new l.P((c.padding.left-c.padding.right)/2,(c.padding.top-c.padding.bottom)/2).rotate(s*Math.PI/180),te=se.add(G).mult(g.scale/g.zoomScale(ee));return{center:g.unproject(x.add(b).div(2).sub(te)),zoom:ee,bearing:s}}fitBounds(t,n,s){return this._fitInternal(this.cameraForBounds(t,n),n,s)}fitScreenCoordinates(t,n,s,c,p){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(l.P.convert(t)),this.transform.pointLocation(l.P.convert(n)),s,c),c,p)}_fitInternal(t,n,s){return t?(delete(n=l.e(t,n)).padding,n.linear?this.easeTo(n,s):this.flyTo(n,s)):this}jumpTo(t,n){this.stop();const s=this._getTransformForUpdate();let c=!1,p=!1,g=!1;return"zoom"in t&&s.zoom!==+t.zoom&&(c=!0,s.zoom=+t.zoom),t.center!==void 0&&(s.center=l.L.convert(t.center)),"bearing"in t&&s.bearing!==+t.bearing&&(p=!0,s.bearing=+t.bearing),"pitch"in t&&s.pitch!==+t.pitch&&(g=!0,s.pitch=+t.pitch),t.padding==null||s.isPaddingEqual(t.padding)||(s.padding=t.padding),this._applyUpdatedTransform(s),this.fire(new l.k("movestart",n)).fire(new l.k("move",n)),c&&this.fire(new l.k("zoomstart",n)).fire(new l.k("zoom",n)).fire(new l.k("zoomend",n)),p&&this.fire(new l.k("rotatestart",n)).fire(new l.k("rotate",n)).fire(new l.k("rotateend",n)),g&&this.fire(new l.k("pitchstart",n)).fire(new l.k("pitch",n)).fire(new l.k("pitchend",n)),this.fire(new l.k("moveend",n))}calculateCameraOptionsFromTo(t,n,s,c=0){const p=l.U.fromLngLat(t,n),g=l.U.fromLngLat(s,c),_=g.x-p.x,x=g.y-p.y,b=g.z-p.z,T=Math.hypot(_,x,b);if(T===0)throw new Error("Can't calculate camera options with same From and To");const I=Math.hypot(_,x),P=this.transform.scaleZoom(this.transform.cameraToCenterDistance/T/this.transform.tileSize),V=180*Math.atan2(_,-x)/Math.PI;let N=180*Math.acos(I/T)/Math.PI;return N=b<0?90-N:90+N,{center:g.toLngLat(),zoom:P,pitch:N,bearing:V}}easeTo(t,n){this._stop(!1,t.easeId),((t=l.e({offset:[0,0],duration:500,easing:l.bb},t)).animate===!1||!t.essential&&l.h.prefersReducedMotion)&&(t.duration=0);const s=this._getTransformForUpdate(),c=this.getZoom(),p=this.getBearing(),g=this.getPitch(),_=this.getPadding(),x="zoom"in t?+t.zoom:c,b="bearing"in t?this._normalizeBearing(t.bearing,p):p,T="pitch"in t?+t.pitch:g,I="padding"in t?t.padding:s.padding,P=l.P.convert(t.offset);let V=s.centerPoint.add(P);const N=s.pointLocation(V),$=l.L.convert(t.center||N);this._normalizeCenter($);const B=s.project(N),ee=s.project($).sub(B),se=s.zoomScale(x-c);let G,te;t.around&&(G=l.L.convert(t.around),te=s.locationPoint(G));const ce={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||x!==c,this._rotating=this._rotating||p!==b,this._pitching=this._pitching||T!==g,this._padding=!s.isPaddingEqual(I),this._easeId=t.easeId,this._prepareEase(n,t.noMoveStart,ce),this.terrain&&this._prepareElevation($),this._ease((ue=>{if(this._zooming&&(s.zoom=l.B.number(c,x,ue)),this._rotating&&(s.bearing=l.B.number(p,b,ue)),this._pitching&&(s.pitch=l.B.number(g,T,ue)),this._padding&&(s.interpolatePadding(_,I,ue),V=s.centerPoint.add(P)),this.terrain&&!t.freezeElevation&&this._updateElevation(ue),G)s.setLocationAtPoint(G,te);else{const me=s.zoomScale(s.zoom-c),be=x>c?Math.min(2,se):Math.max(.5,se),xe=Math.pow(be,1-ue),Te=s.unproject(B.add(ee.mult(ue*xe)).mult(me));s.setLocationAtPoint(s.renderWorldCopies?Te.wrap():Te,V)}this._applyUpdatedTransform(s),this._fireMoveEvents(n)}),(ue=>{this.terrain&&this._finalizeElevation(),this._afterEase(n,ue)}),t),this}_prepareEase(t,n,s={}){this._moving=!0,n||s.moving||this.fire(new l.k("movestart",t)),this._zooming&&!s.zooming&&this.fire(new l.k("zoomstart",t)),this._rotating&&!s.rotating&&this.fire(new l.k("rotatestart",t)),this._pitching&&!s.pitching&&this.fire(new l.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._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&n!==this._elevationTarget){const s=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(s-(n-(s*t+this._elevationStart))/(1-t)),this._elevationTarget=n}this.transform.elevation=l.B.number(this._elevationStart,this._elevationTarget,t)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_applyUpdatedTransform(t){if(!this.transformCameraUpdate)return;const n=t.clone(),{center:s,zoom:c,pitch:p,bearing:g,elevation:_}=this.transformCameraUpdate(n);s&&(n.center=s),c!==void 0&&(n.zoom=c),p!==void 0&&(n.pitch=p),g!==void 0&&(n.bearing=g),_!==void 0&&(n.elevation=_),this.transform.apply(n)}_fireMoveEvents(t){this.fire(new l.k("move",t)),this._zooming&&this.fire(new l.k("zoom",t)),this._rotating&&this.fire(new l.k("rotate",t)),this._pitching&&this.fire(new l.k("pitch",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const s=this._zooming,c=this._rotating,p=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,s&&this.fire(new l.k("zoomend",t)),c&&this.fire(new l.k("rotateend",t)),p&&this.fire(new l.k("pitchend",t)),this.fire(new l.k("moveend",t))}flyTo(t,n){if(!t.essential&&l.h.prefersReducedMotion){const Ne=l.F(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Ne,n)}this.stop(),t=l.e({offset:[0,0],speed:1.2,curve:1.42,easing:l.bb},t);const s=this._getTransformForUpdate(),c=this.getZoom(),p=this.getBearing(),g=this.getPitch(),_=this.getPadding(),x="zoom"in t?l.ad(+t.zoom,s.minZoom,s.maxZoom):c,b="bearing"in t?this._normalizeBearing(t.bearing,p):p,T="pitch"in t?+t.pitch:g,I="padding"in t?t.padding:s.padding,P=s.zoomScale(x-c),V=l.P.convert(t.offset);let N=s.centerPoint.add(V);const $=s.pointLocation(N),B=l.L.convert(t.center||$);this._normalizeCenter(B);const ee=s.project($),se=s.project(B).sub(ee);let G=t.curve;const te=Math.max(s.width,s.height),ce=te/P,ue=se.mag();if("minZoom"in t){const Ne=l.ad(Math.min(t.minZoom,c,x),s.minZoom,s.maxZoom),St=te/s.zoomScale(Ne-c);G=Math.sqrt(St/ue*2)}const me=G*G;function be(Ne){const St=(ce*ce-te*te+(Ne?-1:1)*me*me*ue*ue)/(2*(Ne?ce:te)*me*ue);return Math.log(Math.sqrt(St*St+1)-St)}function xe(Ne){return(Math.exp(Ne)-Math.exp(-Ne))/2}function Te(Ne){return(Math.exp(Ne)+Math.exp(-Ne))/2}const Be=be(!1);let ut=function(Ne){return Te(Be)/Te(Be+G*Ne)},Ee=function(Ne){return te*((Te(Be)*(xe(St=Be+G*Ne)/Te(St))-xe(Be))/me)/ue;var St},We=(be(!0)-Be)/G;if(Math.abs(ue)<1e-6||!isFinite(We)){if(Math.abs(te-ce)<1e-6)return this.easeTo(t,n);const Ne=ce<te?-1:1;We=Math.abs(Math.log(ce/te))/G,Ee=function(){return 0},ut=function(St){return Math.exp(Ne*G*St)}}return t.duration="duration"in t?+t.duration:1e3*We/("screenSpeed"in t?+t.screenSpeed/G:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=p!==b,this._pitching=T!==g,this._padding=!s.isPaddingEqual(I),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(B),this._ease((Ne=>{const St=Ne*We,ct=1/ut(St);s.zoom=Ne===1?x:c+s.scaleZoom(ct),this._rotating&&(s.bearing=l.B.number(p,b,Ne)),this._pitching&&(s.pitch=l.B.number(g,T,Ne)),this._padding&&(s.interpolatePadding(_,I,Ne),N=s.centerPoint.add(V)),this.terrain&&!t.freezeElevation&&this._updateElevation(Ne);const at=Ne===1?B:s.unproject(ee.add(se.mult(Ee(St))).mult(ct));s.setLocationAtPoint(s.renderWorldCopies?at.wrap():at,N),this._applyUpdatedTransform(s),this._fireMoveEvents(n)}),(()=>{this.terrain&&this._finalizeElevation(),this._afterEase(n)}),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,n){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const s=this._onEaseEnd;delete this._onEaseEnd,s.call(this,n)}if(!t){const s=this.handlers;s&&s.stop(!1)}return this}_ease(t,n,s){s.animate===!1||s.duration===0?(t(1),n()):(this._easeStart=l.h.now(),this._easeOptions=s,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,n){t=l.b5(t,-180,180);const s=Math.abs(t-n);return Math.abs(t-360-n)<s&&(t-=360),Math.abs(t+360-n)<s&&(t+=360),t}_normalizeCenter(t){const n=this.transform;if(!n.renderWorldCopies||n.lngRange)return;const s=t.lng-n.center.lng;t.lng+=s>180?-360:s<-180?360:0}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(l.L.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}class Ki{constructor(t={}){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options&&this.options.compact,this._container=W.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=W.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=W.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(){W.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,n){const s=this._map._getUIString(`AttributionControl.${n}`);t.title=s,t.setAttribute("aria-label",s)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((c=>typeof c!="string"?"":c))):typeof this.options.customAttribution=="string"&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const c=this._map.style.stylesheet;this.styleOwner=c.owner,this.styleId=c.id}const n=this._map.style.sourceCaches;for(const c in n){const p=n[c];if(p.used||p.usedForTerrain){const g=p.getSource();g.attribution&&t.indexOf(g.attribution)<0&&t.push(g.attribution)}}t=t.filter((c=>String(c).trim())),t.sort(((c,p)=>c.length-p.length)),t=t.filter(((c,p)=>{for(let g=p+1;g<t.length;g++)if(t[g].indexOf(c)>=0)return!1;return!0}));const s=t.join(" | ");s!==this._attribHTML&&(this._attribHTML=s,t.length?(this._innerContainer.innerHTML=s,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Mt{constructor(t={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const s=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&s.classList.add("maplibregl-compact"):s.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=W.create("div","maplibregl-ctrl");const n=W.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){W.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class ps{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const n=++this._id;return this._queue.push({callback:t,id:n,cancelled:!1}),n}remove(t){const n=this._currentlyRunning,s=n?this._queue.concat(n):this._queue;for(const c of s)if(c.id===t)return void(c.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const s of n)if(!s.cancelled&&(s.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}const uo={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.enableTerrain":"Enable terrain","TerrainControl.disableTerrain":"Disable terrain"};var Al=l.Q([{name:"a_pos3d",type:"Int16",components:3}]);class kl extends l.E{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(t,n){this.sourceCache.update(t,n),this._renderableTilesKeys=[];const s={};for(const c of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n}))s[c.key]=!0,this._renderableTilesKeys.push(c.key),this._tiles[c.key]||(c.posMatrix=new Float64Array(16),l.aS(c.posMatrix,0,l.N,0,l.N,0,1),this._tiles[c.key]=new Yr(c,this.tileSize));for(const c in this._tiles)s[c]||delete this._tiles[c]}freeRtt(t){for(const n in this._tiles){const s=this._tiles[n];(!t||s.tileID.equals(t)||s.tileID.isChildOf(t)||t.isChildOf(s.tileID))&&(s.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){const n={};for(const s of this._renderableTilesKeys){const c=this._tiles[s].tileID;if(c.canonical.equals(t.canonical)){const p=t.clone();p.posMatrix=new Float64Array(16),l.aS(p.posMatrix,0,l.N,0,l.N,0,1),n[s]=p}else if(c.canonical.isChildOf(t.canonical)){const p=t.clone();p.posMatrix=new Float64Array(16);const g=c.canonical.z-t.canonical.z,_=c.canonical.x-(c.canonical.x>>g<<g),x=c.canonical.y-(c.canonical.y>>g<<g),b=l.N>>g;l.aS(p.posMatrix,0,b,0,b,0,1),l.$(p.posMatrix,p.posMatrix,[-_*b,-x*b,0]),n[s]=p}else if(t.canonical.isChildOf(c.canonical)){const p=t.clone();p.posMatrix=new Float64Array(16);const g=t.canonical.z-c.canonical.z,_=t.canonical.x-(t.canonical.x>>g<<g),x=t.canonical.y-(t.canonical.y>>g<<g),b=l.N>>g;l.aS(p.posMatrix,0,l.N,0,l.N,0,1),l.$(p.posMatrix,p.posMatrix,[_*b,x*b,0]),l.a0(p.posMatrix,p.posMatrix,[1/2**g,1/2**g,0]),n[s]=p}}return n}getSourceTile(t,n){const s=this.sourceCache._source;let c=t.overscaledZ-this.deltaZoom;if(c>s.maxzoom&&(c=s.maxzoom),c<s.minzoom)return null;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(c).key);let p=this.sourceCache.getTileByID(this._sourceTileCache[t.key]);if((!p||!p.dem)&&n)for(;c>=s.minzoom&&(!p||!p.dem);)p=this.sourceCache.getTileByID(t.scaledTo(c--).key);return p}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter((n=>n.timeAdded>=t))}}class Cl{constructor(t,n,s){this.painter=t,this.sourceCache=new kl(n),this.options=s,this.exaggeration=typeof s.exaggeration=="number"?s.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,n,s,c=l.N){var p;if(!(n>=0&&n<c&&s>=0&&s<c))return 0;const g=this.getTerrainData(t),_=(p=g.tile)===null||p===void 0?void 0:p.dem;if(!_)return 0;const x=(function(N,$,B){var ee=$[0],se=$[1];return N[0]=B[0]*ee+B[4]*se+B[12],N[1]=B[1]*ee+B[5]*se+B[13],N})([],[n/c*l.N,s/c*l.N],g.u_terrain_matrix),b=[x[0]*_.dim,x[1]*_.dim],T=Math.floor(b[0]),I=Math.floor(b[1]),P=b[0]-T,V=b[1]-I;return _.get(T,I)*(1-P)*(1-V)+_.get(T+1,I)*P*(1-V)+_.get(T,I+1)*(1-P)*V+_.get(T+1,I+1)*P*V}getElevationForLngLatZoom(t,n){const{tileID:s,mercatorX:c,mercatorY:p}=this._getOverscaledTileIDFromLngLatZoom(t,n);return this.getElevation(s,c%l.N,p%l.N,l.N)}getElevation(t,n,s,c=l.N){return this.getDEMElevation(t,n,s,c)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){const c=this.painter.context,p=new l.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new nt(c,p,c.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new nt(c,new l.R({width:1,height:1}),c.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(c.gl.NEAREST,c.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=l.ao([])}const n=this.sourceCache.getSourceTile(t,!0);if(n&&n.dem&&(!n.demTexture||n.needsTerrainPrepare)){const c=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new nt(c,n.dem.getPixels(),c.gl.RGBA,{premultiply:!1}),n.demTexture.bind(c.gl.NEAREST,c.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}const s=n&&n+n.tileID.key+t.key;if(s&&!this._demMatrixCache[s]){const c=this.sourceCache.sourceCache._source.maxzoom;let p=t.canonical.z-n.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=c?p=t.canonical.z-c:l.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const g=t.canonical.x-(t.canonical.x>>p<<p),_=t.canonical.y-(t.canonical.y>>p<<p),x=l.bc(new Float64Array(16),[1/(l.N<<p),1/(l.N<<p),0]);l.$(x,x,[g*l.N,_*l.N,0]),this._demMatrixCache[t.key]={matrix:x,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:n&&n.dem&&n.dem.dim||1,u_terrain_matrix:s?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:n&&n.dem&&n.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(n&&n.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:n}}getFramebuffer(t){const n=this.painter,s=n.width/devicePixelRatio,c=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===s&&this._fbo.height===c||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new nt(n.context,{width:s,height:c,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new nt(n.context,{width:s,height:c,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=n.context.createFramebuffer(s,c,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,s,c))),this._fbo.colorAttachment.set(t==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let p=0,g=0;p<this._coordsTextureSize;p++)for(let _=0;_<this._coordsTextureSize;_++,g+=4)n[g+0]=255&_,n[g+1]=255&p,n[g+2]=_>>8<<4|p>>8,n[g+3]=0;const s=new l.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),c=new nt(t,s,t.gl.RGBA,{premultiply:!1});return c.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=c,c}pointCoordinate(t){const n=new Uint8Array(4),s=this.painter.context,c=s.gl;s.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),c.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,c.RGBA,c.UNSIGNED_BYTE,n),s.bindFramebuffer.set(null);const p=n[0]+(n[2]>>4<<8),g=n[1]+((15&n[2])<<8),_=this.coordsIndex[255-n[3]],x=_&&this.sourceCache.getTileByID(_);if(!x)return null;const b=this._coordsTextureSize,T=(1<<x.tileID.canonical.z)*b;return new l.U(this._allowMercatorOverflow(t,(x.tileID.canonical.x*b+p)/T),(x.tileID.canonical.y*b+g)/T,this.getElevation(x.tileID,p,g,b))}getTerrainMesh(){if(this._mesh)return this._mesh;const t=this.painter.context,n=new l.bd,s=new l.b0,c=this.meshSize,p=l.N/c,g=c*c;for(let I=0;I<=c;I++)for(let P=0;P<=c;P++)n.emplaceBack(P*p,I*p,0);for(let I=0;I<g;I+=c+1)for(let P=0;P<c;P++)s.emplaceBack(P+I,c+P+I+1,c+P+I+2),s.emplaceBack(P+I,c+P+I+2,P+I+1);const _=n.length,x=_+2*(c+1);for(const I of[0,1])for(let P=0;P<=c;P++)for(const V of[0,1])n.emplaceBack(P*p,I*l.N,V);for(let I=0;I<2*c;I+=2)s.emplaceBack(x+I,x+I+1,x+I+3),s.emplaceBack(x+I,x+I+3,x+I+2),s.emplaceBack(_+I,_+I+3,_+I+1),s.emplaceBack(_+I,_+I+2,_+I+3);const b=n.length,T=b+2*(c+1);for(const I of[0,1])for(let P=0;P<=c;P++)for(const V of[0,1])n.emplaceBack(I*l.N,P*p,V);for(let I=0;I<2*c;I+=2)s.emplaceBack(b+I,b+I+1,b+I+3),s.emplaceBack(b+I,b+I+3,b+I+2),s.emplaceBack(T+I,T+I+3,T+I+1),s.emplaceBack(T+I,T+I+2,T+I+3);return this._mesh={indexBuffer:t.createIndexBuffer(s),vertexBuffer:t.createVertexBuffer(n,Al.members),segments:l.S.simpleSegment(0,0,n.length,s.length)},this._mesh}getMeshFrameDelta(t){return 2*Math.PI*l.be/Math.pow(2,t)/5}getMinTileElevationForLngLatZoom(t,n){var s;const{tileID:c}=this._getOverscaledTileIDFromLngLatZoom(t,n);return(s=this.getMinMaxElevation(c).minElevation)!==null&&s!==void 0?s:0}getMinMaxElevation(t){const n=this.getTerrainData(t).tile,s={minElevation:null,maxElevation:null};return n&&n.dem&&(s.minElevation=n.dem.min*this.exaggeration,s.maxElevation=n.dem.max*this.exaggeration),s}_getOverscaledTileIDFromLngLatZoom(t,n){const s=l.U.fromLngLat(t.wrap()),c=(1<<n)*l.N,p=s.x*c,g=s.y*c,_=Math.floor(p/l.N),x=Math.floor(g/l.N);return{tileID:new l.O(n,0,n,_,x),mercatorX:p,mercatorY:g}}_allowMercatorOverflow(t,n){const s=t.x<this.painter.width/2;let c=l.bf(n);const p=this.painter.transform.center.lng;return s&&Math.sign(c)>0&&Math.sign(p)<0||!s&&Math.sign(c)<0&&Math.sign(p)>0?(c=360*Math.sign(p)+c,l.G(c)):n}}class Ec{constructor(t,n,s){this._context=t,this._size=n,this._tileSize=s,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),s=new nt(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return s.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(s.texture),{id:t,fbo:n,texture:s,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((n=>t.id!==n)),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length<this._size)&&this._objects.some((t=>!t.inUse))===!1}}const Ti={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class ds{constructor(t,n){this.painter=t,this.terrain=n,this.pool=new Ec(t.context,30,n.sourceCache.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter((s=>!t._layers[s].isHidden(n))),this._coordsDescendingInv={};for(const s in t.sourceCaches){this._coordsDescendingInv[s]={};const c=t.sourceCaches[s].getVisibleCoordinates();for(const p of c){const g=this.terrain.sourceCache.getTerrainCoords(p);for(const _ in g)this._coordsDescendingInv[s][_]||(this._coordsDescendingInv[s][_]=[]),this._coordsDescendingInv[s][_].push(g[_])}}this._coordsDescendingInvStr={};for(const s of t._order){const c=t._layers[s],p=c.source;if(Ti[c.type]&&!this._coordsDescendingInvStr[p]){this._coordsDescendingInvStr[p]={};for(const g in this._coordsDescendingInv[p])this._coordsDescendingInvStr[p][g]=this._coordsDescendingInv[p][g].map((_=>_.key)).sort().join()}}for(const s of this._renderableTiles)for(const c in this._coordsDescendingInvStr){const p=this._coordsDescendingInvStr[c][s.tileID.key];p&&p!==s.rttCoords[c]&&(s.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;const n=t.type,s=this.painter,c=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(Ti[n]&&(this._prevType&&Ti[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(t.id),!c))return!0;if(Ti[this._prevType]||Ti[n]&&c){this._prevType=n;const p=this._stacks.length-1,g=this._stacks[p]||[];for(const _ of this._renderableTiles){if(this.pool.isFull()&&(jt(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(_),_.rtt[p]){const b=this.pool.getObjectForId(_.rtt[p].id);if(b.stamp===_.rtt[p].stamp){this.pool.useObject(b);continue}}const x=this.pool.getOrCreateFreeObject();this.pool.useObject(x),this.pool.stampObject(x),_.rtt[p]={id:x.id,stamp:x.stamp},s.context.bindFramebuffer.set(x.fbo.framebuffer),s.context.clear({color:l.aT.transparent,stencil:0}),s.currentStencilSource=void 0;for(let b=0;b<g.length;b++){const T=s.style._layers[g[b]],I=T.source?this._coordsDescendingInv[T.source][_.tileID.key]:[_.tileID];s.context.viewport.set([0,0,x.fbo.width,x.fbo.height]),s._renderTileClippingMasks(T,I),s.renderLayer(s,s.style.sourceCaches[T.source],T,I),T.source&&(_.rttCoords[T.source]=this._coordsDescendingInvStr[T.source][_.tileID.key])}}return jt(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),Ti[n]}return!1}}const je=le,He={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:void 0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:l.c.MAX_TILE_CACHE_ZOOM_LEVELS,localIdeographFontFamily:"sans-serif",transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,validateStyle:!0,maxCanvasSize:[4096,4096]},Ia=u=>{u.touchstart=u.dragStart,u.touchmoveWindow=u.dragMove,u.touchend=u.dragEnd},ho={showCompass:!0,showZoom:!0,visualizePitch:!1};class po{constructor(t,n,s=!1){this.mousedown=g=>{this.startMouse(l.e({},g,{ctrlKey:!0,preventDefault:()=>g.preventDefault()}),W.mousePos(this.element,g)),W.addEventListener(window,"mousemove",this.mousemove),W.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=g=>{this.moveMouse(g,W.mousePos(this.element,g))},this.mouseup=g=>{this.mouseRotate.dragEnd(g),this.mousePitch&&this.mousePitch.dragEnd(g),this.offTemp()},this.touchstart=g=>{g.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=W.touchPos(this.element,g.targetTouches)[0],this.startTouch(g,this._startPos),W.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),W.addEventListener(window,"touchend",this.touchend))},this.touchmove=g=>{g.targetTouches.length!==1?this.reset():(this._lastPos=W.touchPos(this.element,g.targetTouches)[0],this.moveTouch(g,this._lastPos))},this.touchend=g=>{g.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 c=t.dragRotate._mouseRotate.getClickTolerance(),p=t.dragRotate._mousePitch.getClickTolerance();this.element=n,this.mouseRotate=Kn({clickTolerance:c,enable:!0}),this.touchRotate=(({enable:g,clickTolerance:_,bearingDegreesPerPixelMoved:x=.8})=>{const b=new vl;return new Nr({clickTolerance:_,move:(T,I)=>({bearingDelta:(I.x-T.x)*x}),moveStateManager:b,enable:g,assignEvents:Ia})})({clickTolerance:c,enable:!0}),this.map=t,s&&(this.mousePitch=Vr({clickTolerance:p,enable:!0}),this.touchPitch=(({enable:g,clickTolerance:_,pitchDegreesPerPixelMoved:x=-.5})=>{const b=new vl;return new Nr({clickTolerance:_,move:(T,I)=>({pitchDelta:(I.y-T.y)*x}),moveStateManager:b,enable:g,assignEvents:Ia})})({clickTolerance:p,enable:!0})),W.addEventListener(n,"mousedown",this.mousedown),W.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),W.addEventListener(n,"touchcancel",this.reset)}startMouse(t,n){this.mouseRotate.dragStart(t,n),this.mousePitch&&this.mousePitch.dragStart(t,n),W.disableDrag()}startTouch(t,n){this.touchRotate.dragStart(t,n),this.touchPitch&&this.touchPitch.dragStart(t,n),W.disableDrag()}moveMouse(t,n){const s=this.map,{bearingDelta:c}=this.mouseRotate.dragMove(t,n)||{};if(c&&s.setBearing(s.getBearing()+c),this.mousePitch){const{pitchDelta:p}=this.mousePitch.dragMove(t,n)||{};p&&s.setPitch(s.getPitch()+p)}}moveTouch(t,n){const s=this.map,{bearingDelta:c}=this.touchRotate.dragMove(t,n)||{};if(c&&s.setBearing(s.getBearing()+c),this.touchPitch){const{pitchDelta:p}=this.touchPitch.dragMove(t,n)||{};p&&s.setPitch(s.getPitch()+p)}}off(){const t=this.element;W.removeEventListener(t,"mousedown",this.mousedown),W.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),W.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),W.removeEventListener(window,"touchend",this.touchend),W.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){W.enableDrag(),W.removeEventListener(window,"mousemove",this.mousemove),W.removeEventListener(window,"mouseup",this.mouseup),W.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),W.removeEventListener(window,"touchend",this.touchend)}}let Wt;function fo(u,t,n){if(u=new l.L(u.lng,u.lat),t){const s=new l.L(u.lng-360,u.lat),c=new l.L(u.lng+360,u.lat),p=n.locationPoint(u).distSqr(t);n.locationPoint(s).distSqr(t)<p?u=s:n.locationPoint(c).distSqr(t)<p&&(u=c)}for(;Math.abs(u.lng-n.center.lng)>180;){const s=n.locationPoint(u);if(s.x>=0&&s.y>=0&&s.x<=n.width&&s.y<=n.height)break;u.lng>n.center.lng?u.lng-=360:u.lng+=360}return u}const pr={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 El(u,t,n){const s=u.classList;for(const c in pr)s.remove(`maplibregl-${n}-anchor-${c}`);s.add(`maplibregl-${n}-anchor-${t}`)}class Tn extends l.E{constructor(t){if(super(),this._onKeyPress=n=>{const s=n.code,c=n.charCode||n.keyCode;s!=="Space"&&s!=="Enter"&&c!==32&&c!==13||this.togglePopup()},this._onMapClick=n=>{const s=n.originalEvent.target,c=this._element;this._popup&&(s===c||c.contains(s))&&this.togglePopup()},this._update=n=>{if(!this._map)return;const s=this._map.loaded()&&!this._map.isMoving();((n==null?void 0:n.type)==="terrain"||(n==null?void 0:n.type)==="render"&&!s)&&this._map.once("render",this._update),this._map.transform.renderWorldCopies&&(this._lngLat=fo(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(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 p="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?p="rotateX(0deg)":this._pitchAlignment==="map"&&(p=`rotateX(${this._map.getPitch()}deg)`),n&&n.type!=="moveend"||(this._pos=this._pos.round()),W.setTransform(this._element,`${pr[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${p} ${c}`),this._map.terrain&&!this._opacityTimeout&&(this._opacityTimeout=setTimeout((()=>{const g=this._map.unproject(this._pos),_=40075016686e-3*Math.abs(Math.cos(this._lngLat.lat*Math.PI/180))/Math.pow(2,this._map.transform.tileZoom+8);this._element.style.opacity=g.distanceTo(this._lngLat)>20*_?"0.2":"1.0",this._opacityTimeout=null}),100))},this._onMove=n=>{if(!this._isDragging){const s=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=s}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new l.k("dragstart"))),this.fire(new l.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 l.k("dragend")),this._state="inactive"},this._addDragHandler=n=>{this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(this._pos).add(this._offset),this._pointerdownPos=n.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment!=="auto"?t.pitchAlignment:this._rotationAlignment,t&&t.element)this._element=t.element,this._offset=l.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=W.create("div"),this._element.setAttribute("aria-label","Map marker");const n=W.createNS("http://www.w3.org/2000/svg","svg"),s=41,c=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${s}px`),n.setAttributeNS(null,"width",`${c}px`),n.setAttributeNS(null,"viewBox",`0 0 ${c} ${s}`);const p=W.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"stroke","none"),p.setAttributeNS(null,"stroke-width","1"),p.setAttributeNS(null,"fill","none"),p.setAttributeNS(null,"fill-rule","evenodd");const g=W.createNS("http://www.w3.org/2000/svg","g");g.setAttributeNS(null,"fill-rule","nonzero");const _=W.createNS("http://www.w3.org/2000/svg","g");_.setAttributeNS(null,"transform","translate(3.0, 29.0)"),_.setAttributeNS(null,"fill","#000000");const x=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const ee of x){const se=W.createNS("http://www.w3.org/2000/svg","ellipse");se.setAttributeNS(null,"opacity","0.04"),se.setAttributeNS(null,"cx","10.5"),se.setAttributeNS(null,"cy","5.80029008"),se.setAttributeNS(null,"rx",ee.rx),se.setAttributeNS(null,"ry",ee.ry),_.appendChild(se)}const b=W.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill",this._color);const T=W.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 I=W.createNS("http://www.w3.org/2000/svg","g");I.setAttributeNS(null,"opacity","0.25"),I.setAttributeNS(null,"fill","#000000");const P=W.createNS("http://www.w3.org/2000/svg","path");P.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),I.appendChild(P);const V=W.createNS("http://www.w3.org/2000/svg","g");V.setAttributeNS(null,"transform","translate(6.0, 7.0)"),V.setAttributeNS(null,"fill","#FFFFFF");const N=W.createNS("http://www.w3.org/2000/svg","g");N.setAttributeNS(null,"transform","translate(8.0, 8.0)");const $=W.createNS("http://www.w3.org/2000/svg","circle");$.setAttributeNS(null,"fill","#000000"),$.setAttributeNS(null,"opacity","0.25"),$.setAttributeNS(null,"cx","5.5"),$.setAttributeNS(null,"cy","5.5"),$.setAttributeNS(null,"r","5.4999962");const B=W.createNS("http://www.w3.org/2000/svg","circle");B.setAttributeNS(null,"fill","#FFFFFF"),B.setAttributeNS(null,"cx","5.5"),B.setAttributeNS(null,"cy","5.5"),B.setAttributeNS(null,"r","5.4999962"),N.appendChild($),N.appendChild(B),g.appendChild(_),g.appendChild(b),g.appendChild(I),g.appendChild(V),g.appendChild(N),n.appendChild(g),n.setAttributeNS(null,"height",s*this._scale+"px"),n.setAttributeNS(null,"width",c*this._scale+"px"),this._element.appendChild(n),this._offset=l.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(n=>{n.preventDefault()})),this._element.addEventListener("mousedown",(n=>{n.preventDefault()})),El(this._element,this._anchor,"marker"),t&&t.className)for(const n of t.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(t){return this.remove(),this._map=t,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("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),W.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=l.L.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 c=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":[c,-1*(38.1-13.5+c)],"bottom-right":[-c,-1*(38.1-13.5+c)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=t,this._lngLat&&this._popup.setLngLat(this._lngLat),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?t.remove():t.addTo(this._map),this):this}getOffset(){return this._offset}setOffset(t){return this._offset=l.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}}const qt={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Nt=0,Jn=!1;const Aa={maxWidth:100,unit:"metric"};function ka(u,t,n){const s=n&&n.maxWidth||100,c=u._container.clientHeight/2,p=u.unproject([0,c]),g=u.unproject([s,c]),_=p.distanceTo(g);if(n&&n.unit==="imperial"){const x=3.2808*_;x>5280?In(t,s,x/5280,u._getUIString("ScaleControl.Miles")):In(t,s,x,u._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?In(t,s,_/1852,u._getUIString("ScaleControl.NauticalMiles")):_>=1e3?In(t,s,_/1e3,u._getUIString("ScaleControl.Kilometers")):In(t,s,_,u._getUIString("ScaleControl.Meters"))}function In(u,t,n,s){const c=(function(p){const g=Math.pow(10,`${Math.floor(p)}`.length-1);let _=p/g;return _=_>=10?10:_>=5?5:_>=3?3:_>=2?2:_>=1?1:(function(x){const b=Math.pow(10,Math.ceil(-Math.log(x)/Math.LN10));return Math.round(x*b)/b})(_),g*_})(n);u.style.width=t*(c/n)+"px",u.innerHTML=`${c}&nbsp;${s}`}const mo={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},go=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Qn(u){if(u){if(typeof u=="number"){const t=Math.round(Math.abs(u)/Math.SQRT2);return{center:new l.P(0,0),top:new l.P(0,u),"top-left":new l.P(t,t),"top-right":new l.P(-t,t),bottom:new l.P(0,-u),"bottom-left":new l.P(t,-t),"bottom-right":new l.P(-t,-t),left:new l.P(u,0),right:new l.P(-u,0)}}if(u instanceof l.P||Array.isArray(u)){const t=l.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:l.P.convert(u.center||[0,0]),top:l.P.convert(u.top||[0,0]),"top-left":l.P.convert(u["top-left"]||[0,0]),"top-right":l.P.convert(u["top-right"]||[0,0]),bottom:l.P.convert(u.bottom||[0,0]),"bottom-left":l.P.convert(u["bottom-left"]||[0,0]),"bottom-right":l.P.convert(u["bottom-right"]||[0,0]),left:l.P.convert(u.left||[0,0]),right:l.P.convert(u.right||[0,0])}}return Qn(new l.P(0,0))}const _o={extend:(u,...t)=>l.e(u,...t),run(u){u()},logToElement(u,t=!1,n="log"){const s=window.document.getElementById(n);s&&(t&&(s.innerHTML=""),s.innerHTML+=`<br>${u}`)}},yo=le;class vt{static get version(){return yo}static get workerCount(){return br.workerCount}static set workerCount(t){br.workerCount=t}static get maxParallelImageRequests(){return l.c.MAX_PARALLEL_IMAGE_REQUESTS}static set maxParallelImageRequests(t){l.c.MAX_PARALLEL_IMAGE_REQUESTS=t}static get workerUrl(){return l.c.WORKER_URL}static set workerUrl(t){l.c.WORKER_URL=t}static addProtocol(t,n){l.c.REGISTERED_PROTOCOLS[t]=n}static removeProtocol(t){delete l.c.REGISTERED_PROTOCOLS[t]}}return vt.Map=class extends Il{constructor(u){if(l.bg.mark(l.bh.create),(u=l.e({},He,u)).minZoom!=null&&u.maxZoom!=null&&u.minZoom>u.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(u.minPitch!=null&&u.maxPitch!=null&&u.minPitch>u.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(u.minPitch!=null&&u.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(u.maxPitch!=null&&u.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new ls(u.minZoom,u.maxZoom,u.minPitch,u.maxPitch,u.renderWorldCopies),{bearingSnap:u.bearingSnap}),this._cooperativeGesturesOnWheel=t=>{this._onCooperativeGesture(t,t[this._metaKey],1)},this._contextLost=t=>{t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new l.k("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{this._setupPainter(),this.resize(),this._update(),this.fire(new l.k("webglcontextrestored",{originalEvent:t}))},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=u.interactive,this._cooperativeGestures=u.cooperativeGestures,this._metaKey=navigator.platform.indexOf("Mac")===0?"metaKey":"ctrlKey",this._maxTileCacheSize=u.maxTileCacheSize,this._maxTileCacheZoomLevels=u.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=u.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=u.preserveDrawingBuffer,this._antialias=u.antialias,this._trackResize=u.trackResize,this._bearingSnap=u.bearingSnap,this._refreshExpiredTiles=u.refreshExpiredTiles,this._fadeDuration=u.fadeDuration,this._crossSourceCollisions=u.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=u.collectResourceTiming,this._renderTaskQueue=new ps,this._controls=[],this._mapId=l.a2(),this._locale=l.e({},uo,u.locale),this._clickTolerance=u.clickTolerance,this._overridePixelRatio=u.pixelRatio,this._maxCanvasSize=u.maxCanvasSize,this.transformCameraUpdate=u.transformCameraUpdate,this._imageQueueHandle=Ke.addThrottleControl((()=>this.isMoving())),this._requestManager=new st(u.transformRequest),typeof u.container=="string"){if(this._container=document.getElementById(u.container),!this._container)throw new Error(`Container '${u.container}' not found.`)}else{if(!(u.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=u.container}if(u.maxBounds&&this.setMaxBounds(u.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})),this.once("idle",(()=>{this._idleTriggered=!0})),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let t=!1;const n=Sn((s=>{this._trackResize&&!this._removed&&this.resize(s)._update()}),50);this._resizeObserver=new ResizeObserver((s=>{t?n(s):t=!0})),this._resizeObserver.observe(this._container)}this.handlers=new co(this,u),this._cooperativeGestures&&this._setupCooperativeGestures(),this._hash=u.hash&&new va(typeof u.hash=="string"&&u.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:u.center,zoom:u.zoom,bearing:u.bearing,pitch:u.pitch}),u.bounds&&(this.resize(),this.fitBounds(u.bounds,l.e({},u.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=u.localIdeographFontFamily,this._validateStyle=u.validateStyle,u.style&&this.setStyle(u.style,{localIdeographFontFamily:u.localIdeographFontFamily}),u.attributionControl&&this.addControl(new Ki({customAttribution:u.customAttribution})),u.maplibreLogo&&this.addControl(new Mt,u.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(t=>{this._update(t.dataType==="style"),this.fire(new l.k(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new l.k(`${t.dataType}dataloading`,t))})),this.on("dataabort",(t=>{this.fire(new l.k("sourcedataabort",t))}))}_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 l.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=u.onAdd(this);this._controls.push(u);const s=this._controlPositions[t];return t.indexOf("bottom")!==-1?s.insertBefore(n,s.firstChild):s.appendChild(n),this}removeControl(u){if(!u||!u.onRemove)return this.fire(new l.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,n,s){return s==null&&this.terrain&&(s=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(u,t,n,s)}resize(u){var t;const n=this._containerDimensions(),s=n[0],c=n[1],p=this._getClampedPixelRatio(s,c);if(this._resizeCanvas(s,c,p),this.painter.resize(s,c,p),this.painter.overLimit()){const _=this.painter.context.gl;this._maxCanvasSize=[_.drawingBufferWidth,_.drawingBufferHeight];const x=this._getClampedPixelRatio(s,c);this._resizeCanvas(s,c,x),this.painter.resize(s,c,x)}this.transform.resize(s,c),(t=this._requestedCameraState)===null||t===void 0||t.resize(s,c);const g=!this._moving;return g&&(this.stop(),this.fire(new l.k("movestart",u)).fire(new l.k("move",u))),this.fire(new l.k("resize",u)),g&&this.fire(new l.k("moveend",u)),this}_getClampedPixelRatio(u,t){const{0:n,1:s}=this._maxCanvasSize,c=this.getPixelRatio(),p=u*c,g=t*c;return Math.min(p>n?n/p:1,g>s?s/g:1)*c}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(Et.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()}getCooperativeGestures(){return this._cooperativeGestures}setCooperativeGestures(u){return this._cooperativeGestures=u,this._cooperativeGestures?this._setupCooperativeGestures():this._destroyCooperativeGestures(),this}project(u){return this.transform.locationPoint(l.L.convert(u),this.style&&this.terrain)}unproject(u){return this.transform.pointLocation(l.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,n){if(u==="mouseenter"||u==="mouseover"){let s=!1;return{layer:t,listener:n,delegates:{mousemove:p=>{const g=this.getLayer(t)?this.queryRenderedFeatures(p.point,{layers:[t]}):[];g.length?s||(s=!0,n.call(this,new Xi(u,this,p.originalEvent,{features:g}))):s=!1},mouseout:()=>{s=!1}}}}if(u==="mouseleave"||u==="mouseout"){let s=!1;return{layer:t,listener:n,delegates:{mousemove:g=>{(this.getLayer(t)?this.queryRenderedFeatures(g.point,{layers:[t]}):[]).length?s=!0:s&&(s=!1,n.call(this,new Xi(u,this,g.originalEvent)))},mouseout:g=>{s&&(s=!1,n.call(this,new Xi(u,this,g.originalEvent)))}}}}{const s=c=>{const p=this.getLayer(t)?this.queryRenderedFeatures(c.point,{layers:[t]}):[];p.length&&(c.features=p,n.call(this,c),delete c.features)};return{layer:t,listener:n,delegates:{[u]:s}}}}on(u,t,n){if(n===void 0)return super.on(u,t);const s=this._createDelegatedListener(u,t,n);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[u]=this._delegatedListeners[u]||[],this._delegatedListeners[u].push(s);for(const c in s.delegates)this.on(c,s.delegates[c]);return this}once(u,t,n){if(n===void 0)return super.once(u,t);const s=this._createDelegatedListener(u,t,n);for(const c in s.delegates)this.once(c,s.delegates[c]);return this}off(u,t,n){return n===void 0?super.off(u,t):(this._delegatedListeners&&this._delegatedListeners[u]&&(s=>{const c=this._delegatedListeners[u];for(let p=0;p<c.length;p++){const g=c[p];if(g.layer===t&&g.listener===n){for(const _ in g.delegates)this.off(_,g.delegates[_]);return c.splice(p,1),this}}})(),this)}queryRenderedFeatures(u,t){if(!this.style)return[];let n;const s=u instanceof l.P||Array.isArray(u),c=s?u:[[0,0],[this.transform.width,this.transform.height]];if(t=t||(s?{}:u)||{},c instanceof l.P||typeof c[0]=="number")n=[l.P.convert(c)];else{const p=l.P.convert(c[0]),g=l.P.convert(c[1]);n=[p,new l.P(g.x,p.y),g,new l.P(p.x,g.y),p]}return this.style.queryRenderedFeatures(n,t,this.transform)}querySourceFeatures(u,t){return this.style.querySourceFeatures(u,t)}setStyle(u,t){return(t=l.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 n=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!u)),u?(this.style=new hi(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof u=="string"?this.style.loadURL(u,t,n):this.style.loadJSON(u,t,n),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new hi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(u,t){if(typeof u=="string"){const n=this._requestManager.transformRequest(u,Ye.Style);l.f(n,((s,c)=>{s?this.fire(new l.j(s)):c&&this._updateDiff(c,t)}))}else typeof u=="object"&&this._updateDiff(u,t)}_updateDiff(u,t){try{this.style.setState(u,t)&&this._update(!0)}catch(n){l.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(u,t)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():l.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 l.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}`);for(const n in this.style._layers){const s=this.style._layers[n];s.type==="hillshade"&&s.source===u.source&&l.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Cl(this.painter,t,u),this.painter.renderToTexture=new ds(this.painter,this.terrain),this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=n=>{n.dataType==="style"?this.terrain.sourceCache.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==u.source||this._elevationFreeze||(this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(n.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform._minEleveationForCurrentTile=0,this.transform.elevation=0;return this.fire(new l.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 n=u[t]._tiles;for(const s in n){const c=n[s];if(c.state!=="loaded"&&c.state!=="errored")return!1}}return!0}addSourceType(u,t,n){return this._lazyInitEmptyStyle(),this.style.addSourceType(u,t,n)}removeSource(u){return this.style.removeSource(u),this._update(!0)}getSource(u){return this.style.getSource(u)}addImage(u,t,n={}){const{pixelRatio:s=1,sdf:c=!1,stretchX:p,stretchY:g,content:_}=n;if(this._lazyInitEmptyStyle(),!(t instanceof HTMLImageElement||l.a(t))){if(t.width===void 0||t.height===void 0)return this.fire(new l.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:x,height:b,data:T}=t,I=t;return this.style.addImage(u,{data:new l.R({width:x,height:b},new Uint8Array(T)),pixelRatio:s,stretchX:p,stretchY:g,content:_,sdf:c,version:0,userImage:I}),I.onAdd&&I.onAdd(this,u),this}}{const{width:x,height:b,data:T}=l.h.getImageData(t);this.style.addImage(u,{data:new l.R({width:x,height:b},T),pixelRatio:s,stretchX:p,stretchY:g,content:_,sdf:c,version:0})}}updateImage(u,t){const n=this.style.getImage(u);if(!n)return this.fire(new l.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const s=t instanceof HTMLImageElement||l.a(t)?l.h.getImageData(t):t,{width:c,height:p,data:g}=s;if(c===void 0||p===void 0)return this.fire(new l.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(c!==n.data.width||p!==n.data.height)return this.fire(new l.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const _=!(t instanceof HTMLImageElement||l.a(t));return n.data.replace(g,_),this.style.updateImage(u,n),this}getImage(u){return this.style.getImage(u)}hasImage(u){return u?!!this.style.getImage(u):(this.fire(new l.j(new Error("Missing required image id"))),!1)}removeImage(u){this.style.removeImage(u)}loadImage(u,t){Ke.getImage(this._requestManager.transformRequest(u,Ye.Image),t)}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,n){return this.style.setLayerZoomRange(u,t,n),this._update(!0)}setFilter(u,t,n={}){return this.style.setFilter(u,t,n),this._update(!0)}getFilter(u){return this.style.getFilter(u)}setPaintProperty(u,t,n,s={}){return this.style.setPaintProperty(u,t,n,s),this._update(!0)}getPaintProperty(u,t){return this.style.getPaintProperty(u,t)}setLayoutProperty(u,t,n,s={}){return this.style.setLayoutProperty(u,t,n,s),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,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(u,t,n,(s=>{s||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,(n=>{n||this._update(!0)})),this}setLight(u,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(u,t),this._update(!0)}getLight(){return this.style.getLight()}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=W.create("div","maplibregl-canvas-container",u);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=W.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region");const n=this._containerDimensions(),s=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],s);const c=this._controlContainer=W.create("div","maplibregl-control-container",u),p=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((g=>{p[g]=W.create("div",`maplibregl-ctrl-${g} `,c)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_setupCooperativeGestures(){this._cooperativeGesturesScreen=W.create("div","maplibregl-cooperative-gesture-screen",this._container);let u=typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.windowsHelpText?this._cooperativeGestures.windowsHelpText:"Use Ctrl + scroll to zoom the map";navigator.platform.indexOf("Mac")===0&&(u=typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.macHelpText?this._cooperativeGestures.macHelpText:"Use ⌘ + scroll to zoom the map"),this._cooperativeGesturesScreen.innerHTML=`
<div class="maplibregl-desktop-message">${u}</div>
<div class="maplibregl-mobile-message">${typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.mobileHelpText?this._cooperativeGestures.mobileHelpText:"Use two fingers to move the map"}</div>
`,this._cooperativeGesturesScreen.setAttribute("aria-hidden","true"),this._canvasContainer.addEventListener("wheel",this._cooperativeGesturesOnWheel,!1),this._canvasContainer.classList.add("maplibregl-cooperative-gestures")}_destroyCooperativeGestures(){W.remove(this._cooperativeGesturesScreen),this._canvasContainer.removeEventListener("wheel",this._cooperativeGesturesOnWheel,!1),this._canvasContainer.classList.remove("maplibregl-cooperative-gestures")}_resizeCanvas(u,t,n){this._canvas.width=Math.floor(n*u),this._canvas.height=Math.floor(n*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",(s=>{t={requestedAttributes:u},s&&(t.statusMessage=s.statusMessage,t.type=s.type)}),{once:!0});const n=this._canvas.getContext("webgl2",u)||this._canvas.getContext("webgl",u);if(!n){const s="Failed to initialize WebGL";throw t?(t.message=s,new Error(JSON.stringify(t))):new Error(s)}this.painter=new wn(n,this.transform),Se.testSupport(n)}_onCooperativeGesture(u,t,n){return!t&&n<2&&(this._cooperativeGesturesScreen.classList.add("maplibregl-show"),setTimeout((()=>{this._cooperativeGesturesScreen.classList.remove("maplibregl-show")}),100)),!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(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 n=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const c=this.transform.zoom,p=l.h.now();this.style.zoomHistory.update(c,p);const g=new l.a8(c,{now:p,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),_=g.crossFadingFactor();_===1&&_===this._crossFadingFactor||(n=!0,this._crossFadingFactor=_),this.style.update(g)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform._minEleveationForCurrentTile=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._minEleveationForCurrentTile=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 l.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,l.bg.mark(l.bh.load),this.fire(new l.k("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const s=this._sourcesDirty||this._styleDirty||this._placementDirty;return s||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new l.k("idle")),!this._loaded||this._fullyLoaded||s||(this._fullyLoaded=!0,l.bg.mark(l.bh.fullLoad)),this}redraw(){return this.style&&(this._frame&&(this._frame.cancel(),this._frame=null),this._render(0)),this}remove(){var u;this._hash&&this._hash.remove();for(const n of this._controls)n.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),Ke.removeThrottleControl(this._imageQueueHandle),(u=this._resizeObserver)===null||u===void 0||u.disconnect();const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),W.remove(this._canvasContainer),W.remove(this._controlContainer),this._cooperativeGestures&&this._destroyCooperativeGestures(),this._container.classList.remove("maplibregl-map"),l.bg.clearMetrics(),this._removed=!0,this.fire(new l.k("remove"))}triggerRepaint(){this.style&&!this._frame&&(this._frame=l.h.frame((u=>{l.bg.frame(u),this._frame=null,this._render(u)})))}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 je}getCameraTargetElevation(){return this.transform.elevation}},vt.NavigationControl=class{constructor(u){this._updateZoomButtons=()=>{const t=this._map.getZoom(),n=t===this._map.getMaxZoom(),s=t===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=s,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",s.toString())},this._rotateCompassArrow=()=>{const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=t},this._setButtonTitle=(t,n)=>{const s=this._map._getUIString(`NavigationControl.${n}`);t.title=s,t.setAttribute("aria-label",s)},this.options=l.e({},ho,u),this._container=W.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}))),W.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}))),W.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=W.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 po(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){W.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 n=W.create("button",u,this._container);return n.type="button",n.addEventListener("click",t),n}},vt.GeolocateControl=class extends l.E{constructor(u){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new l.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 l.k("geolocate",t)),this._finish()}},this._updateCamera=t=>{const n=new l.L(t.coords.longitude,t.coords.latitude),s=t.coords.accuracy,c=this._map.getBearing(),p=l.e({bearing:c},this.options.fitBoundsOptions),g=Et.fromLngLat(n,s);this._map.fitBounds(g,p,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const n=new l.L(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=t=>{if(this._map){if(this.options.trackUserLocation)if(t.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(t.code===3&&Jn)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new l.k("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=t=>{if(this._map){if(this._container.addEventListener("contextmenu",(n=>n.preventDefault())),this._geolocateButton=W.create("button","maplibregl-ctrl-geolocate",this._container),W.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",t===!1){l.w("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=W.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Tn({element:this._dotElement}),this._circleElement=W.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Tn({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(n=>{n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||n.originalEvent&&n.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new l.k("trackuserlocationend")))}))}},this.options=l.e({},qt,u)}onAdd(u){return this._map=u,this._container=W.create("div","maplibregl-ctrl maplibregl-ctrl-group"),(function(t,n=!1){Wt===void 0||n?window.navigator.permissions!==void 0?window.navigator.permissions.query({name:"geolocation"}).then((s=>{Wt=s.state!=="denied",t(Wt)})).catch((()=>{Wt=!!window.navigator.geolocation,t(Wt)})):(Wt=!!window.navigator.geolocation,t(Wt)):t(Wt)})(this._setupUI),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(),W.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Nt=0,Jn=!1}_isOutOfMapMaxBounds(u){const t=this._map.getMaxBounds(),n=u.coords;return t&&(n.longitude<t.getWest()||n.longitude>t.getEast()||n.latitude<t.getSouth()||n.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const u=this._map.getBounds(),t=u.getSouthEast(),n=u.getNorthEast(),s=t.distanceTo(n),c=Math.ceil(this._accuracy/(s/this._map._container.clientHeight)*2);this._circleElement.style.width=`${c}px`,this._circleElement.style.height=`${c}px`}trigger(){if(!this._setup)return l.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new l.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Nt--,Jn=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new l.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 l.k("trackuserlocationstart"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let u;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Nt++,Nt>1?(u={maximumAge:6e5,timeout:0},Jn=!0):(u=this.options.positionOptions,Jn=!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)}},vt.AttributionControl=Ki,vt.LogoControl=Mt,vt.ScaleControl=class{constructor(u){this._onMove=()=>{ka(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,ka(this._map,this._container,this.options)},this.options=l.e({},Aa,u)}getDefaultPosition(){return"bottom-left"}onAdd(u){return this._map=u,this._container=W.create("div","maplibregl-ctrl maplibregl-ctrl-scale",u.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){W.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},vt.FullscreenControl=class extends l.E{constructor(u={}){super(),this._onFullscreenChange=()=>{(window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement)===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,u&&u.container&&(u.container instanceof HTMLElement?this._container=u.container:l.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=W.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){W.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const u=this._fullscreenButton=W.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);W.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 l.k("fullscreenstart")),this._map._cooperativeGestures&&(this._prevCooperativeGestures=this._map._cooperativeGestures,this._map.setCooperativeGestures())):(this.fire(new l.k("fullscreenend")),this._prevCooperativeGestures&&(this._map.setCooperativeGestures(this._prevCooperativeGestures),delete this._prevCooperativeGestures))}_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()}},vt.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.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))},this.options=u}onAdd(u){return this._map=u,this._container=W.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=W.create("button","maplibregl-ctrl-terrain",this._container),W.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(){W.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},vt.Popup=class extends l.E{constructor(u){super(),this.remove=()=>(this._content&&W.remove(this._content),this._container&&(W.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new l.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=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=W.create("div","maplibregl-popup",this._map.getContainer()),this._tip=W.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._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._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=fo(this._lngLat,this._pos,this._map.transform)),this._trackPointer&&!t)return;const n=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);let s=this.options.anchor;const c=Qn(this.options.offset);if(!s){const g=this._container.offsetWidth,_=this._container.offsetHeight;let x;x=n.y+c.bottom.y<_?["top"]:n.y>this._map.transform.height-_?["bottom"]:[],n.x<g/2?x.push("left"):n.x>this._map.transform.width-g/2&&x.push("right"),s=x.length===0?"bottom":x.join("-")}const p=n.add(c[s]).round();W.setTransform(this._container,`${pr[s]} translate(${p.x}px,${p.y}px)`),El(this._container,s,"popup")},this._onClose=()=>{this.remove()},this.options=l.e(Object.create(mo),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 l.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(u){return this._lngLat=l.L.convert(u),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(u){return this.setDOMContent(document.createTextNode(u))}setHTML(u){const t=document.createDocumentFragment(),n=document.createElement("body");let s;for(n.innerHTML=u;s=n.firstChild,s;)t.appendChild(s);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=W.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(u),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(u){this._container&&this._container.classList.add(u)}removeClassName(u){this._container&&this._container.classList.remove(u)}setOffset(u){return this.options.offset=u,this._update(),this}toggleClassName(u){if(this._container)return this._container.classList.toggle(u)}_createCloseButton(){this.options.closeButton&&(this._closeButton=W.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const u=this._container.querySelector(go);u&&u.focus()}},vt.Marker=Tn,vt.Style=hi,vt.LngLat=l.L,vt.LngLatBounds=Et,vt.Point=l.P,vt.MercatorCoordinate=l.U,vt.Evented=l.E,vt.AJAXError=l.bi,vt.config=l.c,vt.CanvasSource=Xr,vt.GeoJSONSource=Wr,vt.ImageSource=ar,vt.RasterDEMTileSource=Bn,vt.RasterTileSource=Rn,vt.VectorTileSource=dn,vt.VideoSource=ua,vt.setRTLTextPlugin=l.bj,vt.getRTLTextPluginStatus=l.bk,vt.prewarm=function(){Na().acquire(_t)},vt.clearPrewarmedResources=function(){const u=Lr;u&&(u.isPreloaded()&&u.numActive()===1?(u.release(_t),Lr=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()"))},_o.extend(vt,{isSafari:l.ac,getPerformanceMetrics:l.bg.getPerformanceMetrics}),vt}));var K=F;return K}))})(Oo)),Oo.exports}var ud=cd();const bu=od(ud);function No(h,w,E,L,F,Q,K,l){var le=typeof h=="function"?h.options:h;return w&&(le.render=w,le.staticRenderFns=E,le._compiled=!0),Q&&(le._scopeId="data-v-"+Q),{exports:h,options:le}}const hd={props:{center:{type:Object,required:!0},zoom:{type:Number,required:!0},markers:{type:Array,default:()=>[]},selectedMarkerId:{type:String,default:null}},setup(h,{emit:w}){const E=Vue.ref(null),L=Vue.ref(null),F=Vue.ref(!0),Q=Vue.ref(new Map),K=Vue.ref(!1);Vue.onMounted(async()=>{await Vue.nextTick(),l()}),Vue.onBeforeUnmount(()=>{L.value&&(L.value.remove(),L.value=null),Q.value.clear()}),Vue.watch(()=>h.center,ve=>{if(L.value&&L.value.loaded()&&!K.value){const $e=L.value.getCenter();(Math.abs($e.lat-ve.lat)>1e-5||Math.abs($e.lng-ve.lon)>1e-5)&&L.value.setCenter([ve.lon,ve.lat])}},{deep:!0}),Vue.watch(()=>h.zoom,ve=>{if(L.value&&L.value.loaded()){const $e=L.value.getZoom();Math.abs($e-ve)>.01&&L.value.setZoom(ve)}}),Vue.watch(()=>h.markers,()=>{le()},{deep:!0}),Vue.watch(()=>h.selectedMarkerId,ve=>{Se(ve)});function l(){if(!E.value){console.error("Map container not found");return}F.value=!0;try{L.value=new bu.Map({container:E.value,style:{version:8,sources:{osm:{type:"raster",tiles:["https://a.tile.openstreetmap.org/{z}/{x}/{y}.png","https://b.tile.openstreetmap.org/{z}/{x}/{y}.png","https://c.tile.openstreetmap.org/{z}/{x}/{y}.png"],tileSize:256,attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}},layers:[{id:"osm",type:"raster",source:"osm",minzoom:0,maxzoom:19}]},center:[h.center.lon,h.center.lat],zoom:h.zoom}),L.value.on("load",()=>{F.value=!1,le()}),L.value.on("click",ve=>{if(!ve.originalEvent.target.closest(".custom-marker")){const Ke={lat:ve.lngLat.lat,lng:ve.lngLat.lng};w("map-click",Ke)}})}catch(ve){console.error("Error initializing map:",ve),F.value=!1}}function le(){!L.value||!L.value.loaded()||(Q.value.forEach(({marker:ve})=>{ve&&ve.remove()}),Q.value.clear(),h.markers&&Array.isArray(h.markers)&&h.markers.forEach((ve,$e)=>{W(ve,$e)}))}function W(ve,$e){if(!L.value||!ve||!ve.position)return;const Qe=document.createElement("div");Qe.className="custom-marker";const Ke=document.createElement("div");Ke.className="marker-inner",h.selectedMarkerId===ve.id&&Ke.classList.add("selected");const Ye=document.createElement("div");Ye.className="marker-number",Ye.textContent=$e+1,Ke.appendChild(Ye),Qe.appendChild(Ke);try{const st=[ve.position.lon,ve.position.lat],wi=new bu.Marker({element:Qe,draggable:!0,anchor:"bottom"}).setLngLat(st).addTo(L.value);wi.on("dragstart",()=>{K.value=!0}),wi.on("dragend",()=>{const Pi=wi.getLngLat();w("marker-moved",{markerId:ve.id,position:{lat:Pi.lat,lng:Pi.lng}}),setTimeout(()=>{K.value=!1},100)}),Qe.addEventListener("click",Pi=>{Pi.stopPropagation(),w("marker-click",ve.id)}),Qe.addEventListener("dblclick",Pi=>{Pi.stopPropagation(),w("marker-dblclick",ve.id)}),Q.value.set(ve.id,{marker:wi,element:Qe})}catch(st){console.error("Error adding marker to map:",st)}}function Se(ve){Q.value.forEach(({element:$e},Qe)=>{if($e){const Ke=$e.querySelector(".marker-inner");Ke&&(Qe===ve?Ke.classList.add("selected"):Ke.classList.remove("selected"))}})}function de(){if(L.value&&L.value.loaded()){const ve=L.value.getCenter();return{lat:ve.lat,lon:ve.lng}}return{lat:h.center.lat,lon:h.center.lon}}function ge(ve,$e){L.value&&L.value.loaded()&&L.value.flyTo({center:[$e,ve],zoom:L.value.getZoom(),duration:1e3})}return{mapContainer:E,loading:F,getCurrentCenter:de,centerOnPosition:ge}}};var pd=function(){var w=this,E=w._self._c;return E("div",{staticClass:"map-preview"},[E("div",{ref:"mapContainer",staticClass:"map-container"}),w.loading?E("div",{staticClass:"map-loading"},[E("div",{staticClass:"spinner"}),E("span",[w._v("Loading map...")])]):w._e()])},dd=[],fd=No(hd,pd,dd,!1,null,null);const md=fd.exports,Is={BASE_URL:"https://nominatim.openstreetmap.org/search",USER_AGENT:"GeoProject/1.0 (Kirby CMS Map Editor)",RATE_LIMIT_MS:1e3,MIN_QUERY_LENGTH:3,MAX_RESULTS:5,DEFAULT_LANGUAGE:"fr"},gd={GEOCODING:500};async function _d(h){if(!h||h.trim().length<Is.MIN_QUERY_LENGTH)return[];try{const w=new URLSearchParams({q:h.trim(),format:"json",addressdetails:"1",limit:String(Is.MAX_RESULTS),"accept-language":Is.DEFAULT_LANGUAGE}),E=await fetch(`${Is.BASE_URL}?${w.toString()}`,{headers:{"User-Agent":Is.USER_AGENT}});if(!E.ok)throw new Error(`Nominatim API error: ${E.status}`);return(await E.json()).map(F=>({id:F.place_id,displayName:F.display_name,lat:parseFloat(F.lat),lon:parseFloat(F.lon),type:F.type,importance:F.importance,boundingBox:F.boundingbox}))}catch(w){throw console.error("Geocoding error:",w),w}}function yd(h,w=500){let E;return function(...F){const Q=()=>{clearTimeout(E),h(...F)};clearTimeout(E),E=setTimeout(Q,w)}}const xd={emits:["select-location","center-map"],setup(h,{emit:w}){const E=Vue.ref(null),L=Vue.ref(""),F=Vue.ref([]),Q=Vue.ref(!1),K=Vue.ref(null),l=Vue.ref(!1),le=Vue.ref(-1),W=yd(async Ye=>{if(!Ye||Ye.trim().length<3){F.value=[],l.value=!1,Q.value=!1;return}Q.value=!0,K.value=null;try{const st=await _d(Ye);F.value=st,l.value=!0,le.value=-1}catch{K.value="Erreur lors de la recherche. Veuillez réessayer.",F.value=[]}finally{Q.value=!1}},gd.GEOCODING);function Se(){W(L.value)}function de(Ye){w("select-location",{lat:Ye.lat,lon:Ye.lon,displayName:Ye.displayName}),L.value=Ye.displayName,l.value=!1}function ge(){F.value.length>0&&de(F.value[0])}function ve(Ye){!l.value||F.value.length===0||(le.value+=Ye,le.value<0?le.value=F.value.length-1:le.value>=F.value.length&&(le.value=0))}function $e(){L.value="",F.value=[],l.value=!1,K.value=null,le.value=-1}function Qe(){E.value&&E.value.focus()}function Ke(Ye){Ye.target.closest(".geocode-search")||(l.value=!1)}return Vue.watch(l,Ye=>{Ye?setTimeout(()=>{document.addEventListener("click",Ke)},100):document.removeEventListener("click",Ke)}),{searchInput:E,searchQuery:L,results:F,isLoading:Q,error:K,showResults:l,selectedIndex:le,handleInput:Se,selectResult:de,selectFirstResult:ge,navigateResults:ve,clearSearch:$e,focus:Qe}}};var vd=function(){var w=this,E=w._self._c;return E("div",{staticClass:"geocode-search"},[E("div",{staticClass:"search-input-wrapper"},[E("input",{directives:[{name:"model",rawName:"v-model",value:w.searchQuery,expression:"searchQuery"}],ref:"searchInput",staticClass:"search-input",attrs:{type:"text",placeholder:"Rechercher une adresse..."},domProps:{value:w.searchQuery},on:{input:[function(L){L.target.composing||(w.searchQuery=L.target.value)},w.handleInput],keydown:[function(L){return!L.type.indexOf("key")&&w._k(L.keyCode,"escape",void 0,L.key,void 0)?null:w.clearSearch.apply(null,arguments)},function(L){return!L.type.indexOf("key")&&w._k(L.keyCode,"enter",13,L.key,"Enter")?null:(L.preventDefault(),w.selectFirstResult.apply(null,arguments))},function(L){return!L.type.indexOf("key")&&w._k(L.keyCode,"down",40,L.key,["Down","ArrowDown"])?null:(L.preventDefault(),w.navigateResults(1))},function(L){return!L.type.indexOf("key")&&w._k(L.keyCode,"up",38,L.key,["Up","ArrowUp"])?null:(L.preventDefault(),w.navigateResults(-1))}]}}),w.searchQuery?E("button",{staticClass:"clear-button",attrs:{type:"button",title:"Effacer"},on:{click:w.clearSearch}},[E("k-icon",{attrs:{type:"cancel"}})],1):w._e(),w.isLoading?E("div",{staticClass:"search-spinner"},[E("div",{staticClass:"spinner-icon"})]):w._e()]),w.showResults?E("div",{staticClass:"results-dropdown"},[w.error?E("div",{staticClass:"error-message"},[E("k-icon",{attrs:{type:"alert"}}),E("span",[w._v(w._s(w.error))])],1):w.results.length===0&&!w.isLoading?E("div",{staticClass:"no-results"},[w._v(" Aucun résultat trouvé ")]):E("div",{staticClass:"results-list"},w._l(w.results,function(L,F){return E("div",{key:L.id,staticClass:"result-item",class:{active:F===w.selectedIndex},on:{click:function(Q){return w.selectResult(L)},mouseenter:function(Q){w.selectedIndex=F}}},[E("div",{staticClass:"result-icon"},[E("k-icon",{attrs:{type:"pin"}})],1),E("div",{staticClass:"result-content"},[E("div",{staticClass:"result-name"},[w._v(w._s(L.displayName))]),E("div",{staticClass:"result-coords"},[w._v(" "+w._s(L.lat.toFixed(6))+", "+w._s(L.lon.toFixed(6))+" ")])])])}),0),w.results.length>0?E("div",{staticClass:"results-footer"},[E("small",[w._v("Powered by OpenStreetMap Nominatim")])]):w._e()]):w._e()])},bd=[],wd=No(xd,vd,bd,!1,null,null);const Sd={components:{GeocodeSearch:wd.exports},props:{markers:{type:Array,required:!0},selectedMarkerId:{type:String,default:null},maxMarkers:{type:Number,default:50}},emits:["add-marker","select-marker","edit-marker","delete-marker","select-location"],setup(h){return{canAddMarker:Vue.computed(()=>h.markers.length<h.maxMarkers)}}};var Td=function(){var w=this,E=w._self._c;return E("aside",{staticClass:"k-map-markers-sidebar"},[E("header",{staticClass:"k-section-header"},[E("k-headline",[w._v(" Marqueurs "),E("k-counter",[w._v(w._s(w.markers.length)+"/"+w._s(w.maxMarkers))])],1),E("k-button",{attrs:{icon:"add",size:"xs",variant:"filled",title:"Ajouter un marqueur",disabled:!w.canAddMarker},on:{click:function(L){return w.$emit("add-marker")}}},[w._v(" Ajouter ")])],1),E("div",{staticClass:"k-map-markers-search"},[E("GeocodeSearch",{on:{"select-location":function(L){return w.$emit("select-location",L)}}})],1),E("div",{staticClass:"k-map-markers-list"},[w._l(w.markers,function(L,F){return E("div",{key:L.id,staticClass:"k-map-marker-item",class:{"is-selected":w.selectedMarkerId===L.id},on:{click:function(Q){return w.$emit("select-marker",L.id)}}},[E("span",{staticClass:"k-map-marker-icon"},[w._v(" "+w._s(F+1)+" ")]),E("span",{staticClass:"k-map-marker-text"},[w._v(" "+w._s(L.title||`Marqueur ${F+1}`)+" ")]),E("span",{staticClass:"k-map-marker-options"},[E("k-button",{attrs:{icon:"open",size:"xs",title:"Modifier le marqueur"},on:{click:function(Q){return Q.stopPropagation(),w.$emit("edit-marker",L.id)}}}),E("k-button",{attrs:{icon:"trash",size:"xs",title:"Supprimer le marqueur"},on:{click:function(Q){return Q.stopPropagation(),w.$emit("delete-marker",L.id)}}})],1)])}),w.markers.length===0?E("div",{staticClass:"k-map-markers-empty"},[E("k-icon",{attrs:{type:"map-pin"}}),E("p",{staticClass:"k-map-markers-empty-text"},[w._v("Aucun marqueur")]),E("p",{staticClass:"k-map-markers-empty-info"},[w._v(' Cliquez sur la carte ou sur "Ajouter" pour créer un marqueur ')])],1):w._e()],2)])},Id=[],Ad=No(Sd,Td,Id,!1,null,"6f63259e");const kd=Ad.exports;function Cd(h){const w=Vue.ref([]),E=Vue.ref(!1),L=Vue.ref(null),F=()=>{if(window.panel&&window.panel.csrf)return window.panel.csrf;const W=document.querySelector('meta[name="csrf"]');return W&&W.content?W.content:window.csrf?window.csrf:(console.warn("CSRF token not found"),"")};async function Q(){E.value=!0,L.value=null;try{const Se=await(await fetch(`/api/map-editor/pages/${h}/markers`,{method:"GET",headers:{"Content-Type":"application/json"}})).json();if(Se.status==="error")throw new Error(Se.message||"Failed to fetch markers");return w.value=Se.data.markers||[],w.value}catch(W){throw L.value=W.message,console.error("Error fetching markers:",W),W}finally{E.value=!1}}async function K(W){E.value=!0,L.value=null;try{const de=await(await fetch(`/api/map-editor/pages/${h}/markers`,{method:"POST",headers:{"Content-Type":"application/json","X-CSRF":F()},body:JSON.stringify({position:W})})).json();if(de.status==="error")throw new Error(de.message||"Failed to create marker");const ge=de.data.marker;return w.value.push(ge),ge}catch(Se){throw L.value=Se.message,console.error("Error creating marker:",Se),Se}finally{E.value=!1}}async function l(W,Se){E.value=!0,L.value=null;try{const ge=await(await fetch(`/api/map-editor/pages/${h}/markers/${W}`,{method:"PATCH",headers:{"Content-Type":"application/json","X-CSRF":F()},body:JSON.stringify({position:Se})})).json();if(ge.status==="error")throw new Error(ge.message||"Failed to update marker position");const ve=w.value.findIndex($e=>$e.id===W);return ve!==-1&&(w.value[ve]=ge.data.marker),ge.data.marker}catch(de){throw L.value=de.message,console.error("Error updating marker position:",de),de}finally{E.value=!1}}async function le(W){E.value=!0,L.value=null;try{const de=await(await fetch(`/api/map-editor/pages/${h}/markers/${W}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-CSRF":F()}})).json();if(de.status==="error")throw new Error(de.message||"Failed to delete marker");const ge=w.value.findIndex(ve=>ve.id===W);return ge!==-1&&w.value.splice(ge,1),!0}catch(Se){throw L.value=Se.message,console.error("Error deleting marker:",Se),Se}finally{E.value=!1}}return{markers:w,loading:E,error:L,fetchMarkers:Q,createMarker:K,updateMarkerPosition:l,deleteMarker:le}}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function wu(h){return typeof h>"u"||h===null}function Ed(h){return typeof h=="object"&&h!==null}function Md(h){return Array.isArray(h)?h:wu(h)?[]:[h]}function Pd(h,w){var E,L,F,Q;if(w)for(Q=Object.keys(w),E=0,L=Q.length;E<L;E+=1)F=Q[E],h[F]=w[F];return h}function zd(h,w){var E="",L;for(L=0;L<w;L+=1)E+=h;return E}function Dd(h){return h===0&&Number.NEGATIVE_INFINITY===1/h}var Ld=wu,Fd=Ed,Rd=Md,Bd=zd,Od=Dd,Nd=Pd,ci={isNothing:Ld,isObject:Fd,toArray:Rd,repeat:Bd,isNegativeZero:Od,extend:Nd};function Su(h,w){var E="",L=h.reason||"(unknown reason)";return h.mark?(h.mark.name&&(E+='in "'+h.mark.name+'" '),E+="("+(h.mark.line+1)+":"+(h.mark.column+1)+")",!w&&h.mark.snippet&&(E+=`
`+h.mark.snippet),L+" "+E):L}function As(h,w){Error.call(this),this.name="YAMLException",this.reason=h,this.mark=w,this.message=Su(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}As.prototype=Object.create(Error.prototype),As.prototype.constructor=As,As.prototype.toString=function(w){return this.name+": "+Su(this,w)};var $i=As;function Ql(h,w,E,L,F){var Q="",K="",l=Math.floor(F/2)-1;return L-w>l&&(Q=" ... ",w=L-l+Q.length),E-L>l&&(K=" ...",E=L+l-K.length),{str:Q+h.slice(w,E).replace(/\t/g,"→")+K,pos:L-w+Q.length}}function ec(h,w){return ci.repeat(" ",w-h.length)+h}function Vd(h,w){if(w=Object.create(w||null),!h.buffer)return null;w.maxLength||(w.maxLength=79),typeof w.indent!="number"&&(w.indent=1),typeof w.linesBefore!="number"&&(w.linesBefore=3),typeof w.linesAfter!="number"&&(w.linesAfter=2);for(var E=/\r?\n|\r|\0/g,L=[0],F=[],Q,K=-1;Q=E.exec(h.buffer);)F.push(Q.index),L.push(Q.index+Q[0].length),h.position<=Q.index&&K<0&&(K=L.length-2);K<0&&(K=L.length-1);var l="",le,W,Se=Math.min(h.line+w.linesAfter,F.length).toString().length,de=w.maxLength-(w.indent+Se+3);for(le=1;le<=w.linesBefore&&!(K-le<0);le++)W=Ql(h.buffer,L[K-le],F[K-le],h.position-(L[K]-L[K-le]),de),l=ci.repeat(" ",w.indent)+ec((h.line-le+1).toString(),Se)+" | "+W.str+`
`+l;for(W=Ql(h.buffer,L[K],F[K],h.position,de),l+=ci.repeat(" ",w.indent)+ec((h.line+1).toString(),Se)+" | "+W.str+`
`,l+=ci.repeat("-",w.indent+Se+3+W.pos)+`^
`,le=1;le<=w.linesAfter&&!(K+le>=F.length);le++)W=Ql(h.buffer,L[K+le],F[K+le],h.position-(L[K]-L[K+le]),de),l+=ci.repeat(" ",w.indent)+ec((h.line+le+1).toString(),Se)+" | "+W.str+`
`;return l.replace(/\n$/,"")}var Ud=Vd,$d=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],jd=["scalar","sequence","mapping"];function qd(h){var w={};return h!==null&&Object.keys(h).forEach(function(E){h[E].forEach(function(L){w[String(L)]=E})}),w}function Zd(h,w){if(w=w||{},Object.keys(w).forEach(function(E){if($d.indexOf(E)===-1)throw new $i('Unknown option "'+E+'" is met in definition of "'+h+'" YAML type.')}),this.options=w,this.tag=h,this.kind=w.kind||null,this.resolve=w.resolve||function(){return!0},this.construct=w.construct||function(E){return E},this.instanceOf=w.instanceOf||null,this.predicate=w.predicate||null,this.represent=w.represent||null,this.representName=w.representName||null,this.defaultStyle=w.defaultStyle||null,this.multi=w.multi||!1,this.styleAliases=qd(w.styleAliases||null),jd.indexOf(this.kind)===-1)throw new $i('Unknown kind "'+this.kind+'" is specified for "'+h+'" YAML type.')}var bi=Zd;function Tu(h,w){var E=[];return h[w].forEach(function(L){var F=E.length;E.forEach(function(Q,K){Q.tag===L.tag&&Q.kind===L.kind&&Q.multi===L.multi&&(F=K)}),E[F]=L}),E}function Gd(){var h={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},w,E;function L(F){F.multi?(h.multi[F.kind].push(F),h.multi.fallback.push(F)):h[F.kind][F.tag]=h.fallback[F.tag]=F}for(w=0,E=arguments.length;w<E;w+=1)arguments[w].forEach(L);return h}function tc(h){return this.extend(h)}tc.prototype.extend=function(w){var E=[],L=[];if(w instanceof bi)L.push(w);else if(Array.isArray(w))L=L.concat(w);else if(w&&(Array.isArray(w.implicit)||Array.isArray(w.explicit)))w.implicit&&(E=E.concat(w.implicit)),w.explicit&&(L=L.concat(w.explicit));else throw new $i("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");E.forEach(function(Q){if(!(Q instanceof bi))throw new $i("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(Q.loadKind&&Q.loadKind!=="scalar")throw new $i("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(Q.multi)throw new $i("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),L.forEach(function(Q){if(!(Q instanceof bi))throw new $i("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var F=Object.create(tc.prototype);return F.implicit=(this.implicit||[]).concat(E),F.explicit=(this.explicit||[]).concat(L),F.compiledImplicit=Tu(F,"implicit"),F.compiledExplicit=Tu(F,"explicit"),F.compiledTypeMap=Gd(F.compiledImplicit,F.compiledExplicit),F};var Iu=tc,Au=new bi("tag:yaml.org,2002:str",{kind:"scalar",construct:function(h){return h!==null?h:""}}),ku=new bi("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(h){return h!==null?h:[]}}),Cu=new bi("tag:yaml.org,2002:map",{kind:"mapping",construct:function(h){return h!==null?h:{}}}),Eu=new Iu({explicit:[Au,ku,Cu]});function Hd(h){if(h===null)return!0;var w=h.length;return w===1&&h==="~"||w===4&&(h==="null"||h==="Null"||h==="NULL")}function Wd(){return null}function Xd(h){return h===null}var Mu=new bi("tag:yaml.org,2002:null",{kind:"scalar",resolve:Hd,construct:Wd,predicate:Xd,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function Kd(h){if(h===null)return!1;var w=h.length;return w===4&&(h==="true"||h==="True"||h==="TRUE")||w===5&&(h==="false"||h==="False"||h==="FALSE")}function Yd(h){return h==="true"||h==="True"||h==="TRUE"}function Jd(h){return Object.prototype.toString.call(h)==="[object Boolean]"}var Pu=new bi("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Kd,construct:Yd,predicate:Jd,represent:{lowercase:function(h){return h?"true":"false"},uppercase:function(h){return h?"TRUE":"FALSE"},camelcase:function(h){return h?"True":"False"}},defaultStyle:"lowercase"});function Qd(h){return 48<=h&&h<=57||65<=h&&h<=70||97<=h&&h<=102}function ef(h){return 48<=h&&h<=55}function tf(h){return 48<=h&&h<=57}function rf(h){if(h===null)return!1;var w=h.length,E=0,L=!1,F;if(!w)return!1;if(F=h[E],(F==="-"||F==="+")&&(F=h[++E]),F==="0"){if(E+1===w)return!0;if(F=h[++E],F==="b"){for(E++;E<w;E++)if(F=h[E],F!=="_"){if(F!=="0"&&F!=="1")return!1;L=!0}return L&&F!=="_"}if(F==="x"){for(E++;E<w;E++)if(F=h[E],F!=="_"){if(!Qd(h.charCodeAt(E)))return!1;L=!0}return L&&F!=="_"}if(F==="o"){for(E++;E<w;E++)if(F=h[E],F!=="_"){if(!ef(h.charCodeAt(E)))return!1;L=!0}return L&&F!=="_"}}if(F==="_")return!1;for(;E<w;E++)if(F=h[E],F!=="_"){if(!tf(h.charCodeAt(E)))return!1;L=!0}return!(!L||F==="_")}function nf(h){var w=h,E=1,L;if(w.indexOf("_")!==-1&&(w=w.replace(/_/g,"")),L=w[0],(L==="-"||L==="+")&&(L==="-"&&(E=-1),w=w.slice(1),L=w[0]),w==="0")return 0;if(L==="0"){if(w[1]==="b")return E*parseInt(w.slice(2),2);if(w[1]==="x")return E*parseInt(w.slice(2),16);if(w[1]==="o")return E*parseInt(w.slice(2),8)}return E*parseInt(w,10)}function af(h){return Object.prototype.toString.call(h)==="[object Number]"&&h%1===0&&!ci.isNegativeZero(h)}var zu=new bi("tag:yaml.org,2002:int",{kind:"scalar",resolve:rf,construct:nf,predicate:af,represent:{binary:function(h){return h>=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),sf=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function of(h){return!(h===null||!sf.test(h)||h[h.length-1]==="_")}function lf(h){var w,E;return w=h.replace(/_/g,"").toLowerCase(),E=w[0]==="-"?-1:1,"+-".indexOf(w[0])>=0&&(w=w.slice(1)),w===".inf"?E===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:w===".nan"?NaN:E*parseFloat(w,10)}var cf=/^[-+]?[0-9]+e/;function uf(h,w){var E;if(isNaN(h))switch(w){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(w){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(w){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(ci.isNegativeZero(h))return"-0.0";return E=h.toString(10),cf.test(E)?E.replace("e",".e"):E}function hf(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||ci.isNegativeZero(h))}var Du=new bi("tag:yaml.org,2002:float",{kind:"scalar",resolve:of,construct:lf,predicate:hf,represent:uf,defaultStyle:"lowercase"}),Lu=Eu.extend({implicit:[Mu,Pu,zu,Du]}),Fu=Lu,Ru=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Bu=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function pf(h){return h===null?!1:Ru.exec(h)!==null||Bu.exec(h)!==null}function df(h){var w,E,L,F,Q,K,l,le=0,W=null,Se,de,ge;if(w=Ru.exec(h),w===null&&(w=Bu.exec(h)),w===null)throw new Error("Date resolve error");if(E=+w[1],L=+w[2]-1,F=+w[3],!w[4])return new Date(Date.UTC(E,L,F));if(Q=+w[4],K=+w[5],l=+w[6],w[7]){for(le=w[7].slice(0,3);le.length<3;)le+="0";le=+le}return w[9]&&(Se=+w[10],de=+(w[11]||0),W=(Se*60+de)*6e4,w[9]==="-"&&(W=-W)),ge=new Date(Date.UTC(E,L,F,Q,K,l,le)),W&&ge.setTime(ge.getTime()-W),ge}function ff(h){return h.toISOString()}var Ou=new bi("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:pf,construct:df,instanceOf:Date,represent:ff});function mf(h){return h==="<<"||h===null}var Nu=new bi("tag:yaml.org,2002:merge",{kind:"scalar",resolve:mf}),ic=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
\r`;function gf(h){if(h===null)return!1;var w,E,L=0,F=h.length,Q=ic;for(E=0;E<F;E++)if(w=Q.indexOf(h.charAt(E)),!(w>64)){if(w<0)return!1;L+=6}return L%8===0}function _f(h){var w,E,L=h.replace(/[\r\n=]/g,""),F=L.length,Q=ic,K=0,l=[];for(w=0;w<F;w++)w%4===0&&w&&(l.push(K>>16&255),l.push(K>>8&255),l.push(K&255)),K=K<<6|Q.indexOf(L.charAt(w));return E=F%4*6,E===0?(l.push(K>>16&255),l.push(K>>8&255),l.push(K&255)):E===18?(l.push(K>>10&255),l.push(K>>2&255)):E===12&&l.push(K>>4&255),new Uint8Array(l)}function yf(h){var w="",E=0,L,F,Q=h.length,K=ic;for(L=0;L<Q;L++)L%3===0&&L&&(w+=K[E>>18&63],w+=K[E>>12&63],w+=K[E>>6&63],w+=K[E&63]),E=(E<<8)+h[L];return F=Q%3,F===0?(w+=K[E>>18&63],w+=K[E>>12&63],w+=K[E>>6&63],w+=K[E&63]):F===2?(w+=K[E>>10&63],w+=K[E>>4&63],w+=K[E<<2&63],w+=K[64]):F===1&&(w+=K[E>>2&63],w+=K[E<<4&63],w+=K[64],w+=K[64]),w}function xf(h){return Object.prototype.toString.call(h)==="[object Uint8Array]"}var Vu=new bi("tag:yaml.org,2002:binary",{kind:"scalar",resolve:gf,construct:_f,predicate:xf,represent:yf}),vf=Object.prototype.hasOwnProperty,bf=Object.prototype.toString;function wf(h){if(h===null)return!0;var w=[],E,L,F,Q,K,l=h;for(E=0,L=l.length;E<L;E+=1){if(F=l[E],K=!1,bf.call(F)!=="[object Object]")return!1;for(Q in F)if(vf.call(F,Q))if(!K)K=!0;else return!1;if(!K)return!1;if(w.indexOf(Q)===-1)w.push(Q);else return!1}return!0}function Sf(h){return h!==null?h:[]}var Uu=new bi("tag:yaml.org,2002:omap",{kind:"sequence",resolve:wf,construct:Sf}),Tf=Object.prototype.toString;function If(h){if(h===null)return!0;var w,E,L,F,Q,K=h;for(Q=new Array(K.length),w=0,E=K.length;w<E;w+=1){if(L=K[w],Tf.call(L)!=="[object Object]"||(F=Object.keys(L),F.length!==1))return!1;Q[w]=[F[0],L[F[0]]]}return!0}function Af(h){if(h===null)return[];var w,E,L,F,Q,K=h;for(Q=new Array(K.length),w=0,E=K.length;w<E;w+=1)L=K[w],F=Object.keys(L),Q[w]=[F[0],L[F[0]]];return Q}var $u=new bi("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:If,construct:Af}),kf=Object.prototype.hasOwnProperty;function Cf(h){if(h===null)return!0;var w,E=h;for(w in E)if(kf.call(E,w)&&E[w]!==null)return!1;return!0}function Ef(h){return h!==null?h:{}}var ju=new bi("tag:yaml.org,2002:set",{kind:"mapping",resolve:Cf,construct:Ef}),rc=Fu.extend({implicit:[Ou,Nu],explicit:[Vu,Uu,$u,ju]}),Ln=Object.prototype.hasOwnProperty,Vo=1,qu=2,Zu=3,Uo=4,nc=1,Mf=2,Gu=3,Pf=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,zf=/[\x85\u2028\u2029]/,Df=/[,\[\]\{\}]/,Hu=/^(?:!|!!|![a-z\-]+!)$/i,Wu=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Xu(h){return Object.prototype.toString.call(h)}function Gr(h){return h===10||h===13}function oa(h){return h===9||h===32}function ir(h){return h===9||h===32||h===10||h===13}function Da(h){return h===44||h===91||h===93||h===123||h===125}function Lf(h){var w;return 48<=h&&h<=57?h-48:(w=h|32,97<=w&&w<=102?w-97+10:-1)}function Ff(h){return h===120?2:h===117?4:h===85?8:0}function Rf(h){return 48<=h&&h<=57?h-48:-1}function Ku(h){return h===48?"\0":h===97?"\x07":h===98?"\b":h===116||h===9?" ":h===110?`
`:h===118?"\v":h===102?"\f":h===114?"\r":h===101?"\x1B":h===32?" ":h===34?'"':h===47?"/":h===92?"\\":h===78?"…":h===95?" ":h===76?"\u2028":h===80?"\u2029":""}function Bf(h){return h<=65535?String.fromCharCode(h):String.fromCharCode((h-65536>>10)+55296,(h-65536&1023)+56320)}function Yu(h,w,E){w==="__proto__"?Object.defineProperty(h,w,{configurable:!0,enumerable:!0,writable:!0,value:E}):h[w]=E}for(var Ju=new Array(256),Qu=new Array(256),La=0;La<256;La++)Ju[La]=Ku(La)?1:0,Qu[La]=Ku(La);function Of(h,w){this.input=h,this.filename=w.filename||null,this.schema=w.schema||rc,this.onWarning=w.onWarning||null,this.legacy=w.legacy||!1,this.json=w.json||!1,this.listener=w.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=h.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function eh(h,w){var E={name:h.filename,buffer:h.input.slice(0,-1),position:h.position,line:h.line,column:h.position-h.lineStart};return E.snippet=Ud(E),new $i(w,E)}function Xe(h,w){throw eh(h,w)}function $o(h,w){h.onWarning&&h.onWarning.call(null,eh(h,w))}var th={YAML:function(w,E,L){var F,Q,K;w.version!==null&&Xe(w,"duplication of %YAML directive"),L.length!==1&&Xe(w,"YAML directive accepts exactly one argument"),F=/^([0-9]+)\.([0-9]+)$/.exec(L[0]),F===null&&Xe(w,"ill-formed argument of the YAML directive"),Q=parseInt(F[1],10),K=parseInt(F[2],10),Q!==1&&Xe(w,"unacceptable YAML version of the document"),w.version=L[0],w.checkLineBreaks=K<2,K!==1&&K!==2&&$o(w,"unsupported YAML version of the document")},TAG:function(w,E,L){var F,Q;L.length!==2&&Xe(w,"TAG directive accepts exactly two arguments"),F=L[0],Q=L[1],Hu.test(F)||Xe(w,"ill-formed tag handle (first argument) of the TAG directive"),Ln.call(w.tagMap,F)&&Xe(w,'there is a previously declared suffix for "'+F+'" tag handle'),Wu.test(Q)||Xe(w,"ill-formed tag prefix (second argument) of the TAG directive");try{Q=decodeURIComponent(Q)}catch{Xe(w,"tag prefix is malformed: "+Q)}w.tagMap[F]=Q}};function Fn(h,w,E,L){var F,Q,K,l;if(w<E){if(l=h.input.slice(w,E),L)for(F=0,Q=l.length;F<Q;F+=1)K=l.charCodeAt(F),K===9||32<=K&&K<=1114111||Xe(h,"expected valid JSON character");else Pf.test(l)&&Xe(h,"the stream contains non-printable characters");h.result+=l}}function ih(h,w,E,L){var F,Q,K,l;for(ci.isObject(E)||Xe(h,"cannot merge mappings; the provided source object is unacceptable"),F=Object.keys(E),K=0,l=F.length;K<l;K+=1)Q=F[K],Ln.call(w,Q)||(Yu(w,Q,E[Q]),L[Q]=!0)}function Fa(h,w,E,L,F,Q,K,l,le){var W,Se;if(Array.isArray(F))for(F=Array.prototype.slice.call(F),W=0,Se=F.length;W<Se;W+=1)Array.isArray(F[W])&&Xe(h,"nested arrays are not supported inside keys"),typeof F=="object"&&Xu(F[W])==="[object Object]"&&(F[W]="[object Object]");if(typeof F=="object"&&Xu(F)==="[object Object]"&&(F="[object Object]"),F=String(F),w===null&&(w={}),L==="tag:yaml.org,2002:merge")if(Array.isArray(Q))for(W=0,Se=Q.length;W<Se;W+=1)ih(h,w,Q[W],E);else ih(h,w,Q,E);else!h.json&&!Ln.call(E,F)&&Ln.call(w,F)&&(h.line=K||h.line,h.lineStart=l||h.lineStart,h.position=le||h.position,Xe(h,"duplicated mapping key")),Yu(w,F,Q),delete E[F];return w}function ac(h){var w;w=h.input.charCodeAt(h.position),w===10?h.position++:w===13?(h.position++,h.input.charCodeAt(h.position)===10&&h.position++):Xe(h,"a line break is expected"),h.line+=1,h.lineStart=h.position,h.firstTabInLine=-1}function li(h,w,E){for(var L=0,F=h.input.charCodeAt(h.position);F!==0;){for(;oa(F);)F===9&&h.firstTabInLine===-1&&(h.firstTabInLine=h.position),F=h.input.charCodeAt(++h.position);if(w&&F===35)do F=h.input.charCodeAt(++h.position);while(F!==10&&F!==13&&F!==0);if(Gr(F))for(ac(h),F=h.input.charCodeAt(h.position),L++,h.lineIndent=0;F===32;)h.lineIndent++,F=h.input.charCodeAt(++h.position);else break}return E!==-1&&L!==0&&h.lineIndent<E&&$o(h,"deficient indentation"),L}function jo(h){var w=h.position,E;return E=h.input.charCodeAt(w),!!((E===45||E===46)&&E===h.input.charCodeAt(w+1)&&E===h.input.charCodeAt(w+2)&&(w+=3,E=h.input.charCodeAt(w),E===0||ir(E)))}function sc(h,w){w===1?h.result+=" ":w>1&&(h.result+=ci.repeat(`
`,w-1))}function Nf(h,w,E){var L,F,Q,K,l,le,W,Se,de=h.kind,ge=h.result,ve;if(ve=h.input.charCodeAt(h.position),ir(ve)||Da(ve)||ve===35||ve===38||ve===42||ve===33||ve===124||ve===62||ve===39||ve===34||ve===37||ve===64||ve===96||(ve===63||ve===45)&&(F=h.input.charCodeAt(h.position+1),ir(F)||E&&Da(F)))return!1;for(h.kind="scalar",h.result="",Q=K=h.position,l=!1;ve!==0;){if(ve===58){if(F=h.input.charCodeAt(h.position+1),ir(F)||E&&Da(F))break}else if(ve===35){if(L=h.input.charCodeAt(h.position-1),ir(L))break}else{if(h.position===h.lineStart&&jo(h)||E&&Da(ve))break;if(Gr(ve))if(le=h.line,W=h.lineStart,Se=h.lineIndent,li(h,!1,-1),h.lineIndent>=w){l=!0,ve=h.input.charCodeAt(h.position);continue}else{h.position=K,h.line=le,h.lineStart=W,h.lineIndent=Se;break}}l&&(Fn(h,Q,K,!1),sc(h,h.line-le),Q=K=h.position,l=!1),oa(ve)||(K=h.position+1),ve=h.input.charCodeAt(++h.position)}return Fn(h,Q,K,!1),h.result?!0:(h.kind=de,h.result=ge,!1)}function Vf(h,w){var E,L,F;if(E=h.input.charCodeAt(h.position),E!==39)return!1;for(h.kind="scalar",h.result="",h.position++,L=F=h.position;(E=h.input.charCodeAt(h.position))!==0;)if(E===39)if(Fn(h,L,h.position,!0),E=h.input.charCodeAt(++h.position),E===39)L=h.position,h.position++,F=h.position;else return!0;else Gr(E)?(Fn(h,L,F,!0),sc(h,li(h,!1,w)),L=F=h.position):h.position===h.lineStart&&jo(h)?Xe(h,"unexpected end of the document within a single quoted scalar"):(h.position++,F=h.position);Xe(h,"unexpected end of the stream within a single quoted scalar")}function Uf(h,w){var E,L,F,Q,K,l;if(l=h.input.charCodeAt(h.position),l!==34)return!1;for(h.kind="scalar",h.result="",h.position++,E=L=h.position;(l=h.input.charCodeAt(h.position))!==0;){if(l===34)return Fn(h,E,h.position,!0),h.position++,!0;if(l===92){if(Fn(h,E,h.position,!0),l=h.input.charCodeAt(++h.position),Gr(l))li(h,!1,w);else if(l<256&&Ju[l])h.result+=Qu[l],h.position++;else if((K=Ff(l))>0){for(F=K,Q=0;F>0;F--)l=h.input.charCodeAt(++h.position),(K=Lf(l))>=0?Q=(Q<<4)+K:Xe(h,"expected hexadecimal character");h.result+=Bf(Q),h.position++}else Xe(h,"unknown escape sequence");E=L=h.position}else Gr(l)?(Fn(h,E,L,!0),sc(h,li(h,!1,w)),E=L=h.position):h.position===h.lineStart&&jo(h)?Xe(h,"unexpected end of the document within a double quoted scalar"):(h.position++,L=h.position)}Xe(h,"unexpected end of the stream within a double quoted scalar")}function $f(h,w){var E=!0,L,F,Q,K=h.tag,l,le=h.anchor,W,Se,de,ge,ve,$e=Object.create(null),Qe,Ke,Ye,st;if(st=h.input.charCodeAt(h.position),st===91)Se=93,ve=!1,l=[];else if(st===123)Se=125,ve=!0,l={};else return!1;for(h.anchor!==null&&(h.anchorMap[h.anchor]=l),st=h.input.charCodeAt(++h.position);st!==0;){if(li(h,!0,w),st=h.input.charCodeAt(h.position),st===Se)return h.position++,h.tag=K,h.anchor=le,h.kind=ve?"mapping":"sequence",h.result=l,!0;E?st===44&&Xe(h,"expected the node content, but found ','"):Xe(h,"missed comma between flow collection entries"),Ke=Qe=Ye=null,de=ge=!1,st===63&&(W=h.input.charCodeAt(h.position+1),ir(W)&&(de=ge=!0,h.position++,li(h,!0,w))),L=h.line,F=h.lineStart,Q=h.position,Ra(h,w,Vo,!1,!0),Ke=h.tag,Qe=h.result,li(h,!0,w),st=h.input.charCodeAt(h.position),(ge||h.line===L)&&st===58&&(de=!0,st=h.input.charCodeAt(++h.position),li(h,!0,w),Ra(h,w,Vo,!1,!0),Ye=h.result),ve?Fa(h,l,$e,Ke,Qe,Ye,L,F,Q):de?l.push(Fa(h,null,$e,Ke,Qe,Ye,L,F,Q)):l.push(Qe),li(h,!0,w),st=h.input.charCodeAt(h.position),st===44?(E=!0,st=h.input.charCodeAt(++h.position)):E=!1}Xe(h,"unexpected end of the stream within a flow collection")}function jf(h,w){var E,L,F=nc,Q=!1,K=!1,l=w,le=0,W=!1,Se,de;if(de=h.input.charCodeAt(h.position),de===124)L=!1;else if(de===62)L=!0;else return!1;for(h.kind="scalar",h.result="";de!==0;)if(de=h.input.charCodeAt(++h.position),de===43||de===45)nc===F?F=de===43?Gu:Mf:Xe(h,"repeat of a chomping mode identifier");else if((Se=Rf(de))>=0)Se===0?Xe(h,"bad explicit indentation width of a block scalar; it cannot be less than one"):K?Xe(h,"repeat of an indentation width identifier"):(l=w+Se-1,K=!0);else break;if(oa(de)){do de=h.input.charCodeAt(++h.position);while(oa(de));if(de===35)do de=h.input.charCodeAt(++h.position);while(!Gr(de)&&de!==0)}for(;de!==0;){for(ac(h),h.lineIndent=0,de=h.input.charCodeAt(h.position);(!K||h.lineIndent<l)&&de===32;)h.lineIndent++,de=h.input.charCodeAt(++h.position);if(!K&&h.lineIndent>l&&(l=h.lineIndent),Gr(de)){le++;continue}if(h.lineIndent<l){F===Gu?h.result+=ci.repeat(`
`,Q?1+le:le):F===nc&&Q&&(h.result+=`
`);break}for(L?oa(de)?(W=!0,h.result+=ci.repeat(`
`,Q?1+le:le)):W?(W=!1,h.result+=ci.repeat(`
`,le+1)):le===0?Q&&(h.result+=" "):h.result+=ci.repeat(`
`,le):h.result+=ci.repeat(`
`,Q?1+le:le),Q=!0,K=!0,le=0,E=h.position;!Gr(de)&&de!==0;)de=h.input.charCodeAt(++h.position);Fn(h,E,h.position,!1)}return!0}function rh(h,w){var E,L=h.tag,F=h.anchor,Q=[],K,l=!1,le;if(h.firstTabInLine!==-1)return!1;for(h.anchor!==null&&(h.anchorMap[h.anchor]=Q),le=h.input.charCodeAt(h.position);le!==0&&(h.firstTabInLine!==-1&&(h.position=h.firstTabInLine,Xe(h,"tab characters must not be used in indentation")),!(le!==45||(K=h.input.charCodeAt(h.position+1),!ir(K))));){if(l=!0,h.position++,li(h,!0,-1)&&h.lineIndent<=w){Q.push(null),le=h.input.charCodeAt(h.position);continue}if(E=h.line,Ra(h,w,Zu,!1,!0),Q.push(h.result),li(h,!0,-1),le=h.input.charCodeAt(h.position),(h.line===E||h.lineIndent>w)&&le!==0)Xe(h,"bad indentation of a sequence entry");else if(h.lineIndent<w)break}return l?(h.tag=L,h.anchor=F,h.kind="sequence",h.result=Q,!0):!1}function qf(h,w,E){var L,F,Q,K,l,le,W=h.tag,Se=h.anchor,de={},ge=Object.create(null),ve=null,$e=null,Qe=null,Ke=!1,Ye=!1,st;if(h.firstTabInLine!==-1)return!1;for(h.anchor!==null&&(h.anchorMap[h.anchor]=de),st=h.input.charCodeAt(h.position);st!==0;){if(!Ke&&h.firstTabInLine!==-1&&(h.position=h.firstTabInLine,Xe(h,"tab characters must not be used in indentation")),L=h.input.charCodeAt(h.position+1),Q=h.line,(st===63||st===58)&&ir(L))st===63?(Ke&&(Fa(h,de,ge,ve,$e,null,K,l,le),ve=$e=Qe=null),Ye=!0,Ke=!0,F=!0):Ke?(Ke=!1,F=!0):Xe(h,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),h.position+=1,st=L;else{if(K=h.line,l=h.lineStart,le=h.position,!Ra(h,E,qu,!1,!0))break;if(h.line===Q){for(st=h.input.charCodeAt(h.position);oa(st);)st=h.input.charCodeAt(++h.position);if(st===58)st=h.input.charCodeAt(++h.position),ir(st)||Xe(h,"a whitespace character is expected after the key-value separator within a block mapping"),Ke&&(Fa(h,de,ge,ve,$e,null,K,l,le),ve=$e=Qe=null),Ye=!0,Ke=!1,F=!1,ve=h.tag,$e=h.result;else if(Ye)Xe(h,"can not read an implicit mapping pair; a colon is missed");else return h.tag=W,h.anchor=Se,!0}else if(Ye)Xe(h,"can not read a block mapping entry; a multiline key may not be an implicit key");else return h.tag=W,h.anchor=Se,!0}if((h.line===Q||h.lineIndent>w)&&(Ke&&(K=h.line,l=h.lineStart,le=h.position),Ra(h,w,Uo,!0,F)&&(Ke?$e=h.result:Qe=h.result),Ke||(Fa(h,de,ge,ve,$e,Qe,K,l,le),ve=$e=Qe=null),li(h,!0,-1),st=h.input.charCodeAt(h.position)),(h.line===Q||h.lineIndent>w)&&st!==0)Xe(h,"bad indentation of a mapping entry");else if(h.lineIndent<w)break}return Ke&&Fa(h,de,ge,ve,$e,null,K,l,le),Ye&&(h.tag=W,h.anchor=Se,h.kind="mapping",h.result=de),Ye}function Zf(h){var w,E=!1,L=!1,F,Q,K;if(K=h.input.charCodeAt(h.position),K!==33)return!1;if(h.tag!==null&&Xe(h,"duplication of a tag property"),K=h.input.charCodeAt(++h.position),K===60?(E=!0,K=h.input.charCodeAt(++h.position)):K===33?(L=!0,F="!!",K=h.input.charCodeAt(++h.position)):F="!",w=h.position,E){do K=h.input.charCodeAt(++h.position);while(K!==0&&K!==62);h.position<h.length?(Q=h.input.slice(w,h.position),K=h.input.charCodeAt(++h.position)):Xe(h,"unexpected end of the stream within a verbatim tag")}else{for(;K!==0&&!ir(K);)K===33&&(L?Xe(h,"tag suffix cannot contain exclamation marks"):(F=h.input.slice(w-1,h.position+1),Hu.test(F)||Xe(h,"named tag handle cannot contain such characters"),L=!0,w=h.position+1)),K=h.input.charCodeAt(++h.position);Q=h.input.slice(w,h.position),Df.test(Q)&&Xe(h,"tag suffix cannot contain flow indicator characters")}Q&&!Wu.test(Q)&&Xe(h,"tag name cannot contain such characters: "+Q);try{Q=decodeURIComponent(Q)}catch{Xe(h,"tag name is malformed: "+Q)}return E?h.tag=Q:Ln.call(h.tagMap,F)?h.tag=h.tagMap[F]+Q:F==="!"?h.tag="!"+Q:F==="!!"?h.tag="tag:yaml.org,2002:"+Q:Xe(h,'undeclared tag handle "'+F+'"'),!0}function Gf(h){var w,E;if(E=h.input.charCodeAt(h.position),E!==38)return!1;for(h.anchor!==null&&Xe(h,"duplication of an anchor property"),E=h.input.charCodeAt(++h.position),w=h.position;E!==0&&!ir(E)&&!Da(E);)E=h.input.charCodeAt(++h.position);return h.position===w&&Xe(h,"name of an anchor node must contain at least one character"),h.anchor=h.input.slice(w,h.position),!0}function Hf(h){var w,E,L;if(L=h.input.charCodeAt(h.position),L!==42)return!1;for(L=h.input.charCodeAt(++h.position),w=h.position;L!==0&&!ir(L)&&!Da(L);)L=h.input.charCodeAt(++h.position);return h.position===w&&Xe(h,"name of an alias node must contain at least one character"),E=h.input.slice(w,h.position),Ln.call(h.anchorMap,E)||Xe(h,'unidentified alias "'+E+'"'),h.result=h.anchorMap[E],li(h,!0,-1),!0}function Ra(h,w,E,L,F){var Q,K,l,le=1,W=!1,Se=!1,de,ge,ve,$e,Qe,Ke;if(h.listener!==null&&h.listener("open",h),h.tag=null,h.anchor=null,h.kind=null,h.result=null,Q=K=l=Uo===E||Zu===E,L&&li(h,!0,-1)&&(W=!0,h.lineIndent>w?le=1:h.lineIndent===w?le=0:h.lineIndent<w&&(le=-1)),le===1)for(;Zf(h)||Gf(h);)li(h,!0,-1)?(W=!0,l=Q,h.lineIndent>w?le=1:h.lineIndent===w?le=0:h.lineIndent<w&&(le=-1)):l=!1;if(l&&(l=W||F),(le===1||Uo===E)&&(Vo===E||qu===E?Qe=w:Qe=w+1,Ke=h.position-h.lineStart,le===1?l&&(rh(h,Ke)||qf(h,Ke,Qe))||$f(h,Qe)?Se=!0:(K&&jf(h,Qe)||Vf(h,Qe)||Uf(h,Qe)?Se=!0:Hf(h)?(Se=!0,(h.tag!==null||h.anchor!==null)&&Xe(h,"alias node should not have any properties")):Nf(h,Qe,Vo===E)&&(Se=!0,h.tag===null&&(h.tag="?")),h.anchor!==null&&(h.anchorMap[h.anchor]=h.result)):le===0&&(Se=l&&rh(h,Ke))),h.tag===null)h.anchor!==null&&(h.anchorMap[h.anchor]=h.result);else if(h.tag==="?"){for(h.result!==null&&h.kind!=="scalar"&&Xe(h,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+h.kind+'"'),de=0,ge=h.implicitTypes.length;de<ge;de+=1)if($e=h.implicitTypes[de],$e.resolve(h.result)){h.result=$e.construct(h.result),h.tag=$e.tag,h.anchor!==null&&(h.anchorMap[h.anchor]=h.result);break}}else if(h.tag!=="!"){if(Ln.call(h.typeMap[h.kind||"fallback"],h.tag))$e=h.typeMap[h.kind||"fallback"][h.tag];else for($e=null,ve=h.typeMap.multi[h.kind||"fallback"],de=0,ge=ve.length;de<ge;de+=1)if(h.tag.slice(0,ve[de].tag.length)===ve[de].tag){$e=ve[de];break}$e||Xe(h,"unknown tag !<"+h.tag+">"),h.result!==null&&$e.kind!==h.kind&&Xe(h,"unacceptable node kind for !<"+h.tag+'> tag; it should be "'+$e.kind+'", not "'+h.kind+'"'),$e.resolve(h.result,h.tag)?(h.result=$e.construct(h.result,h.tag),h.anchor!==null&&(h.anchorMap[h.anchor]=h.result)):Xe(h,"cannot resolve a node with !<"+h.tag+"> explicit tag")}return h.listener!==null&&h.listener("close",h),h.tag!==null||h.anchor!==null||Se}function Wf(h){var w=h.position,E,L,F,Q=!1,K;for(h.version=null,h.checkLineBreaks=h.legacy,h.tagMap=Object.create(null),h.anchorMap=Object.create(null);(K=h.input.charCodeAt(h.position))!==0&&(li(h,!0,-1),K=h.input.charCodeAt(h.position),!(h.lineIndent>0||K!==37));){for(Q=!0,K=h.input.charCodeAt(++h.position),E=h.position;K!==0&&!ir(K);)K=h.input.charCodeAt(++h.position);for(L=h.input.slice(E,h.position),F=[],L.length<1&&Xe(h,"directive name must not be less than one character in length");K!==0;){for(;oa(K);)K=h.input.charCodeAt(++h.position);if(K===35){do K=h.input.charCodeAt(++h.position);while(K!==0&&!Gr(K));break}if(Gr(K))break;for(E=h.position;K!==0&&!ir(K);)K=h.input.charCodeAt(++h.position);F.push(h.input.slice(E,h.position))}K!==0&&ac(h),Ln.call(th,L)?th[L](h,L,F):$o(h,'unknown document directive "'+L+'"')}if(li(h,!0,-1),h.lineIndent===0&&h.input.charCodeAt(h.position)===45&&h.input.charCodeAt(h.position+1)===45&&h.input.charCodeAt(h.position+2)===45?(h.position+=3,li(h,!0,-1)):Q&&Xe(h,"directives end mark is expected"),Ra(h,h.lineIndent-1,Uo,!1,!0),li(h,!0,-1),h.checkLineBreaks&&zf.test(h.input.slice(w,h.position))&&$o(h,"non-ASCII line breaks are interpreted as content"),h.documents.push(h.result),h.position===h.lineStart&&jo(h)){h.input.charCodeAt(h.position)===46&&(h.position+=3,li(h,!0,-1));return}if(h.position<h.length-1)Xe(h,"end of the stream or a document separator is expected");else return}function nh(h,w){h=String(h),w=w||{},h.length!==0&&(h.charCodeAt(h.length-1)!==10&&h.charCodeAt(h.length-1)!==13&&(h+=`
`),h.charCodeAt(0)===65279&&(h=h.slice(1)));var E=new Of(h,w),L=h.indexOf("\0");for(L!==-1&&(E.position=L,Xe(E,"null byte is not allowed in input")),E.input+="\0";E.input.charCodeAt(E.position)===32;)E.lineIndent+=1,E.position+=1;for(;E.position<E.length-1;)Wf(E);return E.documents}function Xf(h,w,E){w!==null&&typeof w=="object"&&typeof E>"u"&&(E=w,w=null);var L=nh(h,E);if(typeof w!="function")return L;for(var F=0,Q=L.length;F<Q;F+=1)w(L[F])}function Kf(h,w){var E=nh(h,w);if(E.length!==0){if(E.length===1)return E[0];throw new $i("expected a single document in the stream, but found more")}}var Yf=Xf,Jf=Kf,ah={loadAll:Yf,load:Jf},sh=Object.prototype.toString,oh=Object.prototype.hasOwnProperty,oc=65279,Qf=9,ks=10,em=13,tm=32,im=33,rm=34,lc=35,nm=37,am=38,sm=39,om=42,lh=44,lm=45,qo=58,cm=61,um=62,hm=63,pm=64,ch=91,uh=93,dm=96,hh=123,fm=124,ph=125,Mi={};Mi[0]="\\0",Mi[7]="\\a",Mi[8]="\\b",Mi[9]="\\t",Mi[10]="\\n",Mi[11]="\\v",Mi[12]="\\f",Mi[13]="\\r",Mi[27]="\\e",Mi[34]='\\"',Mi[92]="\\\\",Mi[133]="\\N",Mi[160]="\\_",Mi[8232]="\\L",Mi[8233]="\\P";var mm=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],gm=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function _m(h,w){var E,L,F,Q,K,l,le;if(w===null)return{};for(E={},L=Object.keys(w),F=0,Q=L.length;F<Q;F+=1)K=L[F],l=String(w[K]),K.slice(0,2)==="!!"&&(K="tag:yaml.org,2002:"+K.slice(2)),le=h.compiledTypeMap.fallback[K],le&&oh.call(le.styleAliases,l)&&(l=le.styleAliases[l]),E[K]=l;return E}function ym(h){var w,E,L;if(w=h.toString(16).toUpperCase(),h<=255)E="x",L=2;else if(h<=65535)E="u",L=4;else if(h<=4294967295)E="U",L=8;else throw new $i("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+E+ci.repeat("0",L-w.length)+w}var xm=1,Cs=2;function vm(h){this.schema=h.schema||rc,this.indent=Math.max(1,h.indent||2),this.noArrayIndent=h.noArrayIndent||!1,this.skipInvalid=h.skipInvalid||!1,this.flowLevel=ci.isNothing(h.flowLevel)?-1:h.flowLevel,this.styleMap=_m(this.schema,h.styles||null),this.sortKeys=h.sortKeys||!1,this.lineWidth=h.lineWidth||80,this.noRefs=h.noRefs||!1,this.noCompatMode=h.noCompatMode||!1,this.condenseFlow=h.condenseFlow||!1,this.quotingType=h.quotingType==='"'?Cs:xm,this.forceQuotes=h.forceQuotes||!1,this.replacer=typeof h.replacer=="function"?h.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function dh(h,w){for(var E=ci.repeat(" ",w),L=0,F=-1,Q="",K,l=h.length;L<l;)F=h.indexOf(`
`,L),F===-1?(K=h.slice(L),L=l):(K=h.slice(L,F+1),L=F+1),K.length&&K!==`
`&&(Q+=E),Q+=K;return Q}function cc(h,w){return`
`+ci.repeat(" ",h.indent*w)}function bm(h,w){var E,L,F;for(E=0,L=h.implicitTypes.length;E<L;E+=1)if(F=h.implicitTypes[E],F.resolve(w))return!0;return!1}function Zo(h){return h===tm||h===Qf}function Es(h){return 32<=h&&h<=126||161<=h&&h<=55295&&h!==8232&&h!==8233||57344<=h&&h<=65533&&h!==oc||65536<=h&&h<=1114111}function fh(h){return Es(h)&&h!==oc&&h!==em&&h!==ks}function mh(h,w,E){var L=fh(h),F=L&&!Zo(h);return(E?L:L&&h!==lh&&h!==ch&&h!==uh&&h!==hh&&h!==ph)&&h!==lc&&!(w===qo&&!F)||fh(w)&&!Zo(w)&&h===lc||w===qo&&F}function wm(h){return Es(h)&&h!==oc&&!Zo(h)&&h!==lm&&h!==hm&&h!==qo&&h!==lh&&h!==ch&&h!==uh&&h!==hh&&h!==ph&&h!==lc&&h!==am&&h!==om&&h!==im&&h!==fm&&h!==cm&&h!==um&&h!==sm&&h!==rm&&h!==nm&&h!==pm&&h!==dm}function Sm(h){return!Zo(h)&&h!==qo}function Ms(h,w){var E=h.charCodeAt(w),L;return E>=55296&&E<=56319&&w+1<h.length&&(L=h.charCodeAt(w+1),L>=56320&&L<=57343)?(E-55296)*1024+L-56320+65536:E}function gh(h){var w=/^\n* /;return w.test(h)}var _h=1,uc=2,yh=3,xh=4,Ba=5;function Tm(h,w,E,L,F,Q,K,l){var le,W=0,Se=null,de=!1,ge=!1,ve=L!==-1,$e=-1,Qe=wm(Ms(h,0))&&Sm(Ms(h,h.length-1));if(w||K)for(le=0;le<h.length;W>=65536?le+=2:le++){if(W=Ms(h,le),!Es(W))return Ba;Qe=Qe&&mh(W,Se,l),Se=W}else{for(le=0;le<h.length;W>=65536?le+=2:le++){if(W=Ms(h,le),W===ks)de=!0,ve&&(ge=ge||le-$e-1>L&&h[$e+1]!==" ",$e=le);else if(!Es(W))return Ba;Qe=Qe&&mh(W,Se,l),Se=W}ge=ge||ve&&le-$e-1>L&&h[$e+1]!==" "}return!de&&!ge?Qe&&!K&&!F(h)?_h:Q===Cs?Ba:uc:E>9&&gh(h)?Ba:K?Q===Cs?Ba:uc:ge?xh:yh}function Im(h,w,E,L,F){h.dump=(function(){if(w.length===0)return h.quotingType===Cs?'""':"''";if(!h.noCompatMode&&(mm.indexOf(w)!==-1||gm.test(w)))return h.quotingType===Cs?'"'+w+'"':"'"+w+"'";var Q=h.indent*Math.max(1,E),K=h.lineWidth===-1?-1:Math.max(Math.min(h.lineWidth,40),h.lineWidth-Q),l=L||h.flowLevel>-1&&E>=h.flowLevel;function le(W){return bm(h,W)}switch(Tm(w,l,h.indent,K,le,h.quotingType,h.forceQuotes&&!L,F)){case _h:return w;case uc:return"'"+w.replace(/'/g,"''")+"'";case yh:return"|"+vh(w,h.indent)+bh(dh(w,Q));case xh:return">"+vh(w,h.indent)+bh(dh(Am(w,K),Q));case Ba:return'"'+km(w)+'"';default:throw new $i("impossible error: invalid scalar style")}})()}function vh(h,w){var E=gh(h)?String(w):"",L=h[h.length-1]===`
`,F=L&&(h[h.length-2]===`
`||h===`
`),Q=F?"+":L?"":"-";return E+Q+`
`}function bh(h){return h[h.length-1]===`
`?h.slice(0,-1):h}function Am(h,w){for(var E=/(\n+)([^\n]*)/g,L=(function(){var W=h.indexOf(`
`);return W=W!==-1?W:h.length,E.lastIndex=W,wh(h.slice(0,W),w)})(),F=h[0]===`
`||h[0]===" ",Q,K;K=E.exec(h);){var l=K[1],le=K[2];Q=le[0]===" ",L+=l+(!F&&!Q&&le!==""?`
`:"")+wh(le,w),F=Q}return L}function wh(h,w){if(h===""||h[0]===" ")return h;for(var E=/ [^ ]/g,L,F=0,Q,K=0,l=0,le="";L=E.exec(h);)l=L.index,l-F>w&&(Q=K>F?K:l,le+=`
`+h.slice(F,Q),F=Q+1),K=l;return le+=`
`,h.length-F>w&&K>F?le+=h.slice(F,K)+`
`+h.slice(K+1):le+=h.slice(F),le.slice(1)}function km(h){for(var w="",E=0,L,F=0;F<h.length;E>=65536?F+=2:F++)E=Ms(h,F),L=Mi[E],!L&&Es(E)?(w+=h[F],E>=65536&&(w+=h[F+1])):w+=L||ym(E);return w}function Cm(h,w,E){var L="",F=h.tag,Q,K,l;for(Q=0,K=E.length;Q<K;Q+=1)l=E[Q],h.replacer&&(l=h.replacer.call(E,String(Q),l)),(un(h,w,l,!1,!1)||typeof l>"u"&&un(h,w,null,!1,!1))&&(L!==""&&(L+=","+(h.condenseFlow?"":" ")),L+=h.dump);h.tag=F,h.dump="["+L+"]"}function Sh(h,w,E,L){var F="",Q=h.tag,K,l,le;for(K=0,l=E.length;K<l;K+=1)le=E[K],h.replacer&&(le=h.replacer.call(E,String(K),le)),(un(h,w+1,le,!0,!0,!1,!0)||typeof le>"u"&&un(h,w+1,null,!0,!0,!1,!0))&&((!L||F!=="")&&(F+=cc(h,w)),h.dump&&ks===h.dump.charCodeAt(0)?F+="-":F+="- ",F+=h.dump);h.tag=Q,h.dump=F||"[]"}function Em(h,w,E){var L="",F=h.tag,Q=Object.keys(E),K,l,le,W,Se;for(K=0,l=Q.length;K<l;K+=1)Se="",L!==""&&(Se+=", "),h.condenseFlow&&(Se+='"'),le=Q[K],W=E[le],h.replacer&&(W=h.replacer.call(E,le,W)),un(h,w,le,!1,!1)&&(h.dump.length>1024&&(Se+="? "),Se+=h.dump+(h.condenseFlow?'"':"")+":"+(h.condenseFlow?"":" "),un(h,w,W,!1,!1)&&(Se+=h.dump,L+=Se));h.tag=F,h.dump="{"+L+"}"}function Mm(h,w,E,L){var F="",Q=h.tag,K=Object.keys(E),l,le,W,Se,de,ge;if(h.sortKeys===!0)K.sort();else if(typeof h.sortKeys=="function")K.sort(h.sortKeys);else if(h.sortKeys)throw new $i("sortKeys must be a boolean or a function");for(l=0,le=K.length;l<le;l+=1)ge="",(!L||F!=="")&&(ge+=cc(h,w)),W=K[l],Se=E[W],h.replacer&&(Se=h.replacer.call(E,W,Se)),un(h,w+1,W,!0,!0,!0)&&(de=h.tag!==null&&h.tag!=="?"||h.dump&&h.dump.length>1024,de&&(h.dump&&ks===h.dump.charCodeAt(0)?ge+="?":ge+="? "),ge+=h.dump,de&&(ge+=cc(h,w)),un(h,w+1,Se,!0,de)&&(h.dump&&ks===h.dump.charCodeAt(0)?ge+=":":ge+=": ",ge+=h.dump,F+=ge));h.tag=Q,h.dump=F||"{}"}function Th(h,w,E){var L,F,Q,K,l,le;for(F=E?h.explicitTypes:h.implicitTypes,Q=0,K=F.length;Q<K;Q+=1)if(l=F[Q],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof w=="object"&&w instanceof l.instanceOf)&&(!l.predicate||l.predicate(w))){if(E?l.multi&&l.representName?h.tag=l.representName(w):h.tag=l.tag:h.tag="?",l.represent){if(le=h.styleMap[l.tag]||l.defaultStyle,sh.call(l.represent)==="[object Function]")L=l.represent(w,le);else if(oh.call(l.represent,le))L=l.represent[le](w,le);else throw new $i("!<"+l.tag+'> tag resolver accepts not "'+le+'" style');h.dump=L}return!0}return!1}function un(h,w,E,L,F,Q,K){h.tag=null,h.dump=E,Th(h,E,!1)||Th(h,E,!0);var l=sh.call(h.dump),le=L,W;L&&(L=h.flowLevel<0||h.flowLevel>w);var Se=l==="[object Object]"||l==="[object Array]",de,ge;if(Se&&(de=h.duplicates.indexOf(E),ge=de!==-1),(h.tag!==null&&h.tag!=="?"||ge||h.indent!==2&&w>0)&&(F=!1),ge&&h.usedDuplicates[de])h.dump="*ref_"+de;else{if(Se&&ge&&!h.usedDuplicates[de]&&(h.usedDuplicates[de]=!0),l==="[object Object]")L&&Object.keys(h.dump).length!==0?(Mm(h,w,h.dump,F),ge&&(h.dump="&ref_"+de+h.dump)):(Em(h,w,h.dump),ge&&(h.dump="&ref_"+de+" "+h.dump));else if(l==="[object Array]")L&&h.dump.length!==0?(h.noArrayIndent&&!K&&w>0?Sh(h,w-1,h.dump,F):Sh(h,w,h.dump,F),ge&&(h.dump="&ref_"+de+h.dump)):(Cm(h,w,h.dump),ge&&(h.dump="&ref_"+de+" "+h.dump));else if(l==="[object String]")h.tag!=="?"&&Im(h,h.dump,w,Q,le);else{if(l==="[object Undefined]")return!1;if(h.skipInvalid)return!1;throw new $i("unacceptable kind of an object to dump "+l)}h.tag!==null&&h.tag!=="?"&&(W=encodeURI(h.tag[0]==="!"?h.tag.slice(1):h.tag).replace(/!/g,"%21"),h.tag[0]==="!"?W="!"+W:W.slice(0,18)==="tag:yaml.org,2002:"?W="!!"+W.slice(18):W="!<"+W+">",h.dump=W+" "+h.dump)}return!0}function Pm(h,w){var E=[],L=[],F,Q;for(hc(h,E,L),F=0,Q=L.length;F<Q;F+=1)w.duplicates.push(E[L[F]]);w.usedDuplicates=new Array(Q)}function hc(h,w,E){var L,F,Q;if(h!==null&&typeof h=="object")if(F=w.indexOf(h),F!==-1)E.indexOf(F)===-1&&E.push(F);else if(w.push(h),Array.isArray(h))for(F=0,Q=h.length;F<Q;F+=1)hc(h[F],w,E);else for(L=Object.keys(h),F=0,Q=L.length;F<Q;F+=1)hc(h[L[F]],w,E)}function zm(h,w){w=w||{};var E=new vm(w);E.noRefs||Pm(h,E);var L=h;return E.replacer&&(L=E.replacer.call({"":L},"",L)),un(E,0,L,!0,!0)?E.dump+`
`:""}var Dm=zm,Lm={dump:Dm};function pc(h,w){return function(){throw new Error("Function yaml."+h+" is removed in js-yaml 4. Use yaml."+w+" instead, which is now safe by default.")}}var Fm=bi,Rm=Iu,Bm=Eu,Om=Lu,Nm=Fu,Vm=rc,Um=ah.load,$m=ah.loadAll,jm=Lm.dump,qm=$i,Zm={binary:Vu,float:Du,map:Cu,null:Mu,pairs:$u,set:ju,timestamp:Ou,bool:Pu,int:zu,merge:Nu,omap:Uu,seq:ku,str:Au},Gm=pc("safeLoad","load"),Hm=pc("safeLoadAll","loadAll"),Wm=pc("safeDump","dump"),Ih={Type:Fm,Schema:Rm,FAILSAFE_SCHEMA:Bm,JSON_SCHEMA:Om,CORE_SCHEMA:Nm,DEFAULT_SCHEMA:Vm,load:Um,loadAll:$m,dump:jm,YAMLException:qm,types:Zm,safeLoad:Gm,safeLoadAll:Hm,safeDump:Wm};function Xm(h={}){const{defaultCenter:w={lat:43.836699,lon:4.360054},defaultZoom:E=13,onSave:L=()=>{}}=h,F=Vue.ref({...w}),Q=Vue.ref(E),K=Vue.ref(null);Vue.onBeforeUnmount(()=>{K.value&&clearTimeout(K.value)});function l(Se){if(!Se||Se.trim()==="")return null;try{const de=Ih.load(Se);if(de)return de.center&&(F.value={lat:de.center.lat,lon:de.center.lon}),de.zoom!==void 0&&(Q.value=de.zoom),de}catch(de){return console.error("Error loading map data:",de),null}return null}function le(){const Se={background:{type:"osm"},center:{lat:F.value.lat,lon:F.value.lon},zoom:Q.value},de=Ih.dump(Se,{indent:2,lineWidth:-1,noRefs:!0});return L(de),de}function W(Se=300){K.value&&clearTimeout(K.value),K.value=setTimeout(()=>{le()},Se)}return{center:F,zoom:Q,loadMapData:l,saveMapData:le,debouncedSave:W}}const Km={components:{MapPreview:md,MarkerList:kd},props:{value:String,name:String,label:String,help:String,disabled:Boolean,defaultCenter:{type:Array,default:()=>[43.836699,4.360054]},defaultZoom:{type:Number,default:13},maxMarkers:{type:Number,default:50},mode:{type:String,default:"multi",validator:h=>["multi","single"].includes(h)},latitude:{type:[Number,String],default:null},longitude:{type:[Number,String],default:null}},setup(h,{emit:w}){const E=Vue.ref(!1),L=Vue.ref(null),F=Vue.ref(null),Q=Vue.computed(()=>{var nt;if(h.mode==="single")return null;const Ve=window.location.pathname.match(/\/panel\/pages\/(.+)/);if(Ve)return Ve[1].replace(/\+/g,"/");const it=(nt=h.name)==null?void 0:nt.match(/pages\/([^/]+)/);return it?it[1].replace(/\+/g,"/"):(console.warn("Could not extract page ID, using default"),"map/carte")}),K=h.mode==="multi"?Cd(Q.value):{markers:Vue.ref([]),loading:Vue.ref(!1),error:Vue.ref(null)},{center:l,zoom:le,loadMapData:W,debouncedSave:Se}=Xm({defaultCenter:{lat:h.defaultCenter[0],lon:h.defaultCenter[1]},defaultZoom:h.defaultZoom,onSave:Ve=>w("input",Ve)}),de=Vue.computed(()=>{if(h.mode==="single"){const Ve=ve.value,it=$e.value;return!isNaN(Ve)&&!isNaN(it)&&Ve!==null&&it!==null&&Ve!==0&&it!==0?[{id:"single-marker",position:{lat:Ve,lon:it},title:"Current position"}]:[]}return K.markers.value}),ge=Vue.computed(()=>h.mode==="single"?!1:de.value.length<h.maxMarkers),ve=Vue.ref(null),$e=Vue.ref(null);function Qe(){const Ve=document.querySelector(".k-form");if(!Ve)return{lat:null,lon:null};const it=Ve.querySelector('input[name*="latitude"]'),nt=Ve.querySelector('input[name*="longitude"]');return{lat:it?parseFloat(it.value):null,lon:nt?parseFloat(nt.value):null}}Vue.onMounted(async()=>{if(h.mode==="multi")try{await K.fetchMarkers()}catch(Ve){console.error("Failed to load markers:",Ve)}else if(h.mode==="single"){const Ve=Qe();ve.value=Ve.lat,$e.value=Ve.lon,!isNaN(Ve.lat)&&!isNaN(Ve.lon)&&Ve.lat!==0&&Ve.lon!==0&&(l.value={lat:Ve.lat,lon:Ve.lon});const it=document.querySelector(".k-form");if(it){it.addEventListener("input",Vt=>{if(Vt.target.name&&(Vt.target.name.includes("latitude")||Vt.target.name.includes("longitude"))){const qi=Qe();ve.value=qi.lat,$e.value=qi.lon}});const nt=it.querySelector('input[name*="latitude"]'),ji=it.querySelector('input[name*="longitude"]');if(nt&&ji){const Vt=new MutationObserver(()=>{const Dt=Qe();(Dt.lat!==ve.value||Dt.lon!==$e.value)&&(ve.value=Dt.lat,$e.value=Dt.lon)});Vt.observe(nt,{attributes:!0,attributeFilter:["value"]}),Vt.observe(ji,{attributes:!0,attributeFilter:["value"]});const qi=setInterval(()=>{const Dt=Qe();(Dt.lat!==ve.value||Dt.lon!==$e.value)&&(ve.value=Dt.lat,$e.value=Dt.lon)},500);Vue.onBeforeUnmount(()=>{Vt.disconnect(),clearInterval(qi)})}}}h.value&&h.mode==="multi"&&W(h.value),await Vue.nextTick(),E.value=!0}),Vue.watch([l,le],()=>{h.mode==="multi"&&Se()},{deep:!0}),Vue.watch(()=>[ve.value,$e.value],([Ve,it])=>{h.mode==="single"&&(!isNaN(Ve)&&!isNaN(it)&&Ve!==null&&it!==null&&Ve!==0&&it!==0?Vue.nextTick(()=>{L.value&&L.value.centerOnPosition&&L.value.centerOnPosition(Ve,it)}):(l.value={lat:h.defaultCenter[0],lon:h.defaultCenter[1]},Vue.nextTick(()=>{L.value&&L.value.centerOnPosition&&L.value.centerOnPosition(l.value.lat,l.value.lon)})))});function Ke(){return L.value&&L.value.getCurrentCenter?L.value.getCurrentCenter():{lat:l.value.lat,lon:l.value.lon}}async function Ye(){if(!ge.value||h.mode==="single")return;const Ve=Ke(),it={lat:Ve.lat,lon:Ve.lon||Ve.lng};try{await K.createMarker(it)}catch(nt){console.error("Failed to create marker:",nt)}}async function st(Ve){if(!(!ge.value||h.mode==="single"))try{await K.createMarker({lat:Ve.lat,lon:Ve.lng})}catch(it){console.error("Failed to create marker:",it)}}function wi(Ve){F.value=Ve;const it=de.value.find(nt=>nt.id===Ve);it&&L.value&&L.value.centerOnPosition&&L.value.centerOnPosition(it.position.lat,it.position.lon)}async function Pi({markerId:Ve,position:it}){if(h.mode==="single"){const nt=document.querySelector(".k-form");if(nt){const ji=nt.querySelector('input[name*="latitude"]'),Vt=nt.querySelector('input[name*="longitude"]');ji&&Vt&&(ji.value=it.lat,Vt.value=it.lng,ji.dispatchEvent(new Event("input",{bubbles:!0})),Vt.dispatchEvent(new Event("input",{bubbles:!0})),ve.value=it.lat,$e.value=it.lng)}}else try{await K.updateMarkerPosition(Ve,{lat:it.lat,lon:it.lng})}catch(nt){console.error("Failed to update marker position:",nt)}}function Hr(Ve){if(h.mode==="single")return;const it=de.value.find(nt=>nt.id===Ve);it&&it.panelUrl&&(window.top.location.href=it.panelUrl)}async function rr(Ve){if(h.mode!=="single"&&confirm("Supprimer ce marqueur ?"))try{await K.deleteMarker(Ve),F.value===Ve&&(F.value=null)}catch(it){console.error("Failed to delete marker:",it)}}function hn(Ve){L.value&&L.value.centerOnPosition&&L.value.centerOnPosition(Ve.lat,Ve.lon)}return{center:l,zoom:le,markers:de,selectedMarkerId:F,mapReady:E,mapPreview:L,canAddMarker:ge,loading:K.loading,error:K.error,handleAddMarker:Ye,handleMapClick:st,handleSelectMarker:wi,handleMarkerMoved:Pi,handleLocationSelect:hn,deleteMarker:rr,editMarker:Hr}}};var Ym=function(){var w=this,E=w._self._c;return E("k-field",w._b({staticClass:"k-map-editor-field"},"k-field",w.$props,!1),[E("div",{staticClass:"map-editor-container"},[E("div",{staticClass:"map-content",class:{"single-mode":w.mode==="single"}},[w.mode==="multi"?E("MarkerList",{attrs:{markers:w.markers,"selected-marker-id":w.selectedMarkerId,"max-markers":w.maxMarkers},on:{"add-marker":w.handleAddMarker,"select-marker":w.handleSelectMarker,"edit-marker":w.editMarker,"delete-marker":w.deleteMarker,"select-location":w.handleLocationSelect}}):w._e(),E("div",{staticClass:"map-preview-container"},[w.mapReady?E("MapPreview",{ref:"mapPreview",attrs:{center:w.center,zoom:w.zoom,markers:w.markers,"selected-marker-id":w.selectedMarkerId},on:{"marker-moved":w.handleMarkerMoved,"map-click":w.handleMapClick,"marker-click":w.handleSelectMarker,"marker-dblclick":w.editMarker}}):w._e()],1)],1)])])},Jm=[],Qm=No(Km,Ym,Jm,!1,null,null);const eg=Qm.exports;window.panel.plugin("geoproject/map-editor",{fields:{"map-editor":eg}})})();